/* Lodestar operations console — dark, dense, legible at 3am.
   One scale for everything: 8 px spacing grid, 32 px controls, 8 px radius,
   type at 11/12/13/14 px. Colour is reserved for state. */
:root {
  color-scheme: dark;
  /* Braeburn Group palette (matches the BRIAR console) */
  --bg: #09111c;
  --panel: #101b2a;
  --panel-2: #0d1724;
  --panel-3: #16233a;
  --line: #25344a;
  --line-soft: #1b2839;
  --text: #edf2f7;
  --muted: #91a0b4;
  --faint: #5f6f86;
  --accent: #67a7ff;
  --gold: #c4a464;
  --ok: #56c596;       /* moving */
  --contact: #2f6fe0;  /* still, and in contact: the phone is heard from (heartbeats, wake-ups). Deeper than the
                          #4c8dff accuracy circle; white on it is 4.7:1, and it reads on the light map and the dark roster */
  --idle: #6a7b90;
  --aboard: #e040fb;   /* a traveller on a flight: magenta, the colour of being aboard (vessels share it), never
                          the red of an SOS — silence is flight mode, not a lost traveller (Andy, 1 Oct 2026) */
  --warn: #f7b955;
  --crit: #ff6b6b;
  --sos: #ff4d4f;
  --radius: 8px;
  --control: 32px;
  --header-h: 52px;
  --left-w: 340px;
  --right-w: 340px;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
  --flight: #ff1a1a;   /* aircraft and their tracks: red, to stand out on the light map */
  --vessel: #e040fb;   /* vessels travellers are aboard: magenta, clear of water, land, the trip, zone and status colours */
  --paused: #b9a4ff;   /* paused by the traveller: lavender, apart from every alarm colour — not an alarm, but nobody is watching */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 13px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---- controls ---------------------------------------------------------- */
button {
  height: var(--control); padding: 0 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
button.danger { background: var(--sos); border-color: var(--sos); color: #fff; font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.active { border-color: var(--accent); color: var(--accent); }

.icon-btn { width: var(--control); padding: 0; justify-content: center; font-size: 16px; line-height: 1; }
.link-btn { height: auto; padding: 0; background: none; border: 0; color: var(--accent); font-size: 12px; }
.link-btn:hover { text-decoration: underline; }

input, select, textarea {
  height: var(--control); background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0 10px; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

/* ---- popover menus ------------------------------------------------------ */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 200px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; display: grid; gap: 2px;
}
.menu.menu-right { left: auto; right: 0; }
.menu-item {
  height: var(--control); justify-content: flex-start; background: transparent; border-color: transparent;
  width: 100%; border-radius: 6px;
}
.menu-item:hover { background: var(--panel-3); border-color: transparent; }
.menu-item.danger { background: transparent; color: var(--crit); font-weight: 500; }
.menu-item.danger:hover { background: rgba(255,77,79,.12); }
.menu-check { display: flex; align-items: center; gap: 8px; height: var(--control); padding: 0 10px; border-radius: 6px; cursor: pointer; }
.menu-check:hover { background: var(--panel-3); }
.menu-check input { width: 14px; height: 14px; margin: 0; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.menu-section { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }

/* ---- layout ------------------------------------------------------------ */
.app { display: grid; grid-template-rows: var(--header-h) 1fr; height: 100%; }

header.top {
  display: flex; align-items: center; gap: 20px; min-width: 0;
  padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand .mark { width: 22px; height: 22px; }
.brand .word { font-weight: 700; letter-spacing: .3px; font-size: 14px; }
.brand small { color: var(--muted); font-weight: 400; }
.top-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }

/* KPIs are navigation: each one focuses the map and the roster on its group. */
/* min-width: 0 lets the strip shrink and scroll instead of widening the header past a phone's screen. */
.kpis { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.kpis::-webkit-scrollbar { display: none; }
.kpi {
  height: 40px; padding: 0 12px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 0; background: transparent; border: 1px solid transparent; border-radius: var(--radius); min-width: 76px;
}
.kpi:hover { background: var(--panel-2); border-color: var(--line); }
.kpi.active { background: var(--panel-3); border-color: var(--accent); }
.kpi b { font-size: 16px; line-height: 1.1; font-variant-numeric: tabular-nums; font-weight: 600; }
.kpi span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; line-height: 1.3; }
.kpi.alarm b { color: var(--warn); }
.kpi.sos b { color: var(--sos); }
.kpi.zero b { color: var(--muted); font-weight: 500; }

.conn { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.conn.live .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.conn.down .dot { background: var(--crit); }
.whoami { color: var(--muted); font-size: 12px; white-space: nowrap; }
#notifyBtn { width: var(--control); padding: 0; font-size: 14px; line-height: 1; }
#notifyBtn[aria-pressed="true"] { border-color: var(--accent); }

.main { display: grid; grid-template-columns: var(--left-w) 1fr var(--right-w); min-height: 0; }
.app[data-left="closed"] { --left-w: 0px; }
.app[data-right="closed"] { --right-w: 0px; }
.app[data-left="closed"] .col.left, .app[data-right="closed"] .col.right { display: none; }

.col { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--panel); }
/* Each column owns its slot, so hiding one leaves the others where they are
   instead of letting the grid slide the map into the empty first column. */
.col.left { grid-column: 1; border-right: 1px solid var(--line); }
.col.center { grid-column: 2; }
.col.right { grid-column: 3; border-left: 1px solid var(--line); }
.col-view { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.col-head {
  display: flex; align-items: center; gap: 8px; height: 48px; flex: 0 0 48px;
  padding: 0 12px; border-bottom: 1px solid var(--line);
}
.col-head h2 { margin: 0; flex: 1; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.scroll { overflow-y: auto; flex: 1; min-height: 0; }
.spacer { flex: 1; }

.tabs { display: flex; gap: 4px; padding: 8px 12px 0; }
.tab { height: 30px; padding: 0 12px; border-radius: 999px; font-size: 12px; background: transparent; border: 1px solid transparent; color: var(--muted); }
.tab.active { background: var(--panel-2); border-color: var(--line); color: var(--text); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.filters input { flex: 1 1 0; min-width: 0; }
.filters select { width: 120px; flex: 0 0 auto; }
/* Operators: search on its own line, then status and client side by side.
   The portal has no client picker and keeps the single line. */
body:not(.portal) .filters input { flex-basis: 100%; }
body:not(.portal) .filters select { flex: 1 1 0; width: auto; min-width: 0; }
body.portal #clientFilter { display: none !important; }
.filters select.active { border-color: var(--accent); color: var(--accent); }

/* Column edge toggles: always visible, sit on the map's edges. */
.edge {
  position: absolute; z-index: 6; top: 50%; transform: translateY(-50%);
  width: 18px; height: 56px; padding: 0; border-radius: 0 6px 6px 0; border-left: 0;
  background: rgba(16,27,42,.92); color: var(--muted); font-size: 14px; justify-content: center;
}
.edge:hover { color: var(--text); }
.edge-left { left: 0; }
.edge-right { right: 0; border-radius: 6px 0 0 6px; border-right: 0; border-left: 1px solid var(--line); }

/* ---- roster ------------------------------------------------------------ */
.row {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center;
  height: 56px; padding: 0 12px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.row:hover { background: var(--panel-2); }
.row.selected { background: var(--panel-3); box-shadow: inset 2px 0 0 var(--accent); }
.row .dot { width: 10px; height: 10px; border-radius: 50%; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub .tag { color: var(--warn); }
.row .meta .wake { color: var(--faint); font-size: 10px; cursor: help; }
.row .meta .low-battery { color: var(--warn); cursor: help; }
.row .meta { text-align: right; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; line-height: 1.4; }

.dot.moving { background: var(--ok); }
.dot.in_flight { background: var(--aboard); }
.dot.idle, .dot.ok { background: var(--contact); }
.dot.no_signal, .dot.overdue { background: var(--warn); }
.dot.sos { background: var(--sos); animation: pulse 1.1s infinite; }
.dot.paused, .dot.unknown { background: #4a5766; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ---- traveller detail (left column) ------------------------------------ */
.detail-head { padding: 0 8px 0 12px; }
.detail-title { display: flex; align-items: center; gap: 10px; padding: 14px 12px 6px; }
.detail-title h3 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 12px 12px; border-bottom: 1px solid var(--line); }
.detail-body { padding: 12px; display: grid; gap: 10px; align-content: start; }

/* Facts: a fixed two-column grid of equal tiles. Long values are cut, with
   the full text on hover, so nothing wraps and nothing lines up wrong. */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { height: 54px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 8px 10px; min-width: 0; }
.fact span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.fact b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.fact b.warn { color: var(--warn); }
.fact b.crit { color: var(--sos); }
.fact b.ok { color: var(--ok); }
.fact.wide { grid-column: 1 / -1; }
/* A fact that is a sentence (what the phone is doing): wraps, full width, rather than being cut. */
.fact.tall { height: auto; min-height: 54px; }
.fact.tall b { white-space: normal; line-height: 1.35; }
.fact .fact-select { display: block; width: 100%; height: 24px; margin-top: 1px; padding: 0 6px; font-size: 13px; font-weight: 600; }

/* Sections fold. Closed by default except what the operator needs first. */
details.section { border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--panel-2); }
details.section summary {
  list-style: none; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; cursor: pointer;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); user-select: none;
}
details.section summary::-webkit-details-marker { display: none; }
details.section summary::before { content: '›'; font-size: 14px; color: var(--faint); transition: transform .15s; width: 10px; }
details.section[open] summary::before { transform: rotate(90deg); }
details.section summary .count { margin-left: auto; font-size: 11px; color: var(--text); background: var(--panel-3); border-radius: 999px; padding: 1px 8px; letter-spacing: 0; text-transform: none; }
details.section .section-body { padding: 0 8px 8px; display: grid; gap: 6px; }

.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.pill.low, .pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.moderate, .pill.warn, .pill.overdue, .pill.no_signal { color: var(--warn); border-color: var(--warn); }
.pill.in_flight { color: var(--aboard); border-color: var(--aboard); }
/* Traveller status: still and in contact is filled, so it is never taken for "resting" (an accent outline). */
.pill.idle { background: var(--contact); border-color: var(--contact); color: #fff; }
.pill.moving { color: var(--ok); border-color: var(--ok); }
.pill.high { color: #ff8a3d; border-color: #ff8a3d; }
.pill.extreme, .pill.sos { color: var(--sos); border-color: var(--sos); }
.pill.resting { color: var(--accent); border-color: var(--accent); }

.seglist { display: grid; gap: 6px; }
.seg { display: grid; grid-template-columns: 62px 1fr auto; gap: 8px; align-items: center;
       background: var(--panel); border: 1px solid var(--line-soft); border-radius: 6px; padding: 7px 10px; font-size: 12px; min-width: 0; }
.seg > span:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg .kind { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.seg .status { font-size: 11px; color: var(--muted); white-space: nowrap; }
.seg .status.delayed, .seg .status.diverted, .seg .status.cancelled { color: var(--crit); }

/* ---- map --------------------------------------------------------------- */
.col.center { position: relative; background: #0d1319; }
#map { position: absolute; inset: 0; }
.map-empty {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  padding: 30px; color: var(--muted); gap: 10px;
}
.map-empty code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; color: var(--text); }

.map-tools { position: absolute; z-index: 5; top: 10px; left: 26px; display: flex; gap: 6px; }
.map-tools button { background: rgba(16,27,42,.92); backdrop-filter: blur(6px); }
.map-tools .menu { background: rgba(16,27,42,.98); }

/* The bars over the map: the client picker's, then a KPI's. Below the map
   tools, so a bar never covers Fit all. */
.map-notices {
  position: absolute; z-index: 5; top: 52px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  max-width: calc(100% - 52px); pointer-events: none;
}
.map-notice {
  display: flex; align-items: center; gap: 12px; height: var(--control); padding: 0 14px; max-width: 100%;
  background: rgba(16,27,42,.96); border: 1px solid var(--accent); border-radius: 999px; font-size: 12px;
  white-space: nowrap; pointer-events: auto;
}
.map-notice > span { overflow: hidden; text-overflow: ellipsis; }
/* An SOS the client picker is hiding: never silent. */
.client-notice.alarm { border-color: var(--sos); box-shadow: 0 0 0 1px var(--sos); }
.client-notice .out-sos { color: var(--sos); font-weight: 700; }
.map-hint {
  position: absolute; z-index: 5; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(16,27,42,.95); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-size: 12px; display: none;
}
.map-hint.show { display: block; }

.marker {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--idle); border: 2px solid rgba(255,255,255,.85); color: #04121f;
  font-size: 11px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.6); transition: opacity .2s, transform .2s, translate .25s;
}
.marker.moving { background: var(--ok); }
.marker.in_flight { background: var(--aboard); }
/* Shown on the aircraft: a badge off the plane's lower right, so the plane stays visible. */
.marker.onplane { translate: 15px 15px; scale: .8; }
.marker.idle, .marker.ok { background: var(--contact); color: #fff; }
.marker.unknown { background: var(--idle); color: #fff; }
.marker.no_signal, .marker.overdue { background: var(--warn); }
.marker.sos { background: var(--sos); color: #fff; animation: pulse 1.1s infinite; }
/* Every live marker pulses, whatever it is doing, so it is easy to spot on the map
   (Andy, 6 Oct 2026): a ring in the marker's own colour pings outward and fades.
   An SOS keeps its blink and pings faster. Track breadcrumbs are left still. */
.marker { position: relative; --ring: var(--idle); }
.marker.moving { --ring: var(--ok); }
.marker.in_flight { --ring: var(--aboard); }
.marker.idle, .marker.ok { --ring: var(--contact); }
.marker.no_signal, .marker.overdue { --ring: var(--warn); }
.marker.sos { --ring: var(--sos); }
.marker.flight { --ring: var(--flight); }
.marker.flight.diverted { --ring: var(--sos); }
.marker.vessel { --ring: var(--vessel); }
.marker.vessel.distress { --ring: var(--sos); }
.marker::after {
  content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 3px solid var(--ring);
  pointer-events: none; opacity: 0; animation: marker-ping 1.8s ease-out infinite;
}
.marker.flight::after, .marker.vessel::after { inset: auto; left: -15px; top: -15px; width: 30px; height: 30px; }
.marker.sos::after, .marker.flight.diverted::after, .marker.vessel.distress::after { animation-duration: 1.1s; }
@keyframes marker-ping { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(2.3); opacity: 0; } }
/* Markers that would sit on top of each other are fanned out around their shared spot
   (layoutFan in console.js); a thin line in the marker's colour runs back to where it
   really is, starting at the marker's edge. */
.marker[data-fanned] { translate: var(--fan-x, 0) var(--fan-y, 0); z-index: 1; }
.marker[data-fanned]::before {
  content: ''; position: absolute; left: 50%; top: 50%; height: 2px; pointer-events: none;
  width: max(0px, calc(var(--fan-len, 0px) - 14px)); background: var(--ring); opacity: .85;
  transform-origin: 0 50%; transform: rotate(var(--fan-angle, 0rad)) translateX(14px);
}
/* With the system's reduce-motion setting on, a steady halo instead of the ping. */
@media (prefers-reduced-motion: reduce) {
  .marker::after { animation: none; opacity: .55; transform: scale(1.5); }
}
/* An aircraft: the plane sits on the position, the card hangs off a wire above right. */
.marker.flight {
  display: block; position: relative; width: 0; height: 0; overflow: visible;
  background: none; border: 0; box-shadow: none; border-radius: 0; cursor: default;
}
.marker.flight .plane {
  position: absolute; left: -13px; top: -13px; width: 26px; height: 26px; fill: var(--flight);
  filter: drop-shadow(0 0 2px rgba(255,255,255,.9)) drop-shadow(0 1px 3px rgba(0,0,0,.6)); transition: transform .4s;
}
.marker.flight .wire {
  position: absolute; left: 0; top: 0; width: 30px; height: 1px; background: var(--flight);
  transform: rotate(-42deg); transform-origin: left center; opacity: .95;
}
.marker.flight .tag {
  position: absolute; left: 20px; top: -30px; white-space: nowrap; font-size: 10px; font-weight: 700;
  letter-spacing: .3px; color: var(--flight); background: var(--panel); border: 1px solid var(--flight);
  border-radius: 4px; padding: 2px 6px; box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.marker.flight.diverted .plane { fill: var(--sos); animation: pulse 1.1s infinite; }
.marker.flight.diverted .tag { border-color: var(--sos); }
.marker.flight.diverted .wire { background: var(--sos); }
/* A vessel: the hull sits on the position, the card hangs off a wire above right, like an aircraft's. */
.marker.vessel {
  display: block; position: relative; width: 0; height: 0; overflow: visible;
  background: none; border: 0; box-shadow: none; border-radius: 0; cursor: default;
}
.marker.vessel .hull {
  position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; fill: var(--vessel);
  filter: drop-shadow(0 0 2px rgba(255,255,255,.9)) drop-shadow(0 1px 3px rgba(0,0,0,.6)); transition: transform .4s;
}
.marker.vessel .wire {
  position: absolute; left: 0; top: 0; width: 30px; height: 1px; background: var(--vessel);
  transform: rotate(-42deg); transform-origin: left center; opacity: .95;
}
.marker.vessel .tag {
  position: absolute; left: 20px; top: -30px; white-space: nowrap; font-size: 10px; font-weight: 700;
  letter-spacing: .3px; color: var(--vessel); background: var(--panel); border: 1px solid var(--vessel);
  border-radius: 4px; padding: 2px 6px; box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.marker.vessel.stale { opacity: .55; }
.marker.vessel.distress .hull { fill: var(--sos); animation: pulse 1.1s infinite; }
.marker.vessel.distress .tag, .marker.vessel.distress .wire { border-color: var(--sos); background: var(--sos); color: #fff; }
.vesselline.distress { color: var(--sos); font-weight: 700; }
.flightline { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); min-width: 0; }
.flightline > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flightline.in_air { color: var(--accent); }
.flight-candidates { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; color: var(--warn, var(--muted)); }
.flightline.diverted { color: var(--sos); font-weight: 600; }
.flightline .link-btn { font-size: 11px; flex: 0 0 auto; }
.marker.focus { transform: scale(1.2); box-shadow: 0 0 0 4px rgba(103,167,255,.45), 0 0 22px var(--accent); animation: ring 1.4s infinite; }
.marker.dim { opacity: .3; }
@keyframes ring { 0% { box-shadow: 0 0 0 3px rgba(103,167,255,.6); } 100% { box-shadow: 0 0 0 14px rgba(103,167,255,0); } }

/* ---- lists (alerts, trips, intel) --------------------------------------- */
.alert { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); border-left: 3px solid var(--idle); cursor: pointer; }
.alert:hover { background: var(--panel-2); }
.alert.info { border-left-color: var(--accent); }
.alert.warning { border-left-color: var(--warn); background: rgba(247,185,85,.04); }
.alert.critical { border-left-color: var(--sos); background: rgba(255,77,79,.08); }
.alert .msg { font-size: 13px; }
.alert .when { color: var(--muted); font-size: 11px; display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; }
.alert.acked { border-left-color: var(--line); background: none; }
.alert.acked .msg { color: var(--muted); }
/* Who acknowledged an alert, and who did what it records (src/actors.js). The
   names are people's own, so they wrap rather than widen the column. */
.alert .who { margin-top: 3px; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.alert .who .tick { color: var(--ok); }
.alert .who.pending { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--warn); }
.alert .when { align-items: center; }
/* An SOS or an unanswered phone is acknowledged only by this button, never by
   a click on its card. */
.alert .ack-btn { flex: 0 0 auto; height: 26px; padding: 0 10px; font-size: 12px; font-weight: 600; color: var(--text); }
.alert.critical .ack-btn { border-color: var(--sos); }
.alert .ack-btn:hover { background: var(--sos); border-color: var(--sos); color: #fff; }
.empty { padding: 24px 14px; color: var(--muted); text-align: center; font-size: 13px; }
.empty.warn { color: var(--warn); }
.section-label { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); padding: 12px 12px 4px; }

/* ---- intelligence feed --------------------------------------------------- */
.chip { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 6px; font-size: 10px; text-transform: capitalize; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); margin-right: 6px; }
.intel-rel { font-size: 11px; margin-top: 4px; color: var(--warn); font-weight: 600; }
.intel-rel.here { color: var(--sos); }
/* Near our people but not affecting them (R6): grey, no warning sign, the reason as a chip. */
.intel-rel.context { color: var(--muted); font-weight: 400; }
.chip.reason { text-transform: none; margin: 0 0 0 4px; }
/* An official warning, and who must be credited for any item (Andy, 8 Oct 2026). */
.chip.official { text-transform: none; color: var(--warn); border-color: var(--warn); }
.intel-attrib { font-size: 10px; margin-top: 3px; color: var(--muted); }
.alert.context { border-left-color: var(--line); }
.alert.context .msg { color: var(--muted); }
.intel-affected.context { color: var(--muted); }
.intel-detail { display: grid; gap: 4px; }
.intel-detail-head { display: flex; gap: 6px; align-items: center; }
.intel-detail-meta { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.intel-detail-body { font-size: 13px; line-height: 1.55; white-space: pre-wrap; margin: 0 0 6px; }
.intel-affected { font-size: 12px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.btn-link { align-self: center; margin-right: auto; color: var(--accent); text-decoration: none; font-size: 13px; }
.btn-link:hover { text-decoration: underline; }

/* ---- usage (header menu) ----------------------------------------------- */
.usage { font-size: 12px; color: var(--muted); min-width: 220px; }
.usage .bar { height: 4px; background: var(--panel-3); border-radius: 3px; overflow: hidden; margin: 4px 0 8px; }
.usage .bar i { display: block; height: 100%; background: var(--ok); }
.usage .bar i.warn { background: var(--warn); }
.usage .bar i.crit { background: var(--crit); }
.usage .line { display: flex; justify-content: space-between; }

/* ---- dialogs ------------------------------------------------------------ */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 0; width: min(520px, 92vw); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { padding: 18px 20px; display: grid; gap: 12px; }
dialog h3 { margin: 0 0 4px; font-size: 15px; }
dialog label { display: grid; gap: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
dialog label input, dialog label select { text-transform: none; letter-spacing: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast {
  position: fixed; z-index: 50; bottom: 18px; right: 18px; background: var(--panel-2);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 10px 14px; max-width: 340px; display: none; box-shadow: var(--shadow);
}
.toast.show { display: block; }
.toast.critical { border-left-color: var(--sos); }
.toast.warning, .toast.warn { border-left-color: var(--warn); }

/* ---- sign-in ------------------------------------------------------------ */
.signin {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #16202b 0%, var(--bg) 60%);
}
.signin[hidden] { display: none; }
.signin-card {
  width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 26px; display: grid; gap: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.signin-mark { width: 44px; height: 44px; justify-self: center; }
.signin-card h1 { margin: 0; font-size: 22px; text-align: center; letter-spacing: .3px; }
.signin-sub { margin: -8px 0 6px; text-align: center; color: var(--muted); font-size: 13px; }
.ms-button {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #2f2f2f; color: #fff; border: 1px solid #3c3c3c; border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; font-weight: 600; text-decoration: none;
}
.ms-button:hover { border-color: var(--accent); }
.signin-note { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.signin-error { margin: 0; min-height: 18px; color: var(--crit); font-size: 12px; text-align: center; }

/* ---- enrolment dialog ---------------------------------------------------- */
/* One column that never grows to fit its longest line: a long link or code
 * wraps inside the dialog rather than pushing its contents off the left edge. */
.enrol-body { padding: 18px 20px; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.enrol-body h3 { margin: 0; font-size: 15px; }
.enrol-sub { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.enrol-body label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-top: 6px; }
.enrol-row { display: flex; gap: 8px; align-items: center; }
.enrol-row code {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  overflow-x: auto; white-space: nowrap;
}
.enrol-row code.enrol-code { font-size: 20px; letter-spacing: 2px; color: var(--accent); text-align: center; }
.fine { margin: 0; font-size: 12px; color: var(--muted); }
#copyInvite { margin-top: 10px; }

/* Inline "Remove" beside a device: quiet, must not compete with the list. */
.link-danger { height: auto; background: none; border: 0; padding: 0 0 0 10px; font-size: 11px; color: var(--muted); opacity: .65; }
.link-danger:hover { color: var(--sos); opacity: 1; }

/* ---- duress code word ------------------------------------------------------ */
.codeword { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 8px 10px; }
.codeword .cw-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.codeword .cw-value { font-size: 15px; font-weight: 700; letter-spacing: .3px; color: var(--gold); flex: 1; }
.codeword .link-btn { flex: 0 0 auto; }

/* ---- movement track -------------------------------------------------------- */
/* Drawn on the light map, so its marks and legend are light-surface too. */
.fix-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 .5px rgba(0,0,0,.4); }
.fix-dot.hollow { background: transparent; border: 1.5px dashed #8a8f98; box-shadow: none; }
.stop-ring { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #5b6472; background: rgba(255,255,255,.85); }
.trip-label {
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1; white-space: nowrap;
  padding: 4px 7px; border-radius: 10px; border: 1.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45);
  transform: translateY(-14px);
}
.track-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 6; width: min(360px, calc(100% - 24px)); max-height: 45%;
  display: flex; flex-direction: column; background: #fff; color: #1f2733; border-radius: 10px;
  box-shadow: 0 6px 22px rgba(0,0,0,.35); font-size: 12px;
}
.track-legend[hidden] { display: none; }
.track-legend .leg-head { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px 2px; }
.track-legend .leg-head .link-btn { margin-left: auto; color: #1f5fbf; }
.track-legend .leg-sub { padding: 0 12px 8px; color: #52514e; }
.track-legend .leg-list { overflow-y: auto; border-top: 1px solid #e3e6ea; padding: 4px 0; }
.track-legend .leg-row {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; width: 100%; height: auto;
  padding: 6px 12px; background: none; border: 0; border-radius: 0; color: inherit; font-size: 12px; text-align: left;
}
.track-legend button.leg-row { cursor: pointer; }
.track-legend button.leg-row:hover { background: #f1f3f6; }
.track-legend .leg-row i { width: 14px; height: 4px; border-radius: 2px; }
.track-legend .leg-row i.ring { width: 10px; height: 10px; border-radius: 50%; border: 2.5px solid #5b6472; background: #fff; }
.track-legend .dim { color: #52514e; white-space: nowrap; }
.track-legend .dim.warn { color: #9a5b00; font-weight: 600; }

/* The location engine's own log, folded under the phone diagnostics. */
.sdklog { margin-top: 8px; }
.sdklog summary { font-size: 11px; color: var(--muted); cursor: pointer; }
.sdklog pre { margin: 6px 0 0; max-height: 260px; overflow: auto; font-size: 10px; line-height: 1.35; color: var(--muted); background: var(--panel-2); padding: 8px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- messages ------------------------------------------------------------ */
/* The thread with a phone: theirs on the left, ours on the right, the automatic
   receipt as a quiet line between. Same 8 px grid and 13 px type as the rest. */
.row .name .unread {
  display: inline-block; margin-left: 6px; min-width: 16px; height: 16px; padding: 0 5px; border-radius: 8px;
  background: var(--accent); color: #04121f; font-size: 10px; font-weight: 700; font-style: normal;
  line-height: 16px; text-align: center; vertical-align: 1px;
}
.thread { display: grid; gap: 6px; max-height: 300px; overflow-y: auto; padding: 4px 2px; }
.thread .empty { padding: 14px 8px; }
.bubble { max-width: 90%; padding: 7px 10px; border-radius: 10px; font-size: 13px; line-height: 1.4; }
.bubble .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .meta { margin-top: 3px; font-size: 10px; color: var(--muted); }
.bubble.theirs { justify-self: start; background: var(--panel-3); border-bottom-left-radius: 3px; }
.bubble.ours { justify-self: end; background: rgba(103,167,255,.14); border: 1px solid rgba(103,167,255,.28); border-bottom-right-radius: 3px; }
.bubble.ours .meta { text-align: right; }
.bubble.receipt { justify-self: center; max-width: 100%; background: none; border: 0; padding: 2px 0; color: var(--muted); font-size: 11px; text-align: center; }
.bubble.receipt .body { font-style: italic; }
.bubble.receipt .meta { display: inline; margin-left: 6px; }
.composer { display: flex; gap: 6px; margin-top: 4px; }
.composer input { flex: 1; min-width: 0; }

/* ---- narrower desktops --------------------------------------------------- */
@media (max-width: 1180px) { :root { --left-w: 300px; --right-w: 300px; } }

/* ---- phone layout -------------------------------------------------------- */
/* One pane at a time with a tab bar. The map is never destroyed when
   switching panes — a second Google map instantiation would be a second
   billable map load. */
.tabbar { display: none; }

@media (max-width: 820px) {
  :root { --header-h: 50px; }
  .app { grid-template-rows: var(--header-h) 1fr auto; }
  .main { grid-template-columns: 1fr; position: relative; }
  .col.left, .col.center, .col.right { grid-column: 1; grid-row: 1; border: 0; min-width: 0; width: 100%; }
  .app[data-left="closed"] .col.left, .app[data-right="closed"] .col.right { display: flex; }
  .app[data-view="map"]    .col.left,
  .app[data-view="map"]    .col.right,
  .app[data-view="roster"] .col.center,
  .app[data-view="roster"] .col.right,
  .app[data-view="alerts"] .col.center,
  .app[data-view="alerts"] .col.left { display: none; }
  .app[data-view="map"] .col.center { display: flex; }
  .edge { display: none; }

  header.top { padding: 0 10px; gap: 10px; }
  .brand .word { font-size: 13px; }
  .brand small, .whoami { display: none; }
  .kpi { min-width: 60px; padding: 0 8px; }
  .kpi b { font-size: 14px; }
  .kpi span { font-size: 9px; letter-spacing: .2px; }

  .row { height: 60px; }
  .alert { padding: 13px 12px; }
  button, .tab { min-height: 38px; }
  .map-tools { top: 8px; left: 8px; right: 8px; flex-wrap: wrap; }
  .map-notices { top: 56px; max-width: calc(100% - 16px); }
  .map-tools button { font-size: 12px; padding: 0 9px; }
  .facts { grid-template-columns: 1fr 1fr; }

  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--panel); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button {
    height: auto; background: none; border: 0; border-radius: 0; color: var(--muted);
    display: grid; justify-items: center; gap: 2px; padding: 8px 4px 6px;
    font-size: 10px; letter-spacing: .3px; position: relative;
  }
  .tabbar button .ico { font-size: 17px; line-height: 1; }
  .tabbar button.active { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
  .tabbar .badge {
    position: absolute; top: 5px; right: 50%; margin-right: -22px;
    min-width: 16px; height: 16px; border-radius: 8px; background: var(--crit);
    color: #fff; font-size: 10px; font-style: normal; line-height: 16px; padding: 0 4px;
  }
}

@media (max-width: 420px) {
  .kpi.secondary { display: none; }
}

/* ==== Client portal theme (Braeburn) ====================================
 * The same console served to an external client under /client wears The
 * Braeburn Group's brand — gold accent over Braeburn navy, Cormorant/Montserrat
 * — rather than the BRIAR-matched operator palette. It is applied by a single
 * body.portal class set at boot, over the CSS custom properties, plus a couple
 * of rules that hide the operator-only controls (device enrolment, Maps usage).
 */
body.portal {
  --bg: #0d1624;
  --panel: #131f30;
  --panel-2: #0f1a29;
  --panel-3: #1a2942;
  --line: #2a3a53;
  --line-soft: #18243a;
  --text: #f0ece4;
  --muted: #a09880;
  --faint: #6f6a5c;
  --accent: #c9a84c;   /* gold replaces the BRIAR blue as the primary accent */
  --gold: #c9a84c;
  font-family: Montserrat, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
body.portal button.primary { color: #16110a; }   /* dark label on gold */
body.portal .brand .word {
  font-family: "Cormorant Garamond", Georgia, serif; font-weight: 300;
  font-size: 18px; letter-spacing: .3px;
}
/* Operator-only controls, hidden for clients (also gated server-side). */
body.portal #drawerEnrol,
body.portal #importTrips,
body.portal #requestPlan,
body.portal #usageSection,
body.portal #keepAwakeSection { display: none !important; }

/* ==== Client access dialog (operator-only) ====================================
 * Add a client, add a user to it (one-time invite link), and the three account
 * actions the admin routes support. The menu item is hidden in portal mode and
 * the routes themselves reject a client principal.
 */
#clientsDialog { width: min(600px, 94vw); }
.clients-forms { display: grid; gap: 8px; }
.inline-form { padding: 0; display: flex; gap: 6px; align-items: center; }
.inline-form input, .inline-form select { flex: 1; min-width: 0; }
.clients-list { display: grid; gap: 10px; max-height: 42vh; overflow: auto; }
.client-block { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 8px 10px; display: grid; gap: 6px; }
.client-name { font-size: 13px; }
/* A zone's details on the map (Google's info window is white: dark text here). */
.zone-info { color: #1b2533; font: 13px/1.4 system-ui, sans-serif; min-width: 200px; }
.zone-info b { font-size: 14px; }
.zone-info .zi-meta, .zone-info .zi-inside { color: #4d5b6d; margin-top: 2px; }
.zone-info .zi-off { color: #b26a00; }
.zone-info .zi-actions { display: flex; gap: 8px; margin-top: 10px; }
.zone-info button { height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid #c8d0da; background: #f4f6f9; color: #1b2533; cursor: pointer; }
.zone-info button.zi-danger { border-color: #e2a3a3; background: #fdf0f0; color: #b3261e; }

/* ---- weather warnings (Andy, 9 Oct 2026) ----------------------------------
   A symbol per warning, coloured by its CAP severity (public/weather-icons.js),
   the count of any it stands for; the details in an info window on the light
   map, like a zone's. */
.wx-marker { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; filter: drop-shadow(0 2px 4px rgba(0,0,0,.55)); transition: transform .15s; }
.wx-marker:hover { transform: scale(1.12); }
/* The marker element around it takes keyboard focus. */
:focus-visible > .wx-marker { transform: scale(1.12); filter: drop-shadow(0 0 3px #67a7ff) drop-shadow(0 0 2px #fff); }
.wx-marker svg { display: block; }
.wx-count { position: absolute; top: -5px; right: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: #101b2a; color: #fff; border: 1.5px solid #fff; font: 700 10px/15px system-ui, sans-serif; text-align: center; }
.wx-info { color: #1b2533; font: 13px/1.4 system-ui, sans-serif; max-width: 320px; display: grid; gap: 5px; }
.wx-head b { font-size: 14px; }
.wx-head { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; }
.wx-event, .wx-meta, .wx-muted { color: #4d5b6d; }
.wx-event { font-size: 12px; margin-top: 1px; }
.wx-chip { display: inline-block; padding: 0 7px; border-radius: 999px; border: 1.5px solid var(--wx); color: #1b2533; font-weight: 600; font-size: 12px;
  background: color-mix(in srgb, var(--wx) 22%, #fff); }
.wx-estimate-note { font-weight: 600; color: #8a4b00; border: 1.5px dashed #c77700; border-radius: 6px; padding: 2px 7px; justify-self: start; }
.wx-when { font-variant-numeric: tabular-nums; }
.wx-area { font-size: 12px; }
.wx-instr { font-size: 12px; background: #f4f6f9; border-radius: 6px; padding: 5px 7px; max-height: 9em; overflow: auto; }
.wx-aff { font-size: 12px; }
.wx-link { color: #1f5fbf; font-weight: 600; }
.wx-attrib { font-size: 11px; color: #4d5b6d; border-top: 1px solid #e3e7ec; padding-top: 4px; }
.wx-cluster { gap: 2px; }
.wx-row { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: center; text-align: left; width: 100%; min-height: 30px;
  padding: 3px 4px; border: 0; border-radius: 6px; background: transparent; color: #1b2533; font: 13px/1.3 system-ui, sans-serif; cursor: pointer; }
.wx-row:hover, .wx-row:focus-visible { background: #eef2f7; outline: none; }
.wx-legend { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 0 10px 6px 32px; font-size: 11px; color: var(--muted); max-width: 260px; }
.wx-legend:empty { display: none; }
.wx-legend .wx-muted { color: var(--muted); flex-basis: 100%; }
.wx-swatch { display: inline-flex; align-items: center; gap: 4px; }
.wx-swatch::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--wx); border: 1px solid rgba(255,255,255,.7); }
.wx-swatch.estimate::before { background: transparent; border: 1.5px dashed var(--muted); }
.client-travellers { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.client-travellers .assigned { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px 1px 8px; border: 1px solid var(--line); border-radius: 999px; }
.client-travellers select { font-size: 12px; max-width: 100%; }
.row .sub .client-tag { color: var(--gold); }
.seg.client-user .status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body.portal #clientsBtn,
body.portal #oncallBtn { display: none !important; }

/* ==== Itinerary editor ===================================================== */
.trip-actions { display: flex; gap: 12px; margin-top: 4px; }
#tripDialog { width: min(900px, 96vw); }
.trip-segments { display: grid; gap: 8px; max-height: 38vh; overflow: auto; padding-right: 2px; }
.trip-seg { display: grid; grid-template-columns: 96px 1fr 84px 84px auto; gap: 6px; align-items: center;
  padding: 8px; border: 1px solid var(--line-soft); border-radius: var(--radius); }
.trip-seg input, .trip-seg select { min-width: 0; width: 100%; }
.trip-seg .span3 { grid-column: 3 / -1; }
/* A stop is two lines: its kind, reference and places; then when it leaves and
 * arrives, and a note. The first two columns are wide enough for a date AND a
 * time (a datetime box narrower than that hides the time, so it cannot be
 * edited), and the places share what is left. */
.trip-seg { grid-template-columns: minmax(190px, 210px) minmax(190px, 210px) 1fr 1fr auto; }
@media (max-width: 760px) {
  /* On a phone: kind and reference, then the places, then leaves and arrives, the note, and "remove" last. */
  .trip-seg { grid-template-columns: 1fr 1fr; }
  .trip-seg .span3 { grid-column: 1 / -1; }
  .trip-seg [data-seg-remove] { order: 9; grid-column: 1 / -1; justify-self: end; }
}

/* Fit fixes. The panel title yields to its buttons (truncates) instead of
 * wrapping and pushing them out of a 340px column; in the client-access dialog
 * a long one-time link wraps and the per-user action row shares width with
 * the email, so neither can widen the dialog past the viewport. */
.col-head h2 { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#clientsDialog .enrol-row code, #planDialog .enrol-row code { min-width: 0; white-space: normal; word-break: break-all; }
#planDialog { width: min(600px, 94vw); }
.seg.client-user { grid-template-columns: 62px minmax(0, 1fr) minmax(0, 1fr); }
.seg.client-user .status { white-space: normal; justify-content: flex-end; }

/* ==== Phone setup warnings ================================================
 * A phone that cannot track in the background or be woken (location not
 * "Always", location services off, notifications off) is flagged in the roster
 * and explained, with the fix, at the top of the traveller's detail. */
.row .name .setup-flag { font-style: normal; color: var(--warn); margin-left: 6px; font-size: 12px; cursor: help; }
.setup-warn { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--warn); border-left-width: 3px;
  border-radius: var(--radius); background: rgba(247, 185, 85, 0.08); font-size: 12px; }
.setup-warn b { color: var(--warn); }
.setup-warn ul { margin: 6px 0 4px; padding-left: 16px; }
.setup-warn li { margin: 4px 0; }
.setup-warn .fix { display: block; color: var(--muted); margin-top: 2px; }

/* ==== Paused sharing =======================================================
 * The traveller's own pause (made in the app, only they can lift it) and the
 * organisation's "Stop monitoring" both switch off location, loss of contact
 * and missed check-ins (Q5). The roster gives a paused traveller a line of its
 * own, lavender when the traveller paused; the detail opens with the same
 * words. An organisation's stop is quieter: someone in the room chose it. */
.row.pause-traveller, .row.pause-org { height: auto; min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
.row .pause-line { margin-top: 3px; font-size: 11px; line-height: 1.35; color: var(--muted); white-space: normal; overflow-wrap: anywhere; }
.row.pause-traveller .pause-line { color: var(--paused); font-weight: 600; }
.dot.pause-traveller { background: var(--paused); }
.dot.pause-org { background: #4a5766; }
.pill.pause-traveller { color: var(--paused); border-color: var(--paused); }
.pill.pause-org { color: var(--muted); border-color: var(--muted); }
.fact b.paused { color: var(--paused); }
.pause-banner { display: grid; gap: 4px; padding: 10px 12px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius); background: var(--panel-2); overflow-wrap: anywhere; }
.pause-banner b { font-size: 13px; color: var(--text); }
.pause-banner.pause-traveller { border-color: var(--paused); background: rgba(185, 164, 255, 0.08); }
.pause-banner.pause-traveller b { color: var(--paused); }
/* The detail menu's Resume, disabled with the reason when the traveller paused. */
.menu-item.with-note { height: auto; min-height: var(--control); padding: 6px 12px; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.menu-item.with-note:disabled { opacity: .75; }
.menu-note { display: block; max-width: 240px; font-size: 11px; color: var(--muted); white-space: normal; }
/* The record of pauses, resumes and consent, newest first. */
.hist { display: grid; gap: 8px; }
.hist-row { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 2px 8px; font-size: 12px; }
.hist-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-what { overflow-wrap: anywhere; }
.hist-more { grid-column: 2; color: var(--muted); overflow-wrap: anywhere; }

/* ==== In an emergency ======================================================
 * Who to call if something happens to a traveller: their contacts (one to
 * call first, any of them next of kin), their client's assistance providers
 * and Braeburn's defaults, and the Ops Room once its number is entered. Open
 * by default, forced open with a red edge during an SOS. The roster flags a
 * traveller with nobody on file ("no NOK"), in the manner of the setup ⚠. */
.row .name .nok-flag { margin-left: 6px; padding: 0 5px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 10px; font-weight: 500; color: var(--muted); cursor: help; vertical-align: 1px; }
details.section.emergency.sos { border-color: var(--sos); box-shadow: inset 3px 0 0 var(--sos); }
details.section.emergency.missing summary .count { color: var(--warn); }
.ec-block { display: grid; gap: 6px; }
.ec-block + .ec-block { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.ec-title { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.ec-row { display: grid; gap: 2px; padding: 7px 10px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 6px; font-size: 12px; min-width: 0; }
.ec-row.ops-room { border-color: var(--gold); }
.ec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.ec-head b { font-size: 13px; overflow-wrap: anywhere; }
.ec-kind { color: var(--muted); overflow-wrap: anywhere; }
.ec-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line); }
.ec-tag.first { color: var(--ok); border-color: var(--ok); }
.ec-tag.nok { color: var(--gold); border-color: var(--gold); }
.ec-src { margin-left: auto; font-size: 10px; color: var(--faint); }
.ec-src.client { color: var(--gold); }
.ec-reach { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; overflow-wrap: anywhere; }
.ec-reach a { color: var(--accent); text-decoration: none; }
.ec-reach a.tel { font-weight: 600; font-variant-numeric: tabular-nums; padding: 2px 0; }
.ec-reach a:hover { text-decoration: underline; }
.ec-note { color: var(--muted); overflow-wrap: anywhere; white-space: pre-line; }
.ec-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.ec-foot span { min-width: 0; overflow-wrap: anywhere; }
.ec-foot .link-btn { flex: 0 0 auto; }
.ec-missing { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; font-size: 12px;
  color: var(--warn); border: 1px solid var(--warn); border-radius: 6px; background: rgba(247, 185, 85, 0.06); }
.ec-missing button { flex: 0 0 auto; }
.ec-none { font-size: 12px; color: var(--muted); }

/* The contacts and assistance dialogs: fieldsets in the travellerDialog's grid. */
#contactsDialog, #assistanceDialog { width: min(640px, 94vw); max-height: 92vh; overflow: auto; }
.contact-blocks, .provider-rows { display: grid; gap: 10px; }
.contact-block, .provider-row { margin: 0; padding: 6px 12px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius); min-width: 0; }
.contact-block legend, .provider-row legend { display: flex; align-items: center; gap: 10px; padding: 0 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.contact-block legend .link-btn, .provider-row legend .link-btn { text-transform: none; letter-spacing: 0; font-size: 11px; }
dialog .form-grid label.check { display: flex; align-items: center; gap: 6px; font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--text); }
dialog .form-grid label.check input { margin: 0; width: auto; height: auto; }
.health-note { color: var(--warn); }
@media (max-width: 560px) {
  #contactsDialog .form-grid, #assistanceDialog .form-grid { grid-template-columns: 1fr; }
}
/* The portal's own assistance providers: a top-menu item operators do not need. */
body:not(.portal) .portal-only { display: none !important; }

/* SOS escalation: the line on an SOS card, the drawer timeline, the rota. */
.alert .esc-line { margin-top: 4px; font-size: 12px; color: var(--crit); }
.alert .esc-line.stopped { color: var(--muted); }
.esc-head { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.esc-head b { color: var(--text); }
.esc-step .status.simulated { font-style: italic; color: var(--muted); }
.esc-step .status.failed { color: var(--crit); }
.esc-step .status.skipped { color: var(--warn); }
.oncall-list { max-height: 30vh; }
.seg.oncall-row { grid-template-columns: 62px minmax(0, 1fr) auto; }
.seg.oncall-row > span:nth-child(2) { white-space: normal; overflow-wrap: anywhere; }
.oncall-row.off { opacity: .55; }
.oncall-row .status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; white-space: normal; max-width: 220px; }
.oncall-row select { height: 24px; font-size: 12px; width: auto; flex: 0 0 auto; }
.oncall-row label, .oncall-channels label {
  display: inline-flex; gap: 4px; align-items: center; margin: 0;
  font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--text);
}
.oncall-row input[type="checkbox"], .oncall-channels input[type="checkbox"] { width: auto; height: auto; padding: 0; margin: 0; flex: none; }
.oncall-warn { font-size: 12px; color: var(--warn); border-left: 3px solid var(--warn); padding: 2px 8px; margin: 4px 0; }
.oncall-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 0 0; border-top: 1px solid var(--line-soft); margin-top: 8px; }
.oncall-form input, .oncall-form select { flex: 1 1 180px; min-width: 0; }
.oncall-form-title { flex-basis: 100%; }
.oncall-channels { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.oncall-form-actions { display: flex; gap: 6px; margin-left: auto; }
.oncall-changes { margin-top: 8px; font-size: 12px; }

/* Roll calls: "Are you safe?" (console.js#renderWelfare) */
.tab .badge { display: inline-block; min-width: 16px; height: 16px; margin-left: 6px; border-radius: 8px; background: var(--crit);
  color: #fff; font-size: 10px; font-style: normal; line-height: 16px; padding: 0 4px; vertical-align: 1px; }
.welfare-card { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); border-left: 3px solid var(--accent); }
.welfare-card.closed { border-left-color: var(--idle); opacity: .8; }
.welfare-card.alarm { border-left-color: var(--crit); }
.welfare-card .title { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.welfare-card .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.welfare-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.welfare-counts span { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.welfare-counts .safe b { color: var(--ok); }
.welfare-counts .help b { color: var(--crit); }
.welfare-counts .silent b { color: var(--warn); }
.welfare-people { margin-top: 6px; }
.welfare-person { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 12px; }
.welfare-person .who { font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.welfare-person .why { grid-column: 1 / -1; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.welfare-person .state { text-align: right; white-space: nowrap; }
.welfare-person .state.safe { color: var(--ok); }
.welfare-person .state.need_help { color: var(--crit); font-weight: 600; }
.welfare-person .state.silent { color: var(--warn); }
.welfare-person .acts { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.welfare-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.pref-checks { display: flex; flex-direction: column; gap: 4px; margin: 2px 0 8px; }
.pref-checks label { display: flex; gap: 8px; align-items: center; margin: 0; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); }
.pref-checks input[type="checkbox"] { width: auto; height: auto; flex: none; margin: 0; }
#alertPrefsDialog textarea { width: 100%; font: inherit; font-size: 13px; }
dialog label.pref-inline { display: flex; gap: 8px; align-items: center; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
dialog label.pref-inline input { width: auto; height: auto; flex: none; margin: 0; }
