/* Design tokens + dashboard/chart styles. Shared by the PWA and the e-mailed HTML report. */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #eef2f1; --ink: #14201e; --ink-2: #4b5b58; --ink-3: #7b8a87;
  --line: #dde4e2; --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #ddf1ee; --warn: #b45309; --warn-soft: #fdf1e1;
  --bad: #b91c1c; --bad-soft: #fde8e8; --ok: #15803d; --ok-soft: #e3f4e8; --info-soft: #e6f0fb; --shadow: 0 1px 2px rgba(16,24,23,.06), 0 4px 14px rgba(16,24,23,.06);
  --radius: 14px; --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1513; --surface: #16201e; --surface-2: #1d2a27; --ink: #e6efed; --ink-2: #a9bab6; --ink-3: #7d8f8b;
    --line: #2a3936; --brand: #2bb3a3; --brand-ink: #062a26; --brand-soft: #173a35; --warn: #f0a548; --warn-soft: #3a2a14;
    --bad: #f27474; --bad-soft: #3d1c1c; --ok: #4ed38a; --ok-soft: #173826; --info-soft: #172a3d; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1513; --surface: #16201e; --surface-2: #1d2a27; --ink: #e6efed; --ink-2: #a9bab6; --ink-3: #7d8f8b;
  --line: #2a3936; --brand: #2bb3a3; --brand-ink: #062a26; --brand-soft: #173a35; --warn: #f0a548; --warn-soft: #3a2a14;
  --bad: #f27474; --bad-soft: #3d1c1c; --ok: #4ed38a; --ok-soft: #173826; --info-soft: #172a3d; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  color-scheme: dark;
}

.dash { display: block; }
.dash h2 { font-size: 1.05rem; margin: 28px 0 12px; letter-spacing: .01em; }
.dash-filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; position: sticky; top: 0; z-index: 5; box-shadow: var(--shadow); }
.dash-filters label { display: flex; flex-direction: column; font-size: .72rem; color: var(--ink-2); gap: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.dash-filters input, .dash-filters select { font: inherit; font-size: .9rem; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 400; }
.dash-filters .chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chip { font: inherit; font-size: .8rem; border: 0; background: var(--brand-soft); color: var(--ink); border-radius: 99px; padding: 5px 10px; cursor: pointer; }
.dash-hint { color: var(--ink-3); font-size: .8rem; margin: 8px 2px 0; }
.dash-toc { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 2px; margin-top: 18px; scrollbar-width: thin; }
.dash-toc a { white-space: nowrap; font-size: .8rem; padding: 5px 11px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; }
.dash-toc a:hover { border-color: var(--brand); color: var(--brand); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.dash-grid.ov { margin-top: 14px; }
.dcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 12px; box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; }
.dcard.wide { grid-column: span 2; }
@media (max-width: 700px) { .dcard.wide { grid-column: auto; } .dash-grid { grid-template-columns: 1fr; } }
.dcard header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.dcard h3 { font-size: .92rem; margin: 0; flex: 1 1 200px; line-height: 1.35; font-weight: 650; }
.dcard header small { color: var(--ink-3); font-size: .74rem; }
.dcard .flip { font: inherit; font-size: .72rem; border: 1px solid var(--line); background: transparent; color: var(--ink-2); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.dcard .foot, .foot { color: var(--ink-3); font-size: .74rem; margin-top: 8px; }
.ch-empty { color: var(--ink-3); font-size: .85rem; padding: 18px 0; text-align: center; }
.ch-empty.big { padding: 60px 0; font-size: 1rem; }
[data-q] { cursor: pointer; }

/* KPIs */
.ch-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi span { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); font-weight: 600; }
.kpi b { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; margin: 2px 0; letter-spacing: -.02em; }
.kpi small { color: var(--ink-3); font-size: .74rem; }
.kpi .spark { position: absolute; right: 10px; bottom: 10px; width: 80px; height: 24px; }
.ch-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-bottom: 10px; }
.ch-stats div { background: var(--surface-2); border-radius: 10px; padding: 7px 10px; }
.ch-stats span { display: block; font-size: .68rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.ch-stats b { font-size: 1rem; font-variant-numeric: tabular-nums; }
.topbox { font-size: .85rem; color: var(--ink-2); margin-bottom: 8px; }
.topbox b { font-size: 1.5rem; color: var(--brand); margin-right: 4px; }

/* Horizontal bars */
.ch-hbar { display: flex; flex-direction: column; gap: 7px; }
.hb-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: .82rem; border-radius: 6px; }
.hb-row:hover .hb-bar { filter: brightness(1.1); }
.hb-row.active .hb-label { font-weight: 700; color: var(--brand); }
.hb-label { line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.hb-track { height: 14px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hb-bar { height: 100%; border-radius: 99px; min-width: 2px; transition: width .4s ease; }
.lolli .hb-track { height: 4px; overflow: visible; position: relative; }
.lolli .hb-bar { position: relative; }
.lolli .hb-bar::after { content: ""; position: absolute; right: -6px; top: -4px; width: 12px; height: 12px; border-radius: 50%; background: inherit; }
.hb-val { text-align: right; font-variant-numeric: tabular-nums; min-width: 64px; }
.hb-val b { font-weight: 650; }
.hb-val span { color: var(--ink-3); margin-left: 5px; font-size: .74rem; }

/* Donut / waffle / legend */
.ch-donut { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.ch-donut svg { width: 150px; height: 150px; flex: 0 0 auto; }
.ch-donut .seg { transition: opacity .2s; }
.ch-donut svg:hover .seg { opacity: .55; }
.ch-donut svg .seg:hover, .ch-donut .seg.active { opacity: 1; }
.d-big { font-size: 26px; font-weight: 750; fill: var(--ink); }
.d-sm { font-size: 11px; fill: var(--ink-2); }
.ch-legend { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; flex: 1 1 120px; min-width: 0; }
.ch-stack + .ch-legend { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }
.ch-legend span { display: flex; align-items: center; gap: 6px; }
.ch-legend i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.ch-legend b { margin-left: auto; font-variant-numeric: tabular-nums; padding-left: 6px; }
.ch-stack + .ch-legend b { margin-left: 0; }
.ch-waffle-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.ch-waffle { width: 140px; height: 140px; }
.ch-waffle rect:hover { opacity: .7; }
.wf-stats { display: flex; flex-direction: column; gap: 8px; }
.wf-stat b { font-size: 1.6rem; display: block; line-height: 1.1; letter-spacing: -.02em; }
.wf-stat span { font-size: .8rem; color: var(--ink-2); }

/* Stacked */
.ch-stack { display: flex; flex-direction: column; gap: 10px; }
.st-label { font-size: .8rem; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.st-label small { color: var(--ink-3); }
.st-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.st-bar div { display: flex; align-items: center; justify-content: center; font-size: .7rem; color: #fff; font-weight: 650; min-width: 0; overflow: hidden; }
.st-bar div:hover { filter: brightness(1.12); }

/* SVG charts */
.ch-hist, .ch-area, .ch-box, .ch-cal, .ch-points { width: 100%; height: auto; display: block; }
.ch-area { height: 180px; }
svg .grid { stroke: var(--line); stroke-width: 1; }
svg .ax { font-size: 10px; fill: var(--ink-3); }
svg .mean { stroke: var(--warn); stroke-dasharray: 3 3; stroke-width: 1.5; }
svg .mean-t { fill: var(--warn); }
svg .wh { stroke: var(--ink-3); stroke-width: 1.5; }
svg .out { fill: var(--surface); stroke: var(--ink-2); }
svg .cal-empty { fill: var(--surface-2); }
svg .pt-bg { fill: var(--surface-2); }
.ch-clock { width: 190px; height: 190px; display: block; margin: 0 auto; }
svg .clock-face { fill: var(--surface-2); }
.ch-gauge { width: 200px; max-width: 100%; display: block; margin: 0 auto 6px; }
.g-track { fill: none; stroke: var(--surface-2); stroke-width: 16; stroke-linecap: round; }
.g-val { fill: none; stroke-width: 16; stroke-linecap: round; }
.ch-stars { display: flex; align-items: baseline; gap: 2px; font-size: 1.6rem; margin-bottom: 10px; }
.ch-stars .star { position: relative; color: var(--surface-2); line-height: 1; }
.ch-stars .star span { position: absolute; left: 0; top: 0; overflow: hidden; color: #f59e0b; white-space: nowrap; }
.ch-stars b { font-size: 1.2rem; margin-left: 10px; }
.ch-stars > span:last-child { font-size: .85rem; color: var(--ink-3); margin-left: 3px; }
.ch-words { line-height: 1.5; text-align: center; padding: 4px 0 8px; }
.ch-words span { display: inline-block; margin: 0 5px; font-weight: 600; }
.latest { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 6px; }
.latest li { font-size: .82rem; background: var(--surface-2); border-radius: 8px; padding: 6px 10px; overflow-wrap: anywhere; }
.latest a { color: var(--brand); }
.rank { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: .85rem; }
.rank li span { margin-right: 8px; }
.rank b { color: var(--ink-3); font-weight: 500; font-size: .76rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--surface-2); display: block; }
.gallery.sig img { object-fit: contain; background: #fff; aspect-ratio: 2; }
.mapbox { height: 300px; border-radius: 10px; overflow: hidden; }
.others { margin-top: 10px; font-size: .8rem; color: var(--ink-2); }
.others summary { cursor: pointer; }
.ch-table { overflow-x: auto; }
.ch-table table { border-collapse: collapse; width: 100%; font-size: .8rem; }
.ch-table th, .ch-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ch-table th { color: var(--ink-2); font-weight: 600; font-size: .74rem; }
.ch-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ch-table.heat td { text-align: center; font-variant-numeric: tabular-nums; border: 2px solid var(--surface); border-radius: 6px; }
.ch-tip { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 1000; background: #111a18; color: #fff; padding: 6px 9px; border-radius: 8px; font-size: .78rem; max-width: 280px; opacity: 0; transition: opacity .12s; box-shadow: 0 4px 16px rgba(0,0,0,.25); font-family: var(--font); }
