:root {
  --bg: #0d1013;
  --bg-2: #13171b;
  --panel: #181d22;
  --panel-2: #1f252b;
  --line: #2a3138;
  --text: #e6eaed;
  --dim: #8b959e;
  --faint: #5d6770;
  --accent: #2f7de1;
  --accent-2: #5b9bf0;
  --ok: #2eb872;
  --warn: #e0a526;
  --bad: #d9443a;
  --rx: #1f8a5b;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --r: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 14px; font-weight: 650; margin: 0 0 12px; color: var(--text); }
p { margin: 0 0 10px; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---- layout ---- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; box-sizing: border-box;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center;
}
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.15; }
.brand-sub { font-size: 11px; color: var(--dim); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; color: var(--dim); font-weight: 500;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav svg { width: 16px; height: 16px; flex: none; }
.side-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--dim); }
.side-foot b { color: var(--text); font-weight: 600; }
.side-foot .links { display: flex; gap: 12px; margin-top: 6px; }

/* The page area scrolls by itself, so when a page is wider than the window its sideways
   scroll bar sits at the bottom of the window (not at the end of a long page). */
.app { height: 100vh; }
.main { padding: 22px 28px 48px; min-width: 0; height: 100vh; overflow: auto; box-sizing: border-box; }
.main > #view { min-width: 760px; }
/* Wide tables make the page wider instead of scrolling inside their card, so the one scroll bar at
   the bottom of the window slides everything over. */
.card:has(.tbl-wrap) { overflow: visible; min-width: min-content; }
.card:has(.tbl-wrap) .tbl-wrap { overflow-x: visible; }
/* Inside a two-column grid a wide table scrolls in its own card instead of running into the next column. */
.grid > * { min-width: 0; }
.grid .card:has(.tbl-wrap) { min-width: 0; overflow: hidden; }
.grid .card:has(.tbl-wrap) .tbl-wrap { overflow-x: auto; }
.grid.upd-grid { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); }
.side { scrollbar-width: thin; }
/* Short screens: a tighter menu so it fits without scrolling */
@media (max-height: 820px) {
  .nav a { padding: 5px 10px; }
  .brand { padding-bottom: 10px; }
  .side-toggle { margin: -4px 0 4px; padding: 4px 10px; }
  .side-foot { padding-top: 6px; }
}
.main::-webkit-scrollbar { height: 14px; width: 12px; }
.main::-webkit-scrollbar-thumb { background: var(--line); border-radius: 7px; border: 3px solid var(--bg); }
.main::-webkit-scrollbar-thumb:hover { background: var(--dim); }
.side-toggle { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px dashed var(--line); color: var(--dim);
  padding: 6px 10px; border-radius: 6px; margin: -8px 0 8px; font-size: 12px; justify-content: flex-start; }
.side-toggle:hover { color: var(--text); background: var(--panel); }
.side-toggle svg { width: 16px; height: 16px; flex: none; }
/* Narrow menu: icons only */
.app.side-small { grid-template-columns: 58px 1fr; }
.side-small .side { padding: 16px 8px; }
.side-small .brand { padding: 4px 6px 18px; }
.side-small .brand > div:last-child, .side-small .lbl, .side-small .side-foot { display: none; }
.side-small .nav a { justify-content: center; padding: 9px 0; }
.side-small .side-toggle { justify-content: center; padding: 6px 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head .sub { color: var(--dim); font-size: 13px; margin-top: 2px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card + .card { margin-top: 14px; }
.grid > .card { margin-top: 0; }
.grid + .card, .grid + .grid, .card + .grid { margin-top: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 14px 16px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.tile .k { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.tile .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 13px; color: var(--dim); font-weight: 500; margin-left: 3px; }
.tile .s { font-size: 12px; color: var(--dim); margin-top: 2px; }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; background: var(--bg-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,0.015); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--dim); }

/* ---- controls ---- */
button, .btn {
  font: inherit; font-weight: 550; font-size: 13px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 7px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: #3a434c; background: #262d34; text-decoration: none; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #3a88ec; }
button.danger { color: #ff8a80; }
button.danger:hover { background: rgba(217,68,58,0.15); border-color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover { color: var(--text); background: var(--panel-2); }
button.sm, .btn.sm { padding: 4px 8px; font-size: 12px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,125,225,0.2); }
input[type=checkbox], input[type=radio] { width: auto; flex: none; padding: 0; height: auto; accent-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 5px; font-weight: 500; }
label.check { display: block; position: relative; padding-left: 24px; margin-bottom: 8px; cursor: pointer; line-height: 1.45; }
label.check > input:first-child { position: absolute; left: 0; top: 3px; margin: 0; }
.hint { font-size: 12px; color: var(--dim); margin-top: 4px; }
.checks { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--bg-2); }

/* ---- status ---- */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,184,114,0.15); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.tx { background: var(--bad); box-shadow: 0 0 0 3px rgba(217,68,58,0.25); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(217,68,58,0.05); } }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px;
  background: var(--panel-2); color: var(--dim); border: 1px solid var(--line); white-space: nowrap;
}
.badge.ok { color: #7be0a8; background: rgba(46,184,114,0.12); border-color: rgba(46,184,114,0.3); }
.badge.warn { color: #f3c35e; background: rgba(224,165,38,0.12); border-color: rgba(224,165,38,0.3); }
.badge.bad { color: #ff8a80; background: rgba(217,68,58,0.12); border-color: rgba(217,68,58,0.3); }
.badge.info { color: var(--accent-2); background: rgba(47,125,225,0.12); border-color: rgba(47,125,225,0.3); }
.who { display: flex; align-items: center; gap: 9px; }
.who b { font-weight: 600; }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; vertical-align: middle; }
.bars i { width: 3px; background: var(--line); border-radius: 1px; }
.bars i.on { background: var(--ok); }
.bars.weak i.on { background: var(--warn); }

/* ---- channels on the dashboard ---- */
.chan-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.chan { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.chan.live { border-color: rgba(217,68,58,0.6); box-shadow: 0 0 0 1px rgba(217,68,58,0.25) inset; }
.chan .n { font-weight: 650; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chan .talk { margin: 8px 0 6px; font-size: 13px; color: #ff9f97; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.chan .idle { margin: 8px 0 6px; font-size: 13px; color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11.5px; padding: 2px 7px; border-radius: 4px; background: var(--panel-2); color: var(--dim); border: 1px solid var(--line); }
.chip.tx { color: #fff; background: var(--bad); border-color: var(--bad); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.ok { color: var(--ok, #2f9e5b); border-color: currentColor; }

/* ---- key display ---- */
.keybox { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.keybox code { font-size: 18px; letter-spacing: 0.12em; color: var(--text); flex: 1; }
.keybox code.addr { font-size: 12.5px; letter-spacing: 0; word-break: break-all; white-space: normal; }

/* ---- charts ---- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 150px; }
.chart .yl { position: absolute; left: 0; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; transform: translateY(-50%); background: var(--panel); padding-right: 4px; }
.chart .xl { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--dim); margin-bottom: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--dim); }
.seg button.on { background: var(--panel-2); color: var(--text); }

/* ---- event log ---- */
.log { font-family: var(--mono); font-size: 12px; max-height: 360px; overflow: auto; }
.log .row { display: grid; grid-template-columns: 150px 46px 110px 120px 1fr; gap: 10px; padding: 5px 16px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.log .row:hover { background: rgba(255,255,255,0.02); }
.log .lv-warn { color: var(--warn); }
.log .lv-error { color: var(--bad); }
.log .lv-info { color: var(--faint); }
.log .t { color: var(--faint); }

/* ---- dialog / toast ---- */
dialog {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text);
  padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
dialog::backdrop { background: rgba(0,0,0,0.55); }
dialog form { padding: 20px; }
dialog h2 { font-size: 16px; margin-bottom: 16px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--ok); padding: 10px 14px; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); max-width: 380px; }
.toast.err { border-left-color: var(--bad); }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 100%); }
.login .brand { justify-content: center; padding-bottom: 22px; }
.login .card { padding: 22px; }
.err-text { color: #ff8a80; font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.progress { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }

@media (max-width: 900px) {
  .app, .app.side-small { grid-template-columns: 1fr; height: auto; }
  .main { height: auto; overflow: visible; }
  .main > #view { min-width: 0; }
  .card:has(.tbl-wrap) { overflow: hidden; min-width: 0; }
  .card:has(.tbl-wrap) .tbl-wrap { overflow-x: auto; }
  .side-toggle { display: none; }
  .side-small .lbl { display: inline; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 0 8px 0 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side-foot { display: none; }
  .main { padding: 16px; }
  .g2, .g3, .g4, .grid.upd-grid { grid-template-columns: 1fr; }
  .log .row { grid-template-columns: 150px 1fr; }
  .log .row > :nth-child(2), .log .row > :nth-child(4) { display: none; }
}

/* ---- settings editor ---- */
table.settings td { vertical-align: top; }
table.settings td:first-child { width: 22%; }
table.settings .ed { margin-top: 6px; }
table.settings select, table.settings input:not([type=checkbox]):not([type=range]) { max-width: 320px; }
.range-row { display: flex; align-items: center; gap: 10px; max-width: 320px; }
.range-row input { flex: 1; padding: 0; accent-color: var(--accent); }
.keys { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.keys .chip a { color: var(--faint); margin-left: 4px; }
.keys .chip a:hover { color: var(--bad); text-decoration: none; }
tr.sel td { background: rgba(47,125,225,0.06); }
a.who { color: inherit; }
a.who:hover { text-decoration: none; }
a.who:hover b { text-decoration: underline; }

.drop{display:flex;flex-direction:column;align-items:center;gap:4px;padding:28px 16px;border:2px dashed var(--line);border-radius:12px;cursor:pointer;text-align:center;transition:border-color .15s,background .15s}
.drop:hover,.drop.over{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 8%,transparent)}
.drop.busy{opacity:.6;pointer-events:none}
.drop-icon svg{width:34px;height:34px;color:var(--accent)}

/* ---- map ---- */
.mapwrap { display: grid; grid-template-columns: 280px 1fr; gap: 14px; height: calc(100vh - 170px); min-height: 420px; }
.maplist { display: flex; flex-direction: column; overflow: hidden; margin: 0; }
.ml-head { padding: 10px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.seg { display: flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 4px 6px; font-size: 12px; color: var(--dim); }
.seg button.on { background: var(--accent); color: #fff; }
.ml-items { overflow: auto; flex: 1; }
.ml-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 9px 12px; color: var(--text); }
.ml-item:hover { background: var(--bg-2); }
.ml-item.sel { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.ml-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ml-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot.st-on { background: #2eb872; } .dot.st-off { background: #e5484d; } .dot.st-tx { background: #f5a524; }
.mapbox { position: relative; overflow: hidden; margin: 0; }
#m-map, .minimap { position: absolute; inset: 0; }
.minimap { position: relative; height: 280px; border-radius: 8px; overflow: hidden; }
label.check.inline { display: inline-block; margin: 0 6px; }

.tmap { position: relative; overflow: hidden; background: #dfe3e8; touch-action: none; cursor: grab; user-select: none; }
.tmap:active { cursor: grabbing; }
.tm-tiles, .tm-markers { position: absolute; inset: 0; }
.tm-tile { position: absolute; left: 0; top: 0; width: 256px; height: 256px; max-width: none; }
.tm-tile.tm-missing { visibility: hidden; }
.tm-lines { position: absolute; left: 0; top: 0; pointer-events: none; }
.tm-markers { pointer-events: none; }
.tm-marker { pointer-events: auto; }
.tm-lines .tdot { pointer-events: all; cursor: pointer; }
.tm-lines .tdot:hover { stroke: #111; stroke-width: 2; }
.tm-zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; box-shadow: 0 1px 4px rgba(0,0,0,.35); border-radius: 6px; overflow: hidden; }
.tm-zoom button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 0; background: #fff; color: #222; font-size: 18px; line-height: 1; }
.tm-zoom button + button { border-top: 1px solid #ddd; }
.tm-attr { position: absolute; right: 0; bottom: 0; background: rgba(255,255,255,.8); color: #333; font-size: 10px; padding: 1px 6px; }
.tm-attr a { color: #0b5cad; }
.tm-marker { position: absolute; left: 0; top: 0; width: 0; height: 0; cursor: pointer; z-index: 1; }
.tm-marker.st-off { z-index: 0; }
.tm-marker.st-tx, .tm-marker.sel { z-index: 3; }
.tm-marker .pin { position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); display: grid; place-items: center; }
.tm-marker .pin span { width: 14px; height: 14px; border-radius: 50%; background: #2eb872; }
.tm-marker.st-off .pin span { background: #e5484d; }
.tm-marker.st-tx .pin span { background: #f5a524; }
.tm-marker.st-tx .pin::after { content: ''; position: absolute; inset: -7px; border-radius: 50%; border: 3px solid #f5a524; animation: tm-pulse 1.2s ease-out infinite; }
@keyframes tm-pulse { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
.tm-marker.stale .pin { opacity: .55; }
.tm-marker.sel .pin { outline: 3px solid var(--accent); outline-offset: 1px; }
.tm-marker .hd { position: absolute; left: 4px; top: -9px; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 9px solid #1b1f24; transform-origin: 6px 19px; }
.tm-marker .lbl { position: absolute; left: 0; top: 13px; transform: translateX(-50%); white-space: nowrap; font-size: 11px; font-weight: 600; color: #111; background: rgba(255,255,255,.88); padding: 0 5px; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.tm-pop { position: absolute; z-index: 5; width: 270px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.5); font-size: 13px; }
.pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pop-head button { margin-left: auto; }
.pr { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.pr > span:last-child { text-align: right; }
.pop-foot { display: flex; align-items: center; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.pop-foot a { margin-left: auto; }
@media (max-width: 800px) {
  .mapwrap { grid-template-columns: 1fr; grid-template-rows: 62vh auto; height: auto; }
  .mapbox { order: -1; }
  .maplist { max-height: 340px; }
}
.tm-note { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(20,24,28,.85); color: #e6eaed; font-size: 12px; padding: 6px 10px; border-radius: 6px; max-width: 80%; text-align: center; pointer-events: none; }
.toolbar select { width: auto; }

.tm-tip { position: absolute; z-index: 6; min-width: 190px; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--ok); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.45); }
.tm-tip.st-off { border-top-color: var(--bad); }
.tm-tip.st-tx { border-top-color: #f5a524; }
.tip-h { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.tip-s { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ok); }
.tm-tip.st-off .tip-s { color: var(--bad); }
.tm-tip.st-tx .tip-s { color: #f5a524; }

/* ---- dispatch ---- */
.dgrid { display: grid; grid-template-columns: minmax(330px, 420px) 1fr; gap: 14px; align-items: start; }
.dcol { display: grid; gap: 14px; }
.dcol .card { margin: 0; }
.d-chhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.d-chhead h2 { margin: 0; }
.d-chhead select { width: auto; padding: 4px 6px; font-size: 12px; }
.d-chans { max-height: 46vh; overflow: auto; }
.d-ch { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; transition: background .2s; }
.d-ch.off { opacity: .55; }
.d-ch.live { background: color-mix(in srgb, #f5a524 14%, transparent); border-left-color: #f5a524; }
.d-ch.locked { background: color-mix(in srgb, #f5a524 24%, transparent); border-left-color: #f5a524; box-shadow: inset 0 0 0 1px #f5a524; }
.d-ch.tx { background: color-mix(in srgb, var(--bad) 20%, transparent); border-left-color: var(--bad); }
.d-ch.flash { animation: d-flash 1s ease-out 2; }
@keyframes d-flash { 0% { background: color-mix(in srgb, #f5a524 55%, transparent); } 100% { background: color-mix(in srgb, #f5a524 14%, transparent); } }
.d-mon { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 15px; flex: none; }
.d-mon.on { border-color: var(--ok); }
.d-chinfo { flex: 1; min-width: 0; cursor: pointer; }
.d-chname { font-weight: 700; font-size: 15px; }
.d-who b { color: #f5a524; }
.d-txsel { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--dim); cursor: pointer; flex: none; }
.d-pttcard { text-align: center; }
.d-ptt { width: 100%; height: 96px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; touch-action: none; user-select: none; }
.d-ptt-main { font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.d-ptt-sub { font-size: 12px; color: var(--dim); }
.d-ptt:not(:disabled):hover { border-color: var(--accent); }
.d-ptt.waiting { border-color: #f5a524; }
.d-ptt.talking { background: var(--bad); border-color: #ff7b72; color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 35%, transparent); }
.d-ptt.talking .d-ptt-sub { color: #fff; }
.center { text-align: center; }
.d-log { max-height: 240px; overflow: auto; }
.d-logrow { display: grid; grid-template-columns: 72px 1fr 1.3fr auto; gap: 8px; align-items: baseline; padding: 6px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.d-logrow.mine { color: var(--accent-2); }
.d-mapcard { margin: 0; display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 460px; position: sticky; top: 14px; }
.d-maphead { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.d-maphead select { width: auto; }
.d-mapbox { position: relative; flex: 1; }
#d-map { position: absolute; inset: 0; border-radius: 0 0 var(--r) var(--r); }
.check-chip { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.check-chip input { margin: 0; }
.d-banner { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 12px 16px; border-radius: 10px;
  background: color-mix(in srgb, #f5a524 22%, var(--panel)); border: 1px solid #f5a524; font-size: 15px; }
.d-banner.live { animation: d-glow 1.2s ease-in-out infinite alternate; }
@keyframes d-glow { from { box-shadow: 0 0 0 0 rgba(245,165,36,.0); } to { box-shadow: 0 0 0 6px rgba(245,165,36,.35); } }
.d-banner button { margin-left: auto; }
.d-pulse { width: 12px; height: 12px; border-radius: 50%; background: #f5a524; animation: tm-pulse 1s ease-out infinite; }
.gate { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.warnbox { border-color: var(--warn); }
@media (max-width: 980px) {
  .dgrid { grid-template-columns: 1fr; }
  .d-mapcard { position: static; height: 60vh; }
}
.ml-items { overflow-x: hidden; }
.ml-txt > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srvbanner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* track history panel */
.hist-row { display: flex; justify-content: space-between; align-items: baseline; }
.ml-head .field.sm { margin: 0; display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 6px; }
.ml-head .field.sm span { font-size: 12px; color: var(--dim); }
.ml-head input[type=datetime-local] { width: 100%; min-width: 0; }
.hist-item { cursor: pointer; }
.hist-item input { margin: 0; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); flex: none; }
.hist-foot { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.hist-foot .primary { flex: 1; }
.logfilter .lf-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.logfilter .lf-row:last-child { margin-bottom: 0; }
.logfilter .lf-k { width: 52px; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.logfilter label.check.inline { margin: 0 8px 0 0; }
.logfilter select, .logfilter input[type=datetime-local] { width: auto; }
.log.log5 .row { grid-template-columns: 150px 46px 90px 150px 1fr; }
@media (max-width: 700px) { .logfilter .lf-k { width: 100%; } .log.log5 .row { grid-template-columns: 1fr; gap: 2px; } }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line, rgba(255,255,255,0.08)); margin: 4px 0 16px; }
.tabs a { padding: 9px 16px; color: var(--dim, #9aa4ad); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: inherit; }
.tabs a.on { color: inherit; border-bottom-color: var(--accent, #2f7de1); }
.tabhead { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
.tabhead .sub { flex: 1 1 320px; }

/* Reconnecting bar (0.7.4.1): shown while the servers can't be reached, e.g. during a change of primary. */
#conn-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 60; padding: 8px 16px; text-align: center;
  background: var(--warn); color: #1a1300; font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.35); }

/* Track stops (0.7.4.1) */
.tm-marker .stop-pin { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 6px; background: #fff; color: #111;
  border: 3px solid #2f7de1; font: 700 12px/16px system-ui, sans-serif; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.hist-stops { display: flex; flex-direction: column; gap: 2px; margin: -2px 0 8px 40px; font-size: 12px; }
.hist-stops a { color: var(--accent-2); }
/* Logs of several servers (0.7.4.2): a Server column */
.log.log6 .row { grid-template-columns: 150px 90px 46px 90px 150px 1fr; }
.srvtag { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 7px; border-radius: 10px;
  background: rgba(47,125,225,.18); color: var(--accent-2); font-size: 12px; font-weight: 600; }
@media (max-width: 700px) { .log.log6 .row { grid-template-columns: 1fr; gap: 2px; } }
.okbox { border-color: #2eb872; }
.errbox { border-color: #e5484d; }
.rob .btn { margin-left: 6px; }

/* load and capacity (0.7.6) */
.loadbar { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin: 2px 0 4px; }
.loadbar i { display: block; height: 100%; border-radius: 99px; }
.loadbar.ok i { background: var(--ok); }
.loadbar.warn i { background: var(--warn); }
.loadbar.bad i { background: var(--bad); }
.warn-text { color: var(--warn); }

/* Emergencies (0.8.9) */
.emerg-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: #7f1d1d; color: #fff; border: 1px solid #e5484d; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.emerg-bar.live { background: #b91c1c; animation: emerg-flash 1s steps(2, start) infinite; }
.emerg-bar .small { color: #fde2e2; }
.emerg-bar a, .emerg-bar .mono { color: #fff; }
.emerg-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.emerg-btns .btn, .emerg-btns button { background: #fff; color: #7f1d1d; border-color: #fff; }
.emerg-btns button.primary { background: #111; color: #fff; border-color: #111; }
.emerg-hist { margin: -4px 0 10px; text-align: right; }
@keyframes emerg-flash { 50% { background: #7f1d1d; } }
.emerg-pop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 1000; }
.emerg-card { background: var(--card, #161b22); border: 3px solid #e5484d; border-radius: 14px; padding: 18px 20px; width: min(520px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.emerg-title { background: #b91c1c; color: #fff; font-weight: 800; letter-spacing: .08em; font-size: 20px; padding: 8px 12px; border-radius: 8px; text-align: center; animation: emerg-flash 1s steps(2, start) infinite; }
.emerg-who { font-size: 18px; margin: 12px 0 8px; }
.emerg-card .emerg-btns { margin-top: 12px; }
.emerg-card .emerg-btns .btn, .emerg-card .emerg-btns button { background: transparent; color: inherit; border-color: var(--line, #30363d); }
.emerg-card .emerg-btns button.primary { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.emerg-tag { background: #b91c1c; color: #fff; font-weight: 700; font-size: 12px; padding: 3px 8px; border-radius: 6px; margin: 4px 0 6px; display: inline-block; }
.tm-marker.emerg .pin span { background: #e5484d; }
.tm-marker.emerg .pin { width: 26px; height: 26px; left: -13px; top: -13px; }
.tm-marker.emerg .pin::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; border: 4px solid #e5484d; animation: tm-pulse 1s ease-out infinite; }
.tm-marker.emerg { z-index: 50; }
/* A company's own logo (0.8.9), top right of every page; the NEXRadio brand stays top left. */
.co-logo { float: right; margin: 0 0 8px 12px; }
.co-logo img { max-height: 44px; max-width: 200px; display: block; }
.logo-prev { max-height: 60px; max-width: 240px; display: block; background: #fff; padding: 6px; border-radius: 6px; }
