/* ============================================================
   Dashboard CSS v2 — supplementary styles only
   Critical layout rules are inlined in dashboard.html <style>
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ---------- Ranking table inside sidebar ---------- */
.ranking-card { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.ranking-card .table-wrap { flex: 1; overflow-y: auto; min-height: 0; }

/* ---------- Table sticky headers ---------- */
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fb;
}

/* ---------- Cost tab ---------- */
.cost-card .table-wrap { flex: 1; overflow: auto; min-height: 0; }
#cost-table th { white-space: nowrap; }

/* ---------- Route legend (Leaflet control, bottom-right) ---------- */
.route-legend {
  background: rgba(255,255,255,0.94);
  padding: 6px 8px; border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.18);
  font-size: 11px; line-height: 1.5; max-height: 42vh; overflow-y: auto;
}
.route-legend-title { font-weight: 700; color: #1a3a5c; margin-bottom: 4px; font-size: 10px; }
.route-legend-row {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; padding: 1px 2px; border-radius: 3px; white-space: nowrap;
}
.route-legend-row:hover { background: #EAF4FE; }
.route-legend-swatch {
  display: inline-block; width: 18px; height: 0;
  border-top-width: 3px; border-top-style: solid; flex-shrink: 0;
}
.route-legend-swatch.dashed { border-top-style: dashed; }
.route-legend-label { color: #334155; }

/* ---------- Table row <-> map linkage ---------- */
tr.row-clickable { cursor: pointer; }
tr.row-clickable.highlight { background: #EAF4FE; box-shadow: inset 3px 0 0 #0EA5E9; }

/* ---------- Table toolbar (row count + CSV export) ---------- */
.table-toolbar {
  float: right; display: inline-flex; align-items: center; gap: 8px;
  font-weight: 400; text-transform: none;
}
.table-count { font-size: 10px; color: #94A3B8; font-variant-numeric: tabular-nums; }
.table-export {
  font-size: 10px; font-weight: 600; color: #0EA5E9;
  background: #F0F9FF; border: 1px solid #BAE6FD;
  border-radius: 4px; padding: 2px 8px; cursor: pointer; font-family: inherit;
}
.table-export:hover { background: #E0F2FE; }

/* ---------- Sortable headers ---------- */
th[data-sortable] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sortable]:hover { color: #0EA5E9; }
th[data-sortable]:focus-visible { outline: 2px solid #4FC3F7; outline-offset: -2px; }

/* ---------- Markdown ---------- */
.md-img { max-width: 100%; border-radius: 6px; margin: 4px 0; }
.md-img-block { display: block; margin: 12px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.md-img[src*="radar"] { max-width: 60%; display: block; margin: 12px auto; }

/* Fenced code blocks in reports (shared markdown renderer) */
#markdown-content pre {
  background: #0F172A; color: #E2E8F0;
  padding: 10px 14px; border-radius: 6px;
  overflow-x: auto; font-size: 12px; line-height: 1.5; margin: 8px 0;
}
#markdown-content pre code { background: none; color: inherit; padding: 0; font-size: 12px; }

/* ---------- Route legend ---------- */
.route-legend { padding: 4px 8px; background: rgba(255,255,255,0.9); border-radius: 4px; font-size: 12px; }

/* ---------- Custom scrollbar (WebKit) ---------- */
#overview-sidebar::-webkit-scrollbar,
#tab-report::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
#markdown-content::-webkit-scrollbar { width: 5px; height: 5px; }

#overview-sidebar::-webkit-scrollbar-thumb,
#tab-report::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
#markdown-content::-webkit-scrollbar-thumb { background: #c4c9cf; border-radius: 3px; }

#overview-sidebar::-webkit-scrollbar-track,
#tab-report::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
#markdown-content::-webkit-scrollbar-track { background: transparent; }

/* ---------- Study area: notes, lock tags, validation ---------- */
.pl-note {
  font-size: 9px; color: #94A3B8; line-height: 1.45;
  margin: 0 0 6px 0;
}
.pl-section-title .pl-lock-tag {
  font-size: 9px; font-weight: 700; color: #92400E;
  background: #FEF3C7; border-radius: 3px; padding: 1px 5px;
  margin-left: 6px; white-space: nowrap;
}
.pl-sub-title {
  font-size: 10px; font-weight: 600; color: #334155;
  margin: 8px 0 4px 0;
}
.pl-scope-status {
  font-size: 10px; line-height: 1.45; margin-top: 6px;
  padding: 4px 6px; border-radius: 4px;
}
.pl-scope-status.ok { background: #ECFDF5; color: #047857; }
.pl-scope-status.bad { background: #FEF2F2; color: #B91C1C; }
.pl-point-btn {
  flex: 1; padding: 4px; font-size: 10px; border-radius: 4px;
  background: #FFF; cursor: pointer; font-family: inherit;
}
.pl-point-btn.pl-point-start { border: 1px solid #FECACA; color: #EF4444; }
.pl-point-btn.pl-point-end { border: 1px solid #A7F3D0; color: #10B981; }
.pl-point-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Panel-driven region drawing (replaces Leaflet.draw's toolbar button) */
.pl-draw-btn {
  width: 100%; padding: 6px; font-size: 11px; font-weight: 600;
  border: 1px solid #7DD3FC; border-radius: 4px;
  background: #F0F9FF; color: #0369A1;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.pl-draw-btn:hover:not(:disabled) { background: #E0F2FE; }
.pl-draw-btn.active { background: #0EA5E9; border-color: #0EA5E9; color: #FFF; }
.pl-draw-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Tooltip host — used by the "?" hints (parameters and section titles alike) */
.hint-host { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.hint-host:hover > .hint-bubble,
.hint-host:focus-within > .hint-bubble { opacity: 1; visibility: visible; }

/* (the guide bar / stepper is styled in the console redesign block below) */

/* ---------- Environment-factor weights (new project only) ---------- */
.pl-tunables-note {
  font-size: 10px; color: #64748B; margin-bottom: 6px;
  padding: 3px 6px; background: #F1F5F9; border-radius: 4px; line-height: 1.4;
}
.pl-tunables-note.locked { background: #FEF3C7; color: #92400E; }

.tw-group { margin-bottom: 8px; }
.tw-group-title { font-size: 10px; font-weight: 700; color: #334155; margin-bottom: 1px; }
.tw-group-note { font-size: 9px; color: #94A3B8; line-height: 1.4; margin-bottom: 4px; }

/* One field per row: label (+ "?" hint) on the left, numeric input on the right */
.tw-field {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 1px 0;
}
.tw-label {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px;
  font-size: 10px; color: #475569;
}
.tw-control { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.tw-input {
  width: 62px; padding: 3px 5px; font-size: 11px; text-align: right;
  border: 1px solid #CBD5E1; border-radius: 4px;
  font-family: inherit; background: #FFF; color: #0F172A;
}
.tw-input:focus {
  outline: none; border-color: #0EA5E9; box-shadow: 0 0 0 2px rgba(14,165,233,0.15);
}
.tw-input:disabled { background: #F1F5F9; color: #94A3B8; cursor: not-allowed; }
.tw-input.invalid { border-color: #EF4444; box-shadow: 0 0 0 2px rgba(239,68,68,0.15); }
.tw-unit { font-size: 9px; color: #94A3B8; }

/* "?" badge — hover or focus inside the field reveals the explanation */
.hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  background: #E2E8F0; color: #64748B;
  font-size: 9px; font-weight: 700; line-height: 1; cursor: help;
}
.tw-field:hover .hint,
.hint-host:hover .hint { background: #BAE6FD; color: #0369A1; }
.hint-bubble {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 3px; z-index: 30;
  background: #0F172A; color: #E2E8F0;
  font-size: 10px; line-height: 1.5; text-align: left;
  padding: 7px 9px; border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
  opacity: 0; visibility: hidden; transition: opacity 0.12s;
  pointer-events: none;
}
.tw-field:hover > .hint-bubble,
.tw-field:focus-within > .hint-bubble { opacity: 1; visibility: visible; }

/* Section-title hints anchor at their own left edge and need an explicit width
   (they live in an inline-flex span, not a full-width field row). */
.hint-host > .hint-bubble { right: auto; width: 258px; }

/* ============================================================
   Accessibility
   ============================================================ */

/* Visually hidden but available to screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Keyboard focus must be visible (mouse users keep the clean look) */
#header-bar button:focus-visible,
#header-bar select:focus-visible,
.pl-btn-sm:focus-visible,
.pl-btn-run:focus-visible,
.pl-link-btn:focus-visible,
.step-group-toggle:focus-visible,
.step-group-all:focus-visible,
.custom-modal-btn:focus-visible,
.custom-modal-input:focus-visible,
#assistant-toggle:focus-visible,
#assistant-close:focus-visible,
#assistant-send:focus-visible,
.suggestion-chip:focus-visible {
  outline: 2px solid #4FC3F7;
  outline-offset: 2px;
}

/* Step status: glyph + screen-reader text, so state is never colour-only */
.step-status { flex-shrink: 0; font-size: 10px; line-height: 1; margin-left: 2px; }

/* ============================================================
   Pipeline Tab — modern console redesign

   Scope: only #tab-pipeline (+ the shared header). Every id, class and
   onclick handler that pipeline.js relies on is preserved; this block is
   presentation only.
   ============================================================ */

:root {
  --ui-bg: #f5f7fa;
  --ui-card: #ffffff;
  --ui-border: #e5e9f0;
  --ui-border-strong: #cbd5e1;
  --ui-text: #1f2937;
  --ui-text-soft: #475569;
  --ui-muted: #64748b;
  --ui-dim: #94a3b8;
  --ui-primary: #0ea5e9;
  --ui-primary-600: #0284c7;
  --ui-primary-700: #0369a1;
  --ui-success: #10b981;
  --ui-warn: #f59e0b;
  --ui-danger: #ef4444;
  --ui-radius: 8px;
  --ui-radius-sm: 6px;
  --ui-radius-lg: 10px;
  --ui-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --ui-shadow-md: 0 4px 12px rgba(16, 24, 40, .10);
  --ui-ring: 0 0 0 3px rgba(14, 165, 233, .14);
  --ui-term-bg: #1e1e1e;
  --ui-term-panel: #252526;
  --ui-term-text: #d4d4d4;
}

#tab-pipeline.active {
  display: flex !important;
  position: absolute; inset: 0;
  gap: 0;
  background:
    radial-gradient(1100px 420px at 12% -10%, #e8eef7 0%, rgba(232, 238, 247, 0) 60%),
    var(--ui-bg);
}

/* ---------- Left panel: translucent "glass" surface holding white cards --- */
#pipeline-left {
  width: 348px; flex-shrink: 0;
  overflow-y: auto; overflow-x: hidden;
  background: rgba(255, 255, 255, .62);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  border-right: 1px solid var(--ui-border);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ---------- Cards -------------------------------------------------------- */
#tab-pipeline .pl-section {
  background: var(--ui-card);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: 12px 14px;
  box-shadow: var(--ui-shadow-sm);
  transition: box-shadow .18s ease, transform .18s ease;
}
#tab-pipeline .pl-section:hover { box-shadow: var(--ui-shadow-md); }
#tab-pipeline .pl-section.gated { opacity: .62; }

#tab-pipeline .pl-section-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--ui-text);
  margin: 0 0 10px 0; padding-bottom: 8px;
  border-bottom: 1px solid var(--ui-border);
}
/* accent bar instead of the redundant numbering */
#tab-pipeline .pl-section-title::before {
  content: ""; flex-shrink: 0;
  width: 3px; height: 13px; border-radius: 2px;
  background: linear-gradient(180deg, var(--ui-primary), var(--ui-primary-700));
}
#tab-pipeline .pl-section-title > .pl-link-btn { margin-left: auto; }

/* Live study-area extent in the ② header. The numbers matter: "0.90° x 0.95°"
   and "4.86° x 2.62°" look similar but differ by ~20x in DEM tiles to download. */
.pl-span-info {
  font-size: 9.5px; font-weight: 600; color: var(--ui-muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pl-span-info.over { color: #B91C1C; }
.pl-span-info:empty { display: none; }

.pl-note {
  font-size: 10px; color: var(--ui-muted); line-height: 1.6;
  margin: 0 0 8px 0;
}
.pl-sub-title {
  font-size: 11px; font-weight: 600; color: var(--ui-text-soft);
  margin: 12px 0 6px 0;
}

/* Lock / status chips */
#tab-pipeline .pl-lock-tag {
  font-size: 9px; font-weight: 700; color: #92400e;
  background: #fef3c7; border: 1px solid #fde68a;
  border-radius: 999px; padding: 1px 8px; margin-left: auto; white-space: nowrap;
}
.pl-status-line {
  font-size: 11px; color: var(--ui-muted); margin-top: 8px; line-height: 1.5;
}
.pl-name-error {
  margin-top: 6px; font-size: 10px; line-height: 1.5;
  color: #b91c1c; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: var(--ui-radius-sm);
  padding: 5px 8px;
}
.pl-scope-status {
  font-size: 10px; line-height: 1.55; margin-top: 10px;
  padding: 6px 9px; border-radius: var(--ui-radius-sm);
  border: 1px solid transparent;
}
.pl-scope-status.ok { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.pl-scope-status.bad { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* ---------- Fields ------------------------------------------------------- */
.pl-grid-4, .pl-grid-3 { display: grid; gap: 8px; }
.pl-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pl-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#tab-pipeline .pl-grid-4 label,
#tab-pipeline .pl-grid-3 label {
  display: block; font-size: 9px; font-weight: 600;
  color: var(--ui-muted); margin-bottom: 3px; letter-spacing: .02em;
}
#tab-pipeline .pl-grid-4 input,
#tab-pipeline .pl-grid-3 input,
#pipeline-left select,
#pl-new-name {
  width: 100%; padding: 6px 8px; font-size: 12px;
  border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm);
  background: #fff; color: var(--ui-text); font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#tab-pipeline .pl-grid-4 input:focus,
#tab-pipeline .pl-grid-3 input:focus,
#pipeline-left select:focus,
#pl-new-name:focus {
  outline: none; border-color: var(--ui-primary); box-shadow: var(--ui-ring);
}
#tab-pipeline input:disabled,
#pipeline-left select:disabled {
  background: #f1f5f9; color: var(--ui-dim); cursor: not-allowed;
}

/* Unit suffix rendered inside the coordinate boxes (deg) */
#pl-section-scope .pl-grid-4 > div { position: relative; }
#pl-section-scope .pl-grid-4 > div::after {
  content: "°"; position: absolute; right: 8px; bottom: 7px;
  font-size: 9px; color: var(--ui-dim); pointer-events: none;
}
#pl-section-scope .pl-grid-4 input { padding-right: 18px; }

/* ---------- Buttons ------------------------------------------------------ */
.pl-btn-run {
  padding: 9px 18px; font-size: 13px; font-weight: 700;
  border: none; border-radius: var(--ui-radius-sm); cursor: pointer;
  color: #fff; font-family: inherit;
  background: linear-gradient(135deg, var(--ui-primary), var(--ui-primary-600));
  box-shadow: 0 1px 2px rgba(2, 132, 199, .35);
  transition: transform .12s ease, box-shadow .18s ease, filter .18s ease;
}
.pl-btn-run:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, .32);
  filter: saturate(115%);
}
.pl-btn-run:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.pl-btn-run:disabled {
  cursor: not-allowed; color: #fff;
  background: #cbd5e1; box-shadow: none; opacity: 1;
}
.pl-btn-stop {
  background: linear-gradient(135deg, #f87171, var(--ui-danger));
  box-shadow: 0 1px 2px rgba(220, 38, 38, .3);
}
.pl-btn-stop:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(220, 38, 38, .3); }

.pl-btn-sm {
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm);
  background: #fff; color: var(--ui-text-soft); cursor: pointer;
  font-family: inherit; transition: all .15s ease;
}
.pl-btn-sm:hover { background: #f1f5f9; border-color: var(--ui-dim); }
.pl-btn-danger { color: var(--ui-danger); border-color: #fecaca; }
.pl-btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }

.pl-link-btn {
  margin-left: auto; font-size: 10px; font-weight: 600;
  color: var(--ui-primary-600); background: none; border: none;
  cursor: pointer; text-decoration: none; padding: 2px 4px;
  border-radius: 4px; font-family: inherit; transition: all .15s ease;
}
.pl-link-btn:hover { background: #e0f2fe; color: var(--ui-primary-700); }
.pl-link-btn:disabled { color: var(--ui-dim); cursor: not-allowed; background: none; }

/* Region drawing (replaces Leaflet.draw's toolbar button) */
.pl-draw-btn {
  width: 100%; padding: 9px; margin-bottom: 8px;
  font-size: 12px; font-weight: 700; font-family: inherit;
  border: 1px dashed #7dd3fc; border-radius: var(--ui-radius-sm);
  background: #f0f9ff; color: var(--ui-primary-700);
  cursor: pointer; transition: all .16s ease;
}
.pl-draw-btn:hover:not(:disabled) { background: #e0f2fe; border-style: solid; }
.pl-draw-btn.active {
  background: linear-gradient(135deg, var(--ui-primary), var(--ui-primary-600));
  border: 1px solid var(--ui-primary-600); color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, .3);
}
.pl-draw-btn:disabled { opacity: .45; cursor: not-allowed; }

.pl-point-btn {
  flex: 1; padding: 7px 6px; font-size: 11px; font-weight: 600;
  border-radius: var(--ui-radius-sm); background: #fff; cursor: pointer;
  font-family: inherit; transition: all .16s ease; border: 1px solid;
}
.pl-point-btn.pl-point-start { border-color: #fecaca; color: #dc2626; }
.pl-point-btn.pl-point-start:hover:not(:disabled) { background: #fef2f2; transform: translateY(-1px); }
.pl-point-btn.pl-point-end { border-color: #a7f3d0; color: #059669; }
.pl-point-btn.pl-point-end:hover:not(:disabled) { background: #ecfdf5; transform: translateY(-1px); }
.pl-point-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* The run card: primary action grows, stop keeps its size */
.pl-section-run { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-section-run #pl-btn-create { flex: 1; min-width: 132px; }
.pl-section-run #pl-run-hint { flex-basis: 100%; margin: 2px 0 0 0; }

/* Session actions live in the name card, under the input */
#pl-btn-newdraft, #pl-btn-delete { margin-left: 0; }
#pl-btn-delete { color: var(--ui-danger); }
#pl-btn-delete:hover { background: #fef2f2; color: #b91c1c; }

/* ---------- Stepper (map guide bar) -------------------------------------- */
/* Kept deliberately compact: every pixel here is taken from the map. */
#pl-guide {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 4px 14px; min-height: 30px; flex-shrink: 0;
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ui-border);
}
.pl-guide-step {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px 2px 3px; border-radius: 999px;
  font-size: 10.5px; color: var(--ui-muted); background: #eef2f7;
  border: 1px solid transparent; white-space: nowrap;
  transition: all .2s ease;
}
.pl-guide-idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; color: var(--ui-muted);
  font-size: 8.5px; font-weight: 700; font-style: normal;
  border: 1px solid var(--ui-border-strong);
}
/* done */
.pl-guide-step.ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; font-weight: 600; }
.pl-guide-step.ok .pl-guide-idx {
  background: var(--ui-success); border-color: var(--ui-success); color: #fff;
}
.pl-guide-step.ok .pl-guide-idx::before { content: "✓"; }
.pl-guide-step.ok .pl-guide-idx { font-size: 9px; }
.pl-guide-step.ok .pl-guide-idx > span { display: none; }
/* current: the first step after the last completed one */
#pl-guide .pl-guide-step:first-child:not(.ok),
#pl-guide .pl-guide-step.ok + .pl-guide-arrow + .pl-guide-step:not(.ok) {
  background: #e0f2fe; color: var(--ui-primary-700);
  border-color: var(--ui-primary); font-weight: 700;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, .12);
}
#pl-guide .pl-guide-step:first-child:not(.ok) .pl-guide-idx,
#pl-guide .pl-guide-step.ok + .pl-guide-arrow + .pl-guide-step:not(.ok) .pl-guide-idx {
  background: var(--ui-primary); border-color: var(--ui-primary); color: #fff;
}
.pl-guide-arrow { color: #cbd5e1; font-size: 9px; padding: 0 1px; }
.pl-guide-step.ok + .pl-guide-arrow { color: var(--ui-success); }
.pl-guide-hint { margin-left: auto; font-size: 10px; color: var(--ui-muted); }

/* ---------- Steps accordion --------------------------------------------- */
#pl-step-list { max-height: 268px; overflow-y: auto; padding-right: 2px; }
.pl-step-total {
  margin-right: 8px; font-size: 10px; font-weight: 600;
  color: var(--ui-muted); font-variant-numeric: tabular-nums;
}
.pl-step-total.partial { color: var(--ui-primary-600); }

.step-group {
  margin-bottom: 4px; border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm); background: #fff; overflow: hidden;
}
.step-group.partial { border-color: #bae6fd; background: #f8fdff; }
.step-group-head { display: flex; align-items: center; }

.step-group-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; background: none; border: none; cursor: pointer;
  font-family: inherit; text-align: left; transition: background .15s ease;
}
.step-group-toggle:hover { background: #f1f5f9; }
.step-chev {
  font-size: 9px; color: var(--ui-muted); display: inline-block;
  transition: transform .18s ease; transform-origin: 50% 45%;
}
.step-group.collapsed .step-chev { transform: rotate(-90deg); }
.step-group-title {
  flex: 1; min-width: 0; font-size: 11px; font-weight: 600; color: var(--ui-text-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.step-group-count { font-size: 10px; color: var(--ui-dim); font-variant-numeric: tabular-nums; }
.step-group.partial .step-group-count { color: var(--ui-primary-600); font-weight: 700; }
.step-group-status {
  font-size: 10px; line-height: 1; margin-right: 4px; flex-shrink: 0;
  min-width: 9px; text-align: center;
}
.step-group-status.running { color: var(--ui-primary); }
.step-group-status.done { color: var(--ui-success); }
.step-group-status.failed { color: var(--ui-danger); font-weight: 700; }

.step-group-all {
  font-size: 9px; font-weight: 600; color: var(--ui-primary-600);
  background: none; border: none; cursor: pointer; padding: 3px 8px;
  margin-right: 4px; border-radius: 4px; font-family: inherit;
  visibility: hidden; white-space: nowrap; transition: background .15s ease;
}
.step-group-head:hover .step-group-all,
.step-group-all:focus { visibility: visible; }
.step-group-all:hover { background: #e0f2fe; }

.step-group-body { padding: 2px 6px 6px 8px; border-top: 1px solid #f1f5f9; }
.step-group.collapsed .step-group-body { display: none; }

.step-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--ui-text-soft); padding: 5px 7px;
  cursor: pointer; border-radius: 5px; border-left: 2px solid transparent;
  transition: background .15s ease, border-color .15s ease;
}
.step-item:hover { background: #f1f5f9; }
.step-item input[type="checkbox"] { margin: 0; flex-shrink: 0; accent-color: var(--ui-primary); }
.step-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-net { font-size: 9px; flex-shrink: 0; opacity: .7; }
.step-item input:not(:checked) ~ .step-item-text { color: #a9b4c0; }
.step-item.running {
  color: var(--ui-primary-700); font-weight: 600;
  background: #e0f2fe; border-left-color: var(--ui-primary);
}
.step-item.done { color: #047857; border-left-color: var(--ui-success); }
.step-item.failed {
  color: #b91c1c; font-weight: 600;
  background: #fef2f2; border-left-color: var(--ui-danger);
}
.step-status { flex-shrink: 0; font-size: 10px; line-height: 1; margin-left: 2px; }
.step-empty { font-size: 10px; color: var(--ui-dim); padding: 8px 4px; }
.step-empty.error { color: var(--ui-danger); }

/* ---------- Tunable parameter groups ------------------------------------ */
.pl-tunables-note {
  font-size: 10px; color: var(--ui-muted); margin-bottom: 8px;
  padding: 6px 8px; background: #f1f5f9; border-radius: var(--ui-radius-sm);
  line-height: 1.55;
}
.pl-tunables-note.locked { background: #fef3c7; color: #92400e; }

.tw-group {
  margin-bottom: 8px; padding: 8px 10px;
  background: #f8fafc; border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
}
.tw-group:last-child { margin-bottom: 0; }
.tw-group-title { font-size: 11px; font-weight: 700; color: var(--ui-text-soft); }
.tw-group-note { font-size: 9px; color: var(--ui-dim); line-height: 1.5; margin: 2px 0 7px; }

.tw-field { position: relative; display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tw-label {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--ui-text-soft);
}
.tw-control {
  display: flex; align-items: center; flex-shrink: 0;
  border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm);
  background: #fff; padding-right: 7px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.tw-control:focus-within { border-color: var(--ui-primary); box-shadow: var(--ui-ring); }
.tw-input {
  width: 66px; padding: 5px 7px; font-size: 11px; text-align: right;
  border: none; background: transparent; color: var(--ui-text); font-family: inherit;
}
.tw-input:focus { outline: none; }
.tw-input:disabled { color: var(--ui-dim); }
.tw-input.invalid { color: var(--ui-danger); }
.tw-control:has(.tw-input.invalid) { border-color: var(--ui-danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }
.tw-unit { font-size: 9px; color: var(--ui-dim); white-space: nowrap; }

/* "?" badge — hover or focus reveals the explanation */
.hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0;
  background: #e2e8f0; color: var(--ui-muted);
  font-size: 9px; font-weight: 700; line-height: 1; cursor: help;
  transition: background .15s ease, color .15s ease;
}
.tw-field:hover .hint,
.hint-host:hover .hint { background: #bae6fd; color: var(--ui-primary-700); }
.hint-bubble {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 30;
  background: #0f172a; color: #e2e8f0;
  font-size: 10px; line-height: 1.6; text-align: left;
  padding: 8px 10px; border-radius: var(--ui-radius-sm);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .3);
  opacity: 0; visibility: hidden; transition: opacity .14s ease;
  pointer-events: none;
}
.tw-field:hover > .hint-bubble,
.tw-field:focus-within > .hint-bubble { opacity: 1; visibility: visible; }
.hint-host { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.hint-host:hover > .hint-bubble,
.hint-host:focus-within > .hint-bubble { opacity: 1; visibility: visible; }
.hint-host > .hint-bubble { right: auto; width: 258px; }

/* ---------- Right column: map card + terminal log ----------------------- */
#pipeline-right {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; padding: 10px; gap: 8px;
}
#pipeline-map {
  flex: 1 1 auto; min-height: 300px;
  border-radius: var(--ui-radius-lg);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-md);
  background: #e2e8f0;
  overflow: hidden;
}

/* Map chrome */
#pipeline-map .leaflet-control-zoom {
  border: none; border-radius: var(--ui-radius-lg); overflow: hidden;
  box-shadow: var(--ui-shadow-md);
}
#pipeline-map .leaflet-control-zoom a {
  width: 34px; height: 34px; line-height: 34px;
  font-size: 17px; font-weight: 600; color: var(--ui-text-soft);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--ui-border);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: all .15s ease;
}
#pipeline-map .leaflet-control-zoom a:hover {
  background: #fff; color: var(--ui-primary-600);
}
#pipeline-map .leaflet-control-zoom a:last-child { border-bottom: none; }
#pipeline-map .leaflet-control-attribution {
  background: rgba(255, 255, 255, .78); border-radius: var(--ui-radius-sm) 0 0 0;
  font-size: 9px; color: var(--ui-muted); padding: 1px 7px;
}
#pipeline-map .leaflet-control-attribution a { color: var(--ui-primary-600); }
#pipeline-map .leaflet-bar a, #pipeline-map .leaflet-bar a:hover { border-radius: 0; }

/* Start/end popups as modern bubble cards */
#pipeline-map .leaflet-popup-content-wrapper {
  border-radius: var(--ui-radius-lg);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .22);
  border: 1px solid var(--ui-border);
  padding: 2px;
}
#pipeline-map .leaflet-popup-content {
  margin: 10px 14px; font-size: 12px; line-height: 1.6; color: var(--ui-text);
}
#pipeline-map .leaflet-popup-content b { color: var(--ui-primary-700); font-weight: 700; }
#pipeline-map .leaflet-popup-content b::before { content: "★ "; color: var(--ui-warn); }
#pipeline-map .leaflet-popup-tip { box-shadow: none; border: 1px solid var(--ui-border); }
#pipeline-map .leaflet-popup-close-button {
  width: 22px; height: 22px; top: 6px; right: 6px;
  font-size: 15px; line-height: 20px; color: var(--ui-dim);
  border-radius: 50%; transition: all .15s ease;
}
#pipeline-map .leaflet-popup-close-button:hover {
  background: #f1f5f9; color: var(--ui-text);
}
/* drawn rectangle + endpoint stars read better on satellite imagery */
#pipeline-map .leaflet-overlay-pane path { transition: stroke-width .15s ease; }
#pipeline-map .endpoint-star, #pipeline-map div[class=""] > .endpoint-star { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }

/* Terminal log — height adapts to the viewport so the map keeps its share.
   Roughly 5-8 lines depending on screen height, and scrollable either way. */
#pipeline-log-wrap {
  height: clamp(112px, 14vh, 168px); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--ui-term-bg);
  border: 1px solid #2d2d30;
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-md);
  overflow: hidden;
}
#pipeline-log-header {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; flex-shrink: 0;
  background: var(--ui-term-panel);
  border-bottom: 1px solid #333;
  font-size: 11px; font-weight: 600; color: #cccccc;
  font-family: "Cascadia Mono", Consolas, Menlo, monospace;
}
#pipeline-log-header::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: #ff5f56; box-shadow: 14px 0 0 #ffbd2e, 28px 0 0 #27c93f;
  margin-right: 30px;
}
#pl-log {
  flex: 1; overflow-y: auto;
  padding: 8px 12px;
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 11.5px; line-height: 1.65;
  color: var(--ui-term-text);
}
.log-line { color: #9ca3af; white-space: pre-wrap; word-break: break-all; }
.log-line.dim { color: #6b7280; }
.log-line.step-start { color: #4fc1ff; font-weight: 600; }
.log-line.step-start::before { content: "▸ "; color: #4fc1ff; }
.log-line.step-end { color: #4ec9b0; font-weight: 600; }
.log-line.step-end::before { content: "[OK] "; color: #4ec9b0; }
.log-line.error { color: #f48771; font-weight: 600; }
.log-line.error::before { content: "[ERR] "; }
.log-line.warn { color: #dcdcaa; }
.log-line.warn::before { content: "[WARN] "; }
#pl-log::-webkit-scrollbar { width: 8px; }
#pl-log::-webkit-scrollbar-track { background: #1e1e1e; }
#pl-log::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }
#pl-log::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* ---------- Responsive -------------------------------------------------- */
@media (max-width: 900px) {
  #tab-pipeline.active { flex-direction: column; }
  #pipeline-left { width: 100%; max-height: 46%; border-right: none; border-bottom: 1px solid var(--ui-border); }
  #pipeline-map { min-height: 200px; }
  #pipeline-log-wrap { height: clamp(96px, 16vh, 140px); }
  .pl-guide-hint { flex-basis: 100%; margin-left: 0; }
}

/* ============================================================
   AI Assistant — slide-out chat panel
   ============================================================ */

/* Floating toggle button — a FAB while the assistant is closed.
   It is hidden once the panel is open: besides the visual clutter, it sat at
   z-index 9999 directly over the panel's 发送 button (same bottom-right corner)
   and swallowed the clicks. The panel has its own ✕ close button, plus Esc and
   the backdrop, so hiding the FAB costs no way of closing it. */
#assistant-toggle {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff; border: none; font-size: 22px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(14, 165, 233, .38);
  transition: opacity .22s ease, transform .22s ease, box-shadow .22s ease;
  display: flex; align-items: center; justify-content: center;
}
#assistant-toggle:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 26px rgba(14, 165, 233, .48);
}
#assistant-toggle:active { transform: translateY(0) scale(1); }
#assistant-toggle:focus-visible { outline: 2px solid #4fc3f7; outline-offset: 3px; }
body:has(#assistant-panel.open) #assistant-toggle {
  opacity: 0; transform: scale(.72) translateY(10px); pointer-events: none;
}

/* Slide-out panel */
#assistant-panel {
  position: fixed; top: 0; right: -420px; z-index: 9998;
  width: 400px; height: 100vh;
  background: #fff;
  border-left: 1px solid var(--ui-border, #e5e9f0);
  box-shadow: -12px 0 32px rgba(15, 23, 42, .16);
  display: flex; flex-direction: column;
  transition: right .32s cubic-bezier(.4, 0, .2, 1), box-shadow .3s ease;
}
#assistant-panel.open { right: 0; }

/* Panel header */
#assistant-header {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  background: linear-gradient(135deg, #0369a1, #0ea5e9 70%, #38bdf8);
  color: #fff; flex-shrink: 0;
}
#assistant-header .title { font-size: 14.5px; font-weight: 700; flex: 1; }
#assistant-header .subtitle { font-size: 10px; opacity: .82; }
#assistant-close {
  background: rgba(255, 255, 255, .16); border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 50%; font-size: 15px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, transform .15s ease;
}
#assistant-close:hover { background: rgba(255, 255, 255, .28); transform: rotate(90deg); }

/* Messages area */
#chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: #F8FAFC;
}
.chat-msg {
  max-width: 88%; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.65; word-break: break-word;
}
.chat-msg.system {
  align-self: center; max-width: 92%;
  background: #e0f2fe; color: #0c4a6e;
  font-size: 11.5px; text-align: center; border-radius: 999px;
  padding: 7px 14px;
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, .22);
}
.chat-msg.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--ui-border, #e5e9f0);
  border-bottom-left-radius: 5px;
  color: #1f2937;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.chat-msg.assistant p { margin: 5px 0; }
.chat-msg.assistant h1, .chat-msg.assistant h2,
.chat-msg.assistant h3, .chat-msg.assistant h4 { font-size: 13.5px; margin: 9px 0 5px; color: #0369a1; }
.chat-msg.assistant ul, .chat-msg.assistant ol { margin: 4px 0; padding-left: 18px; }
.chat-msg.assistant li { margin: 2px 0; }
/* Tables and rules can appear in assistant replies (shared markdown renderer) */
.chat-msg.assistant .markdown-table-wrap { overflow-x: auto; margin: 6px 0; }
.chat-msg.assistant table { font-size: 12px; }
.chat-msg.assistant hr { border: none; border-top: 1px solid #E2E8F0; margin: 8px 0; }
.chat-msg.assistant code {
  background: #F1F5F9; padding: 1px 5px; border-radius: 3px;
  font-size: 12px; color: #0EA5E9;
}
.chat-msg.assistant pre {
  background: #0F172A; color: #E2E8F0; padding: 10px 14px;
  border-radius: 8px; overflow-x: auto; font-size: 11px; margin: 6px 0;
}
.chat-msg.assistant pre code { background: none; color: inherit; padding: 0; }

/* Loading dots */
.chat-msg.loading { padding: 16px 20px; }
.dot-pulse {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #94A3B8;
  animation: dotPulse 1.4s infinite ease-in-out both;
  position: relative;
}
.dot-pulse::before, .dot-pulse::after {
  content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #94A3B8; position: absolute; top: 0;
  animation: dotPulse 1.4s infinite ease-in-out both;
}
.dot-pulse::before { left: -16px; animation-delay: -0.32s; }
.dot-pulse::after  { left: 16px;  animation-delay: 0.32s; }
@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input area */
#assistant-input-area {
  padding: 10px 14px; border-top: 1px solid var(--ui-border, #e5e9f0);
  display: flex; gap: 8px; flex-shrink: 0; background: #fff;
}
#assistant-input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--ui-border-strong, #cbd5e1);
  border-radius: 8px; font-size: 13px; font-family: inherit;
  resize: none; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
#assistant-input:focus { border-color: #0ea5e9; box-shadow: 0 0 0 3px rgba(14, 165, 233, .14); }
#assistant-send {
  padding: 9px 18px; background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff; border: none; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(2, 132, 199, .3);
  transition: transform .12s ease, box-shadow .18s ease, filter .18s ease;
}
#assistant-send:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(2, 132, 199, .3); }
#assistant-send:active { transform: translateY(0); box-shadow: none; }
#assistant-send:disabled { background: #cbd5e1; box-shadow: none; cursor: not-allowed; }

/* Suggested questions */
#assistant-suggestions {
  padding: 8px 14px 10px; display: flex; gap: 6px; flex-wrap: wrap;
  border-top: 1px solid var(--ui-border, #e5e9f0); flex-shrink: 0; background: #fff;
}
.suggestion-chip {
  font-size: 10.5px; padding: 5px 11px; border-radius: 999px;
  background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd;
  cursor: pointer; white-space: nowrap;
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.suggestion-chip:hover {
  background: #e0f2fe; transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(2, 132, 199, .16);
}

/* Backdrop overlay */
#assistant-backdrop {
  position: fixed; inset: 0; z-index: 9997;
  background: rgba(0,0,0,0.3);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#assistant-panel.open ~ #assistant-backdrop { opacity: 1; pointer-events: auto; }

@media (max-width: 480px) {
  #assistant-panel { width: 100vw; right: -100vw; }
}

/* ============================================================
   Custom Modal (replaces browser alert/confirm)
   ============================================================ */
.custom-modal-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  animation: modalFadeIn 0.15s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.custom-modal {
  background: #FFF; border-radius: 12px;
  padding: 28px 32px 20px;
  max-width: 420px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  text-align: center;
  animation: modalSlideIn 0.2s ease;
}
@keyframes modalSlideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.custom-modal-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; margin-bottom: 12px;
}
.custom-modal-msg {
  font-size: 14px; color: #1E293B; line-height: 1.6;
  margin-bottom: 20px; white-space: pre-wrap;
}
.custom-modal-btns { display: flex; gap: 10px; justify-content: center; }
.custom-modal-btn {
  padding: 8px 28px; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: #FFF; transition: opacity 0.15s;
}
.custom-modal-btn:hover { opacity: 0.85; }
.custom-modal-btn.secondary {
  background: #E2E8F0; color: #475569;
}
.custom-modal-btn.secondary:hover { background: #CBD5E1; }

/* Text input inside a modal (used instead of window.prompt) */
.custom-modal-input {
  width: 100%; padding: 9px 12px; margin-bottom: 18px;
  border: 1px solid #CBD5E1; border-radius: 8px;
  font-size: 14px; font-family: inherit; color: #1E293B;
  text-align: left;
}
.custom-modal-input:focus {
  outline: none; border-color: #0EA5E9;
  box-shadow: 0 0 0 2px rgba(14,165,233,0.15);
}

/* ============================================================
   Console design layer — shared by the results tabs
   (路线总览 / 工程造价 / 模型评估 / 推荐报告)

   Presentation only: every id, class and JS-rendered structure that
   dashboard.js depends on is preserved.
   ============================================================ */

/* ---------- Page surfaces ------------------------------------------------ */
#tab-overview.active,
#tab-cost.active,
#tab-models.active,
#tab-report.active {
  background:
    radial-gradient(1100px 420px at 12% -10%, #e8eef7 0%, rgba(232, 238, 247, 0) 60%),
    #f5f7fa;
}

/* ---------- Tables (all four tabs) -------------------------------------- */
table { font-size: 12px; border-collapse: separate; border-spacing: 0; }
th, td {
  padding: 9px 12px; text-align: left;
  border-bottom: 1px solid #eef1f5;
  transition: background .15s ease;
}
th {
  position: sticky; top: 0; z-index: 1;
  background: #f7f9fc; color: #64748b;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap;
  border-bottom: 1px solid #e5e9f0;
}
tbody tr { transition: background .15s ease, box-shadow .15s ease; }
tbody tr:hover { background: #f0f7ff; }
tbody tr:last-child td { border-bottom: none; }
th[data-sortable] { cursor: pointer; user-select: none; }
th[data-sortable]:hover { color: #0284c7; background: #eef7ff; }
th[data-sortable]:focus-visible { outline: 2px solid #4fc3f7; outline-offset: -2px; }

/* Ranking table: bold rank, score pills, winner row highlighted */
#ranking-table td:nth-child(1) { font-weight: 700; color: #1f2937; font-variant-numeric: tabular-nums; }
#ranking-table td:nth-child(2) { color: #334155; }
#ranking-table td:nth-child(3),
#ranking-table td:nth-child(4) { font-variant-numeric: tabular-nums; white-space: nowrap; }
#ranking-table tbody tr:first-child { background: #ecfdf5; }
#ranking-table tbody tr:first-child:hover { background: #dcfce7; }
#ranking-table tbody tr:first-child td:nth-child(1)::before {
  content: "🏆"; margin-right: 4px; font-size: 10px;
}
#ranking-table tr.row-clickable.highlight { background: #e0f2fe; box-shadow: inset 3px 0 0 #0ea5e9; }

/* Score cells rendered as tags (markup comes from the ranking render fn) */
#ranking-table .score-tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.5;
}
#ranking-table .score-rf { background: #e0f2fe; color: #0369a1; }
#ranking-table .score-mlp { background: #f1f5f9; color: #64748b; font-weight: 600; }
#ranking-table tbody tr:first-child .score-rf { background: #d1fae5; color: #047857; }

/* Cost table: numeric columns right-aligned, total emphasised */
#cost-table th:not(:first-child), #cost-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
#cost-table td:nth-child(2) { font-weight: 800; color: #0369a1; }
#cost-table tbody tr:hover td:nth-child(2) { color: #075985; }

/* Metrics table: RF column emphasised (it is the model of record) */
#metrics-table td { font-variant-numeric: tabular-nums; }
#metrics-table th:nth-child(2), #metrics-table td:nth-child(2) { background: #f0f9ff; }
#metrics-table th:nth-child(3), #metrics-table td:nth-child(3) { background: #f8fafc; color: #64748b; }
#metrics-table td:first-child { color: #475569; font-weight: 600; }
#metrics-table tbody tr:hover td { background: #e8f4ff; }

/* ---------- Table toolbar / export chip --------------------------------- */
/* Inside a flex h3 the toolbar needs an auto margin (float is ignored there) */
.card h3 .table-toolbar { margin-left: auto; }
.table-toolbar { float: right; display: inline-flex; align-items: center; gap: 8px; font-weight: 400; text-transform: none; }
.table-count { font-size: 10px; color: #94a3b8; font-variant-numeric: tabular-nums; }
.table-export {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; color: #0369a1;
  background: #f0f9ff; border: 1px solid #bae6fd;
  border-radius: 999px; padding: 3px 10px; cursor: pointer; font-family: inherit;
  transition: all .15s ease;
}
.table-export:hover { background: #e0f2fe; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(2,132,199,.18); }
.table-export:active { transform: translateY(0); }

/* ---------- Map chrome for the overview map ----------------------------- */
#map .leaflet-control-zoom {
  border: none; border-radius: 10px; overflow: hidden;
  box-shadow: 0 4px 12px rgba(16,24,40,.10);
}
#map .leaflet-control-zoom a {
  width: 34px; height: 34px; line-height: 34px;
  font-size: 17px; font-weight: 600; color: #475569;
  background: rgba(255,255,255,.94); border-bottom: 1px solid #e5e9f0;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: all .15s ease;
}
#map .leaflet-control-zoom a:hover { background: #fff; color: #0284c7; }
#map .leaflet-control-zoom a:last-child { border-bottom: none; }
#map .leaflet-control-attribution {
  background: rgba(255,255,255,.78); border-radius: 6px 0 0 0;
  font-size: 9px; color: #64748b; padding: 1px 7px;
}
#map .leaflet-popup-content-wrapper {
  border-radius: 10px; border: 1px solid #e5e9f0; padding: 2px;
  box-shadow: 0 10px 28px rgba(15,23,42,.22);
}
#map .leaflet-popup-content { margin: 10px 14px; font-size: 12px; line-height: 1.65; color: #1f2937; }
#map .leaflet-popup-content b { color: #0369a1; }
#map .leaflet-popup-tip { box-shadow: none; border: 1px solid #e5e9f0; }
#map .leaflet-popup-close-button {
  width: 22px; height: 22px; top: 6px; right: 6px;
  font-size: 15px; line-height: 20px; color: #94a3b8;
  border-radius: 50%; transition: all .15s ease;
}
#map .leaflet-popup-close-button:hover { background: #f1f5f9; color: #1f2937; }
/* route legend becomes a floating card */
.route-legend { border-radius: 8px; border: 1px solid #e5e9f0; box-shadow: 0 4px 12px rgba(16,24,40,.12); }

/* ---------- Report prose ------------------------------------------------ */
#markdown-content { font-size: 13.5px; line-height: 1.85; color: #334155; }
#markdown-content h1,
#markdown-content h2,
#markdown-content h3 { color: #0f172a; letter-spacing: -0.01em; }
#markdown-content h1 { font-size: 20px; margin: 4px 0 14px; padding-bottom: 8px; border-bottom: 1px solid #e5e9f0; }
#markdown-content h2 {
  font-size: 16px; margin: 22px 0 10px; padding-left: 9px;
  border-left: 3px solid #0ea5e9;
}
#markdown-content h3 { font-size: 14px; margin: 16px 0 8px; color: #0369a1; }
#markdown-content p { margin: 8px 0; }
#markdown-content strong { color: #0f172a; }
#markdown-content ul, #markdown-content ol { margin: 8px 0; padding-left: 22px; }
#markdown-content li { margin: 3px 0; }
#markdown-content code {
  background: #f1f5f9; color: #0369a1;
  padding: 2px 6px; border-radius: 5px; font-size: 12px;
  font-family: "Cascadia Mono", Consolas, Menlo, monospace;
}
#markdown-content hr { border: none; border-top: 1px solid #e5e9f0; margin: 18px 0; }
#markdown-content .markdown-table-wrap {
  margin: 12px 0; border: 1px solid #e5e9f0;
  border-radius: 8px; overflow: auto; box-shadow: 0 1px 2px rgba(16,24,40,.05);
}
#markdown-content .markdown-table-wrap table { font-size: 12px; }
#markdown-content .md-img { border-radius: 8px; box-shadow: 0 4px 14px rgba(16,24,40,.12); }
#markdown-content .md-img-block { margin: 14px 0; }

/* ---------- Chart cards ------------------------------------------------- */
#chart-fi, #chart-radar { min-height: 120px; }
.chart-note { font-size: 10.5px; color: #94a3b8; margin: 8px 0 0; line-height: 1.55; }
