.viz-root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface-1: #ffffff;
  --text-primary: #191919;
  --text-secondary: #666666;
  --text-muted: #8a8a8a;
  --border: #e3e5e8;
  --grid: #eeeeee;
  --accent: #257de0;
  --accent-soft: #e8f1fc;
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --series-4: #f2a600;
  --good: #0aac23;
  --critical: #dc3c3d;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
  font-size: 13px;
}
* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; cursor: pointer; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.title { font-size: 18px; font-weight: 600; letter-spacing: .2px; }
.sub { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; color: var(--text-secondary); font-weight: 500; }
.tabs button:hover { background: var(--bg); color: var(--text-primary); }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }

.controls { padding: 10px 20px 4px; background: var(--surface-1); border-bottom: 1px solid var(--border); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface-1); padding: 6px 10px; color: var(--text-secondary); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: #fff; }
.seg.small button { padding: 4px 8px; font-size: 12px; }
.rates { display: inline-flex; gap: 8px; color: var(--text-secondary); font-size: 12px; align-items: center; }
.rates input { width: 64px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.link { border: 0; background: none; color: var(--accent); padding: 6px 4px; }

.ms { position: relative; }
.ms > button { border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 6px 10px;
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.ms > button .lab { color: var(--text-secondary); margin-right: 4px; }
.ms.active > button { border-color: var(--accent); background: var(--accent-soft); }
.ms .pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; width: 320px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 8px; display: none; }
.ms.open .pop { display: block; }
.ms .pop input[type=search] { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.ms .pop .acts { display: flex; justify-content: space-between; margin: 6px 0; font-size: 12px; }
.ms .pop .list { max-height: 280px; overflow: auto; }
.ms .pop label { display: flex; gap: 6px; padding: 4px 2px; align-items: flex-start; font-size: 12px; cursor: pointer; }
.ms .pop label:hover { background: var(--bg); }
.ms .pop .more { color: var(--text-muted); font-size: 11px; padding: 4px; }

main { padding: 16px 20px 40px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.card h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .4px; color: var(--text-secondary); text-transform: uppercase;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h3 .note { text-transform: none; font-weight: 400; letter-spacing: 0; color: var(--text-muted); }
.chart { width: 100%; height: 300px; }
.chart.tall { height: 520px; }
.s2 { grid-column: span 2; } .s3 { grid-column: span 3; } .s4 { grid-column: span 4; } .s5 { grid-column: span 5; }
.s6 { grid-column: span 6; } .s7 { grid-column: span 7; } .s8 { grid-column: span 8; } .s12 { grid-column: span 12; }
@media (max-width: 1100px) { .s2,.s3,.s4,.s5,.s6,.s7,.s8 { grid-column: span 12; } }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; grid-column: span 12; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.kpi.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.kpi .k { color: var(--text-secondary); font-size: 12px; }
.kpi .v { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; margin-top: 2px; color: var(--text-muted); }
.up { color: var(--good); } .down { color: var(--critical); }

.srcbar { grid-column: span 12; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--text-secondary); }

.tbl-wrap { overflow: auto; max-height: 520px; border-radius: 8px; }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
table.t th { position: sticky; top: 0; background: #f8f9fa; text-align: left; font-weight: 600; color: var(--text-secondary);
  padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; z-index: 1; }
table.t th.num, table.t td.num { text-align: right; }
table.t td { padding: 6px 8px; border-bottom: 1px solid var(--grid); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.t tr:hover td { background: #fafbfc; }
table.t tr.total td { font-weight: 600; background: #f8f9fa; position: sticky; bottom: 0; border-top: 1px solid var(--border); }
.tbl-tools { display: flex; gap: 8px; align-items: center; }
.tbl-tools input { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; width: 180px; }
.muted { color: var(--text-muted); }
.empty { color: var(--text-muted); padding: 24px; text-align: center; }

.loading { position: fixed; right: 20px; bottom: 20px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.1); z-index: 50; }
.loading.hide { display: none; }
.spin { width: 16px; height: 16px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.tip { position: fixed; pointer-events: none; display: none; }
.err { background: #fdecec; color: #8a1c1c; border-radius: 10px; padding: 12px; grid-column: span 12; }
