:root {
  --navy: #14213d;
  --navy-2: #1f2f55;
  --gold: #fca311;
  --bg: #f3f4f7;
  --card: #ffffff;
  --text: #1a1d24;
  --muted: #5d6475;
  --line: #d9dce4;
  --accent: #1d4ed8;
  --danger: #b42318;
  --ok: #157f3c;
  --warn-bg: #fff4d6;
  --radius: 10px;
  --tap: 44px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1220;
    --card: #171c2c;
    --text: #e8eaf0;
    --muted: #9aa1b2;
    --line: #2b3247;
    --accent: #7aa2ff;
    --danger: #ff7a6e;
    --ok: #4fd17d;
    --warn-bg: #3a2f12;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px 0;
  padding-top: max(10px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; font-size: 12px; opacity: .75; font-weight: 400; }
/* The shield-and-bell mark, colored by background-color through the SVG mask. */
.logo {
  display: block; flex: none; width: 34px; height: 34px;
  background: var(--gold);
  -webkit-mask: url(/shield.svg) center / contain no-repeat;
  mask: url(/shield.svg) center / contain no-repeat;
}
#nav { display: flex; gap: 4px; overflow-x: auto; margin-top: 8px; scrollbar-width: none; }
#nav a {
  color: #fff; opacity: .75; text-decoration: none; white-space: nowrap;
  padding: 10px 12px; border-bottom: 3px solid transparent; font-weight: 600; font-size: 15px;
}
#nav a.on { opacity: 1; border-bottom-color: var(--gold); }

main { max-width: 860px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 14px; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.cards { display: grid; gap: 10px; }
button.card { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
button.card:hover { border-color: var(--accent); }

.auth-box { max-width: 400px; margin: 6vh auto 0; }
.auth-box .logo { width: 64px; height: 64px; margin: 0 auto 10px; }

/* Forms */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=password], select {
  width: 100%; min-height: var(--tap);
  padding: 8px 12px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 14px; }
.field .err { color: var(--danger); font-size: 14px; margin-top: 4px; }
.field.bad input, .field.bad select { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 500; }
.check input { width: 20px; height: 20px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; }
.form-error { background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }

button, .btn {
  min-height: var(--tap); padding: 8px 16px;
  font: inherit; font-weight: 600;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.wide { width: 100%; }
button:disabled { opacity: .6; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.actions .push { margin-left: auto; }

/* Chips and badges */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 13px; padding: 2px 9px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line);
}
.badge { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.flag { font-size: 13px; color: var(--danger); font-weight: 600; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { min-height: 36px; padding: 4px 14px; border-radius: 999px; }
.tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.person-name { font-weight: 700; font-size: 17px; }
.person-meta { color: var(--muted); font-size: 14px; }
.inactive { opacity: .6; }
a.tel { color: var(--accent); font-weight: 600; text-decoration: none; }

/* ? help icons */
.help {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; font-weight: 700; cursor: help; margin-left: 6px; vertical-align: middle;
  background: var(--card); padding: 0; min-height: 0;
}

/* Dialog */
dialog {
  border: none; border-radius: 14px; padding: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  background: var(--card); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(10, 14, 30, .55); }
dialog .dlg-body { padding: 18px 18px 20px; overflow-y: auto; }
dialog h1 { font-size: 19px; }
.secret {
  font: 700 24px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .06em;
  background: var(--bg); border-radius: 8px; padding: 14px; text-align: center; user-select: all;
}

details.log summary { cursor: pointer; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; }
.log-item { border-top: 1px solid var(--line); padding: 8px 0; font-size: 14px; }

@media (min-width: 700px) {
  .cards.two { grid-template-columns: 1fr 1fr; }
  main { padding: 24px; }
}

/* ---------- Status board ---------- */
:root { --duty: #15803d; --call: #c8102e; --off: #8a91a3; --duty-bg: #e7f6ec; --call-bg: #fdeaec; }
@media (prefers-color-scheme: dark) {
  :root { --duty: #3ccf74; --call: #ff5a6e; --off: #6b7286; --duty-bg: #12301f; --call-bg: #3a1720; }
}
.card.person { display: flex; align-items: center; gap: 10px; border-left: 8px solid var(--off); padding-left: 12px; }
.card.person.s-duty { border-left-color: var(--duty); }
.card.person.s-call { border-left-color: var(--call); }
.card.person .grow { flex: 1; min-width: 0; }
.status-label { font-weight: 600; }
.s-duty .status-label { color: var(--duty); }
.s-call .status-label { color: var(--call); }
.s-off .status-label { color: var(--muted); }
.ringing { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.call-btn { background: var(--duty); border-color: var(--duty); color: #fff; min-width: 64px; }
.small-btn { min-height: 36px; padding: 4px 10px; font-size: 14px; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-left: 6px; }
.dot.s-duty { background: var(--duty); }
.dot.s-call { background: var(--call); }
.dot.s-off { background: var(--off); }
.chip.c-call { background: var(--call-bg); border-color: var(--call); color: var(--call); font-weight: 600; }
.chip.c-duty { background: var(--duty-bg); border-color: var(--duty); color: var(--duty); }
.chip.c-now { background: var(--navy); border-color: var(--navy); color: #fff; margin-left: 8px; }

.card.rings { margin: 12px 0 14px; }
.card.rings.warn { background: var(--warn-bg); border-color: var(--call); }
.rings-names { font-size: 19px; font-weight: 700; margin: 2px 0; }

/* My duty switch: big enough for a thumb. */
.duty-switch {
  width: 100%; justify-content: flex-start; gap: 14px; padding: 12px 16px; margin-top: 4px;
  min-height: 64px; border-radius: var(--radius); text-align: left;
}
.duty-switch strong { display: block; font-size: 18px; }
.duty-switch small { display: block; font-weight: 400; color: var(--muted); }
.duty-switch .knob {
  flex: none; width: 54px; height: 30px; border-radius: 999px; background: var(--off); position: relative; transition: background .15s;
}
.duty-switch .knob::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s;
}
.duty-switch.on { border-color: var(--duty); background: var(--duty-bg); }
.duty-switch.on .knob { background: var(--duty); }
.duty-switch.on .knob::after { left: 27px; }

.big-choice { justify-content: center; }
.big-choice button { min-width: 120px; min-height: 56px; font-size: 18px; }
.big-choice button.yes { background: var(--duty); border-color: var(--duty); color: #fff; }

/* ---------- Schedule ---------- */
.week-nav { margin: 4px 0 12px; }
.week-nav button { min-width: 48px; font-size: 22px; padding: 0 12px; }
.day-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.day-label { font-weight: 700; min-width: 120px; display: flex; align-items: center; }
.day-row.today { border-color: var(--navy); box-shadow: inset 4px 0 0 var(--gold); }
button.card.day-row { display: flex; justify-content: flex-start; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
input[type=date], input[type=time] {
  width: 100%; min-height: var(--tap); padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
.hours-row { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 6px; }
.hours-row .check { margin: 0; }
.hours-row .row { flex-wrap: nowrap; gap: 6px; }
.hours-row input[type=time] { flex: 1; min-width: 0; max-width: 150px; padding: 8px 6px; }
.hours-row input:disabled { opacity: .4; }
@media (max-width: 480px) {
  /* Narrow phones: drop the clock icon so "05:00 PM" fits; tapping the box still opens the picker. */
  .hours-row input[type=time]::-webkit-calendar-picker-indicator { display: none; }
  .hours-row input[type=time] { font-size: 15px; padding: 8px 4px; text-align: center; }
}

/* Settings: copyable webhook addresses */
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; margin-top: 8px; }
.copy-row .muted { grid-column: 1 / -1; }
.copy-row code { font-size: 13px; background: var(--bg); border-radius: 6px; padding: 6px 8px; overflow-wrap: anywhere; }

/* Holidays */
.chip.c-holiday { background: var(--warn-bg); border-color: var(--gold); color: var(--text); margin-left: 8px; font-weight: 600; }
.holiday-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.holiday-row .day-label { min-width: 0; white-space: nowrap; }
.holiday-row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.holiday-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 10px; align-items: start; margin-top: 12px; }
@media (max-width: 480px) {
  .holiday-add { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .holiday-add > :last-child { grid-column: 1 / -1; margin-bottom: 0; }
  .holiday-add > :last-child label { display: none; }
  .holiday-row .day-label { font-size: 14px; }
}

/* ---------- Acknowledgement page (/a/<token>) ---------- */
.ack-body { font-size: 19px; font-weight: 600; white-space: pre-line; margin: 6px 0 10px; }
.ack-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 12px; }
.ack-btn { min-height: 72px; font-size: 20px; border-width: 2px; }
.ack-btn.go { background: var(--duty); border-color: var(--duty); color: #fff; }
.ack-btn.no { background: var(--card); }
.ack-btn.chosen { outline: 4px solid var(--gold); outline-offset: 2px; }
.ack-done { margin: 12px 0 0; }
.ack-done.responding { background: var(--duty-bg); border-color: var(--duty); }
.call-sup { width: 100%; min-height: 56px; font-size: 17px; margin-bottom: 8px; }
a.btn.wide { display: flex; }

/* ---------- Templates and alerts ---------- */
textarea {
  width: 100%; padding: 8px 12px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; resize: vertical;
}
.field-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.field-row-main { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; margin-bottom: 6px; }
.field-row-options { margin-bottom: 6px; }
.field.bad .field-row, .field-row.bad { border-color: var(--danger); }
.insert-chips { margin-top: 8px; align-items: center; }
.chip-btn { cursor: pointer; font: inherit; font-size: 13px; color: var(--accent); min-height: 30px; }
.sms-preview {
  white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.4 system-ui, sans-serif;
  background: var(--bg); border-radius: 14px 14px 14px 4px; padding: 12px 14px; margin: 4px 0 6px;
}
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.template-btn { min-height: 64px; font-size: 17px; background: var(--navy); color: #fff; border-color: var(--navy); }
.req { color: var(--danger); }
.yesno { display: flex; gap: 8px; }
.yesno button { min-width: 80px; min-height: 44px; }
.yesno button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.big-send { min-height: 56px; font-size: 18px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.status-ok { color: var(--duty); font-weight: 600; }
.board-alerts { margin: 0 0 14px; }
.board-alert { display: block; padding: 6px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.board-alert:first-of-type { border-top: none; }

/* Responses: Responding (green), No response (red), Other (yellow) */
.ack-btn.call { background: var(--accent); border-color: var(--accent); color: #fff; }
.ack-btn.other { background: var(--card); }
.other-box { display: grid; gap: 10px; margin-bottom: 12px; }
.responders { margin: 0 0 12px; }
.responder { padding: 4px 0; border-top: 1px solid var(--line); }
.responder:first-of-type { border-top: none; }

/* Active incident card at the top of the board */
.incident { border: 2px solid var(--call); background: var(--call-bg); margin: 4px 0 14px; }
.incident .ack-body { font-size: 17px; margin: 4px 0 8px; }
.incident .who { margin: 8px 0; }
.incident .who .chip { margin: 2px 4px 2px 0; }
.respond-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.respond-row button { min-height: 48px; padding: 4px; font-size: 14px; }
.respond-row button.chosen { outline: 3px solid var(--gold); outline-offset: 1px; }
.respond-row .go { background: var(--duty); border-color: var(--duty); color: #fff; }
.respond-row .call { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 400px) { .respond-row { grid-template-columns: 1fr 1fr; } }

/* Icons: phone next to the sender's name, map next to the pin */
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 2px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--accent); font-weight: 600; text-decoration: none;
}
.icon-link .icon-phone { color: var(--duty); }
.incident .icon-link { background: var(--card); }

/* Response buttons: green / red, then yellow full width */
.ack-btn.no, .respond-row .no { background: var(--call); border-color: var(--call); color: #fff; }
.ack-btn.other, .respond-row .other { background: var(--gold); border-color: var(--gold); color: #1a1d24; }
.ack-buttons .wide, .respond-row .wide { grid-column: 1 / -1; }
.respond-row { grid-template-columns: 1fr 1fr; }
.ack-btn.chosen, .respond-row button.chosen { outline: 4px solid #fff; outline-offset: -6px; }
@media (prefers-color-scheme: light) { .ack-btn.chosen, .respond-row button.chosen { outline-color: var(--navy); outline-offset: 2px; } }
.incident .ack-buttons { margin-bottom: 4px; }
.incident .other-box { margin-top: 8px; margin-bottom: 0; }
.sent-note { margin: 8px 0 0; font-weight: 600; color: var(--duty); }
.incident .ack-btn { font-size: 18px; min-height: 60px; white-space: nowrap; padding: 4px 8px; }

/* Log button and pop-up on the scene card */
button.icon-link { font: inherit; font-weight: 600; cursor: pointer; }
.log-dialog { border: none; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); background: var(--card); color: var(--text); }
.log-dialog::backdrop { background: rgba(10, 14, 30, .55); }
.run-log-row { display: grid; grid-template-columns: 72px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.run-log-row:first-child { border-top: none; }
.run-log-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip { white-space: nowrap; }
.incident .row.small { gap: 6px; }
@media (max-width: 420px) {
  .icon-link { padding: 2px 8px; gap: 4px; font-size: 14px; min-height: 34px; }
  .icon-link .icon { width: 16px; height: 16px; }
}

/* The shield logo is the duty switch: green on duty, grey off duty */
button.logo { border: none; padding: 0; min-height: 0; border-radius: 0; cursor: default; }
button.logo:disabled { opacity: 1; }
button.logo.duty-on, button.logo.duty-off, button.logo.duty-call, button.logo.duty-held { cursor: pointer; transition: background .15s; }
button.logo.duty-on { background: #22c55e; }
button.logo.duty-off { background: #8a91a3; }
button.logo.duty-call { background: #e5484d; } /* on call, not on duty */
button.logo:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

/* ---------- Log ---------- */
.log-filters label { display: block; margin-bottom: 10px; }
.log-filters input, .log-filters select { margin-top: 4px; }
.log-row { display: block; width: 100%; text-align: left; }
.log-title { font-weight: 700; margin: 4px 0 2px; }
.log-detail { white-space: pre-line; overflow-wrap: anywhere; }
.log-row.t-escalation { border-left: 6px solid var(--call); }
.log-row.t-alert { border-left: 6px solid var(--gold); }
.log-row.t-call { border-left: 6px solid var(--accent); }
.health { border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.health.ok { background: var(--duty-bg); }
.health.bad { background: var(--warn-bg); border: 1px solid var(--call); }
input[type=search] { width: 100%; min-height: var(--tap); padding: 8px 12px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.more-filters { margin: 0 0 6px; }
.more-filters summary { cursor: pointer; font-weight: 600; color: var(--accent); min-height: 36px; display: flex; align-items: center; }
.more-filters[open] summary { margin-bottom: 8px; }
.log-filters .actions { margin-top: 8px; }

/* Top bar: account icon at the right; Admin button after the tabs */
.brand { position: relative; }
#account-btn {
  margin-left: auto; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; opacity: .8; border: 1px solid rgba(255, 255, 255, .25);
}
#account-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#account-btn.on { opacity: 1; border-color: var(--gold); }
#nav a.admin-tab { margin-left: auto; color: var(--gold); opacity: .9; }
#nav a.admin-tab.on { opacity: 1; }
.subnav { display: flex; gap: 6px; overflow-x: auto; margin: -4px 0 14px; scrollbar-width: none; }
.subnav a {
  white-space: nowrap; text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
}
.subnav a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.rank-name { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr); gap: 10px; }
.group-picks .check { align-items: flex-start; }
.rights-list .check { min-height: 38px; }

/* Settings > Phone line: connect to Twilio */
.connect .steps { padding-left: 20px; margin: 8px 0; }
.connect .steps li { margin: 4px 0; }
pre.twiml { background: var(--bg); border-radius: 8px; padding: 10px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
input[type=url] { width: 100%; min-height: var(--tap); padding: 8px 12px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; }

/* Ring order tags on the Status cards: 2nd and 3rd are quieter than "Rings now". */
.ringing.later { opacity: .65; }

/* Settings: end-of-day reset days */
.row.wrap { flex-wrap: wrap; }
.day-check { min-width: 64px; }

/* Groups: per-member schedule admin / backup checkboxes in investigations groups */
.member-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: none; }
.member-flags { display: flex; gap: 12px; }
.member-flags[hidden] { display: none; }
.check.small { font-size: 13px; }

/* Notification detail: a person picked up the call-out call */
.heard { color: var(--ok); font-weight: 600; }

/* Incident card: All-call, collapsed incidents, responder call chips */
.allcall-btn { width: 100%; margin-top: 10px; background: transparent; border: 2px solid var(--danger); color: var(--danger); font-weight: 700; }
.card.incident.collapsed { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px 16px; }
.chip-call { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.chip-call .icon { width: 14px; height: 14px; }
.oncall-now { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

/* Super admin "view as" bar */
.viewing-banner { position: sticky; top: 0; z-index: 20; background: #b26b00; color: #fff; padding: 6px 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: center; }

/* On-call: a day taken over by a swap */
.chip.c-swap { background: #ede4ff; color: #5b2bb5; border-color: #9b7be0; }
@media (prefers-color-scheme: dark) { .chip.c-swap { background: #2e2350; color: #c9b6ff; border-color: #6d55b8; } }

/* Pull down to refresh (the home-screen app has no browser refresh) */
body { overscroll-behavior-y: contain; }
.ptr { position: fixed; top: 0; left: 50%; z-index: 30; margin-left: -110px; width: 220px; height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 4px 14px rgba(0,0,0,.18); font-size: 14px; font-weight: 600;
  transform: translateY(-60px); pointer-events: none; }
.ptr-spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; }
.ptr.ready .ptr-spin { border-color: var(--gold); }
.ptr.busy .ptr-spin { animation: ptrspin .7s linear infinite; }
.ptr.done .ptr-spin { border-color: var(--ok); }
@keyframes ptrspin { to { transform: rotate(360deg); } }

/* On call, held over past the morning handoff until a detective goes on duty (John, 2026-10-14) */
button.logo.duty-held { background: #f97316; }
.card.person.s-held { border-left-color: #f97316; }
.s-held .status-label { color: #c2410c; }
.dot.s-held { background: #f97316; }

/* All-call: replaces No response / Other once you're Responding; a banner once it's sent (John, 2026-10-14) */
.respond-row .allcall-btn { margin-top: 0; grid-column: span 3; background: var(--danger); border-color: var(--danger); color: #fff; }
.respond-row .allcall-btn.sent, .respond-row .allcall-btn:disabled { background: transparent; color: var(--danger); opacity: 1; }
.respond-row .linkish { grid-column: 1 / -1; min-height: 0; background: none; border: 0; color: var(--accent); text-decoration: underline; font-size: 13px; padding: 2px; }
@media (max-width: 400px) { .respond-row .allcall-btn { grid-column: span 1; } }
.allcall-banner { background: var(--danger); color: #fff; border-radius: 8px; padding: 7px 10px; margin: 8px 0 6px; font-size: 14px; line-height: 1.35; }
.allcall-banner strong { color: #fff; letter-spacing: .3px; }
.respond-row.allcall-only .allcall-btn, .respond-row.allcall-below .allcall-btn { grid-column: 1 / -1; }
/* Notifications page: who to call right now (John, 2026-10-14) */
.oncall-now .call-btn.on-call { background: var(--danger); border-color: var(--danger); }
.oncall-now .call-btn.on-duty { background: var(--duty); border-color: var(--duty); }
.oncall-now.on-call { border-left: 6px solid var(--danger); }
.oncall-now.on-duty { border-left: 6px solid var(--duty); }

/* ---------- Teams (spec 2026-10-14) ---------- */
.team-card { padding: 0; overflow: hidden; border: 2px solid #111; margin: 4px 0 14px; }
.team-card .team-head { background: #111; color: #fff; display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; align-items: baseline; }
.team-card .team-title { font-weight: 800; letter-spacing: .3px; text-transform: uppercase; font-size: 14px; }
.team-card .team-time { font-size: 13px; color: #ddd; white-space: nowrap; }
.team-card .team-body { padding: 10px 12px 12px; }
.team-card.ended { opacity: .75; }
.team-address { font-weight: 700; margin-bottom: 6px; }
.team-map { width: 100%; border-radius: 8px; border: 1px solid var(--line); margin: 4px 0 6px; display: block; }
.team-counts { font-weight: 700; margin: 8px 0 6px; }
.team-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.team-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-size: 14px; font-weight: 600; text-decoration: none; border: 2px solid; }
.team-pill svg { width: 15px; height: 15px; }
.team-pill.t-none { background: #222; color: #fff; border-color: #222; }
.team-pill.t-yes { background: var(--duty); color: #fff; border-color: var(--duty); }
.team-pill.t-no { background: var(--call); color: #fff; border-color: var(--call); }
.team-activate-btn { background: #111; border-color: #111; }
.leave-add { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.leave-add > :last-child { grid-column: auto; margin-bottom: 0; align-self: end; }
.leave-add > :last-child label { display: none; }

/* Address picker: autocomplete, map, draggable pin */
.addr-wrap { position: relative; }
.addr-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.18); overflow: hidden; }
.addr-list[hidden] { display: none; }
.addr-option { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 10px 12px; font-size: 15px; min-height: 0; }
.addr-option:last-child { border-bottom: 0; }
.addr-map { position: relative; margin-top: 10px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); touch-action: none; }
.addr-map[hidden] { display: none; }
.addr-map-img { display: block; width: 100%; aspect-ratio: 600 / 260; object-fit: cover; cursor: crosshair; }
.addr-pin { position: absolute; transform: translate(-50%, -100%); font-size: 32px; line-height: 1; cursor: grab; user-select: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
.addr-map-hint { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 6px; pointer-events: none; }
a.card { display: block; color: inherit; text-decoration: none; }
button.primary.team-activate-btn, a.btn.primary.team-activate-btn { background: #111; border-color: #111; color: #fff; }
/* Who-to-call card: the Call button runs from right after the label to the right edge (John, 2026-10-15) */
.oncall-now .oncall-who { flex: none; }
.oncall-now .call-btn { flex: 1; text-align: center; justify-content: center; }

/* Team members: one per line, Leader or Member (John, 2026-10-15) */
.role-list { display: flex; flex-direction: column; }
.role-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.role-row:last-child { border-bottom: 0; }
.role-name { min-width: 0; overflow-wrap: anywhere; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: -2px; }

/* The app's own Yes/Cancel box (replaces the browser's confirm pop-up) */
.ask-dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 0; max-width: min(420px, calc(100vw - 32px)); }
.ask-dialog::backdrop { background: rgba(0,0,0,.5); }
.ask-dialog p { font-size: 16px; margin: 0 0 14px; }

/* Team activation follow-ups */
.team-update { border-left: 3px solid var(--gold); padding: 4px 0 4px 10px; margin: 6px 0; }
.followup-btn { color: var(--gold) !important; font-weight: 700; }
.followup-dialog { width: min(520px, calc(100vw - 32px)); }
.team-map-wrap { position: relative; display: block; margin: 4px 0 6px; }
.team-map-wrap .team-map { margin: 0; }
.team-map-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); font-size: 30px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.45)); pointer-events: none; }

/* Export: the PDF in an in-app window (computers). */
dialog.pdf-dialog { width: min(1000px, 96vw); height: min(1200px, 94vh); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
dialog.pdf-dialog:not([open]) { display: none; }
dialog.pdf-dialog iframe { flex: 1; width: 100%; border: 0; border-radius: 6px; background: #fff; }
dialog.pdf-dialog .actions { margin: 0; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Text-link page: cleared after No response / Other, and a way into the app (John, 2026-10-15) */
.card.cleared h1 { margin: 0 0 6px; font-size: 20px; }
.card.cleared .linkish { background: none; border: 0; color: var(--accent); text-decoration: underline; font-size: 14px; padding: 4px 0; min-height: 0; }
.ack-open { margin-top: 16px; }
.ack-open .btn { padding: 12px 22px; }

/* Red Active tab: shows only while a call-out is live (John, 2026-10-15) */
#nav a.tab-active { color: #ff5a67; opacity: 1; font-weight: 800; letter-spacing: .02em; }
#nav a.tab-active.on { border-bottom-color: #ff5a67; }

/* Roster access boxes (John, 2026-10-15): checkboxes keep their size next to long text */
.access-picks .check { align-items: center; min-height: 38px; }
.access-picks .check input { flex: none; width: 20px; height: 20px; }
.access-picks .check .small { font-weight: 400; margin-top: 2px; }
.access-picks .sub-check { margin-left: 30px; }
.chip.c-access { background: rgba(252, 163, 17, .14); border-color: rgba(252, 163, 17, .45); color: var(--gold); }

/* CSI button next to the green Responding button: yellow (John, 2026-10-15) */
.respond-row .csi-btn { background: #f5d90a; border-color: #f5d90a; color: #1a1d24; font-weight: 800; letter-spacing: .5px; }
.respond-row .csi-btn.sent, .respond-row .csi-btn:disabled { background: transparent; color: #f5d90a; border-color: #f5d90a; opacity: 1; }
.respond-row.has-csi .allcall-btn { grid-column: 1 / -1; }
.csi-banner { background: #f5d90a; color: #1a1d24; border-radius: 8px; padding: 7px 10px; margin: 8px 0 6px; font-size: 14px; line-height: 1.35; }
.csi-banner strong { color: #1a1d24; letter-spacing: .3px; }

/* End call-out (detectives), under the answer buttons (John, 2026-10-15) */
.incident .end-btn { width: 100%; margin-top: 10px; min-height: 40px; background: transparent; border: 1px dashed var(--muted, #8892a6); color: inherit; font-weight: 600; opacity: .85; }

/* Team Members: name, Leader/Member, then Remove at the end. */
.role-row .role-name { flex: 1; }
.role-row > .small-btn { order: 3; flex: none; }

/* Active tab: the open card's top line folds it up. */
button.incident-head { width: 100%; background: none; border: 0; padding: 0; min-height: 0; color: inherit; font: inherit; cursor: pointer; }

/* Roster: texts to this person bounce. */
.text-problem { margin-top: 6px; color: var(--danger); font-weight: 600; font-size: .9em; }
.chip.warn { color: var(--danger); border-color: var(--danger); }

/* Team Members: Add a member (pick list grows, button beside it). */
.member-add { display: flex; align-items: flex-end; gap: 10px; }
.member-add .field { flex: 1; margin: 0; min-width: 0; }
.member-add .field select { width: 100%; }
.member-add button { flex: none; }

/* Detective units (John, 2026-10-20): the unit picker under the Detectives pages. Units this
   person can't open are listed but greyed (like other teams on the Teams tab). */
.unit-picker { margin-top: -6px; }
.unit-picker span.locked {
  white-space: nowrap; color: var(--muted); font-weight: 600; font-size: 14px; padding: 6px 12px;
  border-radius: 999px; border: 1px dashed var(--line); background: transparent; cursor: default;
}
.access-picks .sub-check .sub-select { margin-left: 8px; min-width: 150px; width: auto; }
/* Units tab: a unit you can't open is shown but quieter. */
.unit-card.locked { opacity: 0.72; }
a.unit-card { text-decoration: none; color: inherit; }

/* Status > Edit (John, 2026-10-21): the same member editor on units and teams. */
.edit-bar { margin: 0 0 10px; align-items: center; }
.icon-btn {
  flex: none; order: 3; width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-size: 15px; line-height: 1; cursor: pointer; display: inline-grid; place-items: center;
}
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { border-color: var(--danger); }
.pick-list { max-height: 50vh; overflow-y: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; }
.pick-row {
  display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: var(--card); font-size: 16px; cursor: pointer;
}
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover, .pick-row:focus-visible { background: var(--bg, #f3f5fa); }
.access-picks .unit-picks { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 2px 0 6px 30px; }
/* Template "Sends to": one row per group, Respond or FYI on the right once it's picked. */
.sends-list { display: flex; flex-direction: column; }
.sends-section + .sends-section { margin-top: 18px; }
.sends-section h3 { margin: 0 0 2px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sends-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.sends-row:last-child { border-bottom: 0; }
.sends-row .check { margin: 0; }
.seg-small span { padding: 5px 12px; font-size: 13px; }

/* License banners (John, 2026-10-21). */
.license-banner { border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; font-size: 14px; line-height: 1.4; border: 1px solid; }
.license-banner.warn { background: color-mix(in srgb, #f5a800 14%, var(--card)); border-color: #f5a800; }
.license-banner.bad { background: color-mix(in srgb, var(--danger) 12%, var(--card)); border-color: var(--danger); }

/* "What's new" (John, 2026-10-21): the one-time banner, and the version line at the bottom. */
.whats-new { border-left: 4px solid var(--navy, #13254a); margin-bottom: 14px; }
.whats-new ul, .whats-new-past ul { margin: 8px 0 4px; padding-left: 20px; }
.whats-new li, .whats-new-past li { margin: 4px 0; }
.whats-new .actions { margin-top: 8px; }
.whats-new-past { margin-bottom: 14px; }
.version-footer { margin-top: 28px; }
.summary-text { white-space: pre-wrap; font: 14px/1.5 ui-monospace, Consolas, monospace; background: var(--bg, #f3f5fa); padding: 12px; border-radius: 10px; max-height: 60vh; overflow: auto; }

/* Admin > Groups > Members (John, 2026-10-21): the same rows as Status > Edit. */
.member-card { padding-top: 4px; padding-bottom: 4px; }
.member-card .role-row .check { margin: 0; }
.member-card .role-name { min-width: 7em; }
/* Units: name and remove on top, Leader / Member and Backup underneath. */
.member-card .role-row.two-line { flex-wrap: wrap; row-gap: 8px; }
.member-card .two-line .role-name { flex: 1 1 calc(100% - 60px); }
.member-card .two-line .icon-btn { order: 1; }
.member-card .two-line .seg, .member-card .two-line .check { order: 2; }
.add-member { margin-top: 10px; }
.add-picker { margin-top: 10px; }

/* Admin > Groups: "unit" and "team" side by side (John, 2026-10-21). */
.type-picks { display: flex; flex-wrap: wrap; gap: 4px 28px; }
.type-picks .check { margin: 0; }

/* Roster: one short line per person, and a search box (John, 2026-10-21). */
.roster-search { width: 100%; margin: 4px 0 12px; }
.card.roster-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.roster-row .text-problem { display: inline; }
