/* Permit2Route — Route Ops design system (shared across all pages)
 * Dark theme neutrals follow VS Code Default Dark Modern. */
:root,
html[data-theme="dark"] {
  /* VS Code Dark Modern: editor #1F1F1F, chrome #181818, input #313131 */
  --bg: #1f1f1f;
  --bg-elevated: #181818;
  --surface: #252526;
  --surface-hover: #2a2d2e;
  --surface-inset: #313131;
  --border: #3c3c3c;
  --border-strong: #4a4a4a;
  --text: #cccccc;
  --text-secondary: #9d9d9d;
  --text-tertiary: #6e6e6e;
  --ai: #e8a317;
  --ai-soft: rgba(232, 163, 23, 0.12);
  --ai-glow: rgba(232, 163, 23, 0.22);
  --accent-b: #3794ff;
  --accent-b-soft: rgba(55, 148, 255, 0.12);
  --accent-b-glow: rgba(55, 148, 255, 0.22);
  --warn: #cca700;
  --danger: #f85149;
  --success: #89d185;
  --header-bg: rgba(24, 24, 24, 0.92);
  --nav-shell: #181818;
  --footer-bg: rgba(24, 24, 24, 0.95);
  --canvas-glow-a: rgba(232, 163, 23, 0.04);
  --canvas-glow-b: rgba(55, 148, 255, 0.03);
  --canvas-glow-c: rgba(31, 31, 31, 0.95);
  --stripe: rgba(255, 255, 255, 0.015);
  --on-accent: #1f1f1f;
  --overlay-scrim: rgba(24, 24, 24, 0.86);
  --panel-head-bg: #2b2b2b;
  --pill-bg: #2b2b2b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #eef2f6;
  --bg-elevated: #f7f9fc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --surface-inset: #e8eef5;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --ai: #b45309;
  --ai-soft: rgba(180, 83, 9, 0.1);
  --ai-glow: rgba(180, 83, 9, 0.22);
  --accent-b: #0e7490;
  --accent-b-soft: rgba(14, 116, 144, 0.1);
  --accent-b-glow: rgba(14, 116, 144, 0.22);
  --warn: #b45309;
  --danger: #dc2626;
  --success: #059669;
  --header-bg: rgba(247, 249, 252, 0.9);
  --nav-shell: rgba(255, 255, 255, 0.95);
  --footer-bg: rgba(241, 245, 249, 0.95);
  --canvas-glow-a: rgba(180, 83, 9, 0.08);
  --canvas-glow-b: rgba(14, 116, 144, 0.07);
  --canvas-glow-c: rgba(238, 242, 246, 0.95);
  --stripe: rgba(15, 23, 42, 0.03);
  --on-accent: #ffffff;
  --overlay-scrim: rgba(238, 242, 246, 0.88);
  --panel-head-bg: #f1f5f9;
  --pill-bg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 56px rgba(15, 23, 42, 0.12);
  color-scheme: light;
}

:root {
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "Barlow Condensed", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;
  --header-h: 68px;
  --max-w: 1280px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body.page-text {
  --accent-b: #3794ff;
  --accent-b-soft: rgba(55, 148, 255, 0.12);
  --accent-b-glow: rgba(55, 148, 255, 0.22);
}

html[data-theme="light"] body.page-text {
  --accent-b: #0e7490;
  --accent-b-soft: rgba(14, 116, 144, 0.1);
  --accent-b-glow: rgba(14, 116, 144, 0.22);
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
  transition: background-color 0.25s ease, color 0.25s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 42% at 12% -8%, var(--canvas-glow-a), transparent 55%),
    radial-gradient(ellipse 45% 38% at 92% 8%, var(--canvas-glow-b), transparent 50%),
    radial-gradient(ellipse 60% 50% at 50% 110%, var(--canvas-glow-c), transparent 55%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 47px,
      var(--stripe) 47px,
      var(--stripe) 48px
    );
  pointer-events: none;
  z-index: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.site-header__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Show the theme you'll switch *to* */
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }

html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.brand__mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(145deg, #f0b429 0%, #c47d0a 55%, #8a5a12 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(232, 163, 23, 0.35), 0 8px 20px var(--ai-glow);
}

.brand__mark svg { width: 18px; height: 18px; color: #1f1f1f; stroke: #1f1f1f; }

.brand__text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}

.brand__text .accent,
.brand__text .ai { color: var(--ai); }
.brand__text .b { color: var(--accent-b); }

.brand__badge {
  margin-left: 0.15rem;
  padding: 0.22rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ai);
  background: var(--ai-soft);
  border: 1px solid rgba(232, 163, 23, 0.3);
}

html[data-theme="light"] .brand__badge {
  border-color: rgba(180, 83, 9, 0.28);
}

.nav-tabs {
  display: flex;
  gap: 0.2rem;
  padding: 4px;
  background: var(--nav-shell);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.nav-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.95rem;
  border-radius: 7px;
  font-size: 0.8125rem;
  font-weight: 550;
  text-decoration: none;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.nav-tabs a:hover { color: var(--text); background: var(--surface-hover); }

.nav-tabs a.active {
  color: var(--on-accent);
  background: linear-gradient(180deg, #f0b429, #d49212);
  box-shadow: 0 2px 10px var(--ai-glow);
  font-weight: 650;
}

html[data-theme="light"] .nav-tabs a.active {
  color: #fff;
  background: linear-gradient(180deg, #d97706, #b45309);
}

.nav-tabs a.active svg { opacity: 1; color: inherit; }

.nav-tabs a svg {
  width: 14px;
  height: 14px;
  opacity: 0.75;
  flex-shrink: 0;
}

.nav-tabs a .label { line-height: 1; }

.main {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4.5rem;
}

@media (min-width: 960px) {
  .main { padding: 2.75rem 2rem 5rem; }
}

.hero {
  text-align: left;
  margin-bottom: 2.25rem;
  padding: 0.25rem 0 0;
  max-width: 46rem;
}

.hero--compact { margin-bottom: 1.75rem; }

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.7rem;
  margin-bottom: 0.9rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
}

.hero__badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.2);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(2.15rem, 5vw, 3.15rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.05;
  text-transform: uppercase;
  color: var(--text);
}

.hero p {
  margin: 0;
  max-width: 38rem;
  color: var(--text-secondary);
  font-size: 1.02rem;
  line-height: 1.55;
}

.hero__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1.15rem;
}

.pill {
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 550;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  background: var(--pill-bg);
  border: 1px solid var(--border);
}

html[data-theme="light"] .pill {
  box-shadow: var(--shadow-sm);
}

.workspace {
  display: grid;
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 960px) {
  .workspace {
    grid-template-columns: minmax(340px, 0.9fr) minmax(0, 1.35fr);
    gap: 1.75rem;
  }
}

@media (min-width: 1200px) {
  .workspace {
    grid-template-columns: minmax(380px, 0.85fr) minmax(0, 1.4fr);
    gap: 2rem;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 28%), var(--surface);
}

html[data-theme="light"] .panel {
  box-shadow: var(--shadow);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel-head-bg);
}

.panel__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}

html[data-theme="dark"] .panel__title {
  color: var(--text-secondary);
}

.panel__title svg {
  width: 16px;
  height: 16px;
  opacity: 0.85;
  color: var(--ai);
}

.panel__body { padding: 1.35rem 1.35rem 1.5rem; }

@media (min-width: 960px) {
  .panel__body { padding: 1.5rem 1.55rem 1.65rem; }
}

.panel__body--flush { padding: 0; }

#results.panel { min-height: 440px; }

/* ── Form controls ── */
.field {
  display: block;
  margin-top: 1rem;
}

.field:first-child { margin-top: 0; }

.field__label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.field__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

select,
.input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

select:focus,
.input:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

textarea.input {
  min-height: 220px;
  max-height: 420px;
  resize: vertical;
  line-height: 1.55;
}

textarea.input.code-mode {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  tab-size: 2;
}

.char-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.char-meta .warn { color: var(--warn); }

/* ── Dropzone ── */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 3rem 1.75rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  background: var(--surface-inset);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--ai);
  background: var(--ai-soft);
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--border);
  padding: 1rem;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.dropzone__icon svg { width: 22px; height: 22px; }

.dropzone__title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.dropzone__hint {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.dropzone__formats {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.preview {
  margin-top: 1rem;
  display: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  width: 100%;
}

.preview:not([hidden]),
.preview.visible { display: block; }

.preview img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  margin: 0 auto;
  object-fit: contain;
  background: #000;
}

.file-meta {
  margin-top: 0.65rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-secondary);
  word-break: break-all;
  text-align: left;
  width: 100%;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
  align-items: stretch;
}

.upload-actions .btn {
  width: auto;
  flex: 1 1 140px;
  margin-top: 0;
}

.upload-actions .btn--ghost {
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
}

.upload-actions .btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ── Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow var(--transition), opacity var(--transition);
}

.btn--primary {
  color: var(--on-accent);
  background: linear-gradient(180deg, #f0b429 0%, #d49212 100%);
  box-shadow: 0 2px 14px var(--ai-glow);
}

html[data-theme="light"] .btn--primary {
  color: #fff;
  background: linear-gradient(180deg, #d97706 0%, #b45309 100%);
}

body.page-text .btn--primary {
  color: #ffffff;
  background: linear-gradient(180deg, #1a8cff 0%, #0078d4 100%);
  box-shadow: 0 2px 14px var(--accent-b-glow);
}

.btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--ai-glow);
}

body.page-text .btn--primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px var(--accent-b-glow);
}

.btn--primary:active:not(:disabled) { transform: translateY(0); }
.btn--primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn svg { width: 18px; height: 18px; }

/* ── Status ── */
.status {
  display: none;
  align-items: flex-start;
  gap: 0.65rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.status.visible { display: flex; }

.status--loading {
  background: var(--ai-soft);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
}

body.page-text .status--loading {
  background: var(--accent-b-soft);
  border-color: rgba(56, 189, 248, 0.25);
  color: #7dd3fc;
}

.status--error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.status--ok {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #86efac;
}

.spinner {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results panel ── */
#results { opacity: 0.6; transition: opacity var(--transition); }
#results.visible { opacity: 1; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state__icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 1.1rem;
  border-radius: 12px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ai);
}

.empty-state__icon svg { width: 26px; height: 26px; }

.empty-state h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.empty-state p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  max-width: 280px;
  margin-inline: auto;
  line-height: 1.5;
}

/* ── Score display ── */
.score-block {
  animation: fadeUp 0.45s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.verdict-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.verdict-badge.likely_ai {
  background: var(--ai-soft);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.verdict-badge.likely_real,
.verdict-badge.likely_human {
  background: var(--accent-b-soft);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

body.page-text .verdict-badge.likely_human { color: #7dd3fc; border-color: rgba(56, 189, 248, 0.3); }

.verdict-badge.uncertain {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.verdict-badge.mixed {
  background: rgba(161, 161, 170, 0.1);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.confidence-chip {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
}

.confidence-chip strong { color: var(--text-secondary); font-weight: 600; }

.gauge-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 1.5rem;
}

.gauge-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.gauge-wrap .track { fill: none; stroke: var(--surface-inset); stroke-width: 10; }

.gauge-wrap .arc-ai {
  fill: none;
  stroke: url(#gaugeAiGrad);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-center__value {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.gauge-center__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

.gauge-center__value.ai-color { color: var(--ai); }
.gauge-center__value.b-color { color: var(--accent-b); }

.stat-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  text-align: center;
}

.stat-card__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 0.35rem;
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-card__value .unit { font-size: 0.9rem; font-weight: 600; opacity: 0.65; }

.stat-card--ai .stat-card__value { color: var(--ai); }
.stat-card--b .stat-card__value { color: var(--accent-b); }

.meter-bar {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-inset);
  margin-bottom: 1.25rem;
}

.meter-bar__ai {
  background: linear-gradient(90deg, var(--accent-b), var(--ai));
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.meter-bar__b {
  flex: 1;
  background: linear-gradient(90deg, #059669, var(--accent-b));
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  margin-top: -1rem;
  margin-bottom: 1.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.meter-labels .ai { color: var(--ai); }
.meter-labels .b { color: var(--accent-b); }

.summary-box {
  padding: 1rem 1.125rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  border-left-width: 3px;
}

.summary-box.ai-lean { border-left-color: var(--ai); }
.summary-box.b-lean { border-left-color: var(--accent-b); }
.summary-box.uncertain-lean { border-left-color: var(--warn); }

.section { margin-bottom: 1.25rem; }
.section:last-child { margin-bottom: 0; }

.section__title {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.indicator-list { display: flex; flex-direction: column; gap: 0.5rem; }

.indicator {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}

.indicator__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.indicator__icon.ai { background: var(--ai-soft); color: var(--ai); }
.indicator__icon.b { background: var(--accent-b-soft); color: var(--accent-b); }
.indicator__icon.neutral { background: rgba(161,161,170,0.1); color: var(--text-tertiary); }

.indicator__cat {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.indicator__strength {
  font-weight: 400;
  text-transform: lowercase;
  margin-left: 0.25rem;
}

.indicator__desc {
  margin-top: 0.2rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.meta-grid {
  display: grid;
  gap: 0.5rem;
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}

.meta-grid__row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-secondary);
}

.meta-grid__val.yes { color: var(--success); font-weight: 500; }
.meta-grid__val.no { color: var(--danger); font-weight: 500; }

.note-text {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  line-height: 1.55;
  margin: 0;
}

.content-type-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  background: var(--surface-inset);
  color: var(--text-tertiary);
  vertical-align: middle;
}

/* ── Raw JSON ── */
details.raw {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

details.raw summary {
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  user-select: none;
}

details.raw summary:hover { color: var(--text-secondary); }

pre.raw-json {
  margin: 0.75rem 0 0;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}

/* ── Footer ── */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  background: var(--footer-bg);
  padding: 1.35rem 1.5rem;
  margin-top: 2rem;
}

.site-footer__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer__brand {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.site-footer__disclaimer {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  max-width: 520px;
  line-height: 1.5;
  text-align: right;
}

@media (max-width: 640px) {
  .site-header__inner { padding: 0 1rem; }
  .nav-tabs a span.label { display: none; }
  .main { padding: 1.5rem 1rem 3rem; }
  .field__row { grid-template-columns: 1fr; }
  .site-footer__disclaimer { text-align: left; }
}

/* ── Admin ── */
body.page-admin {
  --admin-sidebar-w: 320px;
}

body.page-admin .brand__text .accent { color: var(--ai); }

/* Login */
.admin-login {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h));
  padding: 2rem 1.25rem;
}

body.admin-authed .admin-login {
  display: none !important;
}

.admin-login__card {
  width: min(420px, 100%);
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.admin-login__head {
  margin-bottom: 1.25rem;
}

.admin-login__head h1 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.admin-login__head p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.admin-login__head code {
  font-family: var(--mono);
  font-size: 0.78em;
  color: var(--text);
}

.admin-login__btn {
  margin-top: 1.15rem;
}

.admin-login .status {
  margin-top: 0.85rem;
}

/* App shell — full bleed under header */
.admin-shell {
  position: relative;
  z-index: 1;
  display: none;
  grid-template-columns: var(--admin-sidebar-w) minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - var(--header-h));
  background: var(--bg);
  box-sizing: border-box;
}

body.admin-authed .admin-shell {
  display: grid;
}

@media (max-width: 900px) {
  body.admin-authed .admin-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

/* Sidebar */
.admin-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  min-height: calc(100vh - var(--header-h));
  max-height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .admin-sidebar {
    position: relative;
    top: auto;
    min-height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .admin-list {
    max-height: 280px;
  }
}

.admin-sidebar__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.admin-sidebar__title h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.admin-sidebar__title p {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.admin-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.admin-icon-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.admin-sidebar__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-filter {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.admin-filter:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.admin-filter.active {
  background: var(--ai-soft);
  color: var(--ai);
  border-color: rgba(245, 158, 11, 0.35);
}

.admin-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.55rem;
  min-height: 0;
}

.admin-list__msg {
  margin: 0;
  padding: 1rem 0.65rem;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  text-align: center;
}

.admin-list__msg--error { color: #fca5a5; }

.admin-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  padding: 0.7rem 0.75rem;
  margin: 0 0 0.35rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.admin-item:hover { background: var(--surface); }
.admin-item.active {
  background: var(--surface);
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: inset 3px 0 0 var(--ai);
}

.admin-item__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.admin-item__type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--ai-soft);
  color: var(--ai);
}

.admin-item__type.permit { background: var(--ai-soft); color: var(--ai); }
.admin-item__type.image { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.admin-item__type.text { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; }

.admin-item__date {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.admin-item__summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.admin-item__verdict {
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 0.35rem;
  color: #86efac;
}

.admin-item__verdict.fail { color: #fca5a5; }

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.admin-pagination span {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
  text-align: center;
}

.admin-pagination button {
  width: 34px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.admin-pagination button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.admin-pagination button:disabled { opacity: 0.35; cursor: not-allowed; }

.admin-sidebar__foot {
  padding: 0.65rem 0.75rem 0.85rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.admin-signout {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.admin-signout:hover {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

/* Main detail area */
.admin-main {
  min-width: 0;
  width: 100%;
  padding: 1.25rem 1.35rem 2rem;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
}

@media (min-width: 1100px) {
  .admin-main {
    padding: 1.5rem 1.75rem 2.5rem;
  }
}

.admin-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: min(420px, 60vh);
  padding: 3rem 1.5rem;
  color: var(--text-tertiary);
}

.admin-empty[hidden] {
  display: none !important;
}

.admin-detail[hidden] {
  display: none !important;
}

.admin-empty__icon {
  width: 56px;
  height: 56px;
  margin-bottom: 1rem;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.admin-empty__icon svg { width: 26px; height: 26px; }

.admin-empty h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text-secondary);
}

.admin-empty p {
  margin: 0;
  max-width: 320px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.admin-detail {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  min-width: 0;
}

.admin-detail__head {
  min-width: 0;
}

.admin-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.admin-meta-bar .chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.2;
}

.admin-meta-bar .chip--ok {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.1);
}

.admin-meta-bar .chip--fail {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
}

.admin-meta-bar .chip--file {
  max-width: min(420px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.7rem;
}

/* Detail panes — prevent grid blowout */
.admin-detail__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
  align-items: start;
  min-width: 0;
}

@media (min-width: 1100px) {
  .admin-detail__grid {
    grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.35fr);
    gap: 1.35rem;
  }
}

.admin-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.admin-pane__head {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.admin-pane__title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.admin-pane__body {
  min-width: 0;
  padding: 1rem 1.1rem 1.2rem;
}

.admin-pane--result .admin-pane__body {
  overflow-x: auto;
}

.admin-preview-frame {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-inset);
}

.admin-preview-pdf {
  display: block;
  width: 100%;
  height: min(62vh, 560px);
  border: 0;
  background: #111;
}

.admin-preview-img {
  max-width: 100%;
  max-height: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
  background: #000;
}

.admin-preview-text {
  width: 100%;
  min-height: 280px;
  max-height: 420px;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-inset);
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-raw {
  margin: 0;
}

/* Results inside admin: keep nested blocks from stretching page */
.admin-pane--result .route-map-canvas {
  height: 320px;
}

@media (min-width: 1100px) {
  .admin-pane--result .route-map-canvas {
    height: 360px;
  }
}

.admin-pane--result .table-wrap {
  max-width: 100%;
}

.admin-pane--result .permit-card,
.admin-pane--result .results {
  min-width: 0;
}

/* ── Permit2Route ── */
body.page-permit .brand__text .accent { color: var(--ai); }

.preview--pdf {
  margin-top: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  height: 280px;
  width: 100%;
}

.preview--pdf embed {
  width: 100%;
  height: 100%;
  border: 0;
}

.permit-card,
.route-card {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.permit-card__head,
.route-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.permit-card h3,
.route-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.permit-grid {
  display: grid;
  grid-template-columns: minmax(120px, 38%) 1fr;
  gap: 0.45rem 1rem;
  margin: 0;
}

.permit-grid dt {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 0.82rem;
}

.permit-grid dd {
  margin: 0;
  font-size: 0.88rem;
}

.list-block {
  margin-bottom: 0.85rem;
}

.list-block h4,
.segments h4,
.export-actions h4,
.warnings-block h4 {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.list-block ul,
.warnings-block ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
}

.route-summary {
  margin: 0 0 0.85rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.conf-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.conf-high { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.conf-medium { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.conf-low { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

.route-type-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  margin-left: 0.35rem;
}

.map-regions {
  margin: 0.75rem 0;
  font-size: 0.85rem;
}

.map-regions ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

.route-empty {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.table-wrap { overflow-x: auto; }

.waypoint-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.waypoint-table th,
.waypoint-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.waypoint-table th {
  color: var(--text-tertiary);
  font-weight: 500;
}

.waypoint-table .mono {
  font-family: var(--mono);
  font-size: 0.78rem;
}

.segments ol {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
}

.muted { color: var(--text-tertiary); }

.warnings-block {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.extraction-banner {
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.extraction-banner--complete {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.extraction-banner--partial {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.extraction-banner--insufficient {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.geometry-suspect-note {
  color: #b45309;
  margin-top: 0.5rem;
}

.extraction-banner p {
  margin: 0.45rem 0 0;
  color: var(--text-secondary);
}

.extraction-banner ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.route-map {
  margin-bottom: 1rem;
}

.route-map-wrap {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.map-disclaimer {
  margin: 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(148, 163, 184, 0.08);
  border-bottom: 1px solid var(--border);
}

.route-map-canvas {
  height: 380px;
}

@media (min-width: 960px) {
  .route-map-canvas {
    height: 460px;
  }
}

.waypoint-links {
  margin-top: 0.75rem;
  font-size: 0.82rem;
}

.waypoint-links ul {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}

.waypoint-table a {
  color: var(--accent, #f59e0b);
  text-decoration: none;
}

.waypoint-table a:hover {
  text-decoration: underline;
}

.map-pin-link {
  font-size: 0.78rem;
  font-weight: 500;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(245, 158, 11, 0.06);
}

.btn--sm {
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
}

.p2r-pin {
  background: transparent;
  border: none;
}

.p2r-pin__bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f59e0b;
  color: #1a1a1a;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  border: 2px solid #fff;
}

.p2r-pin__bubble--muted {
  background: #94a3b8;
  color: #fff;
}

.waypoint-links li {
  margin: 0.25rem 0;
}

.map-empty {
  padding: 1rem;
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.export-actions {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.export-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn--secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn--outline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
}

.btn--ghost {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
}

.btn--secondary:hover,
.btn--outline:hover { background: var(--surface-hover); }

.btn--orange {
  width: auto;
  margin-top: 0;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(180deg, #f0b429 0%, #d49212 100%);
  box-shadow: 0 2px 12px rgba(232, 163, 23, 0.35);
}

.btn--orange:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.45);
}

.btn--orange:active:not(:disabled) {
  transform: translateY(0);
}

.wim-toolbar .btn {
  width: auto;
  margin-top: 0;
}

.results { animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ── WIM station map tool ── */
.main--wim {
  max-width: 1100px;
}

.hero--compact {
  margin-bottom: 1.25rem;
}

.hero--compact h1 {
  font-size: clamp(1.65rem, 4vw, 2.1rem);
}

.wim-tool {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wim-toolbar {
  padding: 1rem 1.1rem;
}

.wim-toolbar.panel {
  margin-bottom: 0;
}

.wim-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}

.wim-field {
  flex: 0 1 160px;
  min-width: 120px;
  margin: 0;
}

.wim-field--search {
  flex: 1 1 200px;
  max-width: 280px;
}

.wim-stats {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.wim-map-panel .panel__body--flush {
  padding: 0;
}

.wim-map-canvas {
  height: min(70vh, 620px);
  min-height: 360px;
  width: 100%;
  background: var(--surface-inset);
}

.wim-attribution {
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}

.wim-attribution a {
  color: var(--accent-b, #38bdf8);
  text-decoration: none;
}

.wim-attribution a:hover {
  text-decoration: underline;
}

.wim-pin {
  background: transparent;
  border: none;
}

.wim-pin__dot {
  width: 12px;
  height: 12px;
  margin: 1px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #0f172a;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

.wim-popup dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.82rem;
}

.wim-popup dt {
  margin: 0;
  color: #64748b;
}

.wim-popup dd {
  margin: 0;
}

.wim-popup a {
  color: #0284c7;
  font-size: 0.82rem;
}

.leaflet-container {
  font-family: inherit;
}

@media (max-width: 640px) {
  .wim-field,
  .wim-field--search {
    flex: 1 1 100%;
    max-width: none;
  }

  .wim-map-canvas {
    min-height: 300px;
  }
}

/* ── Analyzing overlay ── */
.analyze-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, var(--ai-soft), transparent 60%),
    radial-gradient(ellipse 50% 45% at 70% 70%, var(--accent-b-soft), transparent 55%),
    var(--overlay-scrim);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.analyze-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.analyze-card {
  position: relative;
  width: min(460px, 100%);
  padding: 1.75rem 1.6rem 1.4rem;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
    var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.08),
    0 24px 64px rgba(0, 0, 0, 0.55);
  text-align: center;
  overflow: hidden;
  animation: analyze-card-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes analyze-card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.analyze-anim {
  position: relative;
  width: 100%;
  max-width: 300px;
  height: 168px;
  margin: 0 auto 1rem;
}

.analyze-anim__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(28px);
  pointer-events: none;
}

.analyze-anim__glow--a {
  width: 120px;
  height: 80px;
  left: 10%;
  top: 30%;
  background: rgba(245, 158, 11, 0.28);
  animation: analyze-glow-drift 4.5s ease-in-out infinite;
}

.analyze-anim__glow--b {
  width: 100px;
  height: 70px;
  right: 8%;
  top: 18%;
  background: rgba(56, 189, 248, 0.22);
  animation: analyze-glow-drift 5.2s ease-in-out infinite reverse;
}

@keyframes analyze-glow-drift {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.7; }
  50% { transform: translate(10px, -8px) scale(1.15); opacity: 1; }
}

.analyze-anim__scene {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  overflow: hidden;
  background:
    linear-gradient(160deg, #12151a 0%, #0c0e12 55%, #10141a 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.analyze-anim__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 85%);
  animation: analyze-grid-pan 18s linear infinite;
}

@keyframes analyze-grid-pan {
  to { background-position: 22px 22px; }
}

.analyze-anim__route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.analyze-anim__route-glow {
  stroke: rgba(245, 158, 11, 0.35);
  stroke-width: 6;
  stroke-linecap: round;
  filter: blur(3px);
}

.analyze-anim__route-line {
  stroke: url(#analyzeRouteGrad);
  stroke: #f59e0b;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: analyze-draw-route 3.2s ease-in-out infinite;
}

@keyframes analyze-draw-route {
  0% { stroke-dashoffset: 100; opacity: 0.55; }
  35% { stroke-dashoffset: 0; opacity: 1; }
  70% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: -20; opacity: 0.4; }
}

.analyze-anim__node {
  fill: #38bdf8;
  stroke: #0c0e12;
  stroke-width: 2;
  transform-origin: center;
  transform-box: fill-box;
  animation: analyze-node-pulse 3.2s ease-in-out infinite;
}

.analyze-anim__node--1 { animation-delay: 0s; }
.analyze-anim__node--2 { animation-delay: 0.45s; fill: #f59e0b; }
.analyze-anim__node--3 { animation-delay: 0.9s; }
.analyze-anim__node--4 { animation-delay: 1.35s; fill: #86efac; }

@keyframes analyze-node-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.75); }
  40%, 55% { opacity: 1; transform: scale(1.15); }
}

.analyze-anim__truck-g {
  opacity: 0.95;
}

.analyze-anim__headlight {
  animation: analyze-blink 1.1s ease-in-out infinite;
}

@keyframes analyze-blink {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.analyze-anim__scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 28%;
  top: -30%;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(56, 189, 248, 0.08),
    rgba(56, 189, 248, 0.22),
    rgba(56, 189, 248, 0.08),
    transparent
  );
  animation: analyze-scan 2.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

@keyframes analyze-scan {
  0% { top: -30%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.analyze-anim__doc {
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 42px;
  height: 52px;
  border-radius: 5px;
  background: linear-gradient(160deg, #313131, #252526);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 7px 8px;
  z-index: 1;
  animation: analyze-doc-bob 3.6s ease-in-out infinite;
}

.analyze-anim__doc span {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  animation: analyze-doc-line 1.8s ease-in-out infinite;
}

.analyze-anim__doc span:nth-child(1) { width: 88%; animation-delay: 0s; }
.analyze-anim__doc span:nth-child(2) { width: 70%; animation-delay: 0.2s; }
.analyze-anim__doc span:nth-child(3) { width: 78%; animation-delay: 0.4s; }

@keyframes analyze-doc-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-4px) rotate(1deg); }
}

@keyframes analyze-doc-line {
  0%, 100% { opacity: 0.35; background: rgba(255, 255, 255, 0.16); }
  50% { opacity: 1; background: rgba(56, 189, 248, 0.55); }
}

.analyze-stages {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 1rem;
}

.analyze-stages__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 0.35s ease, transform 0.35s ease, box-shadow 0.35s ease;
}

.analyze-stages__dot.is-active {
  background: var(--ai);
  transform: scale(1.25);
  box-shadow: 0 0 10px var(--ai-glow);
}

.analyze-stages__dot.is-done {
  background: var(--accent-b);
  box-shadow: 0 0 8px var(--accent-b-glow);
}

.analyze-card__title {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fafafa 0%, #fcd34d 50%, #7dd3fc 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: analyze-title-shine 4s linear infinite;
}

@keyframes analyze-title-shine {
  to { background-position: 200% center; }
}

.analyze-card__step {
  margin: 0 0 1.15rem;
  min-height: 2.6em;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
  transition: opacity 0.25s ease;
}

.analyze-progress {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 0.65rem;
}

.analyze-progress__bar {
  position: relative;
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d97706, #f59e0b, #38bdf8);
  background-size: 200% 100%;
  transition: width 0.6s ease;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.4);
  animation: analyze-bar-flow 2s linear infinite;
}

.analyze-progress__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: analyze-bar-sheen 1.6s ease-in-out infinite;
}

@keyframes analyze-bar-flow {
  to { background-position: 200% 0; }
}

@keyframes analyze-bar-sheen {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.analyze-card__meta {
  margin: 0 0 1.15rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.analyze-card__actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.analyze-card__actions .btn {
  min-width: 120px;
}

.analyze-card__actions .btn--ghost {
  width: auto;
  margin-top: 0;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
}

.analyze-card__actions .btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

body.is-analyzing {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .analyze-card,
  .analyze-anim__glow,
  .analyze-anim__grid,
  .analyze-anim__route-line,
  .analyze-anim__node,
  .analyze-anim__scan,
  .analyze-anim__doc,
  .analyze-anim__doc span,
  .analyze-anim__headlight,
  .analyze-card__title,
  .analyze-progress__bar,
  .analyze-progress__bar::after {
    animation: none !important;
  }
  .analyze-anim__truck-g animateMotion {
    display: none;
  }
  .analyze-anim__route-line { stroke-dashoffset: 0; opacity: 1; }
  .analyze-anim__node { opacity: 1; transform: none; }
  .analyze-card__title {
    color: var(--text);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
  }
}
