/* ═══════════════════════════════════════════════════════
   AggsData — Delivered Price Estimator
   Aesthetic: Clean light — white / light grey, warm amber
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:           #f0f2f5;
  --bg2:          #ffffff;
  --bg3:          #e6e9ed;
  --border:       #cdd1d9;
  --amber:        #b87010;
  --amber-dim:    #8a5208;
  --amber-glow:   rgba(184,112,16,0.10);
  --green:        #2a9e52;
  --red:          #cc2f40;
  --text:         #1e2330;
  --text-dim:     #80889a;
  --text-mid:     #484f62;
  --owned:        #b87010;
  --competitor:   #e05070;
  --order-dot:    #2a9e52;
  --radius-fill:  rgba(184,112,16,0.07);
  --radius-stroke:rgba(184,112,16,0.40);
  --sidebar-w:    510px;
  --font-head:    'Barlow Condensed', sans-serif;
  --font-mono:    'DM Mono', monospace;
  --font-body:    'Barlow', sans-serif;
}

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

html, body {
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  overflow: hidden;
}

/* ── Layout ──────────────────────────────────────────── */
body { display: flex; }

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  transition: width 0.25s ease, min-width 0.25s ease;
}

body.sidebar-collapsed #sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
}

/* ── Sidebar toggle button ───────────────────────────── */
#sidebar-toggle {
  position: fixed;
  top: 50%;
  left: var(--sidebar-w);
  transform: translateY(-50%);
  z-index: 1500;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 4px 4px 0;
  color: var(--text-dim);
  cursor: pointer;
  width: 14px;
  height: 52px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  transition: left 0.25s ease, color 0.15s, background 0.15s;
}

#sidebar-toggle:hover {
  color: var(--amber);
  background: var(--bg3);
}

body.sidebar-collapsed #sidebar-toggle {
  left: 0;
  border-left: 1px solid var(--border);
  border-radius: 0 4px 4px 0;
}

#map-container {
  flex: 1;
  position: relative;
  height: 100vh;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* ── Sidebar Header ──────────────────────────────────── */
#sidebar-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#logo-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

#logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

#logo-title {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--amber);
  line-height: 1;
}

#logo-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 3px;
}

/* ── Panels ──────────────────────────────────────────── */
.panel {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 7px;
  /*border-bottom: 1px solid var(--border);*/
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sub-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin: 16px 0 8px;
  padding-bottom: 7px;
  /*border-bottom: 1px solid var(--border);*/
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Form Controls ───────────────────────────────────── */
.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
  margin-top: 12px;
}

.field-label:first-of-type { margin-top: 0; }

.toggle-row {
  display: flex;
  gap: 6px;
}

.toggle-btn {
  flex: 1;
  padding: 7px 4px;
  background: var(--bg3);
  border: 1px solid #d0d4da;
  border-radius: 3px;
  color: var(--text-mid);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn:hover { border-color: var(--amber-dim); color: var(--text); }

.toggle-btn.active {
  background: var(--amber-glow);
  border-color: var(--amber);
  color: var(--amber);
}

.styled-select, .styled-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg3);
  border: 1px solid #d0d4da;
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  appearance: none;
  outline: none;
  transition: border-color 0.15s;
}

.styled-select:focus, .styled-input:focus {
  border-color: var(--amber-dim);
}

.styled-select option { background: var(--bg2); }

.date-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-row .styled-input { flex: 1; }
.date-sep { color: var(--text-dim); font-size: 12px; }


.hint-text {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--amber-dim);
  letter-spacing: 0.05em;
  animation: pulse-hint 2.5s ease-in-out infinite;
}

@keyframes pulse-hint {
  0%,100% { opacity: 0.6; }
  50%      { opacity: 1;   }
}

/* ── Estimate Block ──────────────────────────────────── */
#reset-params-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 8px;
  letter-spacing: 0.06em;
  transition: all 0.15s;
}

#reset-params-btn:hover {
  border-color: var(--amber-dim);
  color: var(--amber);
}

#clear-btn {
  background: none;
  border: 1px solid var(--amber-dim);
  border-radius: 3px;
  color: var(--amber-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 8px;
  letter-spacing: 0.06em;
  transition: all 0.15s;
  white-space: nowrap;
}

#clear-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#methodology-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 2px 6px;
  transition: all 0.15s;
}

#methodology-btn:hover { border-color: var(--amber-dim); color: var(--amber); }

/* Muted note appended to a sub-title (e.g. "within 15 mi") */
.sub-note {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text-dim);
}

/* Methodology explainer card (toggled by the ⓘ button) */
#methodology-popover {
  display: none;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 4px;
  padding: 12px 14px;
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-mid);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

#methodology-popover.visible { display: block; }

#methodology-popover .mp-title {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 8px;
}

#methodology-popover p  { margin-bottom: 8px; }
#methodology-popover p:last-child { margin-bottom: 0; }
#methodology-popover ul { margin: 0 0 8px 0; padding-left: 16px; }
#methodology-popover li { margin-bottom: 4px; }
#methodology-popover strong { color: var(--text); }

/* Historic price sparkline */
#price-sparkline {
  display: none;
  margin-top: 12px;
  padding: 10px 12px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.spark-svg { width: 100%; height: auto; display: block; }

.spark-line {
  fill: none;
  stroke: var(--amber-dim);
  stroke-width: 1.4px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spark-modeled-halo { fill: var(--bg); stroke: var(--amber); stroke-width: 1.2px; }
.spark-modeled      { fill: var(--amber); }

.spark-projection {
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.2px;
  stroke-dasharray: 2.5 2.5;
  opacity: 0.7;
}

.spark-axis {
  fill: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.02em;
}

#estimate-block {
  background: var(--bg);
  border: 1px solid rgba(184,112,16,0.25);
  border-left: 3px solid var(--amber);
  border-radius: 4px;
  padding: 20px 22px 16px;
}

#est-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 14px;
}

#est-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#est-value {
  font-family: var(--font-head);
  font-size: 56px;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: -0.02em;
  line-height: 1;
}

#est-range {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-mid);
  margin-top: 6px;
  letter-spacing: 0.01em;
}

#est-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* Low effective-sample-size warning on the orders-used line */
#est-meta .thin-data {
  color: var(--amber);
  cursor: help;
}

/* ── Orders Table ────────────────────────────────────── */
#orders-table-wrap {
  overflow-y: auto;
  overflow-x: auto;
  max-height: 240px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Column min-widths — date/numbers fixed, product/plant get room to breathe */
#orders-table th:nth-child(1), #orders-table td:nth-child(1) { min-width: 100px; } /* Date         */
#orders-table th:nth-child(2), #orders-table td:nth-child(2) { min-width: 150px; } /* Product       */
#orders-table th:nth-child(3), #orders-table td:nth-child(3) { min-width: 170px; } /* Plant         */
#orders-table th:nth-child(4), #orders-table td:nth-child(4) { min-width:  96px; } /* Dist. to Plant*/
#orders-table th:nth-child(5), #orders-table td:nth-child(5) { min-width:  96px; } /* Dist. to Point*/
#orders-table th:nth-child(6), #orders-table td:nth-child(6) { min-width:  80px; } /* Volume        */
#orders-table th:nth-child(7), #orders-table td:nth-child(7) { min-width:  80px; } /* Base ASP      */
#orders-table th:nth-child(8), #orders-table td:nth-child(8) { min-width:  80px; } /* Delivery      */
#orders-table th:nth-child(9), #orders-table td:nth-child(9) { min-width:  90px; } /* Total ASP     */

#orders-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

#orders-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 5px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  white-space: nowrap;
}

#orders-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

#orders-table thead th.sortable:hover { color: var(--amber); }
#orders-table thead th.sort-asc  .sort-icon,
#orders-table thead th.sort-desc .sort-icon { color: var(--amber); opacity: 1; }
#orders-table thead th:not(.sort-asc):not(.sort-desc) .sort-icon { opacity: 0.3; }

.sort-icon { font-size: 9px; margin-left: 1px; }

#orders-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

#orders-table tbody tr:last-child { border-bottom: none; }
#orders-table tbody tr:hover { background: var(--bg3); }
#orders-table tbody tr.row-highlight { background: rgba(184,112,16,0.08); }

#orders-table tbody td {
  padding: 5px 5px;
  color: var(--text);
  white-space: nowrap;
}

/* Base ASP, Delivery, Total ASP columns (7,8,9) in amber */
#orders-table tbody td:nth-child(7),
#orders-table tbody td:nth-child(8),
#orders-table tbody td:nth-child(9) {
  color: var(--amber);
}

#orders-count-badge {
  background: var(--bg3);
  color: var(--amber);
  border: 1px solid var(--amber-dim);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 9px;
  margin-left: 6px;
  font-family: var(--font-mono);
  vertical-align: middle;
}

/* ── Orders Drawer (fixed bottom) ────────────────────── */
#orders-drawer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 800;
  background: var(--bg2);
  border-top: 2px solid var(--border);
  display: none;
  transition: left 0.25s ease;
}

#orders-drawer.visible { display: block; }

body.sidebar-collapsed #orders-drawer { left: 0; }

#orders-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 38px;
  border-bottom: 1px solid var(--border);
}

#orders-drawer-title {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.orders-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

#download-orders-btn,
#orders-collapse-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 7px;
  letter-spacing: 0.05em;
  transition: all 0.15s;
}

#download-orders-btn:hover { border-color: var(--green); color: var(--green); }
#orders-collapse-btn:hover  { border-color: var(--amber-dim); color: var(--amber); }

#orders-table-container {
  max-height: 240px;
  overflow: hidden;
  transition: max-height 0.22s ease;
}

/* ── Competitors List ────────────────────────────────── */
#competitors-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.competitor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  cursor: default;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.competitor-row:last-child { border-bottom: none; }
.competitor-row:hover { background: var(--bg3); }

.competitor-name {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.competitor-dist {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  margin-left: 10px;
  flex-shrink: 0;
}

.owned-row .competitor-name { color: var(--amber); }
.owned-row .competitor-dist { color: var(--amber-dim); }

/* Used by drive time result rows */
.competitor-geo {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* keep .product-chip available for the tooltip */
.product-chip {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-dim);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1px 5px;
  white-space: nowrap;
}

/* ── Plant hover tooltip ─────────────────────────────── */
#plant-tooltip {
  position: fixed;
  z-index: 9000;
  display: none;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 11px 14px 12px;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  min-width: 180px;
  max-width: 260px;
}

#pt-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

#pt-name {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

#pt-name.owned { color: var(--amber); }

#pt-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 2px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

#pt-badge.owned      { color: var(--amber);      background: rgba(184,112,16,0.10); border: 1px solid rgba(184,112,16,0.28); }
#pt-badge.competitor { color: var(--competitor);  background: rgba(224,80,112,0.08); border: 1px solid rgba(224,80,112,0.25); }

#pt-geo {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-bottom: 9px;
}

#pt-products {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

/* ── Drive Time Analysis ─────────────────────────────── */
#drivetime-section { margin-top: 4px; }

#drivetime-btn {
  background: none;
  border: 1px solid var(--amber-dim);
  border-radius: 3px;
  color: var(--amber-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 8px;
  letter-spacing: 0.06em;
  transition: all 0.15s;
  white-space: nowrap;
}

#drivetime-btn:hover:not(:disabled) {
  border-color: var(--amber);
  color: var(--amber);
}

#drivetime-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

#drivetime-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.dt-meta-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.dt-meta-input {
  width: 44px;
  padding: 3px 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.dt-meta-input::-webkit-inner-spin-button,
.dt-meta-input::-webkit-outer-spin-button { opacity: 0.4; }

.dt-meta-input:focus { border-color: var(--amber-dim); }

#drivetime-loading {
  display: none;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--amber-dim);
  padding: 8px 0;
  animation: pulse-hint 1.5s ease-in-out infinite;
}

#drivetime-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drivetime-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid;
  border-radius: 3px;
  padding: 10px 12px;
}

.drivetime-road-dist {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.drivetime-times {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.drivetime-oneway {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mid);
}

.drivetime-roundtrip {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
  letter-spacing: 0.01em;
}

.drivetime-error {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--red);
}

/* ── Legend ──────────────────────────────────────────── */
#legend {
  position: absolute;
  top: 20px;
  right: 16px;
  background: rgba(255,255,255,0.93);
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 12px 18px 14px;
  backdrop-filter: blur(6px);
  z-index: 1000;
  min-width: 170px;
}

#legend-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #222;
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#legend-collapse-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 3px;
  color: #888;
  cursor: pointer;
  font-size: 9px;
  padding: 2px 5px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

#legend-collapse-btn:hover { color: #444; border-color: #999; }

#legend-body {
  overflow: hidden;
  max-height: 600px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}

#legend-body.collapsed {
  max-height: 0;
  opacity: 0;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #333;
  margin-bottom: 6px;
}

.legend-row:last-child { margin-bottom: 0; }

.legend-section-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 6px;
  margin-top: 2px;
}

.legend-divider {
  border-top: 1px solid #ddd;
  margin: 9px 0;
}

.leg-dot {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.leg-dot.order       { background: #4cb87a; border-radius: 50%; }
.leg-dot.click-point { background: #fff; border: 2px solid var(--amber); border-radius: 50%; }

.leg-iso {
  display: inline-block;
  width: 16px;
  height: 11px;
  flex-shrink: 0;
  border-radius: 2px;
  border: 1.5px solid;
  opacity: 0.85;
}

/* Heatmap legend colour ramp */
.heatmap-ramp-row {
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  margin-top: 2px;
}

.heatmap-ramp {
  display: block;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(to right,
    rgb(20,150,50),
    rgb(150,220,130),
    rgb(240,240,220),
    rgb(240,130,70),
    rgb(200,20,20));
  opacity: 0.85;
}

/* Price heatmap: green (low) → cream (median) → red (high) */
.heatmap-ramp.price-ramp {
  background: linear-gradient(to right,
    rgb(30,160,90),
    rgb(130,210,140),
    rgb(245,245,220),
    rgb(240,150,60),
    rgb(205,40,40));
}

.heatmap-ramp-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 7.5px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

/* Toggle buttons (heatmap + isochrone) — sit below their section label */
.iso-toggle-btn {
  display: block;
  margin-bottom: 7px;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: 1.6;
}

.iso-toggle-btn:hover  { color: var(--text); border-color: var(--text-mid); }
.iso-toggle-btn.iso-on { color: var(--amber); border-color: var(--amber-dim); background: rgba(184,112,16,0.08); }

/* Hide legend colour chips when layer is off */
#iso-legend-rows.iso-hidden,
#heatmap-legend-rows.iso-hidden { display: none; }

/* ── Map Overlay Hint ────────────────────────────────── */
#map-overlay-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.90);
  border: 1px solid #d0d4da;
  border-radius: 20px;
  padding: 6px 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--amber-dim);
  letter-spacing: 0.1em;
  pointer-events: none;
  z-index: 900;
  transition: opacity 0.3s;
}

#map-overlay-hint.hidden { opacity: 0; }

/* ── Address search control ──────────────────────────── */
.search-control {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

.search-input-wrap {
  display: flex;
  align-items: stretch;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.14);
  width: 240px;
}

#address-search {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 7px 10px;
  outline: none;
  min-width: 0;
}

#address-search::placeholder { color: var(--text-dim); }

#address-search-clear {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 8px;
  display: flex;
  align-items: center;
  font-size: 11px;
  line-height: 1;
  transition: color 0.15s;
}

#address-search-clear:hover { color: var(--red); }

#address-search-btn {
  background: var(--bg3);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-mid);
  cursor: pointer;
  padding: 0 10px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

#address-search-btn:hover { color: var(--amber); background: var(--bg2); }

#search-results {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 3px 3px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,0.14);
}

.search-result-item {
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg3); color: var(--amber); }

.search-no-results {
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* ── Leaflet overrides ───────────────────────────────── */

/* Lay out topleft controls in a row so the search bar sits
   to the right of the zoom buttons, flush at the top.       */
.leaflet-top.leaflet-left {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}

/* Remove the bottom margin Leaflet adds between stacked controls */
.leaflet-top.leaflet-left .leaflet-control {
  margin-bottom: 0;
}

.leaflet-container {
  background: #e8eaed !important;
  font-family: var(--font-body);
}

.leaflet-tile { filter: none; }

.leaflet-control-zoom a {
  background: var(--bg2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover { background: var(--bg3) !important; }

/* Popup */
.leaflet-popup-content-wrapper {
  background: var(--bg2);
  border: 1px solid #d0d4da;
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.16);
}

.leaflet-popup-tip { background: var(--bg2); }

.leaflet-popup-content {
  margin: 10px 14px;
  line-height: 1.5;
}

.popup-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 4px;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.popup-key  { color: var(--text-dim); font-size: 10px; font-family: var(--font-mono); }
.popup-val  { color: var(--text);     font-size: 11px; font-family: var(--font-mono); }

/* ── Radius circle animation ─────────────────────────── */
@keyframes draw-circle {
  from { stroke-dashoffset: 1000; }
  to   { stroke-dashoffset: 0; }
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--amber-dim); }

/* ── Map labels (shown when sidebar is collapsed) ───── */
.plant-label {
  display: inline-block;
  transform: translate(14px, -50%);
  background: rgba(255,255,255,0.93);
  border: 1px solid #bbb;
  border-radius: 3px;
  padding: 2px 7px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: #222;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 5px rgba(0,0,0,0.18);
}

.order-label {
  display: inline-block;
  transform: translate(10px, -50%);
  background: rgba(255,255,255,0.92);
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 3px 7px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: #333;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.13);
  line-height: 1.5;
}

.order-label .ol-product { font-weight: 600; color: #111; }
.order-label .ol-meta    { color: #666; }

/* ── Order hover tooltip ─────────────────────────────── */
.order-tooltip {
  background: rgba(255,255,255,0.96) !important;
  border: 1px solid #ccc !important;
  border-radius: 3px !important;
  font-family: var(--font-mono) !important;
  font-size: 10px !important;
  color: #333 !important;
  padding: 4px 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important;
}
