:root {
  --accent:        #ED7C30;
  --accent-dark:   #c4621f;
  --bg-header:     #ffffff;
  --bg-page:       #f7f7f8;
  --text-main:     #1a1a1a;
  --text-muted:    #5a5a5a;
  --text-nav:      #2c2c2c;
  --header-height: 89px;
  --side-col:      200px;
  --border:        #e6e6e8;
}

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

html, body {
  font-size: 16px;
  font-family: 'Poppins', sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
}

/* ---------- Header (3-column grid: logo | centered title | spacer) ---------- */
.header-row {
  display: grid;
  grid-template-columns: var(--side-col) 1fr var(--side-col);
  align-items: center;
  padding: 0 2rem;
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  width: 100%;
}

.header-logo-left { justify-self: start; }
.header-logo-left img {
  width: 180px;
  height: 70px;
  object-fit: contain;
  display: block;
}

.header-title-block {
  text-align: center;
  justify-self: center;
  max-width: 720px;
}
.header-title-block h1 {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text-main);
}
.header-subtitle {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.2rem;
  letter-spacing: 0.01em;
}

.header-spacer { width: var(--side-col); }

@media (max-width: 900px) {
  .header-row {
    grid-template-columns: auto 1fr auto;
    padding: 0.5rem 1rem;
    height: auto;
  }
  .header-logo-left img { width: 130px; height: 50px; }
  .header-title-block h1 { font-size: 1.2rem; }
  .header-subtitle { font-size: 0.72rem; }
  .header-spacer { display: none; }
}

/* ---------- Page shell ---------- */
.page { padding: 0; }
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.section-title {
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

/* ---------- Dashboard (legacy 2-column layout, kept for fallback) ---------- */
.dashboard {
  --map-frac: 60%;
  --resizer-w: 6px;
  display: grid;
  grid-template-columns: var(--map-frac) var(--resizer-w) minmax(0, 1fr);
  gap: 0;
  padding: 0.85rem 1.1rem 1rem;
  height: calc(100vh - var(--header-height));
  box-sizing: border-box;
}
.dashboard-alert { grid-column: 1 / -1; }

/* ---------- Variation D layout (map-first + inspector drawer) ---------- */
/* Vertical-flex: top chip toolbar, then main = (map | optional inspector). */
.dashboard.d-variant {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  padding: 0.6rem 0.9rem 0.9rem;
  gap: 0.6rem;
}

.d-toolbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  background: var(--panel, #f6f3ee);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}

.d-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: #fff;
  border: 1.4px solid var(--border, #d4d4d8);
  color: #1a1a1a;
  font: 500 0.82rem/1.2 inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.d-chip:hover { border-color: var(--accent, #e8703a); }
.d-chip[disabled] {
  cursor: not-allowed;
  opacity: 0.75;
  border-style: dashed;
}
.d-chip-on { border-color: #1a1a1a; background: #fff; }
.d-chip-on .d-chip-label { background: #1a1a1a; color: #fff; }
.d-chip-off .d-chip-label { background: #e4e4e7; color: #1a1a1a; }
.d-chip-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
}
.d-chip-text { font-weight: 600; }
.d-chip-meta { color: #6b7280; font-weight: 400; }

/* Numbered-step chips (top toolbar) — larger, clearer flow indicator.
   Three states: -active (current step, accent ring), -done (completed,
   black ring + check), -pending (blocked on a prior step, dashed/muted). */
.d-step {
  padding: 0.5rem 0.9rem 0.5rem 0.55rem;
  gap: 0.7rem;
  font-size: 0.95rem;
  line-height: 1.25;
  align-items: center;
  border-width: 1.6px;
}
.d-step-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  background: #e4e4e7;
  color: #6b7280;
}
.d-step-body {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  min-width: 0;
  text-align: left;
}
.d-step-eyebrow {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7280;
}
.d-step-text { font-weight: 700; font-size: 0.98rem; color: #1a1a1a; }
.d-step-meta { font-size: 0.78rem; color: #6b7280; font-weight: 500; }

/* Active = the step the user should act on now. */
.d-step-active { border-color: var(--accent, #e8703a); background: #fff; }
.d-step-active .d-step-num { background: var(--accent, #e8703a); color: #fff; }
.d-step-active .d-step-eyebrow { color: var(--accent, #e8703a); }

/* Done = step already completed. */
.d-step-done { border-color: #1a1a1a; background: #fff; }
.d-step-done .d-step-num { background: #1a1a1a; color: #fff; font-size: 1.05rem; }
.d-step-done .d-step-eyebrow { color: #1a1a1a; }

/* Pending = waiting on a prior step (disabled state). */
.d-step-pending { background: #fafafa; }
.d-step-pending .d-step-num { background: #e4e4e7; color: #9ca3af; }
.d-step-pending .d-step-text { color: #6b7280; font-weight: 600; }
.d-chip.d-step[disabled] { opacity: 1; }   /* dashed border alone signals disabled */

.d-toolbar-status { font-size: 0.78rem; color: #6b7280; }
.d-toolbar-spacer { flex: 1 1 auto; min-width: 0.5rem; }

.d-main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0.6rem;
}
.d-map-section {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 10px;
  overflow: hidden;
}
.d-map-section .map-stack { width: 100%; height: 100%; }

/* Discoverability callout pointing at the Leaflet-Draw toolbar.
   Shown after EPW load until the first AOI is drawn. */
.d-aoi-hint {
  position: absolute;
  top: 76px;            /* sits beside the draw toolbar buttons */
  left: 60px;           /* clears Leaflet's left-edge controls   */
  z-index: 700;
  background: #1a1a1a;
  color: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.95rem 0.6rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: 320px;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  pointer-events: none; /* never blocks the map or draw tools */
  animation: aoiHintBob 1.9s ease-in-out infinite;
}
.d-aoi-hint[hidden] { display: none; }
.d-aoi-hint-arrow {
  font-size: 1.35rem;
  color: var(--accent, #e8703a);
  line-height: 1;
  font-weight: 700;
}
.d-aoi-hint-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.d-aoi-hint-body strong { font-size: 0.86rem; }
.d-aoi-hint-body span { color: #d4d4d8; }
@keyframes aoiHintBob {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(4px); }
}

/* Floating AOI summary, top-left of the map. */
.d-aoi-overlay {
  position: absolute;
  top: 14px;
  left: 60px;          /* clears Leaflet's zoom + / − stack */
  z-index: 600;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #1a1a1a;
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  font-size: 0.78rem;
}
.d-aoi-overlay-cell .d-aoi-overlay-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.1rem;
}
.d-aoi-overlay-cell .d-aoi-overlay-value {
  font-weight: 700;
  font-size: 0.9rem;
}
.d-aoi-overlay-accent { color: #e8703a; }
.d-aoi-overlay-divider {
  width: 1px;
  height: 28px;
  background: #e4e4e7;
}

/* Inspector drawer — opens on building click. */
.d-inspector {
  width: 360px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.d-inspector[hidden] { display: none; }
.d-inspector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  background: #fff1e9;
  border-bottom: 1px solid #e8703a;
}
.d-inspector-eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
}
.d-inspector-title {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0.15rem;
  word-break: break-word;
}
.d-inspector-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: #6b7280;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
}
.d-inspector-close:hover { color: #1a1a1a; }
.d-inspector-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
}
.d-kpi {
  background: #fafafa;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
}
.d-kpi-accent { background: #fff1e9; border-color: #e8703a; }
.d-kpi-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
}
.d-kpi-value {
  margin-top: 0.25rem;
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-weight: 700;
  font-size: 1.1rem;
}
.d-kpi-unit { font-size: 0.7rem; color: #6b7280; font-weight: 400; }
.d-kpi-sub {
  margin-top: 0.15rem;
  font-size: 0.66rem;
  color: #6b7280;
  font-weight: 500;
  line-height: 1.1;
}
.d-kpi-sub:empty { display: none; }
.d-inspector-meta {
  padding: 0 0.85rem;
  font-size: 0.78rem;
  color: #6b7280;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.d-meta-section { display: flex; flex-direction: column; gap: 0.18rem; }
.d-meta-section-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.1rem;
}
.d-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.76rem;
  color: #1a1a1a;
}
.d-meta-key { color: #6b7280; }
.d-meta-val { font-weight: 600; text-align: right; word-break: break-word; }
.d-meta-empty { font-style: italic; color: #9ca3af; font-size: 0.74rem; }
.d-inspector-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-bottom: 0.85rem;
}
.d-inspector-card {
  margin: 0 0.85rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  background: #fafafa;
}
.d-inspector-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.45rem;
}
.d-inspector-card-foot {
  font-size: 0.72rem;
  color: #6b7280;
  margin-top: 0.45rem;
}
/* Inspector monthly chart: parent is a normal block so bars + axis stack
 * vertically; the inner .d-month-chart-bars is the flex row of bars. */
#inspector-monthly-chart {
  /* default block layout */
}
.d-month-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 70px;
}
.d-month-bar {
  flex: 1;
  background: #e8703a;
  border-radius: 2px 2px 0 0;
  position: relative;
  min-height: 2px;
}
.d-month-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.62rem;
  color: #6b7280;
}
#inspector-panel-layout svg {
  display: block;
  width: 100%;
  max-width: 100%;
}
.d-inspector-nav {
  display: flex;
  gap: 0.4rem;
  padding: 0 0.85rem;
}
.d-inspector-nav button { flex: 1; }

/* Popover floating from the EPW chip — contains the catalog + lat/lon UI. */
.d-popover {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: 480px;
  max-width: calc(100vw - 2rem);
  background: #fff;
  border: 1px solid var(--border, #d4d4d8);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.d-popover[hidden] { display: none; }
.d-popover-row { display: flex; flex-direction: column; gap: 0.35rem; }
.d-popover-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a1a1a;
}
.d-search-input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
  box-sizing: border-box;
}
.d-search-input:focus {
  outline: none;
  border-color: #e8703a;
  box-shadow: 0 0 0 2px rgba(232, 112, 58, 0.18);
}
.d-search-results {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  background: #fff;
}
.d-search-results[hidden] { display: none; }
.d-search-result {
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f1f3;
  font-size: 0.82rem;
  line-height: 1.3;
}
.d-search-result:last-child { border-bottom: none; }
.d-search-result:hover,
.d-search-result.is-active {
  background: #fff1e9;
}
.d-search-result-title { font-weight: 600; }
.d-search-result-meta {
  font-size: 0.72rem;
  color: #6b7280;
  margin-top: 0.1rem;
}
.d-search-result-meta mark {
  background: #fff3a8;
  color: inherit;
  padding: 0 0.1em;
  border-radius: 2px;
}
.d-search-empty {
  padding: 0.6rem 0.7rem;
  font-size: 0.78rem;
  color: #6b7280;
  font-style: italic;
}

/* Draggable splitter between map column and sidebar */
.dash-resizer {
  position: relative;
  cursor: col-resize;
  background: var(--border);
  margin: 0 0.35rem;
  border-radius: 3px;
  transition: background 0.15s;
  user-select: none;
  touch-action: none;
}
.dash-resizer::before {
  /* Grip dots in the middle — a universal "draggable handle" affordance */
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 44px;
  transform: translate(-50%, -50%);
  background-image: radial-gradient(circle, #ffffff 1.4px, transparent 1.6px);
  background-size: 4px 8px;
  background-repeat: repeat-y;
  background-position: center;
  border-radius: 2px;
  pointer-events: none;
}
.dash-resizer::after {
  /* Wider invisible hit area so the handle is easy to grab */
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -6px;
  right: -6px;
}
.dash-resizer:hover,
.dash-resizer:focus-visible,
.dash-resizer.is-dragging {
  background: var(--accent);
  outline: none;
}
body.dash-resizing { cursor: col-resize; user-select: none; }
body.dash-resizing iframe { pointer-events: none; }

.dash-map-col {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem 0.85rem;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.dash-map {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  margin-bottom: 0.65rem;
}

.dash-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}
.dash-sidebar > .setup-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
}
.dash-sidebar .map-header { margin-bottom: 0.4rem; }
.dash-sidebar .map-hint { font-size: 0.76rem; margin-top: 0.15rem; }

@media (max-width: 1100px) {
  .dashboard {
    grid-template-columns: 1fr;
    height: auto;
    padding-bottom: 2rem;
  }
  .dash-map { flex: none; height: 480px; }
  .dash-sidebar { overflow: visible; }
  .dash-resizer { display: none; }
}

/* ---------- Sidebar widget compaction ---------- */
.dash-sidebar .climate-context {
  gap: 0.3rem;
  margin-bottom: 0;
}
.dash-sidebar .climate-chip {
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
}
.dash-sidebar .results-header {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  margin-bottom: 0.1rem;
}
.dash-sidebar .results-header h3 { font-size: 1rem; }
.dash-sidebar .building-select-wrap select {
  min-width: 0;
  width: 100%;
  padding: 0.35rem 0.55rem;
}
.dash-sidebar .mode-banner {
  padding: 0.4rem 0.65rem;
  font-size: 0.76rem;
  margin-bottom: 0;
}
.dash-sidebar .stats-grid {
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0;
}
.dash-sidebar .stats-sticky {
  position: static;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}
.dash-sidebar .stat {
  padding: 0.55rem 0.7rem;
}
.dash-sidebar .stat-value { font-size: 1.3rem; }
.dash-sidebar .stat-label { font-size: 0.68rem; margin-top: 0.2rem; }
.dash-sidebar .chart-card {
  padding: 0.6rem 0.75rem 0.75rem;
  margin-bottom: 0;
}
.dash-sidebar .chart-card h4 {
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
}
.dash-sidebar .chart-card canvas {
  width: 100% !important;
  height: 170px !important;
}
.dash-sidebar .raw-meta { font-size: 0.78rem; margin-top: 0; }
.dash-sidebar .raw-meta ul { font-size: 0.72rem; }

/* Compact AOI toolbar inside the map column */
.dash-map-col .map-header h3 { font-size: 1rem; }
.dash-map-col .map-hint { font-size: 0.76rem; margin-top: 0.1rem; }
.dash-map-col .area-toolbar {
  gap: 0.5rem;
  margin-top: 0;
}
.dash-map-col .btn-primary {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
}
.dash-map-col .btn-secondary {
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
}
.dash-map-col .area-status { font-size: 0.76rem; }

.alert {
  padding: 0.85rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert-error {
  background: #fee9e1;
  color: #8a2a0d;
  border: 1px solid #f4b69e;
}

/* ---------- Form ---------- */
.setup-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}
.setup-form .form-field { width: 100%; }
.setup-form .form-field span { font-size: 0.82rem; }
.epw-loading {
  font-size: 0.78rem;
  color: var(--accent-dark);
  font-weight: 500;
}
.extra-inputs {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.extra-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.extra-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-nav);
}
.extra-coord {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.35rem;
}
.extra-coord input {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  min-width: 0;
}
.extra-coord input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.catalog-row {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.6fr) auto;
  gap: 0.35rem;
  align-items: center;
}
.catalog-select {
  font: inherit;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fff;
  min-width: 0;
}
.catalog-select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.catalog-select:disabled { background: #f3f3f5; color: var(--text-muted); }
.btn-mini {
  padding: 0.35rem 0.7rem !important;
  font-size: 0.78rem !important;
}
.extra-status {
  font-size: 0.74rem;
  color: var(--text-muted);
}
.extra-status.is-error { color: #8a2a0d; }
.extra-status.is-success { color: var(--accent-dark); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.form-field-wide { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.88rem; }
.form-field span { font-weight: 500; color: var(--text-nav); }
.form-field input {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.form-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.form-field small { color: var(--text-muted); font-size: 0.72rem; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.75rem 1.6rem;
  font: 500 0.95rem 'Poppins', sans-serif;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-dark); }

/* ---------- Map ---------- */
.map-header { margin-bottom: 0.75rem; }
.map-header h3 { font-weight: 500; }
.map-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}
.map-wrap {
  width: 100%;
  height: 480px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

/* Custom sun marker */
.sunthesis-marker {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  border: 2px solid #fff;
}

/* Area controls */
.area-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.btn-secondary {
  background: #fff;
  color: var(--text-nav);
  border: 1px solid var(--border);
  padding: 0.6rem 1.1rem;
  font: 500 0.88rem 'Poppins', sans-serif;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover:not(:disabled) { background: #f3f3f5; }
.btn-secondary.btn-active {
  background: #1e40af;
  color: #fff;
  border-color: #1e3a8a;
}
.btn-secondary.btn-active:hover { background: #1e3a8a; }
.btn-secondary:disabled,
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.area-status {
  font-size: 0.82rem;
  color: var(--text-muted);
}
/* Results header with building selector */
.results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.results-header h3 { font-weight: 500; margin: 0; }
.building-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.building-select-wrap label {
  font-weight: 500;
  color: var(--text-nav);
}
.building-select-wrap select {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  min-width: 240px;
  cursor: pointer;
}
.building-select-wrap select:disabled {
  background: #f3f3f5;
  color: var(--text-muted);
  cursor: not-allowed;
}
.building-select-wrap select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* Climate context strip */
.climate-context {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.climate-chip {
  background: #fafafb;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  color: var(--text-nav);
}
.climate-chip b {
  font-weight: 600;
  margin-right: 0.4rem;
  color: var(--text-main);
}

/* Mode banner (AOI / Building label above the stats) */
.mode-banner {
  background: #fafafb;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.86rem;
  color: var(--text-main);
}
.mode-banner-error {
  background: #fee9e1;
  border-color: #f4b69e;
  color: #8a2a0d;
}

/* Sticky KPI cards stay visible while scrolling */
.stats-sticky {
  position: sticky;
  top: 0.5rem;
  z-index: 5;
  background: #fff;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* Hover tooltip on map buildings */
.leaflet-tooltip.building-tooltip {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-family: 'Poppins', sans-serif;
  font-size: 0.72rem;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  line-height: 1.3;
}
.leaflet-tooltip.building-tooltip b {
  font-weight: 600;
  color: var(--accent);
}

/* Heatmap legend (Leaflet control) */
.map-legend {
  background: rgba(255, 255, 255, 0.95);
  padding: 0.55rem 0.7rem 0.6rem;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  font-family: 'Poppins', sans-serif;
  font-size: 0.72rem;
  color: var(--text-main);
  line-height: 1.25;
  min-width: 130px;
}
.legend-title {
  font-weight: 600;
  font-size: 0.74rem;
  margin-bottom: 0.35rem;
  color: var(--text-nav);
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.18rem;
}
.legend-row:last-child { margin-bottom: 0; }
.legend-swatch {
  display: inline-block;
  width: 16px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 2px;
}
.legend-range {
  color: var(--text-muted);
}

/* ---------- Results ---------- */
.results {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem 1.5rem;
}
.results h3 { font-weight: 500; margin-bottom: 1rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: #fafafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.chart-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.chart-card h4 { font-weight: 500; margin-bottom: 0.75rem; font-size: 0.95rem; }
.chart-card canvas { width: 100% !important; height: 320px !important; }

.raw-meta { margin-top: 1rem; font-size: 0.85rem; }
.raw-meta summary { cursor: pointer; font-weight: 500; }
.raw-meta ul { margin: 0.5rem 0 0 1.5rem; }
.raw-meta li { margin-bottom: 0.15rem; color: var(--text-muted); }

.caveat {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-style: italic;
}

/* ─── Side-panel step sections ─────────────────────────────────────────────
 * Numbered cards laid out vertically. Each section gets its own card so the
 * workflow (Weather → Buildings → Results) reads top-to-bottom as a clear
 * sequence.                                                                 */
.step-section {
  background: #fff;
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 8px;
  padding: 0.75rem 0.9rem 0.9rem;
}
.step-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f1f1f3;
}
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ED7C30;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.step-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1f2937;
}
.step-status {
  margin-left: auto;
  font-size: 0.9rem;
}
.step-status-done {
  color: #16a34a;
  font-weight: 700;
}
.step-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.step-body .extra-row { margin: 0; }
.step-body .climate-context {
  margin-top: 0.2rem;
}
.step-body .stats-grid {
  margin-top: 0.2rem;
}

.height-column-dialog {
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  padding: 0;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.height-column-dialog::backdrop {
  background: rgba(15, 15, 20, 0.45);
}
.height-column-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.1rem 1.25rem 1.25rem;
}
.height-column-form h3 {
  margin: 0;
  font-size: 1.05rem;
}
.height-column-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.height-column-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}
.height-column-form select {
  padding: 0.4rem 0.5rem;
  border: 1px solid #d4d4d8;
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
.height-column-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* 2D / 3D map stack ─────────────────────────────────────────────────── */
/* .map-stack is now the direct flex child of .dash-map-col, taking over the
 * `flex: 1 1 auto` role that .dash-map used to play. Both the Leaflet map
 * and the deck.gl canvas are absolutely positioned inside it so they share
 * the same footprint and stack cleanly. */
.map-stack {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0.65rem;
}
.map-stack > #solar-map,
.map-stack > .deck-3d-canvas {
  position: absolute;
  inset: 0;
}
.deck-3d-canvas {
  background: #b4d3ec; /* sky-ish fallback while tiles load */
}
.deck-3d-canvas[hidden] { display: none; }
.deck-3d-popup {
  position: absolute;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #d4d4d8;
  border-radius: 4px;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  line-height: 1.3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  z-index: 500;
  max-width: 260px;
}
.deck-3d-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid #d4d4d8;
  border-radius: 4px;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  z-index: 400;
}
.deck-3d-legend .legend-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.deck-3d-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.deck-3d-legend .legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Layer / basemap control for the 3D view — Leaflet-style: a small
 * stacked-tiles icon button that expands into a panel on hover or focus. */
.deck-3d-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 400;
}
.deck-3d-controls-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #b4b4b8;
  border-radius: 4px;
  cursor: pointer;
  color: #1f2937;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  padding: 0;
  transition: opacity 0.12s ease;
}
.deck-3d-controls-icon svg { display: block; }
.deck-3d-controls-icon:hover,
.deck-3d-controls-icon:focus { outline: none; }
.deck-3d-controls-panel {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 180px;
  max-width: 240px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #b4b4b8;
  border-radius: 4px;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  display: none;
}
/* Expand on hover (mouse) or when the icon was clicked (touch/keyboard). */
.deck-3d-controls:hover .deck-3d-controls-panel,
.deck-3d-controls.is-open .deck-3d-controls-panel {
  display: block;
}
.deck-3d-controls:hover .deck-3d-controls-icon,
.deck-3d-controls.is-open .deck-3d-controls-icon {
  /* Hide the icon while panel is shown so they don't overlap visually. */
  opacity: 0;
  pointer-events: none;
}
.deck-3d-controls-panel fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 0.45rem;
}
.deck-3d-controls-panel fieldset:last-of-type { margin-bottom: 0; }
.deck-3d-controls-panel legend {
  font-weight: 600;
  margin-bottom: 0.2rem;
  padding: 0;
}
.deck-3d-controls-panel label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}
.deck-3d-controls-panel .controls-hint {
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid #e4e4e7;
  color: var(--text-muted, #6b7280);
  font-size: 0.72rem;
  line-height: 1.3;
}
.deck-3d-controls-panel .layer-widget-warning {
  margin-top: 0.45rem;
  padding: 0.35rem 0.45rem;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 3px;
  color: #92400e;
  font-size: 0.72rem;
  line-height: 1.35;
}
.deck-3d-controls-panel .layer-widget-warning[hidden] { display: none; }
