:root {
  --accent: #658d1b;
  --accent-soft: rgba(101, 141, 27, 0.16);
  --surface: rgba(246, 248, 250, 0.82);
  --surface-border: rgba(208, 215, 222, 0.9);
  --surface-elevated: rgba(255, 255, 255, 0.9);
  --ink: #1f2328;
  --ink-muted: #57606a;
}

html, body {
  font-feature-settings: "cv11", "ss01", "ss03";
  font-family: "Montserrat", "Open Sans", system-ui, -apple-system, sans-serif;
}

#map { background: #0d1117; }

.chart-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(208, 215, 222, 0.9);
  background: rgba(255, 255, 255, 0.95);
  padding: 8px;
}
.dark .chart-wrap {
  border-color: rgba(48, 54, 61, 0.9);
  background: rgba(13, 17, 23, 0.95);
}
.chart-wrap.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border-radius: 9999px;
  border: 3px solid rgba(101, 141, 27, 0.2);
  border-top-color: #658d1b;
  animation: chart-spin 720ms linear infinite;
  pointer-events: none;
}
.dark .chart-wrap.is-loading::after {
  border-color: rgba(137, 169, 73, 0.2);
  border-top-color: #89a949;
}
@keyframes chart-spin { to { transform: rotate(360deg); } }
.chart-stack { display: grid; grid-template-columns: 1fr; gap: 12px; }
.chart-card {
  border-radius: 12px;
  border: 1px solid rgba(208, 215, 222, 0.9);
  background: rgba(255, 255, 255, 0.78);
  padding: 12px;
}
.dark .chart-card {
  border-color: rgba(48, 54, 61, 0.9);
  background: rgba(22, 27, 34, 0.75);
}
.chart-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #334155;
  margin-bottom: 4px;
}
.dark .chart-title { color: #cbd5e1; }
.chart-ndvi-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 10px;
  color: #64748b;
}
.dark .chart-ndvi-legend {
  color: #94a3b8;
}
.chart-ndvi-legend li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chart-ndvi-swatch {
  width: 14px;
  height: 2px;
  border-radius: 1px;
}
.chart-ndvi-swatch--dense {
  background: #44b374;
}
.chart-ndvi-swatch--sparse {
  background: #c8921f;
}
.chart-wrap-cover { height: 340px; }
.chart-wrap-pdsi { height: 320px; }
.chart-wrap-ndvi { height: 300px; }
#watershedRapChart, #watershedPdsiChart, #watershedNdviChart {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.glass {
  background: var(--surface);
  -webkit-backdrop-filter: saturate(135%) blur(14px);
  backdrop-filter: saturate(135%) blur(14px);
  border: 1px solid var(--surface-border);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 1px 3px rgba(31, 35, 40, 0.12),
    0 8px 24px rgba(31, 35, 40, 0.08);
}
.dark .glass {
  background: rgba(22, 27, 34, 0.8);
  border: 1px solid rgba(48, 54, 61, 0.95);
  box-shadow:
    0 0 0 1px rgba(48, 54, 61, 0.75),
    0 8px 24px rgba(1, 4, 9, 0.35);
}

/* App switcher — shares layer-control glass + summary/list styling */
.brand-pill {
  min-width: 0;
  flex-shrink: 1;
}
.brand-pill .layer-control-summary > span {
  min-width: 0;
}
.brand-pill .layer-control-list {
  min-width: 14rem;
  max-width: 18rem;
}
.layer-control-list .app-switcher-item {
  display: block;
  padding: 4px 0;
  text-decoration: none;
  color: inherit;
}
.layer-control-list .app-switcher-item + .app-switcher-item {
  margin-top: 2px;
}
.layer-control-list .app-switcher-item:hover .app-switcher-label {
  color: #547617;
}
.dark .layer-control-list .app-switcher-item:hover .app-switcher-label {
  color: #89a949;
}
.app-switcher-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}
.app-switcher-sub {
  display: block;
  font-size: 11px;
  margin-top: 2px;
  color: rgba(31, 35, 40, 0.55);
}
.dark .app-switcher-sub {
  color: rgba(177, 186, 196, 0.7);
}

/* Mobile: hide app switcher when Layers panel is open so it has full header width */
@media (max-width: 639px) {
  header:has(#layersControl[open]) .brand-pill { display: none; }
  .brand-pill {
    max-width: calc(100vw - 7.5rem);
  }
  .brand-pill .layer-control-summary > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand-pill[open] .layer-control-list {
    min-width: 0;
    max-width: calc(100vw - 1.5rem);
  }
  .app-switcher-label {
    overflow-wrap: anywhere;
  }
}

.analysis-brand-mark {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: visible;
}
.analysis-logo {
  width: 30px; height: 30px;
  object-fit: contain; object-position: center;
  transform: scale(1.38) translateX(0.5px);
  transform-origin: center;
}

.panel-label {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.dark .panel-label { color: rgba(177, 186, 196, 0.85); }
.panel-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
}

.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 9999px;
  background: linear-gradient(to right, var(--accent) var(--progress, 50%), rgba(15, 23, 42, 0.08) var(--progress, 50%));
  outline: none;
  transition: background 120ms linear;
}
.dark .slider {
  background: linear-gradient(to right, var(--accent) var(--progress, 50%), rgba(241, 245, 249, 0.08) var(--progress, 50%));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #ffffff; border: 2px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(101, 141, 27, 0.35), 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-webkit-slider-thumb:active { transform: scale(0.95); }
.slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #ffffff; border: 2px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(101, 141, 27, 0.35);
}
.dark .slider::-webkit-slider-thumb { background: #0f172a; }
.dark .slider::-moz-range-thumb { background: #0f172a; }

.layer-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(15, 23, 42, 0.85);
  transition: background 120ms ease;
}
.dark .layer-row { color: rgba(226, 232, 240, 0.9); }
.layer-row:hover { background: rgba(15, 23, 42, 0.04); }
.dark .layer-row:hover { background: rgba(241, 245, 249, 0.05); }
.layer-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 5px;
  border: 1.5px solid rgba(15, 23, 42, 0.3);
  background: #ffffff;
  display: grid; place-content: center;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
  flex-shrink: 0;
}
.dark .layer-row input[type="checkbox"] {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(241, 245, 249, 0.25);
}
.layer-row input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
.layer-row input[type="checkbox"]:checked::after {
  content: ""; width: 8px; height: 8px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'><path d='M13.854 3.854a.5.5 0 0 0-.708-.708L6 10.293 2.854 7.146a.5.5 0 1 0-.708.708l3.5 3.5a.5.5 0 0 0 .708 0l7.5-7.5z'/></svg>");
  background-size: contain;
}

.status-chip {
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 11px; font-weight: 500;
  color: #57606a;
  background: rgba(31, 35, 40, 0.04);
  border: 1px solid rgba(208, 215, 222, 0.9);
}
.dark .status-chip {
  color: #b1bac4;
  background: rgba(22, 27, 34, 0.85);
  border-color: rgba(48, 54, 61, 0.9);
}
.status-chip.is-error {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.35);
}
.dark .status-chip.is-error {
  color: #fca5a5;
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(220, 38, 38, 0.45);
}

.scroll-shadow {
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.15) transparent;
}
.dark .scroll-shadow {
  scrollbar-color: rgba(241, 245, 249, 0.12) transparent;
}
.scroll-shadow::-webkit-scrollbar { width: 6px; }
.scroll-shadow::-webkit-scrollbar-track { background: transparent; }
.scroll-shadow::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
  border-radius: 9999px;
}
.dark .scroll-shadow::-webkit-scrollbar-thumb {
  background: rgba(241, 245, 249, 0.12);
}

/* Offcanvas */
.offcanvas {
  transform: translateX(-100%);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
  pointer-events: none;
}
.offcanvas > * { pointer-events: auto; }
.offcanvas.open { transform: translateX(0); }
@media (max-width: 1023px) { .offcanvas { z-index: 1100; } }

/* ---------- Mesic Watersheds: watershed summary (visual stat layout) ---------- */
.watershed-summary {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.stat-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stat-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0;
}
.dark .stat-section-title { color: rgba(177, 186, 196, 0.85); }

/* Stat bars (numeric metrics with a natural 0–100% range) */
.stat-bars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
@media (max-width: 480px) {
  .stat-bars { grid-template-columns: 1fr; }
}
.stat-bar {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.stat-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.stat-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.dark .stat-bar-label { color: #e6edf3; }
.stat-bar-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.dark .stat-bar-value { color: #e6edf3; }
.stat-bar-value.is-missing {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-style: italic;
  font-weight: 500;
  font-size: 11px;
  color: rgba(31, 35, 40, 0.45);
}
.dark .stat-bar-value.is-missing { color: rgba(177, 186, 196, 0.5); }
.stat-bar-unit {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-muted);
}
.dark .stat-bar-unit { color: rgba(177, 186, 196, 0.85); }
.stat-bar-track {
  position: relative;
  height: 8px;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.07);
  overflow: visible;
}
.dark .stat-bar-track { background: rgba(241, 245, 249, 0.08); }
.stat-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--w, 0%);
  background: var(--c, var(--accent));
  border-radius: 9999px;
  z-index: 1;
  transition: width 380ms cubic-bezier(0.22, 1, 0.36, 1);
}
.stat-bar[data-state="missing"] .stat-bar-track {
  background: repeating-linear-gradient(
    45deg,
    rgba(15, 23, 42, 0.04),
    rgba(15, 23, 42, 0.04) 4px,
    rgba(15, 23, 42, 0.09) 4px,
    rgba(15, 23, 42, 0.09) 8px
  );
}
.dark .stat-bar[data-state="missing"] .stat-bar-track {
  background: repeating-linear-gradient(
    45deg,
    rgba(241, 245, 249, 0.04),
    rgba(241, 245, 249, 0.04) 4px,
    rgba(241, 245, 249, 0.09) 4px,
    rgba(241, 245, 249, 0.09) 8px
  );
}
.stat-bar-scale {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  margin-top: 4px;
}
.dark .stat-bar-scale { color: rgba(177, 186, 196, 0.7); }

/* Stat rows (categorical / numeric values, table-style 2-col grid) */
.stat-rows {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  border-radius: 10px;
  border: 1px solid rgba(208, 215, 222, 0.9);
  background: rgba(208, 215, 222, 0.9);
  overflow: hidden;
}
.dark .stat-rows {
  border-color: rgba(48, 54, 61, 0.9);
  background: rgba(48, 54, 61, 0.9);
}
@media (min-width: 640px) {
  .stat-rows { grid-template-columns: 1fr 1fr; }
  /* Avoid a blank grid cell (gap fill) when row count is odd */
  .stat-row:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.85);
}
.dark .stat-row {
  background: rgba(22, 27, 34, 0.85);
}
.stat-row-label {
  font-weight: 500;
  color: var(--ink-muted);
  font-size: 11.5px;
}
.dark .stat-row-label { color: rgba(177, 186, 196, 0.85); }
.stat-row-value {
  font-weight: 600;
  color: var(--ink);
  font-size: 12px;
  text-align: right;
  max-width: 65%;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.dark .stat-row-value { color: #e6edf3; }
.stat-row-value.is-missing {
  font-style: italic;
  font-weight: 500;
  color: rgba(31, 35, 40, 0.45);
  font-size: 11px;
}
.dark .stat-row-value.is-missing { color: rgba(177, 186, 196, 0.5); }

/* Tier badge inside subtitle / summary cells */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.06);
  color: var(--ink);
  /* Allow the badge to shrink inside a truncating subtitle so a long tier
     label never pushes the panel header's action buttons off-screen. */
  max-width: 100%;
  min-width: 0;
  vertical-align: middle;
}
.dark .tier-badge {
  background: rgba(241, 245, 249, 0.08);
  color: #e6edf3;
}
.tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #94a3b8;
  flex-shrink: 0;
}
/* The label is a flex child so text-overflow: ellipsis can kick in even
   though the parent .tier-badge is inline-flex (which would otherwise be
   atomic and just clip). */
.tier-badge-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Layers panel — legends */
.legend-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink);
}
.dark .legend-list { color: #e6edf3; }
.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 11.5px;
}
/* Legend labels wrap instead of truncating, so long category names never
   force the layers panel wider than the viewport. */
.legend-item > span {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: break-word;
  min-width: 0;
}
.legend-item > .legend-swatch { margin-top: 3px; }
.legend-swatch {
  width: 16px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  flex-shrink: 0;
  background-clip: padding-box;
}
.dark .legend-swatch { border-color: rgba(255, 255, 255, 0.15); }
.legend-swatch--line {
  width: 18px;
  height: 0;
  border: 0;
  border-top-style: solid;
}
.legend-swatch--ramp {
  width: 100%;
  height: 10px;
  border-radius: 4px;
  border: 1px solid rgba(15, 23, 42, 0.18);
}
.dark .legend-swatch--ramp { border-color: rgba(255, 255, 255, 0.15); }
.legend-ramp {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 4px;
}
.legend-ramp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.dark .legend-ramp-labels { color: rgba(177, 186, 196, 0.85); }
.legend-block {
  margin: 4px 0 6px 26px;
  padding-left: 8px;
  border-left: 1px solid rgba(15, 23, 42, 0.06);
}
.dark .legend-block { border-left-color: rgba(241, 245, 249, 0.06); }
.legend-block:empty { display: none; }
.layer-row + .legend-block { margin-top: -2px; }

/* ---------- Print report ---------- */
@page { size: letter; margin: 0.55in 0.5in 0.6in; }

@media print {
  /* Most of the chrome is hidden — the report body owns the page. */
  body > *:not(#printReport) { display: none !important; }
  body {
    overflow: visible !important;
    background: #ffffff !important;
    color: #0f172a !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  html, body { height: auto !important; }
  #printReport {
    display: block !important;
    position: static !important;
    width: 100%;
    padding: 0;
    color: #0f172a;
    font-family: 'Montserrat', 'Open Sans', system-ui, -apple-system, sans-serif;
    font-size: 11px;
    line-height: 1.45;
    font-feature-settings: "tnum" 1, "lnum" 1;
  }

  /* ---------- Letterhead ---------- */
  #printReport .report-letterhead {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 10px;
    margin-bottom: 16px;
    border-bottom: 2px solid #658d1b;
  }
  #printReport .report-letterhead-mark {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  #printReport .report-letterhead-mark img {
    width: 40px; height: 40px;
    object-fit: contain;
    transform: scale(1.14);
    transform-origin: center;
  }
  #printReport .report-letterhead-copy { flex: 1; min-width: 0; }
  #printReport .report-letterhead-program {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #1f2937;
  }
  #printReport .report-letterhead-product {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #658d1b;
    margin-top: 1px;
  }
  #printReport .report-letterhead-meta {
    text-align: right;
    font-size: 10px;
    color: #64748b;
    line-height: 1.35;
  }

  /* ---------- Title block ---------- */
  #printReport .report-title-block { margin-bottom: 14px; }
  #printReport h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
    color: #0f172a;
  }
  #printReport .report-title-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10.5px;
    color: #475569;
  }
  #printReport .tier-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #658d1b;
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #printReport .report-id { color: #64748b; }
  #printReport .report-id code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #1f2937;
  }

  /* ---------- Section primitives ---------- */
  #printReport h2 {
    font-size: 10.5px;
    font-weight: 700;
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #658d1b;
  }
  #printReport .report-section { page-break-inside: avoid; }
  #printReport .report-section + .report-section { margin-top: 10px; }
  /* Inside the summary grid, row-gap handles vertical spacing — clear the
     adjacent-sibling margin so paired tables share a top edge. */
  #printReport .report-summary-grid > .report-section { margin-top: 0; }
  #printReport .report-section-lede {
    font-size: 10px;
    color: #64748b;
    margin: 0 0 8px;
  }

  /* ---------- Map ---------- */
  #printReport .report-section-map { margin-bottom: 14px; }
  #printReport .report-map {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    page-break-inside: avoid;
  }
  #printReport .report-map img { width: 100%; height: auto; display: block; }
  #printReport .report-map-caption {
    font-size: 9.5px;
    color: #64748b;
    font-style: italic;
    margin: 4px 0 0;
  }

  /* ---------- Summary grid (geometry / persistence / land cover) ---------- */
  #printReport .report-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 18px;
    row-gap: 12px;
    margin-bottom: 14px;
  }
  /* Persistence section spans full width so the bar is readable. */
  #printReport .report-summary-grid > .report-section:last-child {
    grid-column: 1 / -1;
  }

  /* ---------- Tables ---------- */
  #printReport .report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10.5px;
  }
  #printReport .report-table th,
  #printReport .report-table td {
    text-align: left;
    padding: 5px 0;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: baseline;
  }
  #printReport .report-table th {
    font-weight: 500;
    color: #475569;
    width: 55%;
  }
  #printReport .report-table td {
    font-weight: 600;
    color: #0f172a;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  #printReport .report-table tr:last-child th,
  #printReport .report-table tr:last-child td { border-bottom: none; }

  /* ---------- Persistence stacked bar ---------- */
  #printReport .report-bar {
    display: flex;
    width: 100%;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: #f1f5f9;
    margin: 6px 0 8px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #printReport .report-bar-seg {
    height: 100%;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #printReport .report-bar-legend {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px 12px;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 10.5px;
  }
  #printReport .report-bar-legend li {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }
  #printReport .report-bar-dot {
    width: 8px; height: 8px;
    border-radius: 999px;
    flex-shrink: 0;
    transform: translateY(1px);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #printReport .report-bar-key { color: #475569; flex: 1; }
  #printReport .report-bar-val {
    font-weight: 600;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
  }

  /* ---------- Time series ---------- */
  #printReport .report-section-charts {
    page-break-before: always;
    padding-top: 4px;
  }
  #printReport .report-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }
  #printReport .report-chart {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 12px;
    page-break-inside: avoid;
  }
  #printReport .report-chart h3 {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 6px;
    color: #475569;
  }
  #printReport img.report-chart-img {
    width: 100%;
    height: auto;
    display: block;
  }

  /* ---------- Footer ---------- */
  #printReport .report-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e2e8f0;
    margin-top: 18px;
    padding-top: 8px;
    font-size: 9px;
    color: #94a3b8;
    letter-spacing: 0.02em;
  }
  #printReport .report-footer-brand { font-weight: 600; color: #475569; }
}
#printReport { display: none; }

/* Hover tooltip */
.feature-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 1100;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(13, 17, 23, 0.92);
  color: #f0f6fc;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transform: translate(12px, 12px);
}
.feature-tooltip[hidden] { display: none; }
/* On touch devices a hover tooltip has no real "hover" — a tap fires
   mousemove+click, so the tooltip would briefly flash on top of the
   analysis pop-out. Suppress it entirely when the pointer can't hover. */
@media (hover: none) {
  .feature-tooltip { display: none !important; }
}

/* Toast */
.toast {
  background: rgba(220, 38, 38, 0.96);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  max-width: 520px;
  text-align: center;
}