:root {
  --bg: #0b1220;
  --bg-elev: #111a2e;
  --fg: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(255,255,255,0.08);
  --accent: #fbbf24;
  --blue: #38bdf8;
  --purple: #a78bfa;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.dashboard {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; }
}

/* CONTROLS */
.controls {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: 24px;
}

.control + .control {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.control label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--fg);
}

.unit {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}

.slider-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 12px;
  align-items: center;
}

.slider-row input[type=range] {
  width: 100%;
  accent-color: var(--blue);
}

.slider-row input[type=number] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px 8px;
  border-radius: 6px;
  font: inherit;
  text-align: right;
}

.hint {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

/* OUTPUTS */
.outputs {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  border-top: 3px solid var(--blue);
}

.stat-card.stat-purple { border-top-color: var(--purple); }
.stat-card.stat-green { border-top-color: var(--green); }
.stat-card.stat-amber { border-top-color: var(--amber); }
.stat-card.stat-red { border-top-color: var(--red); }

.stat-num {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-lbl {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* VIZ */
.viz {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  overflow: hidden;
}

#hex-svg {
  width: 100%;
  height: auto;
  max-height: 720px;
  display: block;
  border-radius: 8px;
}

.hex-tile {
  fill: rgba(56, 189, 248, 0.10);
  stroke: rgba(56, 189, 248, 0.55);
  stroke-width: 2;
  cursor: default;
  transition: fill 0.2s;
}

.hex-tile:hover {
  fill: rgba(56, 189, 248, 0.20);
}

.hex-tile.is-center {
  fill: rgba(167, 139, 250, 0.18);
  stroke: var(--purple);
  stroke-width: 3;
}

.hex-label {
  fill: var(--fg);
  font-size: 18px;
  font-weight: 600;
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.hex-sub {
  fill: var(--muted);
  font-size: 12px;
  text-anchor: middle;
  pointer-events: none;
}

.cell-dot {
  fill: var(--green);
  opacity: 0.85;
  filter: drop-shadow(0 0 4px var(--green));
}

.cell-dot.dim {
  fill: var(--muted);
  opacity: 0.25;
  filter: none;
}

.axis-label {
  fill: var(--accent);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

/* FORMULAS */
.formulas {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
}

.formulas summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 0;
}

.formulas summary:hover { color: var(--fg); }

.formulas ul {
  margin: 12px 0 4px 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

.formulas li { margin-bottom: 4px; }

.formulas code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--blue);
  font-size: 12px;
}

/* PROJECT SECTION */
.project {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 8px;
}

.project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.project-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.project-meta {
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
  margin-left: 8px;
}

.project-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.project-controls label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  gap: 4px;
}

.project-controls input[type=number] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px 10px;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  width: 80px;
  font-size: 14px;
}

#pavement-svg {
  width: 100%;
  height: auto;
  max-height: 280px;
  display: block;
  border-radius: 8px;
  margin-top: 16px;
}

.proj-hex {
  fill: rgba(56, 189, 248, 0.10);
  stroke: rgba(56, 189, 248, 0.45);
  stroke-width: 1;
}

.axis-label-small {
  fill: var(--accent);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

/* SECTION TITLE */
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 24px 0 0 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.section-title:first-child { margin-top: 0; }

.reset-btn {
  margin-top: 24px;
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.reset-btn:hover {
  color: var(--fg);
  border-color: var(--accent);
}

/* MASS SECTION */
.mass {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 8px;
}

.mass-bar {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.mass-bar-track {
  display: flex;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elev);
}

.mass-seg {
  height: 100%;
  transition: width 0.2s ease;
}

.mass-seg-gen  { background: #38bdf8; }
.mass-seg-tile { background: #a78bfa; }
.mass-seg-supp { background: #fbbf24; }

.mass-bar-legend {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.mass-bar-legend .leg {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mass-bar-legend b {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.mass-bar-legend .leg::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.leg-gen::before  { background: #38bdf8; }
.leg-tile::before { background: #a78bfa; }
.leg-supp::before { background: #fbbf24; }
