/* =================================================================
   HelioTwin — Application Styles
   Layout, structural chrome, components, map overlays, overrides.
   All colour/spacing values reference tokens.css custom properties.
   No hardcoded values. No gradients. No shadows heavier than 1px border.
   ================================================================= */

/* ── RESET ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: var(--font-sans);
  font-size: var(--text-base); color: var(--c-text-primary);
  background: var(--c-white); -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; }
a { color: var(--c-blue-600); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── APP SHELL ──────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── WORKFLOW RAIL ──────────────────────────────────────────────── */
#workflow-rail {
  width: var(--rail-collapsed);
  min-width: var(--rail-collapsed);
  background: var(--c-rail-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 200;
  overflow: hidden;
  transition: width var(--t-rail), min-width var(--t-rail);
  border-right: 1px solid #161a1f;
}
#workflow-rail:hover {
  width: var(--rail-expanded);
  min-width: var(--rail-expanded);
}
.rail-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-3);
  height: var(--topbar-height);
  border-bottom: 1px solid var(--c-rail-divider);
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
}
.rail-logo-mark {
  width: 28px;
  height: 28px;
  background: var(--c-blue-600);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--w-semibold);
  color: var(--c-white);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.rail-app-name {
  font-size: var(--text-base);
  font-weight: var(--w-semibold);
  color: var(--c-rail-active);
  white-space: nowrap;
}
.rail-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--sp-2) 0;
  overflow: hidden;
}
.rail-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-3);
  height: 40px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  transition: background var(--t-rail);
  user-select: none;
  border-left: 2px solid transparent;
}
.rail-item:hover:not(.rail-item--locked) {
  background: var(--c-rail-hover);
}
.rail-item--active {
  border-left-color: var(--c-rail-indicator);
  background: var(--c-rail-hover);
}
.rail-item--locked {
  cursor: not-allowed;
  opacity: 0.4;
}
.rail-item--stale .rail-item-label {
  color: var(--c-amber-600);
}
.rail-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-rail-text);
}
.rail-item--active .rail-item-icon,
.rail-item--complete .rail-item-icon {
  color: var(--c-rail-active);
}
.rail-item-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.rail-item-label {
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  color: var(--c-rail-text);
  white-space: nowrap;
}
.rail-item--active .rail-item-label {
  color: var(--c-rail-active);
}
.rail-item--complete .rail-item-label {
  color: var(--c-rail-text);
}
.rail-item-status {
  font-size: var(--text-xs);
  color: var(--c-rail-text);
  opacity: 0.7;
  margin-top: 1px;
}
.rail-item--active .rail-item-status { color: var(--c-blue-600); opacity: 1; }
.rail-item--complete .rail-item-status { color: var(--c-green-600); opacity: 1; }
.rail-item--stale .rail-item-status { color: var(--c-amber-600); opacity: 1; }
.rail-divider {
  height: 1px;
  background: var(--c-rail-divider);
  margin: var(--sp-2) 0;
  flex-shrink: 0;
}
.rail-footer {
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--c-rail-divider);
  flex-shrink: 0;
}

/* ── MAIN AREA ──────────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOPBAR ─────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-height);
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-4);
  gap: var(--sp-3);
  flex-shrink: 0;
  z-index: 100;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  max-width: 400px;
  position: relative;
}
.topbar-search-icon {
  position: absolute;
  left: var(--sp-2);
  color: var(--c-text-tertiary);
  pointer-events: none;
}
.topbar-search input {
  width: 100%;
  height: 28px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 0 var(--sp-2) 0 28px;
  font-size: var(--text-sm);
  color: var(--c-text-primary);
  background: var(--c-surface);
  outline: none;
  transition: border-color var(--t-fast);
}
.topbar-search input:focus {
  border-color: var(--c-blue-600);
  background: var(--c-white);
}
.topbar-search input::placeholder { color: var(--c-text-tertiary); }
.topbar-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  z-index: 500;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}
.topbar-search-results.visible { display: block; }
.search-result-item {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  color: var(--c-text-secondary);
  cursor: pointer;
  border-bottom: 1px solid var(--c-border-subtle);
  transition: background var(--t-fast);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover {
  background: var(--c-surface);
  color: var(--c-text-primary);
}
.search-result-name {
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  color: var(--c-text-primary);
}
.search-result-sub {
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
  margin-top: 1px;
}
.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--c-border);
  flex-shrink: 0;
}
.topbar-date {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.topbar-date label {
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
}
.topbar-date input[type=date] {
  height: 28px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--sp-2);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--c-text-primary);
  background: var(--c-white);
  outline: none;
  cursor: pointer;
}
.topbar-date input[type=date]:focus { border-color: var(--c-blue-600); }
.topbar-spacer { flex: 1; }
.topbar-export-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 28px;
  padding: 0 var(--sp-3);
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  color: var(--c-text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
}
.topbar-export-btn:hover {
  background: var(--c-surface);
  color: var(--c-text-primary);
}

/* ── MAP CONTAINER ──────────────────────────────────────────────── */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#map {
  position: absolute;
  inset: 0;
}

/* ── STATUS BAR ─────────────────────────────────────────────────── */
#status-bar {
  height: var(--statusbar-height);
  background: var(--c-white);
  border-top: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-4);
  gap: var(--sp-5);
  flex-shrink: 0;
  z-index: 100;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
}
.status-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
}
.status-label {
  color: var(--c-text-tertiary);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
}
.status-value { color: var(--c-text-primary); }
.status-sep {
  width: 1px;
  height: 14px;
  background: var(--c-border);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-text-tertiary);
}
.status-dot--day { background: var(--c-amber-600); }
.status-dot--night { background: var(--c-text-tertiary); }

/* ── WORKSPACE PANEL ────────────────────────────────────────────── */
#workspace-panel {
  width: var(--panel-width);
  background: var(--c-white);
  border-left: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 100;
}
.panel-header {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
  background: var(--c-white);
}
.panel-title {
  font-size: var(--text-base);
  font-weight: var(--w-semibold);
  color: var(--c-text-primary);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
}
.panel-subtitle {
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
  margin-top: 2px;
}
.panel-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 2px; }
.panel-section {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--c-border-subtle);
}
.panel-section:last-child { border-bottom: none; }
.section-label {
  font-size: var(--text-xs);
  font-weight: var(--w-semibold);
  color: var(--c-text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-footer {
  padding: var(--sp-4);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}

/* ── METRIC ROWS ────────────────────────────────────────────────── */
.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
}
.metric-row + .metric-row {
  border-top: 1px solid var(--c-border-subtle);
}
.metric-label {
  font-size: var(--text-sm);
  color: var(--c-text-secondary);
  flex: 1;
  min-width: 0;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  color: var(--c-text-primary);
  white-space: nowrap;
}
.metric-unit {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
  margin-left: 2px;
}
.metric-value--positive { color: var(--c-green-600); }
.metric-value--warning  { color: var(--c-amber-600); }
.metric-value--critical { color: var(--c-red-600); }
.metric-value--blue     { color: var(--c-blue-600); }

/* ── BUTTONS ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 30px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  border: 1px solid transparent;
  outline: none;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary {
  background: var(--c-blue-600);
  color: var(--c-white);
}
.btn-primary:hover { background: var(--c-blue-700); }
.btn-primary:disabled {
  background: var(--c-surface);
  color: var(--c-text-tertiary);
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--c-white);
  color: var(--c-text-secondary);
  border-color: var(--c-border);
}
.btn-secondary:hover {
  background: var(--c-surface);
  color: var(--c-text-primary);
}
.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--c-text-secondary);
  border: none;
  padding: 0 var(--sp-2);
}
.btn-ghost:hover {
  background: var(--c-surface);
  color: var(--c-text-primary);
}
.btn-sm { height: 26px; padding: 0 var(--sp-2); font-size: var(--text-xs); }
.btn-full { width: 100%; }
.btn-group {
  display: flex;
  gap: var(--sp-2);
}

/* ── FORM INPUTS ────────────────────────────────────────────────── */
.form-field { margin-bottom: var(--sp-3); }
.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--w-medium);
  color: var(--c-text-secondary);
  margin-bottom: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
}
.form-input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--sp-2);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--c-text-primary);
  background: var(--c-white);
  outline: none;
  transition: border-color var(--t-fast);
}
.form-input:focus { border-color: var(--c-blue-600); }
.form-input::placeholder { color: var(--c-text-tertiary); }
.form-input--mono { font-family: var(--font-mono); }
.form-select {
  width: 100%;
  height: 30px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--sp-2);
  font-size: var(--text-sm);
  color: var(--c-text-primary);
  background: var(--c-white);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
.form-select:focus { border-color: var(--c-blue-600); }

/* ── RANGE SLIDER (Time) ────────────────────────────────────────── */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.slider-track {
  position: relative;
  display: flex;
  align-items: center;
}
input[type=range].time-slider {
  width: 100%;
  height: 4px;
  appearance: none;
  background: var(--c-border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type=range].time-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-blue-600);
  cursor: pointer;
  border: 2px solid var(--c-white);
  box-shadow: 0 0 0 1px var(--c-blue-600);
}
input[type=range].time-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-blue-600);
  cursor: pointer;
  border: 2px solid var(--c-white);
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
}
.slider-value {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--w-semibold);
  color: var(--c-text-primary);
  text-align: center;
}

/* ── BADGES & STATUS ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  padding: 0 var(--sp-1);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--w-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge--complete { background: var(--c-green-100); color: var(--c-green-700); }
.badge--stale    { background: var(--c-amber-100); color: var(--c-amber-600); }
.badge--error    { background: var(--c-red-100);   color: var(--c-red-600);   }
.badge--locked   { background: var(--c-surface);   color: var(--c-text-tertiary); }
.badge--info     { background: var(--c-blue-100);  color: var(--c-blue-600); }

/* ── PROGRESS INDICATOR ─────────────────────────────────────────── */
.progress-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
}
.progress-label {
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
  margin-bottom: var(--sp-2);
}
.progress-bar-track {
  height: 4px;
  background: var(--c-border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--c-blue-600);
  border-radius: 2px;
  transition: width 200ms linear;
}

/* ── INSIGHT TOGGLE ROW ─────────────────────────────────────────── */
.insight-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--c-border-subtle);
}
.insight-row:last-child { border-bottom: none; }
.insight-toggle-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.insight-title {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  color: var(--c-text-primary);
}
.insight-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding-left: 24px;
}
.insight-metric {
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
  font-family: var(--font-mono);
}

/* ── TOGGLE SWITCH ──────────────────────────────────────────────── */
.toggle {
  position: relative;
  width: 32px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: var(--c-border);
  transition: background var(--t-fast);
}
.toggle input:checked + .toggle-track { background: var(--c-blue-600); }
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-white);
  transition: transform var(--t-fast);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(14px); }

/* ── CHART CONTAINER ────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 120px;
  margin-top: var(--sp-2);
}
.chart-wrap--tall { height: 160px; }
.chart-title {
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  margin-bottom: var(--sp-2);
}

/* ── DATA TABLE ─────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}
.data-table th {
  text-align: left;
  padding: var(--sp-1) var(--sp-2);
  font-size: 10px;
  font-weight: var(--w-semibold);
  color: var(--c-text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  border-bottom: 1px solid var(--c-border);
}
.data-table td {
  padding: var(--sp-1) var(--sp-2);
  color: var(--c-text-secondary);
  border-bottom: 1px solid var(--c-border-subtle);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--c-surface); }

/* ── CALL-TO-ACTION FOOTER ──────────────────────────────────────── */
.proceed-btn-wrap {
  padding: var(--sp-4);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}

/* ── EMPTY STATE ────────────────────────────────────────────────── */
.empty-state {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
}
.empty-state-title {
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  color: var(--c-text-secondary);
  margin-bottom: var(--sp-2);
}
.empty-state-body {
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
  line-height: 1.6;
}

/* ── NOTICE BAR ─────────────────────────────────────────────────── */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  line-height: 1.5;
  margin-bottom: var(--sp-3);
}
.notice--info { background: var(--c-blue-100); color: var(--c-blue-600); }
.notice--warn { background: var(--c-amber-100); color: var(--c-amber-600); }
.notice--error { background: var(--c-red-100); color: var(--c-red-600); }
.notice--success { background: var(--c-green-100); color: var(--c-green-700); }

/* ── MAP OVERLAYS ───────────────────────────────────────────────── */
#map-overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* Sun compass */
.sun-compass {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  width: 88px;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2);
  pointer-events: none;
}
.sun-compass-canvas {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto var(--sp-1);
}
.sun-compass-values {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sun-compass-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
}
.sun-compass-key { color: var(--c-text-tertiary); }
.sun-compass-val { color: var(--c-text-primary); font-weight: var(--w-medium); }

/* Map tool controls */
.map-tools {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  pointer-events: all;
}
.map-tool-btn {
  width: 32px;
  height: 32px;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--c-text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
}
.map-tool-btn:hover { background: var(--c-surface); color: var(--c-text-primary); }
.map-tool-btn--active {
  background: var(--c-blue-100);
  color: var(--c-blue-600);
  border-color: var(--c-blue-200);
}

/* Drawing mode cursor */
body.draw-mode #map { cursor: crosshair; }
body.draw-mode-remove #map { cursor: not-allowed; }

/* Analysis zone label */
.zone-label {
  position: absolute;
  background: var(--c-blue-600);
  color: var(--c-white);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 2px var(--sp-1);
  border-radius: 2px;
  pointer-events: none;
  white-space: nowrap;
}

/* Legend */
.map-legend {
  position: absolute;
  bottom: var(--sp-4);
  left: var(--sp-3);
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  pointer-events: none;
  min-width: 140px;
}
.map-legend.hidden { display: none; }
.legend-title {
  font-size: var(--text-xs);
  font-weight: var(--w-semibold);
  color: var(--c-text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  margin-bottom: var(--sp-2);
}
.legend-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: 3px;
}
.legend-swatch {
  width: 20px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-label {
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
  font-family: var(--font-mono);
}

/* ── SCENARIO SPLIT ─────────────────────────────────────────────── */
.scenario-mode-tabs {
  display: flex;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--sp-3);
}
.scenario-tab {
  flex: 1;
  height: 28px;
  background: var(--c-white);
  border: none;
  font-size: var(--text-xs);
  font-weight: var(--w-medium);
  color: var(--c-text-secondary);
  cursor: pointer;
  transition: background var(--t-fast);
}
.scenario-tab + .scenario-tab { border-left: 1px solid var(--c-border); }
.scenario-tab--active {
  background: var(--c-blue-600);
  color: var(--c-white);
}

/* ── COMPARISON TABLE ───────────────────────────────────────────── */
.compare-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--c-border-subtle);
  align-items: center;
}
.compare-row:last-child { border-bottom: none; }
.compare-label {
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
}
.compare-val {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-primary);
  text-align: center;
}
.compare-delta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-align: right;
}
.compare-delta--up { color: var(--c-red-600); }
.compare-delta--down { color: var(--c-green-600); }

/* ── REPORT PREVIEW ─────────────────────────────────────────────── */
.report-preview {
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  max-height: 300px;
  overflow-y: auto;
}
.report-section-title {
  font-weight: var(--w-semibold);
  color: var(--c-text-primary);
}
.report-recommendations {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-primary);
  line-height: 1.6;
  resize: vertical;
  outline: none;
  background: var(--c-white);
}
.report-recommendations:focus { border-color: var(--c-blue-600); }

/* ── MAPLIBRE OVERRIDES ─────────────────────────────────────────── */
.maplibregl-ctrl-logo { display: none !important; }
.maplibregl-ctrl-attrib { font-size: 9px !important; opacity: 0.6; }
.maplibregl-ctrl-attrib-inner { font-family: var(--font-mono) !important; }
.maplibregl-ctrl-group { border: 1px solid var(--c-border) !important;
  border-radius: var(--radius-sm) !important; box-shadow: none !important; }
.maplibregl-ctrl button { background-color: var(--c-white) !important; }
.maplibregl-ctrl button:hover { background-color: var(--c-surface) !important; }
.maplibregl-popup-content {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  padding: var(--sp-3) !important;
  font-family: var(--font-sans) !important;
  font-size: var(--text-xs) !important;
}
.maplibregl-popup-close-button {
  color: var(--c-text-tertiary) !important;
  font-size: 14px !important;
  padding: var(--sp-1) var(--sp-2) !important;
}
.popup-title {
  font-size: var(--text-xs);
  font-weight: var(--w-semibold);
  color: var(--c-text-primary);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  margin-bottom: var(--sp-2);
  border-bottom: 1px solid var(--c-border-subtle);
  padding-bottom: var(--sp-1);
}
.popup-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: 2px;
}
.popup-label { color: var(--c-text-secondary); }
.popup-value { font-family: var(--font-mono); font-weight: var(--w-medium); color: var(--c-text-primary); }

/* ── WORKSPACE TRANSITIONS ──────────────────────────────────────── */
.workspace-enter { opacity: 0; transform: translateX(4px); }
.workspace-enter-active {
  opacity: 1; transform: translateX(0);
  transition: opacity var(--t-normal), transform var(--t-normal);
}

/* ── PROCEED BUTTON ─────────────────────────────────────────────── */
.proceed-btn-wrap {
  padding: var(--sp-4);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}

/* ── NOTICES ────────────────────────────────────────────────────── */
.notice {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  line-height: 1.5;
  border-left: 2px solid;
}
.notice--info    { background: #EFF6FF; border-color: var(--c-blue-600);  color: #1E40AF; }
.notice--warn    { background: var(--c-amber-100); border-color: var(--c-amber-600); color: #92400E; }
.notice--success { background: var(--c-green-100); border-color: var(--c-green-600); color: #14532D; }
.notice--error   { background: var(--c-red-100);   border-color: var(--c-red-600);   color: #991B1B; }

/* ── EMPTY STATE ────────────────────────────────────────────────── */
.empty-state { padding: var(--sp-4); text-align: center; }
.empty-state-title {
  font-size: var(--text-sm); font-weight: var(--w-medium);
  color: var(--c-text-secondary); margin-bottom: var(--sp-1);
}
.empty-state-body {
  font-size: var(--text-xs); color: var(--c-text-tertiary); line-height: 1.6;
}

/* ── BUTTON VARIANTS ────────────────────────────────────────────── */
.btn-group { display: flex; gap: var(--sp-2); }
.btn-full  { width: 100%; justify-content: center; }
.btn-sm    { height: 24px; padding: 0 var(--sp-2); font-size: var(--text-xs); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  height: 20px; padding: 0 var(--sp-1); background: transparent; border: none;
  font-size: var(--text-xs); font-weight: var(--w-medium); color: var(--c-blue-600);
  cursor: pointer; transition: opacity var(--t-fast);
}
.btn-ghost:hover { opacity: 0.7; }

/* ── FORM ELEMENTS ──────────────────────────────────────────────── */
.form-field { margin-bottom: var(--sp-2); }
.form-select {
  width: 100%; height: 28px; padding: 0 var(--sp-2);
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center;
  font-size: var(--text-sm); font-family: var(--font-sans); color: var(--c-text-primary);
  appearance: none; cursor: pointer;
}
.form-select:focus { outline: none; border-color: var(--c-blue-600); }
.form-input {
  width: 100%; height: 28px; padding: 0 var(--sp-2);
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-white); font-size: var(--text-sm); color: var(--c-text-primary);
}
.form-input:focus { outline: none; border-color: var(--c-blue-600); }
.form-input--mono { font-family: var(--font-mono); }

/* ── TIME SLIDER ────────────────────────────────────────────────── */
.slider-container { padding: var(--sp-1) 0; }
.slider-value {
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--w-medium);
  color: var(--c-text-primary); margin-bottom: var(--sp-2);
}
.time-slider {
  width: 100%; height: 4px; appearance: none;
  background: var(--c-border); border-radius: 2px; outline: none; cursor: pointer;
}
.time-slider::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--c-blue-600); border: 2px solid white;
  box-shadow: 0 0 0 1px var(--c-border);
}
.time-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--c-blue-600); border: 2px solid white; cursor: pointer;
}
.slider-labels {
  display: flex; justify-content: space-between; margin-top: var(--sp-1);
  font-size: 9px; font-family: var(--font-mono); color: var(--c-text-tertiary);
}

/* ── TOGGLE SWITCH ──────────────────────────────────────────────── */
.insight-row { padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border-subtle); }
.insight-row:last-child { border-bottom: none; }
.insight-toggle-header { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.insight-title { font-size: var(--text-sm); font-weight: var(--w-medium); color: var(--c-text-primary); }
.insight-metrics { display: flex; flex-direction: column; gap: 2px; padding-left: calc(32px + var(--sp-3)); }
.insight-metric { font-size: var(--text-xs); color: var(--c-text-secondary); font-family: var(--font-mono); line-height: 1.5; }

.toggle { position: relative; display: inline-block; flex-shrink: 0; }
.toggle input[type="checkbox"] { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  display: block; width: 32px; height: 18px; background: var(--c-border);
  border-radius: 9px; cursor: pointer; transition: background var(--t-fast);
}
.toggle input:checked + .toggle-track { background: var(--c-blue-600); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 12px; height: 12px;
  background: white; border-radius: 50%; pointer-events: none; transition: transform var(--t-fast);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(14px); }

/* ── CHART WRAPPERS ─────────────────────────────────────────────── */
.chart-title {
  font-size: var(--text-xs); color: var(--c-text-tertiary);
  text-transform: uppercase; letter-spacing: var(--ls-label); margin-bottom: var(--sp-2);
}
.chart-wrap { position: relative; height: 80px; width: 100%; }
.chart-wrap canvas { display: block; }

/* ── PROGRESS BAR ───────────────────────────────────────────────── */
.progress-wrap { padding: var(--sp-2) 0; }
.progress-label {
  font-size: var(--text-xs); color: var(--c-text-tertiary);
  font-family: var(--font-mono); margin-bottom: var(--sp-2);
}
.progress-bar-track {
  width: 100%; height: 3px; background: var(--c-border); border-radius: 2px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--c-blue-600); border-radius: 2px;
  transition: width 200ms ease-out;
}

/* ── SCENARIO TABS ──────────────────────────────────────────────── */
.scenario-mode-tabs {
  display: flex; gap: var(--sp-1); background: var(--c-surface);
  padding: 3px; border-radius: var(--radius-sm);
}
.scenario-tab {
  flex: 1; height: 24px; border: none; background: transparent; border-radius: 2px;
  font-size: var(--text-xs); font-weight: var(--w-medium); color: var(--c-text-secondary);
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.scenario-tab--active {
  background: var(--c-white); color: var(--c-text-primary); border: 1px solid var(--c-border);
}

/* ── COMPARISON TABLE ───────────────────────────────────────────── */
.compare-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: var(--sp-3);
  align-items: center; padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-border-subtle);
}
.compare-row:last-child { border-bottom: none; }
.compare-label { font-size: var(--text-xs); color: var(--c-text-secondary); min-width: 0; }
.compare-val { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--c-text-primary); text-align: right; white-space: nowrap; }
.compare-delta { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--w-medium); text-align: right; white-space: nowrap; min-width: 48px; }
.compare-delta--up   { color: var(--c-red-600);  }
.compare-delta--down { color: var(--c-green-600); }

/* ── SUN COMPASS ────────────────────────────────────────────────── */
.sun-compass {
  position: absolute; top: var(--sp-3);
  right: calc(var(--sp-3) + 48px);
  background: rgba(255,255,255,0.94); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); padding: var(--sp-2);
  display: flex; align-items: flex-start; gap: var(--sp-2);
  z-index: 50; pointer-events: none;
}
.sun-compass-canvas { flex-shrink: 0; display: block; }
.sun-compass-values { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.sun-compass-row { display: flex; gap: var(--sp-2); align-items: baseline; }
.sun-compass-key {
  font-size: 9px; text-transform: uppercase; letter-spacing: var(--ls-label);
  color: var(--c-text-tertiary); width: 28px; flex-shrink: 0;
}
.sun-compass-val { font-family: var(--font-mono); font-size: 10px; color: var(--c-text-primary); white-space: nowrap; }

/* ── MAP LOADING INDICATOR ──────────────────────────────────────── */
.map-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: #ECEEF0;
  z-index: 10; gap: var(--sp-3); font-size: var(--text-xs);
  color: var(--c-text-tertiary); font-family: var(--font-mono); letter-spacing: var(--ls-label);
}
.map-loading-spinner {
  width: 20px; height: 20px; border: 2px solid var(--c-border);
  border-top-color: var(--c-blue-600); border-radius: 50%;
  animation: ht-spin 0.8s linear infinite;
}
@keyframes ht-spin { to { transform: rotate(360deg); } }

/* ── DRAW MODE CURSOR ───────────────────────────────────────────── */
body.draw-mode,
body.draw-mode .maplibregl-canvas,
body.draw-mode .maplibregl-canvas-container { cursor: crosshair !important; }
/* During draw mode: panel stays interactive so user can click Finish Boundary */
body.draw-mode #workspace-panel { opacity: 0.85; transition: opacity 0.1s; }


/* ── DRAW HINT PANEL ────────────────────────────────────────────── */
.draw-hint-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 2px 0;
  font-size: var(--text-xs);
}
.draw-hint-key {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  padding: 0 5px;
  height: 18px;
  line-height: 18px;
  color: var(--c-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 54px;
  text-align: center;
}
.draw-hint-desc {
  color: var(--c-text-tertiary);
}
