/* === Design Tokens === */
:root, [data-theme="light"] {
  --color-bg: #f7f6f2;
  --color-surface: #ffffff;
  --color-surface-2: #fbfbf9;
  --color-border: #e2e0db;
  --color-divider: #edeae5;
  --color-text: #28251d;
  --color-text-muted: #7a7974;
  --color-text-faint: #bab9b4;
  --color-primary: #01696f;
  --color-primary-hover: #0c4e54;
  --color-primary-light: #e8f4f5;
  --color-success: #437a22;
  --color-success-light: #ecf5e6;
  --color-warning: #964219;
  --color-warning-light: #fdf0e6;
  --color-error: #a13544;
  --color-error-light: #fce8eb;
  --color-gold: #d19900;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,.06);
  --radius: 10px;
  --font-body: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --color-bg: #141413;
  --color-surface: #1c1b19;
  --color-surface-2: #222120;
  --color-border: #333231;
  --color-divider: #2a2928;
  --color-text: #cdccca;
  --color-text-muted: #8a8985;
  --color-text-faint: #5a5957;
  --color-primary: #4f98a3;
  --color-primary-hover: #6bb3be;
  --color-primary-light: #1d2e30;
  --color-success: #6daa45;
  --color-success-light: #1e2c16;
  --color-warning: #bb653b;
  --color-warning-light: #2e1f14;
  --color-error: #dd6974;
  --color-error-light: #2e1418;
  --color-gold: #e8af34;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
  --shadow-md: 0 2px 8px rgba(0,0,0,.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #141413;
    --color-surface: #1c1b19;
    --color-surface-2: #222120;
    --color-border: #333231;
    --color-divider: #2a2928;
    --color-text: #cdccca;
    --color-text-muted: #8a8985;
    --color-text-faint: #5a5957;
    --color-primary: #4f98a3;
    --color-primary-hover: #6bb3be;
    --color-primary-light: #1d2e30;
    --color-success: #6daa45;
    --color-success-light: #1e2c16;
    --color-warning: #bb653b;
    --color-warning-light: #2e1f14;
    --color-error: #dd6974;
    --color-error-light: #2e1418;
    --color-gold: #e8af34;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,.3);
  }
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* === Layout === */
body {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100dvh;
}

/* === Tab Strip === */
.tab-strip {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.tab-strip .tab-btn {
  background: none;
  border: none;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.tab-strip .tab-btn:hover:not(.active) {
  color: var(--color-text);
  background: var(--color-divider);
}
.tab-strip .tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 700;
}
.tab-strip .tab-btn svg {
  flex-shrink: 0;
}
.tab-badge {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  font-weight: 700;
  margin-left: 4px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

/* === Tab Panels === */
.tab-panel {
  display: none;
  flex-direction: column;
  gap: 20px;
}
.tab-panel.active {
  display: flex;
}

.leads-note {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
}
[data-theme="dark"] .leads-note {
  color: var(--color-primary-hover);
}

/* === Leads Window Cards === */
.leads-window-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.leads-window-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  color: inherit;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.leads-window-card:hover {
  border-color: var(--color-primary);
}
.leads-window-card.active {
  border-color: var(--color-primary);
  border-width: 2px;
  padding: 15px 17px;
  background: var(--color-primary-light);
}
.leads-window-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.leads-window-card.active .leads-window-label {
  color: var(--color-primary);
}
.leads-window-sub {
  font-size: 11px;
  color: var(--color-text-faint);
  font-weight: 500;
  margin-bottom: 4px;
}
.leads-window-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-top: 4px;
}
.leads-window-stat-num {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.leads-window-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-top: -2px;
}
@media (max-width: 900px) {
  .leads-window-grid { grid-template-columns: repeat(2, 1fr); }
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo { color: var(--color-primary); }

.logo-mark {
  width: auto;
  height: 44px;
  display: block;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 2px;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--color-primary);
  line-height: 1;
}

.brand-name sup {
  font-size: 10px;
  font-weight: 500;
  vertical-align: super;
  margin-left: 1px;
  color: var(--color-primary);
}

.brand-loc {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.02em;
}

.header-divider {
  width: 1px;
  height: 38px;
  background: var(--color-border);
  flex-shrink: 0;
  margin: 0 4px;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.last-updated {
  font-size: 12px;
  color: var(--color-text-faint);
}

[data-theme-toggle] {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 6px;
  border-radius: 6px;
  transition: background 150ms ease;
}
[data-theme-toggle]:hover { background: var(--color-divider); }

.main {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* === KPI Cards === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.kpi-delta.positive { color: var(--color-success); }
.kpi-delta.negative { color: var(--color-error); }
.kpi-delta.neutral { color: var(--color-text-faint); }
.kpi-goal { color: var(--color-text-muted); font-size: 13px; font-weight: 500; margin-top: 4px; }

/* Pipeline stats */
.pipe-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-top: 8px;
}
.pipe-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px;
}
.pipe-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.pipe-closed { color: var(--color-success); }
.pipe-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.pipe-divider {
  width: 1px;
  height: 28px;
  background: var(--color-border);
}

/* Pace card */
.pace-card { text-align: center; }
.pace-card .kpi-label { text-align: center; }
.pace-day {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.pace-diff {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.pace-word {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.pace-detail {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.pace-ahead .pace-diff,
.pace-ahead .pace-word { color: var(--color-success); }
.pace-behind .pace-diff,
.pace-behind .pace-word { color: var(--color-error); }
.pace-ahead { border-color: var(--color-success); border-width: 2px; }
.pace-behind { border-color: var(--color-error); border-width: 2px; }

/* === Cards === */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  padding: 16px 20px 4px;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  padding: 0 20px 12px;
}

/* === Charts === */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.chart-card { padding-bottom: 12px; }

.chart-container {
  padding: 8px 16px;
  position: relative;
  height: 260px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* === Tables === */
.table-card { overflow: visible; }

.table-scroll {
  overflow-x: auto;
  overscroll-behavior: contain;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums lining-nums;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  background: var(--color-surface-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--color-primary-light); }

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: inherit;
}

thead .sticky-col { background: var(--color-surface-2); z-index: 3; }
tbody tr:hover .sticky-col { background: var(--color-primary-light); }

/* KPI color coding in tables */
.kpi-good { color: var(--color-success); font-weight: 600; }
.kpi-warn { color: var(--color-warning); font-weight: 600; }
.kpi-bad { color: var(--color-error); font-weight: 600; }

.row-inactive { opacity: 0.45; }
.row-total {
  font-weight: 700;
  background: var(--color-surface-2);
}
.row-total td { border-top: 2px solid var(--color-border); }

/* Pipeline age badges */
.age-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.age-fresh { background: var(--color-success-light); color: var(--color-success); }
.age-aging { background: var(--color-warning-light); color: var(--color-warning); }
.age-stale { background: var(--color-error-light); color: var(--color-error); }
/* HOT = quote created within the last 7 days — top follow-up priority */
.hot-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--color-error-light);
  color: var(--color-error);
}
.hot-row td { font-weight: 600; }

/* === Daily Recap Card === */
.recap-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px 24px;
  border-left: 4px solid var(--color-primary);
}
.recap-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.recap-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
}
.recap-date {
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.recap-kpis {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.recap-kpi {
  display: flex;
  flex-direction: column;
}
.recap-kpi-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.recap-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.recap-divider {
  height: 1px;
  background: var(--color-divider);
  margin: 14px 0;
}
.recap-reps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.recap-rep {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.recap-rep-name {
  font-weight: 700;
  color: var(--color-text);
  min-width: 90px;
}
.recap-rep-detail {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.recap-highlight {
  display: inline-block;
  background: var(--color-success-light);
  color: var(--color-success);
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: 4px;
}
.recap-big-sale {
  display: inline-block;
  background: var(--color-gold);
  color: #fff;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: 4px;
}
[data-theme="dark"] .recap-big-sale {
  background: #b8860b;
}
.recap-volume-star {
  display: inline-block;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: 4px;
}
.recap-summary {
  font-size: 13px;
  font-style: italic;
  color: var(--color-text-muted);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-divider);
}
.recap-pipeline {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 8px;
}

/* === Services Section === */
.services-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
}
.kpi-grid-3 {
  grid-template-columns: repeat(3, 1fr);
  min-width: 340px;
}
.chart-container-sm { height: 180px; }

@media (max-width: 900px) {
  .services-row { grid-template-columns: 1fr; }
  .kpi-grid-3 { min-width: auto; }
}

/* === Section Dividers === */
.section-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 -4px;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}
.section-divider span {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  white-space: nowrap;
}

/* === Rep Drill-Down Panel === */
.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  backdrop-filter: blur(2px);
}
.panel-overlay.open { display: block; }

.rep-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(600px, 100vw);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 32px rgba(0,0,0,0.12);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.4,0,0.2,1);
  overscroll-behavior: contain;
}
.rep-panel.open { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.panel-rep-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.panel-rep-link {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.panel-rep-link a {
  color: var(--color-primary);
  text-decoration: none;
}
.panel-rep-link a:hover { text-decoration: underline; }

.panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 8px;
  border-radius: 6px;
  transition: background 150ms;
}
.panel-close:hover { background: var(--color-divider); }

.panel-body {
  overflow-y: auto;
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.panel-kpi-row-3 { grid-template-columns: repeat(3, 1fr); }
.panel-kpi-row-4 { grid-template-columns: repeat(4, 1fr); }
.panel-kpi-row .kpi-card { padding: 12px 14px; }
.panel-kpi-row .kpi-value { font-size: 18px; }

/* Monthly top section — revenue + daily/weekly goals */
.panel-month-top {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 10px;
  margin-bottom: 10px;
}
.month-rev-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.month-rev-card .kpi-label { margin-bottom: 4px; }
.month-rev-card .kpi-value { font-size: 22px; }
.month-rev-progress {
  height: 8px;
  background: var(--color-divider);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.month-rev-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 600ms ease;
}
.month-rev-fill.good { background: var(--color-success); }
.month-rev-fill.warn { background: var(--color-warning); }
.month-rev-fill.bad  { background: var(--color-error); }
.month-rev-sub {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Stretch goal (goal +20%) — tick marks the regular goal, amber = stretch territory */
.goal-tick {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 14px;
  background: var(--color-text-muted);
  border-radius: 1px;
  transform: translateX(-1px);
}
.stretch-line {
  font-size: 11px;
  color: var(--color-warning);
  font-weight: 600;
  margin-top: 3px;
}

.month-target-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.month-target-card .kpi-label { text-align: center; margin-bottom: 4px; }
.month-target-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.month-target-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Yearly section — muted */
.panel-yearly {
  opacity: 0.85;
  padding-top: 16px;
  border-top: 1px solid var(--color-divider);
}
.panel-yearly .panel-section-title { color: var(--color-text-faint); }
.panel-yearly .kpi-card {
  padding: 10px 12px;
  background: var(--color-surface-2);
}
.panel-yearly .kpi-value { font-size: 15px; }
.panel-yearly .kpi-label { font-size: 10px; }
.panel-yearly .kpi-goal { font-size: 11px; }

.panel-year-bar {
  margin-bottom: 10px;
}

.panel-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

/* Goal pacing bars */
.panel-goals {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.goal-row { display: flex; flex-direction: column; gap: 4px; }
.goal-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
}
.goal-row-label { font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.goal-row-values { color: var(--color-text); font-variant-numeric: tabular-nums; }
.goal-bar-track {
  height: 7px;
  background: var(--color-divider);
  border-radius: 99px;
  overflow: hidden;
}
.goal-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 600ms cubic-bezier(0.4,0,0.2,1);
}
.goal-bar-fill.good { background: var(--color-success); }
.goal-bar-fill.warn { background: var(--color-warning); }
.goal-bar-fill.bad  { background: var(--color-error); }
.goal-pct { font-size: 12px; font-weight: 700; }
.goal-pct.good { color: var(--color-success); }
.goal-pct.warn { color: var(--color-warning); }
.goal-pct.bad  { color: var(--color-error); }

/* Panel chart */
.panel-chart-wrap { height: 200px; position: relative; }

/* Rep name clickable */
.rep-link {
  cursor: pointer;
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.rep-link:hover { color: var(--color-primary-hover); }

/* === Footer === */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: var(--color-text-faint);
}

/* === Responsive === */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .header { padding: 10px 16px; }
  .main { padding: 14px 12px 30px; gap: 14px; }
  .kpi-value { font-size: 20px; }
  .kpi-card { padding: 12px 14px; }
  .card-title { padding: 12px 14px 4px; font-size: 13px; }
  .card-subtitle { padding: 0 14px 8px; }
  th, td { padding: 8px 10px; font-size: 12px; }
  .pace-diff { font-size: 18px; }
  .recap-kpis { gap: 16px; }
  .recap-kpi-value { font-size: 16px; }
  .panel-month-top { grid-template-columns: 1fr; }
  .rep-panel { width: 100vw; }
  .header-title { font-size: 14px; }
}

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .header-right { gap: 8px; }
  .last-updated { display: none; }
}

/* === Print Styles === */
@media print {
  body { overflow: visible !important; height: auto !important; }
  .main { overflow: visible !important; height: auto !important; padding: 10px; }
  .header { position: relative; }
  [data-theme-toggle], #printBtn { display: none !important; }
  .card, .kpi-card, .recap-card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
  .rep-panel, .panel-overlay { display: none !important; }
  .chart-container { height: 200px; }
}

/* ============================================================
   MOBILE POLISH v2 — phone-first (revised 2026-08-27)
   Keep the familiar TABLE layout (columns together, like the
   desktop view). The phone "scroll freeze" came from the locked
   app-shell (body overflow:hidden + single .main scroller +
   overscroll-behavior:contain) trapping vertical swipes on a
   sideways-scrolling table. Fix = natural document scroll +
   drop the overscroll traps, so the page scrolls vertically and
   tables scroll sideways without grabbing the gesture.
   ============================================================ */
@media (max-width: 768px) {
  html, body { height: auto; min-height: 100%; overflow: visible; }
  body { display: block; height: auto; }
  .main {
    overflow: visible; height: auto; overscroll-behavior: auto;
    padding: 12px 12px 72px; gap: 14px;
  }
  .header { padding: 10px 14px; position: sticky; top: 0; z-index: 20; }
  .header-subtitle { display: none; }

  .tab-strip {
    padding: 0 6px; position: sticky; top: 56px; z-index: 15;
    overscroll-behavior-x: auto; -webkit-overflow-scrolling: touch;
  }
  .tab-btn { padding: 13px 13px; font-size: 14px; }

  /* Tables stay tables — let vertical swipes chain to the page,
     give sideways scroll momentum, keep the name column frozen. */
  .table-scroll {
    overflow-x: auto; overscroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { font-size: 12.5px; }
  th, td { padding: 9px 10px; }
  .sticky-col { box-shadow: 1px 0 0 var(--color-border); }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .leads-window-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .services-row { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .rep-panel { width: 100%; max-width: 100%; }
}
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  table { font-size: 12px; }
  th, td { padding: 8px 8px; }
}

/* Header status badge — dot + tap popup (added 2026-08-27) */
.upd-pill { display: inline-flex; align-items: center; }
.upd-dot { display: none; align-items: center; justify-content: center; border-radius: 50%; color: #fff; }
.upd-fresh { width: 22px; height: 22px; background: #1f7a3d; }
.upd-stale { width: 28px; height: 28px; background: #c0392b; animation: updpulse 1.6s ease-in-out infinite; }
@keyframes updpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(192,57,43,.55); } 70% { box-shadow: 0 0 0 8px rgba(192,57,43,0); } }
@media (max-width: 768px) {
  .upd-pill { display: none; }
  .upd-dot { display: inline-flex; }
}
