/* Dark Matter — the whole design system, no CDN and no build step, because this
   has to render on a laptop with no network during a demo.

   Structure: tokens, base, login, shell, layout, components, charts, tables,
   states, responsive. Every token is defined ONCE per mode. That is not tidiness
   for its own sake: --discussion previously had two definitions, one in :root and
   one scoped to .viz, so a chart in a container that happened to lack .viz
   silently rendered in a different blue than the one that was colour-validated. */

/* ==========================================================================
   1. Tokens
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Surfaces, lightest to most raised. */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e8ebf0;
  --border: #e3e6eb;
  --border-strong: #d3d8e0;

  /* Ink. Text never wears a series colour — identity comes from the mark. */
  --text: #14161a;
  --text-dim: #565d6b;
  --text-faint: #868d9b;

  /* UI accent, deliberately NOT one of the series hues. Buttons and focus rings
     competing with the data blue is how a chart stops reading as data. */
  --ui: #1c1f26;
  --ui-hover: #2c313b;
  --ui-on: #ffffff;
  --focus: #6d5bd0;
  --accent: #4a5160;
  --accent-soft: #eef0f4;

  /* Series. The validated categorical pair — slot 1 blue, slot 2 orange.
     Worst adjacent CVD ΔE 24.7 against an ≥8 target, normal-vision floor and
     ≥3:1 surface contrast both pass. Re-run the validator before editing a hex. */
  --discussion: #2a78d6;
  --meeting: #eb6834;
  --grid: #e6e9ee;

  --good: #1f7a4d;
  --warn-bg: #fdf4e7;
  --warn-text: #85571f;
  --warn-border: #f0dcbb;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-1: 0 1px 2px rgb(16 20 28 / 0.05);
  --shadow-2: 0 4px 16px rgb(16 20 28 / 0.08);
  --shadow-3: 0 10px 32px rgb(16 20 28 / 0.14);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    /* Selected, not inverted: each value re-chosen against the dark surface. */
    --bg: #0c0e12;
    --surface: #15181e;
    --surface-2: #1c2027;
    --surface-3: #242932;
    --border: #262b34;
    --border-strong: #343a45;

    --text: #e9ebf0;
    --text-dim: #a0a7b4;
    --text-faint: #6e7684;

    --ui: #e9ebf0;
    --ui-hover: #ffffff;
    --ui-on: #14161a;
    --focus: #9b8bf0;
    --accent: #a0a7b4;
    --accent-soft: #21252e;

    /* Same two hues, re-stepped for this surface. Worst adjacent CVD ΔE 26.8. */
    --discussion: #3987e5;
    --meeting: #d95926;
    --grid: #262b34;

    --good: #46b37a;
    --warn-bg: #2a2113;
    --warn-text: #e0b878;
    --warn-border: #45361b;

    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-2: 0 4px 16px rgb(0 0 0 / 0.4);
    --shadow-3: 0 10px 32px rgb(0 0 0 / 0.55);
  }
}

/* ==========================================================================
   2. Base
   ========================================================================== */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--focus); }
[hidden] { display: none !important; }

/* Every figure is tabular so columns of numbers line up and a changing value
   does not shift the text beside it on each 30s refresh. */
.stat, .num, .bar-value, .hbar-value, .trend-value, .theme-time,
.split-legend dd, .delta { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   3. Login
   ========================================================================== */

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 34px;
}
.login-card h1 { margin: 0; font-size: 27px; letter-spacing: -0.025em; }
.tagline { margin: 6px 0 26px; color: var(--text-dim); font-size: 14px; }
.lede { color: var(--text-dim); font-size: 14px; }
.lede code, .empty code {
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

.notice {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 14px;
  margin: 0 0 20px;
}

.stack { display: grid; gap: 8px; margin: 24px 0 16px; }
.stack label { font-size: 13px; font-weight: 600; color: var(--text-dim); }

input[type='email'] {
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  width: 100%;
}
input[type='email']:focus-visible { outline-offset: -1px; }

.fineprint { color: var(--text-faint); font-size: 12.5px; margin: 0; }

/* ==========================================================================
   4. Buttons
   ========================================================================== */

button { font: inherit; cursor: pointer; border: 0; }
button:disabled { opacity: 0.45; cursor: default; }

.btn, .login-card button[type='submit'] {
  padding: 10px 15px;
  border-radius: var(--r-sm);
  background: var(--ui);
  color: var(--ui-on);
  font-weight: 600;
  font-size: 14px;
  transition: background 120ms;
}
.btn:hover:not(:disabled), .login-card button[type='submit']:hover { background: var(--ui-hover); }

.btn-quiet, .viz-toggle, .linkish {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-weight: 550;
  font-size: 13px;
  padding: 6px 11px;
  border-radius: var(--r-sm);
  transition: background 120ms, color 120ms;
}
.btn-quiet:hover:not(:disabled), .viz-toggle:hover, .linkish:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ==========================================================================
   5. Shell
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner,
.tabs,
main {
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: 28px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-block: 13px;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  /* The name, drawn: a bright core with unaccounted-for mass around it. */
  background:
    radial-gradient(circle at 34% 34%, #fff 0 14%, transparent 15%),
    conic-gradient(from 210deg, var(--discussion), var(--meeting), var(--discussion));
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.06) inset;
}
.brand-name { font-weight: 680; letter-spacing: -0.02em; font-size: 16px; }

.sprint-pill {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.sprint-pill.overrun {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: var(--warn-border);
}

.spacer { flex: 1; }

.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.who img { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); }

.tabs { display: flex; gap: 2px; }
.tab {
  background: none;
  color: var(--text-faint);
  padding: 10px 2px;
  margin-right: 20px;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color 120ms;
}
.tab:hover { color: var(--text-dim); }
.tab[aria-selected='true'] { color: var(--text); border-bottom-color: var(--ui); }
.tab-badge {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 5px;
  vertical-align: 1.5px;
}

main { padding-block: 26px 72px; }

/* ==========================================================================
   6. Layout
   ========================================================================== */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 26px 28px;
}
.hero-split { border-left: 1px solid var(--border); padding-left: 28px; }
.hero-actions { display: grid; gap: 16px; }

.eyebrow {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.stat-hero { font-size: 46px; letter-spacing: -0.04em; }
.stat small { font-size: 0.42em; font-weight: 550; color: var(--text-faint); letter-spacing: 0; }

.sub { font-size: 13.5px; color: var(--text-dim); margin: 6px 0 0; }

.delta { margin: 10px 0 0; font-size: 13px; font-weight: 550; color: var(--text-dim); }
.delta.up { color: var(--meeting); }
.delta.down { color: var(--good); }

.grid { display: grid; gap: 14px; margin-top: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-charts { margin-top: 26px; align-items: start; }
.grid-charts .block { margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  padding: 17px 19px;
}
.card h3 { margin: 0 0 6px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }

.block { margin-top: 30px; }
.block-head {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin-bottom: 11px;
  flex-wrap: wrap;
}
.block-head h2 { font-size: 15px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.hint { font-size: 12.5px; color: var(--text-faint); }

.panel, .chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  padding: 18px 20px;
}

/* ---------- the split meter ---------- */

.meter {
  display: flex;
  gap: 2px;               /* the 2px surface gap, as a secondary encoding */
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}
.meter i { display: block; height: 100%; }
.meter i.d { background: var(--discussion); }
.meter i.m { background: var(--meeting); }

.split-legend { display: flex; gap: 26px; margin: 16px 0 0; flex-wrap: wrap; }
.split-legend > div { display: grid; gap: 2px; }
.split-legend dt { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.split-legend dd { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.split-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.split-legend i.d { background: var(--discussion); }
.split-legend i.m { background: var(--meeting); }

/* ==========================================================================
   7. Charts
   Marks follow the spec: thin, capped, 4px rounded data-end square at the
   baseline, 2px surface gaps between fills, recessive hairline gridlines, and a
   legend whenever two series are present so identity is never colour alone.
   ========================================================================== */

/* Identity is never colour alone: a legend is always present for two series. */
.chart-legend, .legend {
  display: flex;
  gap: 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.chart-legend span, .legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i, .legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chart-legend i.d, .legend i.discussion { background: var(--discussion); }
.chart-legend i.m, .legend i.meeting { background: var(--meeting); }

/* ---------- daily columns ---------- */

.daily { position: relative; }
.daily-plot { display: flex; align-items: flex-end; gap: 3px; height: 156px; position: relative; }

.daily-grid { position: absolute; inset: 0; pointer-events: none; }
.daily-grid div { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.daily-grid span {
  position: absolute; left: 0; transform: translateY(-50%);
  font-size: 10.5px; color: var(--text-faint);
  background: var(--surface); padding-right: 6px;
}

.day {
  flex: 1 1 0; min-width: 0; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
  cursor: default; position: relative;   /* hit target is the whole column */
}
.day-stack {
  width: 100%; max-width: 24px; margin: 0 auto;   /* cap the mark, leave air */
  display: flex; flex-direction: column; justify-content: flex-end;
  border-radius: 4px 4px 0 0; overflow: hidden;   /* rounded top, square base */
  gap: 2px;
  transition: filter 100ms;
}
.day-seg { width: 100%; }
.day-seg.d { background: var(--discussion); }
.day-seg.m { background: var(--meeting); }
.day:hover .day-stack { filter: brightness(1.1); }

.day-axis { display: flex; gap: 3px; margin-top: 8px; }
.day-axis div {
  flex: 1 1 0; min-width: 0; text-align: center;
  font-size: 10px; color: var(--text-faint);
  overflow: hidden; white-space: nowrap;
}
.day-axis div.weekend { opacity: 0.4; }

/* ---------- tooltip ---------- */

.tip {
  position: absolute; z-index: 20; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 9px 11px; font-size: 12.5px; line-height: 1.5;
  box-shadow: var(--shadow-3);
  white-space: nowrap; opacity: 0; transition: opacity 90ms;
}
.tip.on { opacity: 1; }
.tip b { font-variant-numeric: tabular-nums; }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.tip i.d { background: var(--discussion); }
.tip i.m { background: var(--meeting); }

/* ---------- horizontal bars: topics, and people ---------- */

.hbars, .bars { display: grid; gap: 9px; }

.hbar, .bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 200px) 1fr auto;
  gap: 14px;
  align-items: center;
}
.hbar-label, .bar-name {
  font-size: 13px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hbar-track, .bar-track {
  height: 18px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  gap: 2px;                /* segments never touch */
}
.hbar-fill, .bar-fill { height: 100%; border-radius: 3px; }
.hbar-fill.d, .bar-fill.discussion { background: var(--discussion); }
.hbar-fill.m, .bar-fill.meeting { background: var(--meeting); }
.hbar-value, .bar-value {
  font-size: 12.5px; color: var(--text-dim);
  min-width: 62px; text-align: right;
}

/* ---------- trend ---------- */

.trend { display: flex; align-items: flex-end; gap: 10px; height: 132px; }
.trend-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  gap: 6px;
}
.trend-bar {
  width: 100%; max-width: 24px;
  background: var(--surface-3);
  border-radius: 4px 4px 0 0;
  min-height: 3px;
}
/* The current sprint is the one being asked about; the rest are context. */
.trend-bar.current { background: var(--discussion); }
.trend-label { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.trend-value { font-size: 11.5px; color: var(--text-dim); }

/* ---------- table view toggle ---------- */

.viz-table { margin-top: 14px; }
.chart-empty { padding: 34px 12px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ==========================================================================
   8. Tables
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 15px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  position: sticky; top: 0;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.055em;
  color: var(--text-faint); font-weight: 650;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.topic { white-space: normal; min-width: 240px; color: var(--text); }

.pill {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.03em;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-dim);
  background: var(--surface-2);
}
.pill.meeting { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.mentions { color: var(--text-faint); font-size: 12px; }

/* ==========================================================================
   9. Themes
   ========================================================================== */

.headline {
  font-size: 16px; line-height: 1.5; margin: 0 0 16px;
  padding-left: 14px; border-left: 2px solid var(--discussion);
  color: var(--text);
}
.themes { display: grid; gap: 12px; }
.theme {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-1); padding: 15px 17px;
}
.theme-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }
.theme-name { font-weight: 650; font-size: 14.5px; }
.theme-time { color: var(--text-dim); font-size: 13px; }
.theme-summary { color: var(--text-dim); font-size: 13.5px; margin: 0 0 11px; }
.theme-topics { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-topic {
  font-size: 12.5px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 3px 9px; color: var(--text-dim);
}
.theme-topic b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

.cat {
  font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 650;
  padding: 2px 7px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--border);
}

/* ==========================================================================
   10. States
   ========================================================================== */

.empty {
  padding: 44px 20px; text-align: center;
  color: var(--text-dim); font-size: 14px; line-height: 1.6;
}
.stale {
  background: var(--warn-bg); color: var(--warn-text);
  border: 1px solid var(--warn-border); border-radius: var(--r-sm);
  padding: 10px 13px; font-size: 13px; margin-bottom: 12px;
}
.provenance { margin-top: 11px; font-size: 12px; color: var(--text-faint); }
.ticket-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ticket-status { font-size: 13px; color: var(--text-dim); }
.error { color: var(--meeting); font-size: 13px; }
.footnote { margin-top: 40px; font-size: 12.5px; color: var(--text-faint); max-width: 72ch; }

/* ==========================================================================
   11. Responsive
   ========================================================================== */

@media (max-width: 860px) {
  .topbar-inner, .tabs, main { padding-inline: 18px; }
  .hero { grid-template-columns: 1fr; gap: 22px; padding: 22px; }
  .hero-split { border-left: 0; border-top: 1px solid var(--border); padding-left: 0; padding-top: 22px; }
  .stat-hero { font-size: 38px; }
  .grid-charts { grid-template-columns: 1fr; }
  .hbar, .bar-row { grid-template-columns: minmax(90px, 130px) 1fr auto; gap: 10px; }
}

@media (max-width: 560px) {
  .stat-hero { font-size: 32px; }
  .who span { display: none; }
  .hbar, .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .hbar-value, .bar-value { text-align: left; }
}
