/* Админка NotchUp (README §393). Цвета графиков — эталонная палитра
   dataviz: три первых категориальных слота, проверены валидатором в обоих
   режимах; бирюзовый на светлом < 3:1 — поэтому подписи у линий и таблица. */
.viz-root {
  color-scheme: light;
  --page: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e0da;
  --grid: #e9e7e1;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #d62828;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --bar-soft: #86b6ef;
  --critical: #d03b3b;
  --good: #0ca30c;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: #34332f;
    --grid: #2b2a27;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --bar-soft: #256abf;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: #f4f3f0; }
@media (prefers-color-scheme: dark) { body { background: #121211; } }
.viz-root { min-height: 100vh; background: var(--page); color: var(--text-primary);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; }
.boot { padding: 40px; color: var(--text-muted); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(380px, 100%); padding: 28px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 18px; color: var(--text-secondary); }
.login input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.login input:focus { outline: 2px solid var(--series-1); outline-offset: 1px; }
.login button { width: 100%; height: 44px; margin-top: 12px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700; }
.login button:disabled { opacity: .6; cursor: default; }
.login .msg { min-height: 20px; margin-top: 10px; color: var(--critical); }

/* ---------- каркас ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 22px;
  background: var(--surface-1); border-bottom: 1px solid var(--border); }
.top h1 { margin: 0; font-size: 16px; }
.top h1 small { color: var(--text-muted); font-weight: 500; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs button { padding: 6px 12px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text-secondary); }
.tabs button.on { border-color: var(--border); background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.filters { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.filters select, .filters button, .bar input, .bar select, .bar button { height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.main { padding: 20px 22px 60px; max-width: 1400px; }
.note { color: var(--text-muted); margin: 0 0 14px; }
.err { padding: 12px 14px; border-radius: 10px; background: var(--surface-1); border: 1px solid var(--critical); color: var(--critical); }

/* ---------- плитки ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { padding: 14px 16px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; }
.tile .k { color: var(--text-secondary); font-size: 13px; }
.tile .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--text-muted); font-size: 12.5px; }

/* ---------- карточки графиков ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; }
.card { position: relative; padding: 16px 18px 12px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; min-width: 0; margin-bottom: 16px; }
.card h2 { margin: 0 0 2px; font-size: 15px; }
.card .sub { margin: 0 0 10px; color: var(--text-muted); font-size: 12.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 6px; color: var(--text-secondary); font-size: 12.5px; }
.legend i { display: inline-block; width: 12px; height: 3px; margin-right: 6px; border-radius: 2px; vertical-align: middle; }
.legend i.box { height: 10px; width: 10px; border-radius: 2px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.axis text, .dlab { fill: var(--text-muted); font-size: 11px; }
.dlab { fill: var(--text-secondary); font-weight: 600; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.base { stroke: var(--border); stroke-width: 1; }
.cross { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { stroke: var(--surface-1); stroke-width: 2; }
.c1 { stroke: var(--series-1); } .f1 { fill: var(--series-1); } .b1 { background: var(--series-1); }
.c2 { stroke: var(--series-2); } .f2 { fill: var(--series-2); } .b2 { background: var(--series-2); }
.c3 { stroke: var(--series-3); } .f3 { fill: var(--series-3); } .b3 { background: var(--series-3); }
.hit { fill: transparent; }
.colhit:hover + g rect, .colgrp:hover rect { opacity: .82; }
.tip { position: absolute; z-index: 4; pointer-events: none; min-width: 140px; padding: 8px 10px; border-radius: 8px;
  background: var(--surface-1); border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.12); font-size: 12.5px; display: none; }
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 12px; color: var(--text-secondary); }
.tip div span:last-child { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; }
details.tbl { margin-top: 8px; }
details.tbl summary { cursor: pointer; color: var(--text-muted); font-size: 12.5px; }

/* ---------- воронки ---------- */
.fun { display: grid; grid-template-columns: minmax(180px, 260px) 1fr auto auto; gap: 6px 12px; align-items: center; }
.fun .lbl { color: var(--text-secondary); }
.fun .track { position: relative; height: 22px; background: var(--surface-2); border-radius: 4px; }
.fun .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.fun .fill.first { border-radius: 4px; }
.fun .pc { color: var(--text-muted); font-size: 12.5px; text-align: right; white-space: nowrap; min-width: 92px; }

/* ---------- таблицы ---------- */
.tw { overflow: auto; max-height: 560px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
td.inb { position: relative; min-width: 110px; }
td.inb span.ib { position: absolute; left: 8px; top: 7px; bottom: 7px; border-radius: 0 3px 3px 0; background: var(--bar-soft); opacity: .55; }
td.inb span.iv { position: relative; }
tr:hover td { background: var(--surface-2); }
.muted { color: var(--text-muted); }
.tag { display: inline-block; margin: 0 4px 2px 0; padding: 0 6px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.bar input[type="search"] { min-width: 260px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; color: var(--text-muted); }
.pager button { height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.pager button:disabled { opacity: .45; cursor: default; }
.link { border: 0; padding: 0; background: none; color: var(--series-1); text-decoration: underline; cursor: pointer; }
code.props { font: 12px/1.4 ui-monospace, Menlo, monospace; color: var(--text-secondary); word-break: break-word; }

@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .fun { grid-template-columns: 1fr auto; }
  .fun .track { grid-column: 1 / -1; }
  .filters { margin-left: 0; }
}
