/* Headroom overview: icon rail, KPI cards, the town, then the charts. Tokens come from ui/theme.css.
   Material: frosted glass over the shared backdrop (.hr-backdrop, injected by ui/motion.js). Every card is a leaf pane
   (--glass, the KPI cards --glass-ink); nothing that wraps a pane or a lens block is frosted, so each pane frosts the
   backdrop itself. Motion lives in ui/motion.css and ui/motion.js; this file never animates transform, opacity or filter. */
:root {
  /* names ui/overview.js uses inside its SVG charts */
  --c1: var(--s-grid); --c2: var(--s-limit); --c3: var(--s-backup); --warn: var(--s-trim); --danger: var(--s-off);
  --neutral: var(--s-neutral); --card: var(--surface); --panel: var(--primary);
  /* the website's session bar (web/session.css) reads these */
  --plum: var(--primary); --cream: #FFFFFF; --grid: var(--primary); --bg: var(--page);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 var(--fs-base)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
p { text-wrap: pretty; }
.hidden { display: none !important; }

/* ---------- glass panes: one material for every card ---------- */
.panel, .side-stats, .bigstats, .main > .town {
  background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow); border-radius: var(--r-lg); isolation: isolate; }
/* the chart panes lift a little under the pointer, like the landing page's ladder rows (motion.css times the change) */
@media (hover: hover) { .panel:hover { background-color: var(--glass-strong); } }
/* the landing page's sheen: a soft band of light that slides across a pane as it travels up the screen
   (--hr-p is written by the lens in ui/motion.js), so scrolling reads like tilting a sheet of glass.
   It sits under the pane's content (z-index -1 inside the pane), so chart and data colours stay exact. */
.panel::after, .side-stats::after, .bigstats::after, .kpi::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: linear-gradient(112deg, transparent 42%, rgb(255 255 255 / var(--sheen, 0.5)) 50%, transparent 58%) no-repeat;
  background-size: 320% 100%; background-position: calc(var(--hr-p, 0.5) * 100%) 0; }

/* ---------- frame: rail + centred column ---------- */
.shell { display: grid; grid-template-columns: 72px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 112px 0 24px; border-right: 1px solid var(--glass-line); background: rgba(255, 255, 255, 0.5);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: 1px 0 0 var(--glass-rule), 10px 0 32px -22px rgba(46, 36, 110, 0.22); }
.side-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-md); color: var(--muted);
  background: none; border: 0; cursor: pointer; text-decoration: none; }
.side-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-btn:hover { background: var(--glass-strong); color: var(--primary); box-shadow: var(--glass-shadow-lo); }
.side-btn.active { background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); box-shadow: inset 0 0 0 1px var(--glass-rule); }
.side-btn.bottom { margin-top: auto; }

.main { width: 100%; max-width: calc(var(--container) + 2 * 40px); margin: 0 auto; padding: 24px 40px 40px; }

/* ---------- header: a glass bar that stays on top while the dashboard scrolls under it (desktop) ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
  padding: 12px 14px; border-radius: var(--r-lg); background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow-lo); }
@media (min-width: 701px) and (min-height: 560px) { .top { position: sticky; top: 0; z-index: 10; } }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 40px; height: 40px; border-radius: 10px; display: block; flex: none; }
.brand h1 { font-size: var(--fs-lg); font-weight: 800; margin: 0; letter-spacing: -0.015em; line-height: 1.2; }
.sub { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--muted); }
/* the header stays readable with indigo KPI cards and town panels passing under it */
.top .sub { color: color-mix(in srgb, var(--ink) 78%, var(--muted)); }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.phase { font-size: var(--fs-sm); font-weight: 600; padding: 7px 12px; border-radius: var(--r-pill); line-height: 1; color: var(--ink);
  background: var(--glass-strong); box-shadow: inset 0 0 0 1px var(--glass-rule); }
.phase.bad { background: color-mix(in srgb, var(--s-off) 13%, transparent); color: var(--s-off-ink); }
.phase.warn { background: color-mix(in srgb, var(--s-backup) 15%, transparent); color: var(--s-backup-ink); }
.planning { font-size: var(--fs-sm); color: var(--muted); }
select { font: 500 var(--fs-sm)/1 var(--font); height: 40px; padding: 0 32px 0 12px; border-radius: var(--r-sm); border: 1px solid var(--glass-line);
  background: var(--glass-strong) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2367637D' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  box-shadow: var(--glass-shadow-lo); color: var(--ink); appearance: none; cursor: pointer; }
select:hover { background-color: rgba(255, 255, 255, 0.94); }
.btn { font: 600 var(--fs-sm)/1 var(--font); height: 40px; min-width: 96px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid var(--primary);
  background: var(--primary); color: var(--on-primary); cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 20px -10px rgba(76, 61, 168, 0.7); }
.btn:hover { background: var(--primary-strong); border-color: var(--primary-strong); }

.moment { display: flex; align-items: center; gap: 16px; margin: -8px 0 24px; padding: 14px 16px 14px 20px; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--primary-soft) 72%, transparent); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow-lo); }
.moment p { margin: 0; flex: 1; font-weight: 500; }
.tag { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary); white-space: nowrap; }

/* ---------- section headings: one style for every block ---------- */
.sec-h, figcaption { font-size: var(--fs-md); font-weight: 700; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 12px; }
.unit { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }

/* ---------- KPI row: indigo glass, then one white pane for the money and safety numbers ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr) minmax(220px, 0.9fr); gap: 20px; margin-bottom: 40px; align-items: stretch; }
/* indigo glass, a touch denser than --glass-ink so the small white notes keep 4.5:1 over the lightest backdrop */
.kpi { --sheen: 0.3; background: var(--glass-ink); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.16); color: var(--on-primary); border-radius: var(--r-lg); padding: 20px 22px; min-height: 124px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 16px 36px -16px rgba(46, 36, 110, 0.55);
  display: flex; flex-direction: column; justify-content: flex-end; position: relative; overflow: hidden; isolation: isolate; }
.kpi::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.06); pointer-events: none; }
.kpi-ic { position: absolute; top: 18px; left: 22px; width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.kpi-label { font-size: var(--fs-sm); font-weight: 600; margin-top: 30px; opacity: 0.94; }
.kpi-val { font-size: 32px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 2px 0; }
.kpi-note { font-size: var(--fs-xs); opacity: 0.92; }
.side-stats { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 14px 20px; }
.side-stats > div { display: flex; flex-direction: column; }
.side-stats > div + div { padding-top: 12px; border-top: 1px solid var(--glass-rule); }
.ss-label { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); line-height: 1.35; }
.ss-val { font-size: 26px; font-weight: 800; color: var(--primary); line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ss-note { font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; }
.side-stats.tall { gap: 22px; padding: 20px 22px; }
.side-stats.tall > div + div { padding-top: 22px; }

/* ---------- the town: the picture and its data panels sit in one pane, the art itself is untouched ---------- */
.main > .town { padding: 18px 20px 16px; }
.main > .town .town-art { border-radius: var(--r-md); }

/* ---------- chart grid ---------- */
.row2, .row3 { display: grid; gap: 24px; margin-bottom: 24px; align-items: stretch; }
.row2 { grid-template-columns: minmax(180px, 0.6fr) 1.3fr 1.5fr; }
.row3 { grid-template-columns: 1.2fr 1.2fr 0.9fr; }
.panel { position: relative; margin: 0; min-width: 0; padding: 20px 22px; }
.chart { display: block; width: 100%; height: 200px; overflow: visible; }
.row3 .chart { height: 180px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; min-height: 200px; }
#donut { width: 150px; height: 150px; flex: none; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; margin: 12px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.legend.col { flex-direction: column; gap: 10px; margin: 0; font-size: var(--fs-sm); }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; flex: none; }
.sw.dot { border-radius: 50%; }
.sw.ln { height: 2px; width: 16px; border-radius: 1px; }
.sw.ln.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }

.chart text { font: 500 11px var(--font); fill: var(--muted); }
.chart .gridl { stroke: var(--glass-rule); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit.on { fill: color-mix(in srgb, var(--primary) 6%, transparent); }

/* the two big numbers keep their warm blush, as a tinted pane */
.bigstats { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 20px 24px;
  background: color-mix(in srgb, var(--blush-soft) 62%, transparent); }
.big { display: flex; align-items: center; gap: 16px; }
.big svg { width: 48px; height: 48px; flex: none; fill: none; stroke: var(--primary); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.big > div { display: flex; flex-direction: column; }
.big-val { font-size: 30px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big-label { font-size: var(--fs-xs); color: var(--muted); }

.foot { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--glass-rule); font-size: var(--fs-xs); color: var(--muted);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.foot a { color: var(--primary); font-weight: 600; text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* tooltip: dark ink glass, so it reads over any chart */
.tip { position: fixed; z-index: 30; pointer-events: none; background: rgba(30, 27, 58, 0.9); color: #fff; font-size: var(--fs-xs); line-height: 1.45;
  -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.1); padding: 8px 10px; border-radius: var(--r-sm); max-width: 240px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 28px -12px rgba(30, 27, 58, 0.55); }
.tip b { font-weight: 700; }

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel, .side-stats, .main > .town, .top, .side { background: var(--glass-strong); }
  .kpi { background: var(--primary); }
}

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .main { padding: 20px 24px 32px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpis .side-stats, .row2 .side-stats.tall { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; gap: 28px; padding: 16px 22px; }
  .side-stats > div + div, .side-stats.tall > div + div { padding: 0 0 0 28px; border-top: 0; border-left: 1px solid var(--glass-rule); }
  .row2 { grid-template-columns: 1fr 1fr; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .bigstats { grid-column: 1 / -1; flex-direction: row; justify-content: space-around; }
}
@media (max-width: 700px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; justify-content: space-around; padding: 8px 16px; gap: 0;
    border-right: 0; border-top: 1px solid var(--glass-line); box-shadow: 0 -1px 0 var(--glass-rule); order: 2; }
  .side-btn.bottom { margin-top: 0; }
  .main { padding: 16px 16px 24px; }
  .top { padding: 12px; }
  .kpis, .row2, .row3 { grid-template-columns: 1fr; gap: 16px; }
  .moment { flex-wrap: wrap; }
  .moment p { flex-basis: 100%; }
  .kpis .side-stats, .row2 .side-stats.tall { flex-direction: column; gap: 12px; padding: 14px 20px; }
  .side-stats > div + div, .side-stats.tall > div + div { padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--glass-rule); }
  .main > .town { padding: 14px 14px 12px; }
  .bigstats { flex-direction: column; }
  .donut-wrap { gap: 16px; min-height: 0; }
  #donut { width: 116px; height: 116px; }
}
