:root {
  --bg: #171a21;
  --panel: #1f2330;
  --text: #e6e8ef;
  --muted: #9aa1b4;
  --accent: #4c8dff;
  --border: #2f3546;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
#app { display: flex; height: 100%; }
#panel {
  width: 320px;
  flex: 0 0 320px;
  padding: 14px 16px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
#map { flex: 1; min-width: 0; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.row { display: flex; gap: 6px; margin-bottom: 8px; }
.row > * { flex: 1; min-width: 0; }
input[type="text"], select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #12141b;
  color: var(--text);
  font: inherit;
}
button {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #2a3042;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
button:hover { background: #343b52; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: #3b7cf0; }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
label .val { float: right; color: var(--text); }
input[type="range"] { width: 100%; margin: 4px 0 0; }
.status { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.status.error { color: #ff7b72; }
.status.ok { color: #7ee787; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.legend div { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: 0 0 14px; }
label.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; }
label.check input { margin: 0; }
.sw.dash { border-radius: 2px; height: 4px; background: repeating-linear-gradient(90deg, #e53935 0 6px, transparent 6px 10px); }
.sw.grad { border-radius: 3px; background: linear-gradient(90deg, hsl(0,85%,45%), hsl(60,85%,45%), hsl(120,85%,45%)); }
footer { margin-top: 18px; font-size: 11px; color: var(--muted); }
footer a { color: var(--muted); }

/* Leaflet popup for intersection control */
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 8px; }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.ctl-popup { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.ctl-title { font-weight: 600; margin-bottom: 2px; }
.ctl-sub { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.ctl { text-align: left; white-space: normal; }
.ctl-timing { margin: 2px 0 6px 8px; padding-left: 8px; border-left: 2px solid var(--accent); }
.ctl-timing label { margin: 4px 0 0; font-size: 12px; }
.ctl-timing label .val { float: right; }
.ctl-timing input[type="range"] { margin: 2px 0 0; }
.ctl.active { border-color: var(--accent); background: #2a3d63; }
.ctl.reset { margin-top: 6px; color: var(--muted); }

@media (max-width: 720px) {
  #app { flex-direction: column; }
  #panel { width: 100%; flex: 0 0 auto; max-height: 45%; border-right: 0; border-bottom: 1px solid var(--border); }
}
