:root {
  color-scheme: light;

  /* CxO Institute brand chrome */
  --header-bg: #0b0b0b;
  --header-accent: #eda100;

  /* dataviz reference palette (light) */
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border-hairline: rgba(11, 11, 11, 0.10);

  --series-actual: #2a78d6;   /* categorical slot 1 */
  --series-pace: #008300;     /* categorical slot 6 */

  --stage-1: #86b6ef;
  --stage-2: #5598e7;
  --stage-3: #2a78d6;
  --stage-4: #1c5cab;
  --stage-5: #104281;

  --grade-gold: #eda100;
  --grade-blue: #2a78d6;
  --grade-green: #008300;
  --grade-red: #e34948;
  --grade-fixed: #4a3aa7;
  --grade-ungraded: #898781;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --success-text: #006300;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

header.app-header {
  background: var(--header-bg);
  color: #fff;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

header.app-header .logo {
  height: 40px;
  width: 40px;
  display: block;
}

header.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

header.app-header .crmx-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--header-accent);
  border: 1.5px solid var(--header-accent);
  border-radius: 4px;
  padding: 8px 14px;
  text-decoration: none;
  white-space: nowrap;
}
header.app-header .crmx-link:hover {
  background: var(--header-accent);
  color: #0b0b0b;
}

.event-bar {
  background: #1c1c1c;
  color: #fff;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.event-bar .field label {
  display: block;
  font-size: 11px;
  color: #a8a8a8;
  margin-bottom: 2px;
}

.event-bar .field .value {
  font-size: 16px;
  font-weight: 600;
}

.event-bar select#event-select {
  font-size: 16px;
  font-weight: 600;
  background: #1c1c1c;
  color: #fff;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 4px 8px;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--surface-1);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 16px 18px;
}

.kpi-card .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.kpi-card .value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.kpi-card .value {
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
}

.kpi-card .pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.kpi-card .pct.status-critical { color: var(--status-critical); }
.kpi-card .pct.status-serious { color: var(--status-serious); }
.kpi-card .pct.status-muted { color: var(--text-muted); }

.kpi-card .track {
  height: 6px;
  border-radius: 3px;
  background: var(--gridline);
  overflow: hidden;
}
.kpi-card .track .fill {
  height: 100%;
  border-radius: 3px;
  background: var(--series-actual);
}

.kpi-card .denom {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.kpi-card.alert .track .fill { background: var(--status-critical); }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.card h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
}

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

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr; }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.table-toggle {
  font-size: 12px;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
}
.table-toggle:hover { background: var(--page-plane); }

.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
}
.chart-table th, .chart-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--gridline);
}
.chart-table[hidden] { display: none; }

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}
.legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
}

.funnel-row {
  display: grid;
  grid-template-columns: 190px 1fr 48px;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}
.funnel-row .stage-label { font-size: 13px; color: var(--text-secondary); }
.funnel-row .bar-track {
  height: 20px;
  background: var(--gridline);
  border-radius: 3px;
  overflow: hidden;
}
.funnel-row .bar-fill {
  height: 100%;
  border-radius: 3px;
}
.funnel-row .stage-count {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stack-bar {
  display: flex;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  gap: 2px;
}
.stack-bar .segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  min-width: 2px;
}

.rep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.rep-table thead th {
  text-align: left;
  font-weight: 700;
  padding: 10px 14px;
  background: var(--gridline);
  white-space: nowrap;
}
.rep-table thead th .sort-arrow {
  font-size: 11px;
  color: var(--text-secondary);
}
.rep-table tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--gridline);
}
.rep-table tbody tr:nth-child(odd) td:first-child {
  background: var(--page-plane);
}
.rep-table td.heat {
  font-weight: 700;
  text-align: center;
}
.rep-table td.heat.status-good { background: var(--status-good); color: #0b0b0b; }
.rep-table td.heat.status-warning { background: var(--status-warning); color: #0b0b0b; }
.rep-table td.heat.status-serious { background: var(--status-serious); color: #0b0b0b; }
.rep-table td.heat.status-critical { background: var(--status-critical); color: #fff; }
.rep-table td.heat.status-na { color: var(--text-muted); text-align: center; }

footer.app-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px 40px;
  font-size: 12px;
  color: var(--text-muted);
}
