/* ---- Tokens (HSL) — vacancy-corpus aligned, extended for analytics ----- */
:root {
  --bg:           0 0% 100%;
  --fg:         240 10% 4%;
  --muted:      240 5% 96%;
  --muted-fg:   240 4% 46%;
  --brd:        240 6% 90%;
  --brd-strong: 240 6% 82%;
  --accent:     240 5% 96%;
  --accent-fg:  240 6% 10%;
  --card:         0 0% 100%;
  --card-fg:    240 10% 4%;
  --primary:    240 6% 10%;
  --primary-fg:   0 0% 98%;
  --destructive:  0 84% 60%;
  --success:    142 71% 35%;
  --warn:        38 92% 50%;
  --info:       212 90% 50%;
  --series-1:   240  6% 10%;
  --series-2:   212 90% 50%;
  --series-3:   142 71% 35%;
  --series-4:    38 92% 50%;
  --series-5:   282 60% 50%;
  --ring:       240 10% 4%;
  --radius: 10px;
  --gap: 16px;
  --row-pad-y: 9px;
  --shadow-1: 0 1px 2px hsl(var(--fg)/0.04), 0 1px 0 hsl(var(--fg)/0.02);
  --shadow-2: 0 8px 24px hsl(var(--fg)/0.06), 0 2px 6px hsl(var(--fg)/0.04);
}
.dark, :root.dark {
  --bg:         240 10% 4%;
  --fg:           0 0% 98%;
  --muted:      240 6% 12%;
  --muted-fg:   240 4% 64%;
  --brd:        240 5% 16%;
  --brd-strong: 240 5% 24%;
  --accent:     240 6% 14%;
  --accent-fg:    0 0% 98%;
  --card:       240 8% 7%;
  --card-fg:      0 0% 98%;
  --primary:      0 0% 98%;
  --primary-fg: 240 10% 4%;
  --ring:         0 0% 98%;
  --series-1:     0 0% 98%;
  --series-2:   212 90% 60%;
  --series-3:   142 65% 50%;
  --series-4:    38 92% 60%;
  --series-5:   282 60% 65%;
  --shadow-1: 0 1px 2px hsl(0 0% 0%/0.4), 0 1px 0 hsl(0 0% 0%/0.2);
  --shadow-2: 0 8px 24px hsl(0 0% 0%/0.45), 0 2px 6px hsl(0 0% 0%/0.25);
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: 240 10% 4%; --fg: 0 0% 98%;
    --muted: 240 6% 12%; --muted-fg: 240 4% 64%;
    --brd: 240 5% 16%; --brd-strong: 240 5% 24%;
    --accent: 240 6% 14%; --accent-fg: 0 0% 98%;
    --card: 240 8% 7%; --card-fg: 0 0% 98%;
    --primary: 0 0% 98%; --primary-fg: 240 10% 4%;
    --ring: 0 0% 98%;
    --series-1: 0 0% 98%;
    --series-2: 212 90% 60%; --series-3: 142 65% 50%; --series-4: 38 92% 60%; --series-5: 282 60% 65%;
    --shadow-1: 0 1px 2px hsl(0 0% 0%/0.4), 0 1px 0 hsl(0 0% 0%/0.2);
    --shadow-2: 0 8px 24px hsl(0 0% 0%/0.45), 0 2px 6px hsl(0 0% 0%/0.25);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  font-feature-settings: 'cv11','ss03','tnum';
  font-size: 14px;
  background: hsl(var(--bg));
  color: hsl(var(--fg));
  -webkit-font-smoothing: antialiased;
}
code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ----- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid hsl(var(--brd));
  background: hsl(var(--bg));
  display: flex; flex-direction: column;
  position: sticky; top: 0; align-self: start; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px 16px; border-bottom: 1px solid hsl(var(--brd)); }
.logo {
  width: 22px; height: 22px; border-radius: 6px;
  background: hsl(var(--primary));
  position: relative; flex-shrink: 0;
}
.logo::before, .logo::after, .logo > i {
  content: ''; position: absolute; left: 5px;
  background: hsl(var(--primary-fg)); border-radius: 1px;
}
.logo::before { top: 6px; width: 10px; height: 1.8px; }
.logo > i { top: 10px; width: 7px; height: 1.8px; }
.logo::after  { top: 14px; width: 12px; height: 1.8px; }
.brand-text { line-height: 1.15; }
.brand-title { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: hsl(var(--muted-fg)); }

.nav { display: flex; flex-direction: column; padding: 8px; gap: 1px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  font-size: 13px; color: hsl(var(--fg));
  cursor: pointer; user-select: none;
  transition: background-color 80ms ease, color 80ms ease;
}
.nav-link:hover { background: hsl(var(--accent)); text-decoration: none; }
.nav-link.active { background: hsl(var(--accent)); color: hsl(var(--accent-fg)); font-weight: 500; }
.nav-link .ico { width: 14px; display: inline-flex; justify-content: center; color: hsl(var(--muted-fg)); font-size: 13px; }
.nav-link.active .ico { color: hsl(var(--accent-fg)); }
.nav-grp { font-size: 10.5px; color: hsl(var(--muted-fg)); text-transform: uppercase; letter-spacing: 0.06em; padding: 12px 12px 4px; }

.side-foot {
  margin-top: auto; padding: 10px 12px; border-top: 1px solid hsl(var(--brd));
  display: flex; align-items: center; gap: 4px;
}
.ver { margin-left: auto; font-size: 11px; color: hsl(var(--muted-fg)); }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 16px 28px; border-bottom: 1px solid hsl(var(--brd));
  position: sticky; top: 0; z-index: 10; background: hsl(var(--bg)/0.92); backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.topbar-left { min-width: 0; }
.topbar-meta { font-size: 12px; color: hsl(var(--muted-fg)); display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; }
.topbar-right { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.view { padding: 22px 28px 60px; max-width: 1440px; }

/* ---- Primitives ----- */
.btn-primary, .btn-outline, .btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease, color 120ms ease;
  border: 1px solid transparent; user-select: none;
  font-family: inherit;
}
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-fg)); }
.btn-primary:hover:not(:disabled) { background: hsl(var(--primary)/0.88); }
.btn-outline { background: hsl(var(--bg)); color: hsl(var(--fg)); border-color: hsl(var(--brd)); }
.btn-outline:hover:not(:disabled) { background: hsl(var(--accent)); border-color: hsl(var(--brd-strong)); }
.btn-outline:active:not(:disabled) { transform: translateY(0.5px); }
.btn-ghost { background: transparent; color: hsl(var(--muted-fg)); }
.btn-ghost:hover { background: hsl(var(--accent)); color: hsl(var(--fg)); }
.btn-sm { padding: 4px 9px; font-size: 11.5px; }
.btn-ico { padding: 4px 6px; min-width: 26px; justify-content: center; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, a:focus-visible, .input:focus-visible, select:focus-visible {
  outline: none; box-shadow: 0 0 0 3px hsl(var(--ring)/0.12);
}

.seg { display: inline-flex; border: 1px solid hsl(var(--brd)); background: hsl(var(--bg)); border-radius: 7px; padding: 2px; gap: 1px; }
.seg button {
  background: transparent; border: 0; cursor: pointer; font: inherit;
  color: hsl(var(--muted-fg));
  padding: 4px 9px; border-radius: 5px; font-size: 11.5px;
  transition: background 120ms ease, color 120ms ease;
}
.seg button:hover { color: hsl(var(--fg)); }
.seg button.is-active { background: hsl(var(--primary)); color: hsl(var(--primary-fg)); }
.dark .seg button.is-active { background: hsl(var(--accent)); color: hsl(var(--fg)); }

.input, select.input, .input-sel {
  width: 100%; padding: 6px 10px;
  border: 1px solid hsl(var(--brd)); background: hsl(var(--bg));
  border-radius: 7px; color: hsl(var(--fg)); font-size: 12.5px;
  font-family: inherit; height: 30px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input-sel { width: auto; min-width: 140px; }
.input:focus, select.input:focus { outline: none; border-color: hsl(var(--fg)); box-shadow: 0 0 0 3px hsl(var(--ring)/0.10); }

.card { background: hsl(var(--card)); color: hsl(var(--card-fg)); border: 1px solid hsl(var(--brd)); border-radius: var(--radius); min-width: 0; overflow: hidden; box-shadow: var(--shadow-1); }
.card-pad { padding: 16px 18px; }
.card-hd {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 10px; border-bottom: 1px solid hsl(var(--brd));
}
.card-hd .ttl { font-size: 12.5px; font-weight: 500; color: hsl(var(--fg)); }
.card-hd .sub { font-size: 11.5px; color: hsl(var(--muted-fg)); }
.card-hd .spacer { flex: 1; }
.card-bd { padding: 14px 16px; }

.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: hsl(var(--muted-fg)); margin: 24px 0 10px; font-weight: 500; }
.muted-fg { color: hsl(var(--muted-fg)); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- KPI cards ----- */
.kpi-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.kpi {
  display: grid; grid-template-rows: auto 1fr auto; gap: 4px;
  padding: 14px 16px 12px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--brd));
  border-radius: var(--radius);
  position: relative; overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
  box-shadow: var(--shadow-1);
}
.kpi:hover { border-color: hsl(var(--brd-strong)); box-shadow: var(--shadow-2); }
.kpi-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: hsl(var(--muted-fg)); font-weight: 500; }
.kpi-row { display: flex; align-items: baseline; gap: 8px; }
.kpi-val { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-unit { font-size: 13px; color: hsl(var(--muted-fg)); font-weight: 400; }
.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 500;
  padding: 1px 6px 1px 5px; border-radius: 999px;
}
.kpi-delta.up { color: hsl(var(--success)); background: hsl(var(--success)/0.10); }
.kpi-delta.down { color: hsl(var(--destructive)); background: hsl(var(--destructive)/0.10); }
.kpi-delta.flat { color: hsl(var(--muted-fg)); background: hsl(var(--muted)); }
.kpi-delta .arr { font-size: 9px; }
.kpi-sub {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: hsl(var(--muted-fg)); font-weight: 400;
  margin-top: 6px;
}
.kpi-spark {
  position: absolute; right: 0; bottom: 0; left: 0; height: 38px;
  pointer-events: none; opacity: 0.55;
  mask-image: linear-gradient(to top, hsl(var(--fg)) 60%, transparent);
  -webkit-mask-image: linear-gradient(to top, hsl(var(--fg)) 60%, transparent);
}
.kpi.is-selected { border-color: hsl(var(--fg)); box-shadow: 0 0 0 3px hsl(var(--ring)/0.10); }
.kpi { cursor: pointer; }

/* ---- Chart cards ----- */
.chart {
  width: 100%;
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.chart .axis text { fill: hsl(var(--muted-fg)); font-size: 10.5px; }
.chart .axis line, .chart .axis path { stroke: hsl(var(--brd)); fill: none; }
.chart .grid line { stroke: hsl(var(--brd)); stroke-dasharray: 2 4; opacity: 0.6; }
.chart .series path { fill: none; stroke-width: 1.6; }
.chart .series-1 .line, .chart .series-1 path { stroke: hsl(var(--series-1)); }
.chart .series-2 .line, .chart .series-2 path { stroke: hsl(var(--series-2)); }
.chart .series-3 .line, .chart .series-3 path { stroke: hsl(var(--series-3)); }
.chart .series-4 .line, .chart .series-4 path { stroke: hsl(var(--series-4)); }
.chart .series-5 .line, .chart .series-5 path { stroke: hsl(var(--series-5)); }
.chart .series .area { fill: hsl(var(--series-1)/0.10); stroke: none; }
.chart .series-2 .area { fill: hsl(var(--series-2)/0.10); }
.chart .series-3 .area { fill: hsl(var(--series-3)/0.10); }
.chart .series-4 .area { fill: hsl(var(--series-4)/0.10); }
.chart .series-5 .area { fill: hsl(var(--series-5)/0.10); }
.chart .series .prev path { stroke-dasharray: 3 3; opacity: 0.55; }
.chart .hover-line { stroke: hsl(var(--fg)); stroke-width: 1; opacity: 0.20; pointer-events: none; }
.chart .dot { fill: hsl(var(--bg)); stroke-width: 2; }

.chart-tip {
  position: absolute; z-index: 6;
  background: hsl(var(--card)); border: 1px solid hsl(var(--brd-strong)); border-radius: 8px;
  padding: 8px 10px; pointer-events: none; min-width: 168px;
  box-shadow: var(--shadow-2);
  transition: opacity 80ms ease, transform 80ms ease;
  font-size: 12px;
}
.chart-tip .tip-ttl { font-size: 11px; color: hsl(var(--muted-fg)); margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; font-feature-settings: 'tnum'; }
.chart-tip .tip-row .swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.chart-tip .tip-row .nm { flex: 1; color: hsl(var(--muted-fg)); font-size: 11.5px; }
.chart-tip .tip-row .vl { color: hsl(var(--fg)); font-variant-numeric: tabular-nums; }

.chart-wrap { position: relative; width: 100%; max-width: 1120px; margin: 0 auto; }

.legend { display: inline-flex; align-items: center; gap: 12px; font-size: 11.5px; color: hsl(var(--muted-fg)); }
.legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw { width: 8px; height: 8px; border-radius: 2px; }
.legend .lg.s1 .sw { background: hsl(var(--series-1)); }
.legend .lg.s2 .sw { background: hsl(var(--series-2)); }
.legend .lg.s3 .sw { background: hsl(var(--series-3)); }
.legend .lg.s4 .sw { background: hsl(var(--series-4)); }
.legend .lg.s5 .sw { background: hsl(var(--series-5)); }
.legend .lg.dash { opacity: 0.7; }
.legend .lg.dash .sw { background: transparent; border-top: 2px dashed hsl(var(--muted-fg)); height: 0; border-radius: 0; }

/* ---- Tables ----- */
.tbl-wrap {
  border: 1px solid hsl(var(--brd)); border-radius: var(--radius);
  background: hsl(var(--card)); overflow: hidden;
}
.tbl-scroll { max-height: calc(100vh - 320px); overflow: auto; scroll-behavior: smooth; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
table.tbl th, table.tbl td {
  text-align: left; padding: var(--row-pad-y) 14px; font-size: 12.5px; vertical-align: top;
  border-bottom: 1px solid hsl(var(--brd));
}
table.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: hsl(var(--muted));
  color: hsl(var(--muted-fg));
  font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid hsl(var(--brd));
  white-space: nowrap;
}
table.tbl tbody tr { transition: background-color 80ms ease; }
table.tbl tbody tr:hover { background: hsl(var(--accent)/0.55); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.mono, table.tbl th.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; }
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable .arr { opacity: 0.30; margin-left: 4px; font-size: 9px; transition: opacity 120ms ease, transform 120ms ease; }
table.tbl th.sortable.active .arr { opacity: 1; }
table.tbl th.sortable.dir-asc .arr { transform: rotate(180deg); }
table.tbl td .bar {
  position: relative; height: 4px; border-radius: 2px;
  background: hsl(var(--muted));
  margin-top: 6px; overflow: hidden;
}
table.tbl td .bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: hsl(var(--series-1));
  border-radius: 2px;
}
table.tbl td .ext { font-size: 11px; color: hsl(var(--muted-fg)); margin-left: 4px; }
table.tbl tr.is-selected { background: hsl(var(--accent)); }

/* ---- Badges ----- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 500; }
.badge.pass { background: hsl(var(--success)/0.12); color: hsl(var(--success)); }
.badge.fail { background: hsl(var(--destructive)/0.12); color: hsl(var(--destructive)); }
.badge.warn { background: hsl(var(--warn)/0.16); color: hsl(var(--warn)); }
.badge.neut { background: hsl(var(--muted)); color: hsl(var(--muted-fg)); }
.badge.info { background: hsl(var(--info)/0.12); color: hsl(var(--info)); }

/* ---- Heatmap (countries / pages) ----- */
.heat { display: grid; grid-template-columns: 1fr; gap: 4px; }
.heat-row { display: grid; grid-template-columns: 180px 1fr 70px; align-items: center; gap: 10px; font-size: 12px; }
.heat-row .lbl { color: hsl(var(--fg)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heat-row .lbl .sub { color: hsl(var(--muted-fg)); font-size: 11px; margin-left: 6px; }
.heat-row .bar {
  height: 18px; border-radius: 4px;
  background: hsl(var(--muted)); position: relative; overflow: hidden;
}
.heat-row .bar > i {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, hsl(var(--series-2)/0.16), hsl(var(--series-2)/0.85));
  border-radius: 4px;
  transition: width 320ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.heat-row .vl { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }

/* ---- Realtime ----- */
.rt-band {
  display: flex; gap: 4px; align-items: end; height: 64px;
  padding: 8px 0;
}
.rt-band .b {
  flex: 1; border-radius: 3px;
  background: hsl(var(--series-2));
  min-height: 2px;
  transition: height 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.rt-band .b.recent { background: hsl(var(--series-2)); }
.rt-band .b.old { background: hsl(var(--series-2)/0.55); }
.rt-axis { display: flex; justify-content: space-between; font-size: 10px; color: hsl(var(--muted-fg)); margin-top: 2px; }

.pulse {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: hsl(var(--success));
  box-shadow: 0 0 0 0 hsl(var(--success)/0.45);
  animation: pulse 1.8s ease-out infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 hsl(var(--success)/0.45); }
  70% { box-shadow: 0 0 0 6px hsl(var(--success)/0); }
  100% { box-shadow: 0 0 0 0 hsl(var(--success)/0); }
}

/* ---- Loading skeletons ----- */
.skel {
  display: inline-block; height: 10px; border-radius: 3px;
  background: linear-gradient(90deg, hsl(var(--muted)) 0%, hsl(var(--accent)) 50%, hsl(var(--muted)) 100%);
  background-size: 200% 100%;
  animation: skel 1100ms ease-in-out infinite;
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-kpi { height: 26px; width: 60%; }
.skel-chart { height: 220px; width: 100%; border-radius: 8px; }

/* ---- Empty / error ----- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 56px 18px; color: hsl(var(--muted-fg)); text-align: center;
}
.empty .glyph {
  width: 36px; height: 36px; border: 1px dashed hsl(var(--brd)); border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
}
.empty .ttl { font-size: 13.5px; color: hsl(var(--fg)); font-weight: 500; }
.empty .sub { font-size: 12.5px; max-width: 460px; line-height: 1.55; }
.empty .cta { margin-top: 6px; }
.empty.empty-inline {
  flex-direction: row; align-items: center; justify-content: flex-start;
  padding: 12px 14px; gap: 12px; text-align: left;
  background: hsl(var(--card-2, var(--card))); border: 1px solid hsl(var(--brd)); border-radius: var(--radius);
}
.empty.empty-inline .glyph { width: 26px; height: 26px; font-size: 13px; flex-shrink: 0; }
.empty.empty-inline .ttl { font-size: 12.5px; }
.empty.empty-inline .sub { font-size: 12px; line-height: 1.45; max-width: none; flex: 1; min-width: 0; }
.empty.empty-inline .cta { margin-top: 0; margin-left: auto; }

/* ---- Toast ----- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: hsl(var(--primary)); color: hsl(var(--primary-fg));
  padding: 8px 14px; border-radius: 8px;
  font-size: 12.5px; z-index: 100;
  box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Animations ----- */
.fade-in { animation: fade 200ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fade 240ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(n+7) { animation-delay: 240ms; }

/* ---- Grids ----- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--gap); }
.grid-211 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--gap); }
@media (max-width: 1100px) {
  .grid-2, .grid-211, .grid-3 { grid-template-columns: 1fr; }
}

/* ---- Issue cards (Index Health) ----- */
.issue-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.issue-card {
  display: block; padding: 14px 16px;
  background: hsl(var(--card)); color: hsl(var(--card-fg));
  border: 1px solid hsl(var(--brd)); border-radius: var(--radius);
  text-decoration: none; transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  box-shadow: var(--shadow-1);
}
.issue-card:hover { border-color: hsl(var(--fg) / 0.4); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.issue-card .issue-ttl { font-size: 13px; font-weight: 600; color: hsl(var(--fg)); margin-bottom: 4px; }
.issue-card .issue-sub { font-size: 12px; line-height: 1.45; color: hsl(var(--muted-fg)); }
.issue-card .issue-ext {
  font-size: 14px; color: hsl(var(--muted-fg));
  transition: color 160ms ease, transform 160ms ease;
}
.issue-card:hover .issue-ext { color: hsl(var(--fg)); transform: translate(2px, -2px); }

/* Numeric cell highlights */
.tnum.bad { color: hsl(0 78% 52%); font-variant-numeric: tabular-nums; font-weight: 600; }
.tnum.warn { color: hsl(36 90% 48%); font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---- Filter bar (date range, source) ----- */
.filterbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.range-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid hsl(var(--brd)); background: hsl(var(--bg));
  border-radius: 7px;
  font-size: 12px; color: hsl(var(--fg));
  cursor: pointer; transition: background 120ms ease, border-color 120ms ease;
}
.range-pill:hover { background: hsl(var(--accent)); border-color: hsl(var(--brd-strong)); }
.range-pill .ico { color: hsl(var(--muted-fg)); }
.range-pill .lbl-sub { font-size: 11px; color: hsl(var(--muted-fg)); }

/* ---- Range popover ----- */
.pop {
  position: fixed; z-index: 60;
  background: hsl(var(--card)); border: 1px solid hsl(var(--brd-strong));
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow-2);
  display: grid; gap: 10px;
  animation: pop-in 140ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.985); } to { opacity: 1; transform: none; } }
.pop .presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; min-width: 280px; }
.pop .preset {
  text-align: left; padding: 6px 10px; font-size: 12px;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  border-radius: 5px; color: hsl(var(--fg)); font-family: inherit;
  transition: background 120ms ease;
}
.pop .preset:hover { background: hsl(var(--accent)); }
.pop .preset.is-active { background: hsl(var(--accent)); border-color: hsl(var(--brd)); }
.pop .custom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pop .custom-row label { font-size: 10.5px; color: hsl(var(--muted-fg)); text-transform: uppercase; letter-spacing: 0.06em; }
.pop .custom-row input { width: 100%; padding: 5px 8px; border: 1px solid hsl(var(--brd)); border-radius: 5px; background: hsl(var(--bg)); color: hsl(var(--fg)); font-family: inherit; font-size: 12px; }
.pop-foot { display: flex; align-items: center; gap: 6px; }
.pop-foot .spacer { flex: 1; }

/* ---- Donut (small inline) ----- */
.donut-ring { transform: rotate(-90deg); }
.donut-ring .seg { fill: none; stroke-width: 8; }

/* ---- Responsive ----- */
@media (max-width: 760px) {
  :root { --gap: 12px; --row-pad-y: 8px; }
  html, body { min-width: 0; overflow-x: hidden; }
  .layout { display: block; min-height: 100dvh; }
  .side {
    position: sticky; top: 0; z-index: 40; height: auto;
    border-right: 0; border-bottom: 1px solid hsl(var(--brd));
  }
  .brand { padding: 10px 12px 8px; border-bottom: 0; }
  .nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 0 8px 8px; gap: 4px; }
  .nav-link { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; }
  .side-foot { padding: 7px 10px; gap: 4px; }
  .topbar { position: static; padding: 12px 14px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .view { padding: 14px 12px 40px; }
  .kpi-val { font-size: 22px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .heat-row { grid-template-columns: 110px 1fr 60px; }
}
