/* Дашборд Navkolo.
   Палитра и правила марок — из гайда по визуализации данных, значения
   проверены валидатором в светлой и тёмной теме. Данные — единственное,
   чему позволено быть громким: хром рецессивный, марки тонкие. */

:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --surface-2:      #f4f3f0;   /* вложенный блок */
  --plane:          #f4f4f1;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11,11,11,0.09);
  --border-strong:  rgba(11,11,11,0.16);
  --shadow:         0 1px 2px rgba(11,11,11,.04), 0 8px 24px -12px rgba(11,11,11,.10);

  --series-1:       #2a78d6;
  --series-2:       #eb6834;
  --series-3:       #1baf7a;
  --series-soft:    #cde2fb;
  --neg:            #e34948;
  --delta-good:     #006300;

  --ord-1: #86b6ef; --ord-2: #5598e7; --ord-3: #2a78d6; --ord-4: #1c5cab; --ord-5: #184f95;

  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;

  --r-lg: 14px; --r-md: 10px; --r-sm: 8px;
  --gap: 18px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19; --surface-2: #201f1e; --plane: #0d0d0d;
    --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #898781;
    --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255,255,255,0.09); --border-strong: rgba(255,255,255,0.18);
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px -12px rgba(0,0,0,.6);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --series-soft: #184f95; --neg: #e66767; --delta-good: #0ca30c;
    --ord-1: #cde2fb; --ord-2: #9ec5f4; --ord-3: #6da7ec; --ord-4: #3987e5; --ord-5: #184f95;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19; --surface-2: #201f1e; --plane: #0d0d0d;
  --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #898781;
  --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255,255,255,0.09); --border-strong: rgba(255,255,255,0.18);
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px -12px rgba(0,0,0,.6);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --series-soft: #184f95; --neg: #e66767; --delta-good: #0ca30c;
  --ord-1: #cde2fb; --ord-2: #9ec5f4; --ord-3: #6da7ec; --ord-4: #3987e5; --ord-5: #184f95;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--plane); color: var(--text-primary);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1280px; margin: 0 auto; padding: 28px 24px 72px; }

/* ─── шапка ─── */
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.top h1 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -0.015em; }
.top .brand { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.top .spacer { flex: 1; }

.freshness {
  font-size: 12px; color: var(--text-secondary); display: inline-flex; align-items: center;
  gap: 7px; background: var(--surface-1); border: 1px solid var(--border);
  padding: 5px 11px; border-radius: 100px;
}
.freshness .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; }
.freshness.stale .dot { background: var(--warning); }
.freshness.failed { color: var(--critical); }
.freshness.failed .dot { background: var(--critical); }

button, select, input[type="date"], input[type="password"] {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 6px 13px; cursor: pointer; transition: background .12s, border-color .12s;
}
button:hover { background: var(--surface-2); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--series-1); color: #fff; border-color: transparent; }
button.primary:hover { background: var(--series-1); filter: brightness(1.06); }

/* сегментированный переключатель периода */
.segmented { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.segmented button { border: 0; background: transparent; border-radius: 6px; padding: 5px 12px; color: var(--text-secondary); }
.segmented button:hover { background: var(--surface-2); }
.segmented button[aria-pressed="true"] { background: var(--series-1); color: #fff; }

.filters {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 24px; border-bottom: 1px solid var(--border);
}
.filters label { font-size: 12px; color: var(--text-muted); }
.filters input[type="date"] { padding: 5px 9px; font-size: 13px; }

/* ─── секции и карточки ─── */
.section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted); margin: 30px 0 12px;
}
.section-label:first-of-type { margin-top: 0; }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: var(--gap);
  box-shadow: var(--shadow);
}
.card > h2 { font-size: 14px; font-weight: 600; margin: 0 0 3px; letter-spacing: -0.005em; }
.card > .sub { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid2 > *, .card { min-width: 0; }
@media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }

/* ─── плитки ─── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; }
.tile .label { font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; }
.tile .value { font-size: 25px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; }
.tile .delta { font-size: 12px; margin-top: 3px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.tile .delta.up { color: var(--delta-good); }
.tile .delta.down { color: var(--critical); }
.tile .spark { margin-top: 8px; height: 26px; }

/* одно ведущее число на экран */
.hero { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
.hero .label { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 4px; }
.hero .value { font-size: 50px; font-weight: 600; letter-spacing: -0.035em; line-height: 1; }
.hero .delta { font-size: 13px; margin-top: 8px; }
.hero .spark { width: 220px; height: 46px; }

/* блок прибыли отделён намеренно: его выборка уже общего оборота */
.profit-block {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 18px 20px; background: var(--surface-2); margin-top: 22px;
}
.profit-block .scope {
  font-size: 12px; color: var(--text-secondary); margin: 0 0 16px;
  display: flex; align-items: center; gap: 8px;
}
.profit-block .scope b { color: var(--text-primary); font-weight: 600; }
.coverage-bar { height: 5px; border-radius: 3px; background: var(--series-soft); overflow: hidden; margin-top: 16px; }
.coverage-bar > i { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }

/* ─── графики ─── */
.chart { position: relative; }
svg { display: block; width: 100%; overflow: visible; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axisline { stroke: var(--axis); stroke-width: 1; }
.tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis-label { fill: var(--text-secondary); font-size: 11.5px; }
.mark-label { fill: var(--text-primary); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hit { fill: transparent; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; border-radius: 1px; width: 14px; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 10; min-width: 158px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 9px 11px; font-size: 12px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .1s;
}
.tooltip.on { opacity: 1; }
.tooltip .t-title { color: var(--text-secondary); margin-bottom: 7px; font-size: 11.5px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.tooltip .t-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tooltip .t-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .t-name { color: var(--text-secondary); }

/* ─── таблицы ─── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
td:first-child, th:first-child { text-align: left; white-space: normal; font-variant-numeric: normal; }
th { color: var(--text-muted); font-weight: 500; font-size: 11.5px; letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.badge.crit::before { background: var(--critical); }
.badge.warn::before { background: var(--warning); }
.badge.ok::before   { background: var(--good); }
.badge.none::before { background: var(--axis); }

.toggle-table {
  font-size: 12px; color: var(--text-secondary); background: none; border: 0;
  padding: 6px 0 0; text-decoration: underline; text-underline-offset: 3px;
}
.toggle-table:hover { background: none; color: var(--text-primary); }
.hidden { display: none !important; }
.reloading .card { opacity: .5; transition: opacity .15s; }

/* ─── требуют внимания ─── */
.attention-list { display: grid; gap: 2px; }
.attention-row {
  display: flex; align-items: center; gap: 14px; padding: 11px 12px;
  border-radius: var(--r-sm); cursor: pointer; transition: background .12s;
}
.attention-row:hover, .attention-row:focus-visible { background: var(--surface-2); outline: none; }
.attention-row[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--series-1); }
.attention-row .sev { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.attention-row .n { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; font-size: 15px; }
.attention-row .t { flex: 1; }
.attention-row .go { color: var(--text-muted); font-size: 12px; opacity: 0; }
.attention-row:hover .go { opacity: 1; }

.note {
  font-size: 12.5px; color: var(--text-secondary); background: var(--surface-2);
  border-left: 2px solid var(--axis); padding: 10px 14px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-top: 14px;
}
.empty { color: var(--text-muted); font-size: 13px; padding: 14px 0; }

.num-muted { color: var(--text-muted); }
