  :root {
    --bg: #F2F7F8;
    --surface: #FFFFFF;
    --ink: #0C2A33;
    --muted: #4F6D77;
    --line: #D3E1E5;
    --accent: #087A8E;
    --accent-ink: #FFFFFF;
    --accent-soft: #D9F0F4;
    --ok: #1B7A4B;
    --ok-soft: #DCF2E5;
    --warn: #9A5200;
    --warn-soft: #FFEFD6;
    --bad: #B3261E;
    --bad-soft: #FDE4E1;
    --f-display: system-ui, sans-serif;
    --f-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
    --f-mono: ui-monospace, Menlo, Consolas, monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0A1B20;
      --surface: #11292F;
      --ink: #E3F1F4;
      --muted: #8FB0B8;
      --line: #21414A;
      --accent: #3CC0D6;
      --accent-ink: #05222A;
      --accent-soft: #12383F;
      --ok: #5BD19A;
      --ok-soft: #12362A;
      --warn: #F0B35A;
      --warn-soft: #3A2B12;
      --bad: #FF8A80;
      --bad-soft: #3D1B18;
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --bg: #0A1B20;
    --surface: #11292F;
    --ink: #E3F1F4;
    --muted: #8FB0B8;
    --line: #21414A;
    --accent: #3CC0D6;
    --accent-ink: #05222A;
    --accent-soft: #12383F;
    --ok: #5BD19A;
    --ok-soft: #12362A;
    --warn: #F0B35A;
    --warn-soft: #3A2B12;
    --bad: #FF8A80;
    --bad-soft: #3D1B18;
    color-scheme: dark;
  }

  * { box-sizing: border-box; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--f-body);
    font-size: 15px;
    line-height: 1.5;
    padding-block: 22px 56px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .wrap { max-width: 720px; margin: 0 auto; display: grid; gap: 28px; }
  .wrap > * { min-width: 0; }

  .eyebrow {
    font: 500 11px/1.4 var(--f-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 10px;
  }
  h1 {
    font: 700 clamp(26px, 7vw, 36px)/1.1 var(--f-display);
    letter-spacing: -0.02em;
    margin: 0 0 12px;
    text-wrap: balance;
  }
  .lede { margin: 0; color: var(--muted); font-size: 16px; max-width: 56ch; }

  h2 {
    font: 600 17px/1.3 var(--f-body);
    margin: 0 0 12px;
    text-wrap: balance;
  }
  section.block { border-top: 1px solid var(--line); padding-top: 20px; }

  /* ввод */
  .input { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 12px; }
  .chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .chips .lbl { font: 500 11px var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  .chip {
    font: 500 13px var(--f-body);
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    cursor: pointer;
  }
  .chip:hover { border-color: var(--accent); color: var(--accent); }
  .chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  textarea {
    width: 100%;
    min-height: 144px;
    resize: vertical;
    font: 400 15px/1.5 var(--f-body);
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }
  textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .btn {
    font: 600 15px var(--f-body);
    background: var(--accent);
    color: var(--accent-ink);
    border: 0;
    border-radius: 8px;
    min-height: 46px;
    padding: 0 18px;
    cursor: pointer;
  }
  .btn:hover { filter: brightness(1.08); }
  .btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); min-height: 40px; font-size: 14px; }
  .hint { margin: 0; font-size: 13px; color: var(--muted); }

  /* что понято */
  figure.cut { margin: 0 0 14px; }
  figure.cut svg { display: block; width: 100%; height: auto; max-width: 420px; margin: 0 auto; }
  .sv-ground { stroke: var(--line); stroke-width: 1.5; }
  .sv-wall { stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; fill: none; }
  .sv-water { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
  .sv-jet { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linecap: round; }
  .sv-dim { stroke: var(--muted); stroke-width: 1; fill: none; }
  .sv-txt { fill: var(--muted); font: 500 12px var(--f-mono); }
  figure.cut figcaption { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }

  .facts { margin: 0; display: grid; }
  .fact {
    display: grid;
    grid-template-columns: minmax(0, 6.2rem) minmax(0, 1fr) auto;
    gap: 4px 12px;
    align-items: baseline;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
  }
  .fact:last-child { border-bottom: 0; }
  .fact dt { color: var(--muted); font-size: 13px; }
  .fact dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
  .tag { font: 500 11px var(--f-mono); letter-spacing: 0.04em; border-radius: 4px; padding: 2px 7px; white-space: nowrap; }
  .tag.found { background: var(--ok-soft); color: var(--ok); }
  .tag.assumed { background: var(--warn-soft); color: var(--warn); }
  .tag.missing { background: var(--bad-soft); color: var(--bad); }

  /* смета */
  .lines { list-style: none; margin: 0; padding: 0; }
  .lines li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .lines .nm { font-weight: 500; }
  .lines .bs { grid-column: 1; font: 400 12px var(--f-mono); color: var(--muted); overflow-wrap: anywhere; }
  .lines .am { grid-row: 1; grid-column: 2; font: 500 14px var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
  .total { display: grid; gap: 6px; padding: 16px 0 6px; }
  .total .sum { font: 500 clamp(26px, 8vw, 34px)/1.1 var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
  .total .meta { color: var(--muted); font-size: 14px; }
  .verdict { margin-top: 10px; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
  .verdict.ok { background: var(--ok-soft); color: var(--ok); }
  .verdict.warn { background: var(--warn-soft); color: var(--warn); }
  .verdict.neutral { background: var(--accent-soft); color: var(--accent); }

  .notice { border-radius: 8px; padding: 12px 14px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }

  /* текстовые документы */
  .doc {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
  }

  /* CRM */
  .crm { display: grid; gap: 14px; }
  .pill { display: inline-block; font: 600 12px var(--f-body); border-radius: 999px; padding: 3px 10px; }
  .pill.hot { background: var(--bad-soft); color: var(--bad); }
  .pill.warm { background: var(--warn-soft); color: var(--warn); }
  .pill.cold { background: var(--accent-soft); color: var(--accent); }
  .steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
  .steps li::marker { color: var(--accent); font-weight: 600; }
  h3 { font: 500 11px var(--f-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 6px 0 4px; }

  footer { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 16px; }
  @media (prefers-reduced-motion: no-preference) {
    .chip, .btn { transition: background-color .15s, border-color .15s, color .15s, filter .15s; }
  }

/* --- дополнения --- */
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.hint.err { color: var(--bad); }
.verdict + .verdict { margin-top: 8px; }
.adjust { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.adjust summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.adjust-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; align-items: end; }
.adjust label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.adjust select, .adjust input[type="number"] { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; min-height: 38px; }
.chks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.chk { display: flex !important; grid-template-columns: none; align-items: center; gap: 6px; color: var(--ink) !important; font-size: 14px !important; }

@media print {
  body.print-kp { background: #fff; padding: 0; }
  body.print-kp header, body.print-kp form, body.print-kp footer,
  body.print-kp #out > section:not(.kp-section), body.print-kp .row { display: none !important; }
  body.print-kp .doc { border: 0; padding: 0; font-size: 13px; color: #000; }
}

/* --- админка прайса --- */
.nav { margin: 12px 0 0; font-size: 14px; }
.nav a { color: var(--accent); }
.admin { display: grid; gap: 28px; align-items: start; }
@media (min-width: 980px) {
  body:has(.admin) .wrap { max-width: 1040px; }
  .admin { grid-template-columns: minmax(0, 1fr) 360px; }
  .preview { position: sticky; top: 16px; }
}
#pform { display: grid; gap: 28px; min-width: 0; }
.plist, .grid-fields { display: grid; }
.prow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 28px;
  grid-template-areas: "l i u" "m m m";
  gap: 2px 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.prow.wide { grid-template-columns: minmax(0, 1fr); grid-template-areas: "l" "i" "m"; }
.prow label { grid-area: l; display: grid; gap: 1px; }
.prow input { grid-area: i; }
.prow .undo { grid-area: u; }
.prow .pm { grid-area: m; font-size: 12px; color: var(--muted); min-height: 0; }
.prow .pm:empty { display: none; }
.pl { font-weight: 500; }
.pu { font: 400 12px var(--f-mono); color: var(--muted); }
.prow input {
  font: 500 14px var(--f-mono); font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px; min-height: 40px; width: 100%; text-align: right;
}
.prow.wide input { font-family: var(--f-body); font-weight: 400; }
.prow.wide input { text-align: left; }
.prow input:focus-visible, .undo:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.prow input[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-soft); }
.prow input[aria-invalid="true"] ~ .pm { color: var(--bad); }
.prow.changed input { border-color: var(--accent); }
.prow.changed .pm { color: var(--accent); }
.undo { border: 0; background: transparent; color: var(--accent); font-size: 18px; line-height: 1; cursor: pointer; width: 28px; height: 28px; border-radius: 6px; }
.undo:hover { background: var(--accent-soft); }
.savebar { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 6px; }
.preview { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.preview .lines li { padding: 7px 0; }
.preview .total .sum { font-size: 24px; }
.preview-city { display: grid; gap: 4px; margin: 10px 0; font-size: 13px; color: var(--muted); }
.preview-city select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; min-height: 38px; }

.model-note{margin:0 0 12px;font-size:13px;color:var(--muted,#5b7078)}

.preview-city { display: grid; gap: 6px; margin: 10px 0; font-size: 13px; color: var(--muted); }
.dd { position: relative; }
.dd-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; font: inherit; font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; min-height: 44px; cursor: pointer; text-align: left; }
.dd-btn:hover, .dd-btn[aria-expanded="true"] { border-color: var(--accent); }
.dd-btn:focus-visible, .dd-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dd-chev { flex: none; color: var(--muted); transition: transform .15s; }
.dd-btn[aria-expanded="true"] .dd-chev { transform: rotate(180deg); }
.dd-panel { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: min(340px, 55vh); overflow-y: auto; overscroll-behavior: contain; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(8, 40, 50, .18); }
.dd-panel[hidden] { display: none; }
.dd-opt { font: inherit; font-size: 15px; color: var(--ink); background: transparent; border: 0; border-radius: 8px; min-height: 42px; padding: 0 12px; text-align: left; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dd-opt.wide { grid-column: 1 / -1; color: var(--muted); border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; margin-bottom: 2px; }
.dd-opt:hover { background: var(--accent-soft); }
.dd-opt[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dd-opt[aria-selected="true"]::after { content: ""; width: 6px; height: 11px; flex: none; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-2px, -2px); }
