:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --panel-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --start: #16a34a;
  --end: #dc2626;
  --route: #2563eb;
  --chokepoint: #d97706;
  --map-bg: #0b1220;
  --map-grid: #1e293b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #eef2f7;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg);
  color: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.subtitle {
  margin: 2px 0 0;
  color: #94a3b8;
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #cbd5e1;
  padding: 6px 10px;
  border: 1px solid #334155;
  border-radius: 999px;
  white-space: nowrap;
}

.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.status.ok .dot {
  background: #22c55e;
}

.status.bad .dot {
  background: #ef4444;
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  padding: 16px 24px 32px;
  align-items: start;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.field {
  margin-bottom: 14px;
}

label,
legend {
  display: block;
  font-weight: 600;
  font-size: 12px;
  color: #334155;
  margin-bottom: 6px;
  padding: 0;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: var(--accent);
}

fieldset.field {
  border: none;
  padding: 0;
  margin: 0 0 14px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 13px;
  margin: 0;
}

.checks input {
  accent-color: var(--accent);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.ghost {
  background: #fff;
  color: #334155;
  border-color: var(--border);
}

button.ghost:hover {
  background: var(--panel-alt);
}

button.small {
  padding: 5px 10px;
  font-size: 12px;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

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

.presets-label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.preset-buttons button {
  background: var(--panel-alt);
  color: #334155;
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 12px;
  padding: 5px 9px;
}

.preset-buttons button:hover {
  background: #e2e8f0;
}

.count {
  color: var(--muted);
  font-weight: 500;
}

.preset-buttons.scroll,
.corridor-list.scroll {
  max-height: 190px;
  overflow-y: auto;
  padding-right: 4px;
  align-content: flex-start;
}

.preset-buttons button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.corridor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.corridor {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  color: #334155;
}

.corridor small {
  color: var(--muted);
}

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

.hidden {
  display: none !important;
}

.placeholder {
  color: var(--muted);
  padding: 40px 10px;
  text-align: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.metric .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.metric .v {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.metric .v small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.map-wrap {
  background: var(--map-bg);
  border-radius: 8px;
  padding: 8px;
}

#map {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1000 / 520;
  border-radius: 6px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 6px 2px;
  color: #cbd5e1;
  font-size: 12px;
}

.legend i.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.swatch.start {
  background: var(--start);
}

.swatch.end {
  background: var(--end);
}

.swatch.route {
  background: var(--route);
  border-radius: 2px !important;
  height: 4px !important;
}

.swatch.chokepoint {
  background: var(--chokepoint);
}

.section {
  margin-top: 18px;
}

.section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #334155;
  margin: 0 0 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-head h2 {
  margin: 0;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge.none {
  background: var(--panel-alt);
  color: var(--muted);
  border-color: var(--border);
  font-weight: 500;
}

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

.error code {
  font-weight: 700;
}

.raw {
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  max-height: 340px;
  font-size: 12px;
  line-height: 1.5;
}

.map-label {
  fill: #94a3b8;
  font-size: 11px;
  font-family: system-ui, sans-serif;
}

.map-label-bright {
  fill: #e2e8f0;
  font-weight: 600;
}

.map-label-chokepoint {
  fill: #fbbf24;
}

.map-grid-line {
  stroke: var(--map-grid);
  stroke-width: 1;
}

.map-land {
  fill: #1e293b;
  stroke: #334155;
  stroke-width: 0.6;
}

.map-route-halo {
  fill: none;
  stroke: #0b1220;
  stroke-width: 6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.map-route {
  fill: none;
  stroke: var(--route);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.map-endpoint {
  stroke: #fff;
  stroke-width: 1.5;
}

.marker-start {
  fill: var(--start);
}

.marker-end {
  fill: var(--end);
}

.map-chokepoint {
  fill: var(--chokepoint);
}
