/* TCE911 PSAP Performance Dashboard
   Branding matches the TCE911 PSAP Performance & NENA Metrics dashboard.
   Seal palette (sampled from the official 2025 TCE911 seal)
   navy #0a0f2c · seal red #a3141a · gold #c9a24a · TN blue #1f3f7f · white */
:root {
  --brand-navy: #0a0f2c;
  --brand-navy-2: #141c45;
  --brand-red: #a3141a;
  --brand-gold: #c9a24a;
  --brand-gold-light: #e2c06e;
  --brand-blue: #1f3f7f;

  --bg: #070b1f;
  --bg-elev: #0d1433;
  --bg-card: #111a3d;
  --bg-card-hover: #17224d;
  --border: #26315e;
  --border-soft: #1b2550;
  --text: #eef1f8;
  --text-muted: #b9c0d8;
  --text-dim: #949dbd;
  --accent: #d4ae57;
  --accent-contrast: #0a0f2c;
  --accent-soft: rgba(201, 162, 74, 0.16);
  --link: #e2c06e;
  --good: #4ade80;
  --good-soft: rgba(74, 222, 128, 0.14);
  --warn: #ff7b80;
  --warn-soft: rgba(255, 123, 128, 0.14);
  --bad: #ff7b80;
  --bad-soft: rgba(255, 123, 128, 0.14);
  --chart-bar: #4a74c9;
  --chart-line: #e0b85a;
  --heatmap-0: #1a2350;
  --heatmap-miss: #c8232b;
  --heatmap-low: #b8892f;
  --heatmap-ok: #1f6b3f;
  --heatmap-high: #2f9a57;
  --heatmap-perfect: #4ade80;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  /* Fluid layout: side gutter 16–24px, gaps scale with the root font */
  --gutter: clamp(16px, 1.25vw, 24px);
  --gap: clamp(0.85rem, 0.9vw, 1.25rem);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Root font scales modestly with viewport: 15px @1366 · ~16.7px @1920 · ~19px @2560 · 24px @3840 (4K wallboard).
   Nearly every size below is in rem, so panels, text, cells and paddings scale together. */
html { scroll-behavior: smooth; font-size: clamp(15px, calc(9px + 0.4vw), 24px); }
body { overflow-x: hidden; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }
[hidden] { display: none !important; }

/* —— Header (same treatment as the metrics dashboard) —— */
.app-header {
  background: linear-gradient(135deg, #070b22 0%, var(--brand-navy) 45%, var(--brand-navy-2) 100%);
  color: #fff;
  border-bottom: 3px solid var(--brand-gold);
  padding: 0.9rem var(--gutter) 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.brand-seal {
  width: 4.5rem;
  height: 4.5rem;
  flex-shrink: 0;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}
.brand-text { min-width: 0; }
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: #fff;
}
.subtitle { margin: 0.2rem 0 0; font-size: 0.88rem; font-weight: 600; color: #e2c06e; }
.subtitle-tag {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0 0.4rem;
  border: 1px solid rgba(226, 192, 110, 0.6);
  border-radius: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  vertical-align: 1px;
}
.nena-note { margin: 0.3rem 0 0; font-size: 0.75rem; color: #c7cde0; font-weight: 500; }

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
}
#header-clock {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
#header-clock .day-date {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #e2c06e;
  margin-top: 2px;
}
.hdr-meta { display: flex; flex-direction: column; gap: 2px; font-size: 0.72rem; color: #c7cde0; }
.visitor-count { font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); }
.visitor-count span { color: var(--brand-gold-light); font-weight: 700; }

/* —— Buttons / controls (metrics dashboard style) —— */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font: 600 0.8rem var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--accent); }
.btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-ghost { background: transparent; border-color: rgba(226, 192, 110, 0.55); color: #fff; }
.btn-ghost:hover { background: rgba(226, 192, 110, 0.14); border-color: var(--brand-gold); }
.btn:disabled { opacity: 0.45; cursor: default; }

.main {
  width: 100%;
  padding: var(--gap) var(--gutter) 1.5rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.control-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.control-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
  margin-right: 0.25rem;
}
.year-btns, .mini-seg { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.mini-seg .btn { padding: 0.2rem 0.55rem; font-size: 0.72rem; }
.date-input {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.33rem 0.6rem;
  font: 600 0.8rem var(--font);
  color-scheme: dark;
}
.date-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* —— Ticker —— */
.ticker {
  position: relative;
  height: 2.4rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--bg-elev);
  overflow: hidden;
  display: flex;
  align-items: center;
  border-radius: var(--radius);
}
.ticker .track { display: flex; white-space: nowrap; animation: scroll 55s linear infinite; }
.ticker:hover .track { animation-play-state: paused; }
.ticker .item { font-size: 0.9rem; padding: 0 1.6rem; color: var(--text-muted); }
.ticker .item:not(:last-child) { border-right: 1px solid var(--border); }
.ticker .item b { color: var(--text); }
.ticker .item .ag { color: var(--good); }
.ticker .item .ab { color: var(--brand-gold-light); }
.ticker .item .ar { color: var(--bad); }
@keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* —— KPI head + tiles (hero / kpi-card style) —— */
.kpi-head { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; margin-bottom: -0.5rem; }
.kpi-head .lbl { font-size: 1rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.kpi-head .pill {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brand-gold-light);
  border: 1px solid rgba(226, 192, 110, 0.6);
  border-radius: 4px;
  padding: 0 0.45rem;
}
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--gap); }
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.kpi .k { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); font-weight: 700; }
.kpi .v { font-size: clamp(1.5rem, 1.9vw, 2.3rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi .d { font-size: 0.75rem; color: var(--text-muted); }
.kpi.primary {
  background: linear-gradient(145deg, #141c45, #1f3f7f);
  border-color: #2c4a8a;
  border-top: 3px solid var(--brand-gold);
}
.kpi.primary .k { color: #e8cf8f; }
.kpi.primary .d { color: #dbe2f2; }
.kpi.good { box-shadow: inset 3px 0 0 var(--good), var(--shadow); }
.kpi.good .v { color: var(--good); }
.kpi.warn { border-color: var(--warn); box-shadow: inset 3px 0 0 var(--warn), var(--shadow); }
.kpi.warn .v { color: var(--warn); }

/* —— Main layout —— */
.box { display: flex; flex-direction: column; gap: var(--gap); }
.row-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); min-height: max(20rem, 30vh); }
.row-mid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--gap); min-height: max(19rem, 28vh); }
.row-bottom { display: grid; grid-template-columns: minmax(0, 1.35fr) repeat(3, minmax(0, 1fr)); gap: var(--gap); min-height: max(19rem, 30vh); }

.periods { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; min-height: 0; }
.pb {
  border: 1px solid var(--border);
  border-top: 3px solid var(--c, var(--good));
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem 0.7rem;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
}
.pb .star { position: absolute; top: 0.4rem; right: 0.5rem; color: var(--brand-gold-light); font-size: 1rem; line-height: 1; }
.pb .p-t { font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; }
.pb .p-top { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.pb .p-pct { font-size: clamp(1.75rem, 2.3vw, 3rem); font-weight: 800; color: var(--c); line-height: 1; letter-spacing: -0.03em; }
.pb .grade {
  font-size: clamp(0.75rem, 0.9vw, 1rem);
  font-weight: 800;
  border-radius: 50%;
  width: clamp(1.65rem, 2vw, 2.4rem);
  height: clamp(1.65rem, 2vw, 2.4rem);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: var(--c);
}
.pb .tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  align-self: flex-start;
  margin-top: 6px;
}
.pb .rows { margin-top: 8px; flex: 1; display: flex; flex-direction: column; }
.pb .r {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border-soft);
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.pb .r:last-child { border-bottom: none; }
.pb .r .k { color: var(--text-dim); }
.pb .r .v { font-weight: 700; }
.pb .r .v.w { color: var(--brand-gold-light); }

/* —— Panels (metrics dashboard .panel look) —— */
.sec {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem 1.05rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sec h3 { font-size: 1rem; font-weight: 700; color: var(--text); flex: none; line-height: 1.3; }
.sec .chart-box { position: relative; flex: 1; min-height: 12rem; margin-top: 0.6rem; }
.sec .chart-box > canvas { position: absolute; inset: 0; }
.sec .chart-box.tall { min-height: max(17rem, 32vh); }
.sec .note { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.4rem; flex: none; }
.sec-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px; padding: 16px; color: var(--text-dim); min-height: 160px;
}
.placeholder .ico { font-size: 28px; opacity: 0.7; }
.placeholder strong { color: var(--text); font-size: 0.9rem; }
.placeholder p { font-size: 0.75rem; line-height: 1.45; max-width: 260px; }

.legend {
  display: flex; flex-wrap: wrap; gap: 0.3rem 0.65rem; font-size: 0.7rem; color: var(--text-dim);
  margin-top: 0.5rem; flex: none;
}
.legend span { display: inline-flex; align-items: center; gap: 0.25rem; }
.legend i { width: 0.75rem; height: 0.75rem; border-radius: 3px; border: 1px solid var(--border); }

/* Calendar + month grid (heatmap tiers from the metrics dashboard) */
.cal { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 0.6rem; container-type: inline-size; }
.cal-h { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-h span { text-align: center; font-size: 0.65rem; font-size: clamp(0.65rem, 1.8cqi, 1.1rem); color: var(--text-dim); font-weight: 700; }
.cal-g { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; gap: 4px; }
.cd {
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
  min-height: 2.3rem;
  background: var(--heatmap-0);
}
.cd b { font-size: 0.66rem; font-size: clamp(0.66rem, 2cqi, 1.3rem); line-height: 1.1; font-weight: 700; opacity: 0.9; }
.cd span { font-size: 0.76rem; font-size: clamp(0.76rem, 2.6cqi, 1.6rem); line-height: 1.15; font-weight: 800; font-variant-numeric: tabular-nums; }
.cd.t-miss { background: var(--heatmap-miss); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55); }
.cd.t-low { background: var(--heatmap-low); }
.cd.t-ok { background: var(--heatmap-ok); }
.cd.t-high { background: var(--heatmap-high); }
.cd.t-perfect { background: var(--heatmap-perfect); color: var(--brand-navy); }
.cd.empty { background: transparent; border: 1px dashed var(--border-soft); }
.cd.none { background: var(--heatmap-0); color: var(--text-dim); }
.cal-g .cd[data-d] { cursor: pointer; }
.cal-g .cd[data-d]:hover { outline: 1px solid var(--accent); outline-offset: 1px; }
.cal-g .cd.sel { outline: 2px solid var(--brand-gold-light); outline-offset: 1px; z-index: 1; }

.mgrid {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr;
  gap: 6px; margin-top: 0.6rem; container-type: inline-size;
}
.mgrid .cd { min-height: 3rem; }
.mgrid .cd b { font-size: 0.7rem; font-size: clamp(0.7rem, 2.3cqi, 1.4rem); }
.mgrid .cd span { font-size: 0.85rem; font-size: clamp(0.85rem, 3cqi, 1.8rem); }

/* Review panels (narrative style: gold left rule) */
.review { border-left: 3px solid var(--accent); }
.review .ai { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex: none; }
.review .ai .l { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand-gold-light); font-weight: 700; }
.review .ai .r { font-size: 0.68rem; color: var(--text-dim); font-style: italic; text-align: right; }
.review h4 { font-size: 1rem; font-weight: 700; margin: 0.4rem 0 0.6rem; line-height: 1.3; flex: none; }
.review .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; border-top: 1px solid var(--border-soft); padding-top: 8px; }
.review .mk { font-size: 0.66rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; }
.review .mv { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.review .mv.g { color: var(--good); }
.review .mv.r { color: var(--bad); }
.review .mv.y { color: var(--brand-gold-light); }
.dr-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 12px; margin-top: 8px;
  border-top: 1px solid var(--border-soft); padding-top: 8px; font-size: 0.8rem; font-variant-numeric: tabular-nums;
}
.dr-stats div { display: flex; justify-content: space-between; gap: 6px; }
.dr-stats span { color: var(--text-dim); }
.dr-stats b { color: var(--text); }
.review .ytd-cols { display: flex; gap: 14px; margin: 4px 0 6px; border-top: 1px solid var(--border-soft); padding-top: 8px; }
.review .ytd-cols .col { flex: 1; }
.review .ytd-cols .yr {
  font-weight: 700; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--brand-gold-light);
  border-bottom: 1px solid var(--border); padding-bottom: 3px; margin-bottom: 4px;
}
.review .ytd-cols .yr.prev { color: var(--text-dim); }
.review .ytd-cols .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.review .ytd-cols .row b { color: var(--text); }
.review .ytd-cols .row b.ne { color: var(--text); }
.review p {
  font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; margin-top: 8px;
  border-top: 1px solid var(--border-soft); padding-top: 8px; flex: 1; min-height: 0; overflow: auto;
}

/* —— Year over Year —— */
.yoy { gap: 1rem; }
.yoy-head { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.yoy-head .lbl { font-size: 1rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.yoy-head .pill {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; color: var(--brand-gold-light);
  border: 1px solid rgba(226, 192, 110, 0.6); border-radius: 4px; padding: 0 0.45rem;
}
.yoy-src { margin-left: auto; font-size: 0.75rem; color: var(--text-dim); }
.yoy-top, .yoy-bottom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.tbl-wrap { overflow-x: auto; margin-top: 0.6rem; border: 1px solid var(--border); border-radius: 8px; }
table.yt { width: 100%; border-collapse: collapse; font-size: 0.76rem; font-variant-numeric: tabular-nums; }
table.yt th {
  text-align: right; color: var(--text-dim); font-size: 0.66rem; letter-spacing: 0.04em; text-transform: uppercase;
  font-weight: 700; padding: 0.55rem 0.38rem; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-elev);
}
table.yt td { text-align: right; padding: 0.42rem 0.38rem; border-bottom: 1px solid var(--border-soft); font-weight: 600; white-space: nowrap; }
table.yt tr:last-child td { border-bottom: 0; }
table.yt tbody tr:hover td, table.yt tr:hover td { background: var(--bg-card-hover); }
table.yt th:first-child, table.yt td:first-child { text-align: left; }
table.yt td.y { font-weight: 700; }
table.yt td.y i { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 2px; margin-right: 6px; }
table.yt tr.cur td { background: var(--accent-soft); }
table.yt tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.yt .up { color: var(--brand-gold-light); }
table.yt .dn { color: #8fb0ef; }
table.yt .g { color: var(--good); }
table.yt .mut { color: var(--text-dim); font-weight: 500; }

/* —— Footer (metrics dashboard wording + contact block) —— */
.app-footer {
  width: 100%;
  padding: 0.5rem var(--gutter) 2.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.app-footer h3 { margin: 0 0 0.5rem; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.app-footer p { margin: 0.35rem 0; }
.app-footer ul { margin: 0.35rem 0; padding-left: 1.2rem; }
.app-footer a { color: var(--link); }
.app-footer code { font-size: 0.72rem; }
.app-footer .agency-note { color: var(--text-muted); }
.footer-contact {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) minmax(260px, 1.4fr);
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand-gold);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.8rem;
}
.footer-contact h3 { margin: 0 0 0.25rem; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 0.9rem; }
.footer-contact address { font-style: normal; line-height: 1.5; }
.footer-seal { width: 3.5rem; height: 3.5rem; display: block; }
.contact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; }
.contact-list li { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: baseline; }
.contact-label { min-width: 14.5rem; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.contact-list a { font-weight: 600; }
.contact-emergency { color: var(--bad); }
.footer-fine { margin-top: 0.9rem; }

/* —— Loading / errors —— */
#loading, .loading {
  position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 14px; z-index: 60; color: var(--text-muted);
}
#loading .ring {
  width: 46px; height: 46px; border: 4px solid var(--border); border-top-color: var(--brand-gold);
  border-radius: 50%; animation: spin2 1s linear infinite;
}
@keyframes spin2 { to { transform: rotate(360deg); } }
#loading .msg { font-size: 0.85rem; letter-spacing: 0.04em; }
.err-banner {
  background: var(--bad-soft); border: 1px solid var(--bad); color: var(--bad);
  padding: 1rem; border-radius: var(--radius); font-size: 0.85rem; display: none;
}

/* —— Responsive ——
   Wide (≥1101px): full 3-row wallboard grid, KPI tiles in one row, YoY tables + charts side by side.
   Laptop (≤1280px): bottom row → 2×2, YoY tables stack (keeps every column visible).
   Tablet (≤1100px): single-column rows. Phone (≤720px): compact header, 2-up KPI tiles. */
@media (max-width: 1280px) {
  .row-bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: auto; }
  .row-bottom > .sec { min-height: 22rem; }
  .yoy-top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .row-top, .row-mid, .yoy-top, .yoy-bottom { grid-template-columns: minmax(0, 1fr); min-height: auto; }
  .periods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-top > .sec { min-height: 20rem; }
  .sec .chart-box { height: 260px; flex: none; }
  .sec .chart-box.tall { height: 300px; min-height: 0; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .footer-contact { grid-template-columns: auto 1fr; }
  .contact-list { grid-column: 1 / -1; gap: 0.6rem; }
  .contact-list li { gap: 0.1rem; }
  .contact-label { min-width: 0; width: 100%; }
}
@media (max-width: 720px) {
  .app-header { position: static; padding: 0.75rem var(--gutter) 0.85rem; }
  .brand { gap: 0.7rem; align-items: flex-start; }
  .brand-seal { width: 3.25rem; height: 3.25rem; }
  .brand h1 { font-size: 1.02rem; }
  .subtitle { font-size: 0.8rem; }
  .nena-note { font-size: 0.7rem; }
  .header-actions { justify-content: flex-start; text-align: left; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .periods, .row-bottom { grid-template-columns: minmax(0, 1fr); }
  .ticker .item { font-size: 0.78rem; padding: 0 0.9rem; }
  .dr-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .yoy-src { margin-left: 0; }
  /* Phone: tables wrap their header labels and tighten so all columns fit without sideways scrolling */
  table.yt { font-size: 0.68rem; }
  table.yt th { white-space: normal; font-size: 0.58rem; padding: 0.45rem 0.22rem; vertical-align: bottom; }
  table.yt td { padding: 0.38rem 0.22rem; }
  table.yt td.y i { margin-right: 3px; }
}
@media (max-width: 480px) {
  /* Narrow phones: swatch-less year cell that may wrap ("2026 / YTD") and minimal cell padding */
  table.yt { font-size: 0.64rem; }
  table.yt th { font-size: 0.54rem; padding: 0.4rem 0.12rem; letter-spacing: 0.01em; }
  table.yt td { padding: 0.36rem 0.12rem; }
  table.yt th:first-child, table.yt td:first-child { padding-left: 0.3rem; }
  table.yt th:last-child, table.yt td:last-child { padding-right: 0.3rem; }
  table.yt td.y { white-space: normal; }
  table.yt td.y i { display: none; }
}
@media (max-width: 480px) {
  .sec { padding: 0.85rem 0.65rem 0.9rem; }
}
@media (max-width: 380px) {
  table.yt { font-size: 0.58rem; }
  table.yt th { font-size: 0.5rem; padding: 0.35rem 0.08rem; }
  table.yt td { padding: 0.32rem 0.08rem; }
}
