.viz-root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-1-wash: rgba(42, 120, 214, 0.10);
  --warning: #fab219;
  --critical: #d03b3b;
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-1-wash: rgba(57, 135, 229, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); }
.viz-root {
  min-height: 100vh;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 8px 12px 32px;
  font-variant-numeric: proportional-nums;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.hint { color: var(--text-secondary); font-size: 13px; margin: -4px 0 10px; }

/* вкладки */
.tabs { display: flex; gap: 4px; background: var(--surface-1); border: 1px solid var(--border);
        border-radius: 12px; padding: 3px; margin-bottom: 10px; }
.tab { flex: 1; border: 0; background: none; padding: 7px 0; border-radius: 9px; color: var(--text-secondary); }
.tab.active { background: var(--series-1); color: #fff; font-weight: 600; }

/* фильтры */
.filters { margin-bottom: 10px; }
.period-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.period-label { border: 0; background: none; font-weight: 600; font-size: 16px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
            background: var(--surface-1); font-size: 20px; line-height: 1; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface-1); border-radius: 999px;
        padding: 5px 11px; font-size: 13px; color: var(--text-secondary); }
.chip.on { border-color: var(--series-1); color: var(--text-primary); font-weight: 600; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 999px;
             background: var(--surface-1); padding: 2px; }
.segmented button { border: 0; background: none; padding: 4px 10px; border-radius: 999px;
                    font-size: 13px; color: var(--text-secondary); }
.segmented button.on { background: var(--series-1-wash); color: var(--text-primary); font-weight: 600; }
.custom-range { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--text-muted); }
input, select { font: inherit; color: var(--text-primary); background: var(--surface-1);
                border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.loading main { opacity: .5; transition: opacity .15s; }

/* итог */
.hero { padding: 6px 2px 10px; }
.hero-label { color: var(--text-secondary); font-size: 13px; }
.hero-value { font-size: 40px; font-weight: 600; letter-spacing: -0.5px; line-height: 1.15; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.tile-label { color: var(--text-secondary); font-size: 12px; }
.tile-value { font-size: 18px; font-weight: 600; }
.rate-line { display: block; margin-top: 8px; border: 1px solid var(--border); background: var(--surface-1);
             border-radius: 10px; padding: 6px 10px; font-size: 14px; text-align: left; width: 100%; }
.rate-line b { font-weight: 600; }
.rate-line .muted { color: var(--text-muted); font-size: 12px; margin-left: 6px; }
.mode-note { color: var(--text-muted); font-size: 12px; margin: 8px 0 0; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
        padding: 12px; margin-bottom: 10px; position: relative; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h2 { margin-bottom: 10px; }
.filter-pill { border: 1px solid var(--series-1); background: var(--series-1-wash); border-radius: 999px;
               font-size: 12px; padding: 3px 9px; margin-bottom: 10px; }

/* столбцы */
.chart { position: relative; height: 200px; display: flex; }
.y-axis { position: relative; width: 44px; flex: none; }
.y-axis span { position: absolute; right: 6px; transform: translateY(50%); font-size: 11px; color: var(--text-muted); }
.plot { position: relative; flex: 1; border-bottom: 1px solid var(--baseline); }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.bar-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; min-width: 0;
            outline: none; }
.bar { width: 100%; max-width: 24px; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 0; }
.bar-slot:hover .bar, .bar-slot:focus .bar, .bar-slot.sel .bar { filter: brightness(1.15); }
.bar-slot.future .bar { opacity: 0; }
.x-axis { display: flex; margin-left: 44px; gap: 2px; height: 18px; }
.x-axis span { flex: 1; text-align: center; font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: visible; }
.tooltip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface-1);
           border: 1px solid var(--border); border-radius: 10px; padding: 6px 9px;
           box-shadow: 0 4px 14px rgba(0,0,0,.12); font-size: 12px; min-width: 120px; }
.tooltip strong { display: block; font-size: 15px; }
.tooltip .t-date { color: var(--text-secondary); }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tooltip .t-row b { color: var(--text-primary); font-weight: 600; margin-left: auto; padding-left: 8px; }

/* статьи */
.cat { padding: 7px 0; border-top: 1px solid var(--grid); cursor: pointer; }
.cat:first-child { border-top: 0; }
.cat.sel .cat-name { font-weight: 600; }
.cat-top { display: flex; align-items: baseline; gap: 8px; }
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-value { font-weight: 600; white-space: nowrap; }
.cat-share { color: var(--text-muted); font-size: 12px; width: 36px; text-align: right; }
.cat-bar { height: 6px; margin-top: 5px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.cat-bar > div { height: 100%; background: var(--series-1); border-radius: 3px; }
.cat-limit { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.cat-limit.warn::before { content: "⚠️ "; }
.cat-limit.over::before { content: "‼️ "; }
.cat-bar.warn > div { background: var(--warning); }
.cat-bar.over > div { background: var(--critical); }
.subs { margin: 6px 0 0 26px; }
.sub { display: flex; gap: 8px; font-size: 13px; color: var(--text-secondary); padding: 2px 0; }
.sub span:first-child { flex: 1; }
.empty { color: var(--text-muted); text-align: center; padding: 20px 0; }

/* список */
.exp { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--grid); }
.exp:first-child { border-top: 0; }
.exp-emoji { font-size: 20px; width: 26px; text-align: center; }
.exp-main { flex: 1; min-width: 0; }
.exp-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-meta { font-size: 12px; color: var(--text-muted); }
.exp-sum { text-align: right; white-space: nowrap; }
.exp-sum .orig { font-size: 12px; color: var(--text-muted); }
.day-head { font-size: 12px; color: var(--text-secondary); font-weight: 600; padding: 10px 0 2px; }
.badge { font-size: 11px; border: 1px solid var(--border); border-radius: 6px; padding: 0 5px; margin-left: 4px; }

/* настройки */
.row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.row label { flex: 1; }
.row input { width: 110px; text-align: right; }
.row .muted { color: var(--text-muted); font-size: 12px; }
.saved { color: #0ca30c; font-size: 12px; }
