/* ============================================================
   Iru — SDR Manager Digest
   Brand: deep navy #0C0C29 anchor · blue #3860BE accent · grotesk.
   Token system shared with the Artifact Hub (work-hub): OKLCH,
   tinted toward navy (hue 279), self-hosted Archivo, light + dark
   via [data-theme]. Tier colors (green/amber/red) stay the
   dashboard's diagnostic language, re-tuned per theme.
   ============================================================ */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/archivo.woff2') format('woff2');
}

/* Hide Alpine.js x-cloak elements until Alpine initializes — avoids
   flash-of-unstyled-content on the refresh button's "Refreshing…" state. */
[x-cloak] { display: none !important; }

/* ---------- Tokens ---------- */
:root {
  --grotesk: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: var(--grotesk);
  --font-mono: var(--mono);

  --r-1: 7px;     /* buttons, tabs, chips */
  --r-2: 11px;    /* cards, tables, modals */
  --radius-sm: var(--r-1);
  --radius: var(--r-2);
  --radius-lg: 14px;

  --ease: cubic-bezier(.2,.7,.2,1);
  --t: 180ms var(--ease);
  --hair: 1px;

  --wide: 1440px;
  --pad: clamp(16px, 2.5vw, 24px);
  --header-h: 56px;
}

/* Light — near-white grounds, navy ink, Iru blue accent */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg:            oklch(0.971 0.004 279);
  --surface:       oklch(0.995 0.0015 279);
  --surface-2:     oklch(0.978 0.003 279);
  --text:          oklch(0.19 0.05 279);
  --text-2:        oklch(0.36 0.04 279);
  --muted:         oklch(0.50 0.025 279);
  --muted-2:       oklch(0.62 0.018 279);
  --border:        oklch(0.90 0.006 279);
  --border-strong: oklch(0.84 0.008 279);

  --navy:          oklch(0.19 0.052 279);
  --navy-hi:       oklch(0.26 0.05 279);
  --on-navy:       oklch(0.97 0.008 279);
  --accent:        oklch(0.53 0.15 264);
  --accent-strong: oklch(0.47 0.16 264);
  --accent-wash:   oklch(0.53 0.15 264 / 0.07);
  --accent-wash-2: oklch(0.53 0.15 264 / 0.13);
  --on-accent:     oklch(0.99 0.005 264);
  --brand: var(--navy);
  --brand-accent: var(--accent);

  /* Tier palette — pill text / fill / border per tier. Same semantic
     thresholds as ever (>=85 green, >=60 amber, else red); hues pulled
     slightly toward the navy-tinted neutrals so the pills sit inside the
     Iru palette instead of stock Tailwind. */
  --green:         oklch(0.42 0.10 152);
  --green-bg:      oklch(0.95 0.045 152);
  --green-border:  oklch(0.80 0.10 152);
  --yellow:        oklch(0.47 0.10 80);
  --yellow-bg:     oklch(0.965 0.05 95);
  --yellow-border: oklch(0.83 0.115 95);
  --red:           oklch(0.45 0.14 25);
  --red-bg:        oklch(0.945 0.028 25);
  --red-border:    oklch(0.79 0.10 25);
  /* Bare day-cell text (no fill/border to anchor it) needs more chroma. */
  --tier-text-green:  oklch(0.55 0.135 152);
  --tier-text-yellow: oklch(0.60 0.135 85);
  --tier-text-red:    oklch(0.55 0.19 25);

  --shadow-sm: 0 1px 2px oklch(0.19 0.05 279 / 0.05), 0 2px 6px oklch(0.19 0.05 279 / 0.05);
  --shadow-md: 0 1px 2px oklch(0.19 0.05 279 / 0.05), 0 10px 28px oklch(0.19 0.05 279 / 0.07);
  --modal-scrim: oklch(0.13 0.03 279 / 0.55);
}

/* Dark — deep navy surfaces, near-white ink, luminous blue */
[data-theme="dark"] {
  color-scheme: dark;
  --bg:            oklch(0.17 0.028 279);
  --surface:       oklch(0.215 0.032 279);
  --surface-2:     oklch(0.245 0.034 279);
  --text:          oklch(0.96 0.006 279);
  --text-2:        oklch(0.80 0.012 279);
  --muted:         oklch(0.66 0.015 279);
  --muted-2:       oklch(0.55 0.016 279);
  --border:        oklch(0.30 0.02 279);
  --border-strong: oklch(0.38 0.022 279);

  --navy:          oklch(0.13 0.03 279);
  --navy-hi:       oklch(0.24 0.035 279);
  --on-navy:       oklch(0.96 0.006 279);
  --accent:        oklch(0.70 0.13 264);
  --accent-strong: oklch(0.80 0.10 264);
  --accent-wash:   oklch(0.70 0.13 264 / 0.12);
  --accent-wash-2: oklch(0.70 0.13 264 / 0.2);
  --on-accent:     oklch(0.16 0.03 279);

  --green:         oklch(0.84 0.10 152);
  --green-bg:      oklch(0.70 0.14 152 / 0.13);
  --green-border:  oklch(0.70 0.14 152 / 0.45);
  --yellow:        oklch(0.86 0.10 90);
  --yellow-bg:     oklch(0.75 0.13 95 / 0.13);
  --yellow-border: oklch(0.75 0.13 95 / 0.45);
  --red:           oklch(0.82 0.09 25);
  --red-bg:        oklch(0.65 0.16 25 / 0.15);
  --red-border:    oklch(0.65 0.16 25 / 0.5);
  --tier-text-green:  oklch(0.80 0.13 152);
  --tier-text-yellow: oklch(0.82 0.125 90);
  --tier-text-red:    oklch(0.74 0.16 25);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3), 0 2px 8px oklch(0 0 0 / 0.25);
  --shadow-md: 0 1px 2px oklch(0 0 0 / 0.3), 0 12px 30px oklch(0 0 0 / 0.36);
  --modal-scrim: oklch(0.08 0.02 279 / 0.66);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--grotesk);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.006em;
  font-feature-settings: "kern" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
button { font: inherit; }
a, button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---------- Navy property strip (Iru signal, scrolls away) ---------- */

.iru-strip { background: var(--navy); color: var(--on-navy); }
.iru-strip-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 7px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  letter-spacing: 0.02em;
  font-weight: 500;
}
.iru-strip-label { color: var(--on-navy); }
.iru-strip-meta { color: oklch(0.97 0.008 279 / 0.62); }

/* ---------- App header (sticky, blurred) ---------- */

.topbar {
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: var(--hair) solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--pad);
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  transition: opacity var(--t);
}
.brand:hover { opacity: 0.82; }
.brand-mark {
  width: 19px;
  height: 19px;
  flex: none;
  border-radius: 5px;
  background: var(--navy);
  position: relative;
}
[data-theme="dark"] .brand-mark { background: var(--on-navy); }
.brand-mark::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.03em;
}
.brand-context {
  padding-left: 11px;
  border-left: var(--hair) solid var(--border-strong);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.nav { display: flex; gap: 2px; margin-left: 4px; }
.nav-link {
  padding: 6px 11px;
  border-radius: var(--r-1);
  text-decoration: none;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  transition: color var(--t), background var(--t);
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.is-active { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.user-block {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13px;
  color: var(--text-2);
}
.user-name { color: var(--text-2); font-weight: 500; }
.signout {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--t);
}
.signout:hover { color: var(--accent-strong); }

.theme-toggle {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-items: center;
  padding: 0;
  width: 30px;
  height: 30px;
  cursor: pointer;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-2);
  border: var(--hair) solid var(--border-strong);
  transition: var(--t);
}
.theme-toggle:hover { background: var(--surface); color: var(--accent-strong); border-color: var(--accent); }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

.role-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: var(--hair) solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.role-pill.role-admin { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-strong); }
.role-pill.role-manager { background: var(--accent-wash); border-color: color-mix(in oklab, var(--accent) 45%, var(--border)); color: var(--accent-strong); }
.role-pill.role-sdr { background: var(--surface-2); }

/* Table-size preset (Smaller / Default / Larger). Scoped to the rep grid
   and monthly groups via `<html data-table-size="sm|md|lg">` (set by an
   inline head boot script + Alpine). */
.ui-scale {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: var(--hair) solid var(--border);
  border-radius: var(--r-1);
  background: var(--surface);
  overflow: hidden;
}
.ui-scale-label {
  padding: 0 10px 0 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
  border-right: var(--hair) solid var(--border);
  height: 26px;
  display: inline-flex;
  align-items: center;
}
.ui-scale .scale-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-left: var(--hair) solid var(--border);
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background var(--t), color var(--t);
}
.ui-scale .scale-btn:first-child { border-left: 0; }
.ui-scale .scale-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.ui-scale .scale-btn.is-active { background: var(--accent); color: var(--on-accent); }

/* Apply the chosen size only to the dashboard cards + monthly tables.
   zoom is layout-safe vs transform:scale. */
:root[data-table-size="sm"] .rep-grid-layout,
:root[data-table-size="sm"] .weekly-groups,
:root[data-table-size="sm"] .spiff-board { zoom: 0.9; }
:root[data-table-size="lg"] .rep-grid-layout,
:root[data-table-size="lg"] .weekly-groups,
:root[data-table-size="lg"] .spiff-board { zoom: 1.2; }

/* Sync status + refresh button in header */
.sync-status {
  font-size: 11px;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 999px;
  border: var(--hair) solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.sync-status.sync-success { color: var(--green); border-color: var(--green-border); background: var(--green-bg); }
.sync-status.sync-running { color: var(--accent-strong); border-color: var(--accent); background: var(--accent-wash); }
.sync-status.sync-failed { color: var(--red); border-color: var(--red-border); background: var(--red-bg); }

.refresh-form { margin: 0; display: inline; }
.refresh-btn {
  padding: 5px 11px;
  border-radius: var(--r-1);
  border: var(--hair) solid var(--border-strong);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: var(--t);
}
.refresh-btn:hover { background: var(--surface); color: var(--accent-strong); border-color: var(--accent); }
.refresh-btn:active { transform: translateY(1px); }
.refresh-btn:disabled { opacity: 0.6; cursor: default; }

/* Flash messages */
.flash-stack {
  max-width: var(--wide);
  margin: 10px auto 0;
  padding: 0 var(--pad);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.flash {
  padding: 9px 14px;
  border-radius: var(--r-1);
  font-size: 13px;
  border: var(--hair) solid;
  font-weight: 500;
}
.flash-success { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.flash-info { background: var(--accent-wash); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); color: var(--accent-strong); }
.flash-error { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }

/* ---------- Demo banner ---------- */

.demo-banner {
  background: var(--yellow-bg);
  border-bottom: var(--hair) solid var(--yellow-border);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  padding: 6px 16px;
}

/* ---------- Main / footer ---------- */

.main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 28px var(--pad) 56px;
}

.footer {
  margin-top: 24px;
  background: var(--navy);
  color: var(--on-navy);
}
.footer-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 18px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 11px;
  letter-spacing: 0.02em;
  font-weight: 500;
  color: oklch(0.97 0.008 279 / 0.7);
}
.footer .conf { color: var(--on-navy); display: inline-flex; align-items: center; }
.footer .conf::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
}

/* ---------- Dashboard header ---------- */

.dash-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.period-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.period-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
}
.period-select {
  padding: 6px 28px 6px 10px;
  border: var(--hair) solid var(--border);
  border-radius: var(--r-1);
  background-color: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%236b7280' d='M3 4.5l3 3 3-3z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  transition: border-color var(--t);
}
.period-select:hover { border-color: var(--border-strong); }
.period-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.scope-toggle {
  display: inline-flex;
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-1);
  padding: 2px;
  box-shadow: var(--shadow-sm);
}
.scope-btn {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t), color var(--t);
}
.scope-btn:hover { background: var(--surface-2); color: var(--text); }
.scope-btn.is-active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.scope-btn.is-active:hover { background: var(--accent); color: var(--on-accent); }

/* ---------- Dashboard controls row (color key + size toggle) ---------- */

.dash-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -12px 0 20px;
  flex-wrap: wrap;
}

.color-key {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
  font-size: 11px;
  color: var(--muted);
}
.color-key-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}
.color-key-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.color-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: var(--hair) solid;
}
.color-swatch.tier-red { background: var(--red-bg); border-color: var(--red-border); }
.color-swatch.tier-yellow { background: var(--yellow-bg); border-color: var(--yellow-border); }
.color-swatch.tier-green { background: var(--green-bg); border-color: var(--green-border); }

.dash-eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.dash-eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  flex: none;
}
.dash-week {
  margin: 0 0 8px;
  font-size: clamp(28px, 24px + 1.2vw, 38px);
  font-weight: 650;
  letter-spacing: -0.028em;
  color: var(--text);
  line-height: 1.02;
  text-wrap: balance;
}
.dash-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.dash-pacing-anchor {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 11px;
  background: var(--surface-2);
  border: var(--hair) solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.dash-pacing-anchor strong { color: var(--text); font-weight: 700; }
.dash-pacing-pct { color: var(--muted); margin-left: 2px; }
.dash-footnote {
  margin: 24px 0 0;
  padding-top: 14px;
  border-top: var(--hair) solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.dash-title-inline {
  color: var(--text-2);
  font-weight: 600;
}

/* ---------- Team totals ledger ----------
   Cross-rep weekly sums in the Artifact Hub "stat ledger" language: one
   bordered strip, hairline-divided cells, big tabular numbers. Bookings is
   the hero cell (Gabe's "how many meetings were booked this week?"). */

.team-stats {
  margin: 0 0 24px;
}
.team-stats-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
}
.team-stats-label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}
.team-stats-scope {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.team-stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 0;
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.team-stat {
  padding: 14px 16px 12px;
  border-right: var(--hair) solid var(--border);
  min-width: 0;
}
.team-stat:last-child { border-right: 0; }
.team-stat-num {
  display: block;
  font-weight: 650;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.team-stat-quota {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -0.01em;
}
.team-stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.team-stat-label .pct {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  border: var(--hair) solid;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
}
.team-stat .pct.tier-green { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.team-stat .pct.tier-yellow { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow); }
.team-stat .pct.tier-red { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.team-stat .pct.tier-none { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

/* Hero cell — Bookings. Accent wash + accent number so the answer to
   "how many meetings this week" is the first thing the eye lands on. */
.team-stat--hero {
  background: var(--accent-wash);
  box-shadow: inset 3px 0 0 var(--accent);
}
.team-stat--hero .team-stat-num { color: var(--accent-strong); }
.team-stat--hero .team-stat-label { color: var(--accent-strong); }

/* Qualified cell — green companion to the Bookings hero. */
.team-stat--good {
  background: var(--green-bg);
  box-shadow: inset 3px 0 0 var(--tier-text-green);
}
.team-stat--good .team-stat-num { color: var(--green); }
.team-stat--good .team-stat-label { color: var(--green); }

.team-stat.is-drillable { cursor: pointer; transition: background var(--t); }
/* Hover affordance is the wash alone — a dotted underline across the big
   number, label, and pct pill reads as clutter at this size. */
.team-stat.is-drillable:hover { background: var(--accent-wash); text-decoration: none; }
.team-stat--hero.is-drillable:hover { background: var(--accent-wash-2); }
.team-stat--good.is-drillable:hover { background: color-mix(in oklab, var(--green-bg) 78%, var(--green-border)); }

/* ---------- Track groups ---------- */

.track-group { margin-bottom: 32px; }
.track-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-1);
  box-shadow: var(--shadow-sm);
  /* Sticks below the sticky app header so the section label stays visible
     while scrolling through a long list of rep cards. */
  position: sticky;
  top: var(--header-h);
  z-index: 5;
}
.track-label { color: var(--text); }
.track-count {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
}

/* ---------- Rep grid layout ---------- */

.rep-grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 12px;
}

/* ---------- Rep card (compact) ---------- */

.rep-card {
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--t), box-shadow var(--t);
}
.rep-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.rep-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: var(--hair) solid var(--border);
  background: var(--surface-2);
  gap: 8px;
}
.rep-id {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.rep-id .rep-name {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  border: var(--hair) solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.tag-track { background: var(--accent-wash); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); color: var(--accent-strong); }
.tag-tz { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow); text-transform: none; letter-spacing: 0; }
/* Informational tag — the M1/M2 qualified ramp-pool note on the Monthly
   view. Mixed-case + tabular nums so "+2 from Apr" reads as data. */
.tag-carryover {
  background: var(--accent-wash);
  border-color: color-mix(in oklab, var(--accent) 40%, var(--border));
  color: var(--accent-strong);
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.form-hint { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* Stale-accounts tile in card header — uses tier-* color tokens */
.stale-tile {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: var(--hair) solid;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.stale-tile.tier-green { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.stale-tile.tier-yellow { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow); }
.stale-tile.tier-red { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.stale-tile.tier-none { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.stale-num { font-size: 13px; font-weight: 700; }
.stale-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

/* Tile cluster (header right side) — pairs the new-accounts pill with stale. */
.header-tiles {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* DQ'd pill — admin/manager-only counter rendered next to stale. */
.new-accounts-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: var(--hair) solid var(--green-border);
  background: var(--green-bg);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.new-accounts-num { font-size: 13px; font-weight: 700; }
.new-accounts-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

/* ---------- Rep table (compact) ---------- */

.rep-table-wrap { overflow-x: auto; }
.rep-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.rep-table th, .rep-table td {
  padding: 5px 4px;
  text-align: center;
  border-bottom: var(--hair) solid var(--border);
}
.rep-table thead th {
  font-weight: 500;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-bottom: var(--hair) solid var(--border);
  padding: 6px 4px;
}
.rep-table th.metric-col, .rep-table td.metric-col {
  text-align: left;
  padding-left: 12px;
  font-weight: 600;
  color: var(--text);
  font-size: 11px;
  width: 78px;
}
.rep-table thead th.metric-col { font-weight: 500; color: var(--muted); }
.rep-table tbody tr:last-child td, .rep-table tbody tr:last-child th { border-bottom: none; }
.rep-table tbody tr:hover td, .rep-table tbody tr:hover th { background: var(--surface-2); }

.day-col { width: 30px; padding: 5px 2px !important; }
.day-col.is-today { background: var(--accent-wash); }
.rep-table tbody tr:hover .day-col.is-today { background: var(--accent-wash-2); }
.rep-table thead th.day-col.is-today { background: var(--accent-wash-2); color: var(--accent-strong); font-weight: 700; }

.day-col.is-future { color: var(--muted-2); }

/* Click-to-inspect: day-column header is clickable when not a future day. */
.rep-table thead th.day-col.is-clickable { cursor: pointer; user-select: none; }
.rep-table thead th.day-col.is-clickable:hover { background: var(--accent-wash-2); }
.rep-table thead th.day-col.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Selected day mirrors the "today" highlight so the inspected column reads
   the same way as today does by default. */
.day-col.is-selected { background: var(--accent-wash); }
.rep-table tbody tr:hover .day-col.is-selected { background: var(--accent-wash-2); }
.rep-table thead th.day-col.is-selected { background: var(--accent-wash-2); color: var(--accent-strong); font-weight: 700; }

.num-col { width: 70px; padding: 5px 6px !important; }
.rep-table thead th.num-col { font-size: 11px; line-height: 1.15; }

/* Daily cell color by tier (text only — no full-cell fills, keeps the grid
   scannable). Amber gets the heavier weight: it reads lighter than red/green
   at the same weight. */
.tier-text-green { color: var(--tier-text-green); font-weight: 600; }
.tier-text-yellow { color: var(--tier-text-yellow); font-weight: 700; }
.tier-text-red { color: var(--tier-text-red); font-weight: 600; }

/* ---------- Tier pills (Pace / Total) ---------- */

.tier { font-weight: 600; }
.num-col.tier > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 2px 6px;
  border-radius: 999px;
  border: var(--hair) solid transparent;
  font-size: 11px;
}
.num-col.tier-green > span { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.num-col.tier-yellow > span { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow); }
.num-col.tier-red > span { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.num-col.tier-none > span { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

/* ---------- Totals column (raw week-sum / quota; no tier coloring) ---------- */

.rep-table .num-col.totals-col { white-space: nowrap; }
.rep-table .num-col.totals-col .count-num { font-weight: 700; color: var(--text); }
.rep-table .num-col.totals-col .count-quota { color: var(--muted); margin-left: 3px; font-weight: 500; }

/* ---------- Weekly report ---------- */

.weekly-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(880px, 1fr));
  align-items: start;
  gap: 16px;
}

.weekly-group {
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.weekly-group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: var(--hair) solid var(--border);
}
.weekly-group-label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text);
}
.weekly-group-count {
  color: var(--muted);
  font-size: 12px;
}

.weekly-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.weekly-table thead th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: var(--hair) solid var(--border);
}
.weekly-table thead th.metric-col {
  text-align: center;
  border-left: var(--hair) solid var(--border);
}
.weekly-table tbody th, .weekly-table tbody td {
  padding: 9px 12px;
  border-bottom: var(--hair) solid var(--border);
  font-size: 13px;
}
.weekly-table tbody tr:last-child th, .weekly-table tbody tr:last-child td { border-bottom: none; }
.weekly-table tbody tr:hover th, .weekly-table tbody tr:hover td { background: var(--surface-2); }

.weekly-table .rep-col {
  text-align: left;
  font-weight: 500;
  width: 20%;
  min-width: 140px;
}
.weekly-table .count-col {
  text-align: right;
  border-left: var(--hair) solid var(--border);
  width: 9%;
  white-space: nowrap;
  padding-right: 6px;
}
.weekly-table .dq-col {
  width: 7%;
  text-align: center;
}
.weekly-table .count-col.dq-col {
  padding-right: 12px;
  padding-left: 12px;
}
.weekly-table .count-num {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.weekly-table .count-quota {
  color: var(--muted);
  margin-left: 3px;
}
/* The .tag carryover note sits inline BEFORE `count-num / count-quota` so the
   right-aligned count stays in column with rows that have no carryover. */
.weekly-table .count-col .tag-carryover { margin-right: 8px; vertical-align: 1px; }
.weekly-table .pct-col {
  text-align: center;
  width: 8.5%;
  padding-left: 4px;
  padding-right: 4px;
}
.weekly-table .pace-col { background: var(--surface-2); }
.weekly-table thead th.pace-col { color: var(--muted); font-style: italic; }
.weekly-table tbody td.count-col.pace-col { border-left: var(--hair) dashed var(--border); }
.weekly-table tbody td.count-col.pace-col .count-num { font-weight: 600; color: var(--muted); }
.weekly-table .pct {
  display: inline-block;
  min-width: 42px;
  padding: 3px 8px;
  border-radius: 999px;
  border: var(--hair) solid;
  font-size: 12px;
  font-weight: 600;
}
.weekly-table .pct.tier-green { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.weekly-table .pct.tier-yellow { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow); }
.weekly-table .pct.tier-red { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.weekly-table .pct.tier-none { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

.weekly-table .total-row th, .weekly-table .total-row td {
  background: var(--surface-2);
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
}
.weekly-table .total-row .rep-col { color: var(--text); }

/* ---------- World Cup spiff ---------- */

.spiff-rules {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -10px 0 18px;
}
.spiff-rule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: var(--hair) solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.spiff-rule strong { color: var(--text); }

/* ---------- World Cup pitch banner ----------
   Prize strip styled as a soccer pitch: mowing-stripe greens, a chalk
   center line + circle, white "chalk marker" prize chips, and a ball that
   rolls in along the touchline on page load. Pitch greens are deliberately
   hardcoded per theme (a pitch is green in any theme); chip internals are
   theme-independent because the chips stay white on grass. */
.spiff-pitch {
  --pitch-1: oklch(0.58 0.105 145);
  --pitch-2: oklch(0.545 0.105 145);
  --pitch-chalk: oklch(1 0 0 / 0.55);
  --pitch-ink: oklch(0.985 0.008 145);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  margin: 0 0 16px;
  padding: 14px 18px 18px;
  border: var(--hair) solid oklch(0.46 0.09 148);
  border-radius: 12px;
  background: repeating-linear-gradient(90deg, var(--pitch-1) 0 72px, var(--pitch-2) 72px 144px);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .spiff-pitch {
  --pitch-1: oklch(0.42 0.085 148);
  --pitch-2: oklch(0.385 0.085 148);
  --pitch-chalk: oklch(1 0 0 / 0.4);
  border-color: oklch(0.34 0.07 148);
}
.spiff-pitch::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 32px, var(--pitch-chalk) 32px 34px, transparent 34px),
    linear-gradient(var(--pitch-chalk), var(--pitch-chalk)) 50% 0 / 2px 100% no-repeat;
  pointer-events: none;
}
.spiff-pitch-prizes,
.spiff-pitch-next {
  position: relative;
  z-index: 2;
}
.spiff-pitch-prizes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.spiff-pitch-kicker {
  margin-right: 4px;
  color: var(--pitch-ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px oklch(0.2 0.05 148 / 0.5);
}
.spiff-prize {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 7px;
  border-radius: 999px;
  background: oklch(0.99 0.003 145 / 0.94);
  color: oklch(0.3 0.06 152);
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 1px 3px oklch(0.2 0.06 148 / 0.35);
}
.spiff-prize-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: oklch(0.99 0.005 145);
}
.spiff-prize-1 .spiff-prize-rank { background: oklch(0.5 0.12 152); }
.spiff-prize-2 .spiff-prize-rank { background: oklch(0.5 0.14 264); }
.spiff-prize-3 .spiff-prize-rank { background: oklch(0.56 0.11 85); }
.spiff-pitch-next {
  margin: 0;
  color: var(--pitch-ink);
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 2px oklch(0.2 0.05 148 / 0.5);
}
.spiff-pitch-next-label {
  margin-right: 8px;
  padding: 2px 8px;
  border: 1px solid var(--pitch-chalk);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.spiff-pitch-ball {
  --spiff-roll: min(74vw, 580px);
  position: absolute;
  bottom: 5px;
  left: 10px;
  z-index: 3;
  margin: 0;
  padding: 2px;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  filter: drop-shadow(0 2px 2px oklch(0.2 0.06 148 / 0.45));
  animation: spiff-ball-roll 2.2s cubic-bezier(0.18, 0.7, 0.3, 1) 0.4s both;
}
.spiff-pitch-ball:hover { filter: drop-shadow(0 3px 4px oklch(0.2 0.06 148 / 0.6)) brightness(1.08); }
.spiff-goal-box {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 30px;
  height: 62px;
  transform: translateY(-50%);
  border: 2px solid var(--pitch-chalk);
  pointer-events: none;
}
.spiff-goal-box-left { left: 0; border-left: 0; }
.spiff-goal-box-right { right: 0; border-right: 0; }
.spiff-goal-flash {
  position: absolute;
  right: 44px;
  bottom: 8px;
  z-index: 3;
  color: oklch(0.99 0.01 145);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px oklch(0.2 0.06 148 / 0.7);
  opacity: 0;
  pointer-events: none;
}
.spiff-goal-flash.is-on { animation: spiff-goal-flash 1.1s ease-out both; }
@keyframes spiff-goal-flash {
  0%   { opacity: 0; transform: translateY(4px) scale(0.7); }
  18%  { opacity: 1; transform: translateY(0) scale(1.12); }
  32%  { transform: translateY(0) scale(1); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px) scale(0.96); }
}
@keyframes spiff-ball-roll {
  0%   { transform: translateX(0) rotate(0turn); }
  72%  { transform: translateX(var(--spiff-roll)) rotate(1.75turn); }
  86%  { transform: translateX(calc(var(--spiff-roll) - 18px)) rotate(1.68turn); }
  100% { transform: translateX(calc(var(--spiff-roll) - 10px)) rotate(1.71turn); }
}
@media (prefers-reduced-motion: reduce) {
  .spiff-pitch-ball {
    animation: none;
    transform: translateX(calc(var(--spiff-roll) - 10px));
  }
}

.spiff-leader-trophy {
  margin-right: 7px;
  font-size: 0.85em;
}

.spiff-summary-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1fr) minmax(280px, 1.2fr);
  gap: 12px;
  margin: 0 0 16px;
}
.spiff-summary-card .metric-value {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.spiff-leader-name {
  font-size: 22px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.spiff-board { margin-bottom: 16px; }
.spiff-table-wrap { overflow-x: auto; }
.spiff-table { min-width: 780px; }
.spiff-table th,
.spiff-table td { vertical-align: middle; }
.spiff-table .spiff-rank-col {
  width: 72px;
  text-align: center;
}
.spiff-table .rep-col { min-width: 210px; width: 28%; }
.spiff-table .count-col {
  text-align: center;
  padding-left: 12px;
  padding-right: 12px;
}
.spiff-table .count-num {
  display: inline-block;
  min-width: 3ch;
  text-align: center;
}
.spiff-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border: var(--hair) solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
/* Prize-position highlights — tier 1 (#1, $500) green, tier 2 (#2, $200)
   accent blue, tier 3 (#3-5, swag) amber. Tiered washes + a left accent bar
   so the paid placements pop at a glance. */
.spiff-table tr.spiff-tier-1 th,
.spiff-table tr.spiff-tier-1 td { background: var(--green-bg); }
.spiff-table tr.spiff-tier-1 > :first-child { box-shadow: inset 3px 0 0 var(--tier-text-green); }
.spiff-tier-1 .spiff-rank {
  background: var(--green);
  border-color: var(--green);
  color: var(--on-accent);
}
.spiff-table tr.spiff-tier-2 th,
.spiff-table tr.spiff-tier-2 td { background: var(--accent-wash-2); }
.spiff-table tr.spiff-tier-2 > :first-child { box-shadow: inset 3px 0 0 var(--accent); }
.spiff-tier-2 .spiff-rank {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.spiff-table tr.spiff-tier-3 th,
.spiff-table tr.spiff-tier-3 td { background: var(--yellow-bg); }
.spiff-table tr.spiff-tier-3 > :first-child { box-shadow: inset 3px 0 0 var(--yellow-border); }
.spiff-tier-3 .spiff-rank {
  background: var(--yellow-bg);
  border-color: var(--yellow-border);
  color: var(--yellow);
}
.spiff-prize-tag {
  display: block;
  margin-top: 4px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.spiff-tier-1 .spiff-prize-tag { color: var(--tier-text-green); }
.spiff-tier-2 .spiff-prize-tag { color: var(--accent-strong); }
.spiff-tier-3 .spiff-prize-tag { color: var(--tier-text-yellow); }
.spiff-rep-name {
  display: block;
  font-weight: 700;
  color: var(--text);
}
.spiff-rep-email {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.spiff-points-col .count-num {
  color: var(--accent-strong);
  font-size: 18px;
}
.spiff-group-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.spiff-mini-table .rep-col {
  width: auto;
  color: var(--muted);
}
.spiff-mini-table .count-col {
  width: 96px;
  text-align: center;
  padding-left: 12px;
  padding-right: 12px;
}

/* ---------- Empty state ---------- */

.empty-card {
  background: var(--surface);
  border: var(--hair) dashed var(--border-strong);
  border-radius: var(--r-2);
  padding: 40px 24px;
  text-align: center;
}
.empty {
  margin: 0;
  color: var(--muted);
}
.empty-state {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

/* ---------- Inline info banner ---------- */

.banner {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: var(--r-1);
  font-size: 13px;
  line-height: 1.5;
  border-left: 3px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
}
.banner code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--accent-wash);
  padding: 1px 5px;
  border-radius: 4px;
}
.banner a { color: var(--accent-strong); font-weight: 500; }
.banner-info {
  background: var(--yellow-bg);
  border-left-color: var(--yellow-border);
  color: var(--yellow);
}

/* ---------- Metric grid (KPI tiles) ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 0 0 24px;
}
.metric-card {
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.metric-value {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.metric-detail {
  font-size: 12px;
  color: var(--muted);
}

.attribution-section {
  margin: 0 0 24px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: var(--r-1);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: var(--hair) solid var(--border-strong);
  cursor: pointer;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-2);
  transition: var(--t);
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); transform: translateY(-1px); }
.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
}

/* ---------- Login (drenched navy poster) ---------- */

body.login-body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--navy);
  color: var(--on-navy);
  padding: clamp(20px, 5vw, 48px);
}
.login-card {
  width: 100%;
  max-width: 33rem;
  margin-inline: auto;
}
.login-mark {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--on-navy);
  margin-bottom: 32px;
  position: relative;
}
.login-mark::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: oklch(0.53 0.15 264);
}
.login-kicker {
  margin: 0 0 9px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: oklch(0.97 0.008 279 / 0.75);
}
.login-title {
  margin: 0;
  font-weight: 600;
  font-size: clamp(34px, 24px + 4vw, 52px);
  line-height: 1.0;
  letter-spacing: -0.03em;
  color: var(--on-navy);
}
.login-note {
  margin: 22px 0 28px;
  max-width: 30rem;
  font-size: 15px;
  line-height: 1.5;
  color: oklch(0.97 0.008 279 / 0.82);
}
.login-note code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: oklch(1 0 0 / 0.08);
  border-radius: 4px;
  padding: 1px 5px;
}
.login-flash {
  margin: 0 0 18px;
  padding: 10px 14px;
  border: var(--hair) solid oklch(1 0 0 / 0.16);
  border-radius: var(--r-2);
  background: oklch(1 0 0 / 0.055);
  color: var(--on-navy);
  font-size: 13px;
  font-weight: 500;
}
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: var(--r-1);
  background: oklch(0.53 0.15 264);
  color: oklch(0.99 0.005 264);
  border: var(--hair) solid oklch(0.53 0.15 264);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  transition: var(--t);
}
.btn-google:hover { background: oklch(0.47 0.16 264); border-color: oklch(0.47 0.16 264); transform: translateY(-1px); }
.login-dev-note {
  margin: 22px 0 0;
  color: oklch(0.97 0.008 279 / 0.62);
  font-size: 12px;
}
.login-dev-note code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: oklch(1 0 0 / 0.08);
  border-radius: 4px;
  padding: 1px 5px;
}
.login-foot {
  margin-top: 56px;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: oklch(0.97 0.008 279 / 0.5);
  font-weight: 500;
}

/* ---------- Admin panel ---------- */

.admin {
  max-width: 1200px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-title {
  font-size: 22px;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.02em;
}

.admin-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: var(--hair) solid var(--border);
}

.admin-subnav-link {
  padding: 8px 14px;
  text-decoration: none;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t);
}
.admin-subnav-link:hover { color: var(--text); }
.admin-subnav-link.is-active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.admin-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.admin-card {
  display: block;
  padding: 20px;
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--t), box-shadow var(--t);
}
.admin-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.admin-card h2 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.admin-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
  overflow: hidden;
}
.data-table thead {
  background: var(--surface-2);
  border-bottom: var(--hair) solid var(--border);
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.data-table td {
  padding: 10px 12px;
  border-top: var(--hair) solid var(--border);
  font-size: 13px;
}
.data-table tr.row-inactive { opacity: 0.55; }
.data-table .mono { font-family: var(--mono); font-size: 12px; }
.data-table .muted { color: var(--muted); }
.data-table .row-actions { white-space: nowrap; }
.data-table .row-actions a { margin-right: 10px; color: var(--accent-strong); text-decoration: none; font-weight: 500; }
.data-table .row-actions a:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }
.link-btn {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

/* Inline-editable reps table */
.hidden-form { display: none; }
.reps-bulk-form { margin: 0; }
.reps-bulk-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}
.reps-edit-table { table-layout: auto; }
.reps-edit-table th,
.reps-edit-table td {
  padding: 6px 8px;
  vertical-align: middle;
}
.reps-edit-table .row-actions { padding-right: 12px; }
.cell-input {
  width: 100%;
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: 5px;
  box-sizing: border-box;
}
.cell-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-wash-2);
}
.cell-input--name { min-width: 110px; }
.cell-input--email { min-width: 150px; }
.cell-input--track { min-width: 92px; }
.cell-input--date {
  min-width: 0;
  width: 122px;
  font-size: 12px;
}
.cell-input--num {
  width: 3.4em;
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  padding: 4px;
  /* Hide number-input spinners — they steal horizontal space. */
  -moz-appearance: textfield;
  appearance: textfield;
}
.cell-input--num::-webkit-outer-spin-button,
.cell-input--num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.cell-quotas {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.quota-units {
  display: block;
  margin-top: 2px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--muted);
}

.form-stack {
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
  padding: 24px;
  max-width: 720px;
}

.form-group {
  border: none;
  padding: 0;
  margin: 0 0 24px;
}
.form-group legend {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-2);
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=number],
.form-group input[type=date],
.form-group select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border: var(--hair) solid var(--border);
  border-radius: var(--r-1);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.form-group input[type=text]:focus,
.form-group input[type=email]:focus,
.form-group input[type=number]:focus,
.form-group input[type=date]:focus,
.form-group select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.form-group input:disabled,
.form-group select:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
.form-group .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-group .checkbox-label input[type=checkbox] {
  margin: 0;
  width: auto;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.empty {
  color: var(--muted);
  background: var(--surface);
  padding: 24px;
  border: var(--hair) dashed var(--border);
  border-radius: var(--r-2);
  text-align: center;
  font-size: 13px;
}

/* ---------- Links matrix ---------- */

.links-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
}

.links-matrix {
  border: none;
  border-radius: 0;
}

.links-matrix th.rep-col {
  min-width: 80px;
  padding: 8px 4px;
  vertical-align: bottom;
  background: var(--surface-2);
  text-align: center;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: 0;
}
.links-matrix th.rep-col .rep-first,
.links-matrix th.rep-col .rep-last {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
}
.links-matrix th.rep-col .rep-last {
  color: var(--muted);
}

.links-matrix td.sticky-col,
.links-matrix th.sticky-col {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  min-width: 180px;
  white-space: nowrap;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
}
.links-matrix th.sticky-col {
  background: var(--surface-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--muted);
}

.link-cell {
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted-2);
  width: 36px;
  padding: 8px 0 !important;
  user-select: none;
  transition: background var(--t);
}
.link-cell:hover { background: var(--accent-wash); }
.link-cell.is-linked {
  color: var(--green);
  background: var(--green-bg);
  font-weight: 600;
}
.link-cell.is-linked:hover {
  background: color-mix(in oklab, var(--green-bg) 70%, var(--green-border));
}

/* ---------------------------------------------------------------------------
   Drill-down modal — clickable Sequenced/Bookings/Qualified cells open a
   centered overlay listing the underlying HubSpot records.
   --------------------------------------------------------------------------- */
.drill-modal-mount { /* empty by default; HTMX fills it */ }
.drill-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.drill-modal-panel {
  background: var(--surface);
  color: var(--text);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-md);
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drill-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: var(--hair) solid var(--border);
  background: var(--surface-2);
}
.drill-modal-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}
.drill-modal-sep { color: var(--muted-2); margin: 0 6px; }
.drill-modal-rep { color: var(--text); }
.drill-modal-period { color: var(--text-2); }
.drill-modal-metric { color: var(--text-2); }
.drill-modal-count { color: var(--muted); margin-left: 6px; font-weight: 500; }
.drill-modal-pipeline {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green);
  border: var(--hair) solid var(--green-border);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.drill-modal-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.drill-modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  transition: color var(--t);
}
.drill-modal-close:hover { color: var(--text); }
/* Segmented Company/Sequence + Recent/A-Z toggles. Per-modal-open state. */
.drill-group-toggle,
.drill-sort-toggle {
  display: inline-flex;
  background: var(--bg);
  border: var(--hair) solid var(--border);
  border-radius: var(--r-1);
  padding: 2px;
  gap: 2px;
}
.drill-group-btn,
.drill-sort-btn {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.drill-group-btn:hover,
.drill-sort-btn:hover { color: var(--text); }
.drill-group-btn-active,
.drill-sort-btn-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.drill-group-btn-active:hover,
.drill-sort-btn-active:hover { background: var(--surface); }
.drill-modal-drift {
  margin: 0;
  padding: 8px 20px;
  font-size: 12px;
  color: var(--yellow);
  background: var(--yellow-bg);
  border-bottom: var(--hair) solid var(--yellow-border);
}
.drill-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 0;
  /* Prevent scroll chaining into the dashboard underneath. */
  overscroll-behavior: contain;
}
.drill-list { list-style: none; padding: 0; margin: 0; }
.drill-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 10px 20px;
  border-bottom: var(--hair) solid var(--border);
  font-size: 13px;
}
.drill-row:last-child { border-bottom: none; }
.drill-row:hover { background: var(--surface-2); }
.drill-primary {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  color: var(--text);
}
.drill-secondary {
  grid-column: 1;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.drill-name { font-weight: 600; }
.drill-amount { color: var(--green); font-weight: 600; font-variant-numeric: tabular-nums; }
.drill-email { color: var(--text-2); }
.drill-category {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-wash-2);
  color: var(--accent-strong);
}
.drill-cat-pff { background: var(--yellow-bg); color: var(--yellow); }
.drill-cat-csql { background: var(--accent-wash-2); color: var(--accent-strong); }
.drill-cat-sql { background: var(--green-bg); color: var(--green); }
.drill-company { font-weight: 500; }
.drill-sequence { color: var(--muted); }
.drill-sep { color: var(--border-strong); }
.drill-contact-email { color: var(--muted-2); }
/* Grouped views — sticky group header so the active bucket label stays
   visible while scrolling a long group. */
.drill-group + .drill-group { margin-top: 4px; }
.drill-group-header {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  border-bottom: var(--hair) solid var(--border);
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: baseline;
  gap: 6px;
  z-index: 1;
}
.drill-group-label { color: var(--text); }
.drill-group-count { color: var(--muted-2); font-weight: 500; }
/* Linked entity names — inherit the row's text color, no underline until
   hover. The right-column icon carries the "open in HubSpot" affordance. */
.drill-anchor {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.drill-anchor:hover { text-decoration: underline dotted; }
.drill-anchor:visited { color: inherit; }
/* Right-column external-link icon — opens the drilled record in HubSpot.
   Hover keeps HubSpot's orange as a deliberate "leaving for HubSpot" cue. */
.drill-link-icon {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--muted-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--t), background var(--t);
}
.drill-link-icon:hover { color: #ff7a59; background: oklch(0.70 0.16 45 / 0.12); }
.drill-link-icon svg { display: block; }
.drill-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}
/* Loading shell — painted instantly on click so the user gets feedback
   before the HubSpot round-trip completes. */
.drill-modal-loading {
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  min-height: 200px;
}
.drill-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: drill-spin 800ms linear infinite;
}
.drill-loading-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}
@keyframes drill-spin {
  to { transform: rotate(360deg); }
}
/* When the modal is open, lock the page beneath from scrolling. */
body.drill-modal-open { overflow: hidden; }

/* Drillable count cells get a subtle affordance: cursor + dotted underline
   on hover (not always-on, to keep the dashboard looking calm). */
.is-drillable { cursor: pointer; }
.is-drillable:hover { text-decoration: underline dotted; }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .topbar-inner { gap: 12px; }
  .nav { display: none; }
  .user-name { display: none; }
  .brand-context { display: none; }
  .iru-strip-meta { display: none; }
  .main { padding: 20px 16px 32px; }
  .dash-week { font-size: 28px; }
  .rep-grid-layout { grid-template-columns: 1fr; }
  .spiff-summary-grid { grid-template-columns: 1fr; }
  .team-stats-strip { grid-template-columns: repeat(2, 1fr); }
  .team-stat { border-bottom: var(--hair) solid var(--border); }
  .team-stat:nth-child(even) { border-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Print ---------- */

@media print {
  :root, [data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #f6f7f9;
    --text: #0c0c29; --text-2: #333; --muted: #555; --muted-2: #777;
    --border: #ddd; --border-strong: #bbb;
    --navy: #0c0c29; --on-navy: #fff;
    --accent: #3860be; --accent-strong: #2f4f9e;
    --accent-wash: #f1f4fb; --accent-wash-2: #e3eaf8; --on-accent: #fff;
  }
  .iru-strip, .topbar, .footer, .dash-controls, .header-controls,
  .refresh-form, .theme-toggle { display: none !important; }
  body { background: #fff; color: #0c0c29; }
  .rep-card, .weekly-group, .metric-card, .team-stats-strip { break-inside: avoid; box-shadow: none; }
  .track-heading { position: static; box-shadow: none; }
}
