:root {
  --bg: #fcf8ed;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #FFFFFF;
  --surface-hover: #FFFFFF;
  --border: rgba(28, 42, 33, 0.10);
  --border-strong: rgba(28, 42, 33, 0.20);
  --hover: rgba(28, 42, 33, 0.05);
  --text: #1C2A21;
  --text-secondary: #46564B;
  --text-muted: #7A887D;
  --accent: #76a193;
  --accent-dim: #A9B9C9;
  --accent-soft: rgba(78, 100, 120, 0.10);
  --shadow: 0 1px 2px rgba(28, 42, 33, 0.04), 0 4px 16px rgba(28, 42, 33, 0.05);

  /* top bar */
  --topbar-bg: #7f9c88;
  --topbar-text: #EDE8DC;
  --topbar-text-2: #C3CFC4;
  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --panel-w: 420px;
  --drawer-w: 352px;
  --lot-w: 340px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  color: var(--text);
  font-family: var(--font-sans);
  background: var(--bg);
}

body { position: relative; overflow: hidden; overflow-x: hidden;}


/* ---------- App shell ---------- */

.app {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
}

.app[hidden] { display: none; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  margin-bottom: 16px;
  position: relative; z-index: 20;
  flex: none;
  background: var(--topbar-bg);
}

.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }

.brand-logo { height: 36px; width: auto; display: block; }

.brand-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.22); }

.brand-name { font-size: 13px; letter-spacing: 0.01em; color: var(--topbar-text-2); font-weight: 500; white-space: nowrap; }

.topbar :focus-visible { outline-color: var(--topbar-text-2); }

/* ---------- Workspace: map + side panel ---------- */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 16px;
  padding: 0 20px 20px;
}

.map-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #E9ECE6;
  box-shadow: var(--shadow);
  min-height: 0;
}

#viewDiv { position: absolute; inset: 0; }

.map-status {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  max-width: 360px; text-align: center;
  font-size: 13.5px; line-height: 1.55; color: var(--text-secondary);
  padding: 16px 20px;
  background: var(--surface); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 5;
}

.map-status[hidden] { display: none; }

.map-status.error { color: var(--text); border-color: rgba(200,70,60,0.45); }

.map-status a { color: var(--accent); }

.panel {
  flex: 1; 
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex; 
  flex-direction: column; 
  gap: 12px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(28,42,33,0.2) transparent;
}

.panel-head { padding: 6px 4px 6px; }

.eyebrow { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; margin-bottom: 6px; }

.panel-head h1 {
  font-family: var(--font-serif); font-weight: 500;
  font-size: 30px; line-height: 1.15; letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.lede { font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); margin-bottom: 16px; }

.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}

.seg-btn {
  flex: 1;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary); background: transparent;
  border: 1px solid transparent; border-radius: 6px;
  padding: 8px 6px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.seg-btn:hover { color: var(--text); background: var(--hover); }

.seg-btn.active { color: #FFFFFF; background: var(--accent); border-color: var(--accent); }

.seg-btn:disabled { opacity: 0.45; cursor: default; }

.card {
  background: var(--surface); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px 18px;
}

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

.card h2 { font-family: var(--font-serif); font-size: 18px; font-weight: 500; }

.badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap;
}

.badge.live { color: #3F8A55; }

.badge.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }



/* ============================================================

   STREETLIGHT KPI SUMMARY — CLEAN CARD LAYOUT

   ============================================================ */

.kpi-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.kpi-total {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--surface, #f7f8f6);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #819086);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-total-value {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text, #24352b);
  font-variant-numeric: tabular-nums;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kpi-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
}

.kpi-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-indicator {
  flex-shrink: 0;
  width: 4px;
  height: 15px;
  border-radius: 3px;
}

.kpi-value {
  font-size: 23px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text, #24352b);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 320px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================

   DONUT CHART

   ============================================================ */

/* Donut container */
.donut-wrap {
  position: relative;
  width: 190px;
  height: 190px;
  margin: 2px auto 16px;
}

/* SVG chart */
.donut {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================

   DONUT SEGMENTS

   ============================================================ */

/* ============================================================

   1. CHART AND LEGEND LAYOUT

   ============================================================ */

/* Desktop: Donut chart on left, legend on right. */
.status-chart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  width: 100%;
}

/* Chart column */
.status-chart-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

/* Legend column */
.status-chart-legend {
  width: 100%;
  min-width: 0;
}

/* Legend list */
.status-chart-legend .lu-list {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Allow long status labels to wrap. */
.status-chart-legend .lu-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ============================================================

   3. INTERACTIVE DONUT SEGMENTS

   ============================================================ */

/* Default segment appearance */
.donut .donut-segment {
  opacity: 1;
  cursor: pointer;
  outline: none;
  stroke: var(--surface-solid);
  stroke-width: 1px;
  -webkit-tap-highlight-color: transparent;
  transition:
    opacity 350ms ease-in-out,
    filter 350ms ease-in-out,
    stroke-width 250ms ease;
}

/* Selected segment */
.donut .donut-segment.is-selected { opacity: 1; }

/* Dim unselected segments */
.donut .donut-segment.is-muted { opacity: 0.45; }

/* Hover over muted segments */
.donut .donut-segment.is-muted:hover { opacity: 0.8; }

/* Hover over normal or selected segments */
.donut .donut-segment:not(.is-muted):hover { filter: brightness(1.08); }

/* ------------------------------------------------------------

   KEYBOARD FOCUS

   ------------------------------------------------------------ */

/* Remove the default rectangular SVG focus outline. */

.donut .donut-segment:focus,
.donut .donut-segment:focus-visible {
  outline: none;
}

/* Highlight the focused segment for keyboard navigation. */
.donut .donut-segment:focus-visible {
  filter: brightness(1.12);
  stroke-width: 3px;
}

/* ============================================================

   4. DONUT CENTER

   ============================================================ */

/* Center content over the SVG donut. */

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 44px;
  text-align: center;
  pointer-events: none;
}

/* Total value */
.dc-value {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Smaller total value */

.dc-value.sm {
  font-size: 17px;
  line-height: 1.2;
}

/* Total label */
.dc-label {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.3;
}

/* ============================================================

   5. RESPONSIVE LAYOUT

   ============================================================ */

/* Mobile: Stack the donut chart above the legend. */

@media (max-width: 767px) {

  .status-chart-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .donut-wrap { margin: 0 auto; }

  .status-chart-legend { width: 100%; }

}

/* ============================================================

   6. REDUCED MOTION

   ============================================================ */

/* Respect users who prefer reduced animation. */
@media (prefers-reduced-motion: reduce) {

  .donut .donut-segment { transition: none; }

}

/* ============================================================

   STATUS LEGEND

   ============================================================ */

/* Legend container */
.lu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Legend item */
.lu-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  opacity: 1;
  transition:
    opacity 350ms ease-in-out,
    background-color 250ms ease,
    color 250ms ease,
    border-color 250ms ease;
}

/* Hover */
.lu-row:hover {
  background: var(--hover);
  color: var(--text);
}

/* Selected status */
.lu-row.is-selected {
  opacity: 1;
  background: var(--accent-soft);
  border-color: var(--accent-dim);
  color: var(--text);
}

/* Unselected statuses */
.lu-row.is-muted { opacity: 0.5; }

/* Hover over an unselected status */
.lu-row.is-muted:hover { opacity: 0.85; }

/* Keyboard focus */
.lu-row:focus-visible { outline: 2px solid var(--accent-dim); outline-offset: 2px; }

/* ============================================================

   ACCESSIBILITY — REDUCED MOTION

   ============================================================ */

@media (prefers-reduced-motion: reduce) {

  .donut .donut-segment, .lu-row { transition: none; }

}

/* ============================================================

   MAP — COMPACT DRONE IMAGERY TOGGLE

   ============================================================ */

.map-imagery-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  font-family: var(--font-sans, Arial, sans-serif);
  position: relative;
  z-index: 10;
}

.map-toggle-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.map-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.map-toggle-track {
  position: relative;
  display: inline-block;
  width: 24px;
  height: 14px;
  background: #cbd0cd;
  border-radius: 999px;
  transition: background-color 220ms ease;
}

.map-toggle-track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  transition: transform 220ms ease;
}

.map-toggle-input:checked + .map-toggle-track { background: #4d9a81; }

.map-toggle-input:checked + .map-toggle-track::before { transform: translateX(10px); }

.map-toggle-input:focus-visible + .map-toggle-track { outline: 2px solid #327e68; outline-offset: 3px; }

.map-toggle-input:disabled + .map-toggle-track { opacity: 0.5; cursor: not-allowed; }

.map-toggle-label { font-size: 11px; line-height: 1; color: #44534d; }

.lu-list.has-focus .lu-row:not(.focus) { opacity: 0.55; }

/* hairline so pale land-use colours still read on white */
.lu-swatch { width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(28,42,33,0.12); }

.lu-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lu-ha { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.lu-pct { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; min-width: 44px; text-align: right; }

.text-btn {
  margin-top: 10px; background: none; border: none; cursor: pointer;
  color: var(--accent); font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  padding: 4px 8px;
}

.text-btn:hover { color: var(--text); }

.panel-foot { font-size: 11px; line-height: 1.6; color: var(--text-muted); padding: 4px 4px 2px; }

.layer-line { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; word-break: break-all; }

/* ============================================================

   ARCGIS WIDGETS — LIGHT THEME

   ============================================================ */

.esri-view .esri-view-surface--inset-outline:focus::after { outline: none !important; }

.esri-ui .esri-widget,
.esri-ui .esri-widget--button,
.esri-popup__main-container,
.esri-popup .esri-widget {
  background-color: #FFFFFF !important;
  color: var(--text) !important;
  font-family: var(--font-sans);
}

.esri-ui .esri-widget--button {
  color: var(--text-secondary) !important;
}

.esri-ui .esri-widget--button:hover {
  background-color: #F1F3EF !important;
  color: var(--text) !important;
}

.esri-ui-corner .esri-component {
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.esri-attribution {
  background: rgba(255, 255, 255, 0.85) !important;
  color: var(--text-muted) !important;
}

.esri-attribution a {
  color: var(--text-secondary) !important;
}

.esri-scale-bar__line {
  background: rgba(255, 255, 255, 0.7) !important;
}

.esri-scale-bar__label {
  color: var(--text-secondary) !important;
}

.esri-popup__header-title,
.esri-feature__title {
  font-family: var(--font-serif) !important;
  font-size: 17px !important;
  font-weight: 500 !important;
}

/* ============================================================

   CUSTOM STREETLIGHT POPUP — LIGHT THEME

   ============================================================ */

.feature-popup {
  position: absolute;
  top: 16px;
  right: 16px;
  left: auto;
  bottom: auto;
  z-index: 50;
  width: 320px;
  max-width: calc(100% - 32px);
  max-height: min(420px, calc(100% - 32px));

  background-color: #FFFFFF;
  color: var(--text);
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);

  transform: none;
  overflow: hidden;
  pointer-events: auto;

}

.feature-popup[hidden] {
  display: none !important;
}

/* Popup content scrolls when there are many attributes */
.feature-popup-body {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 16px 14px;
  scrollbar-width: thin;
}

/* ==========================================================

   RESPONSIVE POPUP

   ========================================================== */

@media (max-width: 480px) {

  .feature-popup {
    top: 12px;
    right: 12px;
    width: 280px;
    max-width: calc(100% - 24px);
    max-height: min(360px, calc(100% - 24px));
  }

  .feature-popup-body {
    max-height: 220px;
  }

}

/* ==========================================================

   POPUP HEADER

   ========================================================== */

.feature-popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  background-color: #FFFFFF;
  border-bottom: 1px solid var(--border);
}

.feature-popup-eyebrow {
  display: block;
  margin-bottom: 5px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.feature-popup-header h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
}

/* ==========================================================

   POPUP CLOSE BUTTON

   ========================================================== */

.feature-popup-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.feature-popup-close:hover {
  background-color: #F1F3EF;
  color: var(--text);
}

.feature-popup-close:focus-visible {
  outline: 2px solid var(--text-secondary);
  outline-offset: 2px;
}

/* ==========================================================

   POPUP STATUS

   ========================================================== */

.feature-popup-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: #FFFFFF;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.feature-popup-status i {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  border-radius: 50%;
}

/* ==========================================================

   POPUP CONTENT

   ========================================================== */

.feature-popup-body {
  padding: 4px 16px 14px;
  max-height: 280px;
  overflow-y: auto;
  background-color: #FFFFFF;
  font-family: var(--font-sans);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.feature-popup-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.5;
}

.feature-popup-row:last-child {
  border-bottom: none;
}

.feature-popup-row span {
  flex: 1;
  color: var(--text-muted);
}

.feature-popup-row strong {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  text-align: right;
  overflow-wrap: anywhere;
}

/* ==========================================================

   RESPONSIVE POPUP

   ========================================================== */

@media (max-width: 480px) {

  .feature-popup {
    width: 280px;
    max-height: 360px;
  }

  .feature-popup-header {
    padding: 12px 14px;
  }

  .feature-popup-body {
    max-height: 220px;
    padding: 4px 14px 12px;
  }

  .feature-popup-row {
    gap: 10px;
    font-size: 11px;
  }

}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {

  * { transition: none !important; }

}


/* ---------- Side wrapper ---------- */
.side { position: relative; min-height: 0; display: flex; }



/* ============================================================

   SEARCH — STREETLIGHTS DASHBOARD

   ============================================================ */

/* ============================================================

   1. SEARCH CARD

   ============================================================ */

/* Keep search dropdown above the Phase filter card. */
.search-card {
  position: relative;
  z-index: 5;
  overflow: visible;
}

/* Development Phase card. */
.phase-filter-card {
  position: relative;
  z-index: 1;
}

/* Space between Phase buttons and clear filters. */
.phase-filter-card .text-btn { margin-top: 12px; }

/* ============================================================

   2. SEARCH CONTAINER

   ============================================================ */

.search {
  position: relative;
  width: 100%;
  margin: 0;
}

.search[hidden] { display: none; }

/* ============================================================

   3. SEARCH MODES

   ============================================================ */

.search-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.search-mode {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease;
}

.search-mode:hover {
  background: var(--hover);
  color: var(--text);
}

.search-mode.active {
  background: var(--text);
  border-color: var(--text);
  color: #ffffff;
}

.search-mode:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================

   4. SEARCH INPUT BOX

   ============================================================ */

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition:
    border-color 200ms ease,
    box-shadow 200ms ease;
}

.search-box:hover {
  border-color: var(--accent-dim, var(--accent));
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ------------------------------------------------------------

   SEARCH ICON

   ------------------------------------------------------------ */

.search-box > svg,
.search-box > .bi-search {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ------------------------------------------------------------

   SEARCH INPUT

   ------------------------------------------------------------ */

#searchInput {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 10px 0;
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
}

#searchInput::placeholder { color: var(--text-muted); }

/* Hide native browser clear button. */
#searchInput::-webkit-search-cancel-button { display: none; }

/* ============================================================

   5. CLEAR SEARCH BUTTON

   ============================================================ */

.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background-color 200ms ease,
    color 200ms ease;
}

.search-clear[hidden] {
  display: none;
}

.search-clear:hover {
  background: var(--hover);
  color: var(--text);
}

.search-clear:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================

   6. SEARCH RESULTS DROPDOWN

   ============================================================ */

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 340px;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(28, 42, 33, 0.16);
}

.search-results[hidden] { display: none; }

/* ============================================================

   7. SEARCH RESULT ITEMS

   ============================================================ */

.search-hit {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}

.search-hit:hover,
.search-hit.cursor {
  background: var(--accent-soft);
}

.search-hit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ------------------------------------------------------------

   RESULT NAME

   ------------------------------------------------------------ */

.sh-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------

   RESULT METADATA

   ------------------------------------------------------------ */

.sh-meta {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sh-meta .ll-sw {
  vertical-align: middle;
}

/* ============================================================

   8. SEARCH RESULT GROUPS

   ============================================================ */

.search-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 4px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.search-group:not(:first-child) {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.search-group span {
  font-weight: 500;
  letter-spacing: 0;
}

/* ============================================================

   9. SEARCH SUMMARY AND EMPTY STATE

   ============================================================ */

.search-summary,
.search-empty {
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.5;

}

.search-empty {
  text-align: center;
}

/* ============================================================

   10. RESPONSIVE STYLES

   ============================================================ */

@media (max-width: 480px) {
  .search-box {
    min-height: 42px;
  }

  .search-results {
    max-height: 280px;
  }

  .search-hit {
    gap: 8px;
    font-size: 12.5px;
  }

  .sh-meta {
    font-size: 11px;
  }

}

/* ============================================================

   11. REDUCED MOTION

   ============================================================ */

@media (prefers-reduced-motion: reduce) {

  .search-mode,
  .search-box,
  .search-clear,
  .search-hit {
    transition: none;
  }

}


/* ---------- Figures (stats-panel.js ---------- */

.stats-cards { display: flex; flex-direction: column; gap: 12px; }

.filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; margin: 2px 0 6px; }

.sub-h { margin: 16px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }

.hint, .icon-note { margin-top: 6px; font-size: 11.5px; color: var(--text-muted); }

.note { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: rgba(224, 178, 74, 0.13); font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) { :root { --panel-w: 360px; } }

@media (max-width: 860px) {

  body { overflow: auto; }

  .app { height: auto; min-height: 100dvh; }

  .workspace { grid-template-columns: 1fr; padding: 0 16px 16px; }

  .map-wrap { height: 62vh; min-height: 360px; }

  .panel { overflow: visible; padding-right: 0; }

  .topbar { padding: 12px 16px; }

  .brand-logo { height: 30px; }

  /* drawer becomes a collapsible card above the panel */
  :root { --drawer-w: calc(100vw - 72px); --lot-w: calc(100vw - 56px); }

}

@media (max-width: 480px) {

  .brand-divider, .brand-name { display: none; }

  .kpi-value { font-size: 23px; }

  .util-btn { padding: 8px; }

}

/* =========================================

   NAVIGATION SIDEBAR

   ========================================= */

.app {
  --nav-width: 220px;
  padding-left: var(--nav-width);
  transition: padding-left 0.25s ease;
}

.app.nav-collapsed { --nav-width: 64px; }

.s-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--nav-width);
  background: var(--topbar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  transition: width 0.25s ease;
  box-sizing: border-box;
}

.s-sidebar-head {
  min-height: 76px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.s-sidebar-toggle {
  background: transparent;
  border: 0;
  color: white;
  cursor: pointer;
  font-size: 21px;
  padding: 8px;
  flex-shrink: 0;
}

.s-sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 8px;
}

.s-nav-item {
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 46px;
  padding: 0 14px;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.s-nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.s-nav-item.active {
  background: rgba(255,255,255,0.17);
  color: #fff;
  font-weight: 600;
}

.s-nav-item .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.s-nav-item .nav-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.nav-label {
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.4;
  min-width: 0;
}

.s-sidebar-foot {
  margin-top: auto;
  padding: 20px;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

/* Collapsed state */
.nav-collapsed .s-sidebar .nav-label {
  display: none;
}

.nav-collapsed .s-sidebar-head {
  justify-content: left;
  padding: 0 14px;
}

.nav-collapsed .s-nav-item {
  justify-content: center;
  padding: 0;
}

.nav-collapsed .s-sidebar-foot {
  padding: 12px 0;
}

/* =========================================

   MOBILE s NAVIGATION

   ========================================= */

@media (max-width: 768px) {

  /* Remove desktop sidebar spacing */
  .app,
  .app.nav-collapsed {
    --nav-width: 0px;
    padding-left: 0;
  }

  /* Navigation becomes a top bar */
  .s-sidebar {
    position: relative;
    top: auto;
    left: auto;
    bottom: auto;
    width: 100% !important;
    height: auto;
    overflow: visible;
    flex-shrink: 0;
  }

  /* Top bar heading */
  .s-sidebar-head {
    min-height: 54px;
    padding: 0 16px;
  }


  /* Hide page links until menu opens */
  .s-sidebar-links {
    display: none;
    padding: 8px 12px 14px;
    flex-direction: column;
    gap: 4px;
  }

  /* Show page links when expanded */
  .app.mobile-nav-open .s-sidebar-links {
    display: flex;
  }

  .s-nav-item,
  .nav-collapsed .s-nav-item {
    justify-content: flex-start;
    padding: 0 14px;
    min-height: 44px;
  }

  .s-sidebar .nav-label,
  .nav-collapsed .s-sidebar .nav-label {
    display: inline;
  }

  .s-sidebar-foot {
    display: none;
  }

  /* Keep the existing page below navigation */
  .workspace {
    width: 100%;
    min-width: 0;
  }

  .nav-collapsed .s-sidebar-head {
    justify-content: left;
    padding:0 14px
  }

}

/* ==========================================

   KEEP NAVIGATION FIXED DURING TRANSITIONS

   ========================================== */

/* Prevent application padding from animating */
body.page-leaving .app,
body.page-entering .app {
  transition: none !important;
}

/* Animate only the workspace */
body.page-leaving .workspace {
  animation: sLeave 750ms
    cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

body.page-entering .workspace {
  animation: sEnter 750ms
    cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ==========================================

   s SINGLE PAGE LAYOUT

   ========================================== */

.s-pages {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.s-page {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.s-page.active {
  display: flex;
  flex-direction: column;
}

.s-page[hidden] {
  display: none !important;
}

.s-page .workspace {
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* Optional smooth page transition */
.s-page.active {
  animation: sPageEnter 400ms ease-out;
}

@keyframes sPageEnter {

  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }

}

@media (prefers-reduced-motion: reduce) {

  .s-page.active {
    animation: none;
  }

}


/* ============================================================
   RESPONSIVE REFINEMENTS — NAVIGATION AND SEARCH PRESERVED

   These rules only adjust available space and dimensions.
   They do not change sidebar positioning or search anchoring.
   The existing navigation breakpoint remains 768px.
   ============================================================ */

/* Allow grid children and cards to shrink without horizontal overflow. */
.workspace > *,
.panel,
.stats-cards,
.card,
.search-card,
.search,
.search-box {
  min-width: 0;
}

/* Donut and legend fit within their card without changing placement. */
.status-chart-visual .donut-wrap {
  width: min(190px, 100%);
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto;
}

/* Mobile portrait: map above the panel, using the existing sidebar layout. */
@media (max-width: 768px) and (orientation: portrait) {
  .workspace {
    gap: 12px;
    padding: 0 12px 16px;
  }

  .map-wrap {
    height: 45dvh;
    min-height: 260px;
  }

  .panel {
    overflow: visible;
    padding-right: 0;
  }

  .card { padding: 14px; }

  .status-chart-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .search-results {
    max-height: min(300px, 45dvh);
  }

  .feature-popup {
    max-width: calc(100% - 24px);
  }
}

/* Mobile landscape: compact map, without changing navigation behavior. */
@media (max-width: 768px) and (orientation: landscape) {
  .workspace {
    gap: 10px;
    padding: 0 12px 12px;
  }

  .map-wrap {
    height: 65dvh;
    min-height: 180px;
  }

  .panel {
    overflow: visible;
    padding-right: 0;
  }

  .card { padding: 12px 14px; }

  .status-chart-layout {
    grid-template-columns: minmax(0, 170px) minmax(0, 1fr);
    gap: 12px;
  }

  .status-chart-visual .donut-wrap { width: min(160px, 100%); }

  .search-results { max-height: min(200px, 55dvh); }

  .feature-popup {
    max-height: calc(100% - 16px);
  }
}

/* Extra-narrow phones: allow KPI and legend content to fit. */
@media (max-width: 350px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .lu-row { gap: 5px; }
  .lu-pct { min-width: 0; }
}


