/* Калькулятор АП-Порте — интерфейс менеджера, стиль B (монохром, как логотип) */
:root {
  --ink: #111111;
  --ink-2: #444444;
  --ink-3: #5c5c5c;
  --line: #e2e2e2;
  --line-2: #bbbbbb;
  --paper: #ffffff;
  --paper-2: #fafafa;
  --warn-bg: #fff4e5;
  --warn: #8a4b00;
  --err-bg: #fdecec;
  --err: #9c1c1c;
  --font: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: "IBM Plex Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--ink); }

/* шапка */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; padding: 0 24px; min-height: 68px;
  border-bottom: 2px solid var(--ink); position: sticky; top: 0; background: var(--paper); z-index: 20; }
.logo { height: 52px; width: auto; display: block; }
.systems { display: flex; flex-wrap: wrap; gap: 0 22px; flex: 1 1 auto; }
.systems button { height: 66px; border: 0; background: transparent; padding: 0; color: var(--ink-2); cursor: pointer; font-size: 15px; }
.systems button[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -4px 0 var(--ink); }
.systems button:hover { color: var(--ink); }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn { height: 40px; padding: 0 14px; border: 1px solid var(--ink); background: var(--paper); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { background: #f2f2f2; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #333; }
.btn.icon { width: 40px; padding: 0; }
.btn.small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.file-btn input { display: none; }

/* раскладка */
.layout { display: flex; flex-wrap: wrap; min-height: calc(100vh - 70px); }
.form { flex: 1 1 520px; max-width: 640px; min-width: 0; padding: 22px 28px 60px; border-right: 2px solid var(--ink); }
.result { flex: 999 1 560px; min-width: 0; padding: 22px 28px 60px; background: var(--paper-2); }
.form.wide { max-width: none; }

/* разделы формы */
.sec { margin-bottom: 26px; }
.sec h2 { margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  border-bottom: 1px solid var(--ink); padding-bottom: 7px; }
.grid { display: grid; gap: 14px 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; margin-top: 12px; }
.sec > .grid:first-of-type { margin-top: 0; }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span.lbl { font-size: 12.5px; color: var(--ink-3); }
.field input[type=text], .field input[type=tel], .field input[type=email], .field input[type=password], .field input[type=number], .field select, .inline input, .inline select {
  height: 36px; border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 0 2px; min-width: 0; width: 100%; border-radius: 0; }
.field input.big { font-size: 21px; font-weight: 300; }
.field select:disabled, .field input:disabled { color: #8a8a8a; border-bottom-color: var(--line-2); }
.field input:focus, .field select:focus, .inline input:focus, .inline select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 2px; }
.field .unit { display: flex; align-items: center; gap: 6px; }
.field .unit span { color: var(--ink-3); font-size: 13px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14.5px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check input { width: 19px; height: 19px; accent-color: var(--ink); flex: none; }
.check.disabled { color: #8a8a8a; cursor: default; }
.opt-row { display: flex; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.opt-row > span { flex: 1 1 auto; }
.opt-row input, .opt-row select { height: 34px; border: 0; border-bottom: 1px solid var(--ink); background: transparent; }
.opt-row input { width: 90px; text-align: right; }
.opt-row select { max-width: 60%; }
.seg { display: flex; flex-wrap: wrap; border: 1px solid var(--ink); }
.seg button { flex: 1 1 0; height: 40px; border: 0; border-left: 1px solid var(--ink); background: var(--paper); cursor: pointer; padding: 0 12px; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.note { font-size: 12.5px; color: var(--ink-3); margin: 6px 0 0; }
textarea { width: 100%; border: 1px solid var(--ink); padding: 9px; resize: vertical; min-height: 58px; background: var(--paper); }

/* двери */
.door-tabs { display: flex; flex-wrap: wrap; border: 1px solid var(--ink); align-self: flex-start; margin-bottom: 12px; }
.door-tabs button { height: 36px; min-width: 52px; border: 0; border-left: 1px solid var(--ink); background: var(--paper); cursor: pointer; padding: 0 12px; }
.door-tabs button:first-child { border-left: 0; }
.door-tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.door-size { font-weight: 600; margin: 4px 0 12px; }
.band { border: 1px solid var(--line-2); padding: 12px 14px; margin-top: 12px; background: var(--paper); }
.band-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; margin-bottom: 8px; }
.band-head small { font-weight: 400; color: var(--ink-3); }
.part { border-top: 1px dashed var(--line-2); margin-top: 10px; padding-top: 10px; }
.part-title { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.copy-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 14px; }
.copy-row .field { flex: 1 1 auto; }

/* результат */
.sum-head { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; }
.sketch { flex: 1 1 300px; min-width: 0; }
.sketch img { max-width: 100%; height: auto; display: block; border: 1px solid var(--line); background: #fff; }
.totals { flex: 1 1 240px; display: flex; flex-direction: column; gap: 6px; }
.totals .row { display: flex; justify-content: space-between; font-size: 14px; }
.totals .row span:first-child { color: var(--ink-2); }
.totals .row.last { border-bottom: 1px solid var(--ink); padding-bottom: 8px; }
.totals .cap { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin-top: 6px; }
.totals .grand { font-size: 44px; font-weight: 300; line-height: 1.05; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 26px; border-bottom: 1px solid var(--ink); margin-bottom: 8px; }
.tabs button { height: 42px; border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--ink-2); font-size: 15px; }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -3px 0 var(--ink); }
.group { margin-top: 10px; }
.group-head { display: flex; justify-content: space-between; align-items: center; min-height: 44px; width: 100%;
  border: 0; border-bottom: 1px solid var(--ink); background: transparent; cursor: pointer; padding: 0; text-align: left; font-size: 15.5px; font-weight: 600; }
.group-head small { font-weight: 400; color: var(--ink-3); font-size: 13.5px; }
.spec-row, .spec-head { display: grid; grid-template-columns: minmax(0, 1fr) 190px minmax(140px, 230px) 96px; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--line); font-size: 14px; align-items: baseline; }
.spec-head { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); border-bottom-color: var(--ink); }
.spec-row .sku { font-family: var(--mono); font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.spec-row .qty { font-size: 13px; color: #333; }
.spec-row .sum, .spec-head .sum { text-align: right; }
.spec-row.temp { background: var(--warn-bg); }
.spec-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px solid var(--ink); margin-top: 14px; padding-top: 12px; }
.spec-total span:first-child { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; }
.spec-total span:last-child { font-size: 26px; font-weight: 500; }
pre.construction { white-space: pre-wrap; font-family: var(--font); font-size: 14px; line-height: 1.55; margin: 8px 0 0; }
.client-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
.client-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.client-table tr.section td { background: var(--ink); color: #fff; font-weight: 600; }
.client-table tr.title td { font-size: 20px; font-weight: 500; border-bottom: 2px solid var(--ink); }
.client-table td:last-child { text-align: right; }
.error-box { background: var(--err-bg); color: var(--err); border-left: 4px solid var(--err); padding: 14px 16px; font-size: 15px; line-height: 1.45; }
.warn-box { background: var(--warn-bg); color: var(--warn); border-left: 4px solid var(--warn); padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.files { margin: 10px 0 0; padding: 12px 14px; border: 1px solid var(--ink); background: var(--paper); font-size: 14px; }
.files a { margin-right: 14px; }
.files code { font-family: var(--mono); font-size: 12.5px; }
.empty { color: var(--ink-3); padding: 30px 0; }

/* служебное */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: 440px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; font-size: 14px; line-height: 1.4; white-space: pre-line; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.warn { background: #6b3a00; }
.toast.err { background: var(--err); }
.busy { position: fixed; top: 74px; right: 18px; background: var(--ink); color: #fff; padding: 6px 12px; font-size: 13px; z-index: 40; }
dialog { border: 2px solid var(--ink); padding: 0; max-width: min(960px, 94vw); width: 94vw; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg h3 { margin: 0; font-size: 18px; font-weight: 600; }
.dlg .bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.dlg input[type=text], .dlg input[type=tel], .dlg input[type=email] { height: 38px; border: 0; border-bottom: 1px solid var(--ink); width: 100%; }
.kit-list { max-height: 60vh; overflow: auto; border-top: 1px solid var(--ink); }
.kit-item { display: grid; grid-template-columns: 170px 110px 100px minmax(0, 1fr); gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer; font-size: 14px; width: 100%; text-align: left; background: transparent; border-left: 0; border-right: 0; border-top: 0; }
.kit-item:hover, .kit-item:focus { background: #f2f2f2; outline: none; }
.radio-row { display: flex; gap: 18px; }
.settings-block { margin-bottom: 26px; }
.settings-block .row { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; }
.settings-block .row .field { flex: 1 1 auto; }
.path { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .top { padding: 0 14px; }
  .form, .result { padding: 18px 16px 40px; border-right: 0; }
  .grid.g3, .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec-row, .spec-head { grid-template-columns: minmax(0, 1fr) 100px 80px; }
  .spec-row .sku, .spec-head .sku { display: none; }
  .kit-item { grid-template-columns: 1fr; }
}
.client-table td[colspan] { text-align: left; }
.client-table tr.row td[colspan] { font-style: italic; color: var(--ink-2); }
@media (max-width: 760px) {
  .top { position: static; }
  .systems button { height: 46px; }
}

/* заставка при запуске */
.splash { position: fixed; inset: 0; background: #fff; z-index: 100; display: flex; align-items: center; justify-content: center; }
.splash.hide { opacity: 0; transition: opacity .25s; pointer-events: none; }
.splash-box { border: 2px solid #000; padding: 26px 36px; display: flex; flex-direction: column; align-items: center; gap: 10px; background: #fff; }
.splash-box img { height: 260px; width: auto; }
.splash-title { font-size: 16px; font-weight: 600; margin-top: 8px; }
.splash-bar { width: 300px; height: 6px; background: #fff; overflow: hidden; position: relative; }
.splash-bar span { position: absolute; top: 0; bottom: 0; width: 35%; background: #235C78; animation: splash-run 1.1s ease-in-out infinite; }
@keyframes splash-run { 0% { left: -35%; } 100% { left: 100%; } }
.splash-text { color: #666; font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .splash-bar span { animation: none; left: 0; width: 100%; } }
.dlg .error-box { white-space: pre-line; margin: 8px 0; font-size: 14px; padding: 10px 12px; }
.dlg textarea { border: 1px solid var(--line, #ccc); padding: 8px; }
.sec .note + .grid { margin-top: 14px; }

/* --- роли (v6.00) */
[hidden] { display: none !important; }
.top-extra { display: contents; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
body.client .form { max-width: 600px; }
@media (max-width: 760px) {
  .top-actions { width: 100%; padding-bottom: 10px; }
  .top-actions .btn { flex: 1 1 auto; justify-content: center; }
  body.client .actions .btn { flex: 1 1 100%; justify-content: center; min-height: 48px; font-size: 16px; }
  .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec-row { grid-template-columns: 1fr auto !important; }
  .spec-row .sku, .spec-row .qty, .spec-head .sku, .spec-head span:nth-child(3) { display: none; }
  .client-table td { font-size: 14px; }
  dialog { width: calc(100vw - 24px); max-width: none; margin: auto; }
}
.components { margin-top: 6px; }
.comp-info { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 0 0 18px; font-size: 15px; }
.comp-info dt { color: var(--ink-2); }
.comp-info dd { margin: 0; }
.comp-group { margin-bottom: 18px; }
.comp-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; border-bottom: 2px solid var(--ink); padding: 6px 0; }
.comp-head small { font-weight: 400; color: var(--ink-2); }
.comp-row { display: grid; grid-template-columns: 1fr 150px 70px; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line, #ddd); font-size: 15px; }
.comp-row .size, .comp-row .qty { text-align: right; white-space: nowrap; }
@media (max-width: 760px) {
  .comp-row { grid-template-columns: 1fr auto; }
  .comp-row .size { grid-column: 1; text-align: left; color: var(--ink-2); font-size: 14px; }
  .comp-row .qty { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
}

/* v6.03: вкладка двери, раздельная прокрутка параметров и результата */
.sketch.one img { max-height: 420px; width: auto; max-width: 100%; margin: 0 auto; display: block; }
.door-view .door-size { margin: 4px 0 12px; }
@media (min-width: 1100px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .top { position: static; flex: none; }
  .layout { flex: 1 1 auto; min-height: 0; flex-wrap: nowrap; overflow: hidden; }
  .form, .result { overflow-y: auto; overscroll-behavior: contain; }
  .result { flex-basis: 480px; }
}
