:root {
  --ink: #142c2a;
  --muted: #657572;
  --line: #dce6e2;
  --soft: #f3f7f5;
  --paper: #ffffff;
  --forest: #0f5b4e;
  --forest-2: #287f6c;
  --mint: #dff2e9;
  --lime: #b7dc76;
  --amber: #ecaa4c;
  --amber-soft: #fff3dc;
  --red: #c8584f;
  --blue: #347fc4;
  --shadow: 0 12px 40px rgba(22, 54, 48, 0.08);
  --device-1: #2684c7;
  --device-2: #58a65c;
  --device-3: #e05a4f;
  --device-4: #eba721;
  --device-5: #657d88;
}

* { box-sizing: border-box; }

html { background: #edf3f0; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% -10%, rgba(183, 220, 118, 0.22), transparent 31rem),
    #edf3f0;
}

button, table { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 48px;
}

.topbar {
  min-height: 116px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.brand-lockup, .header-actions, .panel-heading, .section-heading {
  display: flex;
  align-items: center;
}

.brand-lockup { gap: 16px; }

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  padding: 10px;
  background: var(--forest);
  box-shadow: 0 8px 22px rgba(15, 91, 78, 0.23);
}

.brand-mark span {
  width: 6px;
  border-radius: 6px 6px 2px 2px;
  background: var(--lime);
}
.brand-mark span:nth-child(1) { height: 12px; opacity: .65; }
.brand-mark span:nth-child(2) { height: 22px; }
.brand-mark span:nth-child(3) { height: 17px; opacity: .82; }

.eyebrow, .card-kicker {
  margin: 0;
  color: var(--forest-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
}

.topbar h1 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 2vw, 31px);
  line-height: 1.06;
  font-weight: 500;
}

.header-actions { gap: 12px; }

.status-pill, .small-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(255,255,255,.7);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(236,170,76,.15);
}
.status-fresh .status-dot { background: #44a575; box-shadow: 0 0 0 4px rgba(68,165,117,.15); }
.status-stale .status-dot { background: var(--amber); }

.primary-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 17px;
  background: var(--forest);
  color: white;
  font-weight: 750;
  box-shadow: 0 7px 18px rgba(15, 91, 78, .2);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}
.primary-button:hover { background: #0b4c41; transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.button-icon { font-size: 18px; margin-right: 6px; }

.preview-banner {
  margin-bottom: 15px;
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #eccb8e;
  border-radius: 14px;
  background: var(--amber-soft);
  color: #65450f;
}
.preview-banner div { display: flex; align-items: center; gap: 12px; }
.preview-banner p { margin: 0; font-size: 13px; }
.banner-label {
  padding: 5px 7px;
  border-radius: 6px;
  background: #744d0e;
  color: white;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
}

.tabs {
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 0 8px;
  border-bottom: 1px solid #ccd9d4;
}
.tab {
  align-self: stretch;
  padding: 0 17px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}
.tab.active { color: var(--forest); border-bottom-color: var(--forest); }
.tab-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}
.text-button {
  border: 1px solid #cbd8d3;
  border-radius: 7px;
  padding: 5px 8px;
  background: rgba(255,255,255,.65);
  cursor: pointer;
  font-weight: 750;
}

.view { display: none; padding-top: 18px; }
.view.active { display: block; }

.overview-grid {
  display: grid;
  grid-template-columns: minmax(420px, 2fr) repeat(3, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.hero-card, .stat-card, .panel, .metric-panel, .performance-card, .health-card {
  border: 1px solid rgba(210, 223, 218, .92);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  min-height: 160px;
  padding: 21px 22px 17px;
  overflow: hidden;
  background:
    linear-gradient(115deg, rgba(15,91,78,.98), rgba(25,110,92,.94)),
    var(--forest);
  color: white;
}
.hero-card::after {
  content: "";
  position: absolute;
  width: 210px;
  height: 210px;
  right: -65px;
  top: -100px;
  border: 32px solid rgba(183,220,118,.12);
  border-radius: 50%;
}
.hero-card .card-kicker { color: #addfcd; }
.hero-card h2 {
  margin: 7px 0 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
}
.hero-card p:not(.card-kicker) { margin: 0; color: #d3e7e0; font-size: 12px; }
.hero-metric { position: absolute; right: 25px; bottom: 20px; text-align: right; z-index: 1; }
.hero-metric span { display: block; font-size: 31px; line-height: 1; font-weight: 760; }
.hero-metric small { color: #b9d9cf; }

.horizon-selector {
  position: absolute;
  left: 21px;
  bottom: 16px;
  display: flex;
  gap: 5px;
}
.horizon-selector button {
  position: relative;
  min-width: 47px;
  height: 31px;
  border: 1px solid rgba(255,255,255,.23);
  border-radius: 7px;
  background: rgba(255,255,255,.08);
  color: #d6e9e3;
  cursor: pointer;
  font-weight: 750;
  font-size: 12px;
}
.horizon-selector button:hover { background: rgba(255,255,255,.15); }
.horizon-selector button.selected { background: var(--lime); border-color: var(--lime); color: #173b34; }
.horizon-selector button span {
  position: absolute;
  top: -10px;
  right: -4px;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--amber);
  color: #4b330d;
  font-size: 7px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.stat-card {
  min-height: 160px;
  padding: 21px 19px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stat-card strong {
  margin: 11px 0 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 500;
}
.stat-card > span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.stat-card.accent { border-top: 4px solid var(--lime); }

.chart-stack { display: grid; gap: 14px; }
.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(210, 223, 218, .92);
  border-radius: 14px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 8px 26px rgba(22, 54, 48, .06);
}
.timeline-toolbar-copy {
  min-width: 245px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 2px 10px;
}
.timeline-toolbar-copy strong { font-size: 12px; }
.timeline-toolbar-copy small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
}
.timeline-presets {
  display: flex;
  gap: 5px;
  margin-left: auto;
  padding: 4px;
  border-radius: 9px;
  background: var(--soft);
}
.timeline-presets button,
.timeline-zoom-buttons button {
  min-width: 42px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.timeline-presets button:hover,
.timeline-zoom-buttons button:hover { color: var(--forest); background: #edf5f1; }
.timeline-presets button.selected {
  border-color: #c7dcd4;
  background: #fff;
  color: var(--forest);
  box-shadow: 0 2px 7px rgba(17, 69, 59, .08);
}
.timeline-zoom-buttons { display: flex; gap: 5px; }
.timeline-zoom-buttons button {
  border-color: #cfddd8;
  background: #fff;
  color: var(--forest);
}
.timeline-zoom-buttons button:last-child { min-width: 55px; }
.metric-panel { overflow: hidden; }
.metric-header {
  min-height: 67px;
  padding: 15px 19px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #e8efec;
}
.metric-title { display: flex; align-items: center; gap: 12px; }
.metric-icon {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--mint);
  color: var(--forest);
  font-weight: 850;
}
.metric-header h3 { margin: 0; font-size: 16px; }
.metric-header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: #52635f; font-size: 11px; }
.legend-line { width: 17px; height: 3px; border-radius: 4px; }
.legend-line.dashed {
  height: 2px;
  background: repeating-linear-gradient(to right, var(--ink) 0 4px, transparent 4px 7px);
}
.legend-line.imputed {
  height: 2px;
  background: repeating-linear-gradient(to right, var(--amber) 0 2px, transparent 2px 6px);
}
.legend-line.low-confidence {
  height: 2px;
  background: repeating-linear-gradient(
    to right,
    #b75028 0 7px,
    transparent 7px 10px,
    #b75028 10px 12px,
    transparent 12px 15px
  );
}
.legend-anchor {
  width: 9px;
  height: 9px;
  border: 2px solid var(--forest);
  border-radius: 50%;
  background: #fff;
}
.chart-wrap { position: relative; min-height: 270px; padding: 8px 12px 4px; }
.chart-wrap canvas { width: 100%; height: 265px; display: block; }
.chart-wrap canvas.timeline-interactive { cursor: grab; touch-action: none; }
.chart-wrap canvas.timeline-interactive.is-panning { cursor: grabbing; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  min-width: 130px;
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(18,43,40,.94);
  color: white;
  font-size: 11px;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
  transform: translate(12px, -50%);
  z-index: 3;
}
.chart-tooltip strong { display: block; margin-bottom: 3px; }
.chart-empty {
  height: 250px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.panel { padding: 20px; }
.panel-heading { justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-heading h3 { margin: 5px 0 0; font-size: 17px; }
.small-badge { padding: 6px 9px; font-size: 10px; }
.small-badge.shadow { color: #815415; border-color: #e9c27e; background: var(--amber-soft); }

.route-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.route-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--soft);
}
.route-card span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.route-card strong { display: block; margin: 8px 0 4px; font-size: 13px; }
.route-card small { color: var(--muted); font-size: 10px; }
.route-card.shadow { background: var(--amber-soft); border-color: #eccb8e; }

.stream-matrix { display: grid; grid-template-columns: 62px repeat(3, 1fr); gap: 6px; align-items: center; }
.matrix-header { color: var(--muted); font-size: 10px; text-align: center; text-transform: uppercase; }
.matrix-device { font-size: 11px; font-weight: 800; }
.matrix-cell {
  padding: 7px 4px;
  border-radius: 6px;
  text-align: center;
  font-size: 9px;
  font-weight: 800;
  background: #e7f2ed;
  color: var(--forest);
}
.matrix-cell.unsupported { background: #f2f2f0; color: #9a9e9b; }
.matrix-cell.guarded { background: var(--amber-soft); color: #855d1e; }
.matrix-cell.imputed { background: #fff0d2; color: #79500f; }
.matrix-cell.low-confidence {
  background: #fbe1d4;
  color: #8b351a;
  box-shadow: inset 0 0 0 1px #e9a98f;
}

.section-heading {
  justify-content: space-between;
  gap: 24px;
  padding: 22px 4px 20px;
}
.section-heading h2 {
  margin: 7px 0 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 500;
}
.section-heading p:not(.eyebrow) { max-width: 720px; margin: 0; color: var(--muted); }
.legend-inline { display: flex; gap: 14px; color: var(--muted); font-size: 11px; }
.legend-swatch { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 2px; }
.legend-swatch.positive { background: var(--forest-2); }
.legend-swatch.baseline { background: var(--amber); }

.performance-summary, .health-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.performance-card, .health-card { padding: 19px; }
.performance-card strong, .health-card strong {
  display: block;
  margin: 9px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
}
.performance-card span, .health-card span { color: var(--muted); font-size: 11px; }

.table-panel { padding-bottom: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  padding: 10px 12px;
  border-bottom: 1px solid #ccd9d4;
  color: var(--muted);
  text-align: left;
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
}
td { padding: 13px 12px; border-bottom: 1px solid #e8efec; }
tbody tr:last-child td { border-bottom: 0; }
.model-chip, .decision-chip {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--mint);
  color: var(--forest);
  font-size: 10px;
  font-weight: 800;
}
.model-chip.baseline, .decision-chip.fallback { background: var(--amber-soft); color: #7a5318; }
.skill-bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.skill-bar i { display: block; height: 6px; border-radius: 8px; background: var(--forest-2); }
.skill-bar small { color: var(--muted); }

.shadow-note {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 14px;
  padding: 18px 21px;
  border: 1px solid #eccb8e;
  border-radius: 14px;
  background: var(--amber-soft);
}
.shadow-note > span {
  padding: 10px 12px;
  border-radius: 10px;
  background: #6a4815;
  color: white;
  font-weight: 800;
}
.shadow-note strong { display: block; }
.shadow-note p { margin: 4px 0 0; color: #715526; font-size: 12px; }

.health-grid { margin-top: 0; margin-bottom: 14px; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; min-height: 46px; }
.timeline-dot {
  width: 17px; height: 17px; margin-top: 1px; border: 4px solid #d8eee5; border-radius: 50%; background: var(--forest-2); z-index: 1;
}
.timeline-item:not(:last-child)::after {
  content: ""; position: absolute; left: 8px; top: 16px; width: 1px; height: 31px; background: #cfe1da;
}
.timeline-item strong { font-size: 12px; }
.timeline-item span { color: var(--forest-2); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.timeline-item.guarded .timeline-dot { background: var(--amber); border-color: #f8e6c8; }

.lifecycle-callout { display: flex; align-items: center; gap: 15px; padding: 14px; border-radius: 12px; background: var(--soft); }
.lifecycle-icon {
  flex: 0 0 auto; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--forest); color: white; font-weight: 850;
}
.lifecycle-callout strong { font-size: 13px; }
.lifecycle-callout p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.future-trigger {
  margin-top: 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--forest);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
}
.future-trigger i { height: 2px; background: linear-gradient(to right, var(--forest), var(--lime)); }
.future-trigger p { margin: 3px 0 0; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0; }
.future-trigger p:last-child { grid-column: 3; }

.coverage-track { width: 96px; height: 7px; overflow: hidden; border-radius: 9px; background: #e4ebe8; }
.coverage-track i { display: block; height: 100%; background: var(--forest-2); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 12px 15px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #7d332e; }

.refresh-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(239,245,242,.88);
  backdrop-filter: blur(5px);
}
.refresh-overlay[hidden] { display: none; }
.refresh-overlay strong { margin-top: 16px; font-family: Georgia, serif; font-size: 22px; }
.refresh-overlay p { margin: 6px 0; color: var(--muted); }
.loader-ring {
  width: 46px; height: 46px; border: 5px solid #cce2da; border-top-color: var(--forest); border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .overview-grid { grid-template-columns: 1.5fr repeat(3, 1fr); }
  .hero-card { grid-column: 1 / -1; }
  .stat-card { min-height: 125px; }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 18px, 1540px); }
  .topbar { align-items: flex-start; padding: 18px 0; flex-direction: column; }
  .header-actions { width: 100%; justify-content: space-between; }
  .status-pill { overflow: hidden; }
  .preview-banner, .preview-banner div { align-items: flex-start; flex-direction: column; }
  .tabs { overflow-x: auto; }
  .tab { min-width: max-content; }
  .tab-meta { display: none; }
  .overview-grid { grid-template-columns: 1fr; }
  .hero-card { min-height: 195px; }
  .hero-metric { top: 23px; bottom: auto; }
  .horizon-selector { right: 16px; flex-wrap: wrap; }
  .stat-card { min-height: 110px; }
  .detail-grid, .performance-summary, .health-stats { grid-template-columns: 1fr; }
  .route-cards { grid-template-columns: 1fr; }
  .metric-header { align-items: flex-start; flex-direction: column; }
  .timeline-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .timeline-toolbar-copy { min-width: 100%; }
  .timeline-presets { margin-left: 0; }
  .chart-legend { justify-content: flex-start; }
  .chart-wrap { padding-left: 2px; padding-right: 2px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
}
