/* App-specific styles built on top of design system tokens */

#root {
  min-height: 100vh;
  background: var(--paper);
  color: var(--rich-black);
}

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--soft-rule);
  border-radius: 0;
  padding: 24px;
}
.card-tight { padding: 18px 20px; }
.card-pad-lg { padding: 32px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}
.card-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  line-height: 0.95;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  color: var(--rich-black);
  margin: 0;
}
.card-sub {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-stone);
  margin-top: 6px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
}
.card-eyebrow {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-red);
  margin: 0 0 10px;
}

/* ── Sticky header ──────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--white);
  border-bottom: 1px solid var(--soft-rule);
}
.app-header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 32px;
  max-width: 1440px;
  margin: 0 auto;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  font-size: 18px;
  color: var(--rich-black);
  font-weight: 400;
}
.wordmark-mark {
  width: 22px; height: 22px;
  background: var(--rich-black);
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
}
.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  color: var(--rich-black);
}
.header-divider {
  width: 1px; height: 18px; background: var(--soft-rule);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* badge */
.badge-internal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--brand-red);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 0;
}

/* avatar */
.avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--rich-black);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

/* ── Tabs ──────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  padding: 0 32px;
  border-bottom: 1px solid var(--soft-rule);
  background: var(--white);
  overflow-x: auto;
  max-width: 1440px;
  margin: 0 auto;
}
.tab {
  position: relative;
  padding: 14px 18px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-stone);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-quiet);
  white-space: nowrap;
}
.tab:hover { color: var(--rich-black); }
.tab.active { color: var(--rich-black); }
.tab.active::after {
  content: "";
  position: absolute;
  left: 18px; right: 18px;
  bottom: -1px;
  height: 2px;
  background: var(--brand-red);
}

/* ── Page chrome ───────────────────────────────────────── */
.page-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px;
}
.section-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: flex-end;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--soft-rule);
  margin-bottom: 24px;
}
.section-header h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 0.9;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  color: var(--rich-black);
  margin: 0;
}
.section-header .desc {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--rich-black);
  max-width: 280px;
  margin: 0;
}

/* ── KPI ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--soft-rule);
  border: 1px solid var(--soft-rule);
}
.kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-cell {
  background: var(--white);
  padding: 20px 22px 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 130px;
}
.kpi-label {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-stone);
}
.kpi-value {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--rich-black);
}
.kpi-delta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  font-feature-settings: "tnum" 1;
}
.kpi-delta.pos { color: var(--dark-green); }
.kpi-delta.neg { color: var(--brand-red); }
.kpi-spark {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 72px;
  height: 28px;
  opacity: 0.85;
}

/* ── Pill / Button ────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  min-height: 34px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  border: 1.3px solid var(--rich-black);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), opacity var(--dur-fast), border-color var(--dur-fast);
  background: var(--white);
  color: var(--rich-black);
  white-space: nowrap;
}
.pill .lbl { transform: translateY(0.1em); display: inline-block; }
.pill.filled { background: var(--rich-black); color: var(--white); }
.pill.red { background: var(--brand-red); color: var(--white); border-color: var(--brand-red); }
.pill.red:hover { background: var(--brand-red-hover); border-color: var(--brand-red-hover); }
.pill.outline { background: var(--white); color: var(--rich-black); }
.pill.outline:hover { background: var(--rich-black); color: var(--white); }
.pill.filled:hover { background: var(--white); color: var(--rich-black); }
.pill:active { opacity: 0.92; }
.pill.sm { min-height: 28px; padding: 0 12px; font-size: 9.5px; }
.pill.disabled, .pill:disabled { opacity: 0.4; pointer-events: none; }

/* simple text link */
.tlink {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--rich-black);
  border-bottom: 1px solid var(--soft-rule);
  padding-bottom: 1px;
  cursor: pointer;
  transition: border-color var(--dur-fast);
  background: none; border-left:0; border-right:0; border-top:0; padding-left:0; padding-right:0;
}
.tlink:hover { border-bottom-color: var(--brand-red); }
.tlink.red { color: var(--brand-red); border-bottom-color: var(--brand-red); }

/* ── Status pills (chip badges, not buttons) ──────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--soft-rule);
  background: var(--white);
  color: var(--rich-black);
  white-space: nowrap;
}
.chip-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--rich-black);
}
.chip.healthy .chip-dot { background: var(--dark-green); }
.chip.risk .chip-dot { background: #C18B2A; }
.chip.churn .chip-dot { background: var(--brand-red); }
.chip.healthy { color: var(--dark-green); border-color: rgba(49,90,73,0.25); }
.chip.risk { color: #8B5E18; border-color: rgba(193,139,42,0.3); }
.chip.churn { color: var(--brand-red); border-color: rgba(190,46,43,0.3); }
.chip.connected { color: var(--dark-green); border-color: rgba(49,90,73,0.25); }
.chip.disconnected { color: var(--ink-stone); }
.chip.solid { background: var(--rich-black); color: var(--white); border-color: var(--rich-black); }

/* ── Table ─────────────────────────────────────────────── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.tbl thead th {
  text-align: left;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-stone);
  padding: 10px 14px;
  border-bottom: 1px solid var(--soft-rule);
  background: var(--white);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--rich-black);
}
.tbl tbody tr { transition: background var(--dur-fast); cursor: default; }
.tbl tbody tr:hover { background: var(--paper); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl td .muted { color: var(--ink-stone); }
.tbl td .strong { font-weight: 500; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .num-head { text-align: right; }

/* ── Dropdown ──────────────────────────────────────────── */
.dropdown {
  position: relative;
}
.dd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--soft-rule);
  background: var(--white);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--rich-black);
  cursor: pointer;
  transition: border-color var(--dur-fast);
  border-radius: 0;
}
.dd-trigger:hover { border-color: var(--rich-black); }
.dd-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  max-height: min(60vh, 480px);
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--soft-rule);
  box-shadow: var(--panel-shadow);
  z-index: 50;
  padding: 6px 0;
}
.dd-menu-up {
  top: auto;
  bottom: calc(100% + 4px);
}
.dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: 0;
  font-family: var(--sans);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  color: var(--rich-black);
  transition: background var(--dur-fast);
}
.dd-item:hover { background: var(--paper); }
.dd-item.active { color: var(--brand-red); }
.dd-section {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-stone);
  padding: 10px 14px 4px;
  font-weight: 700;
}
.dd-rule { height: 1px; background: var(--soft-rule); margin: 4px 0; }

/* ── Inputs ────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-stone);
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--soft-rule);
  border-radius: 0;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--rich-black);
  outline: none;
  transition: border-color var(--dur-fast);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--rich-black);
}
.field .help {
  font-size: 11px;
  color: var(--ink-stone);
  margin-top: 2px;
}
.field .err {
  font-size: 12px;
  color: var(--brand-red);
}

/* ── Login ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border: 1px solid var(--soft-rule);
  padding: 40px 36px;
  position: relative;
}
.login-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.login-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: var(--rich-black);
  margin: 16px 0 4px;
}
.login-sub {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-stone);
  margin: 0 0 26px;
}
.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper);
  padding: 4px;
  margin-bottom: 22px;
}
.login-tab {
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-stone);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.login-tab.active {
  background: var(--rich-black);
  color: var(--white);
}
.login-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--soft-rule);
  font-size: 11px;
  color: var(--ink-stone);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Banner ────────────────────────────────────────────── */
.banner {
  background: var(--rich-black);
  color: var(--white);
  padding: 12px 32px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.banner .lbl { font-weight: 500; letter-spacing: 0.02em; }
.banner button {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.4);
  padding: 5px 12px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--dur-fast);
  border-radius: 999px;
}
.banner button:hover { background: rgba(255,255,255,0.1); }

/* ── Toast ─────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--rich-black);
  color: var(--white);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 500;
  min-width: 240px;
  max-width: 360px;
  border-left: 3px solid var(--brand-red);
  animation: toast-in 240ms var(--ease) forwards;
  pointer-events: auto;
}
.toast.success { border-left-color: var(--dark-green); }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ── Modal ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,25,25,0.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade-in 160ms ease forwards;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--white);
  width: 100%;
  max-width: 440px;
  padding: 40px;
  text-align: center;
  position: relative;
}
.modal .spin {
  width: 32px; height: 32px;
  margin: 0 auto 18px;
  border: 1.5px solid var(--soft-rule);
  border-top-color: var(--brand-red);
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.modal .check-circle {
  width: 40px; height: 40px;
  border-radius: 999px;
  background: var(--dark-green);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

/* ── Side panel (prospect detail) ─────────────────────── */
.side-panel-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,25,25,0.35);
  z-index: 150;
  animation: fade-in 160ms ease forwards;
}
.side-panel {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 100%;
  max-width: 540px;
  background: var(--white);
  z-index: 160;
  overflow-y: auto;
  animation: slide-in 280ms var(--ease) forwards;
  border-left: 1px solid var(--soft-rule);
}
@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.side-panel-head {
  position: sticky;
  top: 0;
  background: var(--white);
  padding: 20px 32px;
  border-bottom: 1px solid var(--soft-rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.side-panel-body {
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Misc text ─────────────────────────────────────────── */
.txt-muted { color: var(--ink-stone); }
.txt-strong { color: var(--rich-black); font-weight: 500; }
.txt-red { color: var(--brand-red); }
.txt-green { color: var(--dark-green); }
.txt-tnum { font-variant-numeric: tabular-nums; }

.divider { height: 1px; background: var(--soft-rule); margin: 24px 0; }

/* recharts overrides */
.recharts-cartesian-axis-tick-value,
.recharts-legend-item-text,
.recharts-tooltip-label,
.recharts-tooltip-item {
  font-family: var(--sans) !important;
  font-size: 11px !important;
}
.recharts-cartesian-axis-tick-value { fill: var(--ink-stone) !important; }
.recharts-cartesian-grid-horizontal line,
.recharts-cartesian-grid-vertical line { stroke: var(--soft-rule) !important; }
.recharts-tooltip-wrapper {
  outline: none !important;
}
.recharts-default-tooltip {
  background: var(--rich-black) !important;
  border: 0 !important;
  border-radius: 0 !important;
  color: var(--white) !important;
  padding: 10px 12px !important;
  font-family: var(--sans) !important;
  font-size: 11px !important;
}
.recharts-default-tooltip .recharts-tooltip-label,
.recharts-default-tooltip .recharts-tooltip-item {
  color: var(--white) !important;
}

/* hover lift for cards in editorial-leaning grids */
.card.lift {
  transition: transform var(--dur-quick) var(--ease), box-shadow var(--dur-quick) var(--ease), border-color var(--dur-fast);
  cursor: pointer;
}
.card.lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--panel-shadow);
  border-color: rgba(190,46,43,0.25);
}

/* grid helpers */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.row-12 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

/* ── Sliding text fade between tabs ───────────────────── */
.tab-content {
  animation: tab-fade 240ms var(--ease) forwards;
}
@keyframes tab-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* slider */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 4px;
  background: var(--soft-rule);
  border-radius: 999px;
  outline: none;
}
.slider-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  background: var(--rich-black);
  border-radius: 999px;
  cursor: pointer;
}
.slider-row input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--rich-black);
  border-radius: 999px;
  border: 0;
  cursor: pointer;
}

/* small progress dot */
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.score-pill.hi { background: rgba(49,90,73,0.1); color: var(--dark-green); }
.score-pill.mid { background: rgba(193,139,42,0.12); color: #8B5E18; }
.score-pill.lo { background: rgba(190,46,43,0.1); color: var(--brand-red); }

/* time-range toggle */
.range-toggle {
  display: inline-flex;
  background: var(--paper);
  padding: 3px;
  border: 1px solid var(--soft-rule);
}
.range-toggle button {
  padding: 6px 11px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ink-stone);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.range-toggle button.active { background: var(--rich-black); color: var(--white); }

/* Tweaks panel overrides (slightly tighter to brand) */
.tweaks-panel { background: var(--white); border: 1px solid var(--soft-rule); border-radius: 0; }

/* report-card visual */
.report-card {
  background: var(--paper-elevated);
  border: 1px solid var(--soft-rule);
  padding: 56px 64px;
  position: relative;
}
.report-section {
  padding-top: 28px;
  margin-top: 28px;
  border-top: 1px solid var(--soft-rule);
}
.report-section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.report-section h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  color: var(--rich-black);
}
.report-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.report-section ul li {
  padding: 10px 0 10px 22px;
  border-bottom: 1px solid var(--border);
  position: relative;
  font-size: 13.5px;
  color: var(--rich-black);
  line-height: 1.55;
}
.report-section ul li::before {
  content: "";
  position: absolute;
  left: 0; top: 18px;
  width: 8px; height: 1px;
  background: var(--brand-red);
}

/* empty state */
.empty {
  text-align: center;
  padding: 80px 32px;
  border: 1px dashed var(--soft-rule);
}
.empty .icon-circle {
  width: 56px; height: 56px;
  border: 1px solid var(--soft-rule);
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
  color: var(--ink-stone);
}

/* funnel custom */
.funnel-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.funnel-row:last-of-type { border-bottom: 0; }
.funnel-row .h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
}
.funnel-row .h .stage {
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10.5px;
  color: var(--rich-black);
}
.funnel-row .h .val {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  color: var(--rich-black);
}
.funnel-row .h .pct {
  font-size: 11px;
  color: var(--ink-stone);
  font-variant-numeric: tabular-nums;
}
.funnel-row .bar {
  height: 6px;
  background: var(--paper);
  position: relative;
  overflow: hidden;
}
.funnel-row .bar .fill {
  height: 100%;
  background: var(--rich-black);
  transition: width 400ms var(--ease);
}
.funnel-row.red .bar .fill { background: var(--brand-red); }

/* spending source card */
.source-card {
  background: var(--white);
  border: 1px solid var(--soft-rule);
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 168px;
  transition: border-color var(--dur-fast), transform var(--dur-quick) var(--ease);
}
.source-card:hover { border-color: var(--rich-black); }
.source-card .top {
  display: flex; align-items: center; justify-content: space-between;
}
.source-icon {
  width: 36px; height: 36px;
  border: 1px solid var(--soft-rule);
  display: flex; align-items: center; justify-content: center;
  color: var(--rich-black);
}
.source-card .name {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  color: var(--rich-black);
}
.source-card .sub {
  font-size: 11.5px;
  color: var(--ink-stone);
}

/* timeline (prospect detail) */
.timeline {
  position: relative;
  padding-left: 22px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 5px; top: 4px; bottom: 4px;
  width: 1px;
  background: var(--soft-rule);
}
.timeline-item {
  position: relative;
  padding-bottom: 18px;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -22px; top: 6px;
  width: 11px; height: 11px;
  border-radius: 999px;
  background: var(--white);
  border: 1.5px solid var(--rich-black);
}
.timeline-item.red::before { border-color: var(--brand-red); }
.timeline-item .when {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-stone);
}
.timeline-item .what {
  font-size: 13px;
  color: var(--rich-black);
  margin-top: 2px;
}

/* compact list (top pages etc.) */
.kv-list {
  font-size: 12.5px;
}
.kv-list .row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.kv-list .row:last-child { border-bottom: 0; }
.kv-list .row .name { color: var(--rich-black); }
.kv-list .row .v { color: var(--ink-stone); font-variant-numeric: tabular-nums; }

/* sources grid empty hint */
.connect-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* client roster grid */
.roster-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.roster-card {
  background: var(--white);
  border: 1px solid var(--soft-rule);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: border-color var(--dur-fast), transform var(--dur-quick) var(--ease);
}
.roster-card:hover {
  border-color: var(--rich-black);
  transform: translateY(-1px);
}
.roster-name {
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  color: var(--rich-black);
}
.roster-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-stone);
}
.roster-meta .k {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
}
.roster-meta .k b { color: var(--rich-black); font-weight: 500; }

/* For responsiveness in narrow viewports */
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .row-2, .row-3, .row-12 { grid-template-columns: 1fr; }
  .connect-grid, .roster-grid { grid-template-columns: repeat(2, 1fr); }
  .page-wrap { padding: 20px; }
  .app-header-inner, .tab-bar { padding-left: 20px; padding-right: 20px; }
}

/* ── Side-nav layout ─────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  align-items: stretch;
}
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--soft-rule);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  /* visible so the bottom "View as" dropdown isn't clipped; inner scroll
     lives on .sidebar-scroll. */
  overflow: visible;
}
.sidebar-head {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--soft-rule);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-mark {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-mark img { width: 100%; height: 100%; display: block; }
.sidebar-wordmark {
  font-family: var(--serif);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  font-size: 17px;
  color: var(--rich-black);
  font-weight: 400;
}
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 0 18px;
}
.sidebar-entity {
  padding: 14px 22px 12px;
}
.sidebar-entity-eyebrow {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-red);
  margin: 0 0 6px;
}
.sidebar-entity-name {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  color: var(--rich-black);
  margin: 0;
}
.sidebar-entity-meta {
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-stone);
}
.sidebar-section {
  padding: 14px 12px 4px;
}
.sidebar-section + .sidebar-section { border-top: 1px solid var(--soft-rule); margin-top: 6px; }
.sidebar-section-label {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-stone);
  padding: 6px 12px 10px;
}
.sidebar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-stone);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-quiet), background var(--dur-fast);
}
.sidebar-item:hover { color: var(--rich-black); background: rgba(26,25,25,0.03); }
.sidebar-item.active {
  color: var(--rich-black);
  background: rgba(26,25,25,0.05);
}
.sidebar-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--brand-red);
}
.sidebar-foot {
  border-top: 1px solid var(--soft-rule);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-foot .tlink { font-size: 12px; }

/* ── Slim top utility bar (when sidebar is in use) ─────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--white);
  border-bottom: 1px solid var(--soft-rule);
  padding: 12px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
}
.topbar-title {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  color: var(--rich-black);
  flex: 1;
}
.topbar-title .crumb {
  color: var(--ink-stone);
  font-weight: 400;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* keep flex grid honest for charts */
}
.app-main .page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: 32px;
}
.app-main .banner {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* viewing-as banner inside the sidebar (replaces old full-width banner) */
.sidebar-banner {
  margin: 0 14px 10px;
  padding: 10px 12px;
  background: rgba(220, 38, 38, 0.07);
  border-left: 2px solid var(--brand-red);
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--rich-black);
  line-height: 1.4;
}
.sidebar-banner button {
  margin-top: 6px;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--brand-red);
  text-decoration: underline;
  cursor: pointer;
}

@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--soft-rule); }
  .sidebar-scroll { max-height: none; }
}
