/* ══════════════════════════════════════════════════════════════════════════════
   PXInsights — Shared Components (base.css)
   ══════════════════════════════════════════════════════════════════════════════
   Requires: /css/tokens.css loaded BEFORE this file.
   All colors reference CSS vars from tokens.css — no bare hex values here.

   Index of sections:
     §1  Reset
     §2  Base elements (body, a)
     §3  Legacy nav shell (.navbar, .nav-brand, .nav-links)
     §4  Page layout (.page-header, .breadcrumb, .content)
     §5  Executive summary block
     §6  KPI card  — .kpi-grid column count is PAGE-SPECIFIC (not here)
     §7  Chart card, container, note + chart-grid layout
     §8  Section title
     §9  Toggle + tab controls
     §10 Data tables (leaderboard, matrix, hotspot, client)
     §11 Score / sentiment cards
     §12 Director & dossier cards
     §13 Risk & urgency cards
     §14 Quote cards
     §15 Page footer
     §16 Utility classes
     §17 Responsive overrides

   Keep-in-sync rule: when a component changes, update the index above and the
   section comment below in the same commit.
   ══════════════════════════════════════════════════════════════════════════════ */


/* ── §1 Reset ─────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}


/* ── §2 Base elements ─────────────────────────────────────────────────────── */

body {
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}


/* ── §3 Legacy nav shell ──────────────────────────────────────────────────── */
/* Kept for pages that have not yet been migrated to the nav.js #px-nav mount.
   Pages using <nav id="px-nav"></nav> + /nav.js can omit these entirely;
   nav.js injects its own .pxnav-* styles. These will be removed in Phase 2
   once all pages are confirmed to use the shared nav.js component.            */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 16px var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.nav-brand .icon-box {
  width: 36px;
  height: 36px;
  background: var(--brand-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(255, 74, 0, 0.25);
  color: white;
  font-size: 16px;
}

.nav-brand span {
  color: var(--brand-primary);
}

.nav-links {
  display: flex;
  gap: var(--space-xs);
}

.nav-links a {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.2s;
}

.nav-links a:hover {
  background: rgba(211, 197, 191, 0.3);
}

.nav-links a.active {
  background: rgba(255, 74, 0, 0.08);
  color: var(--brand-primary);
  font-weight: 700;
}


/* ── §4 Page layout ───────────────────────────────────────────────────────── */

.page-header {
  padding: 28px var(--space-xl) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.page-header h1 span {
  color: var(--brand-primary);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a {
  color: var(--brand-primary);
  font-weight: 600;
}

.content {
  padding: var(--space-lg) var(--space-xl);
}


/* ── §5 Executive summary block ───────────────────────────────────────────── */

.exec-summary {
  background: linear-gradient(145deg, var(--bg), var(--surface));
  border: 1px solid var(--brand-primary);
  border-radius: var(--radius-xl);
  padding: 28px;
  margin-bottom: var(--space-lg);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.04);
}

.exec-summary .section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.exec-summary .section-title i {
  color: var(--brand-primary);
}

.exec-summary .summary-text {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-secondary);
  font-weight: 300;
  margin-bottom: var(--space-lg);
  font-style: italic;
}

/* Scoped rule: summary-text inside per-segment .file-panel tabs (no .exec-summary wrapper).
   Single source — covers both exit and check-in segment pages.
   --text-secondary = #4E403B (same hex as the now-deleted check-in page-local override). */
.file-panel .summary-text {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-secondary);
  font-weight: 300;
  font-style: italic;
  margin-bottom: 16px;
}

.exec-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.exec-col {
  padding: var(--space-md);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.exec-col.strengths {
  background: rgba(88, 115, 34, 0.05);
  border-left: 4px solid var(--success);
}

.exec-col.review {
  background: rgba(255, 74, 0, 0.04);
  border-left: 4px solid var(--brand-primary);
}

.exec-col h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.exec-col.strengths h4 { color: var(--success); }
.exec-col.review    h4 { color: var(--brand-primary); }

.exec-col ul {
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.8;
}


/* ── §6 KPI card ──────────────────────────────────────────────────────────── */
/* .kpi-grid grid-template-columns is PAGE-SPECIFIC:
     checkin overview  → repeat(6, 1fr)
     exit overview     → repeat(4, 1fr)
     segment pages     → repeat(7, 1fr)
   Declare it in the page's own <style> block.                                 */

.kpi-grid {
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  display: grid;
  /* column count set per-page */
}

.kpi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.kpi-card .kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.kpi-card .kpi-label i {
  color: var(--brand-primary);
  font-size: 16px;
}

.kpi-card .kpi-value {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-primary);
}

.kpi-card .kpi-value small {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-muted);
}

.kpi-card .kpi-sub {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: var(--space-xs);
}


/* ── §7 Chart card, container, note + layout ──────────────────────────────── */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: var(--space-lg);
}

.chart-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.04);
}

.stacked-cards > .chart-card { margin-bottom: 24px; }

.chart-card.full {
  grid-column: span 2;
}

.chart-card .chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.chart-card .chart-title i {
  color: var(--brand-primary);
  font-size: 16px;
}

.chart-container {
  position: relative;
  height: 300px;
}

.chart-container.tall {
  height: 420px;
}

.chart-note {
  font-size: 12px;
  color: var(--text-subtle);
  background: var(--surface-alt);
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-sm) 12px;
  margin-top: 14px;
  line-height: 1.6;
}

.chart-note strong { color: var(--text-muted); }


/* ── §8 Section title ─────────────────────────────────────────────────────── */

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.section-title i { color: var(--brand-primary); }


/* ── §9 Toggle + tab controls ─────────────────────────────────────────────── */

/* View-mode toggle (checkin: Rate vs Count) */
.view-toggle,
.driver-toggle {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--mist);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface-alt);
  color: var(--slate);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.view-toggle.active,
.driver-toggle.active {
  background: var(--slate);
  color: var(--bg);
  border-color: var(--slate);
}

.driver-toggle-group {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: 12px;
}

/* File-UI tab system (segment pages, per-card) */
.file-tabs {
  display: flex;
  gap: var(--space-xs);
  border-bottom: 1px solid var(--mist);
  margin-bottom: var(--space-md);
}

.file-tab {
  padding: var(--space-sm) var(--space-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--taupe);
  background: var(--surface-alt);
  border: 1px solid var(--mist);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  margin-bottom: -1px;
  user-select: none;
  transition: color 0.12s;
}

.file-tab:hover { color: var(--slate); }

.file-tab.active {
  color: var(--slate);
  background: var(--bg);
  border-bottom: 1px solid var(--bg);
}

.file-panel          { display: none; }
.file-panel.active   { display: block; }


/* ── §10 Data tables ──────────────────────────────────────────────────────── */

/* Shared table header + row baseline */
.leaderboard-table,
.matrix-table,
.hotspot-table,
.client-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Shared th */
.leaderboard-table th,
.matrix-table th,
.hotspot-table th,
.client-table th {
  text-align: left;
  padding: var(--space-sm) 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-subtle);
  border-bottom: 2px solid var(--border);
}

.matrix-table th:not(:first-child) { text-align: center; }

/* Shared td */
.leaderboard-table td,
.matrix-table td,
.hotspot-table td,
.client-table td {
  padding: var(--space-sm) 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.matrix-table td:not(:first-child) { text-align: center; }

.leaderboard-table tr:last-child td,
.matrix-table tr:last-child td,
.hotspot-table tr:last-child td,
.client-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-table tr:hover td,
.matrix-table tr:hover td {
  background: var(--surface-alt);
}

/* Matrix-table specifics */
.matrix-table th { background: var(--surface-alt); }
.matrix-wrap     { margin-bottom: 20px; overflow-x: auto; }

.matrix-cell {
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

.matrix-cell .mc-count { font-size: 16px; font-weight: 800; line-height: 1; }
.matrix-cell .mc-score { font-size: 10px; font-weight: 600; opacity: 0.85; }

.matrix-cell-n {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.matrix-reason-badge {
  display: inline-block;
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--space-xs);
  font-size: 9px;
  font-weight: 600;
  background: var(--border-subtle);
  color: var(--text-muted);
  max-width: 120px;
  word-break: break-word;
  line-height: 1.4;
}

.matrix-empty { color: var(--warm-grey); font-size: 18px; }

/* Hotspot-table specifics */
.hotspot-table th     { white-space: nowrap; }
.hotspot-table td     { padding: 5px 8px; font-size: 12px; }
.hotspot-table tr.sdm-row            { background: var(--surface-alt); cursor: pointer; }
.hotspot-table tr.sdm-row td         { font-weight: 600; }
.hotspot-table tr.tl-row.hidden      { display: none; }
.hotspot-table tr.sdm-row:hover      { background: var(--border-subtle); }

/* Client-table specifics */
.client-table th { padding: 4px 8px; font-size: 10px; }
.client-table td { padding: 6px 8px; }


/* ── §11 Score / sentiment cards ──────────────────────────────────────────── */

/* Used as: .sentiment-card (checkin) and .score-card (exit) — same visual */
.sentiment-grid,
.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.sentiment-card,
.score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-md);
  text-align: center;
}

.sentiment-card .dim-label,
.score-card .dim-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sentiment-card .dim-value,
.score-card .dim-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.sentiment-card .dim-value { font-size: 15px; font-weight: 700; }

.sentiment-card .dim-sub,
.score-card .dim-sub {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 2px;
}

.sentiment-card .dim-bar,
.score-card .dim-bar {
  height: 4px;
  border-radius: 2px;
  margin-top: var(--space-sm);
  background: var(--border);
}

.sentiment-card .dim-bar-fill,
.score-card .dim-bar-fill {
  height: 100%;
  border-radius: 2px;
}


/* ── §12 Director & dossier cards ─────────────────────────────────────────── */

.dir-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

.dir-header,
.dossier-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-mid);
}

.dir-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.dir-stats,
.dossier-vitals {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  flex-wrap: wrap;
}

.dir-stat     { text-align: center; }
.dir-stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-subtle);
  margin-bottom: 2px;
}
.dir-stat-value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.dir-body {
  padding: var(--space-md) 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dir-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-subtle);
  margin-bottom: var(--space-sm);
}

/* Metric pill (segment pages) */
.metric-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: var(--space-sm); }
.metric-pill {
  background: var(--surface-alt);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
}
.metric-pill .m-label { color: var(--text-subtle); font-weight: 600; }
.metric-pill .m-value { font-weight: 800; margin-left: var(--space-xs); }

/* Dossier cards (standalone — exit overview) */
.dossier-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-md) 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.dossier-card:last-child { margin-bottom: 0; }

.dossier-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 160px;
}

.dossier-n {
  display: inline-block;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
}

.dossier-pills {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  flex: 1;
}

.dossier-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-width: 70px;
}

.dossier-pill-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-subtle);
  margin-bottom: 3px;
}

.dossier-pill-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}

.dossier-reason {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-subtle);
  font-style: italic;
  background: var(--surface-alt);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
}


/* ── §13 Risk & urgency cards ─────────────────────────────────────────────── */

.risk-signal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.risk-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-md);
  background: var(--bg);
}

.risk-card .seg-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-mid);
}

.risk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: var(--space-xs) 0;
}

.risk-row .r-label { font-weight: 500; }
.risk-val          { font-weight: 800; font-size: 14px; }

/* Urgency section */
.urgency-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
}

.urgency-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.urgency-card {
  border-radius: 12px;
  padding: var(--space-md);
  border: 1px solid var(--border);
}

.urgency-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.urgency-count {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.urgency-pct { font-size: 12px; color: var(--text-subtle); }


/* ── §14 Quote cards ──────────────────────────────────────────────────────── */

.quotes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-top: var(--space-xs);
}

.quote-card {
  background: var(--surface-alt);
  border: 1px solid var(--border-mid);
  border-left: 3px solid var(--brand-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-md);
}

.quote-card .quote-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.quote-card .quote-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  font-style: italic;
}

.quote-card .quote-score {
  display: inline-block;
  padding: 2px var(--space-sm);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}


/* ── §15 Page footer ──────────────────────────────────────────────────────── */

.page-footer {
  padding: 20px var(--space-xl);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}


/* ── §16 Utility ──────────────────────────────────────────────────────────── */

/* Pipeline pills (exit-specific segment pages) */
.pipeline-pills { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin-top: var(--space-sm); }
.pipeline-pill  { padding: var(--space-xs) 12px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; }
.pipeline-pill.prime  { background: rgba(88, 115, 34, 0.10); color: var(--success); }
.pipeline-pill.warm   { background: rgba(255, 187, 0, 0.10);  color: #b88a00; }
.pipeline-pill.closed { background: rgba(140, 21, 47, 0.10);  color: var(--error); }

/* Concern analysis bottom layout */
.concern-bottom { display: grid; grid-template-columns: 1fr 200px; gap: var(--space-lg); align-items: center; margin-top: var(--space-sm); }


/* ── §17 Responsive overrides ─────────────────────────────────────────────── */

@media (max-width: 900px) {
  .kpi-grid    { grid-template-columns: repeat(2, 1fr) !important; }
  .chart-grid  { grid-template-columns: 1fr; }
  .chart-card.full { grid-column: span 1; }
  .exec-columns    { grid-template-columns: 1fr; }
  .dir-body        { grid-template-columns: 1fr; }
  .urgency-layout  { grid-template-columns: 1fr; }
  .quotes-grid     { grid-template-columns: 1fr; }
  .sentiment-grid,
  .score-grid      { grid-template-columns: repeat(2, 1fr); }
  .risk-signal-grid{ grid-template-columns: repeat(2, 1fr); }
}
