/* Пульт SFERA. Нейтральные тона с холодным синим оттенком — родня сайту (тёмно-синий + циан). */
:root {
  color-scheme: light;
  --page: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #0e1424;
  --ink-2: #48506a;
  --muted: #727a92;
  --line: #e1e5ee;
  --line-2: #cfd5e2;
  --series: #0a86a6;
  --series-wash: rgba(10, 134, 166, 0.10);
  --mark: #0a86a6;
  --c1: #2a78d6;
  --c2: #eb6834;
  --c3: #1baf7a;
  --c4: #eda100;
  --good: #0ca30c;
  --good-ink: #0a6e12;
  --warn: #fab219;
  --warn-ink: #8a5a00;
  --crit: #d03b3b;
  --crit-ink: #b02a2a;
  --off: #a3a9ba;
  --good-bg: #e8f6ea;
  --warn-bg: #fdf3dc;
  --crit-bg: #fbe8e8;
  --shadow: 0 1px 2px rgba(14, 20, 36, 0.05);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0a0b1a;
    --surface: #11132a;
    --surface-2: #161936;
    --ink: #eef0fa;
    --ink-2: #b4bad4;
    --muted: #8189a8;
    --line: #232747;
    --line-2: #30355c;
    --series: #1aa3c4;
    --series-wash: rgba(26, 163, 196, 0.12);
    --mark: #22d3ee;
    --c1: #3987e5;
    --c2: #d95926;
    --c3: #199e70;
    --c4: #c98500;
    --good-ink: #3fcf55;
    --warn-ink: #f6c453;
    --crit-ink: #ff7b7b;
    --off: #555b7a;
    --good-bg: rgba(12, 163, 12, 0.14);
    --warn-bg: rgba(250, 178, 25, 0.14);
    --crit-bg: rgba(208, 59, 59, 0.18);
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0a0b1a;
  --surface: #11132a;
  --surface-2: #161936;
  --ink: #eef0fa;
  --ink-2: #b4bad4;
  --muted: #8189a8;
  --line: #232747;
  --line-2: #30355c;
  --series: #1aa3c4;
  --series-wash: rgba(26, 163, 196, 0.12);
  --mark: #22d3ee;
  --c1: #3987e5;
  --c2: #d95926;
  --c3: #199e70;
  --c4: #c98500;
  --good-ink: #3fcf55;
  --warn-ink: #f6c453;
  --crit-ink: #ff7b7b;
  --off: #555b7a;
  --good-bg: rgba(12, 163, 12, 0.14);
  --warn-bg: rgba(250, 178, 25, 0.14);
  --crit-bg: rgba(208, 59, 59, 0.18);
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; border-radius: 4px; }

.shell { max-width: 1240px; margin: 0 auto; padding: 16px 16px 32px; display: grid; gap: 16px; }
main { display: grid; gap: 16px; }

/* ---- шапка ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--mark); position: relative;
}
.mark::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--mark); }
.top h1 { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 12.5px; }
.sub.stale { color: var(--crit-ink); font-weight: 600; }

.range { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.range button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  color: var(--ink-2); font-size: 13px;
}
.range button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-2); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin: 0;
}

/* ---- вердикт и проблемы ---- */
.verdict { display: grid; gap: 0; overflow: hidden; }
.verdict .head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: 600; }
.verdict.ok .head { background: var(--good-bg); color: var(--good-ink); }
.verdict.warn .head { background: var(--warn-bg); color: var(--warn-ink); }
.verdict.crit .head { background: var(--crit-bg); color: var(--crit-ink); }
.verdict ul { list-style: none; margin: 0; padding: 4px 0; }
.verdict li { display: flex; gap: 10px; align-items: baseline; padding: 7px 16px; border-top: 1px solid var(--line); }
.verdict li:first-child { border-top: 0; }
.verdict li .who { font-weight: 600; white-space: nowrap; }
.verdict li .what { color: var(--ink-2); }

/* Статус: значок + слово, цвет не единственный носитель смысла. */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.st i { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.st.ok i { background: var(--good); }
.st.ok { color: var(--good-ink); }
.st.warn i { background: var(--warn); border-radius: 2px; transform: rotate(45deg) scale(0.85); }
.st.warn { color: var(--warn-ink); }
.st.crit i { background: var(--crit); border-radius: 2px; }
.st.crit { color: var(--crit-ink); }
.st.off i, .st.nodata i { background: transparent; box-shadow: inset 0 0 0 2px var(--off); }
.st.off, .st.nodata { color: var(--muted); }

/* ---- KPI ---- */
.kpis { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 4px; align-content: start; }
.kpi .label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.kpi .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.kpi.hero .value { font-size: 48px; }
.kpi .note { font-size: 12.5px; color: var(--muted); }

/* ---- графики ---- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart { padding: 14px 16px 10px; }
.chart figcaption { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.chart h2 { font-size: 14px; font-weight: 600; }
.hint { color: var(--muted); font-size: 12px; }
.plot { position: relative; height: 200px; }
.plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plot .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.grid line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.base { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.ln { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area { fill: var(--series-wash); }
.dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.endlabel { fill: var(--ink); font-size: 12px; font-weight: 600; }
.cross { stroke: var(--line-2); stroke-width: 1; }
.tableview { grid-column: 1 / -1; color: var(--ink-2); font-size: 13px; }
.tableview summary { cursor: pointer; padding: 2px 0; width: max-content; }
.scroll { overflow-x: auto; margin-top: 8px; }

.tip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); min-width: 140px;
}
.tip .t { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; }
.tip .r b { font-size: 14px; font-variant-numeric: tabular-nums; }
.tip .r .k { width: 12px; height: 2px; background: var(--series); border-radius: 1px; flex: none; }
.tip .r span { color: var(--ink-2); }

/* ---- проверки ---- */
.checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.check { padding: 12px 16px; display: grid; gap: 4px; }
.check .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.check h3 { font-size: 14px; font-weight: 600; }
.check p { color: var(--muted); font-size: 12.5px; }

/* ---- таблица нод ---- */
.group { display: grid; gap: 8px; }
.group > h2 { font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; padding: 0 4px; }
.nodes { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
thead th { border-top: 0; color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr.crit { background: linear-gradient(90deg, var(--crit-bg), transparent 55%); }
tbody tr.warn { background: linear-gradient(90deg, var(--warn-bg), transparent 55%); }
tbody tr.off { color: var(--muted); }
.name b { display: block; font-weight: 600; }
.name small, .cellnote { color: var(--muted); font-size: 12px; display: block; }
.big { font-size: 16px; font-weight: 650; }
.nowrap { white-space: nowrap; }
.cellnote.lossy { color: var(--warn-ink); font-weight: 600; }
.problem { color: var(--ink-2); font-size: 12.5px; max-width: 280px; }
.problem.crit { color: var(--crit-ink); }
.problem.warn { color: var(--warn-ink); }
.spark { width: 120px; height: 30px; display: block; }
.spark .ln { stroke-width: 1.5; }

.meter { display: grid; gap: 4px; min-width: 84px; }
.meter .v { font-weight: 600; }
.meter .bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.meter .bar span { display: block; height: 100%; border-radius: 2px; background: var(--series); }
.meter.warn .bar span { background: var(--warn); }
.meter.crit .bar span { background: var(--crit); }

/* ---- журнал ---- */
.events { padding: 14px 16px; }
.events h2 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.events ol { list-style: none; margin: 0; padding: 0; display: grid; }
.events li { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; }
.events li.crit span { color: var(--crit-ink); }
.events li.warn span { color: var(--warn-ink); }
.events li.ok span { color: var(--good-ink); }

.gate { padding: 40px 16px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.gate h2 { font-size: 20px; }
.gate p { color: var(--ink-2); max-width: 46ch; }
.msg { max-width: 520px; margin: 18vh auto; padding: 0 16px; display: grid; gap: 8px; text-align: center; }
.msg p { color: var(--ink-2); }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; padding: 0 4px; }
.link { background: none; border: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; padding: 0; }
.loading { opacity: 0.55; transition: opacity 0.2s; }

/* ---- узкие экраны: карточки вместо таблицы ---- */
@media (max-width: 900px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi.hero { grid-column: 1 / -1; }
  .charts { grid-template-columns: 1fr; }
  .checks { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { padding: 12px 12px 24px; gap: 12px; }
  .kpi.hero .value { font-size: 44px; }
  .kpi .value { font-size: 24px; }
  .plot { height: 170px; }
  table.nodetable thead { display: none; }
  table.nodetable, table.nodetable tbody { display: block; }
  table.nodetable tr {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 12px; padding: 12px 14px;
    border-top: 1px solid var(--line);
  }
  table.nodetable tbody tr:first-child { border-top: 0; }
  table.nodetable td { padding: 0; border: 0; text-align: left; }
  table.nodetable td.c-name { grid-column: 1 / 3; }
  table.nodetable td.c-status { grid-column: 3; justify-self: end; }
  table.nodetable td.c-spark { grid-column: 1 / -1; }
  table.nodetable td.c-problem { grid-column: 1 / -1; }
  table.nodetable td.c-problem:empty, table.nodetable td.c-spark:empty { display: none; }
  table.nodetable td[data-label]::before {
    content: attr(data-label); display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 2px;
  }
  .spark { width: 100%; height: 34px; }
  .problem { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- вкладки ---- */
.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs a {
  padding: 7px 16px; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px;
}
.tabs a[aria-selected="true"] { background: var(--surface-2); color: var(--ink); font-weight: 650; box-shadow: inset 0 0 0 1px var(--line-2); }
.tabs a:hover { color: var(--ink); }
.tab { display: grid; gap: 16px; }
.tabbody { display: grid; gap: 16px; }
.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---- «сейчас» на вкладке денег ---- */
.nowstrip { display: grid; grid-template-columns: 1fr 1.2fr 1.4fr 1.2fr; gap: 12px; }
.nowc { padding: 12px 16px; display: grid; gap: 6px; align-content: start; }
.nowc h3 { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.big2 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.rows { display: grid; gap: 6px; }
.rows > div { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: 13px; }
.rv { color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }

/* ---- блоки и таблицы ---- */
.block { padding: 14px 16px; display: grid; gap: 10px; }
.blockhead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.blockhead h2 { font-size: 14px; font-weight: 600; }
table.data { font-size: 13px; }
table.data th, table.data td { padding: 8px 10px; white-space: nowrap; }
table.data td:first-child, table.data th:first-child { padding-left: 0; }
table.data tfoot td { font-weight: 650; border-top: 1px solid var(--line-2); }
table.data tr.muted td { color: var(--ink-2); }
table.data tr.neg td { color: var(--crit-ink); }
.tag { margin-left: 6px; font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; }
.two { display: grid; grid-template-columns: 1fr 1.3fr; gap: 12px; }
.facts { margin: 0; display: grid; gap: 0; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.facts > div:first-child { border-top: 0; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.delta { font-size: 12.5px; font-weight: 600; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--crit-ink); }
.notes { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--ink-2); font-size: 13px; max-width: 90ch; }

/* ---- столбики ---- */
.plotwrap { display: grid; gap: 8px; }
.plot.bars { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.s1 { fill: var(--c1); background: var(--c1); }
.s2 { fill: var(--c2); background: var(--c2); }
.s3 { fill: var(--c3); background: var(--c3); }
.s4 { fill: var(--c4); background: var(--c4); }
.bar .hit { fill: transparent; }
.bar.on .seg { opacity: 0.85; }
.bar:focus { outline: none; }
.bar:focus .hit { stroke: var(--series); stroke-width: 1; }
.tip .r .k.s1, .tip .r .k.s2, .tip .r .k.s3, .tip .r .k.s4 { height: 8px; width: 8px; border-radius: 2px; }
.tip .r .k.s1 { background: var(--c1); }
.tip .r .k.s2 { background: var(--c2); }
.tip .r .k.s3 { background: var(--c3); }
.tip .r .k.s4 { background: var(--c4); }
.tip .r.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }

@media (max-width: 900px) {
  .nowstrip { grid-template-columns: 1fr 1fr; }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .top { gap: 10px; }
  .tabs { width: 100%; }
  .tabs a { flex: 1; text-align: center; padding: 8px 6px; }
  .nowstrip { grid-template-columns: 1fr; }
  .plot.bars { height: 180px; }
}
.emptyrow { color: var(--muted); text-align: center; padding: 14px 0 !important; }
