/* FireBuddy components. Opt-in: a page sets {% block body_class %}fb-converted{% endblock %}.
   Unconverted pages are not affected except by the .fb-* classes they never use and the
   legacy helpers at the bottom (moved verbatim from base.html). */

/* .fb-btn { display: inline-flex } would otherwise beat the user-agent [hidden] rule. */
[hidden] {
  display: none !important;
}

/* ---------- Converted page base: centered, v0.2 type scale (16px rem, 17px body, 700 max weight) ---------- */
html:has(body.fb-converted) { font-size: var(--fb-text-base-px); }
body.fb-converted {
  font-family: var(--fb-font-body);
  font-size: var(--fb-text-body-px);
  line-height: 1.5;
}
body.fb-converted h1, body.fb-converted .fb-h1 { font-size: var(--fb-text-xl); font-weight: 700; line-height: 1.2; }
body.fb-converted h2, body.fb-converted .fb-h2 { font-size: var(--fb-text-lg); font-weight: 700; line-height: 1.25; }
body.fb-converted h3 { font-size: 1.1rem; font-weight: 600; }
body.fb-converted a:not(.fb-btn):not(.nav-item):not(.fb-user-chip) { color: var(--fb-accent); text-underline-offset: 3px; }
body.fb-converted :focus-visible { outline: 3px solid var(--fb-focus); outline-offset: 2px; }

/* ---------- Layout ---------- */
.fb-main {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--fb-space-5) var(--fb-space-4) var(--fb-space-7);
}
.fb-legacy-wrap { max-width: 64rem; margin: 0 auto; padding: 1.5rem 1rem; }
.fb-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--fb-space-4);
  margin-bottom: var(--fb-space-5);
}
.fb-page-head:empty { display: none; margin: 0; }
.fb-page-head--center { flex-direction: column; text-align: center; justify-content: center; }
.fb-page-actions { display: flex; flex-wrap: wrap; gap: var(--fb-space-3); }
@media (max-width: 640px) {
  .fb-page-actions { width: 100%; }
  .fb-page-actions > .fb-btn { flex: 1 1 100%; }
}
.fb-stack > * + * { margin-top: var(--fb-space-5); }
.fb-grid { display: grid; gap: var(--fb-space-5); grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.fb-center { text-align: center; margin-left: auto; margin-right: auto; }

/* ---------- Header ---------- */
.fb-header {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; gap: var(--fb-space-3);
  padding: calc(var(--fb-space-3) + env(safe-area-inset-top, 0px)) var(--fb-space-4) var(--fb-space-3);
  background: var(--fb-surface);
  border-bottom: 1px solid var(--fb-border);
}
.fb-logo { height: 40px; width: auto; max-width: 180px; object-fit: contain; }
.fb-logo--plate { background: var(--fb-ink); border-radius: 10px; padding: 4px 8px; }
.fb-header .fb-wordmark { font-weight: 700; font-size: 1.35rem; letter-spacing: 0.02em; }

/* ---------- Buttons ---------- */
.fb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--fb-space-2);
  min-height: var(--fb-tap-min);
  min-width: var(--fb-tap-min);
  padding: 0 var(--fb-space-5);
  border-radius: var(--fb-radius);
  font-size: 1.05rem; font-weight: 700; line-height: 1.1;
  text-decoration: none; cursor: pointer;
  border: 2px solid transparent;
  transition: filter .15s ease;
}
.fb-btn:hover { filter: brightness(1.08); }
.fb-btn:focus-visible { outline: 3px solid var(--fb-focus); outline-offset: 2px; }
.fb-btn[disabled], .fb-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
.fb-btn-primary { background: var(--fb-primary); color: var(--fb-on-primary); }
.fb-btn-secondary { background: var(--fb-surface); color: var(--fb-text); border-color: var(--fb-border); }
.fb-btn-danger { background: transparent; color: var(--fb-danger); border-color: var(--fb-danger); }
.fb-btn-danger:hover { background: var(--fb-danger); color: #121417; }
.fb-btn-ghost { background: transparent; color: var(--fb-text); }
.fb-btn-block { width: 100%; }

/* ---------- Forms ---------- */
.fb-field { display: flex; flex-direction: column; gap: var(--fb-space-2); margin-bottom: var(--fb-space-4); }
.fb-label { color: var(--fb-text-muted); font-size: var(--fb-text-sm); font-weight: 600; }
.fb-help { color: var(--fb-text-muted); font-size: var(--fb-text-sm); }
.fb-error { color: var(--fb-danger); font-size: var(--fb-text-sm); font-weight: 600; }
.fb-input, .fb-select, .fb-textarea {
  width: 100%;
  min-height: var(--fb-tap-min);
  padding: var(--fb-space-3) var(--fb-space-4);
  background: var(--fb-surface);
  color: var(--fb-text);
  border: 2px solid var(--fb-border);
  border-radius: var(--fb-radius);
  font-size: max(1rem, 17px);      /* never below 16px: stops iOS zoom */
}
.fb-textarea { min-height: 8rem; }
.fb-input:focus, .fb-select:focus, .fb-textarea:focus { outline: none; border-color: var(--fb-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fb-focus) 35%, transparent); }
.fb-input[aria-invalid="true"], .fb-select[aria-invalid="true"], .fb-textarea[aria-invalid="true"] { border-color: var(--fb-danger); }
.fb-check { display: inline-flex; align-items: center; gap: var(--fb-space-3); min-height: var(--fb-tap-min); cursor: pointer; }
.fb-check input { width: 28px; height: 28px; accent-color: var(--fb-primary); }

/* ---------- Cards ---------- */
.fb-card {
  background: var(--fb-surface);
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius);
  padding: var(--fb-space-5);
}
.fb-card--accent { border-left: 6px solid var(--fb-primary); }
.fb-card--link { display: block; color: inherit; text-decoration: none; }
.fb-card--link:hover { border-color: var(--fb-accent); }
.fb-stat { text-align: center; }
.fb-stat__value { font-size: var(--fb-text-2xl); font-weight: 700; line-height: 1; }
.fb-stat__label { color: var(--fb-text-muted); font-size: var(--fb-text-sm); margin-top: var(--fb-space-2); }

/* ---------- Tables ---------- */
.fb-table-wrap { width: 100%; overflow-x: auto; border-radius: var(--fb-radius); border: 1px solid var(--fb-border); }
.fb-table { width: 100%; border-collapse: collapse; }
.fb-table th {
  text-align: left; color: var(--fb-text-muted);
  font-size: var(--fb-text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: var(--fb-space-3) var(--fb-space-4);
  background: var(--fb-surface);
}
.fb-table td { padding: var(--fb-space-4); border-top: 1px solid var(--fb-border); }
.fb-table tr.fb-row-link { cursor: pointer; }
.fb-table tr.fb-row-link td { height: var(--fb-tap-min); }
.fb-table tr.fb-row-link:hover td { background: var(--fb-surface-2); }
@media (max-width: 640px) {
  .fb-table--stack thead { display: none; }
  .fb-table--stack tr { display: block; border-top: 1px solid var(--fb-border); padding: var(--fb-space-3) 0; }
  .fb-table--stack td { display: flex; justify-content: space-between; border: 0; padding: var(--fb-space-2) var(--fb-space-4); }
  .fb-table--stack td::before { content: attr(data-label); color: var(--fb-text-muted); font-weight: 600; margin-right: var(--fb-space-3); }
}

/* ---------- Badges & alerts ---------- */
.fb-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 9999px; font-size: var(--fb-text-sm); font-weight: 700; border: 1px solid currentColor; }
.fb-badge--live { color: var(--fb-danger); }
.fb-badge--warning { color: var(--fb-warning); }
.fb-badge--success { color: var(--fb-success); }
.fb-badge--muted { color: var(--fb-text-muted); }
.fb-badge--accent { color: var(--fb-accent); }
.fb-flash { display: flex; flex-direction: column; gap: var(--fb-space-3); margin-bottom: var(--fb-space-4); }
.fb-alert { display: flex; gap: var(--fb-space-3); align-items: flex-start; padding: var(--fb-space-4); border-radius: var(--fb-radius); border: 2px solid; background: var(--fb-surface); font-weight: 600; }
.fb-alert--success { border-color: var(--fb-success); }
.fb-alert--warning { border-color: var(--fb-warning); }
.fb-alert--danger  { border-color: var(--fb-danger); }
.fb-alert--info    { border-color: var(--fb-accent); }

/* ---------- Setup wizard progress (districts/setup) ---------- */
.fb-progress {
  height: 12px;
  background: var(--fb-surface-2);
  border: 1px solid var(--fb-border);
  border-radius: 999px;
  overflow: hidden;
}
.fb-progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--fb-primary);
}
.fb-setup-map {
  height: 380px;
  border-radius: var(--fb-radius);
  border: 1px solid var(--fb-border);
  background: var(--fb-bg);
}
.fb-setup-map .leaflet-control-zoom a {
  width: max(48px, var(--fb-tap-min)) !important;
  height: max(48px, var(--fb-tap-min)) !important;
  line-height: max(48px, var(--fb-tap-min)) !important;
  min-width: 48px;
  min-height: 48px;
}
.fb-setup-step[hidden],
.fb-track-units[hidden] { display: none !important; }
.fb-review { display: grid; gap: var(--fb-space-3); }
.fb-review div { display: flex; justify-content: space-between; gap: var(--fb-space-4); min-height: var(--fb-tap-min); align-items: center; }
.fb-review dt { color: var(--fb-text-muted); }
.fb-review dd { margin: 0; text-align: right; }

/* ---------- Legacy helpers (moved from base.html; delete in the final legacy sweep) ---------- */
.accent-bar { border-left: 4px solid var(--module-accent); }
.btn-accent { background-color: var(--module-accent); color: white; }
.btn-accent:hover { background-color: var(--module-accent-hover); }
.text-accent { color: var(--module-accent); }
.border-accent { border-color: var(--module-accent); }
.bg-accent-soft { background-color: color-mix(in srgb, var(--module-accent) 15%, transparent); }

/* ---------- Operations header (chunk 1): title row, Sections, Reports & tools ----------
   Same surfaces as the old ops tiles (primary orange, surface chips, 16px radius).
   Header controls are 56px. The call list and search are unchanged. */
.fb-ops-tools {
  display: flex; flex-direction: column; gap: 8px;
  margin: 0 0 32px; position: relative; min-width: 0; max-width: 100%;
}
.fb-ops-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.fb-ops-brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 12rem; }
.fb-ops-mark {
  width: 48px; height: 48px; flex: none; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgb(249 115 22 / 0.2); color: #fb923c; font-size: 20px;
}
.fb-ops-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
@media (min-width: 640px) { .fb-ops-title { font-size: 1.875rem; } }
.fb-ops-sub { font-size: 12px; color: #A1A1AA; margin-top: 2px; }
.fb-ops-start, .fb-ops-menu-btn, .fb-ops-tools .fb-ops-tool {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; min-width: 0; max-width: 100%; box-sizing: border-box;
  padding: 8px 16px; border-radius: 16px;
  font: inherit; font-weight: 700; font-size: 1.05rem; line-height: 1.2;
  text-align: center; text-decoration: none; cursor: pointer;
}
.fb-ops-start {
  flex: 0 1 auto; margin-left: auto;
  background: var(--fb-primary); color: var(--fb-on-primary); border: 2px solid var(--fb-primary);
  white-space: nowrap;
}
.fb-ops-start i { color: inherit; }
.fb-ops-menus { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; align-items: flex-start; }
.fb-ops-details { flex: 1 1 12rem; min-width: 0; max-width: 100%; }
.fb-ops-menu-btn {
  width: 100%; list-style: none;
  background: var(--fb-surface); color: var(--fb-text); border: 2px solid var(--fb-border);
}
.fb-ops-menu-btn::-webkit-details-marker { display: none; }
.fb-ops-menu-btn::marker { content: ""; }
.fb-ops-details[open] > .fb-ops-panel {
  display: flex; flex-direction: column; gap: 8px;
  margin: 8px 0 0; padding: 8px; box-sizing: border-box;
  background: var(--fb-chrome); color: var(--fb-text);
  border: 2px solid var(--fb-border); border-radius: 16px;
  max-width: 100%;
}
.fb-ops-tools .fb-ops-tool {
  width: 100%; justify-content: flex-start; text-align: left;
  background: var(--fb-surface); color: var(--fb-text); border: 2px solid var(--fb-border);
  white-space: normal; overflow-wrap: normal; word-break: normal;
}
.fb-ops-tools .fb-ops-tool span { overflow-wrap: normal; word-break: normal; }
.fb-ops-tools .fb-ops-tool[aria-current="page"] {
  border-color: var(--fb-nav-ops);
  box-shadow: inset 4px 0 0 var(--fb-nav-ops);
}
.fb-ops-tool:hover, .fb-ops-menu-btn:hover { border-color: var(--fb-nav-ops); }
.fb-ops-tool i { color: var(--fb-accent-text); }
.fb-ops-start:focus-visible,
.fb-ops-menu-btn:focus-visible,
.fb-ops-tool:focus-visible {
  outline: 3px solid var(--fb-focus); outline-offset: 2px;
}
@media (min-width: 1024px) {
  .fb-ops-details--sections { flex-basis: 100%; }
  #fb-ops-sections-btn { display: none; }
  .fb-ops-details--sections > #fb-ops-sections {
    display: flex !important; flex-direction: row; flex-wrap: wrap; gap: 8px;
    margin: 0; padding: 0; background: transparent; border: 0;
  }
  #fb-ops-sections .fb-ops-tool {
    width: auto; flex: 1 1 9rem; max-width: 100%; justify-content: center; text-align: center;
  }
}
/* Signed-in person (Benjamin, Oct 16): slim top-right chip. The link is a 48px-tall tap area; the
   visible pill inside is 32px, v0.2 nav chrome + thin gold rim, 13px/600 text. Scrolls with the page. */
.fb-user-chip {
    position: absolute; z-index: 30;
    top: env(safe-area-inset-top, 0px);
    right: max(4px, env(safe-area-inset-right, 0px));
    min-height: 48px; min-width: 48px; padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none; color: #F4EDE4;
}
.fb-user-chip__pill {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; max-width: 9.5rem;
    padding: 0 10px 0 4px; border-radius: 9999px;
    background: var(--fb-nav-chrome);
    border: 1px solid color-mix(in srgb, var(--fb-nav-home) 55%, var(--fb-nav-edge));
    font-size: 13px; font-weight: 600; line-height: 1;
}
.fb-user-chip__dot {
    width: 24px; height: 24px; flex: none; border-radius: 9999px; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--fb-nav-home) 22%, var(--fb-nav-base)); color: var(--fb-nav-home); font-size: 12px; font-weight: 700;
}
.fb-user-chip__dot img { width: 100%; height: 100%; object-fit: cover; }
.fb-user-chip__name { color: #F4EDE4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-user-chip:focus-visible { outline: 3px solid var(--fb-focus); outline-offset: -2px; border-radius: 9999px; }
@media print { .fb-user-chip { display: none !important; } }
/* Reserve a slim 44px strip at the top so the chip never sits on a page title or header button. */
body:has(> .fb-user-chip, .fb-user-chip) { padding-top: calc(44px + env(safe-area-inset-top, 0px)); }
#fb-profile-initial { font-size: 12px; font-weight: 700; line-height: 1; }
/* Chip moved into the header row (auth/_chip.html): inline after Edit map / Back, 56px tap area,
   48px pill = same height as the header buttons, vertically centered; no reserved top strip. */
body.fb-chip-inline { padding-top: env(safe-area-inset-top, 0px); }
.fb-user-chip.fb-user-chip--inline { position: static; min-height: 56px; min-width: 56px; padding: 0; flex: none; }
.fb-user-chip--inline .fb-user-chip__pill { height: 48px; padding: 0 14px 0 8px; gap: 8px; border-radius: 12px; font-size: 14px; }
.fb-user-chip--inline .fb-user-chip__dot { width: 32px; height: 32px; }
.fb-backbar .fb-user-chip--inline, .fb-page-head > .fb-user-chip--inline { margin-left: auto; }
.fb-home-head__actions { align-items: center; flex-wrap: wrap; }
.fb-home-head__actions .fb-user-chip--inline { margin-left: 0; }
/* Phones: icon-only chip so it fits the header row. */
@media (max-width: 479px) {
  .fb-user-chip--inline .fb-user-chip__name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fb-user-chip--inline .fb-user-chip__pill { padding: 0 8px; }
}
.fb-mode-btn { min-height: var(--fb-tap-min); border-radius: var(--fb-radius); border: 2px solid var(--fb-border); background: var(--fb-surface-2); color: var(--fb-text); font-weight: 700; font-size: 1.05rem; }
.fb-mode-btn[aria-pressed="true"] { background: var(--fb-primary); color: var(--fb-on-primary); border-color: var(--fb-primary); }

/* ---------- Live number row, modal, list rows (shared; first used by Home) ---------- */
.fb-main:has(.fb-wide) { max-width: 80rem; }
.fb-stat-row {
  display: grid;
  gap: var(--fb-space-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: var(--fb-space-3);
}
/* Five tiles: 2+2+1 on phones (last tile spans the row), one row of five on desktop. */
/* v0.2 restore B: 2 / 3 (>=768) / 5 (>=1024) columns, gap 16, 5th card does not span. */
/* Narrow phones (< 375px): one card per row so 12px labels like APPARATUS never spill past the card. */
/* Six tiles (Tasks added): 2x3 on phones, 3x2 from 768px, one row of six from 1200px. */
@media (max-width: 374px) { .fb-stat-row { gap: 8px; } }
@media (min-width: 768px) { .fb-stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .fb-stat-row { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.fb-stat-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--fb-space-1);
  min-height: 76px; /* vault density: ~72-88px on phones, still a 48px+ tap target */
  padding: var(--fb-space-2) var(--fb-space-3);
  background: var(--fb-surface);
  color: var(--fb-text);
  border: 2px solid var(--fb-border);
  border-radius: var(--fb-radius);
  text-align: center;
  cursor: pointer;
  font: inherit;
  width: 100%;
}
.fb-stat-tile:hover { border-color: var(--fb-accent); }
.fb-stat-tile:focus-visible { outline: 3px solid var(--fb-focus); outline-offset: 2px; }
.fb-stat-tile__value { font-size: var(--fb-text-2xl); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.fb-stat-tile__label { font-size: var(--fb-text-md); font-weight: 700; color: var(--fb-text); }
.fb-stat-tile--live { border-color: var(--fb-live-hot); }
.fb-stat-tile--live .fb-stat-tile__value { color: var(--fb-live-hot); }
/* v0.2 restore B: KPI cards exactly like v0.2 Home — flat dark card, thin colored border (40%),
   44px tinted icon chip on the left, small UPPERCASE muted label above a 36px colored number. */
.fb-stat-tile[data-kpi] {
  --kpi: var(--fb-accent);
  flex-direction: row; justify-content: flex-start; align-items: center; gap: 12px; text-align: left;
  min-height: 0; padding: 20px; border-radius: 16px;
  background: var(--fb-surface);
  border: 1px solid color-mix(in srgb, var(--kpi) 40%, transparent);
  box-shadow: none;
}
.fb-stat-tile[data-kpi]:hover { border-color: var(--kpi); }
/* 2-column phones (375-479px): a little less padding/gap so 12px labels like PERSONNEL fit even with
   wider fallback fonts (DejaVu/Liberation on Linux/Android CI), instead of spilling past the text column. */
@media (max-width: 479px) { .fb-stat-tile[data-kpi] { padding: 16px 14px; gap: 10px; } }
.fb-stat-tile[data-kpi]:active { transform: scale(0.98); }
.fb-stat-tile__text { display: flex; flex-direction: column; min-width: 0; }
.fb-stat-tile[data-kpi] .fb-stat-tile__label { order: -1; color: #A1A1AA; font-size: 12px; font-weight: 400; line-height: 16px; text-transform: uppercase; letter-spacing: 0.025em; }
.fb-stat-tile[data-kpi] .fb-stat-tile__value { color: var(--kpi); font-size: 36px; font-weight: 700; line-height: 40px; }
.fb-stat-tile__icon {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  background: color-mix(in srgb, var(--kpi, var(--fb-accent)) 15%, transparent);
  color: var(--kpi, var(--fb-accent)); font-size: 20px;
}
.fb-stat-tile[data-kpi="stations"] { --kpi: var(--fb-kpi-stations); }
.fb-stat-tile[data-kpi="apparatus"] { --kpi: var(--fb-kpi-apparatus); }
.fb-stat-tile[data-kpi="personnel"] { --kpi: var(--fb-kpi-personnel); }
.fb-stat-tile[data-kpi="incidents"] { --kpi: var(--fb-kpi-incidents); }
.fb-stat-tile[data-kpi="burns"] { --kpi: var(--fb-kpi-burns); }
.fb-stat-tile[data-kpi="tasks"] { --kpi: var(--fb-nav-tasks); }
/* 360px phones: 2 columns of six tiles; slimmer padding/icon so 12px labels stay inside the card. */
@media (max-width: 374px) {
  .fb-stat-tile[data-kpi] { padding: 12px 10px; gap: 8px; }
  .fb-stat-tile[data-kpi] .fb-stat-tile__icon { width: 36px; height: 36px; font-size: 16px; }
}
.fb-stat-tile[data-kpi] .fb-stat-tile__label { overflow-wrap: anywhere; }
/* Bright/Night map control (fb_map.js). 48px tall, solid face, readable on any basemap. */
.leaflet-control.fb-map-style-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 48px; min-width: 48px; padding: 0 0.85rem;
  background: var(--fb-chrome, #2B2E33); color: var(--fb-ink, #F4EDE4);
  border: 2px solid color-mix(in srgb, var(--fb-ink, #F4EDE4) 35%, transparent);
  border-radius: 12px; font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
}
.leaflet-control.fb-map-style-btn[data-map-style="bright"] i { color: #F59E0B; }
.leaflet-control.fb-map-style-btn:focus-visible { outline: 3px solid var(--fb-focus, #FBBF24); outline-offset: 2px; }
.fb-live-status { text-align: center; color: var(--fb-text-muted); font-size: var(--fb-text-sm); margin: 0 0 var(--fb-space-4); min-height: 1.5em; }
.fb-live-status[data-state="offline"] { color: var(--fb-warning); font-weight: 700; }
.fb-map-frame {
  background: var(--fb-surface);
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius);
  padding: var(--fb-space-2);
  position: relative; z-index: 0; overflow: hidden;
}
.fb-map-frame .fb-map { width: 100%; height: 60vh; min-height: 320px; max-height: 640px; border-radius: calc(var(--fb-radius) - 4px); }
.fb-legend { display: flex; flex-wrap: wrap; gap: var(--fb-space-2); justify-content: center; margin-top: var(--fb-space-3); color: var(--fb-text-muted); font-size: var(--fb-text-sm); }
.fb-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
  padding: var(--fb-space-4);
  background: var(--fb-overlay);
}
.fb-modal.flex, .fb-modal:not(.hidden) { display: flex; }
/* Popups clear the floating bottom nav: --fb-nav-clear = nav height + 8px gap (measured in base.html,
   safe-area included). CSS fallback before the measure. Body scrolls inside; head/foot stay visible. */
body:has(nav.fb-bottom-nav) { --fb-nav-clear: calc(92px + env(safe-area-inset-bottom, 0px)); }
.fb-modal { padding-bottom: calc(var(--fb-nav-clear, 0px) + var(--fb-space-2)); }
.fb-modal__head, .fb-modal__foot { flex: none; }
.fb-modal__panel {
  width: 100%; max-width: 42rem; max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--fb-bg); color: var(--fb-text);
  border: 1px solid var(--fb-border); border-radius: var(--fb-radius);
}
.fb-modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--fb-space-3); padding: var(--fb-space-4) var(--fb-space-5); border-bottom: 1px solid var(--fb-border); }
.fb-modal__body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--fb-space-4) var(--fb-space-5); }
.fb-modal__body > * + * { margin-top: var(--fb-space-3); }
.fb-modal__foot { display: flex; flex-wrap: wrap; gap: var(--fb-space-3); padding: var(--fb-space-4) var(--fb-space-5); border-top: 1px solid var(--fb-border); }
.fb-modal__foot > * { flex: 1 1 10rem; }
.fb-list-item {
  display: flex; justify-content: space-between; align-items: center; gap: var(--fb-space-3);
  min-height: var(--fb-tap-min);
  padding: var(--fb-space-3) var(--fb-space-4);
  background: var(--fb-surface); color: var(--fb-text);
  border: 1px solid var(--fb-border); border-radius: calc(var(--fb-radius) - 4px);
  text-decoration: none; cursor: pointer;
}
.fb-list-item:hover { border-color: var(--fb-accent); }

/* ======================================================================
   App shell (v0.3): bottom nav (#58 five-button version), pinning, back bar.
   Moved from the inline <style> in app/templates/base.html. Nav colors come
   from the fixed --fb-nav-* tokens in tokens.css; /theme.css never rewrites them.
   ====================================================================== */
/* v0.2 restore C: the v0.2 floating nav, verbatim sizes — centered gold-rimmed face (max 40rem),
   48px glowing icon wells, small uppercase labels, 5 buttons, Ops in the middle (Map, Resources, Ops, Tasks, More); person = top-right chip. */
.fb-nav-face {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    gap: 0.2rem;
    max-width: 40rem;
    margin: 0 auto;
    padding: 0.5rem 0.4rem 0.4rem;
    border-radius: 1.15rem;
    background: var(--fb-nav-chrome);
    border: 1.5px solid color-mix(in srgb, var(--fb-nav-home) 72%, var(--fb-nav-edge));
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 color-mix(in srgb, var(--fb-nav-home) 28%, transparent),
        inset 0 -10px 18px rgba(0, 0, 0, 0.28);
}
.nav-item {
    position: relative;
    flex: 1;
    min-width: 0;
    color: var(--fb-nav);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-item[data-nav="districts"] { --fb-nav: var(--fb-nav-home); }
.nav-item[data-nav="ops"]       { --fb-nav: var(--fb-nav-ops); }
.nav-item[data-nav="resources"] { --fb-nav: var(--fb-nav-res); }
.nav-item[data-nav="tasks"]     { --fb-nav: var(--fb-nav-tasks); }
.nav-item[data-nav="more"]      { --fb-nav: var(--fb-nav-more); }
.nav-well {
    width: 48px;
    height: 48px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0.8rem;
    border: 1.5px solid color-mix(in srgb, var(--fb-nav) 85%, var(--fb-nav-black));
    background: color-mix(in srgb, var(--fb-nav) 12%, var(--fb-nav-base));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 0 10px color-mix(in srgb, var(--fb-nav) 22%, transparent);
}
.nav-well i {
    font-size: 1.35rem;
    line-height: 1;
    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--fb-nav) 55%, transparent));
}
.nav-label {
    display: block;
    margin-top: 0.28rem;
    font-size: 0.75rem;  /* readable-text rule (Benjamin, Oct 16): >= 12px, overrides v0.2's 0.62rem */
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
}
/* Ops label text is lightened to >= 4.5:1 on the face; the icon keeps v0.2 #E85D04. */
.nav-item[data-nav="ops"] .nav-label { color: var(--fb-nav-ops-text); }
.nav-item:hover { transform: scale(1.06); }
.nav-item:focus-visible { outline: 3px solid var(--fb-focus); outline-offset: 2px; border-radius: 0.8rem; }
.nav-item.active .nav-well {
    background: color-mix(in srgb, var(--fb-nav) 26%, var(--fb-nav-base));
    box-shadow:
        inset 0 0 0 1px color-mix(in srgb, var(--fb-nav) 55%, transparent),
        0 0 16px color-mix(in srgb, var(--fb-nav) 50%, transparent);
}
.nav-item.active::before {
    content: "";
    position: absolute;
    top: -0.28rem;
    left: 50%;
    width: 1.15rem;
    height: 3px;
    margin-left: -0.575rem;
    border-radius: 9999px;
    background: var(--fb-nav);
}
/* 48px tap floor (Benjamin, Oct 16): every nav button is a >= 48x48 clickable area. v0.2 sizes
   already meet it above 360px; at <= 360px the floating bar spans nearly full width (4px side
   margins), the face padding and gaps shrink, and label tracking tightens. Same gold face. */
.nav-item { min-width: 48px; min-height: 48px; }
html {
    scrollbar-gutter: stable both-edges;
    height: 100%;
}
/* ---------- Pinned bottom nav (iPhone / iPad / Android) ---------- */
html, body {
    min-height: 100%;
    min-height: 100dvh;
    overscroll-behavior-y: none;
}
body {
    font-size: 17px;
    /* Pad every page so nothing hides under the pinned nav. */
    padding-bottom: calc(7rem + env(safe-area-inset-bottom, 0px));
}
nav.fb-bottom-nav {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    margin: 0;
    padding: 0.45rem 0.6rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    padding-left: max(0.6rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.6rem, env(safe-area-inset-right, 0px));
    background: transparent !important;
    border-top: 0 !important;
    z-index: 20000 !important;
    isolation: isolate;
    /* Own layer so iOS Safari does not scroll it with the page */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
nav.fixed,
nav.fixed.bottom-0 { z-index: 20000 !important; isolation: isolate; }
/* <= 440px: six 12px labels need the width. The floating gold bar spans nearly full width
   (4px margins), buttons size to their label (Resources gets more room, never < 48px), no gaps,
   tighter tracking. Everything stays inside the gold rim; no label is clipped. */
@media (max-width: 440px) {
    html { scrollbar-gutter: auto; scrollbar-width: none; }  /* phones use overlay scrollbars; never let a desktop gutter eat nav width */
    nav.fb-bottom-nav { padding-left: max(4px, env(safe-area-inset-left, 0px)); padding-right: max(4px, env(safe-area-inset-right, 0px)); }
    .fb-nav-face { gap: 0; padding: 0.4rem 2px 0.35rem; justify-content: space-between; }
    .nav-item { flex: 1 1 auto; }
    .nav-label { letter-spacing: 0; }
}
@media (max-width: 340px) {
    .fb-nav-face { padding-left: 0; padding-right: 0; }
    .nav-label { font-size: 12px; letter-spacing: -0.02em; }
}

@media (hover: none) {
    .nav-item:hover { transform: none; }
}

/* Leaflet panes are 200–1000 and would cover the nav.
   Keep every map in its own stacking context; nav is always on top. */
#district-map,
.leaflet-container {
    isolation: isolate;
    z-index: 0 !important;
}

.fb-backbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
}
.fb-backbar a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
    padding: 0 16px;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
}
.fb-backbar a.fb-back {
    background: var(--fb-primary);
    color: var(--fb-on-primary);
}
.fb-backbar a.fb-back-section {
    background: transparent;
    color: var(--fb-accent);
    border: 2px solid var(--fb-accent);
}
body.fb-converted .fb-backbar a.fb-back {
    color: var(--fb-on-primary);
    text-decoration: none;
}
body.fb-converted .fb-backbar a.fb-back-section {
    color: var(--fb-accent);
    text-decoration: none;
}
@media print {
    .fb-backbar { display: none !important; }
}

/* ---------- v0.2 restore D: More page in the v0.2 look (cd67cee more/index.html) ----------
   Left-aligned header with a violet chip, v0.2 cards (zinc-900, colored 40% border, 48px icon chip
   on top, bold 18px title, 12px muted blurb), 1/2/3/4 columns. Grouping + search kept (additions). */
.fb-more__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 32px; }
.fb-more__brand { display: flex; align-items: center; gap: 12px; }
.fb-more__chip { width: 48px; height: 48px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; background: rgb(139 92 246 / 0.2); color: #A78BFA; font-size: 20px; }
.fb-more__title { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; line-height: 32px; }
@media (min-width: 640px) { .fb-more__title { font-size: 30px; line-height: 36px; } }
.fb-more__sub { font-size: 12px; color: #A1A1AA; margin-top: 2px; }
.fb-more__find {
    display: flex; align-items: center; gap: 8px; width: 100%; max-width: 20rem; min-height: 50px;
    padding: 0 12px; border-radius: 12px; background: #18181B; border: 1px solid #27272A; color: #71717A;
}
.fb-more__find input { flex: 1; min-width: 0; min-height: 48px; background: transparent; border: 0; outline: 0; color: var(--fb-text); font-size: 16px; }
.fb-more__find:focus-within { border-color: #A78BFA; }
.fb-more__group { margin-top: 24px; }
.fb-more__group:first-of-type { margin-top: 0; }
.fb-more__group-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #A1A1AA; margin-bottom: 12px; }
.fb-more__group-title i { font-size: 12px; }
.fb-more__grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .fb-more__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .fb-more__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .fb-more__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.fb-more-tile {
    display: block; padding: 24px; border-radius: 16px; border-width: 1px; border-style: solid;
    background: #18181B; color: var(--fb-text); text-decoration: none;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.fb-more-tile:hover { transform: translateY(-2px); }
.fb-more-tile[hidden], .fb-more__group[hidden] { display: none; }
body.fb-converted a.fb-more-tile { color: var(--fb-text); }
.fb-more-tile__icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.fb-more-tile__icon i { font-size: 24px; }
.fb-more-tile__text { display: block; }
.fb-more-tile__label { display: block; font-size: 18px; font-weight: 700; line-height: 28px; }
.fb-more-tile__blurb { display: block; font-size: 12px; color: #A1A1AA; margin-top: 4px; line-height: 16px; }
.fb-more__none { text-align: center; font-size: 16px; color: #A1A1AA; margin-top: 24px; }

/* ---------- v0.3 compact Home (vault density) ----------
   Less bloat from the fb-converted scale: tighter sections, a compact header bar, smaller
   KPI cards, and the space goes to the map. Body text stays >= 16px, taps >= 48px. */
/* v0.2 restore B: Home header, KPI grid and map frame as in v0.2 (cd67cee). */
.fb-main:has(.fb-home) { padding-top: 24px; }
.fb-main:has(.fb-home) .fb-page-head { margin-bottom: 32px; justify-content: flex-start; }
.fb-home-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }
.fb-home-head__brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.fb-home-head__text { min-width: 0; }
.fb-home-head__actions { display: flex; gap: 8px; }
.fb-home-head__actions .fb-btn { min-height: 48px; padding: 8px 12px; font-size: 14px; font-weight: 400; border-radius: 12px; border: 1px solid #27272A; background: transparent; color: #A1A1AA; }
.fb-home-head__actions .fb-btn--edit { color: #D4D4D8; border-color: rgb(239 68 68 / 0.4); background: rgb(220 38 38 / 0.1); }
.fb-home-head__actions .fb-btn:hover { color: #FCA5A5; }
.fb-home-head__mark {
  flex: none; display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  width: 56px; height: 56px; border-radius: 16px;
  background: rgb(220 38 38 / 0.2); border: 1px solid rgb(239 68 68 / 0.5);
  box-shadow: 0 10px 15px -3px rgb(239 68 68 / 0.2);
  color: #EF4444; font-size: 24px;
}
.fb-home-head__mark img { width: 100%; height: 100%; object-fit: contain; }
body.fb-converted .fb-home-head h1 { font-size: 36px; line-height: 40px; font-weight: 700; letter-spacing: -0.025em; margin: 0; }
.fb-home-head p { margin: 0; color: #A1A1AA; font-size: 18px; line-height: 28px; }
.fb-home .fb-stat-row { gap: 16px; margin-bottom: 24px; }
.fb-home .fb-live-status { margin: -12px 0 8px; font-size: 12px; color: #A1A1AA; min-height: 0; }
.fb-home .fb-map-frame { position: relative; padding: 12px; border-radius: 16px; background: var(--fb-surface); border: 1px solid #27272A; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1); }
@media (min-width: 768px) { .fb-home .fb-map-frame { padding: 16px; } }
.fb-home .fb-map-frame .fb-map { height: 420px; min-height: 0; max-height: none; border-radius: 12px; }
.fb-home .fb-map-frame .fb-legend { position: absolute; left: 24px; bottom: 24px; z-index: 500; margin: 0; justify-content: flex-start; gap: 8px; font-size: 11px; pointer-events: none; }
@media (min-width: 768px) { .fb-home .fb-map-frame .fb-legend { left: 28px; bottom: 28px; } }
.fb-home .fb-map-frame .fb-legend .fb-badge { padding: 4px 8px; border-radius: 8px; background: rgb(9 9 11 / 0.8); font-size: 11px; font-weight: 400; min-height: 0; }
.fb-home .fb-help { font-size: 12px; color: #A1A1AA; }
.fb-home .fb-page-actions { margin-top: 12px !important; }

/* v0.3 dashboard: demo / neighbour district legend (Leaflet control) */
.fb-district-legend { background: var(--fb-surface); color: var(--fb-text); border: 1px solid var(--fb-border); border-radius: 8px; padding: 4px; font-size: var(--fb-text-sm); max-width: min(300px, calc(100vw - 80px)); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.fb-district-legend__bar { display: flex; gap: 4px; flex-wrap: nowrap; }
.fb-district-legend ul { list-style: none; margin: 4px 0 0; padding: 0 4px 0 2px; overflow-y: auto; max-height: 30vh; overscroll-behavior: contain; }
.fb-district-legend ul[hidden] { display: none; }
.fb-district-legend li { display: flex; align-items: center; gap: 6px; margin: 0; padding: 1px 0; line-height: 1.25; font-size: .85em; }
.fb-district-legend__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fb-district-legend__swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 2px solid; opacity: .85; flex: none; }
.fb-district-legend__toggle { min-height: 48px; min-width: 48px; padding: 4px 10px; white-space: nowrap; border-radius: 6px; border: 1px solid var(--fb-border); background: transparent; color: inherit; cursor: pointer; font: inherit; }
.fb-district-legend__toggle:focus-visible { outline: 2px solid var(--fb-accent, currentColor); outline-offset: 2px; }
.fb-district-popup div { margin-top: 2px; }

/* Home map controls (zoom +/- and Night/Bright): 36px visible buttons, tight 8px corner margin,
   stacked top-left (12px from the top so zoom-in's touch area stays inside the map). Each keeps a 48x48 touch area through a transparent ::before; the two zoom
   buttons are stacked, so zoom-in's area grows up and zoom-out's grows down (no overlap). */
.fb-home .fb-map-frame .leaflet-top.leaflet-left .leaflet-control { margin: 12px 0 0 8px; }
.fb-home .fb-map-frame .leaflet-top.leaflet-left .leaflet-control.fb-map-style-btn { margin-top: 22px; }
.fb-home .fb-map-frame .leaflet-bar { border-width: 1px; border-radius: 10px; }
.fb-home .fb-map-frame .leaflet-bar a {
  position: relative; width: 36px; height: 36px; line-height: 36px; font-size: 18px;
}
.fb-home .fb-map-frame .leaflet-bar a::before {
  content: ""; position: absolute; left: -7px; right: -7px; top: 0; bottom: 0;
}
.fb-home .fb-map-frame .leaflet-bar a.leaflet-control-zoom-in::before { top: -13px; }
.fb-home .fb-map-frame .leaflet-bar a.leaflet-control-zoom-out::before { bottom: -13px; }
.fb-home .fb-map-frame .leaflet-control.fb-map-style-btn {
  position: relative; justify-content: center; gap: 0;
  width: 36px; height: 36px; min-width: 36px !important; min-height: 36px !important; padding: 0;
  border-width: 1px; border-radius: 10px; font-size: 16px;
}
.fb-home .fb-map-frame .leaflet-control.fb-map-style-btn::before {
  content: ""; position: absolute; inset: -7px;
}
.fb-home .fb-map-frame .fb-map-style-btn__txt {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* District overview modal: 3x2 grid of count buttons (56px+ each, 12px+ labels). */
.fb-overview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fb-overview-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 8px 4px; width: 100%;
  background: var(--fb-surface); color: var(--fb-text); font: inherit; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--kpi, var(--fb-border)) 40%, transparent); border-radius: 12px; text-align: center;
}
/* Same accents as the Home KPI tiles (v0.2 lock: accent border/icon/number only, no tinted glow). */
.fb-overview-tile[data-overview="stations"] { --kpi: var(--fb-kpi-stations); }
.fb-overview-tile[data-overview="apparatus"] { --kpi: var(--fb-kpi-apparatus); }
.fb-overview-tile[data-overview="personnel"] { --kpi: var(--fb-kpi-personnel); }
.fb-overview-tile[data-overview="active_incidents"] { --kpi: var(--fb-kpi-incidents); }
.fb-overview-tile[data-overview="burns_today"] { --kpi: var(--fb-kpi-burns); }
.fb-overview-tile[data-overview="tasks"] { --kpi: var(--fb-nav-tasks); }
.fb-overview-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fb-overview-head h2 { overflow-wrap: anywhere; }
.fb-overview-head__mark {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: rgb(220 38 38 / 0.2); border: 1px solid rgb(239 68 68 / 0.5); color: #EF4444; font-size: 16px;
}
.fb-overview-tile:hover, .fb-overview-tile[aria-pressed="true"] { border-color: var(--kpi, var(--fb-accent)); }
.fb-overview-tile:focus-visible { outline: 3px solid var(--fb-focus); outline-offset: 2px; }
.fb-overview-tile__top { display: inline-flex; align-items: center; gap: 6px; }
.fb-overview-tile__icon { font-size: 14px; color: var(--kpi, var(--fb-accent)); }
.fb-overview-tile__value { color: var(--kpi, var(--fb-text)); font-size: 24px; font-weight: 700; line-height: 28px; font-variant-numeric: tabular-nums; }
.fb-overview-tile__label { font-size: 12px; line-height: 16px; color: var(--fb-text-muted); overflow-wrap: anywhere; }
.fb-overview-section__title { font-size: var(--fb-text-md); font-weight: 700; margin: 4px 0 8px; }
.fb-overview-section__more { margin-top: 12px; min-height: 48px; }
/* Tasks-only popup (top Tasks tile): 56px targets for list rows, Mark done, Back, All tasks, Close. */
#tasks-summary-modal .fb-btn, #tasks-summary-modal .fb-list-item { min-height: 56px; }
#tasks-summary-modal .fb-modal__head .fb-btn-ghost { min-width: 56px; }
.fb-task-row__meta { font-size: 12px; color: var(--fb-text-muted); }
.fb-task-row__meta .fb-badge { font-size: 12px; padding: 2px 8px; }
.fb-task-detail { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 8px 0; font-size: 14px; }
.fb-task-detail dt { color: var(--fb-text-muted); }
.fb-task-detail dd { margin: 0; overflow-wrap: anywhere; }
.fb-task-detail__desc { font-size: 14px; overflow-wrap: anywhere; }
.fb-task-detail__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.fb-task-detail__actions .fb-btn { flex: 1 1 8rem; min-height: 48px; }
.fb-task-detail__actions .fb-task-done { min-height: 56px; }

/* District record / edit / edit map / new / setup: tighter for iPad (v0.2 look, same colors).
   Smaller headings, less padding, 48px+ fields, 56px buttons, Save/Cancel kept visible above the nav. */
.fb-tight h1, .fb-tight .text-3xl { font-size: 24px; line-height: 30px; }
.fb-tight .text-4xl { font-size: 28px; line-height: 34px; }
.fb-tight h2, .fb-tight .text-lg { font-size: 16px; line-height: 22px; }
.fb-tight.mx-auto > .mb-6, .fb-tight > a.mb-6 { margin-bottom: 12px; }
.fb-tight form.rounded-3xl, .fb-tight .rounded-2xl.p-6, .fb-tight .rounded-2xl.p-5, .fb-tight.fb-stack .fb-card,
.fb-tight .fb-card { padding: 16px 18px; }
.fb-tight .space-y-5 > * + * { margin-top: 12px; }
.fb-tight .space-y-4 > * + * { margin-top: 10px; }
.fb-tight .mb-8 { margin-bottom: 16px; }
.fb-tight .gap-6 { gap: 16px; }
.fb-tight .gap-4 { gap: 12px; }
.fb-tight input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=color]), .fb-tight select {
  padding-top: 10px; padding-bottom: 10px; min-height: 48px; }
.fb-tight textarea { padding-top: 10px; padding-bottom: 10px; }
.fb-tight button, .fb-tight .fb-btn, .fb-tight .fb-form-actions > * { min-height: 56px !important; }
.fb-tight .fb-form-actions {
  position: sticky; bottom: 0; z-index: 5;  /* bar runs under the nav; its buttons sit above it */
  margin: 8px -18px -16px; padding: 10px 18px calc(var(--fb-nav-clear, 0px) + 6px);
  background: var(--fb-surface); border-top: 1px solid var(--fb-border);
  align-items: center; }
.fb-tight .fb-form-actions > * { display: inline-flex; align-items: center; justify-content: center; }
.fb-tight #district-edit-map { height: min(380px, 45vh) !important; }
.fb-tight.mx-auto { padding-bottom: calc(var(--fb-nav-clear, 0px) + 8px); }
/* Map popups (district info tile on the map): compact card. */
.leaflet-popup-content .fb-district-popup { max-width: 260px; font-size: 13px; line-height: 18px; }
.fb-district-popup__title { font-size: 15px; line-height: 20px; margin: 0 0 4px; }

/* Shared Home popup row (fbRowHtml): code + name / detail on the left, pill or counts right. */
.fb-list-item.fb-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; text-align: left; }
.fb-row__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fb-row__line1 { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; min-width: 0; }
.fb-row__code { font-size: 13px; color: var(--fb-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fb-row__name { font-size: 16px; font-weight: 700; color: var(--fb-text); line-height: 1.25; overflow-wrap: anywhere; }
.fb-row__sub { font-size: 13px; line-height: 18px; color: var(--fb-text-muted); overflow-wrap: anywhere; }
.fb-row__aside { flex: none; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 4px; align-self: center; }
.fb-row__pill { min-width: 88px; justify-content: center; text-align: center; font-size: 12px; white-space: nowrap; }
@media (max-width: 380px) { .fb-row__pill { min-width: 72px; } }
/* All Home popups: 56px tap targets (buttons, rows, count tiles). */
.fb-modal[data-module] .fb-btn, .fb-modal[data-module] .fb-list-item,
#district-modal .fb-btn, #district-modal .fb-list-item, #district-modal .fb-overview-tile { min-height: 56px; }
.fb-modal[data-module] .fb-modal__head .fb-btn-ghost, #district-modal .fb-modal__head .fb-btn-ghost { min-width: 56px; }

/* Module colors carried into the Home modals and lists (same tokens as the top tiles).
   v0.2 lock: accent left border, icon and numbers only; surfaces stay neutral, no glow. */
[data-module="stations"] { --mod: var(--fb-kpi-stations); }
[data-module="apparatus"] { --mod: var(--fb-kpi-apparatus); }
[data-module="personnel"] { --mod: var(--fb-kpi-personnel); }
[data-module="incidents"] { --mod: var(--fb-kpi-incidents); }
[data-module="burns"] { --mod: var(--fb-kpi-burns); }
[data-module="tasks"] { --mod: var(--fb-nav-tasks); }
.fb-mod-icon { color: var(--mod, var(--fb-accent)); font-size: 0.85em; margin-right: 4px; }
.fb-modal[data-module] .fb-modal__body .fb-list-item,
.fb-overview-section[data-module] .fb-list-item { border-left: 3px solid var(--mod); }
.fb-modal[data-module] .fb-modal__body .fb-list-item:hover,
.fb-overview-section[data-module] .fb-list-item:hover { border-color: var(--mod); }

/* Station row: name + code left, counts right and vertically centered; wraps on phones. */
.fb-station-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 8px; }
#stations-list .fb-list-item + .fb-list-item { margin-top: 8px; }
.fb-list-item.fb-station-row { flex-wrap: wrap; align-items: center; justify-content: space-between; row-gap: 4px; }
.fb-station-row__name { flex: 1 1 10rem; min-width: 0; }
.fb-station-row__title { font-size: var(--fb-text-md, 16px); font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.fb-station-row__code { font-size: 12px; line-height: 16px; color: var(--fb-text-muted); }
.fb-station-row__counts { flex: 0 1 auto; margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.fb-count { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; color: var(--fb-text-muted); white-space: nowrap; }
.fb-count i { color: var(--mod); font-size: 12px; }
.fb-count b { color: var(--mod); font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 380px) {
  .fb-station-row__counts { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 4px 12px; flex-basis: 100%; margin-left: 0; }
}

/* ---------- v0.2 KPI modal cards (Stations / Apparatus / Personnel): accents only, additive ---------- */
.fb-modal[data-module] .fb-modal__body .fb-list-item.fb-kpi-card {
  border-left-width: 4px; border-radius: 12px; padding: 12px 14px;
  transition: transform .12s ease, border-color .12s ease;
}
.fb-modal[data-module] .fb-modal__body .fb-list-item.fb-kpi-card:hover,
.fb-modal[data-module] .fb-modal__body .fb-list-item.fb-kpi-card:focus-visible {
  border-color: var(--mod); outline: 1px solid var(--mod); outline-offset: -1px; transform: translateY(-1px);
}
.fb-modal[data-module] .fb-modal__body .fb-list-item.fb-kpi-card:active { transform: none; }
.fb-kpi-card .fb-row__name { font-size: 17px; color: var(--fb-text); letter-spacing: .01em; }
.fb-kpi-card .fb-row__code { font-size: 13px; font-weight: 700; color: var(--mod); padding: 0 8px;
  border: 1px solid var(--mod); border-radius: 6px; }
.fb-kpi-card .fb-row__sub { font-size: 13px; color: var(--fb-text); opacity: .8; }
.fb-row__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; min-width: 0; }
.fb-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 1px 10px; border-radius: 9999px;
  font-size: 12px; line-height: 18px; font-weight: 600; color: var(--mod, var(--fb-text-muted));
  border: 1px solid var(--mod, var(--fb-border)); overflow-wrap: anywhere; }
.fb-chip i { font-size: 12px; }
.fb-kpi-card .fb-count { padding: 1px 10px; border-radius: 9999px; font-size: 12px; font-weight: 600; border: 1px solid var(--mod); }
.fb-kpi-card .fb-count b { font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .fb-modal[data-module] .fb-modal__body .fb-list-item.fb-kpi-card { transition: none; transform: none; } }

/* ---------- Overflow guards (v0.3 layout sweep, batch 2) ----------
   Shared, colorless layout helpers so nothing scrolls sideways at 360px.
   .fb-row-wrap   a flex row (filters, scan bars, header + action) that wraps instead of overflowing
   .fb-table-scroll  wide tables scroll inside their own box, not the page
   .fb-tabs       tab strips wrap onto a second line instead of cutting labels off */
.fb-row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--fb-space-3); }
.fb-row-wrap > * { min-width: 0; max-width: 100%; }
.fb-row-wrap > input, .fb-row-wrap > .fb-grow { flex: 1 1 12rem; }
.fb-table-scroll { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fb-tabs { display: flex; flex-wrap: wrap; }
.fb-tabs > * { flex: 1 1 auto; text-align: center; }
.fb-field > input, .fb-field > select, .fb-field > textarea { min-width: 0; max-width: 100%; }
.fb-grid { grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr)); }
/* Big page titles shrink on narrow phones instead of pushing the page sideways. */
.fb-title-fluid { font-size: clamp(1.75rem, 8.5vw, 3rem); line-height: 1.1; overflow-wrap: anywhere; min-width: 0; }


@media (max-width: 380px) { .fb-station-row .fb-row__aside { flex-basis: 100%; align-items: flex-start; } }
/* Home header row with the inline chip: the title shrinks and wraps first, so District record /
   Edit map / profile stay on the title row on tablets and desktop. */
@media (min-width: 768px) {
  .fb-home-head { flex-wrap: nowrap; }
  .fb-home-head__brand { flex: 1 1 auto; min-width: 0; }
  .fb-home-head__text { min-width: 0; }
  .fb-home-head__actions { flex: none; flex-wrap: nowrap; }
}

/* Home density pass (Ben, Oct 20: "on iPad it feels very full"). Updated line in the header,
   ~64px KPI tiles from 768px, compact header + 12px gaps on tablets; the map takes the rest
   (height set in dashboard.js sizeHomeMap down to the nav top, min 320px). */
.fb-home-head .fb-live-status { margin: 2px 0 0; font-size: 12px; line-height: 16px; text-align: left; min-height: 0; }
@media (max-width: 767px) {
  .fb-stat-tile[data-kpi] { padding: 8px 10px; gap: 8px; min-height: 60px; }
  .fb-stat-tile[data-kpi] .fb-stat-tile__icon { width: 32px; height: 32px; border-radius: 10px; font-size: 14px; }
  .fb-stat-tile[data-kpi] .fb-stat-tile__value { font-size: 24px; line-height: 28px; }
  .fb-home .fb-stat-row { gap: 8px; margin-bottom: 12px; }
  .fb-main:has(.fb-home) { padding-top: 12px; }
  .fb-main:has(.fb-home) .fb-page-head { margin-bottom: 12px; }
}
@media (min-width: 768px) {
  .fb-stat-tile[data-kpi] { padding: 8px 14px; gap: 10px; min-height: 64px; }
  .fb-stat-tile[data-kpi] .fb-stat-tile__icon { width: 36px; height: 36px; border-radius: 10px; font-size: 16px; }
  .fb-stat-tile[data-kpi] .fb-stat-tile__value { font-size: 28px; line-height: 32px; }
  .fb-home .fb-stat-row { gap: 12px; margin-bottom: 12px; }
  .fb-home .fb-map-frame { padding: 10px; }
}
@media (min-width: 768px) and (max-width: 1279px) {
  .fb-main:has(.fb-home) { padding: 12px 12px 0; max-width: none; }
  .fb-main:has(.fb-home) .fb-page-head { margin-bottom: 12px; }
  .fb-home-head { gap: 12px; }
  .fb-home-head__brand { gap: 12px; }
  .fb-home-head__mark { width: 44px; height: 44px; border-radius: 12px; font-size: 20px; }
  body.fb-converted .fb-home-head h1 { font-size: 26px; line-height: 30px; }
  .fb-home-head p { font-size: 14px; line-height: 20px; }
}
@media (min-width: 1280px) {
  .fb-main:has(.fb-home) .fb-page-head { margin-bottom: 16px; }
}

