/* =====================================================================
   BERDBUILD — деловое оформление «Графит»
   Плиточная компоновка, «таблетки» для кнопок, полей и вкладок,
   сдержанная палитра: графит + один акцент; светлая и тёмная темы
   на одних токенах.
   ===================================================================== */

:root {
  /* поверхности */
  --bg: #e9ebee;            /* фон окна */
  --frame: #f4f5f7;         /* подложка разделов */
  --panel: #ffffff;         /* плитки */
  --panel-2: #f2f3f5;       /* вложенные элементы, поля */
  --soft: #f2f3f5;
  --hover: #f5f6f8;
  --sel: #e9eef7;
  --line: rgba(17, 24, 39, .08);
  --line-2: rgba(17, 24, 39, .14);
  /* текст */
  --ink: #15171a;
  --muted: #6b7280;
  /* основное действие — графит; акцент — сдержанный синий */
  --primary: #1f2226; --on-primary: #ffffff; --primary-hover: #33373d;
  --accent: #2d63b8; --accent-soft: #e7eefa;
  --logo-ink: #ffffff;
  /* состояния (приглушённые) */
  --ok: #1f7a4d; --ok-soft: #e4f2ea; --warn: #9a6400; --warn-soft: #fbf0d9;
  --bad: #b42d22; --bad-soft: #fbe7e5; --info: #2d63b8; --info-soft: #e7eefa;
  /* совместимость с прежними именами */
  --navy: var(--primary); --navy-2: #4b5563; --teal: var(--accent); --teal-soft: var(--accent-soft); --amber: #c08a2a;
  /* палитра диаграмм: графит, акцент, стальные серые, приглушённое золото */
  --c1: #1f2226; --c2: #2d63b8; --c3: #8792a3; --c4: #c3cad6; --c5: #c08a2a;
  /* геометрия */
  --radius: 18px; --radius-sm: 12px; --pill: 999px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 8px 24px rgba(17, 24, 39, .05);
  --shadow-lg: 0 18px 50px rgba(17, 24, 39, .18);
  color-scheme: light;
}

/* Графитовая тёмная тема: по системной настройке или выбранная вручную */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161719; --frame: #1d1e21; --panel: #25272b; --panel-2: #2e3035; --soft: #2e3035; --hover: #2c2e33; --sel: #303641;
    --line: rgba(255, 255, 255, .07); --line-2: rgba(255, 255, 255, .13);
    --ink: #eceef1; --muted: #9298a2;
    --primary: #e6e8eb; --on-primary: #17181b; --primary-hover: #ffffff;
    --accent: #86aef0; --accent-soft: rgba(134, 174, 240, .14); --logo-ink: #17181b;
    --ok: #63c993; --ok-soft: rgba(99, 201, 147, .13); --warn: #e3b25a; --warn-soft: rgba(227, 178, 90, .14);
    --bad: #f08a7e; --bad-soft: rgba(240, 138, 126, .14); --info: #86aef0; --info-soft: rgba(134, 174, 240, .14);
    --navy-2: #9aa3af; --amber: #d6a24a;
    --c1: #e6e8eb; --c2: #86aef0; --c3: #7d8696; --c4: #4b525d; --c5: #d6a24a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161719; --frame: #1d1e21; --panel: #25272b; --panel-2: #2e3035; --soft: #2e3035; --hover: #2c2e33; --sel: #303641;
  --line: rgba(255, 255, 255, .07); --line-2: rgba(255, 255, 255, .13);
  --ink: #eceef1; --muted: #9298a2;
  --primary: #e6e8eb; --on-primary: #17181b; --primary-hover: #ffffff;
  --accent: #86aef0; --accent-soft: rgba(134, 174, 240, .14); --logo-ink: #17181b;
  --ok: #63c993; --ok-soft: rgba(99, 201, 147, .13); --warn: #e3b25a; --warn-soft: rgba(227, 178, 90, .14);
  --bad: #f08a7e; --bad-soft: rgba(240, 138, 126, .14); --info: #86aef0; --info-soft: rgba(134, 174, 240, .14);
  --navy-2: #9aa3af; --amber: #d6a24a;
  --c1: #e6e8eb; --c2: #86aef0; --c3: #7d8696; --c4: #4b525d; --c5: #d6a24a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- основа */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 24px; line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -.4px; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; letter-spacing: -.1px; }
h3 { font-size: 13.5px; margin: 0 0 8px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- каркас: верхняя строка + разделы-«таблетки» */
.layout { min-height: 100vh; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 12px 24px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 16px; padding: 4px 14px 4px 4px;
  border-radius: var(--pill); background: var(--panel); box-shadow: var(--shadow); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .1px; margin-top: -2px; }
.logo-mark { color: var(--primary); flex: none; display: block; }
.gsearch { display: flex; align-items: center; gap: 8px; height: 42px; width: min(460px, 38vw); padding: 0 16px;
  border-radius: var(--pill); background: var(--panel); box-shadow: var(--shadow); color: var(--muted); cursor: text; }
.gsearch svg { width: 17px; height: 17px; flex: none; }
.gsearch input { border: none !important; background: none !important; box-shadow: none !important; padding: 0 !important; height: 100%; color: var(--ink); }
.ai-pill { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: var(--pill);
  background: var(--panel); box-shadow: var(--shadow); font-size: 13px; font-weight: 550; white-space: nowrap; }
.ai-pill i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
.icon-btn { width: 42px; height: 42px; flex: none; display: inline-grid; place-items: center; border: none; border-radius: 50%;
  background: var(--panel); box-shadow: var(--shadow); color: var(--ink); cursor: pointer; transition: background .15s; }
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.sm { width: 32px; height: 32px; box-shadow: none; background: var(--panel-2); }
.icon-btn.sm svg { width: 16px; height: 16px; }
.me-pill { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 5px 0 5px; border-radius: var(--pill);
  background: var(--panel); box-shadow: var(--shadow); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--primary); color: var(--on-primary); letter-spacing: .3px; }
.me-pill .who { line-height: 1.15; max-width: 190px; overflow: hidden; }
.me-pill .who b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-pill .who small { font-size: 11px; color: var(--muted); white-space: nowrap; }

.nav { display: flex; align-items: center; gap: 6px; padding: 0 24px 12px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--pill);
  color: var(--muted); font-weight: 550; white-space: nowrap; transition: background .15s, color .15s; }
.nav a:hover { color: var(--ink); background: var(--panel); text-decoration: none; }
.nav a.active { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow); }
.nav svg { width: 16px; height: 16px; flex: none; }
.nav .cnt { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--pill); display: inline-grid; place-items: center;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; }

.main { flex: 1; min-width: 0; width: 100%; max-width: 1560px; margin: 0 auto; padding: 8px 24px 48px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 18px; flex-wrap: wrap; }
.topbar .muted { margin-top: 4px; }
.crumbs { font-size: 12.5px; color: var(--muted); margin: 6px 0 2px; }
.crumbs a { color: var(--muted); }

/* ---------- кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px;
  border-radius: var(--pill); border: 1px solid var(--line-2); background: var(--panel); cursor: pointer;
  font-weight: 550; white-space: nowrap; color: var(--ink); transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.teal { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.teal { color: #10131a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.teal { color: #10131a; } }
.btn.teal:hover { filter: brightness(1.07); }
.btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.btn.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: transparent; }
.btn.bad:hover { background: var(--bad-soft); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn.link { border: none; background: none; color: var(--accent); padding: 0 4px; height: auto; }
.btn svg { width: 15px; height: 15px; }

/* ---------- плитки */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid2 > div > .card + .card { margin-top: 16px; }

/* ---------- поля */
input[type=text], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--panel-2); outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
textarea { height: auto; padding: 10px 14px; line-height: 1.45; }
select { padding-right: 10px; cursor: pointer; }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--panel);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: -3px; }
label.f { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 5px; font-weight: 550; }
.err { color: var(--bad); font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }

/* ---------- метки */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--pill);
  font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.mute { background: var(--panel-2); color: var(--muted); }
.pill.teal { background: var(--accent-soft); color: var(--accent); }
kbd { font: 11px Consolas, monospace; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
  background: var(--panel-2); color: var(--muted); }

/* ---------- показатели */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.kpi .v { font-size: 22px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.4px; line-height: 1.15; }
.kpi .l { font-size: 12px; color: var(--muted); line-height: 1.35; }
.kpi.accent { background: var(--primary); border-color: var(--primary); }
.kpi.accent .v { color: var(--on-primary); }
.kpi.accent .l { color: color-mix(in srgb, var(--on-primary) 70%, transparent); }

/* ---------- вкладки проекта: сегментированная «таблетка» */
.tabs { display: flex; align-items: center; gap: 2px; padding: 5px; margin-bottom: 18px; border-radius: var(--pill);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 14px; border-radius: var(--pill);
  color: var(--muted); white-space: nowrap; font-weight: 550; font-size: 13.5px; transition: background .15s, color .15s; }
.tabs a:hover { color: var(--ink); background: var(--panel-2); text-decoration: none; }
.tabs a.active { background: var(--primary); color: var(--on-primary); }
.tabs a.active .muted { color: color-mix(in srgb, var(--on-primary) 65%, transparent); }
.tabs .sep { flex: none; width: 1px; height: 18px; background: var(--line-2); margin: 0 6px; }
.tabs .cnt { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--pill);
  background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; margin-left: 2px; }

/* ---------- таблицы */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.card .tbl-wrap, .modal .tbl-wrap { box-shadow: none; border-radius: var(--radius-sm); }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.t th { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted); font-weight: 600; text-align: left;
  padding: 11px 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line-2); }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:last-child td { border-bottom: none; }
.t tbody tr.click { cursor: pointer; }
.t th.sortable { cursor: pointer; user-select: none; }
.t th.sortable:hover { color: var(--ink); }
.t tbody tr.click:hover td { background: var(--hover); }
.t tbody tr.sel td { background: var(--sel); }
.t tbody tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.t tr.total td { font-weight: 700; background: var(--panel-2); }
.t tr.sec td { background: var(--panel-2); font-weight: 600; color: var(--muted); font-size: 12px; }
.t .src { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card > table.t th { position: static; background: transparent; }
.conf { display: flex; align-items: center; gap: 7px; }
.conf .bar { width: 48px; height: 6px; border-radius: var(--pill); background: var(--panel-2); overflow: hidden; }
.conf .bar span { display: block; height: 100%; border-radius: var(--pill); }
.conf.hi .bar span { background: var(--ok); }
.conf.mid .bar span { background: var(--amber); }
.conf.lo .bar span { background: var(--bad); }
.conf small { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 32px; }

/* ---------- ведомость + панель позиции */
.vor { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.vor.with-panel { grid-template-columns: minmax(0, 1fr) 440px; }
.vor .tbl-wrap { max-height: calc(100vh - 290px); }
.panel { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
.panel .close { float: right; }
.quote { background: var(--panel-2); border-left: 3px solid var(--accent); padding: 9px 12px; border-radius: 10px; font-size: 12.5px;
  white-space: pre-wrap; word-break: break-word; }
.expl { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 11px 13px; font-size: 12.5px; }
.alt { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; margin-bottom: 8px; background: var(--panel); }
.alt.cur { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.alt .h { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.alt .code { font-weight: 700; font-size: 12.5px; }
.alt .nm { font-size: 12.5px; margin: 4px 0; }
.alt .why { font-size: 12px; color: var(--muted); }
.alt .altcost { margin-top: 6px; font-variant-numeric: tabular-nums; }
.alt .altcost:empty { display: none; }
.cost-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cost-grid div { background: var(--panel-2); border-radius: var(--radius-sm); padding: 9px 11px; }
.cost-grid b { display: block; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.cost-grid span { font-size: 11px; color: var(--muted); }
.sect { margin-top: 18px; }
.sect > h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filters input[type=search] { width: 280px; border-radius: var(--pill); background: var(--panel); border-color: var(--line); }
.filters select { width: auto; border-radius: var(--pill); background: var(--panel); border-color: var(--line); padding: 0 14px; }
details.sect > summary { cursor: pointer; list-style: none; }
details.sect > summary::-webkit-details-marker { display: none; }
details.sect > summary::before { content: "▸ "; color: var(--muted); }
details.sect[open] > summary::before { content: "▾ "; }

/* ---------- бюджет */
.summary td:first-child { width: 70%; }
.summary tr.strong td { font-weight: 700; }
.summary tr.grand td { font-weight: 700; font-size: 15px; background: var(--primary); color: var(--on-primary); border-bottom: none; }
.summary tr.grand td:first-child { border-radius: 10px 0 0 10px; }
.summary tr.grand td:last-child { border-radius: 0 10px 10px 0; }
.hbar { display: grid; grid-template-columns: 220px 1fr 130px; gap: 12px; align-items: center; font-size: 12.5px; margin-bottom: 9px; }
.hbar .track { height: 10px; background: var(--panel-2); border-radius: var(--pill); overflow: hidden; }
.hbar .track span { display: block; height: 100%; background: var(--primary); border-radius: var(--pill); opacity: .85; }
.donut-wrap { display: flex; gap: 22px; align-items: center; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.disclaimer { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12.5px; }
.disclaimer ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- документы */
.drop { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 30px; text-align: center; color: var(--muted);
  background: var(--panel); transition: .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop b { color: var(--ink); }

/* ---------- проекты */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.pcard { cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; display: flex; flex-direction: column; }
.pcard:hover { border-color: var(--line-2); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.pcard h2 { font-size: 16px; }
.pcard .meta { font-size: 12.5px; color: var(--muted); margin: 6px 0 14px; }
.pcard .stats { display: flex; gap: 16px; font-size: 12.5px; }
.pcard .stats b { display: block; font-size: 15px; }
.pcard .total { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.6px; line-height: 1.1; }
.pcard .total small { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.pcard .flags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: auto; padding-top: 14px; }
.progress { height: 8px; border-radius: var(--pill); background: var(--panel-2); overflow: hidden; display: flex; gap: 2px; margin: 14px 0 6px; }
.progress span { display: block; height: 100%; border-radius: var(--pill); }
.progress .p-ok { background: var(--ok); }
.progress .p-warn { background: var(--amber); }
.progress .p-bad { background: var(--bad); }
.kpi .v.t-bad { color: var(--bad); }
.progress .p-info { background: color-mix(in srgb, var(--info) 60%, transparent); }
.progress-legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.progress-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* ---------- баннер внимания */
.alert { display: flex; gap: 14px; align-items: flex-start; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px;
  background: var(--bad-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); }
.alert .ic { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bad);
  color: #fff; font-weight: 800; font-size: 14px; line-height: 1; }
.alert b { color: var(--bad); }
.alert ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
.alert .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* ---------- панель отмеченных позиций */
.selbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px 8px 16px; margin-bottom: 12px;
  border-radius: var(--pill); background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow); font-size: 13px; }
.selbar b { color: var(--on-primary); }
.selbar .btn { height: 30px; }
.selbar .btn.link { color: var(--on-primary); opacity: .8; }

/* ---------- обзор проекта: шаги */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: none; }
.steps .num-c { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--panel-2); color: var(--muted); }
.steps li.done .num-c { background: var(--ok-soft); color: var(--ok); }
.steps li.done b { color: var(--muted); font-weight: 600; }
.steps li.next .num-c { background: var(--primary); color: var(--on-primary); }
.steps li.next { background: var(--panel-2); margin: 4px -10px; padding: 10px; border-radius: var(--radius-sm); border-bottom: none; }

/* ---------- обсуждение позиции */
.thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; max-height: 280px; overflow: auto; }
.tmsg { background: var(--panel-2); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.mention { color: var(--accent); }

/* ---------- администрирование: обращения к ИИ по дням */
.daybars { display: flex; align-items: flex-end; gap: 4px; height: 76px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.daybars > div { flex: 1; max-width: 28px; height: 100%; position: relative; display: flex; align-items: flex-end; }
.daybars span { display: block; width: 100%; background: var(--primary); border-radius: 6px 6px 2px 2px; opacity: .8; }
.daybars i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--bad); border-radius: 6px 6px 2px 2px; }

/* ---------- ИИ-ассистент */
.chat-fab { position: fixed; right: 24px; bottom: 24px; z-index: 40; height: 46px; padding: 0 20px; box-shadow: var(--shadow-lg); }
.chat { position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(440px, calc(100vw - 24px)); z-index: 45; background: var(--panel);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-head > svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.chat-log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 5px; }
.msg.ai { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 5px; }
.msg.ai a { font-weight: 600; }
.msg.err { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--panel); border-radius: var(--pill); padding: 6px 12px; font-size: 12.5px;
  cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chat-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: center; }
.chat-form textarea { resize: none; height: 42px; border-radius: 21px; padding: 10px 16px; }
.chat-note { font-size: 11px; color: var(--muted); padding: 0 16px 12px; }

/* ---------- вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--panel) 70%, transparent), transparent), var(--bg); }
.login .card { width: 100%; max-width: 400px; padding: 32px; border-radius: 26px; box-shadow: var(--shadow-lg); }
.logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; padding: 0 0 22px; color: var(--ink); }
.logo small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.login .btn.primary { height: 44px; }

/* ---------- модальные окна, уведомления, загрузка */
.modal-bg { position: fixed; inset: 0; background: rgba(12, 13, 15, .5); backdrop-filter: blur(3px); display: grid; place-items: center;
  z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 720px; max-height: calc(100vh - 32px); overflow: auto; border-radius: 24px; box-shadow: var(--shadow-lg); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 10px); background: var(--primary); color: var(--on-primary);
  padding: 11px 20px; border-radius: var(--pill); box-shadow: var(--shadow-lg); opacity: 0; transition: .2s; pointer-events: none;
  z-index: 60; max-width: min(560px, calc(100vw - 32px)); font-size: 13.5px; font-weight: 500; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }
.toast.act { pointer-events: auto; display: flex; align-items: center; gap: 14px; }
.toast-act { background: none; border: 1px solid color-mix(in srgb, currentColor 45%, transparent); color: inherit; border-radius: var(--pill);
  padding: 4px 14px; cursor: pointer; font-weight: 650; }
.toast-act:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: s .7s linear infinite; vertical-align: -2px; }
@keyframes s { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 32px; color: var(--muted); }
pre.details { margin: 0; font: 11.5px/1.4 Consolas, monospace; white-space: pre-wrap; word-break: break-word; color: var(--muted); max-width: 520px; }

/* ---------- печать: только содержимое вкладки, светлое оформление, таблицы целиком */
@media print {
  :root, :root[data-theme="dark"] {
    --bg: #fff; --frame: #fff; --panel: #fff; --panel-2: #f2f2f2; --ink: #000; --muted: #444; --line: #bbb; --line-2: #999;
    --soft: #f2f2f2; --hover: #fff; --sel: #fff; --primary: #222; --on-primary: #fff;
    --ok-soft: #fff; --warn-soft: #fff; --bad-soft: #fff; --info-soft: #fff; --accent-soft: #fff; color-scheme: light;
  }
  body { background: #fff; font-size: 11px; }
  .appbar, .nav, .tabs, .filters, .selbar, .chat-fab, .chat, .toast, .crumbs, .alert .acts, .btn, button, input[type=checkbox],
  .drop, #panel, .modal-bg, kbd, .icon-btn { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card, .kpi, .tbl-wrap { box-shadow: none; break-inside: avoid; }
  .tbl-wrap, .vor .tbl-wrap { max-height: none !important; overflow: visible; border: none; }
  .t th { position: static; }
  .vor.with-panel { grid-template-columns: 1fr; }
  a { color: inherit; text-decoration: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ---------- адаптивность */
@media (max-width: 1200px) {
  .vor.with-panel { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
  .grid3 { grid-template-columns: 1fr; }
  .me-pill .who { display: none; }
}
@media (max-width: 900px) {
  .appbar { flex-wrap: wrap; padding: 10px 14px; }
  .gsearch { order: 10; width: 100%; }
  .ai-pill { display: none; }
  .nav { padding: 0 14px 10px; }
  .main { padding: 4px 14px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 1fr; gap: 4px; }
  .filters input[type=search] { width: 100%; }
  .alert { flex-wrap: wrap; }
  .alert .grow { flex-basis: calc(100% - 40px); }
  .alert .acts { margin-left: 40px; }
  .brand small { display: none; }
  .projects { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { min-height: 78px; padding: 12px 14px; }
  .kpi .v { font-size: 18px; }
  .page-head h1, h1 { font-size: 22px; }
}

/* ---------- нет связи с сервером */
.offline { position: sticky; top: 0; z-index: 200; background: var(--bad); color: #fff; text-align: center;
  font-size: 13px; font-weight: 600; padding: 8px 16px; }

/* ---------- индикатор загрузки файлов */
.upbar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 150; width: min(460px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; }
.upbar .progress { margin: 8px 0 0; }

.gsearch .gk { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.gsearch:focus-within .gk { display: none; }
@media (max-width: 900px) { .gsearch .gk { display: none; } }

.t-ok { color: var(--ok); }
.t-bad { color: var(--bad); }

.caps { color: var(--warn, #b7791f); margin-top: 4px; font-weight: 600; }

/* ---------- объём в таблице ведомости */
.qcell { cursor: text; }
.qcell:hover { box-shadow: inset 0 -2px 0 var(--accent); }
.qedit { width: 100px; padding: 4px 8px; text-align: right; }

/* ---------- кто сейчас в проекте */
.presence { margin-top: 4px; color: var(--ink); }
.presence .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }

/* Оценка по рынку: шкала ₽/м² — рыночный диапазон, источники и бюджет */
.small.t-bad { color: var(--bad); }
tr.cur td { background: var(--ok-soft); }
.mkscale { position: relative; height: 26px; margin: 4px 0 14px; background: var(--panel-2); border-radius: var(--pill); }
.mkscale .band { position: absolute; top: 0; bottom: 0; background: var(--ok-soft); border-radius: var(--pill); }
.mkscale .dot { position: absolute; top: 8px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--muted); }
.mkscale .dot.ncs { background: var(--info); }
.mkscale .dot.analogs { background: var(--accent); }
.mkscale .dot.bench { background: var(--ok); }
.mkscale .own { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1px; background: var(--primary); border-radius: 2px; }
