/* HaulLens Phase 6 frontend prototype -- styles
   Tokens transcribed directly from docs/design/DESIGN_SYSTEM.md.
   Dark theme only in this prototype (design system's default working
   theme); light theme tokens exist in the source doc but are not wired
   up here -- flagged in README.md as a known scope limit for this pass.

   ACCENT COLOR NOTE: docs/design/DESIGN_SYSTEM.md's own --hl-accent
   token was blue, chosen before the approved gold-accented visual
   reference existed, and self-contradicted that same document's "no
   consumer-SaaS blues" line (flagged, not silently fixed, during Phase 4
   integration). This prototype's owner instructions explicitly specify
   "restrained mining-gold primary accent" and explicitly list "bright
   consumer blue as the primary accent" under Avoid -- so this file uses
   gold for --hl-accent, resolving that open item in practice. See
   README.md for the corresponding doc-update recommendation. */

:root {
  /* ---- Surfaces (dark, the design system's default working theme) ---- */
  --hl-surface-0: #12151A;
  --hl-surface-1: #1A1E24;
  --hl-surface-2: #232830;
  --hl-surface-3: #2A303A;
  --hl-border: #2E343D;
  --hl-border-strong: #454C57;
  --hl-text-primary: #E9EBEE;
  --hl-text-secondary: #9BA3AD;
  --hl-text-tertiary: #6B7280;

  /* ---- Accent: restrained mining gold (see note above) ---- */
  --hl-accent: #D6A419;
  --hl-accent-strong: #E8BC3D;
  --hl-accent-ink: #2A1F03; /* text-on-accent for filled gold controls */
  --hl-focus-ring: #E8BC3D;

  /* ---- State language (DESIGN_SYSTEM.md sec 1-2, dark values) ---- */
  --hl-state-verified: #3DDC91;
  --hl-state-pass: #3DDC91;
  --hl-state-reconstructed: #E4B441;
  --hl-state-inferred: #F0885A;
  --hl-state-hold: #B79CFF;
  --hl-state-fail: #F0776E;
  --hl-state-not-impl: #9AA4B2;
  --hl-state-pending: #8FB4E8;
  --hl-state-unresolved: #C98D89;
  --hl-state-primary: #5FCBD6;

  /* ---- Typography ---- */
  --hl-font-ui: "Inter", "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  --hl-font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  /* ---- Spacing (8px base, DESIGN_SYSTEM.md sec 4) ---- */
  --hl-space-1: 4px;
  --hl-space-2: 8px;
  --hl-space-3: 12px;
  --hl-space-4: 16px;
  --hl-space-5: 24px;
  --hl-space-6: 32px;
  --hl-space-7: 48px;
  --hl-space-8: 64px;

  /* ---- Radii / elevation / motion ---- */
  --hl-radius-control: 4px;
  --hl-radius-panel: 6px;
  --hl-radius-chip: 9px;
  --hl-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --hl-elevation-2: 0 4px 16px rgba(0, 0, 0, 0.5);
  --hl-motion-fast: 120ms ease-out;
  --hl-motion-base: 180ms ease-out;

  /* ---- Cartographic palette (DESIGN_SYSTEM.md sec 2.4) ---- */
  --hl-terrain-1: #3a3630;
  --hl-terrain-2: #4d473c;
  --hl-terrain-3: #5c5748;
  --hl-terrain-4: #6b6754;
  --hl-terrain-5: #7c7860;
  --hl-terrain-hillshade: rgba(0, 0, 0, 0.35);
  --hl-route-baseline: #9BA3AD;
  --hl-route-candidate-a: var(--hl-accent);
  --hl-route-candidate-b: var(--hl-state-primary);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--hl-surface-0);
  color: var(--hl-text-primary);
  font-family: var(--hl-font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-width: 320px;
  overflow-x: hidden;
}

.mono { font-family: var(--hl-font-mono); font-variant-numeric: tabular-nums; }

a { color: inherit; }

/* ============================= Header ============================= */

.hl-header {
  position: relative;
  height: 128px;
  border-bottom: 1px solid var(--hl-border);
  background: var(--hl-surface-1);
  overflow: hidden;
}

.hl-header__bg {
  position: absolute;
  inset: 0;
  background-image: url("assets/haul-truck-hero.png");
  background-size: cover;
  background-position: 68% 40%;
  opacity: 0.4;
  filter: grayscale(30%) contrast(1.08) brightness(0.88);
}

.hl-header__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    var(--hl-surface-1) 0%,
    var(--hl-surface-1) 30%,
    rgba(18, 21, 26, 0.82) 50%,
    rgba(18, 21, 26, 0.55) 70%,
    rgba(18, 21, 26, 0.7) 100%
  );
}

/* A thin gold hairline grounds the hero band as a deliberate, engineered
   edge (CAD-influenced restraint) rather than a decorative photo strip. */
.hl-header { border-bottom: 1px solid var(--hl-border); }
.hl-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--hl-accent) 0%, rgba(214, 164, 25, 0) 60%);
  opacity: 0.55;
}

.hl-header__content {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--hl-space-6);
}

@media (max-width: 1100px) {
  .hl-header__content { padding: 0 var(--hl-space-4); }
  .hl-brand__text p { display: none; }
}

.hl-brand { display: flex; align-items: center; gap: var(--hl-space-3); }

.hl-brand__mark {
  width: 34px;
  height: 34px;
  color: var(--hl-accent);
  flex: none;
}

.hl-brand__text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hl-brand__text p {
  margin: 2px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hl-text-secondary);
}

.hl-header__nav {
  display: flex;
  align-items: center;
  gap: var(--hl-space-5);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hl-text-tertiary);
}

.hl-header__nav span.is-active { color: var(--hl-accent); font-weight: 600; }

/* The workflow nav is presentation-only in this prototype (see the
   aria-label on the element) -- below laptop width there isn't room to
   show all 8 stage labels without wrapping into the fixed-height hero
   band, so it steps aside rather than clipping or shrinking to
   illegible text. */
@media (max-width: 1680px) {
  .hl-header__nav { display: none; }
}

.hl-header__meta {
  display: flex;
  align-items: center;
  gap: var(--hl-space-4);
}

.hl-demo-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--hl-radius-chip);
  border: 1px dashed var(--hl-state-inferred);
  color: var(--hl-state-inferred);
  font-family: var(--hl-font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(240, 136, 90, 0.08);
}

.hl-theme-toggle {
  width: 30px;
  height: 30px;
  border-radius: var(--hl-radius-control);
  border: 1px solid var(--hl-border-strong);
  background: var(--hl-surface-2);
  color: var(--hl-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  opacity: 0.6;
}

/* ============================= Study bar ============================= */

.hl-studybar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--hl-space-3);
  padding: var(--hl-space-4) var(--hl-space-6);
  background: var(--hl-surface-1);
  border-bottom: 1px solid var(--hl-border);
}

.hl-studybar__left { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--hl-space-3) var(--hl-space-4); min-width: 0; }

.hl-studybar__left h2 { margin: 0; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }

.hl-studybar__id {
  font-family: var(--hl-font-mono);
  font-size: 12px;
  color: var(--hl-text-secondary);
}

.hl-studybar__right { display: flex; align-items: center; flex-wrap: wrap; gap: var(--hl-space-3); }

.hl-scenario-select {
  display: flex;
  align-items: center;
  gap: var(--hl-space-2);
  padding: 4px 4px 4px 10px;
  border: 1px dashed var(--hl-state-inferred);
  border-radius: var(--hl-radius-panel);
  background: rgba(240, 136, 90, 0.06);
}

.hl-scenario-select__label {
  font-family: var(--hl-font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hl-state-inferred);
  white-space: nowrap;
}

.hl-scenario-select__btns { display: flex; gap: 4px; }

.hl-scenario-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 5px 10px;
  border-radius: var(--hl-radius-control);
  border: 1px solid var(--hl-border-strong);
  background: var(--hl-surface-2);
  color: var(--hl-text-secondary);
  font-family: var(--hl-font-ui);
  cursor: pointer;
  transition: border-color var(--hl-motion-fast), background var(--hl-motion-fast), color var(--hl-motion-fast);
}

.hl-scenario-btn:hover { border-color: var(--hl-text-secondary); color: var(--hl-text-primary); }

.hl-scenario-btn .name {
  font-size: 11px;
  font-weight: 600;
}

.hl-scenario-btn .tag {
  font-family: var(--hl-font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hl-text-tertiary);
}

.hl-scenario-btn.is-active {
  border-color: var(--hl-accent);
  background: rgba(214, 164, 25, 0.1);
  color: var(--hl-text-primary);
}

.hl-scenario-btn.is-active .tag { color: var(--hl-accent); }

.hl-scenario-btn:focus-visible { outline: 3px solid var(--hl-focus-ring); outline-offset: 1px; }

/* ============================= Chips (state language) ============================= */

.hl-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--hl-radius-chip);
  font-family: var(--hl-font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hl-chip__dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }

.hl-chip--solid { color: var(--hl-surface-0); }
.hl-chip--outline { background: transparent; border: 1px solid currentColor; }
.hl-chip--dashed { background: transparent; border: 1px dashed currentColor; }

.hl-chip--pass, .hl-chip--verified { background: var(--hl-state-pass); color: #08160F; }
.hl-chip--pass .hl-chip__dot, .hl-chip--verified .hl-chip__dot { background: #08160F; }
.hl-chip--hold { background: var(--hl-state-hold); color: #17102E; }
.hl-chip--hold .hl-chip__dot { background: #17102E; }
.hl-chip--fail { background: var(--hl-state-fail); color: #250705; }
.hl-chip--fail .hl-chip__dot { background: #250705; }
.hl-chip--reconstructed { color: var(--hl-state-reconstructed); border: 1px solid var(--hl-state-reconstructed); background: rgba(228, 180, 65, 0.08); }
.hl-chip--reconstructed .hl-chip__dot { background: var(--hl-state-reconstructed); }
.hl-chip--inferred { color: var(--hl-state-inferred); border: 1px solid var(--hl-state-inferred); background: rgba(240, 136, 90, 0.08); }
.hl-chip--inferred .hl-chip__dot { background: var(--hl-state-inferred); }
.hl-chip--primary { color: var(--hl-state-primary); border: 1px solid var(--hl-state-primary); background: rgba(95, 203, 214, 0.08); }
.hl-chip--primary .hl-chip__dot { background: var(--hl-state-primary); }
.hl-chip--not-impl { color: var(--hl-state-not-impl); border: 1px dashed var(--hl-state-not-impl); }
.hl-chip--not-impl .hl-chip__dot { background: var(--hl-state-not-impl); }
.hl-chip--pending { color: var(--hl-state-pending); border: 1px dashed var(--hl-state-pending); }
.hl-chip--pending .hl-chip__dot { background: var(--hl-state-pending); }
.hl-chip--unresolved { color: var(--hl-state-unresolved); border: 1px solid var(--hl-state-unresolved); opacity: 0.85; }
.hl-chip--unresolved .hl-chip__dot { background: var(--hl-state-unresolved); }

/* ============================= Recommendation banner ============================= */

.hl-recommend {
  margin: var(--hl-space-5) var(--hl-space-6) 0;
  padding: var(--hl-space-5);
  border-radius: var(--hl-radius-panel);
  border: 1px solid var(--hl-border);
  background: linear-gradient(180deg, var(--hl-surface-1), var(--hl-surface-2));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--hl-space-4) var(--hl-space-6);
}

.hl-recommend__body { min-width: 240px; }

.hl-recommend__stats { flex-wrap: wrap; }

.hl-recommend--optimise { border-left: 3px solid var(--hl-state-pass); }
.hl-recommend--retain { border-left: 3px solid var(--hl-state-hold); }

.hl-recommend__badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  padding: var(--hl-space-3) var(--hl-space-2);
  border-radius: var(--hl-radius-panel);
}

.hl-recommend--optimise .hl-recommend__badge { background: rgba(61, 220, 145, 0.1); }
.hl-recommend--retain .hl-recommend__badge { background: rgba(183, 156, 255, 0.1); }

.hl-recommend__label {
  font-family: var(--hl-font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.hl-recommend--optimise .hl-recommend__label { color: var(--hl-state-pass); }
.hl-recommend--retain .hl-recommend__label { color: var(--hl-state-hold); }
.hl-recommend--optimise .hl-recommend__badge .hl-icon { color: var(--hl-state-pass); }
.hl-recommend--retain .hl-recommend__badge .hl-icon { color: var(--hl-state-hold); }

.hl-recommend__sub {
  margin-top: 2px;
  font-size: 10px;
  color: var(--hl-text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hl-recommend__body { flex: 1; }

.hl-recommend__body h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }

.hl-recommend__body p { margin: 0; font-size: 13px; color: var(--hl-text-secondary); }

.hl-recommend__stats {
  display: flex;
  gap: var(--hl-space-6);
}

.hl-recommend__stat { text-align: right; }

.hl-recommend__stat .v {
  display: block;
  font-family: var(--hl-font-mono);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hl-recommend__stat .l {
  display: block;
  font-size: 10px;
  color: var(--hl-text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.hl-recommend__stat.is-good .v { color: var(--hl-state-pass); }

/* ============================= Layout grid ============================= */

.hl-main {
  padding: var(--hl-space-5) var(--hl-space-6) var(--hl-space-8);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--hl-space-5);
  align-items: start; /* the two columns are independently-sized content
                          flows, not row-matched cells -- see hl-col-main /
                          hl-col-side. Without this the shorter column's
                          panels would stretch to match the taller one and
                          leave dead space, exactly the bug fixed here. */
}

.hl-col-main, .hl-col-side {
  display: flex;
  flex-direction: column;
  gap: var(--hl-space-5);
  min-width: 0;
}

.hl-chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--hl-space-5);
}

/* Below laptop width the fixed 360px sidebar leaves too little room for
   the terrain workspace (the principal engineering view). The sidebar
   -- stats, gates, evidence -- moves below the terrain/charts/table
   stack instead of shrinking either column to illegibility. Covers
   iPad landscape (1366) and iPad portrait (1024). */
@media (max-width: 1400px) {
  .hl-main { grid-template-columns: 1fr; padding: var(--hl-space-4) var(--hl-space-5) var(--hl-space-7); }
}

@media (max-width: 900px) {
  .hl-chart-row { grid-template-columns: 1fr; }
  .hl-main { padding: var(--hl-space-4) var(--hl-space-4) var(--hl-space-6); }
}

.hl-panel {
  background: var(--hl-surface-1);
  border: 1px solid var(--hl-border);
  border-radius: var(--hl-radius-panel);
  overflow: hidden;
}

/* The terrain workspace is the engineer's primary read -- terrain, then
   baseline, then candidates, then the selected alignment -- so it reads
   as a workstation viewport, not one card among equals: a gold header
   rule instead of a plain divider, and a touch of elevation to lift it
   off the surface behind it. */
.hl-panel--primary {
  border-color: var(--hl-border-strong);
  box-shadow: var(--hl-elevation-2);
}

.hl-panel--primary .hl-panel__header {
  border-bottom: 1px solid var(--hl-accent);
}

.hl-panel--primary .hl-panel__title {
  color: var(--hl-text-primary);
  font-size: 13.5px;
  letter-spacing: 0.05em;
}

.hl-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--hl-space-3) var(--hl-space-4);
  border-bottom: 1px solid var(--hl-border);
  background: var(--hl-surface-2);
}

.hl-panel__title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hl-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ============================= Icon system ============================= */
/* Restrained technical/CAD line icons -- see icons.js and
   docs/design/HAULLENS_ICON_STYLE.md. Neutral by default (informational
   chrome); gold only where an icon marks something interactive/selected,
   matching the accent's reserved meaning ("this is where you can act"). */

.hl-icon { display: block; flex: none; color: var(--hl-text-tertiary); }
.hl-icon--accent { color: var(--hl-accent); }
.hl-icon--muted { color: var(--hl-text-tertiary); opacity: 0.75; }

.hl-icon-badge {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border: 1px solid var(--hl-border-strong);
  border-radius: var(--hl-radius-control);
  background: var(--hl-surface-2);
}

.hl-panel--primary .hl-icon-badge {
  border-color: var(--hl-accent);
  background: rgba(214, 164, 25, 0.08);
}

.hl-panel--primary .hl-icon-badge .hl-icon { color: var(--hl-accent); }

.hl-gate-row__icon {
  display: inline-flex;
  align-items: center;
  margin-right: 5px;
  color: var(--hl-text-tertiary);
  vertical-align: -3px;
}

.hl-recommend__badge .hl-icon { margin-bottom: 4px; }

.hl-panel__body { padding: var(--hl-space-4); }

/* ============================= Terrain / map panel ============================= */

.hl-map {
  position: relative;
  height: 460px;
  background: var(--hl-surface-0);
  overflow: hidden;
}

/* Terrain is the primary engineering read at desktop width -- give it
   materially more room instead of matching the height of secondary
   panels (charts, table). */
@media (min-width: 1400px) {
  .hl-map { height: 720px; }
}

#map-svg-container {
  position: absolute;
  inset: 0;
}

.hl-map svg { display: block; width: 100%; height: 100%; }

.hl-map__legend {
  position: absolute;
  right: var(--hl-space-4);
  bottom: var(--hl-space-4);
  background: rgba(18, 21, 26, 0.88);
  border: 1px solid var(--hl-border-strong);
  border-radius: var(--hl-radius-panel);
  padding: var(--hl-space-3);
  font-size: 11px;
  min-width: 172px;
  backdrop-filter: blur(2px);
}

.hl-map__legend h4 {
  margin: 0 0 var(--hl-space-2);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hl-text-tertiary);
}

.hl-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  border-radius: var(--hl-radius-control);
}

.hl-legend-row:hover { background: rgba(255, 255, 255, 0.04); }

.hl-legend-row .swatch {
  width: 20px;
  height: 0;
  border-top-width: 3px;
  border-top-style: solid;
  flex: none;
}

.hl-legend-row.is-selected { outline: 1px solid var(--hl-border-strong); }
.hl-legend-row .name { flex: 1; }
.hl-legend-row .val { font-family: var(--hl-font-mono); color: var(--hl-text-tertiary); font-size: 10px; }

.hl-map__scale {
  position: absolute;
  left: var(--hl-space-4);
  bottom: var(--hl-space-4);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--hl-font-mono);
  font-size: 10px;
  color: var(--hl-text-secondary);
}

.hl-map__scalebar { width: 64px; height: 3px; background: var(--hl-text-secondary); }

.hl-map__crs {
  position: absolute;
  left: var(--hl-space-4);
  top: var(--hl-space-4);
  font-family: var(--hl-font-mono);
  font-size: 10px;
  color: var(--hl-text-tertiary);
  background: rgba(18, 21, 26, 0.7);
  padding: 3px 7px;
  border-radius: var(--hl-radius-control);
}

.hl-map__north {
  position: absolute;
  right: var(--hl-space-4);
  top: var(--hl-space-4);
  color: var(--hl-text-secondary);
}

/* Higher specificity than ".hl-map svg" above, and declared after it, so
   this correctly overrides the full-bleed map-svg sizing rule for the
   small north-arrow icon specifically. */
.hl-map .hl-map__north {
  width: 22px;
  height: 22px;
}

/* ============================= Route selector chips ============================= */

.hl-route-select {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hl-space-2);
  padding: var(--hl-space-3) var(--hl-space-4);
  border-top: 1px solid var(--hl-border);
  background: var(--hl-surface-2);
}

.hl-route-btn {
  flex: 1 1 160px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--hl-space-2) var(--hl-space-3);
  border-radius: var(--hl-radius-control);
  border: 1px solid var(--hl-border-strong);
  background: var(--hl-surface-1);
  color: var(--hl-text-secondary);
  font-family: var(--hl-font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--hl-motion-fast), background var(--hl-motion-fast), color var(--hl-motion-fast);
  text-align: left;
}

.hl-route-btn:hover { border-color: var(--hl-text-secondary); color: var(--hl-text-primary); }

.hl-route-btn.is-active {
  border-color: var(--hl-accent);
  background: rgba(214, 164, 25, 0.1);
  color: var(--hl-text-primary);
}

.hl-route-btn:focus-visible { outline: 3px solid var(--hl-focus-ring); outline-offset: 1px; }

.hl-route-btn .swatch { width: 22px; height: 0; border-top-width: 3px; border-top-style: solid; flex: none; }

.hl-route-btn .name { font-weight: 600; }

.hl-route-btn .tag {
  margin-left: auto;
  font-family: var(--hl-font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hl-text-tertiary);
}

.hl-route-btn.is-active .tag { color: var(--hl-accent); }

/* ============================= Stats sidebar ============================= */

.hl-stats-group { margin-bottom: var(--hl-space-4); }

.hl-stats-group:last-child { margin-bottom: 0; }

.hl-stats-group h4 {
  margin: 0 0 var(--hl-space-3);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hl-text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hl-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--hl-space-3);
}

.hl-stat {
  padding: var(--hl-space-3);
  background: var(--hl-surface-2);
  border-radius: var(--hl-radius-control);
  border: 1px solid var(--hl-border);
}

.hl-stat .v {
  display: block;
  font-family: var(--hl-font-mono);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--hl-text-primary);
}

.hl-stat .v .u { font-size: 11px; font-weight: 500; color: var(--hl-text-tertiary); margin-left: 3px; }

/* The single figure the recommendation is actually decided on (net
   present cost) gets visible emphasis in the stat grid instead of
   reading as one tile among six equal ones. */
.hl-stat--emphasis {
  grid-column: 1 / -1;
  border-color: var(--hl-accent);
  background: rgba(214, 164, 25, 0.07);
}
.hl-stat--emphasis .v { color: var(--hl-accent-strong); font-size: 20px; }

.hl-stat .l {
  display: block;
  font-size: 10px;
  color: var(--hl-text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 3px;
}

.hl-gates-strip { display: flex; flex-direction: column; gap: 6px; }

.hl-gate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}

.hl-gate-row .name { color: var(--hl-text-secondary); font-family: var(--hl-font-mono); }

/* ============================= Charts ============================= */

.hl-chart svg { display: block; width: 100%; height: 200px; }

.hl-chart-legend {
  display: flex;
  gap: var(--hl-space-4);
  padding: 0 var(--hl-space-4) var(--hl-space-3);
  font-size: 11px;
  color: var(--hl-text-secondary);
}

.hl-chart-legend .item { display: flex; align-items: center; gap: 6px; }

.hl-chart-legend .swatch { width: 14px; height: 0; border-top-width: 2px; border-top-style: solid; }

/* ============================= Comparison table ============================= */

.hl-table-scroll { overflow-x: auto; }

.hl-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 12.5px; }

.hl-table th {
  text-align: right;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--hl-text-tertiary);
  font-weight: 500;
  padding: var(--hl-space-2) var(--hl-space-3);
  border-bottom: 1px solid var(--hl-border-strong);
  white-space: nowrap;
}

.hl-table th:first-child, .hl-table td:first-child { text-align: left; }

.hl-table td {
  text-align: right;
  padding: var(--hl-space-2) var(--hl-space-3);
  border-bottom: 1px solid var(--hl-border);
  font-family: var(--hl-font-mono);
  font-variant-numeric: tabular-nums;
}

.hl-table tr.is-selected { background: rgba(214, 164, 25, 0.07); }

.hl-table tr:hover { background: var(--hl-surface-2); cursor: pointer; }

.hl-table .route-name { display: flex; align-items: center; gap: 8px; font-family: var(--hl-font-ui); font-weight: 600; }

.hl-table .swatch { width: 14px; height: 0; border-top-width: 3px; border-top-style: solid; flex: none; }

.hl-table td.delta-good { color: var(--hl-state-pass); }
.hl-table td.delta-bad { color: var(--hl-state-inferred); }

/* ============================= Evidence panel ============================= */

.hl-evidence-list { display: flex; flex-direction: column; }

/* At desktop width the sidebar (stats + evidence) must not run
   materially taller than the enlarged terrain/chart/table column --
   evidence stays fully present, just scrollable within its own panel
   instead of stretching the page. Full list is always visible
   unscrolled on tablet, where both columns already stack. */
@media (min-width: 1400px) {
  .hl-evidence-list {
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--hl-border-strong) var(--hl-surface-1);
  }
  /* A capped-height list needs an unmistakable scroll affordance -- an
     always-visible thumb (Chromium ignores scrollbar-width) in
     addition to the explicit "scroll for full list" hint below it. */
  .hl-evidence-list::-webkit-scrollbar { width: 7px; }
  .hl-evidence-list::-webkit-scrollbar-track { background: transparent; }
  .hl-evidence-list::-webkit-scrollbar-thumb { background: var(--hl-border-strong); border-radius: 4px; }
  .hl-evidence-list::-webkit-scrollbar-thumb:hover { background: var(--hl-text-tertiary); }
}

.hl-evidence-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: var(--hl-space-3);
  padding: var(--hl-space-3) 0;
  border-bottom: 1px solid var(--hl-border);
}

.hl-evidence-row:last-child { border-bottom: none; }

.hl-evidence-scroll-hint { display: none; }

@media (min-width: 1400px) {
  .hl-evidence-scroll-hint {
    display: block;
    margin-top: var(--hl-space-2);
    padding-top: var(--hl-space-2);
    border-top: 1px solid var(--hl-border);
    font-size: 9.5px;
    font-family: var(--hl-font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hl-text-tertiary);
    text-align: center;
  }
}

.hl-evidence-row .eid { font-family: var(--hl-font-mono); font-size: 10px; color: var(--hl-text-tertiary); padding-top: 1px; }

.hl-evidence-row .field { font-size: 12.5px; font-weight: 600; }

.hl-evidence-row .value { font-size: 11.5px; color: var(--hl-text-secondary); margin-top: 2px; }

.hl-evidence-row .source { font-size: 10px; color: var(--hl-text-tertiary); margin-top: 2px; font-style: italic; }

.hl-evidence-row .hl-chip { margin-top: var(--hl-space-2); }

/* ============================= Footer ============================= */

.hl-footer {
  padding: var(--hl-space-5) var(--hl-space-6) var(--hl-space-6);
  color: var(--hl-text-tertiary);
  font-size: 11px;
  border-top: 1px solid var(--hl-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--hl-space-2) var(--hl-space-5);
  justify-content: space-between;
}

.hl-footer a { color: var(--hl-accent); text-decoration: none; }
.hl-footer a:hover { text-decoration: underline; }

/* ============================= Utility ============================= */

.hl-flex-row { display: flex; align-items: center; gap: var(--hl-space-2); }

::selection { background: rgba(214, 164, 25, 0.35); }
