/* Shared styles for the HTML dashboards */
/* Theme: True brand tones (red -> purple -> blue), as in the slide template */
:root {
  color-scheme: light;
  --page: #f6f5f8; --surface: #ffffff; --surface-2: #f1eff4;
  --ink: #141218; --ink-2: #4f4b57; --muted: #8a8592;
  --grid: #e6e3ea; --axis: #c9c4cf; --border: rgba(20,18,24,0.10);
  --brand: #e60012; --brand-2: #8e2a8b; --brand-3: #1e96e8;
  --s1: #e60012; --s2: #8e2a8b; --s3: #1e96e8; --s4: #f08a24;
  --other: #aaa5b0; --prev: #b3adb9;
  --good: #12a150; --good-ink: #0b7a3b; --good-wash: rgba(18,161,80,0.15);
  --bad: #d81b3c; --bad-ink: #c0102e; --bad-wash: rgba(216,27,60,0.14);
  --sel: #8e2a8b; --accent-wash: rgba(142,42,139,0.09);
  --grad: linear-gradient(90deg, #ff0000 0%, #c8102e 35%, #8e2a8b 65%, #1e96e8 100%);
  --grad-v: linear-gradient(180deg, #ff0000 0%, #c8102e 30%, #8e2a8b 65%, #1e96e8 100%);
}
/* light (white, like the slides) is the default; dark is opt-in from the Home page toggle */
:root[data-theme="dark"] {
    color-scheme: dark;
  --page: #121015; --surface: #1c1920; --surface-2: #27232c; --ink: #f3f1f5; --ink-2: #c6c1cc; --muted: #8f8996;
  --grid: #2e2a33; --axis: #3d3843; --border: rgba(255,255,255,0.10);
  --brand: #ff3341; --brand-2: #c357c0; --brand-3: #45abf0;
  --s1: #ff3341; --s2: #c357c0; --s3: #45abf0; --s4: #f5a04a;
  --other: #6e6875; --prev: #6e6875; --good: #22b866; --good-ink: #3ccf7c; --bad: #ff4d63; --bad-ink: #ff6b7d;
  --sel: #c357c0; --accent-wash: rgba(195,87,192,0.16);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }

/* slicers */
.slicer { position: relative; min-width: 130px; flex: 1 1 140px; max-width: 230px; }
.slicer > label { display: block; font-size: 11px; font-weight: 600; color: var(--ink-2); margin-bottom: 3px; }
.sl-btn { width: 100%; text-align: left; font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 26px 6px 10px; cursor: pointer; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 32px; }
.sl-btn::after { content: ""; position: absolute; right: 10px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); transform: translateY(-70%) rotate(45deg); }
.sl-btn.active { border-color: var(--sel); box-shadow: inset 0 0 0 1px var(--sel); }
.sl-pop { position: absolute; top: 100%; left: 0; margin-top: 4px; min-width: 100%; width: max-content; max-width: min(340px, 90vw); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 8px; z-index: 1001; }
.sl-pop input[type=search] { width: 100%; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--page); color: var(--ink); margin-bottom: 6px; }
.sl-opts { max-height: 280px; overflow-y: auto; }
.sl-pop label.opt { display: flex; gap: 8px; align-items: center; padding: 5px 4px; font-size: 13px; cursor: pointer; border-radius: 4px; }
.sl-pop label.opt:hover { background: var(--surface-2); }
.sl-pop label.opt.all { border-bottom: 1px solid var(--grid); margin-bottom: 4px; padding-bottom: 6px; font-weight: 600; }
.sl-more { font-size: 12px; color: var(--muted); padding: 6px 4px; }
.clear-btn { font: inherit; font-size: 12px; color: var(--ink-2); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; cursor: pointer; height: 32px; }
.clear-btn:hover { color: var(--ink); background: var(--surface); }

/* cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card h2 { font-size: 14px; margin: 0 0 10px; font-weight: 600; }
.card h2 .sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.kpi-label { font-size: 12px; color: var(--ink-2); }
.kpi-val { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-val small { font-size: 15px; font-weight: 400; color: var(--ink-2); }
.kpi-top { display: flex; gap: 28px; flex-wrap: wrap; }
.kpi-deltas { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 10px; border-top: 1px solid var(--grid); padding-top: 8px; }
.delta { font-size: 13px; }
.delta .d { font-weight: 600; }
.delta .vs { color: var(--ink-2); font-size: 12px; }
.up { color: var(--good-ink); } .down { color: var(--bad-ink); } .flat { color: var(--ink-2); }

/* tables */
.tbl-wrap { overflow: auto; max-height: 470px; }
table { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
th, td { padding: 4px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 600; z-index: 1; }
th:first-child, td:first-child { text-align: left; }
tr.grp td { font-weight: 600; }
tr.child td:first-child { padding-left: 28px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
tr.child[hidden] { display: none; }
tr.total td { font-weight: 700; border-top: 2px solid var(--axis); border-bottom: none; position: sticky; bottom: 0; background: var(--surface); }
.tog { cursor: pointer; border: 1px solid var(--axis); background: none; color: var(--ink-2); width: 16px; height: 16px; line-height: 12px; padding: 0; margin-right: 6px; border-radius: 3px; font-size: 12px; }
td.pct { position: relative; min-width: 60px; }
td.pct .bar { position: absolute; top: 3px; bottom: 3px; right: 0; border-radius: 2px; }
td.pct .bar.pos { background: var(--good-wash); } td.pct .bar.neg { background: var(--bad-wash); }
td.pct span { position: relative; }

/* charts / maps */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 380px; }
.map { height: 400px; border-radius: 8px; z-index: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend i.dash { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed var(--prev); vertical-align: 3px; }
.legend i.dot { width: 16px; height: 0; border-radius: 0; border-top: 2px dotted var(--ink-2); vertical-align: 3px; }
.empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }
.note { font-size: 12px; color: var(--muted); margin-top: 20px; }
.nodata { max-width: 640px; margin: 80px auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.nodata code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

/* click-to-filter (cross-filter) */
.pickable { cursor: pointer; }
tr.pickable:hover td, .row.pickable:hover { background: var(--accent-wash); }
tr.picked td, .row.picked, .plan.picked { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--sel); }
tr.picked td:not(:first-child) { box-shadow: none; }
.xf-host:empty { display: none; }
.xf-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 6px 5px 10px; border-radius: 999px; background: var(--sel); color: #fff; font-weight: 600; white-space: nowrap; }
.xf-clear { border: 0; background: rgba(255,255,255,.25); color: #fff; border-radius: 999px; width: 20px; height: 20px; cursor: pointer; font-size: 11px; line-height: 1; padding: 0; }
tr.ch-hdr td { font-weight: 700; background: var(--surface-2); }

/* brand touches */
body::before { content: ""; position: fixed; left: 0; top: 0; bottom: 0; width: 5px; background: var(--grad-v); z-index: 2000; pointer-events: none; }
h1 { color: var(--brand); }
.card h2 { color: var(--ink); }
.kpi-val { color: var(--ink); }
.home-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; background: var(--surface); }
.home-link:hover { color: var(--brand); border-color: var(--brand); }
.pg-nav { display: flex; gap: 6px; flex-basis: 100%; }

/* desktop header: full-width gradient band, like the mobile header and the title slide */
body { overflow-x: clip; }
body header.top { background: var(--grad); color: #fff; margin: -16px calc(50% - 50vw) 12px; padding: 12px calc(50vw - 50% + 16px) 14px; }
body header.top h1 { color: #fff; }
body header.top h1 small { color: rgba(255,255,255,.85); }
body header.top .asof { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.35); color: #fff; }
body header.top .asof b { color: rgba(255,255,255,.85); }
body header.top .chan-pill { background: rgba(255,255,255,.2); color: #fff; }
body header.top .home-link { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.35); color: #fff; }
body header.top .home-link:hover { background: rgba(255,255,255,.28); color: #fff; border-color: #fff; }
