:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --text: #1b1d20;
  --muted: #5d636b;
  --border: #dcd8d0;
  --accent: #1f5fd1;
  --accent-text: #ffffff;
  --soon: #d0342c;
  --tomorrow: #b7791f;
  --later: #8a9099;
  --selected: #1f5fd1;
  --officer: #2f4fb5;
  --sweeper: #13806f;
  --good: #1d8a4e;
  --shadow: 0 6px 24px rgba(20, 22, 25, 0.14), 0 1px 3px rgba(20, 22, 25, 0.1);
  --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181b;
    --surface: #1f2226;
    --surface-2: #272b30;
    --text: #eceae6;
    --muted: #a3a8af;
    --border: #3a3f46;
    --accent: #6d9ef5;
    --accent-text: #0e1116;
    --soon: #f0625a;
    --tomorrow: #e0a43a;
    --later: #7d848d;
    --selected: #6d9ef5;
    --officer: #7f9bf0;
    --sweeper: #3cc0a8;
    --good: #4cc38a;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

#map { position: fixed; inset: 0; }

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 380px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.brand h1 span { color: var(--soon); }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }

h2 { margin: 0; font-size: 18px; }
h3 { margin: 0 0 4px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.45; }
p { margin: 0; }

button {
  font: inherit;
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.6; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.ghost { background: none; padding: 6px 10px; font-size: 13px; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }

.status { font-size: 14px; color: var(--muted); }
.status.error { color: var(--soon); }

.block {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.block-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.block-head p { font-size: 14px; margin-top: 2px; }

.next {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
  border-left: 4px solid var(--later);
}
.next.today { border-left-color: var(--soon); }
.next.tomorrow { border-left-color: var(--tomorrow); }
.next .when { font-size: 17px; font-weight: 650; }
.next .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.ticket { font-size: 15px; line-height: 1.45; }
.ticket strong { font-weight: 650; }
.ticket .live-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--officer);
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 4px;
  vertical-align: 1px;
}

.eta { display: flex; flex-direction: column; gap: 6px; }
.eta-row { display: flex; align-items: baseline; gap: 10px; }
.eta-label { width: 92px; color: var(--muted); font-size: 14px; }
.eta-time { font-size: 18px; font-weight: 650; }
.conf {
  margin-left: auto;
  font-size: 12px;
  font-weight: 650;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.conf-high { color: var(--good); border-color: var(--good); }
.conf-medium { color: var(--tomorrow); border-color: var(--tomorrow); }
.conf-low { color: var(--muted); }

.alerts, .crews { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.alerts { border-top: none; padding-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 1.4; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select {
  font: inherit;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
input[type="range"] { width: 100%; accent-color: var(--sweeper); }
button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font-size: 14px;
  align-self: flex-start;
}

.leads { border: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.leads legend { font-size: 14px; padding: 0; margin-bottom: 6px; }
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  cursor: pointer;
  background: var(--surface-2);
}
.chip-check:has(input:checked) { border-color: var(--accent); color: var(--accent); }

.windows summary { cursor: pointer; font-size: 14px; }
.windows ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.6; }

.live { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.report { display: flex; gap: 8px; flex-wrap: wrap; }

.notes { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
a { color: var(--accent); }

.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 720px) {
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 58%;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .brand p { display: none; }
}
