:root {
  --bg: #eef1f3;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #697681;
  --line: #dfe5e8;
  --alamo: #c62835;
  --dark: #18222b;
  --shadow: 0 12px 40px rgba(22, 35, 45, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); overflow: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
  min-height: 680px;
}

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 30px rgba(22, 35, 45, 0.05);
}

.brand-block {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--alamo);
  color: #fff;
  font-weight: 900;
  font-size: 24px;
  border-radius: 9px;
  letter-spacing: -0.04em;
}

.brand-name {
  color: var(--alamo);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

h1 {
  margin: 3px 0 6px;
  font-size: 20px;
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.subtitle, .helper-text, .sidebar-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.control-section { display: grid; gap: 12px; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 3px 0; font-weight: 700; font-size: 12px; }
.text-button:hover { color: var(--ink); }

.company-controls { display: grid; gap: 9px; }
.company-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.company-card.active { border-color: color-mix(in srgb, var(--company-color) 55%, white); box-shadow: 0 6px 20px rgba(25, 40, 50, .06); }
.company-row { display: flex; align-items: center; gap: 10px; padding: 12px; }
.company-checkbox, .plant-checkbox { width: 17px; height: 17px; accent-color: var(--company-color); }
.company-swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--company-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--company-color) 12%, transparent); }
.company-label { flex: 1; min-width: 0; }
.company-label strong { display: block; font-size: 13px; }
.company-label small { color: var(--muted); font-size: 11px; }
.current-pill { padding: 3px 7px; border-radius: 99px; background: #fbeaec; color: #a71c29; font-weight: 800; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.plant-list { display: grid; gap: 0; border-top: 1px solid var(--line); background: #fafbfb; }
.plant-row { display: flex; align-items: center; gap: 9px; padding: 9px 12px 9px 38px; border-bottom: 1px solid #edf0f1; font-size: 12px; }
.plant-row:last-child { border-bottom: 0; }
.plant-name { display: flex; flex-direction: column; gap: 1px; }
.plant-name small { color: var(--muted); font-size: 10px; }
.company-card:not(.active) .plant-list { opacity: .48; }

.coverage-control { padding-top: 2px; }
.radius-value { font-weight: 900; color: var(--alamo); font-size: 13px; }
input[type="range"] { width: 100%; accent-color: var(--alamo); }
.slider-labels { display: flex; justify-content: space-between; color: #89939b; font-size: 10px; margin-top: -6px; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.summary-card { padding: 12px; border-radius: 11px; background: #f6f8f9; border: 1px solid #e7ecee; min-height: 88px; }
.summary-label { display: block; min-height: 28px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.summary-card strong { display: block; font-size: 22px; line-height: 1.1; margin-top: 4px; }
.summary-card small { color: var(--muted); font-size: 10px; }

.sidebar-actions { display: grid; gap: 8px; }
.primary-button, .secondary-button {
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 800;
  border: 1px solid transparent;
}
.primary-button { color: #fff; background: var(--dark); }
.primary-button:hover { background: #0d141a; }
.secondary-button { color: var(--ink); background: #fff; border-color: var(--line); }
.secondary-button:hover { background: #f7f8f9; }

.sidebar-footer { margin-top: auto; padding-top: 4px; display: grid; gap: 7px; }
.status-row { display: flex; align-items: center; gap: 7px; color: #55616a; font-size: 10px; font-weight: 700; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #81909a; }
.status-dot.live { background: #1b9c68; box-shadow: 0 0 0 4px rgba(27,156,104,.11); }
.status-dot.loading { background: #e4a100; box-shadow: 0 0 0 4px rgba(228,161,0,.11); }

.map-panel { position: relative; min-width: 0; background: #dde4e8; }
#map { position: absolute; inset: 0; background: #e8edef; }
.map-topbar {
  position: absolute;
  z-index: 500;
  top: 20px;
  left: 22px;
  right: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  pointer-events: none;
}
.map-topbar > div {
  pointer-events: auto;
  padding: 10px 13px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(215,223,227,.92);
  border-radius: 11px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.map-topbar strong { display: block; margin-top: 2px; font-size: 14px; }
.eyebrow { color: var(--alamo); font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; max-width: 520px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.map-note { position: absolute; z-index: 500; right: 18px; bottom: 18px; padding: 8px 11px; border-radius: 9px; background: rgba(255,255,255,.93); border: 1px solid rgba(215,223,227,.92); color: var(--muted); box-shadow: var(--shadow); font-size: 10px; }

.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a { color: #1e2a33 !important; border-color: #e0e6e8 !important; }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: 0 14px 35px rgba(20, 32, 40, .17); }
.leaflet-popup-content { margin: 14px 16px; }
.popup-company { font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.popup-title { font-size: 15px; font-weight: 900; margin-bottom: 4px; }
.popup-address { color: #65727b; font-size: 11px; line-height: 1.45; max-width: 230px; }
.custom-marker { background: transparent; border: 0; }
.marker-pin { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50% 50% 50% 7px; transform: rotate(-45deg); border: 3px solid white; box-shadow: 0 4px 12px rgba(0,0,0,.22); }
.marker-pin span { width: 8px; height: 8px; border-radius: 50%; background: #fff; transform: rotate(45deg); }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(620px, 75vh); height: auto; min-height: 100vh; }
  .sidebar { max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .map-panel { min-height: 620px; }
  .map-topbar { left: 12px; right: 12px; top: 12px; align-items: flex-start; }
  .legend { display: none; }
}

@media (max-width: 520px) {
  .sidebar { padding: 18px; }
  .brand-block { grid-template-columns: 40px 1fr; }
  .brand-mark { width: 40px; height: 40px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .map-note { display: none; }
}

/* v1.2 irregular service-area model */
.model-control {
  padding: 12px 13px;
  border: 1px solid #e5eaed;
  border-radius: 11px;
  background: #f8fafb;
  gap: 8px;
}
.model-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #a71c29;
  background: #fbeaec;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.popup-radius { margin-top: 7px; font-size: 10px; font-weight: 700; color: #61707a; }


/* v1.4 fixed drive-time model */
.model-time { font-size: 16px; font-weight: 900; letter-spacing: -0.02em; }
.coverage-warning { padding: 10px 12px; border: 1px solid #f0c36d; border-radius: 10px; background: #fff8e8; color: #7a5610; font-size: 11px; line-height: 1.45; }
.coverage-missing-marker .marker-pin { filter: grayscale(.25); opacity: .72; }


/* v1.5 simplified header */
.simple-brand-block { grid-template-columns: 1fr; gap: 0; }
