/* ReachNT. Layout: the satellite map is the canvas; liquid-glass panels float over it.
   Desktop: top bar, left work panel, right detail card, centred sheets for the trade-off.
   Phone: top bar, map in the top third, panels become bottom sheets. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Geist", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Geist Mono", Menlo, monospace;

  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-edge: rgba(255, 255, 255, 0.7);
  --glass-shadow: 0 18px 50px rgba(15, 20, 30, 0.22), 0 2px 8px rgba(15, 20, 30, 0.08);
  --sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 42%);
  --ink: #1d1d1f;
  --ink-2: #48484d;
  --ink-3: #6e6e73;
  --line: rgba(60, 60, 67, 0.16);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --accent: #0a7aff;
  --hex: #0e8fb8;
  --good: #1f9d4c;
  --warn: #d97706;
  --cut: #a16207;
  --bad: #e5352b;
  --violet: #6e56cf;
  --good-bg: rgba(52, 199, 89, 0.16);
  --warn-bg: rgba(255, 149, 0, 0.16);
  --cut-bg: rgba(255, 204, 0, 0.2);
  --bad-bg: rgba(255, 59, 48, 0.14);
  --accent-bg: rgba(0, 122, 255, 0.12);
  --hex-bg: rgba(50, 173, 230, 0.16);
  --page: #0d1418;
  --on-ink: #ffffff;            /* text on an --ink background */
  --scrim: rgba(10, 14, 18, 0.25);
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 11px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --glass: rgba(28, 30, 36, 0.58); --glass-strong: rgba(36, 38, 46, 0.82); --glass-edge: rgba(255, 255, 255, 0.16);
    --glass-shadow: 0 18px 60px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
    --sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 40%);
    --ink: #f5f5f7; --ink-2: rgba(235, 235, 245, 0.78); --ink-3: rgba(235, 235, 245, 0.56); --on-ink: #0d1418;
    --line: rgba(84, 84, 88, 0.55); --fill: rgba(118, 118, 128, 0.22); --fill-2: rgba(118, 118, 128, 0.32);
    --accent: #0a84ff; --hex: #64d2ff; --good: #30d158; --warn: #ff9f0a; --cut: #ffd60a; --bad: #ff453a; --violet: #a28cff;
    --good-bg: rgba(48, 209, 88, 0.18); --warn-bg: rgba(255, 159, 10, 0.2); --cut-bg: rgba(255, 214, 10, 0.18);
    --bad-bg: rgba(255, 69, 58, 0.2); --accent-bg: rgba(10, 132, 255, 0.22); --hex-bg: rgba(100, 210, 255, 0.18);
    --scrim: rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --glass: rgba(28, 30, 36, 0.58); --glass-strong: rgba(36, 38, 46, 0.82); --glass-edge: rgba(255, 255, 255, 0.16);
  --glass-shadow: 0 18px 60px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
  --sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 40%);
  --ink: #f5f5f7; --ink-2: rgba(235, 235, 245, 0.78); --ink-3: rgba(235, 235, 245, 0.56); --on-ink: #0d1418;
  --line: rgba(84, 84, 88, 0.55); --fill: rgba(118, 118, 128, 0.22); --fill-2: rgba(118, 118, 128, 0.32);
  --accent: #0a84ff; --hex: #64d2ff; --good: #30d158; --warn: #ff9f0a; --cut: #ffd60a; --bad: #ff453a; --violet: #a28cff;
  --good-bg: rgba(48, 209, 88, 0.18); --warn-bg: rgba(255, 159, 10, 0.2); --cut-bg: rgba(255, 214, 10, 0.18);
  --bad-bg: rgba(255, 69, 58, 0.2); --accent-bg: rgba(10, 132, 255, 0.22); --hex-bg: rgba(100, 210, 255, 0.18);
  --scrim: rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page); color: var(--ink); font: 15px/1.45 var(--font); letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.86em; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
p { margin: 0; }

/* ---------------------------------------------------------------- map */
#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 10.5px !important; background: var(--glass) !important; backdrop-filter: blur(12px); color: var(--ink-3) !important; border-radius: 10px 0 0 0; }
.maplibregl-ctrl-attrib a { color: var(--ink-2) !important; }
.maplibregl-ctrl-group { background: var(--glass) !important; backdrop-filter: blur(20px); border-radius: 14px !important; box-shadow: var(--glass-shadow) !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.maplibregl-ctrl-icon { filter: var(--icon-filter, none); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --icon-filter: invert(1); } }
:root[data-theme="dark"] { --icon-filter: invert(1); }

/* ---------------------------------------------------------------- glass */
.glass {
  position: relative; background: var(--glass); border: 1px solid var(--glass-edge); border-radius: var(--r-lg);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
}
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--sheen); pointer-events: none;
}
.glass > * { position: relative; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: fixed; z-index: 20; top: calc(env(safe-area-inset-top, 0px) + 14px); left: 14px; right: 14px;
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-radius: 22px; flex-wrap: nowrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { flex: none; }
.brand b { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand small { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.spacer { flex: 1; }
.seg {
  position: relative; display: inline-flex; padding: 3px; border-radius: 12px; background: var(--fill); gap: 0;
}
.seg button {
  position: relative; z-index: 1; border: 0; background: none; padding: 6px 14px; border-radius: 9px; font-size: 13.5px;
  font-weight: 600; color: var(--ink-2); transition: color 0.25s var(--spring); white-space: nowrap;
}
.seg button[aria-pressed="true"] { color: var(--ink); }
.seg .thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; border-radius: 9px; background: var(--glass-strong);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); transition: left 0.42s var(--spring), width 0.42s var(--spring);
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px;
  font-weight: 600; background: var(--fill); color: var(--ink-2); white-space: nowrap;
}
.pill.syn { background: rgba(110, 86, 207, 0.18); color: var(--violet); }
.pill select { appearance: none; border: 0; background: none; font-weight: 600; padding-right: 2px; max-width: 250px; text-overflow: ellipsis; }
.iconbtn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--fill); display: grid; place-items: center; }

/* ---------------------------------------------------------------- panels */
.panel {
  position: fixed; z-index: 10; display: flex; flex-direction: column; overflow: hidden;
  transition: transform 0.55s var(--spring), opacity 0.4s ease;
}
.panel.hide { opacity: 0; pointer-events: none; transform: translateY(16px) scale(0.985); }
.panel-head { padding: 16px 12px 10px; display: flex; flex-direction: column; gap: 10px; }
.panel-body { overflow-y: auto; padding: 4px 12px 16px; flex: 1; overscroll-behavior: contain; scrollbar-width: thin; }
.left { top: 86px; left: 14px; bottom: 14px; width: 420px; }
.right { top: 86px; right: 14px; width: 380px; max-height: calc(100% - 100px); }
.phone { top: 86px; right: 14px; width: 400px; bottom: 14px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; padding: 6px 9px; border-radius: 10px; font-weight: 600; font-size: 13.5px; color: var(--ink-3); flex: none;
  white-space: nowrap; transition: background 0.25s, color 0.25s;
}
.tabs button[aria-selected="true"] { background: var(--fill-2); color: var(--ink); }

.decision { margin: 0 6px 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--fill); font-size: 13.5px; }
.decision.unsigned { background: var(--warn-bg); }
.decision b { display: block; font-size: 14px; margin-bottom: 2px; }
.decision p { color: var(--ink-2); }
.eyebrow { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 6px 12px; }
.stat { padding: 10px 12px; border-radius: 14px; background: var(--fill); min-width: 0; }
.stat b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); line-height: 1.3; display: block; }

.row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; width: 100%;
  border: 0; background: none; text-align: left; padding: 10px; border-radius: 14px; transition: background 0.2s;
  animation: rise 0.5s var(--spring) both;
}
.row:hover { background: var(--fill); }
.row[aria-current="true"] { background: var(--accent-bg); }
.row .t { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { grid-column: 2; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chip, .row .chips { grid-row: span 2; }
.row .chips { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.dot { width: 10px; height: 10px; border-radius: 50%; grid-row: span 2; }
.dot.immediate { background: var(--bad); } .dot.urgent { background: var(--warn); } .dot.routine { background: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.booked { background: var(--good-bg); color: var(--good); }
.chip.travel_cost { background: var(--warn-bg); color: var(--warn); }
.chip.crew_full { background: var(--accent-bg); color: var(--accent); }
.chip.cut { background: var(--cut-bg); color: var(--cut); }
.chip.lower_priority { background: var(--fill-2); color: var(--ink-2); }
.chip.immediate { background: var(--bad-bg); color: var(--bad); }
.chip.urgent { background: var(--warn-bg); color: var(--warn); }
.chip.routine { background: var(--accent-bg); color: var(--accent); }
.chip.hex { background: var(--hex-bg); color: var(--hex); }
.chip.person { background: rgba(110, 86, 207, 0.18); color: var(--violet); }
.chip.no_access, .chip.parts, .chip.unsafe, .chip.needs_other_trade { background: var(--cut-bg); color: var(--cut); }
.chip.new { background: var(--accent-bg); color: var(--accent); }
.chip.offered { background: rgba(110, 86, 207, 0.18); color: var(--violet); }
.chip.assigned, .chip.next_trip { background: var(--good-bg); color: var(--good); }
.chip.due { background: var(--warn-bg); color: var(--warn); }
.chip.rework { background: var(--cut-bg); color: var(--cut); }
.hexb.evt .hx { filter: drop-shadow(0 0 3px #ff453a) drop-shadow(0 0 7px #ff453a); }
details#evbox summary { list-style: revert; }
#officer .app-head select.pill { min-width: 0; }
.chip.due.late { background: var(--bad-bg); color: var(--bad); }
/* forms: new report, urgency check, who goes */
.form { display: grid; gap: 10px; }
.form[hidden] { display: none; }
.form .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.form select, .form input[type="number"] { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; background: var(--glass-strong); min-width: 0; }
.form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; min-width: 0; }
.qa { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; font-size: 13.5px; }
.yn { display: inline-flex; gap: 2px; background: var(--fill); border-radius: 10px; padding: 2px; }
.yn label { position: relative; }
.yn input { position: absolute; opacity: 0; inset: 0; }
.yn span { display: block; padding: 5px 9px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.yn input:checked + span { background: var(--glass-strong); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.yn input:focus-visible + span { outline: 2px solid var(--accent); }
.src-tag { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.panel-sec { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.hist-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.hist-list li { padding: 8px 10px; border-radius: 12px; background: var(--fill); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.job .worse { width: 100%; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { border: 0; padding: 5px 11px; border-radius: 999px; background: var(--fill); color: var(--ink-2); font-size: 13px; font-weight: 600; }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* detail card */
.detail { padding: 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.detail h2 { font-size: 21px; }
.quote { font-size: 15px; color: var(--ink-2); padding: 10px 14px; border-radius: 14px; background: var(--fill); }
.bars { display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--fill); }
.bars span { height: 100%; transform-origin: left; animation: grow 0.9s var(--spring) both; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-3); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.say p + p { margin-top: 8px; }
.say b { font-weight: 600; }
.closebtn { position: absolute; top: 12px; right: 12px; z-index: 2; }

/* map legend + layer chips */
.mapchips { position: fixed; z-index: 9; left: calc(448px + (100% - 448px) / 2); transform: translateX(-50%); bottom: 18px; display: flex; gap: 8px; flex-wrap: wrap; padding: 6px; border-radius: 18px; }
.mapchips button { border: 0; background: none; padding: 6px 11px; border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.mapchips button[aria-pressed="true"] { background: var(--glass-strong); color: var(--ink); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
.maplegend { position: fixed; z-index: 9; right: 14px; top: 86px; padding: 10px 12px; border-radius: 16px; font-size: 12px; color: var(--ink-2); display: grid; gap: 4px; }
.maplegend i { display: inline-block; width: 11px; height: 11px; margin-right: 7px; vertical-align: -1px; clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); }

/* markers */
.mk { padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink); background: var(--glass-strong);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--glass-edge); white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); transform: translateY(-18px); cursor: pointer; transition: transform 0.3s var(--spring); }
.mk:hover { transform: translateY(-20px) scale(1.04); }
.mk small { color: var(--ink-3); font-weight: 500; margin-left: 4px; }
.mk.hub { background: var(--ink); color: var(--on-ink); border-color: transparent; }

/* sheets (trade-off, about) */
.sheet { position: fixed; z-index: 30; left: 50%; top: calc(50% + 30px); width: min(1080px, calc(100% - 28px)); max-height: calc(100% - 130px);
  transform: translate(-50%, -48%) scale(0.98); opacity: 0; pointer-events: none; transition: transform 0.55s var(--spring), opacity 0.35s;
  display: flex; flex-direction: column; overflow: hidden; }
.sheet.open { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
.scrim { position: fixed; inset: 0; z-index: 25; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity 0.35s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet .body { overflow-y: auto; padding: 4px 22px 22px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; }
.sheet-head { padding: 20px 22px 8px; display: flex; align-items: flex-start; gap: 12px; }
.sheet-head h2 { font-size: 24px; }
.card { background: var(--fill); border-radius: 18px; padding: 14px; min-width: 0; }
.pols { display: grid; gap: 8px; }
.pol { text-align: left; border: 1px solid transparent; background: var(--fill); border-radius: 16px; padding: 12px 14px; display: grid; gap: 2px; transition: border-color 0.25s, background 0.25s; }
.pol[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-bg); }
.pol .n { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.pol .m { font-size: 12.5px; color: var(--ink-3); }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); display: block; margin-bottom: 4px; }
input[type="text"], textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; background: var(--glass-strong); }
textarea { min-height: 84px; resize: vertical; }
.btn { border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; background: var(--fill-2); color: var(--ink); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.good { background: var(--good); color: #fff; }
.btn.ghost { background: var(--fill); }
.note { font-size: 12.5px; color: var(--ink-3); }
svg text { fill: var(--ink-3); font-family: var(--font); }

/* ---------------------------------------------------------------- phone apps (field, tenant) */
.app-head { padding: 18px 18px 8px; display: grid; gap: 12px; }
.who { display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--hex-bg); color: var(--hex); flex: none; }
.who h2 { font-size: 20px; }
.who p { color: var(--ink-3); font-size: 13px; }
.trip-card { padding: 14px; border-radius: 18px; background: var(--fill); display: grid; gap: 6px; margin-bottom: 10px; animation: rise 0.5s var(--spring) both; }
.trip-card h3 { font-size: 16px; }
.job { padding: 14px; border-radius: 18px; background: var(--glass-strong); border: 1px solid var(--line); display: grid; gap: 8px; margin-bottom: 10px; animation: rise 0.5s var(--spring) both; }
.job h4 { font-size: 15.5px; }
.job .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--ink-3); }
.job .acts { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.job .acts .btn { padding: 11px 10px; }
.job.done { opacity: 0.6; }
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.reasons[hidden] { display: none; }
.reasons button { border: 0; border-radius: 12px; padding: 9px; background: var(--fill); font-size: 13px; font-weight: 600; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 4px 8px; }
.section-title h3 { font-size: 15px; }
.offline { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--good); }
.offline i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }

.track { display: grid; gap: 0; margin: 6px 4px 4px; }
.step { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding-bottom: 14px; position: relative; animation: rise 0.5s var(--spring) both; }
.step::before { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.step .node { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--fill-2); }
.step.ok .node { background: var(--good); color: #fff; }
.step.wait .node { background: var(--warn); color: #fff; }
.step.now .node { background: var(--accent); color: #fff; box-shadow: 0 0 0 5px var(--accent-bg); }
.step b { font-size: 14.5px; }
.step p { font-size: 13.5px; color: var(--ink-2); }
.sms { align-self: flex-start; max-width: 92%; background: var(--good); color: #fff; padding: 10px 14px; border-radius: 20px 20px 20px 6px; font-size: 15px; }
.big p { font-size: 16.5px; line-height: 1.5; }
.big h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); margin: 16px 0 4px; }

.toast { position: fixed; z-index: 40; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; padding: 10px 16px; border-radius: 14px;
  font-weight: 600; font-size: 14px; transition: transform 0.45s var(--spring), opacity 0.3s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------------------------------------------------------------- phone layout */
@media (max-width: 1240px) and (min-width: 861px) {
  #planbtn { max-width: 220px; }
}

.show-sm { display: none; }
.sm-only { display: none; }
.tabs .sm { display: none; }
.grabber { display: none; width: 38px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 8px auto 0; }
@media (max-width: 860px) {
  body { font-size: 15.5px; }
  /* top bar: brand, week-and-plan button, demo badge, info; then who is using it, full width */
  .topbar { left: 8px; right: 8px; top: calc(env(safe-area-inset-top, 0px) + 8px); gap: 8px; padding: 8px 8px 8px 12px; flex-wrap: wrap; border-radius: 20px; }
  .brand { flex: none; }
  .brand b { font-size: 16px; }
  .brand small, .hide-sm, .topbar > .planpick, .topbar > #week, .topbar .spacer { display: none; }
  .show-sm { display: inline-flex; }
  .sm-only { display: inline; } .lg-only { display: none; }
  #ctxbtn { flex: 1; min-width: 0; justify-content: space-between; overflow: hidden; background: var(--fill-2); color: var(--ink); }
  #ctxtext { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
  .pill.syn { padding: 6px 10px; }
  .topbar #role { order: 3; width: 100%; }
  .topbar #role button { flex: 1; padding: 8px 6px; }

  /* the map fills the screen; layer buttons and the key sit just under the top bar */
  .mapchips { left: 8px; right: auto; transform: none; top: calc(var(--top-h, 112px) + 8px); bottom: auto; gap: 2px; padding: 3px; border-radius: 14px; flex-wrap: nowrap; }
  .mapchips button { padding: 6px 10px; font-size: 13px; }
  .keybtn { position: fixed; z-index: 9; right: 8px; top: calc(var(--top-h, 112px) + 8px); width: auto; height: 38px; padding: 0 14px; border-radius: 14px; font-weight: 600; font-size: 13px; color: var(--ink); background: var(--glass-strong); }
  .maplegend { display: none; right: 8px; left: auto; top: calc(var(--top-h, 112px) + 50px); max-width: calc(100% - 16px); }
  body.key-open .maplegend { display: grid; }

  /* every panel is a bottom sheet: peek, half or full height; drag the grabber or tap it */
  .left, .right, .phone { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h, 50vh); max-height: none;
    border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); transition: height 0.34s var(--spring), transform 0.55s var(--spring), opacity 0.4s ease; }
  .right { z-index: 12; height: calc(100dvh - var(--top-h, 112px) - 12px); }
  body.sheet-dragging .left, body.sheet-dragging .phone { transition: none; }
  .grabber { display: block; flex: none; width: 100%; height: 22px; margin: 0; background: none; cursor: grab; touch-action: none; position: relative; }
  .grabber::after { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--fill-2); }
  .panel-head { padding: 2px 12px 8px; }
  .tabs { gap: 2px; }
  .tabs button { padding: 7px 10px; font-size: 14px; }
  .tabs .lg { display: none; } .tabs .sm { display: inline; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toast { bottom: calc(var(--sheet-h, 50vh) + 12px); max-width: calc(100% - 24px); }

  .sheet { top: auto; bottom: 0; left: 0; width: 100%; max-height: 88vh; transform: translateY(100%); border-radius: 26px 26px 0 0; }
  .sheet.open { transform: translateY(0); }
  .sheet .body { grid-template-columns: minmax(0, 1fr); padding: 4px 14px 24px; }
  .sheet .grabber::after { top: 8px; }
  /* in the week-and-plan sheet the plan list is always open and the week buttons share the width */
  #ctx-host { display: grid; gap: 14px; margin-top: 10px; }
  #ctx-host #week { display: flex; width: 100%; }
  #ctx-host #week button { flex: 1; padding: 10px 6px; }
  #ctx-host #planbtn { display: none; }
  #ctx-host .menu { display: grid; position: static; width: 100%; box-shadow: none; background: var(--fill); }
}
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* the plan menu: our own list instead of the system dropdown, so it looks the same on Windows, macOS and phones */
.planpick { position: relative; min-width: 0; }
#planbtn { max-width: 360px; cursor: pointer; }
#planbtn .k { color: var(--ink-3); }
#planname { overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-weight: 600; }
.menu { display: none; position: absolute; z-index: 25; top: calc(100% + 8px); right: 0; width: min(420px, 92vw); margin: 0; padding: 6px; list-style: none; border-radius: 16px; gap: 2px; }
.menu.open { display: grid; }
.menu li { padding: 10px 12px 10px 34px; border-radius: 11px; font-size: 14px; line-height: 1.3; color: var(--ink); cursor: pointer; position: relative; white-space: normal; }
.menu li small { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.menu li:hover, .menu li.active { background: var(--fill-2); }
.menu li[aria-selected="true"]::before { content: ""; position: absolute; left: 12px; top: 14px; width: 12px; height: 7px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- map badges: one clean hexagon per community */
.hexb { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; padding: 0; cursor: pointer; }
.hexb .hx {
  width: 38px; height: 34px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%);
  background: linear-gradient(160deg, rgba(255,255,255,.28), rgba(255,255,255,0) 55%), var(--c, #8e8e93);
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.45));
  transition: transform .35s var(--spring);
}
.hexb .hx b { font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.hexb:hover .hx, .hexb.sel .hx { transform: scale(1.12); }
.hexb .nm {
  font-size: 11.5px; font-weight: 600; color: #fff; padding: 2px 7px; border-radius: 999px; white-space: nowrap;
  background: rgba(16, 20, 26, .62); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(-2px); transition: opacity .3s, transform .3s var(--spring); pointer-events: none;
}
.hexb .nm small { font-weight: 500; opacity: .75; margin-left: 4px; }
.hexb:hover .nm, .hexb.sel .nm, body.zoomed .hexb .nm, .hexb.s-stop .nm, .hexb.s-near .nm { opacity: 1; transform: none; }
.hexb.small .hx { width: 30px; height: 27px; font-size: 12px; }
.hexb.s-booked { --c: #26b14f; } .hexb.s-waiting { --c: #f08c00; } .hexb.s-cut { --c: #d9a600; } .hexb.s-none { --c: #8e8e93; }
.hexb.s-stop { --c: #0a84ff; }
.hexb.s-stop .hx { width: 44px; height: 39px; font-size: 17px; }
.hexb.s-near { --c: #5b7488; }   /* nearby, not booked: same hexagon as a stop, in a quieter slate blue */
.hexb.s-near .hx { width: 44px; height: 39px; font-size: 17px; }
.hubb { display: grid; justify-items: center; padding: 6px 12px; border-radius: 14px; background: rgba(255,255,255,.92); color: #14181d; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.hubb span { font-weight: 700; font-size: 13px; } .hubb small { font-size: 10.5px; color: #4a525c; }
.savetag { font-size: 11.5px; color: #e9f8ff; padding: 4px 9px; border-radius: 10px; background: rgba(14, 90, 120, .78); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.savetag b { color: #fff; }
.savetag { opacity: 0; transition: opacity .3s; pointer-events: none; }
body.z8 .savetag, .savetag.always { opacity: 1; }
@media (max-width: 860px) { .savetag { display: none; } .hexb .nm { font-size: 10.5px; } .hexb .nm { display: none; } .hexb.sel .nm { display: inline-block; } }
.hubb { display: flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 999px; }
.hubb i { width: 9px; height: 9px; border-radius: 2px; background: #14181d; }
.hubb small { display: none; }
.maplegend .lg { display: inline-block; width: 12px; height: 11px; margin-right: 7px; vertical-align: -1px; clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); background: var(--c); }
.maplegend .lg.s-booked { --c: #26b14f; } .maplegend .lg.s-waiting { --c: #f08c00; } .maplegend .lg.s-cut { --c: #d9a600; }
.maplegend .ln { display: inline-block; width: 16px; height: 3px; border-radius: 2px; background: #64d2ff; margin-right: 7px; vertical-align: 3px; }
.maplegend .src { margin-top: 4px; font-size: 11px; color: var(--ink-3); }
.maplegend span { display: block; }

/* tips, network state, run numbers, tables */
.guide { display: flex; gap: 10px; align-items: flex-start; margin: 0 6px 10px; padding: 12px 12px 12px 14px; border-radius: var(--r-md); background: var(--hex-bg); font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.guide b { color: var(--ink); }
.guide .iconbtn { width: 26px; height: 26px; flex: none; font-size: 11px; }
.net { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--fill); }
.net i { width: 7px; height: 7px; border-radius: 50%; }
.net.on { color: var(--good); } .net.on i { background: var(--good); }
.net.wait { color: var(--warn); } .net.wait i { background: var(--warn); }
.net.off { color: var(--ink-2); } .net.off i { background: var(--ink-3); }
.stopno { display: inline-grid; place-items: center; width: 22px; height: 20px; margin-right: 8px; font-size: 12px; color: #fff; background: #0a84ff;
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); vertical-align: 1px; }
button.trip-card { width: 100%; text-align: left; border: 0; cursor: pointer; transition: background .2s; }
button.trip-card:hover { background: var(--fill-2); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--ink-3); font-weight: 600; padding: 4px 6px; }
.tbl td { border-top: 1px solid var(--line); padding: 6px; }

#splash { position: fixed; z-index: 50; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 6px; padding: 26px 34px; color: var(--ink); transition: opacity .5s, transform .6s var(--spring); }
#splash span { color: var(--ink-3); font-size: 13.5px; }
#splash.gone { opacity: 0; transform: translate(-50%, -46%) scale(.98); pointer-events: none; }

/* "How are costs worked out?" */
details.costs { margin: 8px 6px 10px; padding: 10px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
details.costs summary { cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; }
details.costs summary::-webkit-details-marker { display: none; }
details.costs summary::before { content: "▸"; display: inline-block; margin-right: 6px; transition: transform .2s; }
details.costs[open] summary::before { transform: rotate(90deg); }
details.costs p, details.costs ul { margin: 8px 0 0; line-height: 1.45; }
details.costs ul { padding-left: 18px; }
@media (prefers-reduced-motion: reduce) { details.costs summary::before { transition: none; } }

/* several communities too close to tap apart: one badge, "N places", tap to zoom in */
.hexb.s-group { --c: #5e5ce6; }
.hexb.s-group .hx { box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 4px 14px rgba(0,0,0,.35); }
.hexb.s-group .nm { opacity: 1; transform: none; }
/* the hub name is a label, not a control: it sits under community badges and lets taps through */
.hubb { pointer-events: none; z-index: 0; }
.hexb { z-index: 1; }
.hexb.s-group { z-index: 2; }

/* no-access evidence form on the run sheet */
form.noaccess { display: grid; gap: 8px; margin-top: 10px; padding: 10px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); }
form.noaccess[hidden] { display: none; }
form.noaccess fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 4px; }
form.noaccess input[type=time], form.noaccess input[type=text] { display: block; width: 100%; margin-top: 4px; }
label.tick { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); min-height: 28px; }

/* a house's repair history in the tenant view */
ul.hist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
ul.hist li { display: grid; gap: 1px; font-size: 14px; color: var(--ink); }
a.btn { display: inline-grid; place-items: center; text-align: center; text-decoration: none; }

/* four roles in the top bar: on narrower desktops the hub name moves to the tooltip and the plan name shortens */
@media (max-width: 1640px) and (min-width: 861px) { .brand small { display: none; } #planbtn { max-width: 300px; } }
.role-short { display: none; }
@media (max-width: 1340px) and (min-width: 861px) {
  .brand b { display: none; }
  .role-long { display: none !important; } .role-short { display: inline; }
  #role button { padding-left: 10px; padding-right: 10px; }
  #planbtn { max-width: 210px; } #planbtn .k { display: none; }
  #week button { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 1100px) and (min-width: 861px) { .pill.syn .lg-only { display: none; } .pill.syn .sm-only { display: inline; } #planbtn { max-width: 160px; } .topbar { gap: 6px; } }
@media (max-width: 860px) { .role-short { display: inline; } }

/* a job open on the right: the map legend makes way, the layer chips centre on the map that is left */
@media (min-width: 901px) {
  body.detail-open .maplegend { display: none; }
  body.detail-open .mapchips { left: calc(448px + (100% - 448px - 394px) / 2); }
}
/* Compare sheet on a phone: the metric switch wraps instead of running off the screen */
@media (max-width: 520px) {
  #metric { flex-wrap: wrap; }
  #metric button { padding: 6px 8px; font-size: 12.5px; white-space: normal; }
  #metric .thumb { display: none; }
  #metric button[aria-pressed="true"] { background: var(--glass-strong); }
}

/* ReachNT mark (brand kit v1.0): one colour, Sky on dark, the deeper blue on light */
.mark { color: #0e8fb8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mark { color: #6ec1e8; } }
:root[data-theme="dark"] .mark { color: #6ec1e8; }
