:root {
  --bg: #F6F7F4;
  --surface: #FFFFFF;
  --ink: #16211C;
  --ink-soft: #5B6660;
  --border: #E1E4DE;
  --primary: #0E7C6B;
  --primary-soft: #E5F1EE;
  --secondary: #E0A526;
  --secondary-text: #8A5F09; /* same amber family, darkened for WCAG AA text contrast (5.64:1 vs 2.19:1) -- --secondary itself is only safe as a fill/background, not as text on a light surface */
  --negative: #B54334;
  --negative-soft: #F7EAE7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22,33,28,0.06), 0 1px 8px rgba(22,33,28,0.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; margin: 0; }
.mono { font-family: 'IBM Plex Mono', monospace; }

.shell { max-width: 1180px; margin: 0 auto; padding: 32px 24px 80px; }

/* ── Header ─────────────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
header .title-block h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
header .title-block p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13.5px; }
.logout-link { color: var(--ink-soft); font-size: 12.5px; text-decoration: none; }
.logout-link:hover { color: var(--negative); text-decoration: underline; }

.custom-range { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 8px; padding: 6px 10px; }
.custom-range input[type="date"] {
  border: none; background: transparent; font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px; color: var(--ink);
}
.custom-range .sep { color: var(--ink-soft); font-size: 12px; }

.cutoff-date-group { position: relative; transition: background 0.12s, box-shadow 0.12s; }
.cutoff-date-group.active { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.last-updated-group { position: relative; transition: background 0.12s, box-shadow 0.12s; }
.last-updated-group.active { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.last-updated-group input[type="number"] { width: 70px; }
.cutoff-clear-btn {
  border: none; background: transparent; cursor: pointer; color: var(--ink-soft);
  font-size: 11px; line-height: 1; padding: 2px 4px; border-radius: 50%;
}
.cutoff-clear-btn:hover { color: var(--negative); background: rgba(181,67,52,0.1); }

.pill-group { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.pill {
  border: none; background: transparent; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 500;
  color: var(--ink-soft); padding: 6px 12px; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.pill.active { background: var(--primary); color: #fff; }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: 11.5px; color: var(--ink-soft); font-weight: 500; }
.filter-field select {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 7px 10px; font-family: 'Inter', sans-serif; font-size: 13px; color: var(--ink);
  min-width: 160px; cursor: pointer;
}
.clear-filters {
  border: none; background: transparent; color: var(--primary); cursor: pointer;
  font-size: 12.5px; font-weight: 500; padding: 7px 4px; text-decoration: underline;
}

/* ── Stage flow ─────────────────────────────────────────────── */
.stage-flow {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 32px;
}
.stage-flow h2 { font-size: 15px; font-weight: 600; }
.stage-flow .sub { color: var(--ink-soft); font-size: 12.5px; margin: 3px 0 16px; }
.flow-total {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px;
}
.flow-total-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft);
}
.flow-total-value {
  font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 600; color: var(--ink);
}
.flow-bar { display: flex; height: 40px; border-radius: 8px; overflow: hidden; }
.flow-seg { display: flex; align-items: center; justify-content: center; min-width: 2px;
            position: relative; transition: filter 0.15s; cursor: default; }
.flow-seg:hover { filter: brightness(0.94); }
.flow-seg .count { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #fff; font-weight: 500; }
.flow-legend { display: flex; gap: 22px; margin-top: 14px; flex-wrap: wrap; }
.flow-legend .item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-soft); }
.flow-legend .swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.flow-legend .val { font-family: 'IBM Plex Mono', monospace; color: var(--ink); }

/* ── Section headers ────────────────────────────────────────── */
section.group { margin-bottom: 36px; }
section.group > h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
section.group > p.desc { color: var(--ink-soft); font-size: 12.5px; margin: 0 0 16px; }

/* ── Gross milestone chart grid ────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
/* Gross Funnel specifically: always exactly 2 rows, however many milestone
   cards exist -- grid-auto-flow:column fills top-to-bottom then wraps to
   the next column, so CSS computes however many columns are needed on its
   own rather than a hardcoded count that would break if a milestone is
   ever added or removed. Scoped to #gross-grid only, since .chart-grid is
   shared with Net Pending, which was not asked to be 2-row-constrained. */
#gross-grid {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, 1fr);
  grid-auto-columns: minmax(200px, 1fr);
  overflow-x: auto;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chart-card:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(14,124,107,0.12); }
.chart-card .card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.chart-card h3 { font-size: 13px; font-weight: 600; }
.chart-card .total { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--primary); }
.chart-card .total.negative { color: var(--negative); }
.chart-card .value-sub { font-size: 11px; color: var(--ink-soft); margin-bottom: 8px; }
.chart-card svg { display: block; width: 100%; height: 106px; overflow: visible; }
.bar { fill: var(--primary); }
.bar.lost, .bar.in_active { fill: var(--negative); }
.bar.won { fill: var(--secondary); }
.axis-label { font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; fill: var(--ink-soft); }
.callout-count { font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; fill: var(--ink); font-weight: 600; }

/* ── Net pending cards ──────────────────────────────────────── */
.net-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.net-card .label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; }
.net-card .count { font-family: 'IBM Plex Mono', monospace; font-size: 30px; font-weight: 500; line-height: 1; }
.net-card .value { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* ── Age bucket table ───────────────────────────────────────── */
.age-table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; overflow-x: auto;
}
table.age-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 640px; }
table.age-table th, table.age-table td { padding: 10px 14px; text-align: right; }
table.age-table th:first-child, table.age-table td:first-child { text-align: left; }
table.age-table thead th {
  color: var(--ink-soft); font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.03em; border-bottom: 1px solid var(--border);
}
table.age-table tbody tr:not(:last-child) td { border-bottom: 1px solid var(--bg); }
table.age-table td.stage-name { font-weight: 500; }

.total-row td {
  border-top: 2px solid var(--ink) !important; font-weight: 600; color: var(--ink);
  font-family: 'IBM Plex Mono', monospace; padding-top: 12px !important;
}
.total-row td:first-child { font-family: 'Space Grotesk', sans-serif; }

.row-total-cell {
  font-weight: 600; color: var(--ink); font-family: 'IBM Plex Mono', monospace;
  border-left: 2px solid var(--border);
}

/* ── Loading spinner ────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.7s linear infinite; margin: 0 auto 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty / error / loading states ────────────────────────── */
.state-msg {
  grid-column: 1 / -1;
  text-align: center; padding: 28px 16px; color: var(--ink-soft); font-size: 13px;
}
.state-msg.error { color: var(--negative); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .spinner { animation: none; border-top-color: var(--border); }
}

/* ── Manual sync widget ─────────────────────────────────────────────── */
.global-filters-bar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--primary-soft); border: 1px solid var(--primary); border-radius: var(--radius);
  padding: 10px 16px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.jump-to-section {
  margin-left: auto; border: 1px solid var(--primary); border-radius: 6px; background: var(--surface);
  font-family: 'Inter', sans-serif; font-size: 12.5px; color: var(--primary); font-weight: 600;
  padding: 6px 10px; cursor: pointer;
}
/* Leaves room for the sticky Global Filters bar so a section's own
   heading doesn't end up hidden underneath it after scrollIntoView --
   approximate sticky bar height plus a little breathing room. */
section.group, .stage-flow { scroll-margin-top: 76px; }
.global-filters-title {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 13px;
  color: var(--primary); display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
/* The shared mountFilterBar() component always renders its own "Filters"
   label first -- redundant here since the title above already says
   "Global Filters". Hidden with CSS rather than adding a flag to the
   shared component, so every other section's filter bar is unaffected. */
#global-filters .controls-label { display: none; }

.sync-widget {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px;
}
.sync-btn {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s; white-space: nowrap;
}
.sync-btn:hover:not(:disabled) { background: #0B6155; }
.sync-btn:disabled { background: var(--border); color: var(--ink-soft); cursor: not-allowed; }
.sync-status { font-size: 12.5px; color: var(--ink-soft); flex: 1; min-width: 200px; }
.sync-meta.error { color: var(--negative); }
.sync-meta.warn { color: var(--secondary-text); }
.sync-live { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-bar { width: 160px; height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.sync-bar-fill { height: 100%; background: var(--primary); transition: width 0.3s; }
.sync-pct { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; color: var(--ink); }
.sync-phase { font-size: 12px; color: var(--ink-soft); }

/* ── Spinner / loading state ──────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.state-msg.loading { display: flex; align-items: center; justify-content: center; gap: 10px; }

/* ── Chart tooltip ─────────────────────────────────────────────────── */
.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.1s;
  white-space: nowrap;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip.wrap {
  white-space: normal; max-width: 280px; font-family: 'Inter', sans-serif; line-height: 1.4;
}
.bar { cursor: pointer; }

.info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: 50%;
  color: var(--ink-soft); cursor: help; vertical-align: -3px;
  margin-left: 4px; transition: color 0.12s, background 0.12s;
}
.info-icon:hover, .info-icon:focus-visible {
  color: var(--primary); background: var(--primary-soft);
}
.info-icon svg { display: block; }

/* ── Preset range + custom range ──────────────────────────────────── */
.preset-group { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.preset-btn {
  border: none; background: transparent; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 500;
  color: var(--ink-soft); padding: 6px 11px; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.preset-btn.active { background: var(--ink); color: #fff; }
.custom-range { display: flex; align-items: center; gap: 6px; }
.custom-range.hidden { display: none; }

/* ── Filter bar ────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-dropdown { position: relative; }
.filter-trigger {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; font-size: 12.5px; font-family: 'Inter', sans-serif;
  cursor: pointer; color: var(--ink); display: flex; align-items: center; gap: 6px;
}
.filter-trigger:focus { outline: none; }
.filter-trigger .badge {
  background: var(--primary); color: #fff; font-size: 10.5px; border-radius: 999px;
  padding: 1px 6px; font-family: 'IBM Plex Mono', monospace; display: none;
}
.filter-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 10px; min-width: 210px; max-height: 260px; overflow-y: auto;
  display: none;
}
.filter-panel.open { display: block; }
.filter-panel label {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 5px 4px;
  cursor: pointer; border-radius: 5px;
}
.filter-panel label:hover { background: var(--bg); }
.filter-clear { font-size: 11.5px; color: var(--ink-soft); cursor: pointer; text-decoration: underline; margin-top: 6px; }

/* ── Age bucket table ──────────────────────────────────────────────── */
.age-table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
table.age-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.age-table th, table.age-table td {
  padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.age-table th:first-child, table.age-table td:first-child {
  text-align: left; font-weight: 500; position: sticky; left: 0; background: var(--surface);
}
table.age-table thead th {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; color: var(--ink-soft);
  font-size: 11.5px; background: var(--bg);
}
table.age-table td .count { font-family: 'IBM Plex Mono', monospace; font-weight: 500; display: block; }
table.age-table td .value { display: block; font-size: 10.5px; color: var(--ink-soft); }
table.age-table td.stale .count { color: var(--negative); }

/* ── Drill-down modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22,33,28,0.45); display: none;
  align-items: center; justify-content: center; z-index: 200; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: 560px; width: 100%; max-height: 80vh; display: flex; flex-direction: column;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 14.5px; }
.modal-close { border: none; background: transparent; cursor: pointer; font-size: 20px; color: var(--ink-soft); line-height: 1; }
.modal-body { padding: 4px 0; overflow-y: auto; }

/* ── Loss reason distribution ──────────────────────────────────────── */
.reason-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.reason-group {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.reason-group h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.reason-group h3.lost { color: var(--negative); }
.reason-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12.5px;
}
.reason-row:last-child { border-bottom: none; }
.reason-row .reason-count { font-family: 'IBM Plex Mono', monospace; font-weight: 500; }
.reason-row .reason-value { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-soft); margin-left: 8px; }
.reason-unmapped { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 11.5px; color: var(--secondary-text); }

/* ── Section-local controls (replaces the old global header controls) ── */
.section-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.controls-label {
  font-family: 'Space Grotesk', sans-serif; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft);
  margin-right: -2px;
}
.section-controls .preset-group.local,
.section-controls .pill-group.local { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.section-controls .custom-range { display: flex; align-items: center; gap: 6px; }
.section-controls .custom-range.hidden { display: none; }
.section-controls .custom-range input[type="date"] {
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
  font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; color: var(--ink); padding: 5px 7px;
}

/* Section-local filter bars sit on their own row beneath the period controls */
.section-filters {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Loss Reason Distribution's optional period toggle */
.period-toggle {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-soft);
  cursor: pointer; user-select: none;
}
.period-toggle input { cursor: pointer; }

/* ── Deal Explorer drawer (replaces the old modal) ─────────────────── */
.explorer-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 300;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(22,33,28,0.12);
  max-height: 0; overflow: hidden;
  transition: max-height 0.25s ease;
  display: flex; flex-direction: column;
}
.explorer-drawer.open { max-height: 60vh; }
.explorer-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.explorer-head h3 { font-size: 14.5px; flex: 1; }
.explorer-search {
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px;
  font-family: 'Inter', sans-serif; font-size: 12.5px; width: 220px; background: var(--bg);
}
.explorer-count { font-size: 11.5px; color: var(--ink-soft); font-family: 'IBM Plex Mono', monospace; white-space: nowrap; }
.explorer-close { border: none; background: transparent; cursor: pointer; font-size: 20px; color: var(--ink-soft); line-height: 1; }
.explorer-table-wrap { overflow-y: auto; padding: 0 20px 16px; }
table.explorer-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.explorer-table th {
  position: sticky; top: 0; background: var(--surface); text-align: left;
  padding: 8px 12px; font-family: 'Space Grotesk', sans-serif; font-weight: 600;
  font-size: 11px; color: var(--ink-soft); cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.explorer-table th:hover { color: var(--ink); }
table.explorer-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.explorer-table tbody tr:hover { background: var(--bg); }

/* ── Clickable drill-down affordances across sections ──────────────── */
.clickable, td.clickable, tr.clickable, .reason-row.clickable {
  cursor: pointer; transition: background 0.12s;
}
td.clickable:hover, tr.clickable:hover td, .reason-row.clickable:hover { background: var(--primary-soft); }

/* ── Weekly review week-nav ─────────────────────────────────────────── */
.week-nav {
  border: 1px solid var(--border); background: var(--bg); border-radius: 6px;
  width: 26px; height: 26px; cursor: pointer; font-size: 12px; color: var(--ink);
}
.week-nav:hover { background: var(--primary-soft); }
.week-range-label { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; color: var(--ink); }
.week-start-day-select {
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
  font-family: 'Inter', sans-serif; font-size: 12.5px; color: var(--ink);
  padding: 6px 8px;
}

/* ── All Deals directory: search/stage controls + pagination ────────── */
.section-controls input[type="text"].all-deals-search {
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
  font-family: 'Inter', sans-serif; font-size: 12.5px; color: var(--ink);
  padding: 6px 10px; min-width: 220px;
}
.all-deals-table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.all-deals-table-wrap th.sortable { cursor: pointer; user-select: none; }
.all-deals-table-wrap th.sortable:hover { color: var(--primary); }
.all-deals-pagination {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-top: 12px; font-size: 12.5px; color: var(--ink-soft);
}
.page-nav {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 14px; font-family: 'Inter', sans-serif; font-size: 12.5px;
  cursor: pointer; color: var(--ink);
}
.page-nav:disabled { color: var(--border); cursor: not-allowed; }
.page-nav:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-label { font-family: 'IBM Plex Mono', monospace; }

/* ── Keyboard focus indicators ──────────────────────────────────────── */
/* Zero focus styles existed before this -- every interactive element a
   keyboard user can reach needs a visible indicator when tabbed to, not
   just when clicked. Using :focus-visible so mouse clicks don't show a
   ring, only actual keyboard navigation does. */
table.explorer-table th:focus-visible,
.all-deals-table-wrap th.sortable:focus-visible,
button:focus-visible,
.filter-trigger:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Login page ──────────────────────────────────────────────────────── */
/* login.html referenced these classes without any matching CSS existing
   anywhere -- it was rendering as unstyled browser-default HTML. This is
   the actual fix, not a rewrite of the page itself. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
body.login-body {
  margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px; font-family: 'Inter', sans-serif; color: var(--ink);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 36px 32px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column;
}
.login-card h1 {
  font-family: 'Space Grotesk', sans-serif; font-size: 19px; font-weight: 700;
  margin: 0 0 4px; letter-spacing: -0.01em; color: var(--ink);
}
.login-card .subtitle { margin: 0 0 20px; font-size: 13px; color: var(--ink-soft); }
.login-card input[type="password"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 14px; color: var(--ink); background: var(--bg);
  margin-bottom: 14px;
}
.login-card input[type="password"]:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; border-color: var(--primary);
}
.login-card .error {
  background: var(--negative-soft); color: var(--negative); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin: 0 0 14px;
}
.login-card button[type="submit"] {
  border: none; border-radius: 8px; background: var(--primary); color: #fff;
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600; padding: 11px;
  cursor: pointer; transition: background 0.15s;
}
.login-card button[type="submit"]:hover { background: #0B6155; }
.login-card button[type="submit"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .login-card button[type="submit"] { transition: none; }
}

/* ── Deal Detail overlay ─────────────────────────────────────────────── */
/* Higher z-index than the Explorer drawer (300) since this can be opened
   from a row click INSIDE the Explorer drawer itself, and needs to layer
   on top of it, not behind it. */
table.explorer-table tbody tr { cursor: pointer; }

.deal-detail-overlay {
  position: fixed; inset: 0; background: rgba(22,33,28,0.45); display: none;
  align-items: center; justify-content: center; z-index: 400; padding: 24px;
}
.deal-detail-overlay.open { display: flex; }
.deal-detail-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(22,33,28,0.25);
  max-width: 640px; width: 100%; max-height: 85vh; display: flex; flex-direction: column;
}
.deal-detail-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.deal-detail-head h3 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.deal-detail-head .subtitle { font-size: 12.5px; color: var(--ink-soft); margin: 0; }
.deal-detail-close { border: none; background: transparent; cursor: pointer; font-size: 22px; color: var(--ink-soft); line-height: 1; }
.deal-detail-close:hover { color: var(--negative); }
.deal-detail-body { padding: 20px 24px; overflow-y: auto; }

.deal-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 18px;
  margin-bottom: 24px;
}
.deal-detail-grid .item .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-soft); margin-bottom: 3px;
}
.deal-detail-grid .item .value { font-size: 13px; color: var(--ink); font-family: 'IBM Plex Mono', monospace; }

.deal-detail-section-title {
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.03em; margin: 0 0 10px;
}
table.timeline-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.timeline-table th {
  text-align: left; padding: 6px 10px; font-size: 11px; color: var(--ink-soft);
  border-bottom: 1px solid var(--border);
}
table.timeline-table td { padding: 7px 10px; border-bottom: 1px solid var(--bg); }
table.timeline-table tr.current td { font-weight: 600; }
.current-badge {
  background: var(--primary-soft); color: var(--primary); font-size: 10px;
  padding: 2px 7px; border-radius: 999px;
}

/* ── More filters (secondary dimensions, grouped) ─────────────────────── */
.filter-panel-wide { min-width: 280px; max-width: 320px; max-height: 400px; }
.more-filter-group { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.more-filter-group:last-of-type { border-bottom: none; margin-bottom: 4px; padding-bottom: 4px; }
.more-filter-label {
  font-family: 'Space Grotesk', sans-serif; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); margin-bottom: 4px;
}
.more-filter-empty { font-size: 12px; color: var(--ink-soft); padding: 8px 4px; }

/* ── Funnel Effectiveness cards ────────────────────────────────────── */
.effectiveness-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.effectiveness-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.effectiveness-card.clickable { cursor: pointer; transition: border-color 0.12s; }
.effectiveness-card.clickable:hover, .effectiveness-card.clickable:focus-visible {
  border-color: var(--primary); outline: none;
}
.effectiveness-label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; display: flex; align-items: center; }
.effectiveness-pct { font-family: 'IBM Plex Mono', monospace; font-size: 30px; font-weight: 500; line-height: 1; color: var(--primary); }
.effectiveness-detail { font-size: 11.5px; color: var(--ink-soft); margin-top: 6px; font-family: 'IBM Plex Mono', monospace; }

.effectiveness-raw-counts { display: flex; gap: 12px; }
.raw-count-item { flex: 1; text-align: center; border-radius: 8px; padding: 10px 8px; transition: background 0.12s; }
.raw-count-item.clickable { cursor: pointer; }
.raw-count-item.clickable:hover, .raw-count-item.clickable:focus-visible { background: var(--bg); outline: none; }
.raw-count-value { font-family: 'IBM Plex Mono', monospace; font-size: 26px; font-weight: 500; color: var(--primary); line-height: 1; }
.raw-count-label { font-size: 11px; color: var(--ink-soft); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.03em; }

/* ── Back to top ─────────────────────────────────────────────────────── */
.back-to-top-row { display: flex; justify-content: center; margin-top: 8px; margin-bottom: 24px; }
.back-to-top-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 20px; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500;
  color: var(--ink-soft); cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.back-to-top-btn:hover, .back-to-top-btn:focus-visible {
  border-color: var(--primary); color: var(--primary); outline: none;
}

/* ── All Deals: selection checkboxes + export ────────────────────────── */
.select-col { width: 32px; text-align: center; }
.select-col input[type="checkbox"] { cursor: pointer; }

.all-deals-export-group { display: flex; gap: 8px; align-items: center; }
.all-deals-export-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 14px; font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 500;
  color: var(--ink); cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.all-deals-export-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.all-deals-export-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.all-deals-stage-filter { display: flex; align-items: center; gap: 8px; }

/* ── Individual Analytics (Team Performance) page ─────────────────────── */
.back-to-dashboard-link {
  font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 500;
  color: var(--primary); text-decoration: none; white-space: nowrap;
}
.back-to-dashboard-link:hover { text-decoration: underline; }
.ia-table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.ia-table-wrap table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ia-table-wrap th, .ia-table-wrap td {
  padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ia-table-wrap th:first-child, .ia-table-wrap td:first-child { text-align: left; font-weight: 500; }
.ia-table-wrap thead th { color: var(--ink-soft); font-weight: 500; background: var(--bg); }
.ia-table-wrap .stage-group-header { background: var(--primary-soft); color: var(--primary); font-weight: 600; text-align: center; }
.ia-leaderboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.ia-leaderboard-grid h3 { font-size: 13px; margin: 0 0 8px; color: var(--ink-soft); font-weight: 600; }
.ia-leaderboard-split { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start; }
.ia-pie-layout { display: flex; align-items: center; gap: 16px; }
.ia-pie-legend { display: flex; flex-direction: column; gap: 5px; }
.ia-pie-legend-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.ia-pie-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.ia-pie-legend-label { white-space: nowrap; }
.ia-lb-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12px; }
.ia-lb-name { width: 90px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ia-lb-bar-track { flex: 1; background: var(--bg); border-radius: 4px; height: 18px; overflow: hidden; }
.ia-lb-bar-fill { background: var(--primary); height: 100%; border-radius: 4px; }
.ia-lb-value { width: 60px; text-align: right; font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; flex-shrink: 0; }