:root {
  --bg:           #ffffff;
  --panel-bg:     #fafafa;
  --border:       #e0e0e0;
  --text:         #212121;
  --text-muted:   #616161;
  --accent:       #1b5e20;

  --c1: #1b5e20;  /* 0-30 mi  : deep forest green */
  --c2: #aed581;  /* 30-50 mi : light green       */
  --c3: #fb8c00;  /* 50-70 mi : orange            */
  --c4: #c62828;  /* >70 mi   : red               */

  --gap-low:      #1b5e20;
  --gap-moderate: #fb8c00;
  --gap-high:     #c62828;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  width: 380px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 24px 32px;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.04);
}

#map {
  flex: 1;
  height: 100%;
}

/* ---- Panel typography ---- */
h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 24px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

p {
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 12px;
}

.description, .instruction, .takeaway, .caveat, .method-note {
  font-size: 14px;
  line-height: 1.55;
}

.instruction {
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  color: var(--text);
}

.takeaway {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 0 0 20px;
}

.method-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 24px;
}

.caveat {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 8px 0 0;
}

/* ---- Back button ---- */
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0 0 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  font-family: inherit;
}
.back-button:hover { color: var(--text); }

/* ---- Legend (idle view) ---- */
.legend {
  margin: 20px 0;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 4px 0;
}
.legend-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

/* ---- Metric cards ---- */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 20px;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 4px;
}

.metric-value {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---- Breakdown table ---- */
table.breakdown {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0 0 20px;
}

table.breakdown th,
table.breakdown td {
  padding: 8px 4px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
table.breakdown th:first-child,
table.breakdown td:first-child {
  text-align: left;
}
table.breakdown th {
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}
table.breakdown td .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
}

/* ---- Horizontal bar chart ---- */
.bars {
  margin: 0 0 20px;
}

.bar-row {
  display: grid;
  grid-template-columns: 64px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
}

.bar-label {
  color: var(--text-muted);
}

.bar-track {
  background: #eeeeee;
  height: 14px;
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  transition: width 0.3s ease;
}

.bar-pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ---- Gap interpretation badge ---- */
.gap-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Leaflet popup styling ---- */
.leaflet-popup-content {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}
.leaflet-popup-content strong { color: var(--text); }

/* ---- Layer control ---- */
.leaflet-control-layers {
  font-family: inherit;
  font-size: 13px;
}
