/* add3-reports design system — one theme for every client (for now).
   Purple = current period / primary accent. Teal = comparison period. */

/* Brand type: Montserrat everywhere (self-hosted variable font, OFL in
   static/fonts/). One face, weights 100-900, so no per-weight files. */
@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/Montserrat-VariableFont_wght.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/Montserrat-Italic-VariableFont_wght.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --accent: #534AB7;
  --accent-soft: rgba(127, 119, 221, 0.22);
  --accent-mid: #7F77DD;
  --compare: #0F6E56;
  --compare-soft: rgba(93, 202, 165, 0.22);
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-alt: #f3f1ee;
  --text: #1c1c1a;
  --text-2: #5f5e5a;
  --text-3: #898781;
  --border: rgba(20, 20, 20, 0.10);
  --good-bg: #eaf3de;
  --good-fg: #3b6d11;
  --bad-bg: #fcebeb;
  --bad-fg: #a32d2d;
  --warn-bg: #fdf3e0;
  --warn-fg: #8a5a00;
  --radius: 8px;
  color-scheme: light;
}

/* Fleet-wide dark mode (2026-08-05, DARK_MODE_PLAN.md). This block is the
   single source of dark-mode truth for every platform token: it exists so
   every client's shared chrome (.date-trigger/.tab/the djdash freeform
   toolbar/the scrollbar/...) goes dark for free the moment
   document.documentElement.dataset.theme is "dark" (set by main.py's
   THEME_BOOT_HTML boot script + static/components.js's A3.setTheme).
   Accent/compare stay the SAME as light — brand accents don't flip; only
   the platform's neutral surface/text/status tokens do. Values are the
   beacon dark-mode pilot's proven pair (clients/beacon/report.html's
   :root[data-theme="dark"] block), now promoted here so every report
   inherits it instead of each client restating it. */
:root[data-theme="dark"] {
  --bg: #141312;
  --surface: #1d1b19;
  --surface-alt: #282623;
  --text: #eceae5;
  --text-2: #a6a29a;
  --text-3: #7d7971;
  --border: rgba(255, 255, 255, 0.12);
  --good-bg: rgba(140, 191, 87, 0.14);
  --good-fg: #8CBF57;
  --bad-bg: rgba(224, 108, 108, 0.14);
  --bad-fg: #E06C6C;
  --warn-bg: rgba(217, 154, 43, 0.12);
  --warn-fg: #D99A2B;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Montserrat", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.report { max-width: 980px; margin: 0 auto; padding: 24px 20px 40px; }

.report-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 0.5px solid var(--border);
  border-top: 3px solid var(--accent-mid);
  border-radius: 12px; padding: 16px 20px; margin-bottom: 12px;
}
.report-header h1 { font-size: 20px; font-weight: 500; margin: 0; }
.report-header .sub { font-size: 13px; color: var(--text-2); margin: 2px 0 0; }
.header-right { position: relative; }

/* Shared icon button (source: clients/pemco-seo/report.html:55-60, the
   pilots' scoped duplicate) — promoted here so every report gets a
   consistent #themeBtn (and any future icon affordance) without a
   per-client copy. */
.icon-btn {
  font-family: inherit; font-size: 14px; color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; line-height: 1;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }

.date-trigger {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; cursor: pointer;
}
.date-trigger:hover { background: var(--surface-alt); }
.date-trigger .chev { color: var(--text-3); font-size: 11px; }

.date-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 220;
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: 12px; padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08);
}

/* ---- tab bar ---- */
.tabbar { display: flex; gap: 4px; border-bottom: 0.5px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
/* Chip-style tabs, promoted fleet-wide 2026-08-27. This treatment was
   authored for PEMCO on 2026-08-06 ("bare labels blended into the page's
   body text") and scoped there to `.tab-group-tabs .tab`, so every other
   report kept the old bare-label + thin-underline look — which read as
   unstyled next to the chips right below it. Boxed like the gallery's
   .exp-btn chips, using the SAME theme tokens, so a tab and a filter chip
   now announce "selected" the same way (solid accent fill) and both light
   and dark themes follow each client's own brand. */
.tab {
  font-size: 13.5px; padding: 6px 11px; cursor: pointer; color: var(--text-2);
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); white-space: nowrap; font-family: inherit;
}
/* accent-soft hover, never gray (Max, 2026-08-06) */
.tab:hover { background: var(--accent-soft); color: var(--text); border-color: var(--accent-mid); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.tabpane { display: none; }
.tabpane.active { display: block; }

.section-label { font-size: 13px; color: var(--text-2); margin: 20px 0 8px; }
.section-label:first-child { margin-top: 4px; }

/* Fluid card rows: pack as many cards as fit, and stretch to fill each row —
   including wrapped rows, which grid auto-fit can't do (tracks are uniform
   across rows, so a partial last row leaves dead space). Flex packs per row.
   --card-min is the density knob: override it in a client's scoped <style>
   block to change how many cards fit before wrapping. */
.card-grid {
  display: flex; flex-wrap: wrap;
  gap: 12px; margin-bottom: 12px;
}
.card-grid > * { flex: 1 1 var(--card-min, 170px); min-width: 0; }
.metric-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.metric-card .label { font-size: 13px; color: var(--text-3); }
.metric-card .value { font-size: 24px; font-weight: 500; }
.metric-card .delta { font-size: 12px; margin-top: 2px; color: var(--text-3); }
.pill { padding: 1px 7px; border-radius: 8px; font-size: 12px; }
.pill.good { background: var(--good-bg); color: var(--good-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.flat { background: var(--surface-alt); color: var(--text-2); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }

.note {
  font-size: 12.5px; color: var(--text-2); background: var(--surface-alt);
  border: 0.5px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; margin: 8px 0 12px;
}
.note b { color: var(--text); font-weight: 500; }

.chart-wrap { position: relative; height: 220px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 4px; }
.chart-short { height: 180px; }

.table-wrap { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 12px; text-align: right; white-space: nowrap; }
th.left, td.left { text-align: left; }
td.left { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
thead th { color: var(--text-3); font-weight: 500; border-bottom: 0.5px solid var(--border); }
tbody tr + tr td { border-top: 0.5px solid var(--border); }

/* drill-down rows */
tr.drillable { cursor: pointer; }
tr.drillable:hover td { background: var(--surface-alt); }
.caret { display: inline-block; width: 14px; color: var(--text-3); transition: transform .12s ease; font-size: 11px; }
tr.open .caret { transform: rotate(90deg); }
tr.child td { background: var(--surface-alt); font-size: 12.5px; color: var(--text-2); }
tr.child td.left { padding-left: 34px; }
tr.child.hidden { display: none; }

/* attribution-gap divider */
tr.gap-divider td {
  text-align: left; font-size: 11.5px; color: var(--text-3); background: var(--surface-alt);
  padding: 5px 12px; letter-spacing: .02em;
}
tr.gap td { color: var(--text-3); }

/* platform split cards */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }
.plat-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.plat-card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.plat-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; }
.plat-rows .kv .k { font-size: 11.5px; color: var(--text-3); }
.plat-rows .kv .v { font-size: 15px; font-weight: 500; }

/* funnel */
.funnel { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.f-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.f-label { width: 128px; font-size: 12.5px; color: var(--text-2); flex-shrink: 0; }
.f-track { flex: 1; height: 22px; background: var(--surface-alt); border-radius: 6px; overflow: hidden; }
.f-bar { height: 100%; background: var(--accent-mid); border-radius: 6px; min-width: 2px; }
.f-val { width: 130px; font-size: 12.5px; text-align: right; flex-shrink: 0; }
.f-val b { font-weight: 500; }
.f-rate { color: var(--text-3); }

.report-footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  font-size: 12px; color: var(--text-3); margin-top: 20px;
  border-top: 0.5px solid var(--border); padding-top: 10px;
}

/* Terms link appended next to "presented by Add3" by static/components.js
   (fleet-wide, 2026-09-14). Muted, not the accent fill (a filled accent link
   in a legal-notice line reads as a CTA, not a disclosure); underline only
   on hover/focus so the footer line stays quiet at rest; sized above the
   footer's own 12px per house style; inherits Montserrat from body. */
.a3-terms-link {
  color: var(--text-3);
  font-family: inherit;
  font-size: 14px;
  text-decoration: none;
}
.a3-terms-link:hover,
.a3-terms-link:focus-visible {
  color: var(--text-2);
  text-decoration: underline;
}

/* ---- date picker internals (rendered by datepicker.js) ---- */
.dp-body { display: flex; gap: 12px; flex-wrap: wrap; }
.dp-presets { width: 148px; flex-shrink: 0; border-right: 0.5px solid var(--border); padding-right: 12px; }
.dp-preset { font-size: 13px; padding: 5px 8px; border-radius: var(--radius); cursor: pointer; color: var(--text-2); }
.dp-preset:hover { background: var(--surface-alt); }
.dp-preset.active { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.dp-rel { border-top: 0.5px solid var(--border); margin-top: 8px; padding-top: 10px; }
.dp-rel label { font-size: 12px; color: var(--text-3); display: block; margin-bottom: 6px; }
.dp-rel input { width: 56px; font-size: 13px; padding: 4px 6px; border: 0.5px solid var(--border); border-radius: var(--radius); }
.dp-rel button { margin-top: 6px; width: 100%; }
.dp-cals { flex: 1; min-width: 0; }
.dp-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dp-months { display: flex; gap: 16px; justify-content: center; flex-wrap: nowrap; }
.dp-month-title { text-align: center; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 32px); }
.dp-dow { width: 32px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-3); }
.dp-day { width: 32px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; border-radius: var(--radius); }
.dp-day.in1 { background: var(--accent-soft); }
.dp-day.in2 { background: var(--compare-soft); }
.dp-day.end1 { background: var(--accent); color: #fff; font-weight: 500; }
.dp-day.end2 { background: var(--compare); color: #fff; font-weight: 500; }
.dp-day.today { outline: 1px solid var(--accent-mid); outline-offset: -1px; }
.dp-footer { border-top: 0.5px solid var(--border); margin-top: 12px; padding-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dp-footer select { font-size: 13px; padding: 4px 8px; border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.dp-readout { font-size: 12px; color: var(--text-2); margin-top: 8px; }
.dp-readout .p1 { color: var(--accent); font-weight: 500; }
.dp-readout .p2 { color: var(--compare); font-weight: 500; }
.dp-chips { display: flex; gap: 6px; }
.dp-chips[hidden] { display: none; }
button { font: inherit; font-size: 13px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 4px 12px; cursor: pointer; color: var(--text); }
button:hover { background: var(--surface-alt); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.chip-on1 { background: var(--accent); border-color: var(--accent); color: #fff; }
button.chip-on2 { background: var(--compare); border-color: var(--compare); color: #fff; }

/* On narrow screens, one navigable month keeps the picker usable without
   shrinking the day targets. The second month returns automatically above
   this breakpoint. */
@media (max-width: 671px) {
  .dp-months > div:nth-child(2) { display: none; }
}

@media (max-width: 520px) {
  .date-panel { padding: 10px; }
  .dp-body { display: block; }
  .dp-presets {
    width: 100%; border-right: 0; border-bottom: 0.5px solid var(--border);
    padding: 0 0 8px; margin-bottom: 8px;
  }
  .dp-preset-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; }
  .dp-preset { font-size: 12px; padding: 4px 6px; }
  .dp-rel { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding-top: 8px; }
  .dp-rel label { display: inline; margin: 0; }
  .dp-cals { width: 100%; }
  .dp-footer { align-items: stretch; }
  .dp-footer > div { justify-content: space-between; flex: 1 1 100%; }
}

/* ---- Explorer / slicer chips (.exp-btn) — shared FALLBACK -------------------
   Every report with an Explorer or a filter-slicer bar renders `.exp-btn`
   chips and marks the current choice with `.active` (report.js sets the
   class). The styling for them, including the selected state, has historically
   been pasted into each client's own <style> block — 55 clients carry an
   identical copy, and Rebode carried NONE, so its Explorer rail and its
   Platform/Channel/Region slicers rendered as unstyled buttons with NO visible
   selected state: the chart changed but nothing told you which chip you were
   on. (Reported from production 2026-08-27.)
   These rules live here as the fleet-wide floor so a report can never again
   ship chips with an invisible selection. A client's own inline block comes
   later in document order and still wins at equal specificity, so the 55
   existing copies are unaffected — this only fills a gap, it never restyles. */
/* The caption and the group box were missed when the .exp-btn floor landed
   earlier today, so on the 13 clients without their own copy the label sat
   flush against the first chip — "PlatformAll", "GrainDay" — with no gap and
   no muted caption treatment. Same fallback contract as the chips above:
   identical to the 55 clients' inline copies, and their own <style> block is
   later in document order, so it still wins at equal specificity. */
.exp-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 6px 8px; }
.exp-cap { font-size: 11px; color: var(--text-3); margin-right: 4px;
  text-transform: uppercase; letter-spacing: .03em; }
.exp-btn { font-size: 12px; padding: 4px 9px; border: 0.5px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text-2);
  cursor: pointer; font-family: inherit; }
.exp-btn:hover { background: var(--surface-alt); }
.exp-btn.active { background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 500; }

/* ---- Focus rings: keyboard yes, mouse no ---------------------------------
   `.tab` and `.exp-btn` are <button>s, and this stylesheet had NO focus
   handling at all — so clicking a tab or a chip left the BROWSER'S DEFAULT
   focus ring on it: a generic rounded-rect box, in the UA's own colour,
   sitting on top of (and louder than) the designed state. On a tab that
   default box visually outranked `.tab.active`'s accent underline, so the
   report read as unstyled/templated rather than branded. (Reported 2026-08-27.)

   `:focus-visible` is the fix, NOT `:focus { outline: none }` — the latter
   would strip the ring for keyboard users too and break navigation for
   anyone not using a mouse. Browsers apply :focus-visible only for keyboard
   /programmatic focus, so a mouse click now shows the DESIGNED state alone
   (the accent underline on a tab, the accent fill on a chip) while tabbing
   through still gets a clear, on-brand ring drawn in the client's own
   var(--accent) instead of the UA default. */
.tab:focus, .exp-btn:focus { outline: none; }
.tab:focus-visible, .exp-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }

/* ---- print / "Export to PDF" fallback (fleet-wide, 2026-09-08, dj-pdf-export-v1.1) ----
   static/pdf-export.js puts an "Export to PDF" button in every report header;
   where the server renderer is not enabled for the slug it falls back to the
   browser's print-to-PDF of the on-screen tab. This block is the shared version
   of the @media print rules kcu/demo/pemco/beacon/fredhutch each author locally
   (those stay; same declarations twice is harmless). Screen layout is untouched.
   Nothing here hides a .tabpane — Beacon's blank-sheet lesson: whichever pane is
   active when print fires is what prints. */
@media print {
  /* chrome, not report content: tab rail, date/theme/export controls, filter
     bar, fleet CSV pill, DJ Dash edit bar, staff presence row, our own export
     control and picker. */
  .tabbar, .header-right, #dimBar, #a3export-btn, .dj-bar, #dj-presence-row,
  .dj-pdf-control, .dj-pdf-panel { display: none !important; }
  /* light tokens regardless of the viewer's saved theme — the export button
     flips data-theme before printing; this catches a raw Ctrl+P that lands
     before the repaint. Values are the :root (light) block above, verbatim.
     Brand --accent* are deliberately NOT restated (they never flip). */
  :root, :root[data-theme="dark"] {
    --bg: #faf9f7; --surface: #ffffff; --surface-alt: #f3f1ee;
    --text: #1c1c1a; --text-2: #5f5e5a; --text-3: #898781;
    --border: rgba(20, 20, 20, 0.10);
    --good-bg: #eaf3de; --good-fg: #3b6d11;
    --bad-bg: #fcebeb; --bad-fg: #a32d2d;
    --warn-bg: #fdf3e0; --warn-fg: #8a5a00;
    color-scheme: light;
  }
  body { padding: 0; }
  /* .table-wrap is a scroll container on screen; paged media has no
     scrollbar, so release it and let a wide table flow across the page. */
  .table-wrap { overflow: visible; }
}
