:root {
  --ink: #0d1f35; --muted: #5f6b7a; --line: #d9dee5; --bg: #f4f6f9; --card: #fff;
  --ok: #2e7d32; --warn: #b26a00; --bad: #c62828; --accent: #1565c0;
  --surface: #fff; --hover: #eef4fb; color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
/* Dark: chosen, or "Match computer" with the computer set to dark. */
:root[data-theme=dark] {
  --ink: #e7ecf2; --muted: #9aa6b4; --line: #2a3646; --bg: #0b121c; --card: #131d2a;
  --surface: #131d2a; --hover: #1d2b3d; --accent: #4f8fe0; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --ink: #e7ecf2; --muted: #9aa6b4; --line: #2a3646; --bg: #0b121c; --card: #131d2a;
    --surface: #131d2a; --hover: #1d2b3d; --accent: #4f8fe0; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.grow { flex: 1; }
button, select, input { font: inherit; }
button, select { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; color: #fff; }
.pill.ok { background: var(--ok); } .pill.bad { background: var(--bad); } .pill.warn { background: var(--warn); }
.msg { color: var(--bad); font-size: 14px; }
.row { display: flex; align-items: center; gap: 8px; }

/* sign in */
.login { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 20px; }
.login form { width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin: 0; font-size: 22px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.login label.check { flex-direction: row; align-items: center; }
.login input:not([type=checkbox]) { padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.login .legal { font-size: 12px; margin: 0; }
a { color: var(--accent); }

/* main */
.main { display: flex; flex-direction: column; height: 100%; }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.body { flex: 1; display: flex; min-height: 0; }
.map { flex: 1; min-width: 0; }
.panel { width: 340px; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); padding: 10px 12px; }
.panel h2 { font-size: 15px; margin: 12px 0 6px; }
.panel h2 .sec-t { all: unset; cursor: pointer; display: flex; align-items: center; gap: 6px; width: 100%; font: inherit; color: var(--ink); }
.panel h2 .sec-t:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.panel h2 .chev { display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; }
.psec.min .chev { transform: rotate(-90deg); }
.psec.min .sec-b { display: none; }
#planes { max-height: 40vh; overflow-y: auto; }
.list .item .pl { width: 24px; height: 24px; flex: none; }
.list .item.emg b { color: #c62828; }
@media (max-width: 760px) {
  .body { flex-direction: column; }
  .panel { width: auto; height: 42%; border-left: 0; border-top: 1px solid var(--line); }
}
.banner { background: var(--bad); color: #fff; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.banner.watch { background: #8e0000; }

.list .item { display: flex; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--bg); cursor: pointer; }
.list .item:hover, .list .item.sel { background: var(--hover); }
.list .item.lost { opacity: .5; }
.list .item .t { flex: 1; min-width: 0; }
.list .item .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed div { font-size: 13px; padding: 3px 0; border-bottom: 1px solid var(--bg); }
.detail { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.detail table { width: 100%; font-size: 13px; border-collapse: collapse; }
.detail td { padding: 2px 0; vertical-align: top; }
.detail td:first-child { color: var(--muted); width: 42%; }

/* markers */
.drone-mk { cursor: pointer; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.drone-mk.lost { opacity: .45; }
.pilot-mk { cursor: pointer; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.site-mk { pointer-events: none; }
.site-mk .nm { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); }
.site-mk .sq { width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid #fff; background: var(--ok); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; }
.site-mk.off .sq { background: #9e9e9e; }
.site-mk.part .sq { background: #f9a825; }   /* on the air, but one of its scanners (C5s) isn't reporting */
.site-mk .nm, .drone-label { font-size: 11px; font-weight: 600; color: #fff; background: rgba(13,31,53,.75); padding: 1px 5px; border-radius: 4px; margin-top: 2px; white-space: nowrap; }

/* The marker's box is only the icon, so its centre is exactly the GPS point at every zoom;
   the label hangs below it without moving it. */
.air-mk { pointer-events: auto; line-height: 0; cursor: pointer; }
.air-mk.sel svg { filter: drop-shadow(0 0 3px #ffd54f) drop-shadow(0 0 2px #ffd54f); }
.air-mk svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.air-mk .lb { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); line-height: 1.4;
  font-size: 10px; font-weight: 600; color: #fff; background: rgba(21,101,192,.85); padding: 0 4px; border-radius: 3px; margin-top: 1px; white-space: nowrap; }
.air-mk.emg .lb { background: #c62828; }

/* history */
.overlay { position: fixed; inset: 0; background: rgba(13,31,53,.35); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 20px; }
.card.wide { width: min(980px, 100%); max-height: 85vh; display: flex; flex-direction: column; }
.scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--bg); }
#hist-rows tr { cursor: pointer; }
#hist-rows tr:hover { background: var(--hover); }

/* the map's own popups and controls */
:root[data-theme=dark] .maplibregl-ctrl-group, :root[data-theme=dark] .maplibregl-popup-content { background: var(--card); color: var(--ink); }
:root[data-theme=dark] .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
:root[data-theme=dark] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1); }

/* the drone list */
.dl-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.dl-form input, .dl-form select, #dl-search, .detail input, .detail select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.dl-form #dl-id { flex: 1 1 200px; } .dl-form #dl-name { flex: 1 1 160px; } .dl-form #dl-pilot { flex: 1 1 180px; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.lv { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; color: #fff; }
.lv.F { background: var(--ok); } .lv.W { background: var(--bad); } .lv.U { background: var(--muted); }
.mark { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.mark .row button.on { outline: 2px solid var(--accent); }
.mark .save { min-width: 84px; font-weight: 600; }
.mark .save.saved { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.mark .save-err { color: #e53935; font-size: 0.9em; }

/* Map layers, settings and zones */
.mapwrap { flex: 1; min-width: 0; position: relative; display: flex; }
.mapwrap .map { flex: 1; }
@media (max-width: 760px) { .mapwrap { min-height: 55vh; } }
button.chip { opacity: .65; }
button.chip.on { opacity: 1; background: var(--accent); color: #fff; border-color: var(--accent); }
.mapnote { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.2); z-index: 2; }
/* The live feed paused by an admin */
.feednote { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 120px);
  background: #fff8e1; color: #5d4037; border: 2px solid var(--warn); border-radius: 8px; padding: 8px 12px; font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); z-index: 3; text-align: center; }
.feednote button { margin-left: 8px; }
.drawbar { position: absolute; left: 10px; right: 10px; bottom: 34px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--surface); color: var(--ink); border: 2px solid #ff6d00; border-radius: 8px; padding: 8px 10px; z-index: 3; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.drawbar #draw-hint { flex: 1 1 260px; font-weight: 600; }
.drawbar button:disabled { opacity: .5; cursor: default; }
.grid-lb { font: 700 11px/1 sans-serif; color: #102030; background: rgba(255,255,255,.75); border-radius: 3px; padding: 1px 3px; pointer-events: none; }
.set-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 24px; }
@media (max-width: 800px) { .set-grid { grid-template-columns: 1fr; } }
.set-grid section > label { display: block; margin: 6px 0; }
#settings h3 { margin: 14px 0 6px; font-size: 15px; }
#settings .card.wide { overflow: auto; display: block; }
#settings .scroll { overflow: visible; }
table.alerts td:nth-child(n+2), table.alerts th:nth-child(n+2) { text-align: center; width: 70px; }
#set-zones input[data-f="name"] { width: 100%; min-width: 120px; }
.maplibregl-popup-content { color: #102030; font-size: 13px; }
.maplibregl-popup-content hr { border: 0; border-top: 1px solid #ccd; margin: 6px 0; }
.menuwrap { position: relative; }
.menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; min-width: 160px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.menu.hidden { display: none; }
.menu button { border: 0; text-align: left; padding: 7px 10px; background: transparent; }
.menu button:hover, .menu button:focus { background: var(--bg); }
.zh { width: 16px; height: 16px; border-radius: 50%; background: #ff6d00; border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); cursor: grab; }
.zh.centre { background: #fff; border-color: #ff6d00; }
.zh:active { cursor: grabbing; }
#settings h4 { margin: 12px 0 4px; font-size: 13px; }
#air-center { white-space: nowrap; }
#hist-q { width: 100%; margin: 4px 0 8px; box-sizing: border-box; }
#hist-rows tr[data-key] { cursor: pointer; }
#hist-rows tr[data-key]:hover { background: var(--hover); }
#hist-rows tr.nopos { cursor: default; opacity: .6; }
.lvl { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; color: #fff; }
.lvl-U { background: #ef6c00; } .lvl-W { background: #c62828; } .lvl-F { background: #2e7d32; }
