:root {
  --bg: #0d1117;
  --bg-1: #131a23;
  --bg-2: #1a2230;
  --bg-3: #232d3c;
  --line: #2a3746;
  --line-2: #384759;
  --fg: #d6e0ea;
  --fg-dim: #8fa3b6;
  --fg-faint: #6b7f92;
  --accent: #4da3ff;
  --warn: #e0a03a;
  --bad: #e0553a;
  --ok: #45c08a;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --ev-person: #4da3ff;
  --ev-vehicle: #45c08a;
  --ev-plate: #e0a03a;
  --ev-face_match: #b184e8;
  --ev-audio: #38b6c4;
  --ev-speech: #6f8ff5;
  --ev-geo: #8fa3b6;
  --ev-other: #7b8ea1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); }

/* ---------- chrome ---------- */

.banner {
  position: sticky;
  top: 0;
  z-index: 900;
  background: linear-gradient(90deg, #3a2a12, #2c2416);
  color: #f0c987;
  border-bottom: 1px solid #5a4320;
  padding: 5px 14px;
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: center;
  font-weight: 600;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 9px 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
}
.brand {
  color: var(--fg);
  font-weight: 700;
  letter-spacing: .11em;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
}
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: var(--fg-dim);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
}
.topbar nav a:hover { background: var(--bg-2); text-decoration: none; }
.topbar nav a.on { background: var(--bg-3); color: var(--fg); }
.spacer { flex: 1; }
.outdir { font-size: 10.5px; color: var(--fg-faint); }

main { padding: 14px; max-width: 1500px; margin: 0 auto; }

.foot {
  border-top: 1px solid var(--line);
  padding: 10px 14px 28px;
  color: var(--warn);
  font-size: 11px;
  text-align: center;
}

h1 { font-size: 16px; margin: 0 0 3px; letter-spacing: .02em; }
h2 {
  font-size: 11px;
  margin: 0 0 8px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
}
.sub { color: var(--fg-faint); font-size: 11.5px; margin: 0 0 14px; }

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.empty { color: var(--fg-faint); font-style: italic; font-size: 12px; }
.err { color: var(--bad); }

/* ---------- badges + bars ---------- */

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.sev-high    { background: #40170f; color: #ff9478; border-color: #7a2c1c; }
.sev-medium  { background: #3a2c10; color: #f0c069; border-color: #6d5320; }
.sev-low     { background: #10303a; color: #78ccdd; border-color: #1f5566; }
.sev-none    { background: #1e2733; color: #90a4b7; border-color: #33455a; }

.v-probable  { background: #3a2c10; color: #f0c069; border-color: #6d5320; }
.v-possible  { background: #2e2438; color: #c9a6ef; border-color: #4d3b63; }
.v-no_match  { background: #1e2733; color: #90a4b7; border-color: #33455a; }

.conf {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-dim);
}
.conf .bar {
  flex: 1;
  min-width: 40px;
  max-width: 120px;
  height: 5px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
}
.conf .bar i { display: block; height: 100%; border-radius: 3px; }
.c-hi  { background: var(--ok); }
.c-mid { background: var(--warn); }
.c-lo  { background: var(--bad); }

.caveat {
  color: var(--warn);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 5px;
  border-left: 2px solid #5a4320;
  padding-left: 7px;
}

/* ---------- timeline view ---------- */

.inc-row {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}
.inc-head {
  display: flex;
  gap: 12px;
  padding: 10px;
  align-items: flex-start;
}
.inc-head .thumb {
  width: 148px;
  height: 84px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  flex: 0 0 auto;
}
.inc-meta { flex: 1; min-width: 0; }
.inc-meta .t { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.inc-meta .m {
  color: var(--fg-faint);
  font-size: 11px;
  font-family: var(--mono);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 5px;
}

/* Frigate-style strip */
.strip-wrap { padding: 0 10px 10px; }
.strip {
  position: relative;
  height: 26px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
}
.strip .tick {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 3px;
  border-radius: 2px;
  transform: translateX(-1.5px);
  opacity: .92;
}
.strip .tick:hover { outline: 1px solid #fff; opacity: 1; }
.strip .grid {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--line);
}
.strip-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--fg-faint);
  margin-top: 3px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 10.5px;
  color: var(--fg-dim);
  margin-bottom: 12px;
}
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---------- incident detail ---------- */

.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
@media (max-width: 1080px) { .grid2 { grid-template-columns: 1fr; } }

[hidden] { display: none !important; }

video.clip {
  width: 100%;
  border-radius: 4px;
  background: #000;
  border: 1px solid var(--line-2);
  display: block;
}
.playhead {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 5px rgba(255,255,255,.8);
  pointer-events: none;
}

.evlist, .scrollpanel { max-height: 460px; overflow-y: auto; }
.ev {
  display: flex;
  gap: 9px;
  padding: 7px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.ev:hover { background: var(--bg-2); }
.ev.on { background: var(--bg-3); border-left-color: var(--accent); }
.ev img {
  width: 76px; height: 44px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--bg-3);
  flex: 0 0 auto;
}
.ev .noimg {
  width: 76px; height: 44px;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px dashed var(--line-2);
  flex: 0 0 auto;
}
.ev .body { flex: 1; min-width: 0; }
.ev .top { display: flex; gap: 8px; align-items: baseline; }
.ev .tt { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.ev .ty {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--fg-dim);
}
.ev .lb { font-size: 12px; margin: 2px 0 4px; word-break: break-word; }

.card {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.card:last-child { border-bottom: 0; }
.card.slim { padding: 5px 0; }
.card img {
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  flex: 0 0 auto;
}
.card .k { color: var(--fg-faint); font-size: 11px; }
.card .body { flex: 1; min-width: 0; }
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 12px;
  font-size: 11.5px;
}
.kv dt { color: var(--fg-faint); }
.kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }

.tags { display: flex; flex-direction: column; gap: 5px; }
.tag-row { display: grid; grid-template-columns: 92px 118px 1fr 34px; gap: 8px; align-items: center; font-size: 11px; }
.tag-row .win { font-family: var(--mono); color: var(--fg-faint); font-size: 10px; }
.tag-bar { height: 16px; background: var(--bg-2); border-radius: 3px; position: relative; overflow: hidden; }
.tag-bar i { position: absolute; top: 0; bottom: 0; background: #1f5566; border: 1px solid #38b6c4; border-radius: 3px; }
.tag-label { font-size: 11px; color: #a9d6de; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tx { max-height: 200px; overflow-y: auto; }
.tx div {
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  cursor: pointer;
}
.tx div:hover { background: var(--bg-2); }
.tx .ts { font-family: var(--mono); font-size: 10.5px; color: var(--accent); margin-right: 7px; }

#map, #map-all { height: 340px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--bg-2); }
#map-all { height: calc(100vh - 210px); min-height: 400px; }
.leaflet-container { background: #0a0f16; }
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.72) contrast(1.05) saturate(.55); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-2); color: var(--fg); border: 1px solid var(--line-2);
}
.leaflet-popup-content { font: 12px var(--sans); }
.leaflet-bar a { background: var(--bg-2); color: var(--fg); border-color: var(--line); }

textarea {
  width: 100%;
  min-height: 230px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 9px;
  font: 12.5px/1.6 var(--sans);
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }

button {
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 6px 13px;
  font: 600 12px var(--sans);
  cursor: pointer;
}
button:hover { background: #2c3a4c; }
button.primary { background: #17456f; border-color: #2a6ba8; color: #d8ecff; }
button.primary:hover { background: #1c5488; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 9px; flex-wrap: wrap; }
.status { font-size: 11.5px; color: var(--fg-faint); }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.flags { list-style: none; padding: 0; margin: 0 0 10px; }
.flags li {
  font-size: 11.5px;
  color: var(--warn);
  padding: 3px 0 3px 8px;
  border-left: 2px solid #5a4320;
  margin-bottom: 3px;
}
.limits { margin: 8px 0 0; padding-left: 16px; color: var(--fg-faint); font-size: 11px; }

/* ---------- auth + upload ---------- */

.topbar .logout { color: var(--fg-faint); font-size: 11.5px; margin-left: 12px; }
.topbar .logout:hover { color: var(--fg); }

.login-wrap { display: flex; justify-content: center; padding: 60px 16px; }
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 22px 20px;
}
.login-card .brand { font-weight: 700; letter-spacing: .08em; font-size: 12.5px; }
.login-card .sub { color: var(--fg-dim); font-size: 12px; margin: 6px 0 16px; }
.login-card label, .upload-form label {
  display: block;
  margin: 12px 0 4px;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.login-card input, .upload-form input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  color: var(--fg);
  font: 13px var(--sans);
  padding: 7px 9px;
}
.login-card input:focus, .upload-form input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.login-card button { width: 100%; margin-top: 16px; padding: 8px; }
.login-note { color: var(--fg-faint); font-size: 11px; margin: 10px 0 0; }
.login-error {
  background: #2c1714;
  border: 1px solid #6b2a20;
  color: #ffb3a5;
  border-radius: 4px;
  padding: 7px 9px;
  font-size: 12px;
  margin: 0 0 4px;
}

.upload-form { max-width: 460px; margin-top: 14px; }
.upload-form fieldset.geo {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 12px 14px;
  margin: 18px 0 0;
}
.upload-form legend { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-dim); }
.upload-form .row { display: flex; gap: 10px; }
.upload-form .row span { flex: 1; }
.upload-form button { margin-top: 18px; padding: 8px 16px; }

.upload-state { font-size: 14px; font-weight: 600; }
.upload-state.run { color: var(--warn); }
.upload-state.ok { color: var(--ok); }
.upload-state.bad { color: var(--bad); }
.log-tail {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px 12px;
  font: 11.5px/1.5 var(--mono);
  color: var(--fg-dim);
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
}
.login-card label .k, .upload-form label .k, .upload-form legend .k {
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg-faint);
  font-size: 11px;
}
