:root {
  --bg: #0b0e13;
  --surface: #141a22;
  --surface-2: #1d2530;
  --surface-3: #232d3a;
  --border: #29333f;
  --border-bright: #3b4756;
  --text: #eef2f7;
  --muted: #98a4b3;
  --primary: #5b9dff;       /* vivid blue accent */
  --primary-d: #3f7ce0;
  --primary-2: #8b6cff;     /* violet, for gradients */
  --accent: #5b9dff;
  --grad: linear-gradient(135deg, #5b9dff 0%, #8b6cff 100%);
  --grad-soft: linear-gradient(135deg, rgba(91,157,255,.16), rgba(139,108,255,.16));
  --online: #3ddc84;
  --low: #3ddc84;
  --medium: #f0b13d;
  --high: #ff9a4d;
  --emergency: #f04852;
  --radius: 13px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0,0,0,.40);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.28);
  --ring: 0 0 0 3px rgba(91,157,255,.30);
  --bottomnav: 60px;       /* mobile bottom nav height (0 on desktop) */
  --mono: ui-monospace, 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
  --sans: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1100px 600px at 100% -5%, rgba(139,108,255,.10), transparent 55%),
    radial-gradient(900px 500px at -10% 0%, rgba(91,157,255,.10), transparent 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hidden { display: none !important; }
h1 { font-size: 1.25rem; font-weight: 700; margin: .4rem 0; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; font-weight: 700; margin: 0 0 .85rem; color: var(--text); letter-spacing: -.01em; }
h3 { font-weight: 700; }
::selection { background: rgba(91,157,255,.32); }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-width: thin; scrollbar-color: var(--border-bright) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid transparent; border-radius: var(--radius); padding: .74rem 1rem;
  font-family: var(--sans); font-size: .9rem; font-weight: 650; cursor: pointer; width: 100%;
  transition: transform .08s ease, filter .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(91,157,255,.30); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 22px rgba(91,157,255,.42); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-bright); }
.btn-ghost:hover { border-color: var(--primary); background: var(--surface-3); }
.btn-light { background: var(--text); color: #11161a; }
.btn-light:hover { filter: brightness(.96); }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; font-weight: 600; }
.link-btn:hover { color: var(--text); }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); width: 38px; height: 38px; font-size: 1.05rem; cursor: pointer; transition: border-color .15s, background .15s; }
.icon-btn:hover { border-color: var(--border-bright); background: var(--surface-3); }

/* ---------- Auth ---------- */
.view { min-height: 100vh; }
#auth-view { display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-box { width: 100%; max-width: 390px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1.7rem; box-shadow: var(--shadow); }
.brand { text-align: center; margin-bottom: 1.1rem; }
.brand-logo-mobile { border-radius: 12px; }
.brand h1 { margin: .5rem 0 0; font-size: 1.3rem; font-weight: 700; }
.tagline { color: var(--muted); margin: .3rem 0 0; font-size: .82rem; }
.tabs { display: flex; gap: .35rem; margin: 1rem 0; padding: .25rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.tab { flex: 1; padding: .55rem; background: none; border: none; color: var(--muted); border-radius: 9px; cursor: pointer; font-size: .9rem; font-weight: 650; transition: background .15s, color .15s; }
.tab.active { background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(91,157,255,.30); }
.auth-form, .stack { display: flex; flex-direction: column; gap: .85rem; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; color: var(--muted); font-weight: 500; }
input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: .72rem; font-size: 1rem; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.error { color: var(--emergency); font-size: .85rem; min-height: 1.2em; text-align: center; }
.info { color: var(--online); font-size: .88rem; text-align: center; min-height: 1.2em; }

/* ---------- App chrome ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem 1rem; background: rgba(17,23,30,.82); backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px); border-bottom: 1px solid var(--border); }
.topbar-left { display: flex; align-items: center; gap: .6rem; min-width: 0; flex: 1 1 auto; }
.topbar-right { display: flex; align-items: center; gap: .6rem; flex: none; }
.topbar-left img { border-radius: 8px; flex: none; }
.topbar-left strong { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 480px) {
  .topbar { padding: .55rem .7rem; }
  .topbar-left, .topbar-right { gap: .4rem; }
  .topbar .icon-btn { width: 34px; height: 34px; font-size: .98rem; }
  .topbar .pill { padding: .3rem .55rem; font-size: .68rem; }
}
/* On phones the brand truncates awkwardly — show just the logo (the full name
   is on the landing/sign-in); wider screens keep the wordmark. */
@media (max-width: 430px) {
  .topbar-left strong { display: none; }
  .topbar-left img { width: 32px; height: 32px; }
}
.pill { font-size: .72rem; font-weight: 650; padding: .32rem .7rem; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.pill[role="button"] { cursor: pointer; }
.pill[role="button"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pill-off { background: var(--surface-2); color: var(--muted); }
.pill-on { background: rgba(61,220,132,.16); color: var(--online); border-color: rgba(61,220,132,.45); box-shadow: 0 0 0 3px rgba(61,220,132,.10); }
.pill-standby { background: rgba(240,177,61,.18); color: var(--medium); border-color: rgba(240,177,61,.45); box-shadow: 0 0 0 3px rgba(240,177,61,.10); }

/* Standby card + toggle switch */
.standby-card.standby-card { border-color: rgba(224,169,59,.35); }
.standby-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.standby-status { margin: .8rem 0 0; font-size: .82rem; color: #e0a93b; }
.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; cursor: pointer; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: background .15s; }
.switch-slider::before { content: ''; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: transform .15s, background .15s; }
.switch input:checked + .switch-slider { background: rgba(224,169,59,.3); border-color: rgba(224,169,59,.6); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); background: #e0a93b; }

.emergency-button {
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  width: 100%; border: none; cursor: pointer; color: #fff;
  font-weight: 800; font-size: 1rem; letter-spacing: .01em; padding: 1rem; border-radius: 0;
  background: linear-gradient(135deg, #ff5a5f, #e0353c);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
  transition: filter .12s ease, transform .08s ease;
}
.emergency-button:hover { filter: brightness(1.07); }
.emergency-button:active { transform: translateY(1px); }
.idcard-button {
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  width: 100%; border: none; border-top: 1px solid var(--border); cursor: pointer;
  color: var(--text); font-weight: 600; font-size: .9rem; padding: .7rem;
  background: var(--surface-2);
}
.idcard-button:hover { background: var(--surface); }
.eb-icon { font-size: 1.2rem; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.0); } 50% { box-shadow: 0 0 0 4px rgba(229,72,77,.18); } }

/* Mobile: the main views live in a fixed bottom navigation bar (the emergency
   and ID buttons stay up top). Desktop turns this into a left sidebar below. */
.tabbar {
  display: flex; background: rgba(17,23,30,.96); backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0,0,0,.4);
}
.navtab {
  position: relative;
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: .45rem .15rem; background: none; border: none;
  color: var(--muted); font-size: .6rem; font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: color .15s ease;
}
.navtab .nt-ic { font-size: 1.3rem; line-height: 1; position: relative; transition: transform .12s ease; }
.navtab .nt-label { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.navtab.active { color: var(--primary); }
.navtab.active .nt-ic { transform: translateY(-1px); }
.navtab.active::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--grad); }
.navtab .nav-badge { position: absolute; top: -6px; left: 100%; margin-left: -8px; }

.panel { padding: 1rem; max-width: 660px; margin: 0 auto; }
/* Directional page-slide when switching views (swipe or tap) — modern feel. */
@keyframes slideInRight { from { transform: translateX(7%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideInLeft  { from { transform: translateX(-7%); opacity: 0; } to { transform: none; opacity: 1; } }
.panel.slide-in-right { animation: slideInRight .24s cubic-bezier(.22,.61,.36,1); }
.panel.slide-in-left  { animation: slideInLeft  .24s cubic-bezier(.22,.61,.36,1); }
@media (prefers-reduced-motion: reduce) { .panel.slide-in-right, .panel.slide-in-left { animation: none; } }
/* Live watch-status dashboard: a row of stat chips. */
.status-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.stat-chip {
  flex: 1 1 0; min-width: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  padding: .65rem .4rem; text-align: center;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: 14px;
  transition: transform .12s, border-color .15s, box-shadow .15s;
}
.stat-ic { font-size: 1.15rem; line-height: 1; }
.stat-num { font-size: 1.4rem; font-weight: 800; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .64rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* Per-stat accents (a tinted top edge + coloured count). */
.stat-incidents { border-top: 2px solid var(--emergency); }
.stat-incidents .stat-num { color: var(--emergency); }
.stat-online    { border-top: 2px solid #35c66b; }
.stat-online .stat-num { color: #4fd98a; }
.stat-standby   { border-top: 2px solid var(--medium); }
.stat-standby .stat-num { color: var(--medium); }
.stat-patrol    { border-top: 2px solid var(--primary); }
.stat-patrol .stat-num { color: var(--primary); }
/* Active-incidents chip lights up (and gently pulses) when something's live. */
.stat-incidents.has-incidents { border-color: var(--emergency); box-shadow: 0 0 0 3px rgba(240,72,82,.14); animation: incidents-pulse 2s ease-in-out infinite; }
@keyframes incidents-pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(240,72,82,.10); } 50% { box-shadow: 0 0 0 5px rgba(240,72,82,.22); } }
@media (prefers-reduced-motion: reduce) { .stat-incidents.has-incidents { animation: none; } }
/* The alerts toggle is a tappable chip. */
button.stat-chip { cursor: pointer; font: inherit; color: var(--text); }
button.stat-chip:hover { transform: translateY(-1px); border-color: var(--border-bright); }
.stat-alerts { border-top: 2px solid var(--muted); }
.stat-alerts .stat-ic { filter: grayscale(.5); opacity: .8; }
.stat-alerts.on { border-top-color: #35c66b; }
.stat-alerts.on .stat-ic { filter: none; opacity: 1; }
.stat-alerts.on .stat-label { color: #4fd98a; }

/* ---------- Lists / cards ---------- */
.list { display: flex; flex-direction: column; gap: .65rem; }
.card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow-sm); }
.card[data-id], .card[data-patrol] { cursor: pointer; transition: transform .1s ease, border-color .15s ease, box-shadow .15s ease; }
.card[data-id]:hover, .card[data-patrol]:hover { transform: translateY(-1px); border-color: var(--border-bright); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.card-title { font-weight: 600; font-size: .96rem; }
.card-meta { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.card-desc { margin: .5rem 0 0; font-size: .92rem; overflow-wrap: anywhere; }
.card-responders { margin: .5rem 0 0; font-size: .82rem; font-weight: 600; color: var(--emergency); overflow-wrap: anywhere; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; font-size: .88rem; }

.badge { font-size: .68rem; font-weight: 600; padding: .2rem .5rem; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; text-transform: capitalize; }
.b-low { background: rgba(53,198,107,.14); color: var(--low); }
.b-medium { background: rgba(224,169,59,.16); color: var(--medium); }
.b-high { background: rgba(239,139,70,.16); color: var(--high); }
.b-emergency { background: var(--emergency); color: #fff; }
.b-status { background: var(--surface-2); color: var(--muted); }
.b-standby { background: rgba(240,177,61,.18); color: var(--medium); border-color: rgba(240,177,61,.45); }
.b-cond { background: var(--surface-2); color: var(--muted); text-transform: none; }
.cond-line { opacity: .92; }

/* Weather card on the home feed: forecast for the day of each upcoming shift. */
.weather-card { margin-bottom: 1rem; }
.weather-head { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.weather-head h2 { margin: 0; }
.weather-today { color: var(--muted); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.weather-shifts { margin-top: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.weather-row { display: flex; align-items: center; gap: .7rem; padding: .5rem .2rem; border-top: 1px solid var(--border); }
.weather-row:first-child { border-top: 0; }
.wx-emoji { font-size: 1.5rem; line-height: 1; flex: 0 0 auto; }
.wx-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.wx-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-day { color: var(--muted); font-size: .76rem; }
.wx-temp { color: var(--text); font-size: .82rem; font-weight: 600; white-space: nowrap; flex: 0 0 auto; }
.wx-chip { white-space: nowrap; }

/* Personal activity tiles in the profile. */
.my-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 1rem 0 .2rem; }
.my-stats:empty { display: none; }
.my-stats .member-sub { grid-column: 1 / -1; margin: 0; }
.stat-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .3rem; text-align: center; }
.stat-tile b { display: block; font-size: 1.15rem; }
.stat-tile span { font-size: .68rem; color: var(--muted); }

.card.incident-emergency { border-color: rgba(240,72,82,.5); border-left: 3px solid var(--emergency); background: linear-gradient(180deg, rgba(240,72,82,.06), transparent 60%), var(--surface); }

.card-actions { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.card-actions .btn { padding: .5rem .8rem; font-size: .82rem; width: auto; flex: 1 1 auto; }

/* ---------- Type picker (buttons) ---------- */
.type-grid { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.type-grid legend { padding: 0 .4rem; color: var(--muted); font-size: .82rem; }
.type-btn { display: flex; align-items: center; gap: .5rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .65rem .6rem; color: var(--text); font-size: .85rem; font-weight: 500; cursor: pointer; text-align: left; transition: border-color .12s, background .12s, transform .08s; }
.type-btn:hover { border-color: var(--border-bright); }
.type-btn:active { transform: scale(.98); }
.type-btn span { line-height: 1.1; }
.type-btn.selected { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(91,157,255,.30); }
@media (min-width: 520px) { .type-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Photo attachments ---------- */
.photos-field { display: flex; flex-direction: column; gap: .5rem; }
.photo-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.photo-actions .btn { width: auto; flex: 1 1 auto; }
.photos-label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.photo-previews { display: flex; flex-wrap: wrap; gap: .5rem; }
.photo-thumb { position: relative; width: 76px; height: 76px; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.65); color: #fff; font-size: .8rem; line-height: 1; cursor: pointer; }
.card-photos { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.card-photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }

/* Voice: dictation + voice note */
.voice-field { display: flex; flex-direction: column; gap: .5rem; }
.voice-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.voice-actions .btn { width: auto; flex: 1 1 auto; }
.btn.recording { background: var(--emergency); border-color: var(--emergency); color: #fff; animation: pulse 1.1s infinite; }
.voicenote-preview { display: flex; align-items: center; gap: .5rem; }
.voicenote-preview audio { flex: 1; min-width: 0; height: 38px; }
.voicenote { display: block; width: 100%; max-width: 360px; height: 38px; margin-top: .6rem; }
.ai-caption { margin: .6rem 0 0; padding: .55rem .7rem; font-size: .85rem; background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 8px; color: var(--text); overflow-wrap: anywhere; }
.voice-transcript { margin: .5rem 0 0; padding: .5rem .7rem; font-size: .85rem; background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--online); border-radius: 8px; color: var(--text); overflow-wrap: anywhere; }

/* Admin: AI assist + retention */
.ai-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.ai-row:first-of-type { border-top: none; }
.ai-row .hint { margin-top: .15rem; }
.ai-unconfigured { color: var(--medium); }
.retain-row { flex-direction: row; align-items: center; justify-content: space-between; gap: .8rem; font-size: .9rem; color: var(--text); flex-wrap: wrap; }
.retain-row span { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.retain-row input { width: 80px; }
.comms-text { margin: -.1rem 0 .2rem 2.2rem; font-size: .82rem; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.storage-status { margin: 0; font-weight: 650; font-size: .9rem; }
.storage-status.storage-ok { color: var(--online); }
.storage-status.storage-warn { color: var(--medium); }
.storage-detail { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .7rem 0 0; font-size: .82rem; }
.storage-detail dt { color: var(--muted); }
.storage-detail dd { margin: 0; font-family: var(--mono); color: var(--text); overflow-wrap: anywhere; }
.storage-card .hint code, .storage-detail code { font-family: var(--mono); background: var(--surface-2); padding: 0 .3rem; border-radius: 4px; }

/* ---------- Urgency picker ---------- */
.urgency { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.urgency legend { padding: 0 .4rem; color: var(--muted); font-size: .82rem; }
.u-opt { flex-direction: row; align-items: center; gap: .5rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: .6rem; font-size: .9rem; color: var(--text); cursor: pointer; }
.u-opt input { accent-color: var(--primary); width: auto; }
.u-low { color: var(--low); }
.u-medium { color: var(--medium); }
.u-high { color: var(--high); }
.u-emergency { color: var(--emergency); }
.checkbox { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
.checkbox input { width: auto; accent-color: var(--primary); }

.newshift { margin-top: 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem 1rem; }
.newshift summary { cursor: pointer; padding: .5rem 0; font-weight: 600; color: var(--primary); }
.newshift .stack { padding-bottom: 1rem; }

/* ---------- Manual location picker ---------- */
.manual-loc { display: flex; flex-direction: column; gap: .5rem; padding: .7rem .8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.manual-loc .btn { width: auto; align-self: flex-start; }
.manual-loc #manual-loc-status { color: var(--online); }
.mappick-sheet { max-width: 640px; }
.mappick-map { height: 52vh; min-height: 280px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); margin-bottom: .8rem; }
.mappick-sheet .row-actions .btn { width: 100%; }

/* ---------- Image lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(5,7,10,.92); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.6); object-fit: contain; }
.lightbox-close { position: absolute; top: calc(.8rem + env(safe-area-inset-top)); right: .8rem; z-index: 1; width: 44px; height: 44px; font-size: 1.2rem; background: rgba(20,26,34,.9); }

/* ---------- Emergency overlay (distress alert) ---------- */
.emergency-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(8,11,14,.9); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.emergency-card { background: var(--surface); border: 1px solid var(--emergency); border-radius: 16px; padding: 1.5rem; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.emergency-flash { font-weight: 700; color: var(--emergency); font-size: 1rem; letter-spacing: .08em; animation: flash 1.1s steps(2, start) infinite; margin-bottom: .5rem; }
@keyframes flash { 50% { opacity: .35; } }
.emergency-card h2 { font-size: 1.35rem; }
.eo-meta { color: var(--muted); font-size: .82rem; }
.emergency-card .btn { margin-top: .6rem; }

/* ---------- Hints / info ---------- */
.hint { color: var(--muted); font-size: .78rem; margin: 0; }

/* ---------- Banners ---------- */
.offline-banner { background: var(--medium); color: #1a1206; font-weight: 600; font-size: .82rem; padding: .55rem 1rem; text-align: center; }
#queued-count { font-weight: 700; }
.broadcast-banner { display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: var(--primary); color: #fff; font-size: .88rem; padding: .6rem 1rem; }
.broadcast-banner .icon-btn { background: rgba(255,255,255,.2); border: none; color: #fff; width: 30px; height: 30px; flex: none; }
.update-banner { display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: var(--grad); color: #fff; font-size: .9rem; font-weight: 600; padding: .55rem 1rem; }
.update-actions { display: flex; align-items: center; gap: .5rem; flex: none; }
.update-banner .btn { width: auto; padding: .4rem .9rem; font-size: .85rem; }
.update-banner .icon-btn { background: rgba(255,255,255,.2); border: none; color: #fff; width: 30px; height: 30px; flex: none; }

/* Patrol welfare check-in prompt. */
.checkin-banner { display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: linear-gradient(90deg, #2a7d5f, #1f6e8c); color: #fff; font-size: .9rem; font-weight: 600; padding: .55rem 1rem; }
.checkin-banner .btn { width: auto; padding: .45rem 1rem; font-size: .88rem; flex: none; }
.checkin-banner.checkin-overdue { background: linear-gradient(90deg, var(--emergency), #b3261e); animation: checkin-pulse 1.1s ease-in-out infinite; }
@keyframes checkin-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .82; } }

/* ---------- Roster assign row ---------- */
.assign-row { display: flex; gap: .5rem; margin-top: .6rem; }
.assign-row .assign-select { flex: 1; }
.assign-row .btn { width: auto; }

/* ---------- Watch setup (admin) ---------- */
.setup-group { border: 1px solid var(--border); border-radius: 12px; padding: .8rem; margin: 0; }
.setup-group legend { padding: 0 .4rem; font-size: .82rem; font-weight: 700; color: var(--text); }
.contact-row .c-label { flex: 1; }
.contact-row .c-phone { flex: 1; }
.contact-row .c-del { flex: none; }

/* ---------- Emergency contacts ---------- */
.contacts-list { display: flex; flex-direction: column; gap: .5rem; }
.contact-card { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .8rem 1rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; color: var(--text); font-weight: 600; }
.contact-card:hover { border-color: var(--primary); background: var(--surface-3); }
.contact-label { font-size: .95rem; }
.contact-phone { color: var(--primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.eo-contacts { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin: .2rem 0; }
.eo-call { width: auto; }

/* ---------- Shift cards ---------- */
.shift-card { border-left: 3px solid var(--border-bright); }
.shift-card.s-live { border-left-color: #35c66b; }
.shift-card.s-upcoming { border-left-color: var(--primary); }
.shift-card.s-daily { border-left-color: var(--primary-2); }
.shift-card.s-ended { opacity: .72; }
.shift-badge.sb-live { background: rgba(53,198,107,.16); color: #4fd98a; border-color: rgba(53,198,107,.4); }
.shift-badge.sb-upcoming { background: rgba(91,157,255,.16); color: var(--primary); border-color: rgba(91,157,255,.4); }
.shift-badge.sb-daily { background: rgba(139,108,255,.16); color: #b9a6ff; border-color: rgba(139,108,255,.4); }
.shift-badge.sb-ended { background: var(--surface-2); color: var(--muted); }
.shift-date { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; font-size: .82rem; color: var(--muted); font-weight: 600; }
.shift-date select { flex: 1; }
.assignee-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .6rem; }
.assignee-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .5rem .2rem .3rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-size: .76rem; }
.assignee-chip.is-me { border-color: var(--primary); background: rgba(91,157,255,.12); }
.assignee-empty { font-size: .78rem; color: var(--muted); font-style: italic; }
.you-tag { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #4fd98a; }
.shift-del { color: var(--muted); margin-top: .6rem; font-size: .76rem; }
.shift-del:hover { color: var(--emergency); }

/* ---------- Shifts: week calendar (who's on each day) ---------- */
.shift-week { display: flex; flex-direction: column; gap: .5rem; }
.wk-day { display: grid; grid-template-columns: 84px 1fr; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .7rem; }
.wk-day.wk-today { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(91,157,255,.12); }
.wk-daylabel { font-size: .8rem; font-weight: 700; color: var(--muted); }
.wk-day.wk-today .wk-daylabel { color: var(--primary); }
.wk-shifts { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.wk-shift { border-left: 2px solid var(--border-bright); padding-left: .6rem; }
.wk-shift-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; }
.wk-time { font-size: .78rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.wk-title { font-size: .82rem; color: var(--text); }
.wk-people { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }
.wk-person { display: inline-flex; align-items: center; gap: .25rem; font-size: .74rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .45rem .1rem .2rem; }
.wk-empty { font-size: .74rem; color: var(--muted); font-style: italic; }
.wk-none { font-size: .78rem; color: var(--muted); }

/* ---------- Nav badge ---------- */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--emergency); color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; }

/* ---------- Incident badges (home / offline) ---------- */
.b-home { background: rgba(76,141,255,.16); color: var(--primary); }
.b-offline { background: rgba(151,163,173,.16); color: var(--muted); }

/* ---------- Member rows ---------- */
.member { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.member-sub { color: var(--muted); font-size: .8rem; }
.role-tag { font-size: .64rem; font-weight: 600; padding: .12rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); text-transform: capitalize; }
.role-admin { background: rgba(76,141,255,.16); color: var(--primary); border-color: rgba(76,141,255,.4); }
.role-controller { background: rgba(168,120,255,.16); color: #c4a8ff; border-color: rgba(168,120,255,.4); }
.role-patroller { background: rgba(53,198,107,.14); color: #5fd98a; border-color: rgba(53,198,107,.36); }
.role-watcher { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.hint-inline { color: var(--muted); font-weight: 400; font-size: .72rem; }
.role-history { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; max-height: 16rem; overflow-y: auto; }
.role-history li { padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: .8rem; }
.role-history li.hint { border-style: dashed; }
.rh-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .35rem; }
.rh-meta { color: var(--muted); font-size: .72rem; }
.rh-reason { margin-top: .2rem; color: var(--muted); font-style: italic; }
.char-count { display: block; text-align: right; margin-top: .15rem; }
.char-count-warn { color: var(--medium); }
.bh-title { margin: .8rem 0 .4rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.broadcast-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; max-height: 14rem; overflow-y: auto; }
.broadcast-history li { padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: .82rem; }
.broadcast-history li.hint { border-style: dashed; }
.bh-line { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; }
.bh-when { color: var(--muted); font-size: .7rem; white-space: nowrap; }
.bh-msg { margin-top: .15rem; color: var(--text); }
.status-pending { color: var(--medium); }
.status-rejected { color: var(--emergency); }
.row-actions { display: flex; gap: .4rem; }
.row-actions .btn { width: auto; padding: .45rem .7rem; font-size: .8rem; }

/* ---------- Generic overlay / bottom sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 900; background: rgba(8,11,14,.6); backdrop-filter: blur(2px); display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 0 0; padding: 0 1.25rem; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; box-shadow: 0 -8px 40px rgba(0,0,0,.4); }
/* Sticky header so the ✕ close button stays reachable while the sheet scrolls.
   Flush to the sheet top (sheet has no top padding) with negative side margins
   to span full width — nothing can scroll above it. */
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  position: sticky; top: 0; z-index: 3;
  margin: 0 -1.25rem .75rem; padding: 1.1rem 1.25rem .7rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
}
.sheet-head h2 { margin: 0; }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 16px; } }

/* ---------- Incident report detail ---------- */
.b-responding { background: rgba(229,72,77,.16); color: var(--emergency); }
.b-onscene { background: rgba(53,198,107,.16); color: var(--online); }
.io-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0 .5rem; }
.io-h { font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1.1rem 0 .5rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.io-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.io-actions .btn { width: auto; flex: 1 1 auto; }
.io-closed-note { margin: .2rem 0 0; padding: .6rem .8rem; font-size: .86rem; color: var(--online); background: rgba(61,220,132,.10); border: 1px solid rgba(61,220,132,.35); border-radius: var(--radius-sm); }
.responder { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .7rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; margin-bottom: .4rem; font-size: .9rem; }
.responder-stood { opacity: .55; }
.timeline { display: flex; flex-direction: column; gap: .5rem; max-height: 240px; overflow-y: auto; }
.tl-item { display: flex; gap: .6rem; font-size: .85rem; align-items: baseline; }
.tl-time { color: var(--muted); font-size: .72rem; white-space: nowrap; min-width: 64px; }
.io-note { display: flex; gap: .5rem; margin-top: .7rem; align-items: center; }
.io-note input[name="message"] { flex: 1; min-width: 0; }
.io-note .btn { width: auto; }
.io-note .icon-btn { flex: none; }
#io-note-previews:not(:empty) { margin-top: .5rem; }
.tl-photos { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; }
.tl-photos img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }

/* ---------- Responsive shell ----------
   Mobile: a fixed-height flex column — topbar, the emergency/ID buttons, a
   single scrolling content region, then the bottom nav as a real flex row.
   This avoids viewport-height math (so the map can't be cut off under the nav
   on iOS) and keeps the nav + emergency/ID buttons always visible. */
#app-view { display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; }
.topbar { flex: none; }
#offline-banner, #broadcast-banner, #update-banner { flex: none; }
.app-shell { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.sidebar { display: contents; }
.emergency-button { order: 1; flex: none; }
.idcard-button { order: 2; flex: none; }
#content { order: 3; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: clip; -webkit-overflow-scrolling: touch; }
.tabbar { order: 4; flex: none; }
@media (min-width: 900px) {
  :root { --bottomnav: 0px; }
  #app-view { display: block; height: auto; overflow: visible; }
  .app-shell { display: flex; flex-direction: row; align-items: flex-start; }
  .sidebar {
    display: flex; flex-direction: column; gap: .6rem;
    width: 240px; flex: none; padding: .9rem; order: 0;
    position: sticky; top: 51px; height: calc(100dvh - 51px);
    border-right: 1px solid var(--border); background: var(--surface);
    overflow-y: auto;
  }
  .topbar { position: sticky; top: 0; z-index: 10; }
  .sidebar .emergency-button { border-radius: var(--radius); }
  .sidebar .idcard-button { border-radius: var(--radius); border-top: 1px solid var(--border); }
  .tabbar { position: static; flex-direction: column; background: transparent; border-top: none; gap: .2rem; overflow: visible; box-shadow: none; padding-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .navtab { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; align-items: center; gap: .55rem; text-align: left; font-size: .9rem; padding: .65rem .8rem; border-left: 3px solid transparent; border-radius: 9px; }
  .navtab .nt-ic { font-size: 1.05rem; }
  .navtab.active .nt-ic { transform: none; }
  .navtab .nav-badge { position: static; margin-left: auto; }
  .navtab.active { border-left-color: var(--primary); background: var(--grad-soft); color: var(--text); }
  .navtab.active::before { display: none; }
  #content { order: 0; flex: 1; min-width: 0; overflow-x: clip; overflow-y: visible; }
  .panel { max-width: 840px; padding: 1.5rem; }
  .map-panel { max-width: none; padding: 0; height: auto; }
}
@media (min-width: 1200px) {
  #incident-list { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; align-items: start; }
}

/* ---------- Map ---------- */
/* z-index:0 makes the panel a stacking context so Leaflet's internal layers
   (panes/controls/attribution, z-index up to 1000) stay contained BELOW the
   fixed bottom nav (z-index 40) and can't paint over it. svh (not dvh) keeps
   the map inside the visible viewport so it never pushes under the nav. */
.map-panel { padding: 0; max-width: none; position: relative; z-index: 0; height: 100%; }
#map { width: 100%; height: 100%; min-height: 240px; background: var(--surface); }
@media (min-width: 900px) { #map { height: calc(100svh - 51px); } }
.map-legend { position: absolute; bottom: 12px; left: 12px; z-index: 500; display: flex; flex-wrap: wrap; gap: .5rem .8rem; background: rgba(15,19,23,.92); border: 1px solid var(--border); border-radius: 9px; padding: .5rem .7rem; font-size: .72rem; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.map-legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.patrol-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .72rem; border: 2px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.leaflet-popup-content { font-size: .85rem; line-height: 1.45; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 4px 18px rgba(0,0,0,.5); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-bar a { background: var(--surface); color: var(--text); border-bottom-color: var(--border); }
.leaflet-bar a:hover { background: var(--surface-2); }
.leaflet-control-attribution { background: rgba(15,19,23,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

/* ---------- Push-to-talk ---------- */
.ptt-btn {
  position: fixed; right: 16px; bottom: calc(16px + var(--bottomnav) + env(safe-area-inset-bottom)); z-index: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 78px; height: 78px; border-radius: 50%; border: 1px solid var(--border-bright);
  background: var(--primary); color: #fff; font-size: 1.5rem; cursor: pointer;
  box-shadow: var(--shadow); user-select: none; -webkit-user-select: none; touch-action: none;
}
.ptt-btn span { font-size: .56rem; font-weight: 600; color: rgba(255,255,255,.85); }
.ptt-btn:active { transform: scale(.96); }
.ptt-btn.recording { background: var(--emergency); border-color: #fff; animation: pulse 1.1s infinite; }
.ptt-indicator {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 600;
  bottom: calc(106px + var(--bottomnav) + env(safe-area-inset-bottom));
  background: var(--emergency); color: #fff; padding: .45rem 1rem; border-radius: 999px;
  font-size: .8rem; font-weight: 600; box-shadow: var(--shadow);
}

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(1.2rem + var(--bottomnav) + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--surface-2); color: var(--text); border: 1px solid var(--border-bright); padding: .7rem 1.1rem; border-radius: 999px; font-size: .85rem; z-index: 500; box-shadow: var(--shadow); max-width: 90vw; }

/* ---------- Avatars ---------- */
.avatar { display: inline-block; vertical-align: middle; border-radius: 6px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: var(--primary); }
.avatar-sm { width: 28px; height: 28px; font-size: .72rem; }
.avatar-xs { width: 20px; height: 20px; font-size: .58rem; }
.avatar-mini { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; display: block; }
.avatar-xxs { width: 16px; height: 16px; font-size: .5rem; border-radius: 4px; }
.member-id { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.card-title .avatar { margin-right: .2rem; }

/* ---------- Responder ID card ---------- */
.idcard { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); margin-bottom: 1.2rem; box-shadow: var(--shadow); }
.idcard-strip { display: flex; justify-content: space-between; align-items: center; background: var(--primary); color: #fff; font-weight: 600; font-size: .68rem; letter-spacing: .04em; padding: .45rem .8rem; }
.idcard-body { display: flex; gap: .9rem; padding: .9rem; }
.idcard-photo { position: relative; width: 84px; height: 100px; flex: none; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.idcard-avatar { width: 100%; height: 100%; object-fit: cover; display: block; }
.idcard-avatar-initials { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 1.9rem; font-weight: 700; color: var(--primary); }
.idcard-cam { position: absolute; right: 4px; bottom: 4px; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border-bright); background: rgba(15,19,23,.85); color: var(--text); cursor: pointer; font-size: .85rem; }
.idcard-info { flex: 1; min-width: 0; }
.idcard-name { font-size: 1.1rem; font-weight: 650; word-break: break-word; }
.idcard-role { font-size: .72rem; color: var(--primary); margin-top: .15rem; }
.idcard-fields { display: grid; grid-template-columns: auto 1fr; gap: .25rem .7rem; margin: .65rem 0 0; font-size: .78rem; }
.idcard-fields dt { color: var(--muted); }
.idcard-fields dd { margin: 0; color: var(--text); word-break: break-word; }
.idcard-foot { display: flex; justify-content: space-between; align-items: center; gap: .6rem; border-top: 1px solid var(--border); padding: .5rem .8rem; font-family: var(--mono); font-size: .66rem; color: var(--muted); }
.idcard-barcode { flex: 1; max-width: 120px; height: 20px; background: repeating-linear-gradient(90deg, var(--muted) 0 2px, transparent 2px 4px, var(--muted) 4px 5px, transparent 5px 9px); opacity: .4; }

/* Enlarged, read-only ID card for "Show my ID card". */
#mycard-overlay { z-index: 950; }
.mycard-sheet { max-width: 460px; }
.mycard-big { margin-bottom: 0; }
.mycard-big .idcard-strip { font-size: .8rem; padding: .6rem 1rem; }
.mycard-big .idcard-body { gap: 1.2rem; padding: 1.2rem; }
.mycard-big .idcard-photo { width: 120px; height: 144px; }
.mycard-big .idcard-avatar-initials { font-size: 2.8rem; }
.mycard-big .idcard-name { font-size: 1.45rem; }
.mycard-big .idcard-role { font-size: .85rem; }
.mycard-big .idcard-fields { font-size: .9rem; margin-top: .9rem; }
.mycard-big .idcard-foot { font-size: .76rem; padding: .7rem 1rem; }

/* ---------- Segmented toggle (reports views & filters) ---------- */
.roster-toggle { display: flex; gap: .4rem; margin-bottom: .8rem; }
.rtoggle { flex: 1; padding: .5rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); border-radius: 8px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.rtoggle.active { background: var(--primary); color: #fff; border-color: var(--primary); }
/* Remove ✕ on a chip (shift assignees) */
.rchip-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .8rem; padding: 0 .1rem; }
.rchip-x:hover { color: var(--emergency); }
.import-box .hint { font-size: .72rem; }

/* ---------- Comms log ---------- */
.comms-log { display: flex; flex-direction: column; gap: .3rem; max-height: 260px; overflow-y: auto; }
.comms-row { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-size: .8rem; }
.comms-seq { color: var(--muted); font-size: .68rem; font-family: var(--mono); }
.comms-who { flex: 1; color: var(--text); font-weight: 600; }
.comms-time { color: var(--muted); font-size: .7rem; }

/* ---------- Auth capabilities ---------- */
.auth-layout { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; width: 100%; }
.poi-field { display: flex; flex-direction: column; gap: .45rem; width: 100%; max-width: 380px; }
.poi { display: flex; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .5rem .7rem; }
.poi-pin { color: var(--primary); font-size: .8rem; line-height: 1; flex: none; }
.poi-tag { display: none; }
.poi-body { display: flex; flex-direction: column; min-width: 0; }
.poi-text { font-size: .82rem; color: var(--muted); }
@media (min-width: 1000px) {
  .auth-layout { flex-direction: row; justify-content: center; align-items: center; gap: 1.6rem; }
  .poi-field { width: 250px; }
  #poi-left { order: -1; }
}

/* ---------- Help (Manual & FAQ) ---------- */
.help-sheet { max-width: 720px; }

/* Pitch overlay (pre-login sales pitch) */
.pitch-sheet { max-width: 760px; }
.pitch-lead { font-size: 1.02rem; line-height: 1.55; color: var(--text); margin: .2rem 0 .4rem; }
.pitch-grid { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.pitch-card { display: flex; gap: .7rem; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .8rem; }
.pitch-card strong { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .12rem; color: var(--text); }
.pitch-card div { font-size: .82rem; color: var(--muted); line-height: 1.45; }
.pitch-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: .3rem; }
.pitch-table th, .pitch-table td { text-align: left; padding: .5rem .6rem; border: 1px solid var(--border); vertical-align: top; }
.pitch-table th { background: var(--surface-2); font-weight: 700; }
.pitch-table td:first-child { color: var(--muted); }
.pitch-cta { margin-top: 1.4rem; padding: 1.1rem; text-align: center; border-radius: var(--radius); background: var(--grad-soft); border: 1px solid var(--border-bright); }
.pitch-cta p { margin: 0 0 .7rem; font-weight: 700; font-size: 1.02rem; }
.pitch-cta .btn { width: auto; padding-left: 1.6rem; padding-right: 1.6rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.5rem; }
.hero-cta .btn { width: auto; margin-top: 0; }
@media (min-width: 560px) { .pitch-grid { grid-template-columns: 1fr 1fr; } }

.help-list { margin: .3rem 0 .5rem; padding-left: 1.2rem; font-size: .88rem; line-height: 1.5; }
.help-list li { margin: .25rem 0; }
.help-faq dt { font-weight: 600; color: var(--text); margin-top: .7rem; }
.help-faq dd { margin: .15rem 0 0; font-size: .88rem; color: var(--muted); line-height: 1.45; }

/* ---------- Reports: filter bar + drill-down ---------- */
.rep-filter { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: .5rem; }
.rep-filter #rep-q { flex: 1 1 160px; min-width: 140px; }
.rep-date { flex-direction: column; gap: .15rem; font-size: .68rem; }
.rep-date input { padding: .5rem; }
.rep-filter .btn { width: auto; flex: none; padding: .55rem .8rem; }
#rep-count { margin: 0 0 .7rem; }
.rep-drawer { margin: -.3rem 0 .5rem; padding: .5rem .6rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.rep-drawer .comms-log { max-height: 200px; }

/* ---------- Incident trends ---------- */
.trend-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: .4rem; }
.trend-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .4rem; text-align: center; }
.trend-stat b { display: block; font-size: 1.4rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.trend-stat span { font-size: .7rem; color: var(--muted); }
.trend-bars { display: flex; flex-direction: column; gap: .35rem; }
.trend-row { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.trend-label { flex: 0 0 38%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize; }
.trend-bar { flex: 1; height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.trend-bar > span { display: block; height: 100%; border-radius: 999px; min-width: 4px; transition: width .3s ease; }
.trend-val { flex: none; width: 2.2em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 90px; padding: .3rem .1rem 0; border-bottom: 1px solid var(--border); }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 2px; min-width: 0; }
.spark-fill { width: 70%; max-width: 18px; background: var(--grad); border-radius: 3px 3px 0 0; }
.spark-x { font-size: .58rem; color: var(--muted); }
.tl-ai { color: var(--primary); }
.trend-range { margin-bottom: .7rem; }
.spark-hours { gap: 2px; height: 70px; }
.spark-hours .spark-fill { width: 80%; }
.ai-brief { margin-top: .3rem; }
.ai-brief .btn { width: auto; }
.briefing-out { margin-top: .7rem; padding: .8rem .9rem; background: var(--grad-soft); border: 1px solid var(--border-bright); border-radius: var(--radius); font-size: .9rem; line-height: 1.5; white-space: pre-wrap; }
.card[data-patrol] { cursor: pointer; }


/* ---------- UI/UX audit: responsive, touch & a11y ---------- */
img, svg, video { max-width: 100%; }
.card, .panel, #content, .member-id, .topbar-left { min-width: 0; }

/* Comfortable touch targets */
.icon-btn { width: 40px; height: 40px; }
.rchip-x { min-width: 24px; min-height: 24px; }

/* Top bar: brand truncates instead of pushing controls off-screen */
.topbar-left { flex: 1; min-width: 0; }
.topbar-left strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { flex: none; }

/* Narrow phones: tighten the bottom-nav labels so all tabs fit. */
@media (max-width: 380px) { .navtab { font-size: .55rem; } .navtab .nt-ic { font-size: 1.2rem; } }

/* Feed status strip: on narrow phones, keep chips comfortably sized. */
@media (max-width: 420px) { .stat-chip { min-width: calc(33.333% - .34rem); } }

/* Member rows wrap their actions instead of overflowing */
.member { flex-wrap: wrap; row-gap: .5rem; }
.row-actions { flex-wrap: wrap; }
@media (max-width: 540px) {
  .member { flex-direction: column; align-items: stretch; }
  .row-actions { justify-content: flex-start; }
  .row-actions .btn { flex: 1 1 auto; }
}

/* Very small screens: keep pickers usable */
@media (max-width: 380px) { .type-grid, .urgency { grid-template-columns: 1fr 1fr; } }

/* Bottom sheets respect the home-indicator safe area */
.sheet { padding-bottom: calc(1.25rem + env(safe-area-inset-bottom)); }

/* Honour reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .ptt-btn.recording, .emergency-flash, .emergency-button { animation: none; }
  * { scroll-behavior: auto; }
}

/* ---------- Landing / sign-in (sales pitch) ---------- */
#auth-view { display: block; padding: 0; align-items: stretch; justify-content: stretch; }
.landing { min-height: 100dvh; display: flex; flex-direction: column; }

.landing-hero {
  position: relative; padding: 2.6rem 1.5rem 2rem;
  background:
    radial-gradient(800px 380px at 12% -10%, rgba(91,157,255,.26), transparent 60%),
    radial-gradient(700px 360px at 95% 8%, rgba(139,108,255,.20), transparent 60%),
    linear-gradient(180deg, #11161f, var(--bg));
}
.hero-brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; padding: .35rem .7rem .35rem .4rem; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.03); }
.hero-brand img { border-radius: 8px; }
.hero-title { font-size: 2.1rem; line-height: 1.1; font-weight: 800; margin: 1.2rem 0 .6rem; letter-spacing: -.02em; background: linear-gradient(180deg, #fff, #b9c6d6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); font-size: 1rem; max-width: 54ch; margin: 0; line-height: 1.55; }
.hero-features { list-style: none; margin: 1.6rem 0 0; padding: 0; display: grid; gap: .8rem; }
.hero-features li { display: flex; gap: .75rem; align-items: flex-start; }
.hf-ic { flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--grad-soft); border: 1px solid var(--border-bright); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; box-shadow: var(--shadow-sm); }
.hero-features strong { display: block; font-weight: 700; font-size: .92rem; margin-bottom: .1rem; color: var(--text); }
.hero-features div { font-size: .82rem; color: var(--muted); line-height: 1.45; }
.hero-trust { margin: 1.7rem 0 0; font-size: .78rem; color: var(--muted); }

.landing-auth { display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.landing-auth .auth-box { box-shadow: var(--shadow); }
.brand-logo-mobile { display: inline-block; }

@media (min-width: 920px) {
  .landing { display: grid; grid-template-columns: 1.05fr .95fr; }
  .landing-hero { padding: 3.5rem 3rem; display: flex; flex-direction: column; justify-content: center; }
  .hero-title { font-size: 2.6rem; }
  .hero-sub { font-size: 1.05rem; }
  .hero-features { grid-template-columns: 1fr 1fr; gap: .9rem 1.6rem; margin-top: 1.8rem; }
  .landing-auth { background: var(--surface); border-left: 1px solid var(--border); }
  .brand-logo-mobile { display: none; }
}
@media (min-width: 1280px) { .hero-title { font-size: 2.9rem; } .landing-hero { padding: 4rem 4.5rem; } }

/* ---------- Install (Add to Home Screen) prompt ---------- */
.install-btn { width: auto; margin-top: 1.2rem; align-self: flex-start; }
.install-ios { margin-top: 1.2rem; font-size: .84rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .65rem .85rem; display: inline-block; }

/* ---------- Patrol track banner ---------- */
.track-banner { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 500; display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: rgba(15,19,23,.92); border: 1px solid var(--border-bright); border-radius: var(--radius); padding: .5rem .7rem; font-size: .82rem; }
.track-banner .btn { width: auto; flex: none; padding: .4rem .7rem; font-size: .78rem; }

/* ---------------------------------------------------------------------------
   Touch-friendly layer — patrollers use phones/tablets in the field, office
   staff use PCs. On touch devices (coarse pointer) we grow tap targets to a
   comfortable minimum (~44px) and kill the tap delay; mouse/PC keeps the
   compact sizing above.
   --------------------------------------------------------------------------- */
button, a, label, summary, input[type="checkbox"], input[type="radio"], select {
  touch-action: manipulation;
}
* { -webkit-tap-highlight-color: rgba(76,141,255,.2); }

@media (pointer: coarse) {
  .btn { min-height: 46px; padding: .8rem 1rem; }
  .card-actions .btn { min-height: 44px; padding: .6rem .9rem; font-size: .88rem; }
  .track-banner .btn { min-height: 40px; }
  .icon-btn { width: 46px; height: 46px; font-size: 1.15rem; }
  .navtab { min-height: 54px; padding: .45rem .15rem; }
  .tab { min-height: 46px; }
  .type-btn { min-height: 50px; padding: .75rem .7rem; font-size: .9rem; }
  .u-opt { min-height: 48px; }
  .checkbox { min-height: 44px; align-items: center; }
  .checkbox input, .u-opt input { transform: scale(1.3); }
  .rtoggle { min-height: 46px; }
  .rchip-x { font-size: 1rem; padding: .2rem .4rem; }
  .newshift summary { min-height: 44px; display: flex; align-items: center; }
  .idcard-cam { width: 38px; height: 38px; font-size: 1rem; }
  .photo-thumb button { width: 30px; height: 30px; font-size: .95rem; }
  /* Inline text actions get a finger-sized hit area without changing layout. */
  .link-btn { padding: .5rem 0; min-height: 40px; display: inline-flex; align-items: center; }
  select, input, textarea { min-height: 46px; }
  textarea { min-height: 90px; }
}
