:root {
  --navy: #0b3d6e; --navy2: #134f8a; --red: #c62828; --green: #2e7d32;
  --grey: #f2f4f7; --border: #d0d5dd; --text: #1d2939;
  font-family: "Segoe UI", system-ui, sans-serif; color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; overflow: hidden; }
.hidden { display: none !important; }
.mono { font-family: Consolas, monospace; }
.err { color: var(--red); min-height: 1em; }
.note { font-size: 12px; color: #667085; }

.overlay { position: fixed; inset: 0; background: linear-gradient(135deg, var(--navy), #08243f);
  display: flex; align-items: center; justify-content: center; z-index: 2000; }
.card { background: #fff; padding: 28px 32px; border-radius: 10px; width: 400px; max-height: 95vh; overflow: auto; }
.card h1 { margin: 0; font-size: 20px; color: var(--navy); }
.card .sub { margin: 4px 0 16px; color: #667085; font-size: 13px; }
label { display: block; font-size: 12px; font-weight: 600; margin: 8px 0 2px; }
label.check { font-weight: 400; display: flex; gap: 6px; align-items: center; }
input, select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px; font: inherit; font-weight: 400; }
input[type=checkbox] { width: auto; }
button { padding: 6px 12px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: pointer; font: inherit; }
button:hover { background: var(--grey); }
button.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
button.primary:hover { background: var(--navy2); }
button.small { padding: 2px 7px; font-size: 12px; }
.card button { margin-top: 12px; width: 100%; }
details { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 10px; }
summary { cursor: pointer; font-size: 13px; color: var(--navy); }

#app { display: flex; flex-direction: column; height: 100vh; }
header { background: var(--navy); color: #fff; padding: 6px 14px; display: flex; gap: 18px; align-items: center; font-size: 14px; }
header #h-utc { margin-left: auto; }
.link-status { color: #7f7; } .link-status.down { color: #f77; }
#body { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; }
aside { width: 380px; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: #fff; }
nav { display: flex; border-bottom: 1px solid var(--border); }
nav button { flex: 1; border: 0; border-radius: 0; padding: 10px 2px; font-size: 12px; }
nav button.active { border-bottom: 3px solid var(--navy); font-weight: 600; }
.badge { background: var(--red); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.badge:empty { display: none; }
.tab { padding: 10px 14px; overflow: auto; flex: 1; }
.tab h3 { font-size: 13px; text-transform: uppercase; color: var(--navy); margin: 14px 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row { display: flex; gap: 6px; margin-top: 8px; }
.row input { flex: 1; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; margin-bottom: 6px; font-size: 13px; }
.list li .title { font-weight: 600; }
.list li .actions { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }
.offline { opacity: .5; }

#tab-messages { display: flex; flex-direction: column; }
#msg-log { flex: 1; overflow: auto; font-size: 13px; }
.msg { margin: 4px 0; padding: 5px 8px; border-radius: 6px; background: var(--grey); }
.msg.own { background: #dbe8f7; }
.msg.private { border-left: 3px solid #e09b00; }
.msg .meta { font-size: 11px; color: #667085; }

.status-tasked { color: #b54708; } .status-acknowledged { color: var(--navy2); }
.status-commenced { color: #6941c6; } .status-completed { color: var(--green); }
.wp { font-family: Consolas, monospace; font-size: 11px; max-height: 120px; overflow: auto; background: var(--grey); padding: 4px; margin-top: 4px; }

.unit-label { background: rgba(255,255,255,.85); border: 1px solid #555; border-radius: 3px; padding: 0 3px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.unit-icon { background: none; border: 0; }
.source { border: 1px dashed var(--border); border-radius: 6px; padding: 4px 8px; margin-top: 6px; }
.source .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 4px; align-items: end; }
.led-on { color: var(--green); } .led-off { color: var(--red); }
.ais-label { background: rgba(255,255,255,.75); border: 0; box-shadow: none; padding: 0 2px; font-size: 10px; color: #444; }

/* ===================== usability additions ===================== */
button { min-height: 34px; }
button.small { min-height: 26px; }
button.big { padding: 10px 14px; font-size: 15px; font-weight: 600; }
button.full { width: 100%; }
button.huge { width: 100%; padding: 14px; font-size: 18px; font-weight: 700; letter-spacing: .5px; margin: 10px 0 4px; }
textarea { width: 100%; font: 12px Consolas, monospace; border: 1px solid var(--border); border-radius: 5px; padding: 6px; }
.card { width: 480px; }
.banner { background: #e8f1fb; border-left: 4px solid var(--navy); padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
details.compact { margin-top: 8px; border: 0; padding: 0; }

/* role cards */
.role-cards { display: flex; flex-direction: column; gap: 5px; }
.role-card { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; margin: 0; cursor: pointer; font-weight: 400; }
.role-card input { width: auto; margin-top: 3px; }
.role-card b { display: block; font-size: 13px; }
.role-card small { color: #667085; font-size: 12px; }
.role-card:has(input:checked) { border-color: var(--navy); background: #e8f1fb; }

/* header buttons */
header { gap: 12px; }
.hbtn { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); padding: 4px 10px; min-height: 28px; font-size: 13px; }
.hbtn:hover { background: rgba(255,255,255,.12); }
.gps-btn { font-weight: 700; font-size: 13px; padding: 4px 12px; min-height: 28px; min-width: 96px; border: 2px solid #98a2b3; background: #475467; color: #fff; }
.gps-btn:hover { background: #5b6577; }
.gps-btn.on { background: var(--green); border-color: #8fe39a; }
.gps-btn.on:hover { background: #38913c; }
.gps-btn.nofix { background: #b54708; border-color: #fdb022; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .65; } }

/* modal dialogs */
.modal-bg { position: fixed; inset: 0; background: rgba(8,20,40,.55); z-index: 5000; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 10px; padding: 18px 22px; width: 420px; max-width: 94vw; max-height: 88vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal.wide { width: 640px; }
.modal h2 { margin: 0 0 8px; font-size: 17px; color: var(--navy); }
.modal-buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.warn { color: #b54708; }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 6000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { background: #1d2939; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.toast.ok { background: var(--green); } .toast.error { background: var(--red); }
.toast.warn { background: #b54708; } .toast.task { background: #6941c6; font-weight: 600; font-size: 15px; }
.toast.clickable { cursor: pointer; }

/* help & glossary */
.help { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--navy2); color: #fff; font-size: 11px; font-weight: 700; cursor: help; vertical-align: middle; }
dl.glossary dt { font-weight: 700; color: var(--navy); margin-top: 8px; }
dl.glossary dd { margin: 2px 0 0 0; font-size: 13px; }

/* map overlay: plotting hint & wizard */
#map-wrap { flex: 1; position: relative; display: flex; }
.plot-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000; background: #1d2939; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.wizard { position: absolute; top: 10px; left: 56px; z-index: 1000; width: 400px; max-height: calc(100% - 20px); overflow: auto; background: #fff; border-radius: 10px; box-shadow: 0 6px 28px rgba(0,0,0,.3); padding: 14px 16px; }
.wizard h2 { margin: 0; font-size: 16px; color: var(--navy); }
.wizard .wz-step { font-size: 12px; color: #667085; margin-bottom: 6px; }
.wizard .choice { display: block; width: 100%; text-align: left; margin: 6px 0; padding: 9px 11px; }
.wizard .choice b { display: block; }
.wizard .choice span { font-size: 12px; color: #667085; }
.wizard .choice.selected { border: 2px solid var(--navy); background: #e8f1fb; }
.wizard .wz-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
.wizard .suggest { background: #ecfdf3; border-left: 4px solid var(--green); padding: 6px 9px; font-size: 13px; margin-top: 8px; }

/* areas: labelled plot buttons */
.plot-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.plot-buttons button { text-align: left; padding: 8px 10px; }
.plot-buttons b { display: block; } .plot-buttons span { font-size: 12px; color: #667085; }

/* first steps */
.steps-box { background: #fffaeb; border: 1px solid #fedf89; border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.steps-box ol { margin: 6px 0 0; padding-left: 18px; } .steps-box li { margin-bottom: 3px; }
.steps-head { display: flex; justify-content: space-between; align-items: center; }

/* my task */
.mytask { border: 2px solid var(--navy); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.mytask.empty { border-style: dashed; border-color: var(--border); font-size: 13px; }
.mytask.status-box-tasked { border-color: #b54708; background: #fffaeb; }
.mytask-head { font-size: 12px; font-weight: 700; letter-spacing: .5px; display: flex; justify-content: space-between; }
.mytask h2 { margin: 4px 0; font-size: 17px; }
.mytask .remarks { background: var(--grey); padding: 5px 8px; border-radius: 5px; }
.mytask-steps { padding-left: 18px; font-size: 13px; } .mytask-steps li { margin-bottom: 8px; }
.big-coord { font-size: 16px; font-weight: 700; }
table.legs { border-collapse: collapse; width: 100%; font-size: 12px; margin: 4px 0; }
table.legs th, table.legs td { border-bottom: 1px solid var(--border); padding: 2px 4px; text-align: left; }
table.legs.big { font-size: 13px; } table.legs.big td { padding: 4px; }
.tab { font-size: 14px; }

/* ===================== night mode (bridge) ===================== */
body.night { --text: #ff6b6b; background: #000; color: #ff6b6b; }
body.night header, body.night aside, body.night nav, body.night .tab, body.night .card, body.night .modal, body.night .wizard,
body.night .list li, body.night .msg, body.night .mytask, body.night .steps-box, body.night .banner, body.night .role-card { background: #0b0b0b !important; color: #ff6b6b !important; border-color: #4a1010 !important; }
body.night input, body.night select, body.night textarea, body.night button { background: #140404; color: #ff6b6b; border-color: #5a1515; }
body.night button.primary, body.night .gps-btn.on { background: #5a0f0f; border-color: #a33; color: #ffb3b3; }
body.night .gps-btn { background: #1a0505; }
body.night .note, body.night .tab h3, body.night summary, body.night .wizard h2, body.night .modal h2, body.night dl.glossary dt { color: #d14b4b !important; }
body.night .leaflet-tile-pane { filter: brightness(.35) sepia(1) hue-rotate(-50deg) saturate(3); }
body.night .overlay { background: #000; }
body.night .toast { background: #3a0808; color: #ffb3b3; }
body.night .wp, body.night .remarks { background: #140404 !important; }
.ais-online { border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font-size: 13px; }
body.night .ais-online { border-color: #4a1010; }

/* ===================== icons, settings drawer, own-ship button ===================== */
svg.ico { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; pointer-events: none; }
button svg.ico { margin-right: 5px; }
button.icon-only svg.ico { margin-right: 0; }
.tab h3 { display: flex; align-items: center; gap: 6px; }
.tab h3 svg.ico, .drawer h3 svg.ico { width: 16px; height: 16px; }
summary svg.ico { margin-right: 4px; }
.row.wrap { flex-wrap: wrap; }
.count { white-space: nowrap; align-self: center; }

header .h-title { display: inline-flex; align-items: center; gap: 6px; }
header .h-title svg.ico { width: 20px; height: 20px; }
.hbtn { display: inline-flex; align-items: center; }
.hbtn.icon-only { padding: 4px 7px; }
.hbtn.icon-only svg.ico { width: 18px; height: 18px; }
.hbtn.active { background: rgba(255,255,255,.22); }
.gps-btn::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; margin-right: 6px; vertical-align: 0; }
.gps-btn.on::before { background: #b7f7c0; }
.gps-btn.nofix::before { background: #fdb022; }

/* tabs: icon above the label */
nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; font-size: 12px; position: relative; }
nav button svg.ico { width: 20px; height: 20px; margin: 0; }
nav button .badge { position: absolute; top: 4px; right: 18%; }

/* settings drawer over the side panel */
aside { position: relative; }
.drawer { position: absolute; inset: 0; background: #fff; z-index: 500; overflow: auto; padding: 0 14px 20px; font-size: 14px; box-shadow: -4px 0 16px rgba(0,0,0,.12); }
.drawer-head { position: sticky; top: 0; background: #fff; display: flex; justify-content: space-between; align-items: center; padding: 12px 0 8px; border-bottom: 1px solid var(--border); z-index: 1; }
.drawer-head b { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; color: var(--navy); }
.drawer-head button { border: 0; }
.drawer h3 { font-size: 13px; text-transform: uppercase; color: var(--navy); margin: 18px 0 6px; display: flex; align-items: center; gap: 6px; }
.drawer details { margin-top: 8px; }

/* plotting buttons with icons */
.plot-buttons button { display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; column-gap: 4px; align-items: center; }
.plot-buttons button svg.ico { grid-row: 1 / 3; width: 22px; height: 22px; margin: 0; color: var(--navy2); }

/* own-ship button on the chart */
.ownship-btn { width: 40px; height: 40px; background: #fff; border: 2px solid rgba(0,0,0,.25); border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--navy); padding: 0; min-height: 0; }
.ownship-btn svg.ico { width: 26px; height: 26px; margin: 0; }
.ownship-btn:hover { background: #e8f1fb; }
.ownship-btn.following { background: var(--navy); color: #fff; border-color: var(--navy); }
.mytask button.huge svg.ico { width: 22px; height: 22px; }
.steps-head b { display: inline-flex; align-items: center; gap: 5px; }

body.night .drawer, body.night .drawer-head { background: #0b0b0b !important; color: #ff6b6b; border-color: #4a1010 !important; }
body.night .drawer h3, body.night .drawer-head b { color: #d14b4b; }
body.night .ownship-btn { background: #140404; color: #ff6b6b; border-color: #5a1515; }
body.night .ownship-btn.following { background: #5a0f0f; color: #ffb3b3; }
body.night .plot-buttons button svg.ico { color: #ff6b6b; }

/* guided planning: picture tiles */
svg.pic { width: 64px; height: 64px; flex: none; fill: none; stroke: var(--navy); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
svg.pic .pf { fill: var(--navy); stroke: none; }
svg.pic .pd { stroke: #98a2b3; stroke-width: 1.6; stroke-dasharray: 4 3; }
svg.pic .pl { stroke: #2e90fa; }
svg.pic .pa { fill: #fde68a; stroke: none; }
svg.pic .pt { fill: #98a2b3; stroke: none; font-family: sans-serif; }
svg.pic.small { width: 40px; height: 40px; }
.wizard .tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.wizard .tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 10px 8px; min-height: 128px; position: relative; }
.wizard .tile b { font-size: 13px; }
.wizard .tile span { font-size: 11.5px; color: #667085; line-height: 1.3; }
.wizard .tile.selected { border: 2px solid var(--navy); background: #e8f1fb; }
.wizard .tile .rec { position: absolute; top: 5px; right: 6px; font-size: 10px; font-weight: 700; color: #fff; background: var(--green); border-radius: 8px; padding: 1px 6px; }
.wizard .tile.wide { grid-column: 1 / -1; flex-direction: row; text-align: left; min-height: 0; }
.wizard .pat-help { font-size: 12.5px; background: #f2f4f7; border-radius: 6px; padding: 7px 9px; margin-top: 8px; }
.wizard .wz-dots { display: flex; gap: 4px; margin-bottom: 8px; }
.wizard .wz-dots i { flex: 1; height: 4px; border-radius: 2px; background: #d0d5dd; }
.wizard .wz-dots i.done { background: var(--navy); }
.mytask h2 { display: flex; align-items: center; gap: 8px; }
body.night svg.pic { stroke: #ff6b6b; } body.night svg.pic .pf { fill: #ff6b6b; }
body.night svg.pic .pa { fill: #5c1a1a; } body.night svg.pic .pl { stroke: #ff9b9b; }
body.night .wizard .tile.selected { background: #2a0d0d; }
body.night .wizard .pat-help { background: #1a0808; }

/* chat pictures and voice messages */
.msg-compose { gap: 4px; }
.msg-compose .icon-only { padding: 6px 8px; }
.msg-compose .icon-only svg.ico { width: 18px; height: 18px; margin: 0; }
#msg-voice.recording { background: #d92d20; color: #fff; border-color: #d92d20; }
.msg-img img { display: block; max-width: 100%; max-height: 220px; border-radius: 6px; margin: 4px 0; cursor: zoom-in; }
.msg-audio { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.msg-audio audio { height: 32px; max-width: 220px; }
.msg-rec { display: flex; align-items: center; gap: 8px; background: #fef3f2; border: 1px solid #fecdca; border-radius: 6px; padding: 6px 9px; font-size: 13px; margin-top: 4px; }
.msg-rec button { margin-left: auto; } .msg-rec button + button { margin-left: 0; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #d92d20; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
body.night .msg-img img { filter: brightness(.6); }
body.night .msg-rec { background: #1a0808; border-color: #4a1010; }
.move-status { display: flex; align-items: center; gap: 9px; margin-top: 8px; padding: 7px 10px; background: #eff8ff; border: 1px solid #b2ddff; border-radius: 6px; font-size: 13px; }
.move-status > svg.ico { width: 22px; height: 22px; color: var(--navy); }
.move-status button { margin-left: auto; }
body.night .move-status { background: #1a0808; border-color: #4a1010; }
body.night .move-status > svg.ico { color: #ff6b6b; }
.ok-text { color: var(--green); font-weight: 600; }
.est { color: #b54708; font-style: italic; }
body.night .est { color: #ff9b9b; }

/* graphic marks and past track */
.mark-bar { display: flex; flex-direction: column; background: #fff; }
.mark-bar button { width: 34px; height: 34px; padding: 0; border: 0; border-bottom: 1px solid #ccc; border-radius: 0; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.mark-bar button:last-child { border-bottom: 0; }
.mark-bar button:hover { background: #f2f4f7; }
.mark-bar button.on { background: #d1e9ff; box-shadow: inset 0 0 0 2px var(--navy); }
.mark-bar svg { pointer-events: none; }
.mark-icon { background: none; border: 0; }
.mark-edit { margin-top: 6px; }
.mark-edit .swatches { display: flex; gap: 4px; margin-bottom: 6px; }
.mark-edit .sw { width: 20px; height: 20px; min-width: 0; min-height: 0; flex: none; padding: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #98a2b3; }
.mark-edit .sw.on { box-shadow: 0 0 0 2px var(--navy); }
body.night .mark-bar, body.night .mark-bar button { background: #0b0b0b; border-color: #4a1010; }

/* bearing and distance tool */
#measure-btn svg.ico { width: 20px; height: 20px; margin: 0; color: #344054; }
.measure-end { background: #fff; border: 2.5px solid #101828; border-radius: 50%; }
.leaflet-marker-draggable.measure-end { cursor: move; }
.measure-tag { font-size: 10px; font-weight: 700; padding: 0 4px; }
.measure-label { background: #101828; color: #fff; border: 0; border-radius: 6px; padding: 5px 9px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.measure-label::before { border-top-color: #101828 !important; }
.measure-label b { display: block; font-size: 14px; font-family: ui-monospace, Consolas, monospace; }
.measure-label span { font-size: 11px; opacity: .85; }
body.night .measure-label { background: #2a0d0d; color: #ff6b6b; }
.mark-bar.collapsed .mark-sym { display: none; }
.mark-bar .mark-toggle { position: relative; }
.mark-bar .mark-toggle .plus { position: absolute; right: 2px; bottom: 0; font-size: 12px; font-weight: 800; color: var(--navy); line-height: 1; }
.mark-bar:not(.collapsed) .mark-toggle { background: #eef4ff; }
.mark-bar .mark-toggle.on { background: #d1e9ff; box-shadow: inset 0 0 0 2px var(--navy); }

/* participant list: joining page and EXCON editor */
.roster-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 300px; overflow: auto; margin-bottom: 6px; }
.roster-card { display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; position: relative; }
.roster-card svg.ico { width: 22px; height: 22px; color: var(--navy); margin: 0; }
.roster-card b { display: block; font-size: 14px; }
.roster-card small { display: block; font-size: 11.5px; color: #667085; }
.roster-card.selected { border: 2px solid var(--navy); background: #e8f1fb; }
.roster-card[disabled] { opacity: .5; cursor: not-allowed; }
.roster-card .busy { position: absolute; top: 3px; right: 6px; font-size: 10px; font-style: normal; color: var(--green); font-weight: 700; }
.linkish { background: none; border: 0; padding: 2px 0; color: var(--navy2, #1570ef); text-decoration: underline; cursor: pointer; font-size: 13px; }
.card-like { border: 1px solid #d0d5dd; border-radius: 6px; padding: 6px 9px; margin: 10px 0; }
.card-like > summary { cursor: pointer; }
.card-like textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; box-sizing: border-box; }
#roster-list li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 4px 8px; }
#roster-list li .title { font-size: 13px; }
#roster-list .icon-only svg.ico { margin: 0; }

/* chart legend */
.legend-box { background: #fff; border-radius: 6px; box-shadow: 0 1px 5px rgba(0,0,0,.35); font-size: 12px; max-width: 290px; }
.legend-toggle { display: flex; align-items: center; gap: 5px; border: 0; background: none; padding: 6px 10px; font-weight: 600; cursor: pointer; }
.legend-box.collapsed .legend-body, .legend-box.collapsed .legend-close { display: none; }
.legend-head { display: flex; align-items: center; justify-content: space-between; }
.legend-close { border: 0; background: none; font-size: 20px; line-height: 1; padding: 2px 10px; cursor: pointer; color: #555; }
.legend-close:hover { color: #c62828; }
.legend-body { padding: 0 10px 8px; max-height: 55vh; overflow: auto; }
.lg-title { font-weight: 700; color: var(--navy); margin: 8px 0 3px; text-transform: uppercase; font-size: 10.5px; letter-spacing: .03em; }
.lg-row { display: flex; align-items: center; gap: 8px; margin: 2px 0; line-height: 1.25; }
.lg-sym { width: 40px; flex: none; display: flex; justify-content: center; }
body.night .legend-box { background: #0b0b0b; color: #ff6b6b; }
body.night .legend-toggle, body.night .legend-close { color: #ff6b6b; }
.leaflet-control-attribution { font-size: 9.5px; opacity: .75; }
/* mark position editing */
.mark-pos { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px; margin: 6px 0; }
.mark-pos label { display: flex; flex-direction: column; font-size: 11px; color: #555; }
.mark-pos input { width: 108px; padding: 3px 5px; font-size: 12px; }
.mark-pos input.bad { border-color: #c62828; background: #fdecea; }
/* chat conversations: all stations vs private */
.msg-convs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.msg-convs .conv { display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; border-radius: 14px; border: 1px solid #d0d5dd; background: #fff; font-size: 12px; cursor: pointer; }
.msg-convs .conv .badge { margin-left: 2px; }
.msg-convs .conv.all.on { background: #0b3d6e; color: #fff; border-color: #0b3d6e; }
.msg-convs .conv.priv.on { background: #e09b00; color: #fff; border-color: #e09b00; }
.msg-convs .conv.priv:not(.on) { border-color: #e09b00; }
.msg-convs select { font-size: 12px; padding: 3px 6px; border-radius: 14px; width: auto; }
.msg-head { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 6px 9px; border-radius: 6px; margin-bottom: 6px; }
.msg-head.all { background: #e8f0fa; color: #0b3d6e; }
.msg-head.priv { background: #fff4e0; color: #8a5a00; border-left: 3px solid #e09b00; }
.msg-tag.priv { font-size: 10px; font-weight: 700; color: #8a5a00; background: #fff4e0; border-radius: 3px; padding: 0 4px; }
body.night .msg-convs .conv, body.night .msg-head { background: #0b0b0b !important; color: #ff6b6b !important; border-color: #4a1010 !important; }
body.night .msg-convs .conv.on { background: #2a0808 !important; }
/* "+" attach menu and documents in the chat */
.attach-wrap { position: relative; }
.attach-menu { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 50; background: #fff; border: 1px solid #d0d5dd; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.18); padding: 4px; min-width: 230px; }
.attach-menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.attach-menu button:hover { background: #f2f4f7; }
.msg-doc { display: flex; align-items: center; gap: 8px; margin: 4px 0; padding: 7px 9px; background: #fff; border: 1px solid #d0d5dd; border-radius: 6px; text-decoration: none; color: inherit; max-width: 280px; }
.msg-doc svg.ico { width: 26px; height: 26px; flex: none; color: #0b3d6e; }
.msg-doc span { display: flex; flex-direction: column; min-width: 0; }
.msg-doc b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.msg-doc small { color: #667085; font-size: 11px; }
.msg-doc:hover { border-color: #0b3d6e; }
body.night .attach-menu, body.night .msg-doc { background: #0b0b0b; color: #ff6b6b; border-color: #4a1010; }

/* ===================== accounts and offline ===================== */
#offline-banner { background: #b42318; color: #fff; text-align: center; font-weight: 700; padding: 6px 10px; font-size: 14px; }
body.accounts #login-connection label:not(:nth-child(2)) { display: none; }
body.night #offline-banner { background: #5a0f0f; color: #ffb3b3; }

/* co-ordination functions */
.functions { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.function-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; }
.function-row + .function-row { border-top: 1px solid var(--border); }
.function-row small { display: block; opacity: .7; }
