/* Layout. Colours live in css/themes/*.css; these values are the fallback (the night theme). */
:root {
  --bg: #14171c; --panel: #1d2128; --line: #2c323c; --text: #d8dde5; --muted: #8a93a1;
  --accent: #4f9cf5; --ok: #3fbf6a; --warn: #e0a83a; --err: #e05252;
  --field: #11141a; --btn: #283041; --btn-line: #36405a; --btn-hover: #313b50;
  --danger-line: #6b2f2f; --danger-bg: #3a2222; --danger-hover: #4a2a2a;
  --on-bg: #2a4a33; --on-line: #3a6b48; --row-line: #23282f;
  --tag-bg: #2a303a; --tag-active-bg: #234030; --tag-active: #8fe0a8;
  --tag-pending-bg: #4a3a1c; --tag-pending: #f0c870; --tag-sync-bg: #1e3350; --tag-sync: #9cc6ff;
  --hover: #24304a; --pop-h: #1a2030; --pop-x: #c5cedb; --brick-on-text: #d8ffe4;
  --menu-danger: #ff8a8a; --menu-chk: #2ee56a; --move-bg: #2b1a2e; --move-line: #6b2f73;
  --legend-btn: #1a2030e6; --shadow: #0008; --isi-mark: #f0c93a; --map: #0d0f13;
  --radius: 6px; --radius-sm: 4px; --bd: 1px;
  --shadow-1: 0 4px 16px var(--shadow);
  --font-ui: "Segoe UI", system-ui, sans-serif;
  --font-mono: Consolas, monospace;
  --fs: 14px;
  
  /* signal / route / schematic literals */
  --sig-face: #12161e;
  --sig-face-ring: #2c3444;
  --sig-inset: #000;
  --sig-on: #3ecf6e;
  --sig-glow: #3ecf6e;
  --sig-off: #b4bcc6;
  --rb-bg: #10141c;
  --rb-ring: #2a3142;
  --rb-cell: #1a2030;
  --rb-cell-lit: #f4f7fb;
  --rl-bg: #141820;
  --rl-fg: #3a4458;
  --rl-lit-bg: #1c2433;
  --rl-lit-fg: #f4f7fb;
  --hold-shoe: #f0c93a;
  --hold-hand: #7ec8ff;
  --gid-paper: #f6f3ea;
  --gid-paper-line: #c8c2b4;
  --gid-grid: #e4dfd2;
  --gid-ink: #3a342c;
  --gid-muted: #8a8175;
  --gid-now: #c0392b;
  --alarm: #b3261e;
  --alarm-dim: #5c130f;
  --badge-ink: #fff;
  --lens-ring: #0008;
  --isi-edge: #0006;
  --isi-flash: #fff5;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs)/1.4 var(--font-ui); height: 100vh; display: flex; flex-direction: column; }
body.locked > header, body.locked > nav, body.locked > main, body.locked > dialog, body.locked > #side-menu, body.locked > #toast { display: none; }
header { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 16px; }
.hdr-status { flex: 1; color: var(--muted); }
.hdr-status b { color: var(--text); font-weight: 600; }
.hdr-actions { display: flex; gap: 8px; align-items: center; }
.hdr-user { white-space: nowrap; }
.user-menu { position: relative; }
.user-btn { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.user-btn::after { content: ' ▾'; color: var(--muted); }
.user-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 260px; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow-1); }
.user-name { font-weight: 600; font-size: 15px; margin-bottom: 8px; overflow-wrap: anywhere; }
.user-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.user-grid .k { color: var(--muted); }
.user-acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
nav { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
nav button { background: none; border: 0; color: var(--muted); padding: 9px 12px; cursor: pointer; border-bottom: 2px solid transparent; font: inherit; }
nav button.active { color: var(--text); border-bottom-color: var(--accent); }
nav button:hover { color: var(--text); }
.subtabs { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.subtabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; padding: 7px 12px; cursor: pointer; margin-bottom: -1px; }
.subtabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.subtabs button:hover { color: var(--text); }
main { flex: 1; overflow: auto; padding: 16px; overflow-anchor: none; }
.tab { display: none; }
.tab.active { display: block; }
.tab-map.active { display: flex; flex-direction: column; height: 100%; }
.tab-gid.active { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.gid-bar { flex: none; }
#gid-canvas { flex: 1; width: 100%; min-height: 420px; background: var(--gid-paper); border: 1px solid var(--gid-paper-line); border-radius: var(--radius-sm); }
h3 { margin: 12px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.cards { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.card { flex: 1 1 160px; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.card.fit { flex: 0 0 auto; min-width: 160px; max-width: 100%; }
.card.fit .v { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 20px; font-weight: 600; margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
#tab-overview.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#tab-overview .cards { margin-bottom: 0; }
#tab-overview .ov-sessions { min-width: 0; overflow-x: auto; }
#tab-overview .ov-sessions .list { max-height: 200px; }
#tab-overview .ov-events {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#tab-overview .ov-events .subtabs,
#tab-overview .ov-events .hint,
#tab-overview .ov-events .row { flex: none; }
#tab-overview .ov-events [data-pane] { display: flex; flex-direction: column; min-height: 0; }
#tab-overview .ov-events [data-pane].hidden { display: none; }
#tab-overview .ov-events .list,
#tab-overview .ov-events .ov-scroll { max-height: 360px; overflow: auto; }
#tab-overview .ov-events .chat { white-space: pre-wrap; overflow-wrap: anywhere; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px 12px; }
.row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.row label { color: var(--muted); }
.grow { flex: 1; min-width: 200px; }
input, select, textarea { background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 5px 8px; font: inherit; }
textarea { resize: vertical; }
input[type=checkbox] { vertical-align: middle; }
.btn { background: var(--btn); color: var(--text); border: 1px solid var(--btn-line); border-radius: var(--radius-sm); padding: 5px 10px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { background: var(--btn-hover); }
.btn.sm { padding: 2px 7px; font-size: 12px; }
.btn.icon { width: 22px; height: 22px; padding: 0; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.btn.icon svg { display: block; }
.btn.danger { border-color: var(--danger-line); background: var(--danger-bg); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.on { background: var(--on-bg); border-color: var(--on-line); }
.theme-pick { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.theme-pick select { max-width: 150px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: -16px; background: var(--panel); }
.tbl td.act { white-space: nowrap; text-align: right; }
.tbl td.act .btn { margin-left: 4px; }
.tbl tr.dim td { opacity: .55; }
.tbl td.nw { white-space: nowrap; }
.hk-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin: 8px 0; }
.hk-card .row input[type=text], .hk-card .row input[type=password] { min-width: 220px; flex: 1; }
.hk-events { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 12px; margin: 6px 0; }
.hk-events label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; max-height: 70vh; overflow: auto; }
.list.small { max-height: 260px; font-size: 13px; }
.list .it { padding: 3px 0; border-bottom: 1px solid var(--row-line); }
.list .t { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.chat { height: 60vh; }
.lvl-WARN { color: var(--warn); }
.lvl-ERROR { color: var(--err); }
.tag { display: inline-block; padding: 0 6px; border-radius: var(--radius-sm); font-size: 12px; background: var(--tag-bg); }
.tag.Active { background: var(--tag-active-bg); color: var(--tag-active); }
.tag.Pending { background: var(--tag-pending-bg); color: var(--tag-pending); }
.tag.Syncing { background: var(--tag-sync-bg); color: var(--tag-sync); }
.asp { display: inline-block; min-width: 14px; height: 14px; border-radius: 7px; vertical-align: middle; margin-right: 4px; }
.hint { color: var(--muted); font-size: 12px; }
.hidden { display: none !important; }
.map-tools { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.map-style { display: inline-flex; align-items: center; gap: 6px; }
.map-style #mp-style { display: inline-flex; }
.map-style #mp-style .btn { border-radius: 0; }
.map-style #mp-style .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.map-style #mp-style .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }
.map-stage { display: flex; gap: 8px; flex: 1; min-height: 0; }
.map-wrap { position: relative; flex: 1; min-width: 0; min-height: 400px; background: var(--map); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.side-resizer { flex: none; width: 6px; margin: 0 -4px; cursor: col-resize; border-radius: 3px; z-index: 2; touch-action: none; }
.side-resizer:hover, .side-resizer.drag { background: var(--line); }
.map-side { width: 340px; flex: none; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.side-box { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; padding: 8px 10px 10px; }
.side-box.side-grow { flex: 1.6; }
.side-box h3 { margin: 0 0 6px; }
.side-q { width: 100%; margin: 0 0 6px; }
.side-list { overflow: auto; min-height: 0; }
.side-train, .side-person { padding: 6px 6px; border-bottom: 1px solid var(--row-line); border-radius: var(--radius-sm); }
.side-train { cursor: pointer; }
.side-train:hover, .side-train.on, .side-person:hover { background: var(--hover); }
.side-train.off { opacity: 0.6; }
.side-line { font-size: 13px; line-height: 1.35; }
.holds { display: inline-flex; gap: 8px; margin-left: 6px; vertical-align: middle; }
.hold { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; }
.hold b { font-weight: 600; }
.hold-i { width: 14px; height: 14px; display: block; }
.hold.shoe { color: var(--hold-shoe); }
.hold.hand { color: var(--hold-hand); }
.side-line b { font-weight: 600; }
.side-person { cursor: default; }
.side-person.has-pos { cursor: pointer; }
.side-person .who { font-weight: 600; }
.api-mark { display: inline-block; margin-right: 5px; padding: 0 4px; border-radius: var(--radius-sm); background: var(--tag-sync-bg); color: var(--tag-sync); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; line-height: 14px; vertical-align: 1px; }
.route-bit { height: 5px; margin-top: 5px; border-radius: var(--radius-sm); background-image: repeating-linear-gradient(90deg, var(--c, var(--muted)) 0 8px, transparent 8px 14px); background-size: 22px 100%; animation: route-flow 0.7s linear infinite; }
.route-bit.idle { animation: none; opacity: 0.28; }
@keyframes route-flow { to { background-position: -22px 0; } }
.bricks { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.brick { display: inline-block; padding: 0 7px; height: 18px; border-radius: var(--radius-sm); border: 1px solid var(--btn-line); background: var(--btn); color: var(--muted); font: 11px/16px inherit; cursor: pointer; }
.brick.on { background: var(--on-bg); border-color: var(--ok); color: var(--brick-on-text); }
.side-menu { position: fixed; z-index: 30; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; box-shadow: var(--shadow-1); }
@media (max-width: 1100px) {
  .map-stage { flex-direction: column; }
  .map-side { width: auto !important; flex-direction: row; max-height: 280px; }
  .side-resizer { display: none; }
  .side-box { min-width: 0; }
}
#map { width: 100%; height: 100%; display: block; cursor: grab; }
.pop { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; min-width: 220px; max-width: 360px; box-shadow: var(--shadow-1); z-index: 5; }
.pop .btn { margin: 2px; }
.pop-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: move; margin: -8px -10px 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--pop-h); border-radius: var(--radius) var(--radius) 0 0; }
.pop-h b { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.ref { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.lock-note { color: var(--ok); }
.pop-x { background: none; border: 0; color: var(--pop-x); cursor: pointer; font-size: 16px; line-height: 1; }
.heads { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.head { display: flex; gap: 6px; align-items: flex-end; }
.sigstack { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sigface { position: relative; background: var(--sig-face); border-radius: 11px; box-shadow: inset 0 0 0 1px var(--sig-inset), 0 0 0 1px var(--sig-face-ring); flex: none; }
.sigface.dwarf { border-radius: 4px; }
.sigface .lens { position: absolute; width: 13px; height: 13px; margin: 0; }
.sigstripe { width: 30px; height: 6px; border-radius: var(--radius-sm); background: var(--sig-on); box-shadow: 0 0 6px var(--sig-glow); }
.electro-key { display: inline-flex; gap: 8px; align-items: center; }
.electro-key i, .swatch { display: inline-block; width: 18px; height: 4px; border-radius: 2px; vertical-align: middle; }
.swatch.off { opacity: 0.45; }
.swatch.pulse { animation: electro-pulse 1.15s ease-in-out infinite; }
@keyframes electro-pulse { 50% { opacity: 0.2; } }
.jn-card { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.jn-pose { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.jn-fig { display: block; }
.jn-fig path { fill: none; stroke-width: 2.6; stroke-linecap: butt; stroke-linejoin: miter; }
.jn-fig .on { stroke: var(--sig-on); filter: drop-shadow(0 0 2px var(--sig-glow)) drop-shadow(0 0 6px var(--sig-glow)); }
.jn-fig .off { stroke: var(--sig-off); }
.routeboard { position: relative; background: var(--rb-bg); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--rb-ring); flex: none; }
.routeboard .cell { position: absolute; width: 5px; height: 5px; border-radius: 1px; background: var(--rb-cell); }
.routeboard .cell.lit { background: var(--rb-cell-lit); box-shadow: 0 0 3px var(--rb-cell-lit); }
.routeletter { min-width: 22px; height: 22px; padding: 0 4px; border-radius: var(--radius-sm); background: var(--rl-bg); color: var(--rl-fg); font-weight: 700; text-align: center; line-height: 22px; }
.routeletter.lit { color: var(--rl-lit-fg); background: var(--rl-lit-bg); text-shadow: 0 0 6px var(--rl-lit-fg); }
@keyframes sigflash { 0%, 45% { opacity: 1; } 55%, 100% { opacity: 0.15; } }
.flash { animation: sigflash 0.9s steps(1) infinite; }
.mast { display: flex; flex-direction: column; gap: 2px; background: var(--sig-face); border-radius: var(--radius); padding: 4px 3px; }
.mast div { display: flex; gap: 2px; justify-content: center; }
.lens { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 1px var(--lens-ring); }
.menu { display: flex; flex-direction: column; margin: 4px -4px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 3px 0; }
.mi { position: relative; display: flex; align-items: center; gap: 4px; width: 100%; background: none; border: 0; color: var(--text); font: inherit; text-align: left; padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer; list-style: none; }
.mi::-webkit-details-marker { display: none; }
.mi:hover, .mi-d[open] > summary { background: var(--hover); }
.mi.danger { color: var(--menu-danger); }
.mi .chk { width: 14px; flex: none; color: var(--menu-chk); font-weight: bold; }
.mi .arr { margin-left: auto; color: var(--muted); }
.has-sub .submenu { display: none; position: absolute; left: 100%; top: -4px; min-width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; box-shadow: var(--shadow-1); z-index: 6; }
.has-sub:hover .submenu { display: block; }
.left-sub .has-sub .submenu { left: auto; right: 100%; }
.mi-d .heads { padding: 0 8px 0 26px; max-height: 280px; overflow: auto; }
.dbg { margin-top: 6px; color: var(--muted); font-size: 12px; }
.move-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 6px 10px; background: var(--move-bg); border: 1px solid var(--move-line); border-radius: var(--radius); flex-wrap: nowrap; min-width: 0; }
.move-bar > b, #mp-kind, #mp-move-rev, #mp-move-cancel { flex: none; }
#mp-move-hint, #mp-move-info, #mp-move-err { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offline { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; background: var(--bg); text-align: center; padding: 24px; }
.offline.hidden { display: none; }
.offline h2 { margin: 0 0 8px; }
.alarm-mute { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px; min-width: 380px; max-height: 90vh; overflow: auto; }
dialog::backdrop { background: var(--shadow); }
#tr-new-dlg { width: min(980px, 96vw); }
#tr-new-num, #tr-new-electro { width: 90px; flex: 0 0 90px; }
#tr-new-notes { display: block; width: 100%; min-height: 4.5em; margin: 8px 0; }
#tr-new-err { color: var(--err); font-size: 12px; }
#tr-new-err:empty { display: none; }
dialog.pick-dlg { min-width: min(560px, 94vw); }
.checks { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow: auto; min-width: 0; }
.checks label { color: var(--text); }
.checks .checks-q { margin-bottom: 4px; }
.pick { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pick select { width: 100%; }
.cfg.dlg { grid-template-columns: 200px 1fr; }
dialog.pick-dlg .cfg.dlg { grid-template-columns: 110px minmax(0, 1fr); align-items: start; }
dialog.pick-dlg .cfg.dlg > label { margin-top: 6px; }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow-1); }
.toast.err { border-color: var(--err); }
.cfg { display: grid; grid-template-columns: 260px 1fr; gap: 6px 12px; max-width: 900px; align-items: center; }
.cfg label { color: var(--muted); }
.cfg label.top { align-self: start; padding-top: 6px; }
.cfg textarea { width: 100%; min-height: 4.5em; }
.tbl td textarea { width: 12em; min-height: 2.6em; }
.cfg .live { color: var(--ok); font-size: 11px; margin-left: 6px; }

/* settings tab */
.cfg-page { max-width: 960px; }
.cfg-tools {
  position: sticky; top: -16px; z-index: 4;
  background: var(--bg);
  margin: -16px -16px 12px; padding: 12px 16px 0;
  border-bottom: 1px solid var(--line);
}
.cfg-tools input { width: 100%; margin-bottom: 8px; }
.cfg-tools .subtabs { margin-bottom: 0; }
.cfg-sec { scroll-margin-top: 168px; margin-bottom: 12px; }
.cfg-sec > h3 { display: flex; align-items: center; gap: 8px; color: var(--text); }
.cfg-sec > h3 .tag { font-weight: 600; }
.cfg-lead { margin: 0 0 4px; }
.cfg-sub { margin: 14px 0 0; font-size: 13px; color: var(--accent); font-weight: 600; }
.cfg-field {
  display: grid; grid-template-columns: minmax(240px, 1.15fr) minmax(180px, 1fr);
  gap: 4px 16px; align-items: start;
  padding: 8px 0; border-top: 1px solid var(--row-line); cursor: pointer;
}
.cfg-lab { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.cfg-name { color: var(--text); }
.cfg-when { font-size: 11px; }
.cfg-when.now { color: var(--ok); }
.cfg-when.later { color: var(--warn); }
.cfg-lab .hint { flex: 1 0 100%; margin: 0; }
.cfg-field.cfg-bool { grid-template-columns: 22px 1fr; align-items: start; }
.cfg-field.cfg-bool .cfg-ctl { grid-column: 1; grid-row: 1; padding-top: 2px; }
.cfg-field.cfg-bool .cfg-lab { grid-column: 2; grid-row: 1; }
.cfg-ctl input[type="text"], .cfg-ctl select { width: 100%; }
.cfg-ctl input[type="number"] { width: 140px; }
.cfg-save {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 4px 0 10px;
}
.cfg-save .hint { flex: 1; min-width: 180px; }
@media (max-width: 720px) {
  .cfg-field { grid-template-columns: 1fr; }
  .cfg-field.cfg-bool { grid-template-columns: 22px 1fr; }
}

/* NG signal database tab */
.isi-lamp { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 2px; border: 1px solid var(--isi-edge); vertical-align: middle; }
.isi-lamp.st { border-radius: 2px; width: 14px; height: 5px; }
.isi-lamp.fl { box-shadow: 0 0 0 2px var(--isi-flash); }
.isi-set { outline: 2px solid var(--isi-mark); }

/* schematic corner: legend, layers, fit */
.map-corner { position: absolute; top: 8px; left: 8px; z-index: 6; display: flex; gap: 6px; align-items: center; }
.legend-btn { background: var(--legend-btn); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; line-height: 1.2; }
.legend-btn.icon-btn { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.legend-btn svg { display: block; }
.legend-btn:hover { border-color: var(--accent); }
.legend { position: absolute; top: 46px; left: 8px; z-index: 7; width: min(560px, calc(100% - 16px)); max-height: calc(100% - 56px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.legend.layers { width: min(280px, calc(100% - 16px)); }
.layers-body { display: flex; flex-direction: column; gap: 4px; }
.layers-body label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.legend.hidden { display: none; }
.legend .pop-h { margin: 0; cursor: default; }
.lg-body { overflow: auto; padding: 4px 12px 10px; }
.lg-body section { margin-top: 8px; }
.lg-body h4 { margin: 6px 0 4px; font-size: 13px; color: var(--accent); }
.lg-r { display: flex; align-items: center; gap: 10px; padding: 2px 0; font-size: 13px; }
.lg-r .lg-s { flex: none; }
.lg-body .hint { margin: 4px 0 0; font-size: 12px; }

/* operator alarm (sounds.js) */
.alarm-wrap { position: relative; z-index: 30; }
.alarm-badge { color: var(--badge-ink); background: var(--alarm); border: 0; border-radius: var(--radius); padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; animation: alarm-blink 1s steps(2) infinite; }
.alarm-badge.idle { background: var(--btn); color: var(--muted); border: 1px solid var(--btn-line); animation: none; }
.alarm-menu { position: absolute; right: 0; top: calc(100% + 6px); width: min(440px, 86vw); max-height: min(70vh, 520px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 6px 8px 8px; }
.alarm-row { display: block; padding: 6px 2px; border-bottom: 1px solid var(--row-line); line-height: 1.45; }
.alarm-row button { display: inline; background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.alarm-set { display: grid; gap: 2px; margin-top: 8px; }
.alarm-set label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; }
.map-cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.peer-cur { position: absolute; }
.peer-cur svg { display: block; filter: drop-shadow(0 1px 1px #000); }
.peer-name { position: absolute; left: 16px; top: 12px; font-size: 12px; line-height: 1.3; white-space: nowrap; color: var(--text); background: var(--panel); border: 1px solid currentColor; border-radius: var(--radius-sm); padding: 0 5px; }
@keyframes alarm-blink { 50% { background: var(--alarm-dim); } }

/* count of new violations on the tab button */
.tab-badge { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px; border-radius: var(--radius); background: var(--err); color: var(--badge-ink); font-size: 11px; line-height: 16px; text-align: center; }
.tab-badge.hidden { display: none; }

.login-page { display: block; height: auto; min-height: 100vh; }
.login-card { width: min(400px, calc(100% - 32px)); margin: 12vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 8px; }
.login-card h1 { font-size: 18px; font-weight: 600; margin: 8px 0 0; }
.login-card input[type="text"], .login-card input[type="password"] { width: 100%; padding: 8px 10px; }
.login-secret { display: flex; flex-direction: column; gap: 8px; }
.login-remember { color: var(--muted); font-size: 13px; }
.login-card .btn { align-self: flex-start; margin-top: 6px; }
.login-err { color: var(--err); margin: 0; }

/* route database editor (TfrmRoutes) */
.re-cols { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 12px; align-items: start; }
@media (max-width: 1100px) { .re-cols { grid-template-columns: 1fr; } }
.re-list { width: 100%; }
.re-edit { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.re-edit.hidden { display: none; }
.re-edit input:not([type=checkbox]), .re-edit select { width: 100%; }

.site-code { margin: 12px 0; text-align: center; }
.site-code code { font-size: 28px; letter-spacing: 4px; }
