@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Montserrat Regular"), local("Montserrat-Regular"), url("fonts/Montserrat-Regular.ttf") format("truetype"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap;
  src: local("Montserrat Medium"), local("Montserrat-Medium"), url("fonts/Montserrat-Medium.ttf") format("truetype"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap;
  src: local("Montserrat SemiBold"), local("Montserrat-SemiBold"), url("fonts/Montserrat-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap;
  src: local("Montserrat Bold"), local("Montserrat-Bold"), url("fonts/Montserrat-Bold.ttf") format("truetype"); }

:root {
  color-scheme: light;
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-2: #f7fafa;
  --text: #17292a;
  --muted: #5d6f70;
  --faint: #8b9a9b;
  --border: #dbe4e5;
  --border-strong: #c3d1d2;
  --accent: #0d6f78;
  --accent-ink: #ffffff;
  --accent-weak: #e2f1f1;
  --head: #0b4f57;
  --good: #1b7f47;
  --good-weak: #e1f3e8;
  --warn: #a86b00;
  --warn-weak: #fbf0d9;
  --crit: #b8322a;
  --crit-weak: #fbe5e3;
  --bar: #0d6f78;
  --bar-ext: #7c5cbf;
  --bar-bg: #e6eded;
  --shadow: 0 1px 2px rgba(16, 40, 42, .06), 0 2px 8px rgba(16, 40, 42, .05);
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1717; --surface: #152121; --surface-2: #1a2828; --text: #e3eeee; --muted: #9fb3b3; --faint: #73898a;
    --border: #253636; --border-strong: #345050; --accent: #3fb3b8; --accent-ink: #062022; --accent-weak: #18393a;
    --head: #0a2f33; --good: #4cc483; --good-weak: #173426; --warn: #e2a93b; --warn-weak: #3a2e14; --crit: #f07a70;
    --crit-weak: #3d1d1b; --bar: #3fb3b8; --bar-ext: #a58ae6; --bar-bg: #233434; --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1717; --surface: #152121; --surface-2: #1a2828; --text: #e3eeee; --muted: #9fb3b3; --faint: #73898a;
  --border: #253636; --border-strong: #345050; --accent: #3fb3b8; --accent-ink: #062022; --accent-weak: #18393a;
  --head: #0a2f33; --good: #4cc483; --good-weak: #173426; --warn: #e2a93b; --warn-weak: #3a2e14; --crit: #f07a70;
  --crit-weak: #3d1d1b; --bar: #3fb3b8; --bar-ext: #a58ae6; --bar-bg: #233434; --shadow: 0 1px 2px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Montserrat", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- шапка */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--head); color: #eaf6f6;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: #13838c; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff; flex: none; }
.brand .t1 { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand .t2 { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.top .spacer { flex: 1; }
.top select, .top .btn { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); color: #fff; }
.top select option { color: #111; }
.top .btn:hover { background: rgba(255,255,255,.18); }

nav.tabs {
  position: sticky; top: 50px; z-index: 19; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; gap: 2px; padding: 0 16px; overflow-x: auto; scrollbar-width: thin;
}
nav.tabs button {
  border: 0; background: none; padding: 12px 14px 10px; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1480px; margin: 0 auto; padding: 18px 20px 60px; }
section.tab { display: none; }
section.tab.active { display: block; }

/* ---------- кнопки, поля */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
select, input[type=text], input[type=password], input[type=number], input:not([type]) {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 6px 9px; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input.numin { width: 140px; text-align: right; font-variant-numeric: tabular-nums; }
input.numin.short { width: 90px; }

/* ---------- карточки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .card + .grid2, .grid2 + .card, .kpis + .card, .card + .kpis, .note + .card { margin-top: 16px; }
.card-h { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }

.note { border-radius: var(--r); padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--border); background: var(--surface-2); }
.note.info { background: var(--accent-weak); border-color: transparent; }
.note.warn { background: var(--warn-weak); border-color: transparent; }
.note b { font-weight: 600; }

/* ---------- плитки */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .k-val { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .meter { display: block; width: 100%; }

/* ---------- таблицы */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.tbl th, .tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tbl thead th {
  position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px;
  white-space: nowrap; z-index: 1;
}
.tbl th.n, .tbl td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr.grp td { background: var(--accent-weak); font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.tbl tr.tot td { font-weight: 700; background: var(--surface-2); }
.tbl tr.tot2 td { font-weight: 700; background: var(--accent-weak); }
.tbl tr.click { cursor: pointer; }
.tbl td.wrap { white-space: normal; min-width: 220px; }
.tbl td .sub { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.tbl .sticky1 { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.tbl thead .sticky1 { background: var(--surface-2); z-index: 2; }
.tbl tr.tot .sticky1, .tbl tr.tot2 .sticky1 { background: var(--surface-2); }
.tbl td.daycell { min-width: 74px; }
.tbl td.dim, .tbl span.dim { color: var(--faint); }
.tbl tr.extra td { color: var(--muted); }

.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.b-good { background: var(--good-weak); color: var(--good); }
.b-warn { background: var(--warn-weak); color: var(--warn); }
.b-crit { background: var(--crit-weak); color: var(--crit); }
.b-mute { background: var(--bar-bg); color: var(--muted); }
.src { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 0 5px; border-radius: 4px; vertical-align: 1px;
  background: var(--warn-weak); color: var(--warn); margin-left: 4px; }
.src.eps { background: var(--accent-weak); color: var(--accent); }

/* полоса исполнения: факт (свои + соисполнение) и метка «ожидаемо к дате» */
.meter { display: inline-block; position: relative; height: 8px; background: var(--bar-bg); border-radius: 999px; overflow: visible; min-width: 90px; }
.meter .f1, .meter .f2 { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.meter .f1 { left: 0; background: var(--bar); }
.meter .f2 { background: var(--bar-ext); }
.meter .pace { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .55; border-radius: 1px; }
.meter.over .f1 { background: var(--crit); }
.pctcell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.pctcell .meter { width: 90px; flex: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 8px; border-radius: 4px; margin-right: 5px; vertical-align: 0; }
.legend .ln { display: inline-block; width: 2px; height: 12px; background: var(--text); opacity: .55; margin-right: 5px; vertical-align: -2px; }

/* ---------- график по дням (SVG) */
.chart { width: 100%; height: 260px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 3px 11px; cursor: pointer; font-size: 12.5px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- подробности (боковая панель) */
.drawer-bg { position: fixed; inset: 0; background: rgba(8, 20, 21, .35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--bg); z-index: 41;
  box-shadow: -8px 0 24px rgba(0,0,0,.18); display: flex; flex-direction: column;
}
.drawer .d-head { padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.drawer .d-head .x { margin-left: auto; }
.drawer .d-body { padding: 16px 20px 40px; overflow-y: auto; }
.drawer .d-body .card { box-shadow: none; }

/* ---------- загрузка */
.drop {
  border: 2px dashed var(--border-strong); border-radius: var(--r); padding: 26px; text-align: center; background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-weak); }
.drop b { font-size: 15px; }
.uplist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.uplist li { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.uplist li.ok { border-left: 4px solid var(--good); }
.uplist li.err { border-left: 4px solid var(--crit); }
.uplist li.wait { border-left: 4px solid var(--faint); }
.need { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.need .item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); }
.need .item b { display: block; margin-bottom: 2px; }

ul.notes { margin: 0; padding-left: 18px; }
ul.notes li { margin: 4px 0; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.empty { text-align: center; padding: 40px 20px; }
.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.form-row label { min-width: 160px; color: var(--muted); }
.search { width: 260px; max-width: 100%; }

@media (max-width: 700px) {
  main { padding: 12px 12px 50px; }
  .top { padding: 8px 12px; gap: 10px; }
  nav.tabs { top: 0; position: relative; padding: 0 8px; }
  .kpi .k-val { font-size: 22px; }
  .brand .t2 { max-width: 80vw; }
}
@media print {
  .top, nav.tabs, .no-print { display: none !important; }
  section.tab { display: block !important; break-after: page; }
  body { background: #fff; }
}
