/* Ad Fatigue & Channel Saturation (Live) — self-contained UI */

:root {
  --bg: #0b1220;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.08);
  --panel: rgba(15, 23, 42, 0.68);
  --panel2: rgba(255, 255, 255, 0.05);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.70);
  --muted2: rgba(255, 255, 255, 0.55);
  --border: rgba(255, 255, 255, 0.12);
  --border2: rgba(255, 255, 255, 0.18);
  --grid: rgba(255, 255, 255, 0.08);
  --axis: rgba(255, 255, 255, 0.22);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);

  --accent: #60a5fa;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background:
    radial-gradient(1200px 800px at 30% 0%, rgba(56, 189, 248, 0.10), transparent 55%),
    radial-gradient(900px 700px at 80% 15%, rgba(34, 197, 94, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 22, 40, 0.85);
  backdrop-filter: blur(10px);
}

.brand__title { font-size: 16px; font-weight: 780; letter-spacing: 0.2px; }
.brand__subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.topbar__right {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(3, 7, 18, 0.18);
  color: rgba(229,231,235,0.82);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pill b {
  font-weight: 820;
  color: rgba(229,231,235,0.92);
}

.seed {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.6);
}
.seed__label { font-size: 12px; color: var(--muted); }
.seed__input {
  width: 120px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(3, 7, 18, 0.6);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}
.seed__input:focus { border-color: rgba(96, 165, 250, 0.7); }

.topbar__buttons { display: flex; gap: 10px; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  padding: 9px 12px;
  border-radius: 12px;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  background: rgba(15, 23, 42, 0.8);
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(180deg, rgba(96,165,250,0.95), rgba(59,130,246,0.85));
  border-color: rgba(96,165,250,0.6);
  color: #071122;
}
.btn--outline { background: rgba(15, 23, 42, 0.6); border-color: rgba(148, 163, 184, 0.22); }
.btn--outline:hover { border-color: rgba(96,165,250,0.5); }
.btn--ghost { background: rgba(3, 7, 18, 0.25); border-color: rgba(148, 163, 184, 0.18); font-weight: 600; }
.btn--ghost:hover { border-color: rgba(148, 163, 184, 0.32); }
.btn--ghost.active {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.4);
  color: rgba(96, 165, 250, 0.95);
}

.badge {
  font-size: 11px;
  font-weight: 780;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(3, 7, 18, 0.25);
  color: rgba(229,231,235,0.9);
}
.badge--ok { border-color: rgba(52,211,153,0.35); background: rgba(52,211,153,0.10); }
.badge--warn { border-color: rgba(251,191,36,0.45); background: rgba(251,191,36,0.12); color: rgba(255,237,213,0.95); }

.page {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 360px;
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--card2), var(--card));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel:hover {
  border-color: var(--border2);
}
.panel__header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.2);
}
.panel__title { font-weight: 780; font-size: 13px; letter-spacing: 0.2px; }
.panel__hint { margin-top: 3px; font-size: 12px; color: var(--muted); }

.panel--left, .panel--right {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 90px);
  overflow: auto;
}

.control-group { padding: 12px 14px; }
.control-group + .control-group { border-top: 1px solid rgba(148, 163, 184, 0.12); }
.control-group__title { font-size: 12px; font-weight: 780; color: rgba(229, 231, 235, 0.9); margin-bottom: 10px; letter-spacing: 0.2px; }

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.field__label { font-size: 12px; color: rgba(229, 231, 235, 0.95); }
.field__value { font-family: var(--mono); font-size: 12px; color: rgba(229, 231, 235, 0.9); font-variant-numeric: tabular-nums; }
.field__hint { margin-top: 5px; font-size: 11px; color: rgba(229, 231, 235, 0.72); }

input[type="range"] { width: 100%; accent-color: rgba(96,165,250,0.95); }

.radio { display: grid; gap: 8px; }
.radio__item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(3, 7, 18, 0.18);
}
.radio__item span { font-size: 12px; color: rgba(229,231,235,0.9); }

.center { min-width: 0; display: grid; gap: 14px; }

.main-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--card2), var(--card));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.main-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.2);
}
.main-card__title { font-weight: 780; font-size: 13px; letter-spacing: 0.2px; }
.main-card__summary {
  padding: 12px 14px;
  border-bottom: 1px solid var(--grid);
  background: rgba(2, 6, 23, 0.10);
}

.narrative-sentence {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  font-style: italic;
  padding: 8px 0;
}

/* System State Card - Primary Focus */
.system-state-card {
  margin: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.08));
  overflow: hidden;
}

.system-state-card__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--grid);
  background: rgba(2, 6, 23, 0.2);
}

.system-state-card__title {
  font-size: 14px;
  font-weight: 780;
  color: var(--text);
  letter-spacing: 0.2px;
}

.system-state-card__body {
  padding: 16px;
}

.system-state-card__status {
  font-size: 20px;
  font-weight: 820;
  font-family: var(--mono);
  margin-bottom: 8px;
  color: var(--text);
}

.system-state-card__status.state-under {
  color: rgba(96, 165, 250, 0.9);
}

.system-state-card__status.state-healthy {
  color: rgba(52, 211, 153, 0.9);
}

.system-state-card__status.state-over {
  color: rgba(251, 191, 36, 0.9);
}

.system-state-card__status.state-saturated {
  color: rgba(251, 113, 133, 0.9);
}

.system-state-card__explanation {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

/* Pressure Scale */
.pressure-scale-container {
  padding: 16px;
  border-bottom: 1px solid var(--grid);
}

.pressure-scale {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pressure-scale__bar {
  position: relative;
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  display: flex;
  overflow: visible;
}

.pressure-scale__zone {
  flex: 1;
  height: 100%;
}

.pressure-scale__zone--low {
  background: rgba(96, 165, 250, 0.2);
}

.pressure-scale__zone--optimal {
  background: rgba(52, 211, 153, 0.2);
}

.pressure-scale__zone--overpressure {
  background: rgba(251, 191, 36, 0.2);
}

.pressure-scale__zone--saturation {
  background: rgba(251, 113, 133, 0.2);
}

.pressure-scale__marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--text);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
  transform: translateX(-50%);
  transition: left 0.3s ease;
}

.pressure-scale__label {
  font-size: 11px;
  color: var(--muted2);
  font-weight: 600;
}

.pressure-scale__label--left {
  margin-bottom: 4px;
}

.pressure-scale__labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted2);
  padding: 4px 8px 0;
  margin-top: 2px;
}

/* Driver Cards */
.driver-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--grid);
}

.driver-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.06));
  overflow: hidden;
}

.driver-card--fatigue.zone-healthy {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.15), rgba(52, 211, 153, 0.10));
  border-color: rgba(52, 211, 153, 0.4);
}

.driver-card--fatigue.zone-borderline {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.10));
  border-color: rgba(251, 191, 36, 0.4);
}

.driver-card--fatigue.zone-saturated {
  background: linear-gradient(180deg, rgba(251, 113, 133, 0.15), rgba(251, 113, 133, 0.10));
  border-color: rgba(251, 113, 133, 0.4);
}

.driver-card__header {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 780;
  color: var(--text);
  border-bottom: 1px solid var(--grid);
  background: rgba(2, 6, 23, 0.1);
}

.driver-card__body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Outcome Cards */
.outcome-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--grid);
}

.outcome-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.06));
  overflow: hidden;
}

.outcome-card__header {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 780;
  color: var(--text);
  border-bottom: 1px solid var(--grid);
  background: rgba(2, 6, 23, 0.1);
}

.outcome-card__body {
  padding: 12px;
}

/* Contextual Warnings */
.contextual-warnings {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contextual-warning {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  border-left: 3px solid;
}

.contextual-warning.warning-fatigue {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.6);
  color: rgba(251, 191, 36, 0.95);
}

.contextual-warning.warning-ctr {
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.6);
  color: rgba(251, 113, 133, 0.95);
}

.contextual-warning.warning-pressure {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.6);
  color: rgba(251, 191, 36, 0.95);
}

/* Metric items within cards */
.metric-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-item:last-child {
  border-bottom: none;
}

.metric-item__label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.metric-item__value {
  font-size: 14px;
  font-weight: 820;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.metric-item__sparkline {
  margin-top: 4px;
  height: 20px;
  width: 100%;
}

.metric-item__sparkline canvas {
  width: 100% !important;
  height: 20px !important;
  display: block;
}

.pipeline-card__sparkline {
  height: 24px;
  width: 100%;
  margin-top: 4px;
  min-width: 100px;
}

.pipeline-card__sparkline canvas {
  width: 100% !important;
  height: 24px !important;
  display: block;
}

.pipeline-card--zone {
  padding: 14px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 780;
}

.pipeline-card--zone.zone-healthy {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.15), rgba(52, 211, 153, 0.10));
  border-color: rgba(52, 211, 153, 0.4);
  color: rgba(52, 211, 153, 0.95);
}

.pipeline-card--zone.zone-borderline {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.10));
  border-color: rgba(251, 191, 36, 0.4);
  color: rgba(251, 191, 36, 0.95);
}

.pipeline-card--zone.zone-saturated {
  background: linear-gradient(180deg, rgba(251, 113, 133, 0.15), rgba(251, 113, 133, 0.10));
  border-color: rgba(251, 113, 133, 0.4);
  color: rgba(251, 113, 133, 0.95);
}

.pipeline-card__indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.pipeline-card__indicator.indicator-ok {
  background: rgba(52, 211, 153, 0.8);
  box-shadow: 0 0 4px rgba(52, 211, 153, 0.5);
}

.pipeline-card__indicator.indicator-warn {
  background: rgba(251, 191, 36, 0.8);
  box-shadow: 0 0 4px rgba(251, 191, 36, 0.5);
}

.pipeline-card__indicator.indicator-danger {
  background: rgba(251, 113, 133, 0.8);
  box-shadow: 0 0 4px rgba(251, 113, 133, 0.5);
}

.pipeline-card__progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.pipeline-card__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.8), rgba(96, 165, 250, 0.6));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.pipeline-card__badge {
  display: inline-block;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  margin-top: 4px;
  font-weight: 600;
}

.pipeline-card__badge.badge-baseline {
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.3);
  color: rgba(96, 165, 250, 0.9);
}

@media (max-width: 1400px) {
  .driver-cards {
    grid-template-columns: 1fr;
  }
  .outcome-cards {
    grid-template-columns: 1fr;
  }
}

.narrative-panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--grid);
  background: rgba(2, 6, 23, 0.12);
}
.narrative-panel__header {
  margin-bottom: 10px;
}
.narrative-panel__title {
  font-size: 12px;
  font-weight: 780;
  color: var(--text);
  letter-spacing: 0.2px;
}
.narrative-panel__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.narrative-panel__text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  min-height: 2.5em;
}
.narrative-panel__summary {
  font-size: 11px;
  color: var(--muted2);
  font-style: italic;
  padding-top: 8px;
  border-top: 1px solid var(--grid);
}

.chart-card.narrative-highlight {
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3), 0 4px 12px rgba(96, 165, 250, 0.15);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.main-card__footer { padding: 10px 14px; border-top: 1px solid rgba(148, 163, 184, 0.12); background: rgba(2, 6, 23, 0.16); }

.footer-row { display: flex; flex-wrap: wrap; gap: 12px 18px; }
.footer-kv { display: flex; gap: 8px; align-items: baseline; }
.kv__k { font-size: 11px; color: rgba(229,231,235,0.65); }
.kv__v { font-size: 12px; font-family: var(--mono); font-variant-numeric: tabular-nums; color: rgba(229,231,235,0.9); }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
}
.chart-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.05));
  border-radius: 14px;
  overflow: hidden;
  height: 260px;
  display: flex;
  flex-direction: column;
}
.chart-card:hover {
  border-color: var(--border2);
}
.chart-card__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 10px 10px 6px;
}
.chart-card__title { font-size: 12px; font-weight: 780; color: var(--text); }
.chart-card__subtitle { font-size: 10px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.chart-card__body {
  flex: 1;
  padding: 10px 12px 12px;
  position: relative;
}
.chart-card__placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  color: var(--muted2);
  text-align: center;
  pointer-events: none;
  line-height: 1.5;
  max-width: 80%;
}
.chart-card__legend {
  padding: 6px 10px 0;
  font-size: 10px;
  color: var(--muted2);
  text-align: center;
  border-top: 1px solid var(--grid);
}
.chart-card__body canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.metrics-grid { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 12px 14px; }
.metric { padding: 10px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel2); }
.metric__k { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.metric__v { font-size: 16px; font-weight: 820; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.howto {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.50);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.howto__summary { padding: 12px 14px; cursor: pointer; font-weight: 780; font-size: 13px; background: rgba(2, 6, 23, 0.14); }
.howto__body { padding: 10px 14px 14px; }
.howto__list { margin: 0; padding-left: 18px; color: rgba(229, 231, 235, 0.78); font-size: 13px; line-height: 1.45; }
.howto__list li + li { margin-top: 8px; }

@media (max-width: 1180px) {
  .page { grid-template-columns: 1fr; }
  .panel--left, .panel--right { position: relative; top: auto; max-height: none; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}
