/* REWIRED EV Planning Tool — Stylesheet
   To re-brand: edit the :root design tokens at the top of this file. */

/* ═══════════════════════════════════════════════════════════════════
   DESIGN TOKENS — override these 10 lines to re-brand for any co-op
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --brand-primary:   #3a9070;   /* teal-green         */
  --brand-accent:    #3a9070;   /* teal-green         */
  --brand-highlight: #6fcfad;   /* light mint         */
  --brand-dark:      #2c3035;   /* charcoal           */
  --brand-hero-from: #2c3035;
  --brand-hero-to:   #363c42;

  /* ── Derived (don't usually need changing) ── */
  --accent:        var(--brand-accent);
  --accent-light:  color-mix(in srgb, var(--brand-accent) 10%, transparent);
  --accent-border: color-mix(in srgb, var(--brand-accent) 30%, transparent);
  --heading:       #1e2428;
  --text:          #444c56;
  --muted:         #6b7280;
  --card-bg:       #ffffff;
  --card-border:   #e4e8ec;
  --card-shadow:   0 1px 4px rgba(0,0,0,0.06), 0 4px 14px rgba(0,0,0,0.04);
  --rule:          #e4e8ec;
  --page-bg:       #f5f6f7;
  --nav-bg:        #ffffff;
  --hero-bg:       linear-gradient(160deg, var(--brand-hero-from) 0%, #363c42 55%, #2f3a38 100%);
  --footer-bg:     #2c3035;

  /* Chart palette — matches ECharts color array */
  --chart-1: #40916c;
  --chart-2: #f4a261;
  --chart-3: #e76f51;
  --chart-4: #74c69d;
  --chart-5: #264653;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────────── */
.syne { font-family: 'Syne', sans-serif; }
.mono { font-family: 'DM Mono', monospace; }

/* ── Layout utils ───────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 48px; }
.rule { height: 1px; background: var(--rule); margin: 40px 0; }
.label {
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.section-h {
  font-weight: 700;
  font-size: 24px;
  color: var(--heading);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

/* ── Screens ────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ═══════════════════════════════════════════════════════════════════
   NAV
   ═══════════════════════════════════════════════════════════════════ */
.app-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 48px;
  position: sticky;
  top: 0;
  z-index: 1100;   /* above Leaflet's internal panes (which go up to ~1000) */
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.app-nav__logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: var(--heading);
  letter-spacing: 0.04em;
  margin-right: 32px;
  flex-shrink: 0;
}
.app-nav__logo span { color: var(--accent); }
.app-nav__tabs { display: flex; height: 100%; gap: 0; }
.app-nav__tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  height: 100%;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
}
.app-nav__tab:hover { color: var(--heading); }
.app-nav__tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.app-nav__step {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  background: var(--page-bg);
  border: 1px solid var(--card-border);
  border-radius: 3px;
  padding: 1px 5px;
  color: #9ca3af;
  line-height: 1.5;
}
.app-nav__tab.active .app-nav__step {
  background: var(--accent-light);
  border-color: var(--accent-border);
  color: var(--accent);
}
.app-nav__spacer { flex: 1; }
.app-nav__badge {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: #9ca3af;
  letter-spacing: 0.03em;
}

/* ═══════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 5px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }
.btn--primary {
  background: var(--accent);
  color: #fff;
  padding: 10px 22px;
  font-size: 14px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn--ghost {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.22);
  padding: 9px 18px;
  font-size: 14px;
}
.btn--ghost:hover { color: #fff; border-color: rgba(255,255,255,0.5); }
.btn--outline {
  background: var(--card-bg);
  color: var(--heading);
  border: 1px solid var(--card-border);
  padding: 8px 16px;
  font-size: 13px;
  box-shadow: var(--card-shadow);
}
.btn--outline:hover { border-color: var(--accent-border); color: var(--accent); }
.btn--run {
  background: var(--accent);
  color: #fff;
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ═══════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.card--accent-top { border-top: 3px solid var(--accent); }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--card-border);
  background: #f9fbfa;
  gap: 12px;
  flex-wrap: wrap;
}
.card__title {
  font-weight: 700;
  font-size: 13px;
  color: var(--heading);
  letter-spacing: 0.01em;
}
.card__tag {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  background: var(--page-bg);
  border: 1px solid var(--card-border);
  border-radius: 3px;
  padding: 2px 7px;
}
.card__body { padding: 20px; }

/* ═══════════════════════════════════════════════════════════════════
   SCREEN 1 — OVERVIEW
   ═══════════════════════════════════════════════════════════════════ */
.hero {
  background: var(--hero-bg);
  padding: 64px 48px 56px;
  position: relative;
  overflow: hidden;
}
/* subtle grid texture */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}
.hero__inner {
  position: relative;
  max-width: 700px;
}
.hero__eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand-highlight);
  margin-bottom: 18px;
  opacity: 0.9;
}
.hero__title {
  font-weight: 800;
  font-size: 38px;
  color: #ffffff;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}
.hero__title em {
  font-style: normal;
  color: var(--brand-highlight);
}
.hero__sub {
  font-size: 16px;
  color: rgba(255,255,255,0.72);
  line-height: 1.75;
  margin-bottom: 32px;
  max-width: 560px;
}
.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero__rule {
  width: 36px; height: 3px;
  background: var(--brand-highlight);
  border-radius: 2px;
  margin-bottom: 20px;
  opacity: 0.7;
}

/* Capability strip */
.cap-strip {
  background: color-mix(in srgb, var(--brand-dark) 95%, transparent);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 10px 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
}
.cap-strip__item {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cap-strip__dot { color: var(--brand-highlight); margin: 0 14px; opacity: 0.45; }

/* Body */
.body { padding: 56px 0 72px; }

/* About grid */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px 72px;
  align-items: start;
}
.body-text p {
  font-size: 15px;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 16px;
}
.body-text strong { color: var(--heading); font-weight: 600; }

/* Objective list */
.objective {
  display: flex;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}
.objective:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.objective__num {
  font-weight: 800;
  font-size: 22px;
  color: var(--accent);
  width: 32px;
  flex-shrink: 0;
  opacity: 0.35;
  line-height: 1.2;
}
.objective__title {
  font-weight: 700;
  font-size: 14px;
  color: var(--heading);
  margin-bottom: 5px;
}
.objective__body { font-size: 13.5px; color: var(--text); line-height: 1.7; }

/* Cap cards */
.cap-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cap-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  padding: 22px 20px;
  box-shadow: var(--card-shadow);
}
.cap-card__title {
  font-weight: 700;
  font-size: 14px;
  color: var(--heading);
  margin-bottom: 8px;
}
.cap-card__body { font-size: 13px; color: var(--text); line-height: 1.7; }

/* Steps */
.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 24px; }
.step-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  padding: 24px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  box-shadow: var(--card-shadow);
}
.step-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.10); transform: translateY(-2px); }
.step-card__num {
  font-weight: 800;
  font-size: 40px;
  color: var(--accent);
  opacity: 0.18;
  line-height: 1;
  margin-bottom: 8px;
}
.step-card__tag {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.step-card__title {
  font-weight: 700;
  font-size: 15px;
  color: var(--heading);
  margin-bottom: 10px;
}
.step-card__body { font-size: 13.5px; color: var(--text); line-height: 1.7; }
.step-card__action {
  display: inline-block;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

/* Privacy block */
.privacy {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 28px 32px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0 48px;
  align-items: start;
}
.privacy__heading {
  font-weight: 700;
  font-size: 20px;
  color: var(--heading);
  margin-top: 8px;
}
.privacy__items { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.privacy__item { margin-bottom: 18px; }
.privacy__item:last-child, .privacy__item:nth-last-child(2) { margin-bottom: 0; }
.privacy__item-title { font-weight: 600; font-size: 13.5px; color: var(--heading); margin-bottom: 4px; }
.privacy__item-body { font-size: 13px; color: var(--text); line-height: 1.65; }

/* Footer */
.footer { background: var(--footer-bg); padding: 36px 48px; }
.footer__partners {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.footer__partner-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  margin-right: 4px;
}
.footer__partner-badge {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 3px;
  padding: 5px 12px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.38);
  text-transform: uppercase;
}
.footer__legal {
  font-size: 11.5px;
  color: rgba(255,255,255,0.38);
  text-align: center;
  line-height: 1.8;
  max-width: 960px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════════════════
   SCREEN 2 — UPLOAD
   ═══════════════════════════════════════════════════════════════════ */
.upload-hero {
  background: var(--hero-bg);
  padding: 40px 48px 36px;
  position: relative;
  overflow: hidden;
}
.upload-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}
.upload-hero__title {
  font-weight: 800;
  font-size: 26px;
  color: #fff;
  margin-bottom: 8px;
  position: relative;
}
.upload-hero__sub { font-size: 14px; color: rgba(255,255,255,0.68); max-width: 640px; line-height: 1.65; position: relative; }

.upload-body { padding: 44px 0 64px; }

/* Data section */
.data-section__title {
  font-weight: 700;
  font-size: 20px;
  color: var(--heading);
  margin-bottom: 6px;
}
.data-section__purpose-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.75;
  max-width: 760px;
  margin-bottom: 14px;
}
.data-section__def-label {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.field-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.field-badge {
  font-family: 'DM Mono', monospace;
  font-size: 11.5px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 3px 10px;
  color: var(--heading);
}
.field-badge--req { border-left: 3px solid var(--accent); }
.field-badge--opt { border-left: 3px solid #d1d5db; color: var(--muted); }
.data-section__note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--card-border);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-border);
  background: var(--accent-light);
}
.drop-zone.has-file {
  border-style: solid;
  border-color: var(--accent-border);
  background: var(--accent-light);
}
.drop-zone__icon { font-size: 30px; margin-bottom: 10px; opacity: 0.5; }
.drop-zone.has-file .drop-zone__icon { opacity: 1; }
.drop-zone__label { font-weight: 600; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.drop-zone.has-file .drop-zone__label { color: var(--accent); }
.drop-zone__sub { font-size: 12px; color: #9ca3af; }

/* Validation */
.val-result { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; min-height: 22px; }
.val-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.val-dot--idle   { background: #d1d5db; }
.val-dot--ok     { background: var(--accent); }
.val-dot--warn   { background: #f59e0b; }
.val-dot--error  { background: #ef4444; }
.val-text--idle  { color: var(--muted); }
.val-text--ok    { color: var(--accent); font-weight: 500; }
.val-text--warn  { color: #d97706; font-weight: 500; }
.val-text--error { color: #dc2626; font-weight: 500; }

/* Preview panel */
.preview-panel { margin-top: 12px; border: 1px solid var(--card-border); border-radius: 8px; background: var(--card-bg); overflow: hidden; box-shadow: var(--card-shadow); }
.preview-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #f9fbfa; border-bottom: 1px solid var(--card-border);
  cursor: pointer; user-select: none;
}
.preview-panel__title { font-weight: 600; font-size: 13px; color: var(--heading); }
.preview-panel__meta { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.preview-panel__badge { background: var(--accent-light); border: 1px solid var(--accent-border); color: var(--accent); border-radius: 3px; padding: 2px 7px; font-size: 11px; }
.preview-panel__chevron { font-size: 10px; color: var(--muted); transition: transform 0.2s; }
.preview-panel__chevron.open { transform: rotate(180deg); }
.preview-panel__body { overflow-x: auto; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; font-family: 'DM Mono', monospace; font-size: 12px; }
.data-table th {
  padding: 8px 14px; text-align: left; font-size: 10px; letter-spacing: 0.10em;
  text-transform: uppercase; color: var(--accent); background: #f9fbfa;
  border-bottom: 1px solid var(--card-border); white-space: nowrap;
}
.data-table td { padding: 7px 14px; color: var(--text); border-bottom: 1px solid #f3f4f6; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:nth-child(even) td { background: #fafcfb; }

/* Section actions */
.section-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }

/* Run block */
.run-block {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  padding: 26px 30px;
}
.run-block__title { font-weight: 700; font-size: 18px; color: var(--heading); margin-bottom: 4px; }
.run-block__sub { font-size: 13.5px; color: var(--muted); margin-bottom: 22px; }
.run-block__row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.run-block__field { display: flex; flex-direction: column; gap: 5px; }
.run-block__label { font-family: 'DM Mono', monospace; font-size: 10px; font-weight: 500; letter-spacing: 0.10em; text-transform: uppercase; color: var(--muted); }
.scenario-select {
  background: #f9fbfa;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  color: var(--heading);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 36px 9px 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  min-width: 230px;
  transition: border-color 0.15s;
}
.scenario-select:focus { outline: none; border-color: var(--accent-border); }
.run-block__spacer { flex: 1; }
.run-checklist { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--rule); }
.run-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.run-check.done { color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════
   LOADING OVERLAY
   ═══════════════════════════════════════════════════════════════════ */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(30,36,40,0.72);
  backdrop-filter: blur(6px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.loading-overlay.visible { display: flex; }
.loading-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  padding: 36px 40px;
  min-width: 380px; max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28);
}
.loading-card__title {
  font-weight: 700; font-size: 18px; color: var(--heading); margin-bottom: 24px;
}
.loading-steps { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.loading-step {
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px; color: var(--muted); transition: color 0.2s;
}
.loading-step.active { color: var(--heading); font-weight: 500; }
.loading-step.done   { color: var(--accent); }
.loading-step__dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--card-border); flex-shrink: 0; transition: all 0.2s;
}
.loading-step.active .loading-step__dot {
  border-color: var(--accent); background: transparent;
  animation: pulse-dot 1s ease-in-out infinite;
}
.loading-step.done .loading-step__dot { border-color: var(--accent); background: var(--accent); }
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.4); opacity: 0.7; }
}
.loading-elapsed { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); text-align: right; }


/* ═══════════════════════════════════════════════════════════════════
   SCREEN 3 — ANALYSIS
   ═══════════════════════════════════════════════════════════════════ */
.analysis-body { padding: 44px 0 80px; }
.analysis-body .container { max-width: 1600px; padding: 0 32px; }
.analysis-body p { font-size: 14.5px; line-height: 1.75; }

/* Scenario pill */
.scenario-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
}

/* Chart containers */
.chart-wrap { width: 100%; height: 300px; }
.chart-wrap--tall { height: 360px; }
.chart-wrap--sm { height: 220px; }

/* Hierarchy table */
.results-table { width: 100%; border-collapse: collapse; font-family: 'DM Mono', monospace; font-size: 13px; }
.results-table th {
  padding: 10px 16px; text-align: left; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); background: #f9fbfa;
  border-bottom: 1px solid var(--card-border); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.results-table td { padding: 10px 14px; border-bottom: 1px solid #f3f6f4; color: var(--text); white-space: nowrap; font-size: 13px; }
.results-table tr:last-child td { border-bottom: none; }
.row-parent td { background: #f4f8f5; font-weight: 600; color: var(--heading); cursor: pointer; font-size: 13.5px; }
.row-parent td:first-child::before { content: '▶\00a0'; font-size: 9px; color: var(--accent); opacity: 0.65; }
.row-parent.open td:first-child::before { content: '▼\00a0'; }
.row-child td { padding-left: 28px; font-size: 12.5px; }
.row-child td:first-child { color: var(--muted); font-style: italic; }

/* Capacity badges */
.badge {
  display: inline-block;
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 2px 8px;
  font-weight: 500;
}
.badge--overloaded { background: rgba(239,68,68,0.10); color: #dc2626; border: 1px solid rgba(239,68,68,0.22); }
.badge--truck      { background: rgba(245,158,11,0.10); color: #d97706; border: 1px solid rgba(245,158,11,0.22); }
.badge--car        { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent-border); }

/* Horizontal bar chart (top circuits) */
.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.hbar-label { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); width: 160px; text-align: right; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { flex: 1; background: #edf2ef; border-radius: 4px; height: 20px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; background: var(--accent); opacity: 0.72; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.hbar-val { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--accent); width: 28px; flex-shrink: 0; font-weight: 500; }

/* Map container */
.map-container { position: relative; }
.map-el { width: 100%; height: 380px; }

/* Map timeline controls — bottom bar */
.map-timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #f9fbfa;
  border-top: 1px solid var(--card-border);
}
.map-play-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 1px 4px color-mix(in srgb, var(--accent) 40%, transparent);
}
.map-play-btn:hover { opacity: 0.85; transform: scale(1.06); }
.map-year-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--heading);
  min-width: 40px;
  text-align: center;
  flex-shrink: 0;
}
.map-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--pct, 0%), #dde5e0 var(--pct, 0%), #dde5e0 100%);
  outline: none;
  cursor: pointer;
}
.map-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.20);
  cursor: pointer;
}
.map-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.20);
  cursor: pointer;
}
.map-year-range {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}
.map-legend {
  position: absolute;
  bottom: 32px;
  right: 12px;
  z-index: 400;
  background: rgba(255,255,255,0.93);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  backdrop-filter: blur(4px);
}
.map-legend__title {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
.map-legend__item { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text); margin-bottom: 5px; }
.map-legend__item:last-child { margin-bottom: 0; }
.map-legend__dot { border-radius: 50%; flex-shrink: 0; }

/* Hierarchy table — sortable headers */
.results-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.12s;
}
.results-table th.sortable:hover { color: var(--heading); }
.results-table th.sort-asc::after  { content: ' ↑'; opacity: 0.65; }
.results-table th.sort-desc::after { content: ' ↓'; opacity: 0.65; }

/* Sparkline cell */
.spark-cell { padding-right: 4px !important; }
svg.spark { display: block; overflow: visible; }

/* ═══════════════════════════════════════════════════════════════════
   SCREEN 4 — METHODOLOGY (scoped to avoid collisions)
   ═══════════════════════════════════════════════════════════════════ */
.m-hero {
  background: linear-gradient(160deg, #2c3035 0%, #363c42 50%, #2f3a38 100%);
  padding: 56px 48px 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.m-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 80% at 50% 110%, rgba(58,144,112,0.16) 0%, transparent 70%);
  pointer-events: none;
}
.m-hero__tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(58,144,112,0.22);
  border: 1px solid rgba(58,144,112,0.30);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #6fcfad;
  margin-bottom: 22px;
  position: relative;
}
.m-hero__tag-dot { width: 5px; height: 5px; border-radius: 50%; background: #6fcfad; }
.m-hero__title {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 700;
  color: #fff;
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin-bottom: 18px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}
.m-hero__title em { font-style: normal; color: #6fcfad; }
.m-hero__sub {
  font-size: 15px;
  color: rgba(255,255,255,0.62);
  line-height: 1.75;
  max-width: 540px;
  margin: 0 auto 36px;
  position: relative;
}
.m-hero__stats {
  display: flex;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
  max-width: 640px;
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  position: relative;
}
.m-hero__stat {
  flex: 1;
  min-width: 140px;
  padding: 18px 20px;
  border-right: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}
.m-hero__stat:last-child { border-right: none; }
.m-hero__stat-val {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  margin-bottom: 5px;
  letter-spacing: -0.02em;
}
.m-hero__stat-val span { color: #6fcfad; }
.m-hero__stat-label {
  font-size: 10px;
  color: rgba(255,255,255,0.48);
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: uppercase;
  font-weight: 500;
}
/* Page wrapper */
.m-page { max-width: 900px; margin: 0 auto; padding: 0 48px; }

/* Section */
.m-section { padding: 52px 0 0; }
.m-section:last-of-type { padding-bottom: 72px; }
.m-eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.m-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.m-section-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.m-title {
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 700;
  color: var(--heading);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}
.m-body {
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.8;
  max-width: 720px;
  margin-bottom: 24px;
}
.m-body strong { color: var(--heading); font-weight: 600; }
.m-divider { height: 1px; background: var(--rule); margin: 52px 0 0; }

/* Answer card */
.m-answer-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  padding: 24px 26px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
}

/* Scenario grid */
.m-scenario-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.m-scenario-card {
  background: var(--page-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px 14px;
}
.m-scenario-card--ref {
  background: var(--accent-light);
  border-color: var(--accent-border);
}
.m-scenario-badge {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-radius: 10px;
  padding: 2px 8px;
  margin-bottom: 9px;
  background: rgba(0,0,0,0.06);
  color: var(--muted);
}
.m-scenario-card--ref .m-scenario-badge { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent-border); }
.m-scenario-name { font-weight: 700; font-size: 13.5px; color: var(--heading); margin-bottom: 6px; }
.m-scenario-desc { font-size: 12.5px; color: var(--text); line-height: 1.6; }

/* Reality check dark card */
.m-reality {
  background: linear-gradient(135deg, #2c3035 0%, #2f3a38 100%);
  border-radius: 10px;
  padding: 32px 32px;
  color: #fff;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.m-reality::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(58,144,112,0.14) 0%, transparent 70%);
  pointer-events: none;
}
.m-reality__label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #6fcfad;
  margin-bottom: 10px;
}
.m-reality__title { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 20px; line-height: 1.25; letter-spacing: -0.015em; }
.m-reality__math {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 0;
  background: rgba(255,255,255,0.06);
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 18px;
}
.m-math-cell { padding: 14px 12px; border-right: 1px solid rgba(255,255,255,0.08); text-align: center; }
.m-math-cell:last-child { border-right: none; }
.m-math-cell__op { font-size: 16px; color: rgba(255,255,255,0.28); font-weight: 300; margin-bottom: 2px; }
.m-math-cell__val { font-size: 18px; font-weight: 700; color: #fff; line-height: 1; margin-bottom: 4px; letter-spacing: -0.02em; }
.m-math-cell__val.m-accent { color: #6fcfad; }
.m-math-cell__label { font-size: 9.5px; color: rgba(255,255,255,0.42); line-height: 1.4; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.m-reality__conclusion { font-size: 13.5px; color: rgba(255,255,255,0.72); line-height: 1.7; border-top: 1px solid rgba(255,255,255,0.09); padding-top: 14px; }
.m-reality__conclusion strong { color: #6fcfad; }

/* SVG chart wrap */
.m-chart-wrap {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 24px 24px 18px;
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
}
.m-chart-title { font-weight: 700; font-size: 13px; color: var(--heading); margin-bottom: 4px; }
.m-chart-sub { font-size: 12px; color: var(--muted); margin-bottom: 18px; line-height: 1.5; }
.m-chart-area { position: relative; height: 150px; margin-bottom: 8px; }
.m-chart-svg { width: 100%; height: 100%; }

/* Authority cards */
.m-authority-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.m-authority-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 18px 18px;
  box-shadow: var(--card-shadow);
}
.m-authority-logo {
  font-family: 'DM Mono', monospace;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--card-border);
}
.m-authority-stat { font-size: 22px; font-weight: 700; color: var(--heading); letter-spacing: -0.02em; line-height: 1; margin-bottom: 4px; }
.m-authority-stat span { color: var(--accent); }
.m-authority-desc { font-size: 12.5px; color: var(--text); line-height: 1.6; }

/* Quote block */
.m-quote {
  background: #2c3035;
  border-radius: 8px;
  padding: 26px 28px;
  margin-bottom: 20px;
  position: relative;
}
.m-quote__mark { font-size: 56px; line-height: 1; color: var(--accent); opacity: 0.3; font-family: Georgia, serif; position: absolute; top: 10px; left: 20px; }
.m-quote__text { font-size: 14.5px; color: rgba(255,255,255,0.80); line-height: 1.75; font-style: italic; padding-left: 30px; margin-bottom: 12px; }
.m-quote__text strong { font-style: normal; color: #6fcfad; }
.m-quote__source {
  padding-left: 30px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.38);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.m-quote__source::before { content: ''; display: block; width: 20px; height: 1.5px; background: var(--accent); opacity: 0.5; }

/* Pipeline */
.m-pipeline { display: flex; flex-direction: column; gap: 0; }
.m-pipeline-step {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 18px 22px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-bottom: none;
}
.m-pipeline-step:first-child { border-radius: 8px 8px 0 0; }
.m-pipeline-step:last-child { border-bottom: 1px solid var(--card-border); border-radius: 0 0 8px 8px; }
.m-pipeline-step__num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent-light);
  border: 1.5px solid var(--accent-border);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.m-pipeline-step__title { font-weight: 700; font-size: 13.5px; color: var(--heading); margin-bottom: 3px; }
.m-pipeline-step__body { font-size: 13px; color: var(--text); line-height: 1.65; }
.m-pipeline-step__body strong { color: var(--heading); }
.m-pipeline-connector { width: 1.5px; height: 10px; background: var(--rule); margin-left: 33px; }

/* Accuracy cards */
.m-accuracy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-accuracy-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 18px 18px; box-shadow: var(--card-shadow); }
.m-accuracy-card__metric { font-family: 'DM Mono', monospace; font-size: 10.5px; font-weight: 500; letter-spacing: 0.10em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.m-accuracy-card__val { font-size: 26px; font-weight: 700; color: var(--heading); letter-spacing: -0.025em; line-height: 1; margin-bottom: 4px; }
.m-accuracy-card__val span { color: var(--accent); font-size: 15px; }
.m-accuracy-card__compare { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
.m-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.m-bar-label { font-family: 'DM Mono', monospace; font-size: 9.5px; font-weight: 600; color: var(--muted); width: 80px; flex-shrink: 0; text-align: right; text-transform: uppercase; letter-spacing: 0.04em; }
.m-bar-track { flex: 1; height: 7px; background: var(--page-bg); border-radius: 3px; overflow: hidden; }
.m-bar-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.m-bar-fill--dim { background: var(--card-border); }
.m-bar-val { font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 600; color: var(--heading); width: 34px; }

/* Takeaway strip */
.m-takeaway {
  background: linear-gradient(160deg, #2c3035 0%, #2f3a38 100%);
  border-radius: 10px;
  padding: 32px 32px;
  margin-top: 52px;
}
.m-takeaway__label { font-family: 'DM Mono', monospace; font-size: 10px; font-weight: 500; letter-spacing: 0.13em; text-transform: uppercase; color: #6fcfad; margin-bottom: 12px; }
.m-takeaway__title { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 22px; letter-spacing: -0.015em; line-height: 1.25; }
.m-takeaway-list { display: flex; flex-direction: column; gap: 11px; }
.m-takeaway-item { display: flex; gap: 13px; align-items: flex-start; }
.m-takeaway-check {
  flex-shrink: 0;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.m-takeaway-text { font-size: 13.5px; color: rgba(255,255,255,0.76); line-height: 1.6; }
.m-takeaway-text strong { color: #fff; }

/* Footer note */
.m-footer-note { text-align: center; padding: 28px 48px 40px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--rule); margin-top: 52px; line-height: 1.7; }

/* Two-col layout helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-2--tall { align-items: start; }
.grid-2--55 { grid-template-columns: minmax(480px, 55fr) minmax(360px, 45fr); }
.grid-2--65 { grid-template-columns: 65fr 35fr; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.stack { display: flex; flex-direction: column; gap: 20px; align-self: stretch; }

/* Quality warning is rendered as a plain text footnote via inline styles */
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  color: #dc2626;
  border-radius: 6px;
  padding: 14px 18px;
  font-size: 13.5px;
  margin-top: 12px;
  display: none;
}
.error-banner.visible { display: block; }

/* Upload tab nudge — draws attention when user tries Analysis without results */
@keyframes tab-nudge {
  0%,100% { background: transparent; }
  25%,75%  { background: rgba(58,144,112,0.12); border-radius: 4px; }
}
.app-nav__tab--nudge {
  animation: tab-nudge 0.45s ease 0s 4;
  color: var(--accent) !important;
}

/* Contain Leaflet's internal z-indexes (up to ~1000) inside the map card
   so the map can never render above the sticky nav */
.map-container, #tx-map {
  position: relative;
  z-index: 0;
  isolation: isolate;
}
