/* ===== Токени ===== */
:root {
  --bg: #EEF0EA;
  --panel: #FAFBF8;
  --ink: #1E2528;
  --muted: #5B666B;
  --line: #CDD2CB;
  --line-soft: #E0E3DD;
  --olive: #4F6630;
  --olive-soft: #E3E9D6;
  --oak: #B5763A;
  --oak-soft: #F3E4D3;
  --elec: #C99410;
  --cold: #2C74B3;
  --hot: #C4503A;
  --grey: #868D91;
  --done: #4F6630;
  --wip: #B5763A;
  --todo: #8E979B;
  --shadow: 0 1px 0 rgba(30, 37, 40, .06);
  --r-s: 4px;
  --r-m: 8px;
  --side: 272px;
  --font: "Golos Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --display: "Unbounded", "Golos Text", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161A1C;
  --panel: #1F2528;
  --ink: #E6E9E4;
  --muted: #9AA4A8;
  --line: #354045;
  --line-soft: #2A3236;
  --olive: #A3BB6E;
  --olive-soft: #2D3A22;
  --oak: #DDA163;
  --oak-soft: #3D2E1F;
  --elec: #E6BE45;
  --cold: #6BA9E0;
  --hot: #E57F67;
  --grey: #9EA6AA;
  --done: #A3BB6E;
  --wip: #DDA163;
  --todo: #7F898D;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--olive); text-underline-offset: 2px; }
a:hover { color: var(--oak); }
:focus-visible { outline: 2px solid var(--oak); outline-offset: 2px; border-radius: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ===== Каркас ===== */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px 14px;
}
.brand-link { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); padding: 4px 6px 14px; }
.brand-mark { width: 52px; color: var(--olive); }
.brand-link b { display: block; font: 700 18px/1.1 var(--display); letter-spacing: .01em; }
.brand-link small { color: var(--muted); font-size: 13px; }

.search input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--bg); outline: none;
}
.search input:focus { border-color: var(--olive); }
.search-results { margin: 6px 0 0; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); max-height: 320px; overflow: auto; }
.search-results a { display: block; padding: 8px 12px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.search-results a:hover, .search-results a:focus { background: var(--olive-soft); }
.search-results small { display: block; color: var(--muted); }
.search-results .empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }

nav { margin-top: 14px; flex: 1; }
.nav-sec { display: block; }
.nav-sec > a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-s);
  text-decoration: none; color: var(--ink); font-weight: 500;
}
.nav-sec > a:hover { background: var(--line-soft); color: var(--ink); }
.nav-sec.active > a { background: var(--olive-soft); color: var(--olive); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; border: 2px solid var(--todo); }
.dot.done { background: var(--done); border-color: var(--done); }
.dot.wip { background: linear-gradient(90deg, var(--wip) 50%, transparent 50%); border-color: var(--wip); }
.nav-subs { margin: 0 0 4px 28px; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.nav-subs a { display: block; padding: 3px 10px; font-size: 14px; color: var(--muted); text-decoration: none; }
.nav-subs a:hover { color: var(--ink); }
.side-foot { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.ghost { background: none; border: 1px solid var(--line); border-radius: var(--r-s); padding: 6px 10px; cursor: pointer; text-align: left; font-size: 14px; color: var(--muted); }
.ghost:hover { color: var(--ink); border-color: var(--muted); }
.file-btn { display: block; }

.main-wrap { min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 16px; align-items: center;
  padding: 12px 32px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.top-meta { margin-left: auto; font-size: 13px; color: var(--muted); }
main { padding: 28px 32px 80px; max-width: 1240px; outline: none; }

/* ===== Типография ===== */
h1 { font: 700 clamp(28px, 3.6vw, 44px)/1.08 var(--display); margin: 0 0 10px; letter-spacing: -.01em; }
h2 { font: 700 22px/1.2 var(--display); margin: 44px 0 6px; letter-spacing: 0; }
h3 { font-size: 17px; margin: 22px 0 6px; }
.lead { font-size: 18px; color: var(--muted); max-width: 70ch; margin: 0 0 8px; }
p { max-width: 75ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* ===== Блокове ===== */
.block { scroll-margin-top: 72px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px 20px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
td.r, th.r { text-align: right; }
tr.total td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--olive-soft) 55%, transparent); }
.table-wrap { overflow-x: auto; }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 10px; background: var(--line-soft); color: var(--muted); white-space: nowrap; }
.tag.est { background: var(--oak-soft); color: var(--oak); }

dl.spec { display: grid; grid-template-columns: max-content 1fr; gap: 6px 22px; margin: 0; }
dl.spec dt { color: var(--muted); }
dl.spec dd { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 16px; padding: 4px 12px; cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--olive); color: var(--panel); border-color: var(--olive); }

.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.check input { margin-top: 5px; accent-color: var(--olive); width: 16px; height: 16px; }
.check.is-done span { color: var(--muted); text-decoration: line-through; }
.check small { display: block; color: var(--muted); }

.notes { margin-top: 48px; }
.notes textarea { width: 100%; min-height: 110px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); resize: vertical; }
.notes small { color: var(--muted); }

.callout { border-left: 3px solid var(--oak); padding: 8px 14px; background: var(--oak-soft); border-radius: 0 var(--r-s) var(--r-s) 0; margin: 12px 0; }
.callout b { display: block; }

/* ===== Табло ===== */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.hero-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; flex-wrap: wrap; }
.hero-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); }
.hero-facts > div { padding: 14px 16px; border-right: 1px solid var(--line-soft); }
.hero-facts > div:last-child { border-right: none; }
.hero-facts b { display: block; font: 700 20px/1.2 var(--display); }
.hero-facts span { font-size: 14px; color: var(--muted); }
.progress-list { list-style: none; margin: 0; padding: 0; }
.progress-list li a { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); }
.progress-list li a:hover { color: var(--olive); }
.progress-list .st { margin-left: auto; font-size: 13px; color: var(--muted); }

/* ===== План ===== */
.plan-tools { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 10px 0; font-size: 14px; }
.plan-tools label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.plan-tools input { accent-color: var(--olive); }
.plan-box { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px; }
.plan-svg { width: 100%; height: auto; display: block; }
.coords { position: absolute; right: 14px; bottom: 10px; font-size: 13px; color: var(--muted); background: var(--panel); padding: 2px 8px; border-radius: var(--r-s); border: 1px solid var(--line-soft); }
.detail h3 { margin-top: 0; }
.detail .empty { color: var(--muted); }

.z { stroke-width: 10; cursor: pointer; transition: fill-opacity .12s; }
.z:hover, .z.sel { fill-opacity: .55; }
.z.dashed { stroke-dasharray: 40 26; }
.z-kitchen { fill: var(--oak); fill-opacity: .25; stroke: var(--oak); }
.z-bath { fill: var(--cold); fill-opacity: .18; stroke: var(--cold); }
.z-desk { fill: var(--olive); fill-opacity: .25; stroke: var(--olive); }
.z-bed { fill: var(--olive); fill-opacity: .12; stroke: var(--olive); }
.z-aisle { fill: transparent; stroke: var(--grey); }
.z-water { fill: var(--cold); fill-opacity: .28; stroke: var(--cold); }
.z-grey { fill: var(--grey); fill-opacity: .22; stroke: var(--grey); }
.z-elec { fill: var(--elec); fill-opacity: .3; stroke: var(--elec); }
.z-heat { fill: var(--hot); fill-opacity: .22; stroke: var(--hot); }
.z-air { fill: var(--cold); fill-opacity: .1; stroke: var(--cold); }
.z-cab { fill: var(--line-soft); stroke: var(--muted); }
.z-shell { fill: var(--muted); fill-opacity: .12; stroke: var(--muted); stroke-dasharray: 30 20; }
.z-shell:hover { fill-opacity: .35; }
.z-label { font: 600 64px var(--font); fill: var(--ink); pointer-events: none; }
.z-sub { font: 48px var(--font); fill: var(--muted); pointer-events: none; }
.shell-wall { fill: none; stroke: var(--ink); stroke-width: 22; }
.cab-outline { fill: none; stroke: var(--muted); stroke-width: 14; }
.open { stroke-width: 34; cursor: pointer; }
.open-door { stroke: var(--oak); }
.open-win { stroke: var(--cold); }
.dim-line { stroke: var(--muted); stroke-width: 5; }
.dim-text { font: 54px var(--font); fill: var(--muted); }
.route { fill: none; stroke-width: 22; stroke-linecap: round; stroke-linejoin: round; cursor: pointer; opacity: .9; }
.route:hover { stroke-width: 34; }
.route-cold { stroke: var(--cold); }
.route-hot { stroke: var(--hot); }
.route-grey { stroke: var(--grey); stroke-dasharray: 50 30; }
.route-elec { stroke: var(--elec); }
.route-led { stroke: #ffa940; stroke-width: 26; filter: drop-shadow(0 0 30px rgba(255,169,64,.7)); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 18px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

.ext-body { fill: var(--panel); stroke: var(--ink); stroke-width: 16; }
.ext-wheel { fill: var(--ink); opacity: .85; }
.ext-hub { fill: var(--muted); }
.ext-ground { stroke: var(--muted); stroke-width: 10; }
.ext-pillar { stroke: var(--line); stroke-width: 10; stroke-dasharray: 40 30; }
.ext-line { fill: none; stroke: var(--muted); stroke-width: 10; }
.z-door { fill: var(--oak); fill-opacity: .12; stroke: var(--oak); }
.z-window { fill: var(--cold); fill-opacity: .25; stroke: var(--cold); }
.ext-svg .z { stroke-width: 12; }

/* ===== Схеми ===== */
.schema-svg { width: 100%; height: auto; display: block; }
.n rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.4; transition: stroke .12s; }
.n.main rect { stroke: var(--olive); stroke-width: 2.2; fill: var(--olive-soft); }
.n.bus rect { fill: var(--line-soft); }
.n.load rect { fill: var(--bg); }
.n.proposal rect { stroke-dasharray: 5 4; }
.n text { pointer-events: none; }
.n .t1 { font: 600 13.5px var(--font); fill: var(--ink); }
.n .t2 { font: 12px var(--font); fill: var(--muted); }
.n { cursor: pointer; }
.n.hl rect { stroke: var(--oak); stroke-width: 2.6; }
.n.dim { opacity: .35; }
.e { fill: none; stroke: var(--muted); stroke-width: 1.8; }
.e-hit { fill: none; stroke: transparent; stroke-width: 14; cursor: pointer; }
.e.proposal { stroke-dasharray: 6 5; }
.e.cold { stroke: var(--cold); }
.e.hot { stroke: var(--hot); stroke-width: 2.4; }
.e.grey { stroke: var(--grey); stroke-dasharray: 6 5; }
.e.hl { stroke: var(--oak); stroke-width: 3.4; }
.e.cold.hl { stroke: var(--cold); stroke-width: 3.6; }
.e.hot.hl { stroke: var(--hot); stroke-width: 3.8; }
.e.grey.hl { stroke: var(--ink); stroke-width: 3; }
.e.dim { opacity: .18; }

/* ===== Калкулатори ===== */
.calc { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.ctrl { display: grid; gap: 14px; }
.ctrl label { display: grid; gap: 4px; font-size: 14px; }
.ctrl label span { display: flex; justify-content: space-between; }
.ctrl output { font-weight: 600; font-variant-numeric: tabular-nums; }
.ctrl input[type=range] { width: 100%; accent-color: var(--olive); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.seg button { border: none; background: none; padding: 6px 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--olive); color: var(--panel); }
.result { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; margin-bottom: 14px; }
.result > div { padding: 12px 14px; border-right: 1px solid var(--line-soft); background: var(--panel); }
.result > div:last-child { border-right: none; }
.result b { display: block; font: 700 19px/1.25 var(--display); font-variant-numeric: tabular-nums; }
.result span { font-size: 13px; color: var(--muted); }
.result .neg b { color: var(--hot); }
.result .pos b { color: var(--olive); }
.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 210px minmax(0, 1fr) 70px; gap: 10px; align-items: center; font-size: 14px; }
.bar .track { height: 12px; background: var(--line-soft); border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--olive); border-radius: 6px; }
.bar .fill.season { background: var(--oak); }
.bar em { font-style: normal; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.stack-svg { width: 100%; height: auto; display: block; margin: 10px 0 6px; }
.stack-svg rect { cursor: pointer; }
.stack-svg .st-lbl { font: 12px var(--font); fill: var(--muted); }

/* ===== Бюджет ===== */
.stack { display: flex; height: 28px; border-radius: var(--r-s); overflow: hidden; border: 1px solid var(--line); background: var(--line-soft); margin: 10px 0 6px; }
.stack div { height: 100%; }
.stack-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.stack-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ===== Галерия ===== */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.shot { border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--panel); cursor: zoom-in; text-align: left; padding: 0; }
.shot img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; display: block; }
.shot div { padding: 10px 12px; }
.shot b { display: block; font-size: 15px; }
.shot small { color: var(--muted); }
.viewer { width: min(96vw, 1500px); max-height: 94vh; border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px; background: var(--panel); color: var(--ink); }
.viewer::backdrop { background: rgba(10, 12, 13, .7); }
.viewer-body { overflow: auto; max-height: 80vh; background: #fff; }
.viewer-body img { width: 100%; height: auto; display: block; }
.viewer .close { float: right; }
.viewer p { margin: 8px 0 0; color: var(--muted); }

/* ===== Подсказка ===== */
.tip {
  position: fixed; z-index: 100; max-width: 340px; padding: 10px 12px; pointer-events: none;
  background: var(--ink); color: var(--bg); border-radius: var(--r-m); font-size: 14px; line-height: 1.45;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.tip b { display: block; font-size: 15px; margin-bottom: 2px; }
.tip .k { opacity: .7; }
.tip .row { display: block; }

.status-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); border: 1px solid var(--line); border-radius: 16px; padding: 3px 12px; background: var(--panel); }

/* ===== Адаптивност ===== */
@media (max-width: 1000px) {
  .split, .calc { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .hero-facts, .result { grid-template-columns: 1fr 1fr; }
  .hero-facts > div:nth-child(2), .result > div:nth-child(2) { border-right: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 40; width: 86vw; max-width: 320px; transform: translateX(-102%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .menu-btn { display: inline-block; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-s); padding: 6px 12px; }
  .top { padding: 10px 16px; }
  .top-meta { display: none; }
  main { padding: 20px 16px 60px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 120px minmax(0, 1fr) 56px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .side, .top, .notes, .plan-tools { display: none !important; }
  .app { display: block; }
  main { padding: 0; max-width: none; }
}

.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--olive); }
