:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #1c2330;
  --muted: #6b7686;
  --line: #dde2ea;
  --accent: #1f4e9c;
  --accent-text: #ffffff;
  --warn: #b42318;
  --warn-bg: #fdecea;
  --mod: #8a5a00;
  --mod-bg: #fff3d6;
  --hover: #eef3fb;
}

/* Тема: по умолчанию как в системе; кнопка в шапке ставит data-theme="light" или "dark". */
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d;
    --panel: #1b212b;
    --text: #e6eaf0;
    --muted: #94a0b0;
    --line: #2c3544;
    --accent: #5b8def;
    --accent-text: #0b1220;
    --warn: #ff8a80;
    --warn-bg: #3a1d1b;
    --mod: #f5c26b;
    --mod-bg: #3a2e12;
    --hover: #232c3a;
  }
}

:root[data-theme="dark"] {
  --bg: #12161d;
  --panel: #1b212b;
  --text: #e6eaf0;
  --muted: #94a0b0;
  --line: #2c3544;
  --accent: #5b8def;
  --accent-text: #0b1220;
  --warn: #ff8a80;
  --warn-bg: #3a1d1b;
  --mod: #f5c26b;
  --mod-bg: #3a2e12;
  --hover: #232c3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0; }
h2 { font-size: 16px; margin-bottom: 8px; }
h3 { font-size: 14px; margin: 12px 0 6px; }

.muted { color: var(--muted); font-weight: normal; }
.pad { padding: 8px 4px; }
.error { color: var(--warn); }
.missing { color: var(--warn); font-style: italic; }

button, select, input[type=search], input[type=number], input[type=text], input[type=password] {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { background: var(--hover); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.1); background: var(--accent); }
button.small { padding: 2px 8px; }
button.danger { color: var(--warn); }
button.add { width: 30px; font-weight: 700; font-size: 16px; line-height: 1; }
button.toggle { border: none; background: none; width: 24px; padding: 0; }

.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; }
.profile-picker { display: flex; align-items: center; gap: 6px; margin-left: 12px; }
.spacer { flex: 1; }
.user { color: var(--muted); }
.link, .link-btn { color: var(--accent); background: none; border: none; padding: 0; text-decoration: none; cursor: pointer; }
form.inline { display: inline; margin: 0; }

.layout {
  display: grid; grid-template-columns: minmax(320px, 5fr) 7fr; gap: 12px;
  padding: 12px 16px; align-items: stretch;
  min-height: calc(100vh - 64px);
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }

.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
#search, #picker-search { width: 100%; margin-bottom: 8px; }

.system-title { font-weight: 700; margin: 12px 0 4px; padding-bottom: 3px; border-bottom: 2px solid var(--line); }
.group-title { font-size: 12px; letter-spacing: .04em; color: var(--muted); margin: 8px 0 2px; }

.row { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-bottom: 1px solid var(--line); }
.row.clickable:hover, .grow.clickable:hover { background: var(--hover); }
.grow { flex: 1; min-width: 0; }
.clickable { cursor: pointer; }
.code { font-size: 12px; color: var(--muted); }

.compose { margin: 2px 0 6px 18px; padding-left: 14px; color: var(--muted); }
.compose[hidden] { display: none; }

.hint { margin: 0 0 8px; font-size: 12px; }
.hint[hidden] { display: none; }

.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

.net { border: 2px solid var(--line); border-radius: 10px; margin-bottom: 12px; background: var(--panel); }
.net.active { border-color: var(--accent); }
.net-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--hover); border-radius: 8px 8px 0 0;
}
.net-title { display: flex; align-items: baseline; gap: 8px; min-width: 150px; }
.net-label { background: var(--mod-bg); color: var(--mod); border-radius: 10px; padding: 1px 9px; font-size: 12px; }
.net-name { flex: 1; min-width: 140px; }
.count { display: flex; align-items: center; gap: 4px; color: var(--muted); }
input.count-input { width: 60px; }
.net-body { padding: 6px 8px 2px; }

.line { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.line-head { border-bottom: none; padding: 6px 8px; }
.line-body { padding: 4px 8px 8px 32px; border-top: 1px solid var(--line); }
.item-row:last-of-type { margin-bottom: 6px; }
.badge { background: var(--mod-bg); color: var(--mod); border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.badge[hidden], button[hidden] { display: none; }
input.qty { width: 52px; text-align: center; }

table.totals { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.totals th, table.totals td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.totals td.num, table.totals th:last-child { text-align: right; }
details > summary { cursor: pointer; font-weight: 600; margin-top: 14px; }

dialog {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text);
  width: min(560px, 94vw); padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .list { max-height: 50vh; overflow: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
dialog fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; }
dialog fieldset label { display: block; padding: 3px 0; }
dialog .row { border: none; }
#export-missing { background: var(--warn-bg); border-radius: 8px; padding: 6px 12px; }
#export-missing[hidden] { display: none; }
#export-missing ul { margin: 4px 0; max-height: 160px; overflow: auto; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  display: flex; flex-direction: column; gap: 12px; width: min(360px, 92vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px;
}
.login-card h1 { font-size: 18px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; }


/* ---------- переключатель продукта ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { border: none; border-radius: 0; background: var(--panel); padding: 6px 14px; font-weight: 600; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: var(--accent); color: var(--accent-text); }
.seg-btn.active:hover:not(:disabled) { background: var(--accent); }

/* ---------- левая панель: шаги ---------- */
.picker { display: flex; flex-direction: column; }
#picker-body { overflow: auto; flex: 1; min-height: 120px; }
.crumbs { display: flex; align-items: center; gap: 8px; min-height: 30px; margin-bottom: 6px; }
.crumb-text { color: var(--muted); font-size: 13px; }
.step-title { font-size: 15px; margin: 6px 0 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  min-height: 108px; padding: 12px 8px; text-align: center; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel);
}
.tile:hover:not(:disabled) { border-color: var(--accent); background: var(--hover); }
.tile .icon { width: 38px; height: 38px; }
.tile-title { font-weight: 600; line-height: 1.2; }
.tile-sub { font-size: 12px; color: var(--muted); }
.icon { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--accent); flex: none; }
.net-head > .icon { width: 24px; height: 24px; }

/* ---------- строки выбора ---------- */
.set { border-bottom: 1px solid var(--line); }
.set > .row { border-bottom: none; }
.pick-row { flex-wrap: wrap; }
.add-btn { padding: 5px 12px; }

.stepper { display: inline-flex; align-items: center; gap: 3px; }
.stepper .step { width: 30px; height: 30px; padding: 0; font-size: 17px; line-height: 1; font-weight: 600; }
input.qty-input { width: 46px; text-align: center; padding: 5px 4px; -moz-appearance: textfield; }
input.qty-input::-webkit-outer-spin-button, input.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- правая панель: сети ---------- */
.solution { min-width: 0; }
.net.collapsed { border-color: var(--line); }
.net.collapsed .net-head { border-radius: 8px; cursor: pointer; }
.net-head { cursor: pointer; }
.net-caret { width: 14px; color: var(--muted); }
.net-title { flex-wrap: wrap; flex: 1; }
.net-summary { font-size: 12px; }
.net .net-name { width: 100%; margin: 4px 0 8px; }
#net-actions { margin: 4px 0 12px; }
#net-actions:empty { margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 20px;
  max-width: 90vw; box-shadow: 0 4px 14px rgba(0,0,0,.3); pointer-events: none;
}
.toast[hidden] { display: none; }

/* ---------- мобильная нижняя панель ---------- */
.mobile-bar { display: none; }
.badge-count:not(:empty) {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-size: 12px; text-align: center;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 8px 8px 76px; }
  body[data-view="picker"] .solution { display: none; }
  body[data-view="solution"] .picker { display: none; }
  #picker-body { overflow: visible; }
  .topbar { position: static; padding: 8px 10px; }
  .topbar h1 { font-size: 15px; width: 100%; }
  .profile-picker { margin-left: 0; }
  .spacer { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile { min-height: 120px; }
  button, .stepper .step { min-height: 40px; }
  .stepper .step { width: 40px; height: 40px; }
  input.qty-input { width: 56px; height: 40px; }
  button.small { min-width: 38px; }
  .mobile-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: var(--panel); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-bar button { flex: 1; border: none; border-radius: 0; padding: 14px 8px; font-weight: 600; }
  .mobile-bar button.active { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
}

.line-head { flex-wrap: wrap; }
.line-head .grow { flex-basis: 140px; }
.topbar .seg { margin-left: 8px; }


/* ---------- кнопки «Назад» и крупные кнопки ---------- */
.back-btn, button.big {
  background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
  font-weight: 400; font-size: 15px; padding: 8px 16px; border-radius: 8px;
}
.back-btn:hover:not(:disabled), button.big:hover:not(:disabled) { background: var(--accent); filter: brightness(1.12); }
.crumbs .back-btn { flex: none; }
.mobile-only { display: none; }
@media (max-width: 900px) { .mobile-only { display: inline-block; margin-top: 8px; } }

#net-actions .tiles { margin-bottom: 8px; }
#net-actions { margin: 4px 0 12px; }

/* ---------- подсказка о составе комплекта ---------- */
.tip {
  position: fixed; z-index: 30; max-width: 380px; padding: 8px 12px; border-radius: 8px;
  background: var(--panel); color: var(--text); border: 1px solid var(--accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); pointer-events: none; font-size: 13px;
}
.tip ul { margin: 6px 0 0; padding-left: 16px; }
.tip-qty { font-weight: 700; }
.tip-code { color: var(--muted); font-size: 12px; }

/* Группы на одной странице: заголовок группы над её списком */
.section-title { margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line, #d0d7e2); }
.section-title:first-child { margin-top: 2px; }

/* Компьютер: страница не прокручивается, у каждой панели своя прокрутка
   (список слева и состав решения справа независимы друг от друга). */
@media (min-width: 901px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .topbar { position: static; flex: 0 0 auto; }
  .layout { flex: 1 1 auto; min-height: 0; overflow: hidden; }
  .layout > .panel { min-height: 0; overflow: auto; }
  .layout > .picker { overflow: hidden; }
  .sol-layout { flex: 1 1 auto; min-height: 0; overflow: hidden; align-items: stretch; }
  .sol-layout .panel { min-height: 0; max-height: none; overflow: auto; }
  #picker-body { overflow: auto; flex: 1 1 auto; min-height: 0; }
  .picker > #search, .picker > .crumbs { flex: 0 0 auto; }
}

/* Окно выбора артикула: заголовки групп */
.picker-group { margin: 12px 0 4px; padding-bottom: 3px; font-size: 14px; border-bottom: 1px solid var(--line); }
.picker-group:first-child { margin-top: 2px; }

/* Внутри сети два поля: основной состав и Auxiliaries */
.net-section { margin-top: 8px; cursor: pointer; min-height: 44px; padding: 4px 8px 6px; border: 1px solid var(--line); border-radius: 8px; }
.net-section.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.section-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.net-section.active { cursor: default; }
.net-section button, .net-section input, .net-section label { cursor: pointer; }
.section-head .grow { flex: 1; }
.aux-mult { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }

.net-title-name { font-weight: 600; margin-left: 4px; overflow-wrap: anywhere; }
.net-title-name:empty { display: none; }

/* ---------- сохранённые решения ---------- */
.solution-label { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog .field { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
dialog .field select, dialog .field input { width: 100%; }
dialog fieldset:disabled { opacity: .6; }
.sol-layout { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(380px, 1.3fr); gap: 10px; padding: 10px; align-items: start; }
.sol-layout .panel { overflow: auto; max-height: calc(100vh - 70px); }
.tree-btn { border: none; background: none; padding: 3px 6px; text-align: left; border-radius: 6px; }
.tree-btn.active { background: var(--accent); color: var(--accent-text); }
.tree-kids { margin-left: 14px; }
details > summary:has(.tree-btn) { font-weight: normal; margin-top: 0; }
.sol-table tbody tr { cursor: pointer; }
.sol-table tbody tr:hover, .sol-table tr.active { background: var(--hover); }
.viewer-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.btn-link { border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; color: inherit; text-decoration: none; }
.btn-link:hover { background: var(--hover); }
button.danger { color: var(--warn); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.tabs button { border: none; border-radius: 6px 6px 0 0; background: none; }
.tabs button.active { background: var(--accent); color: var(--accent-text); }
.v-line ul { margin: 2px 0 8px; padding-left: 20px; }
.v-net { margin-bottom: 14px; }
@media (max-width: 900px) { .sol-layout { grid-template-columns: 1fr; } .sol-layout .panel { max-height: none; } }

/* ---------- единый стиль кнопок ---------- */
.topbar button:not(.link-btn), .btn-link, .viewer-actions button, button.primary {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
}
.topbar button:not(.link-btn):hover:not(:disabled), .btn-link:hover, .viewer-actions button:hover:not(:disabled) {
  background: var(--accent); filter: brightness(1.1);
}
.topbar .seg button { background: var(--panel); color: inherit; border: none; }
.topbar .seg button.active { background: var(--accent); color: var(--accent-text); }
button.danger-fill, .viewer-actions button.danger-fill { background: var(--danger); color: #fff; border-color: var(--danger); }
button.danger-fill:hover:not(:disabled) { background: var(--danger); filter: brightness(1.1); }
:root { --danger: #c42b1c; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.home { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; padding: 60px 16px; }
.home-card {
  display: flex; flex-direction: column; gap: 6px; width: min(340px, 92vw); padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none;
}
.home-card strong { font-size: 18px; color: var(--accent); }
.home-card:hover { background: var(--hover); border-color: var(--accent); }
.home-card[hidden] { display: none; }

.panel-head { margin-bottom: 16px; }

.pw-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(360px, 92vw); }
.pw-wrap .login-card { width: 100%; }

/* ---------- переключатель темы ---------- */
.theme-toggle, .topbar button.theme-toggle {
  background: none; color: var(--muted); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 9px; font-size: 13px; white-space: nowrap;
}
.topbar button.theme-toggle:hover:not(:disabled), .theme-toggle:hover { background: var(--hover); filter: none; color: var(--text); }
.theme-corner { position: fixed; top: 10px; right: 12px; }

#search[hidden], #totals-block[hidden] { display: none; }

/* страница цен */
.prices { max-width: 980px; margin: 0 auto; padding: 16px; }
.price-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 8px; }
.price-controls label, .price-controls .price-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.price-controls input, .price-controls select { min-width: 120px; }
.price-table .num { text-align: right; white-space: nowrap; }
.price-table .set-row { cursor: pointer; font-weight: 600; background: color-mix(in srgb, currentColor 6%, transparent); }
.price-table .sub td { font-weight: 400; }
.price-table .indent { padding-left: 28px; }
.price-table .sum-row td { font-weight: 600; border-top: 1px solid currentColor; }
.price-table tr[hidden] { display: none; }
.price-total { margin-top: 16px; max-width: 360px; margin-left: auto; }
.price-total .tot-row { display: flex; justify-content: space-between; padding: 4px 0; }
.price-total .final { font-size: 1.2em; border-top: 2px solid currentColor; margin-top: 4px; }

.history-actions { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.sol-table tr { cursor: pointer; }

/* цены: одинаковые колонки во всех блоках, сети в рамках */
.price-table { table-layout: fixed; width: 100%; }
.price-table th:nth-child(1), .price-table td:nth-child(1) { width: auto; overflow-wrap: anywhere; }
.price-table th:nth-child(2), .price-table td:nth-child(2) { width: 84px; }
.price-table th:nth-child(3), .price-table td:nth-child(3) { width: 64px; }
.price-table th:nth-child(4), .price-table td:nth-child(4) { width: 118px; }
.price-table th:nth-child(5), .price-table td:nth-child(5) { width: 118px; }
#p-body .v-net { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px;
  background: color-mix(in srgb, var(--accent, #36c) 4%, transparent); }
#p-body .v-net > h3 { margin: 0 0 8px; }
.tabs { background: var(--bg, Canvas); }
.price-controls [hidden] { display: none !important; }

.price-table th:nth-child(6), .price-table td:nth-child(6) { width: 126px; }
.items-table th:nth-child(1), .items-table td:nth-child(1) { width: 90px; }
.items-table th:nth-child(2), .items-table td:nth-child(2) { width: auto; }
.items-table th:nth-child(3), .items-table td:nth-child(3) { width: 64px; }
.items-table th:nth-child(4), .items-table td:nth-child(4), .items-table th:nth-child(5), .items-table td:nth-child(5) { width: 130px; }
.items-table th:nth-child(6), .items-table td:nth-child(6) { width: 150px; }
.price-controls .primary { align-self: end; }

/* кнопки выгрузки в Excel - зелёные */
.btn-excel, .topbar button.btn-excel, .viewer-actions button.btn-excel, a.btn-link.btn-excel {
  background: #1d6f42; border-color: #1d6f42; color: #fff;
}
.btn-excel:hover:not(:disabled), .topbar button.btn-excel:hover:not(:disabled), .viewer-actions button.btn-excel:hover:not(:disabled), a.btn-link.btn-excel:hover {
  background: #155230; border-color: #155230; color: #fff;
}

/* фильтры по папкам */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-items: end; margin-bottom: 8px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.filters label[hidden] { display: none; }
.filters select { width: 100%; }
.sol-table th:last-child, .sol-table td:last-child { text-align: left; }

.price-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 8px; min-height: 34px; }
#v-export { margin-left: auto; order: 99; }

/* ---------- телефон: шапка и таблицы цен ---------- */
@media (max-width: 900px) {
  .topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
  .topbar .home-link { order: 1; white-space: nowrap; }
  .topbar h1 { order: 2; flex: 1 1 auto; width: auto; min-width: 0; margin: 0; }
  .topbar .theme-toggle { order: 3; }
  .topbar .user { order: 4; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar a.link:not(.home-link) { order: 5; }
  .topbar form.inline { order: 6; }
  .topbar .profile-picker { order: 7; flex: 1 1 100%; display: flex; gap: 8px; align-items: center; }
  .topbar .profile-picker select { flex: 1; }
  .topbar .seg { order: 8; flex: 1 1 100%; margin-left: 0; }
  .topbar .seg button { flex: 1; }
  .topbar .solution-label { order: 9; flex: 1 1 100%; max-width: none; }
  .topbar #btn-store, .topbar #btn-export { order: 10; flex: 1 1 0; }
  .topbar label.muted { order: 3; }

  .price-table, .price-table tbody, .price-table tr, .price-table td { display: block; width: auto !important; }
  .price-table thead { display: none; }
  .price-table tr[hidden] { display: none !important; }
  .price-table tr { padding: 6px 2px; border-bottom: 1px solid var(--line); }
  .price-table td { text-align: left !important; padding: 1px 0; border: none; white-space: normal; overflow-wrap: anywhere; }
  .price-table td:empty { display: none; }
  .price-table td:first-child { font-weight: 600; }
  .price-table .item-row td:first-child { font-weight: 400; padding-left: 14px; }
  .price-table td[data-label] { display: inline-block; margin-right: 12px; font-size: 13px; }
  .price-table td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); }
  .items-table td.code-cell { font-weight: 600; display: inline-block; margin-right: 8px; }
  .items-table td.code-cell::before { content: ''; }
  .items-table td.name-cell { display: inline; }
  .price-table .sum-row td:first-child { font-weight: 600; }
  .price-controls { flex-direction: column; align-items: stretch; }
  .price-controls label, .price-controls .price-field, .price-controls input, .price-controls select { width: 100%; }
  .price-controls .seg { display: flex; }
  .price-controls .seg-btn { flex: 1; }
  .price-actions { flex-direction: column; align-items: stretch; }
  .price-actions button, .price-actions a { width: 100%; text-align: center; }
  .filters { grid-template-columns: 1fr 1fr; }
  .viewer-actions #v-export { margin-left: 0; }
}
table.totals.sol-table th:last-child, table.totals.sol-table td:last-child { text-align: left; }
#sol-search { width: 100%; box-sizing: border-box; }
#sol-list { overflow-x: auto; }
@media (max-width: 900px) {
  table.price-table td { border: none; }
}

/* состав и цены: строка таблицы - название, цена за единицу, колонки «в сети / в комплексе / всего» */
.pr-list { border-top: 1px solid var(--line); margin-bottom: 12px; }
.pr-row { display: grid; grid-template-columns: minmax(150px, 1fr) 96px repeat(var(--cols, 1), minmax(120px, 150px));
  gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.pr-head { font-size: 12px; color: var(--muted); }
.pr-head .pr-cell, .pr-head .pr-unit { text-align: right; }
.pr-name { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.pr-code { display: block; font-weight: 400; color: var(--muted); font-size: 12px; white-space: nowrap; }
.pr-unit, .pr-cell { text-align: right; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.pr-cell .q { font-size: 12px; color: var(--muted); }
.pr-cell.empty b { color: var(--muted); font-weight: 400; }
.lbl { display: none; }
.set-entry { cursor: pointer; background: color-mix(in srgb, currentColor 6%, transparent); }
.pr-kids { padding-left: 24px; }
.pr-kids .pr-name { font-weight: 400; }
.pr-kids .pr-unit b, .pr-kids .pr-cell b { font-weight: 500; }
.pr-kids[hidden] { display: none; }
.sum-entry { font-weight: 700; border-top: 1px solid currentColor; }
@media (max-width: 900px) {
  .pr-head { display: none; }
  .pr-row { grid-template-columns: 1fr 1fr; row-gap: 4px; }
  .pr-name { grid-column: 1 / -1; }
  .pr-unit, .pr-cell { align-items: flex-start; text-align: left; }
  .lbl { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
  .pr-kids { padding-left: 12px; }
}

/* контролы менеджера */
.price-root { display: flex; flex-direction: column; }
.price-root > * { order: 5; }
.price-root > .price-controls { order: 1; }
.price-root > .price-actions { order: 3; }
.price-root > .price-bottom { order: 9; }
.pc-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.price-controls { flex-direction: column; align-items: stretch; gap: 10px; }
.price-controls .price-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.pc-adjust { align-items: center; }
.price-controls #p-adjust { min-width: 0; width: 72px; }
.price-controls #p-vat { min-width: 0; width: 90px; }
.pc-row[hidden], .price-field[hidden] { display: none !important; }
@media (max-width: 900px) {
  .price-bottom { flex-direction: column; }
  .price-bottom .save-row { margin-top: 10px; }
  .save-row button { width: 100%; }
  .price-controls label, .price-controls .price-field, .price-controls select { width: auto; }
  .pc-row label { flex: 1; }
  .price-controls #p-vat, .price-controls select { width: 100%; }
  .pc-adjust .seg { flex: 1; }
  .price-controls #p-adjust { width: 80px; flex: none; }
  .price-controls .seg { display: flex; }
}
.price-field .seg { align-self: flex-start; }
.price-root > .price-actions { margin: 0; }
.price-root > .price-actions:not(:has(:not([hidden]))) { display: none; }
.price-root .error:empty { display: none; }
.tot-row { gap: 12px; }
@media (max-width: 900px) { .price-field .seg { align-self: stretch; } .pc-adjust .seg { align-self: auto; } }

.price-bottom { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 8px; }
.price-bottom .price-total { flex: 0 1 380px; }
.price-root.items-mode .price-controls, .price-root.items-mode .save-row { display: none; }
/* подблоки сети */
.sub-block { border-radius: 8px; padding: 8px 10px; margin: 10px 0; }
.sub-block > h4 { margin: 0 0 6px; }
.sub-main { background: color-mix(in srgb, var(--accent, #1e4a9e) 5%, transparent); }
.sub-aux { background: color-mix(in srgb, #d98a00 10%, transparent); }
#p-info:empty { display: none; }
@media (max-width: 900px) {
  .price-bottom { flex-direction: column; align-items: stretch; }
  .price-bottom .price-total { flex: none; }
  .price-bottom .save-row button { width: 100%; }
}
.add-aux { margin: 6px 0 2px; width: 100%; }
.section-head .small.danger { margin-left: 8px; }
.save-row { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.save-row #p-comment { width: 260px; max-width: 100%; box-sizing: border-box; }
@media (max-width: 900px) { .save-row { align-items: stretch; } .save-row #p-comment { width: 100%; } }

/* список решений */
.list-title { margin: 12px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 17px; }
.small-text { font-size: 12px; }
#sol-list { overflow-x: auto; }
.sol-table thead th { position: sticky; top: 0; background: var(--panel, Canvas); z-index: 1; }
#f-reset { width: 100%; margin-top: 8px; }

/* вкладка «Состав»: каждая сеть одной карточкой */
#v-body > .v-net { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; background: color-mix(in srgb, currentColor 3%, transparent); }
#v-body > .v-net > h3 { margin: 0 0 8px; }
.open-constructor { margin: 14px 0 14px; }
.open-constructor a.btn-link { display: inline-block; padding: 7px 14px; font-weight: 600; background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.open-constructor a.btn-link:hover { background: var(--accent); filter: brightness(1.1); }
@media (max-width: 900px) {
  .open-constructor a.btn-link { display: block; text-align: center; padding: 10px 14px; box-sizing: border-box; }
}

/* поле комментария почти до блока итогов, кнопка ниже */
.price-bottom .save-row { flex: 1 1 auto; min-width: 0; margin-right: 16px; }
.price-bottom .save-row #p-comment { width: 100%; }
.price-bottom .save-row button { margin-top: 8px; }
@media (max-width: 900px) { .price-bottom .save-row { margin-right: 0; } }

/* меню выбора вида Excel (администратор) */
.viewer-actions { position: relative; }
.export-menu { position: absolute; right: 0; top: 100%; z-index: 20; display: flex; flex-direction: column; gap: 4px;
  padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel, Canvas); box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.export-menu button { text-align: left; background: transparent; color: inherit; border: none; padding: 8px 12px; white-space: nowrap; cursor: pointer; border-radius: 6px; }
.viewer-actions .export-menu button { background: transparent; color: var(--text); border: none; filter: none; }
.viewer-actions .export-menu button:hover:not(:disabled), .viewer-actions .export-menu button:focus-visible { background: var(--hover); color: var(--text); filter: none; }
@media (max-width: 900px) { .export-menu { left: 0; right: 0; } .export-menu button { white-space: normal; } }
.qty-col { white-space: nowrap; width: 1%; }

/* Справочник */

/* поля процента со стрелками */
.stepper { position: relative; display: inline-flex; align-items: stretch; }
.stepper input { width: 90px; padding-right: 24px; }
.stepper .step-btns { position: absolute; right: 1px; top: 1px; bottom: 1px; display: flex; flex-direction: column; width: 22px; }
.stepper .step-btns button { flex: 1; padding: 0; margin: 0; border: 0; background: transparent; color: var(--muted);
  font-size: 9px; line-height: 1; cursor: pointer; min-height: 0; }
.stepper .step-btns button:hover:not(:disabled) { color: var(--accent); background: var(--hover); filter: none; }

/* прайс-лист и место решения */
#p-list-row { align-items: flex-end; }
#p-list { min-width: 200px; }
#p-cp { min-width: 240px; }
.notice { background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid var(--accent);
  border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.place-dialog { max-width: 420px; width: calc(100vw - 32px); }
.place-dialog .field { display: block; margin: 8px 0; }
.place-dialog select { width: 100%; }
.history-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.history-actions .danger-fill { margin-left: auto; }
.ver-check-cell { width: 28px; text-align: center; }
.history-actions .btn-link[aria-disabled=true], .history-actions button:disabled { opacity: .5; cursor: not-allowed; }
.price-controls .adjust-group { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; align-self: flex-start; }
@media (max-width: 900px) { .price-controls .adjust-group { align-self: stretch; } }
.history-actions .btn-link[aria-disabled=true] { pointer-events: none; }
.cmp-box { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.cmp-box h3, .cmp-box h4 { margin: 4px 0 8px; }
.cmp-finance { margin-top: 12px; }
.cmp-total { font-weight: 600; }
.sol-table tr.cmp-added, .cmp-added { background: rgba(34, 160, 80, .18); }
.cmp-removed { background: rgba(214, 48, 48, .18); }
.cmp-changed { background: rgba(230, 160, 20, .2); }
.cmp-box tr.cmp-added td, .cmp-box tr.cmp-removed td, .cmp-box tr.cmp-changed td { color: var(--text); }
.cmp-added td:nth-child(3) { color: #16803c; font-weight: 600; }
.cmp-removed td:nth-child(3) { color: #c62828; font-weight: 600; }

/* шапка правого блока закреплена при прокрутке */
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.solution .panel-head { position: sticky; top: -12px; z-index: 5; background: var(--panel); margin: -12px -12px 12px; padding: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

.solution .panel-head .complexes { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: auto; }
.solution .panel-head .complexes input { width: 52px; text-align: center; }

.cx-frame { display: inline-flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 8px 0 10px; }
.pr-unit.none { visibility: hidden; }
@media (max-width: 900px) { .pr-unit.none { display: none; } }
.pr-name .badge { white-space: nowrap; margin-left: 6px; display: inline-block; font-weight: 400; }
.pr-name .caret { white-space: nowrap; }

/* список решений: название шире, расположение уже и не переносится */
#sol-list .sol-table th:nth-child(1), #sol-list .sol-table td:nth-child(1) { width: 42%; min-width: 140px; overflow-wrap: anywhere; }
#sol-list .sol-table td.loc-cell { white-space: nowrap; width: 1%; }

/* вкладка «Цены»: внешняя рамка решения -> рамки сетей -> рамки разделов */
.cx-outer { border: 2px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 8px; }
.cx-outer > .cx-head { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.cx-outer > .v-net:last-child { margin-bottom: 0; }
#p-body .sub-block { border: 1px solid var(--line); }
.net-sum { padding-left: 10px; padding-right: 10px; }

#soft-block { margin-top: 12px; }
#soft-block .soft-add { margin-top: 8px; }
#soft-block .free-net { margin-bottom: 12px; }
.free-section { cursor: default; }
.free-section .line .row { border-bottom: none; }
.foreign { color: #c0392b; }
.foreign::after { content: ''; }

/* компьютер: список решений занимает всю оставшуюся высоту панели и прокручивается внутри неё */
@media (min-width: 901px) {
  .sol-layout #list-panel { display: flex; flex-direction: column; overflow: hidden; }
  .sol-layout #list-panel > * { flex: 0 0 auto; }
  .sol-layout #list-panel > #sol-list { flex: 1 1 auto; min-height: 0; overflow: auto; max-height: none; }
}
#f-reset { width: auto; padding: 4px 12px; font-size: 13px; justify-self: start; align-self: flex-start; }
