/* Кликабельный прототип ИИ-комплектации. Адаптив: ≥1024 — сайдбар проекта
   и две панели; 720–1023 — вкладки лентой; <720 — карточки вместо таблиц,
   нижние шторки вместо модальных окон, закреплённая плашка бюджета. */

:root {
  --bg: #f3f5f8;
  --surface: #fff;
  --surface-2: #f7f9fb;
  --ink: #18212d;
  --muted: #5f6b7a;
  --faint: #8a95a3;
  --line: #e2e7ed;
  --line-strong: #cbd3dd;
  --accent: #2459b3;
  --accent-ink: #1d4a96;
  --accent-soft: #e9f0fb;
  --good: #11743a;
  --good-bg: #e6f5ec;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --crit: #b42318;
  --crit-bg: #fdecea;
  --info: #175cd3;
  --info-bg: #e8f0fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(24, 33, 45, .06), 0 6px 18px rgba(24, 33, 45, .06);
  --shadow-lg: 0 12px 40px rgba(24, 33, 45, .22);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --top: 56px;
  --tap: 40px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14.5px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.8px; }
.mono { font-family: var(--mono); font-size: 12.6px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }

/* ── Топбар ───────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--top);
  display: flex; align-items: center; gap: 6px; padding: 0 16px;
  background: #102038; color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; font-size: 15px; margin-right: 14px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(135deg, #4d8af0, #2459b3); font-size: 14px; }
.topnav { display: flex; gap: 2px; }
.topnav a { color: #c5d1e2; padding: 7px 11px; border-radius: 8px; font-size: 14px; }
.topnav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.topnav a.on { background: rgba(255,255,255,.14); color: #fff; }
.topbar .spacer { flex: 1; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px;
  background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.16); border-radius: 9px; cursor: pointer; font-size: 13.5px;
}
.tb-btn:hover { background: rgba(255,255,255,.16); }
.tb-btn .pill { background: #ffd479; color: #3d2c00; border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.menu-btn { display: none; }

/* ── Каркас страниц ──────────────────────────────────────────────── */

.page { max-width: 1240px; margin: 0 auto; padding: 22px 24px 90px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .lead { color: var(--muted); margin: 4px 0 0; max-width: 760px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

.proj { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - var(--top)); }
.pnav {
  position: sticky; top: var(--top); align-self: start; height: calc(100vh - var(--top)); overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px 24px;
}
.pnav .pn-title { padding: 2px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.pnav .pn-title b { display: block; font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.pnav .pn-title span { font-size: 12.5px; color: var(--muted); }
.pnav .grp { margin: 14px 10px 4px; font-size: 11.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); font-weight: 650; }
.pnav a {
  display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 6px 10px; border-radius: 8px;
  color: var(--ink); font-size: 14px; white-space: nowrap;
}
.pnav a:hover { background: var(--surface-2); text-decoration: none; }
.pnav a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.pnav a .n { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700; background: #eef1f5; color: var(--muted); flex-shrink: 0; }
.pnav a.on .n { background: var(--accent); color: #fff; }
.pnav a .n.done { background: var(--good-bg); color: var(--good); }
.pnav a .lb { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pnav a .lb small { display: block; font-size: 11px; line-height: 1.2; color: var(--faint); font-weight: 500; }
.pnav a .cnt { margin-left: auto; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 0 7px; line-height: 19px; }
.cnt.warn { background: var(--warn-bg); color: var(--warn); }
.cnt.crit { background: var(--crit-bg); color: var(--crit); }
.cnt.info { background: var(--info-bg); color: var(--info); }
.cnt.later { background: #eef1f5; color: var(--faint); font-weight: 600; font-size: 10.5px; padding: 0 6px; }
.pmain { min-width: 0; padding: 20px 26px 100px; }

.phead { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.phead .meta { color: var(--muted); font-size: 13.5px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.vchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 2px 10px; vertical-align: middle; margin-left: 8px; }
.vchip.ok { background: var(--good-bg); color: var(--good); }
.vchip.draft { background: var(--warn-bg); color: var(--warn); }
.vchip.none { background: #eef1f5; color: var(--muted); }

.budget {
  min-width: 300px; max-width: 380px; flex: 1 1 300px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; cursor: pointer; text-align: left; display: block; color: inherit;
}
.budget:hover { border-color: var(--line-strong); box-shadow: var(--shadow); text-decoration: none; }
.budget .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.budget .sum { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.budget .of { color: var(--muted); font-size: 12.8px; }
.budget .st { font-size: 12.8px; margin-top: 4px; }
.budget .st.over { color: var(--crit); font-weight: 600; }
.budget .st.ok { color: var(--good); }
.bar { position: relative; height: 8px; border-radius: 5px; background: #e9edf2; overflow: hidden; margin-top: 7px; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--accent); }
.bar i.pend { background: #9ab8e8; }
.bar.over i { background: var(--crit); }
.bar .limit { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }

.dock { display: none; }

/* ── Карточки, сетки, статистика ─────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.card.pad0 { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-h h2, .card-h h3 { margin: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1279px) { .grid.g2.stack-lg { grid-template-columns: minmax(0, 1fr); } }
.tbl td .badge { white-space: normal; line-height: 1.35; padding-top: 2px; padding-bottom: 2px; }
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 15px; }
.stat .l { color: var(--muted); font-size: 12.8px; }
.stat .v { font-size: 21px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .h { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat.crit .v { color: var(--crit); }
.stat.good .v { color: var(--good); }

/* ── Кнопки и поля ───────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 6px 14px;
  border: 1px solid transparent; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--accent-ink); text-decoration: none; }
.btn.sec { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.sec:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--surface); color: var(--crit); border-color: #efc4bf; }
.btn.danger:hover { background: var(--crit-bg); }
.btn.good { background: var(--good); }
.btn.good:hover { background: #0c5c2d; }
.btn.sm { min-height: 30px; padding: 3px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 32px; min-height: 32px; padding: 0; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font: inherit; }
.link:hover { text-decoration: underline; }
.link.warn { color: var(--warn); font-weight: 600; }
.link.crit { color: var(--crit); font-weight: 600; }

.field { margin-bottom: 14px; }
.field > label, .lbl { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.req { color: var(--crit); }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
input[type=text], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 38px; padding: 7px 11px; font: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.field.err input, .field.err select, input.err { border-color: var(--crit); background: #fffafa; }
.field .msg, .msg { font-size: 12.5px; margin-top: 4px; }
.msg.err { color: var(--crit); }
.msg.warn { color: var(--warn); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.inline-num { width: 84px; min-height: 32px; padding: 3px 8px; text-align: right; }
.inline-sel { min-height: 32px; padding: 3px 8px; font-size: 13.5px; min-width: 150px; max-width: 190px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip .c { font-size: 12px; color: var(--muted); }
.chip.on .c { color: var(--accent-ink); }
.chip .x { border: 0; background: none; cursor: pointer; padding: 0 0 0 2px; color: var(--muted); font-size: 16px; line-height: 1; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 240px; max-width: 360px; }

/* ── Бейджи ──────────────────────────────────────────────────────── */

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 20px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.crit { background: var(--crit-bg); color: var(--crit); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.neutral { background: #eef1f5; color: #4a5462; }
.badge.later { background: #eef1f5; color: var(--faint); }

.conf { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.conf i { width: 4px; height: 11px; border-radius: 2px; background: #dfe4ea; }
.conf.c9 i { background: var(--good); }
.conf.c7 i:nth-child(-n+2) { background: #c2a24a; }
.conf.c5 i:first-child { background: var(--crit); }
.conf.c5 { color: var(--crit); }
.conf.ok i { background: var(--good); }

/* ── Баннеры ─────────────────────────────────────────────────────── */

.banner { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; border: 1px solid; }
.banner .ic { font-size: 17px; line-height: 1.25; flex-shrink: 0; }
.banner .bd { flex: 1; min-width: 0; }
.banner .act { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.banner.crit { background: var(--crit-bg); border-color: #f3c6c0; color: #7a1c14; }
.banner.warn { background: var(--warn-bg); border-color: #f0dca8; color: #5f4200; }
.banner.info { background: var(--info-bg); border-color: #cbdcf8; color: #133f8a; }
.banner.good { background: var(--good-bg); border-color: #c6e6d1; color: #0d5a2c; }

/* ── Таблицы (на телефоне — карточки) ───────────────────────────── */

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.8px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.total td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.tbl tr.doubt td { background: #fffbef; }
.tbl tr.doubt td:first-child { box-shadow: inset 3px 0 0 #e0b443; }
.tbl tr.hl td { background: #f1f6ff; }
.tbl .sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.tbl .why { display: block; color: var(--warn); font-size: 12.5px; margin-top: 3px; }
.tbl .acts { text-align: right; white-space: nowrap; width: 1%; }
.tbl .acts .btn { text-align: center; margin: 2px 0; }
.tbl .acts .btn:not(.icon) { white-space: normal; }
.tbl .acts .btns .btn { white-space: nowrap; }

/* Позиции на 900–1199 px (сайдбар + узкий контент) — карточки в две колонки. */
@media (min-width: 900px) and (max-width: 1199px) {
  .tbl.spec thead { display: none; }
  .tbl.spec, .tbl.spec tbody { display: block; width: 100%; }
  .tbl.spec tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 24px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .tbl.spec tr:last-child { border-bottom: 0; }
  .tbl.spec td { border: 0; padding: 2px 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; text-align: right; }
  .tbl.spec td::before { content: attr(data-l); color: var(--muted); font-size: 12.8px; text-align: left; flex-shrink: 0; }
  .tbl.spec td.main { grid-column: 1; grid-row: 1 / span 2; display: block; text-align: left; }
  .tbl.spec td.main::before, .tbl.spec td.acts::before { display: none; }
  .tbl.spec td.acts { grid-column: 1 / -1; justify-content: flex-end; gap: 8px; width: auto; }
  .tbl.spec tr.doubt td:first-child { box-shadow: none; }
  .tbl.spec tr.doubt td { background: none; }
  .tbl.spec tr.doubt { background: #fffbef; box-shadow: inset 3px 0 0 #e0b443; }
  .tbl.spec .prod { justify-content: flex-end; text-align: right; }
}
.tbl-wrap { overflow-x: auto; }
.room-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.room-h h3 { margin: 0; font-size: 15.5px; }
.room-h .dims { font-size: 12.8px; color: var(--muted); }
.room-h .sp { flex: 1; }
.room-h .badge { white-space: normal; line-height: 1.35; padding: 2px 9px; }
.room-h .tot { font-weight: 700; font-variant-numeric: tabular-nums; }

.qty { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fx { border: 1px solid #c9d8f2; background: var(--accent-soft); color: var(--accent-ink); border-radius: 6px; font: italic 600 12.5px/1 Georgia, serif; padding: 4px 6px; cursor: pointer; }
.fx:hover { background: #dbe7fb; }
.prod { display: flex; gap: 9px; align-items: flex-start; min-width: 0; }
.prod .nm { font-size: 13.5px; line-height: 1.35; }

.ctile { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; background: #eef1f5; color: #4a5462; }
.ctile.lg { width: 56px; height: 56px; font-size: 24px; border-radius: 10px; }

/* ── Список проектов ─────────────────────────────────────────────── */

.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.pcard:hover { box-shadow: var(--shadow); }
.pcard h3 { margin: 0; font-size: 16.5px; }
.pcard h3 a { color: var(--ink); }
.pcard .kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13.5px; }
.pcard .kv span:nth-child(odd) { color: var(--muted); }
.next { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: var(--surface-2); border-radius: 9px; padding: 8px 10px; font-size: 13.5px; }
.pcard.new { border-style: dashed; align-items: center; justify-content: center; text-align: center; min-height: 200px; color: var(--muted); }

/* ── Обзор: шаги ─────────────────────────────────────────────────── */

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; background: #eef1f5; color: var(--muted); }
.steps li.done .dot { background: var(--good-bg); color: var(--good); }
.steps li.cur .dot { background: var(--accent); color: #fff; }
.steps .tx { flex: 1; min-width: 0; }
.steps .tx b { display: block; font-size: 14.5px; }
.steps .tx span { color: var(--muted); font-size: 13px; }
.steps li.done .tx b { color: var(--muted); font-weight: 600; }

.hbars .hb { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; padding: 6px 0; font-size: 13.5px; }
.hbars .hb .track { height: 10px; background: #edf0f4; border-radius: 6px; overflow: hidden; }
.hbars .hb .track i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }

/* ── Загрузка ────────────────────────────────────────────────────── */

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 30px 20px;
  border: 2px dashed var(--line-strong); border-radius: 12px; background: var(--surface); cursor: pointer; transition: .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .big { font-size: 30px; color: var(--accent); line-height: 1; }
.drop b { font-size: 16px; }
.file { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.file:last-child { border-bottom: 0; }
.file .ext { width: 40px; height: 46px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 800; text-transform: uppercase; color: #fff; flex-shrink: 0; background: #7b8794; }
.file .ext.xlsx { background: #1d7a46; } .file .ext.csv { background: #3f7f63; } .file .ext.pdf { background: #c0392b; } .file .ext.jpg, .file .ext.png { background: #8e6bbf; }
.file .bd { flex: 1; min-width: 0; }
.file .nm { font-weight: 650; word-break: break-word; }
.stages { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12.8px; color: var(--muted); margin-top: 6px; }
.stages span.ok { color: var(--good); }
.stages span.on { color: var(--accent); font-weight: 600; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Помещения ───────────────────────────────────────────────────── */

.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.room { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.room.bad { border-color: #f0d08a; }
.room .rh { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.room .rh input { font-weight: 650; font-size: 15.5px; border-color: transparent; padding-left: 4px; }
.room .rh input:hover { border-color: var(--line); }
.room .dims { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.room .dims .field { margin: 0; }
.room .dims label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; display: block; }
.room .deps { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; font-size: 13px; }
.room .deps div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }

/* ── Подбор: две панели ──────────────────────────────────────────── */

.pick { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 14px; align-items: start; }
.plist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: sticky; top: calc(var(--top) + 12px); max-height: calc(100vh - var(--top) - 24px); display: flex; flex-direction: column; }
.plist .ph { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 3px; background: #eef1f5; border-radius: 10px; }
.seg button { border: 0; background: none; border-radius: 8px; min-height: 32px; padding: 4px 6px; font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.seg button .c { font-size: 11.5px; opacity: .8; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(24, 33, 45, .12); }
.plist .items { overflow-y: auto; }
.plist .grp { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--faint); font-weight: 650; padding: 10px 12px 4px; }
.pitem { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-left: 3px solid transparent; color: var(--ink); }
.pitem:hover { background: var(--surface-2); text-decoration: none; }
.pitem.on { background: var(--accent-soft); border-left-color: var(--accent); }
.pitem .t { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.35; }
.pitem .t small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.sdot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; background: var(--line-strong); }
.sdot.suggested { background: #6f9be0; box-shadow: 0 0 0 3px #e2ecfb; }
.sdot.accepted, .sdot.replaced { background: var(--good); }
.sdot.none { background: var(--crit); }
.pdetail { min-width: 0; }
.ph-pos { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 12px; }
.opt { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.opt.cur { border: 2px solid var(--accent); padding: 13px; box-shadow: 0 0 0 4px var(--accent-soft); }
.opt .tag { font-size: 11.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.opt.cur .tag { color: var(--accent); }
.opt .nm { font-weight: 650; line-height: 1.35; }
.opt .kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; }
.opt .kv span:nth-child(odd) { color: var(--muted); }
.opt .kv span:nth-child(even) { text-align: right; }
.opt .line { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px dashed var(--line); padding-top: 8px; }
.opt .line b { font-size: 16px; font-variant-numeric: tabular-nums; }
.opt .delta { font-size: 12.5px; font-weight: 700; }
.delta.minus { color: var(--good); } .delta.plus { color: var(--crit); }
.opt ul.why { margin: 0; padding-left: 16px; color: var(--muted); font-size: 12.5px; }
.opt .foot { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Варианты, график ───────────────────────────────────────────── */

.var { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.var.best { border-color: #9fc1f0; box-shadow: 0 0 0 3px var(--accent-soft); }
.var .tot { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tl { display: grid; grid-template-columns: 210px 1fr; gap: 8px 14px; align-items: center; }
.tl .track { position: relative; height: 26px; background: #edf0f4; border-radius: 7px; }
.tl .track i { position: absolute; top: 4px; bottom: 4px; border-radius: 5px; background: var(--accent); opacity: .85; }
.tl .track .today { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--crit); }

/* ── Тур, тост, модальное окно, меню ─────────────────────────────── */

.tour {
  position: fixed; right: 16px; top: calc(var(--top) + 10px); z-index: 60; width: 340px; max-height: calc(100vh - var(--top) - 30px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 14px 16px;
}
.tour ol { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: s; }
.tour li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.tour li:last-child { border-bottom: 0; }
.tour li .m { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; background: #eef1f5; color: var(--muted); }
.tour li.done .m { background: var(--good-bg); color: var(--good); }
.tour li.done .t { color: var(--muted); }
.tour li .t { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); z-index: 90; opacity: 0; pointer-events: none;
  display: flex; gap: 14px; align-items: center; max-width: min(640px, calc(100vw - 24px));
  background: #18212d; color: #fff; border-radius: 11px; padding: 11px 14px 11px 16px; box-shadow: var(--shadow-lg); transition: .2s; font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast button { background: none; border: 0; color: #9cc0ff; font-weight: 700; cursor: pointer; padding: 6px 4px; white-space: nowrap; }

.ov { position: fixed; inset: 0; z-index: 80; background: rgba(16, 24, 36, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.dlg { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; display: flex; flex-direction: column; max-height: 88vh; }
.dlg.wide { max-width: 920px; }
.dlg .dh { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 10px; border-bottom: 1px solid var(--line); }
.dlg .dh h2 { margin: 0; flex: 1; font-size: 17px; line-height: 1.3; }
.dlg .db { padding: 14px 20px; overflow-y: auto; }
.dlg .df { padding: 12px 20px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.x-btn { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); width: 34px; height: 34px; border-radius: 8px; }
.x-btn:hover { background: var(--surface-2); }
.formula { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-family: var(--mono); font-size: 13px; line-height: 1.6; word-break: break-word; }
.formula b { font-family: var(--font); }

.drawer { position: fixed; inset: 0; z-index: 85; background: rgba(16, 24, 36, .45); }
.drawer nav { position: absolute; right: 0; top: 0; bottom: 0; width: min(320px, 86vw); background: var(--surface); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.drawer nav a, .drawer nav button.lnk { display: block; padding: 12px 10px; border-radius: 9px; color: var(--ink); font-size: 15px; text-align: left; background: none; border: 0; cursor: pointer; }
.drawer nav a:hover, .drawer nav button.lnk:hover { background: var(--surface-2); text-decoration: none; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.flow a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--ink); position: relative; }
.flow a:hover { border-color: var(--accent); text-decoration: none; box-shadow: var(--shadow); }
.flow .n { position: absolute; right: 12px; top: 10px; color: var(--faint); font-weight: 700; font-size: 12px; }
.flow .t { font-weight: 650; margin-bottom: 4px; padding-right: 20px; }
.flow .d { color: var(--muted); font-size: 13px; }
.flow .us { margin-top: 8px; font-size: 11.5px; color: var(--accent); font-weight: 700; }
details.help { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; margin-bottom: 14px; }
details.help summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
details.help[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }

/* ── Планшет ─────────────────────────────────────────────────────── */

@media (max-width: 1023px) {
  .proj { grid-template-columns: minmax(0, 1fr); }
  .pnav {
    position: sticky; top: var(--top); z-index: 40; height: auto; overflow-x: auto; overflow-y: hidden; display: flex; gap: 4px;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; scrollbar-width: none;
  }
  .pnav::-webkit-scrollbar { display: none; }
  .pnav .pn-title, .pnav .grp { display: none; }
  .pnav .sep { width: 1px; background: var(--line); margin: 4px 6px; flex-shrink: 0; }
  .pnav a { flex-shrink: 0; min-height: 36px; }
  .pnav a .lb small { display: inline; margin-left: 6px; }
  .pmain { padding: 16px 18px 100px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tour { width: min(360px, calc(100vw - 24px)); }
}
@media (min-width: 1024px) { .pnav .sep { display: none; } }


@media (max-width: 899px) {
  /* Таблица → карточки: каждая строка — блок, подписи из data-l. */
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .tbl.cards tr:last-child { border-bottom: 0; }
  .tbl.cards td { border: 0; padding: 3px 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; text-align: right; }
  .tbl.cards td::before { content: attr(data-l); color: var(--muted); font-size: 12.8px; text-align: left; flex-shrink: 0; }
  .tbl.cards td.main { display: block; text-align: left; font-size: 15px; padding-bottom: 6px; }
  .tbl.cards td.main::before, .tbl.cards td.acts::before, .tbl.cards td[data-l=""]::before { display: none; }
  .tbl.cards td.acts { justify-content: flex-end; padding-top: 8px; gap: 8px; flex-wrap: wrap; width: auto; }
  .tbl.cards tr.doubt td:first-child { box-shadow: none; }
  .tbl.cards td.num { justify-content: space-between; }
  .tbl.cards tr.total td { background: none; }
  .tbl.cards tr.doubt td { background: none; }
  .tbl.cards tr.doubt { background: #fffbef; box-shadow: inset 3px 0 0 #e0b443; }
  .tbl.cards .prod { justify-content: flex-end; text-align: right; }
  .tbl.cards .prod .ctile { display: none; }
}
@media (min-width: 720px) and (max-width: 899px) {
  .tbl.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 24px; }
  .tbl.cards td.main, .tbl.cards td.acts { grid-column: 1 / -1; }
}

@media (max-width: 899px) {
  .pick { grid-template-columns: minmax(0, 1fr); }
  .pick.has-sel .plist { display: none; }
  .pick:not(.has-sel) .pdetail { display: none; }
  .plist { position: static; max-height: none; }
  .back-list { display: inline-flex !important; }
}
.back-list { display: none !important; }

/* ── Телефон ─────────────────────────────────────────────────────── */

@media (max-width: 719px) {
  :root { --top: 52px; }
  body { font-size: 15px; }
  .topbar { padding: 0 10px; }
  .topnav { display: none; }
  .menu-btn { display: inline-flex; }
  .tb-btn .lbl { display: none; }
  .brand { margin-right: 0; }
  .brand .name { display: none; }
  .page { padding: 16px 14px 100px; }
  .pmain { padding: 14px 14px 120px; }
  h1 { font-size: 20px; }
  .phead .budget { display: none; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat .v { font-size: 18px; }
  .row { flex-direction: column; gap: 0; }
  .pcards { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px; }
  .btn { min-height: 42px; }
  .btn.sm { min-height: 36px; }
  .chip { min-height: 36px; }
  .toolbar .search { max-width: none; }
  .tl { grid-template-columns: minmax(0, 1fr); }
  .hbars .hb { grid-template-columns: 96px 1fr 92px; font-size: 12.8px; }

  .inline-sel { max-width: 60vw; min-width: 0; }
  .banner { flex-wrap: wrap; }
  .banner .act { width: 100%; padding-left: 29px; }
  .phead { margin-bottom: 12px; }
  .phead.compact .crumbs, .phead.compact .meta { display: none; }
  .phead.compact h1 { font-size: 17px; }
  .ph-pos { flex-direction: column-reverse; gap: 8px; }
  .ph-pos .btns { align-self: flex-end; }
  .toolbar .btn { margin-left: auto; }

  /* Плашка бюджета — снизу. */
  .dock {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; gap: 12px; align-items: center;
    padding: 9px 14px calc(9px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(24, 33, 45, .08); color: var(--ink);
  }
  .dock:hover { text-decoration: none; }
  .dock .bd { flex: 1; min-width: 0; }
  .dock .sum { font-weight: 700; font-variant-numeric: tabular-nums; }
  .dock .st { font-size: 12.5px; }
  .dock .st.over { color: var(--crit); font-weight: 600; }
  .dock .st.ok { color: var(--good); }
  .dock .bar { margin-top: 4px; }
  .toast { bottom: 84px; left: 12px; right: 12px; max-width: none; transform: translateY(20px); }
  .toast.show { transform: none; }
  #modal:not(:empty) + .toast { bottom: auto; top: calc(var(--top) + 8px); }
  .toast span { flex: 1; }

  /* Модальные окна — нижние шторки. */
  .ov { padding: 0; align-items: flex-end; }
  .dlg, .dlg.wide { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .dlg .dh::before { content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); transform: translateX(-50%); }
  .dlg .dh { position: relative; padding-top: 20px; }
  .dlg .df { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .dlg .df .btn { flex: 1; }
  .tour { left: 8px; right: 8px; width: auto; top: calc(var(--top) + 6px); }
  .opts { grid-template-columns: minmax(0, 1fr); }
}

/* ── Печать: только спецификация ─────────────────────────────────── */

@media print {
  body { background: #fff; font-size: 11px; }
  .topbar, .pnav, .phead .budget, .dock, .toast, .tour, .no-print, .btn, .chips { display: none !important; }
  .proj { display: block; }
  .pmain { padding: 0; }
  .card { border: 0; padding: 0; }
  .print-only { display: block !important; }
  .tbl th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tbl td, .tbl th { padding: 4px 6px; }
}
.print-only { display: none; }
