/* ============================================================
   BCFD Staff Portal — V2 design system
   Editorial sage/Fraunces theme, ported from the brand handoff
   and adapted for the Beaver County Fire District staff site.
   Vanilla CSS — no Bootstrap. Drives the markup in includes/*
   and every rewritten page.
   ============================================================ */

:root {
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --gap: 16px;
  --pad-x: 28px;
  --row: 52px;

  /* default palette (sage) */
  --bg:        #f5f3ec;
  --surface:   #ffffff;
  --surface-2: #faf8f1;
  --surface-3: #f1eee4;
  --line:      #e6e2d6;
  --line-soft: #efeadc;
  --ink:       #1f2622;
  --ink-2:     #4b554f;
  --ink-3:     #828b85;
  --ink-4:     #b3b9b3;
  --accent:    #4f7a5a;
  --accent-2:  #dde7d3;
  --accent-ink:#26402c;
  --warn:      #b97532;
  --warn-soft: #f4e1cc;
  --danger:    #a93b3b;
  --danger-soft:#f0d6d6;
  --good:      #4f7a5a;
  --info:      #4a6b8a;
  --rail-bg:   #efece2;

  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: "Fraunces", "Source Serif Pro", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --shadow-1: 0 1px 0 rgba(255,255,255,.6) inset, 0 1px 2px rgba(20,28,24,.04);
  --shadow-2: 0 4px 24px rgba(20,28,24,.06), 0 1px 2px rgba(20,28,24,.05);
}

/* Alternate palettes (toggle by swapping the class on <body>) */
.pal-sage   { --bg:#f5f3ec; --surface:#fff; --surface-2:#faf8f1; --surface-3:#f1eee4; --line:#e6e2d6; --line-soft:#efeadc; --rail-bg:#efece2;
              --ink:#1f2622; --ink-2:#4b554f; --ink-3:#828b85;
              --accent:#4f7a5a; --accent-2:#dde7d3; --accent-ink:#26402c; }
.pal-indigo { --bg:#f4f5fa; --surface:#fff; --surface-2:#f9fafd; --surface-3:#eef0f8; --line:#e2e5ee; --line-soft:#ecf0f7; --rail-bg:#eef0f8;
              --ink:#171a25; --ink-2:#3a4254; --ink-3:#737d92;
              --accent:#3a5ad9; --accent-2:#dee6fb; --accent-ink:#16276f; }
.pal-ember  { --bg:#faf5ed; --surface:#fff; --surface-2:#fbf4ec; --surface-3:#f3e9da; --line:#ecdfd2; --line-soft:#f2e9de; --rail-bg:#f3eada;
              --ink:#27201a; --ink-2:#4f4137; --ink-3:#7e7068;
              --accent:#c75d3a; --accent-2:#f4d9c8; --accent-ink:#6a2611; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; border: 0; background: none; padding: 0; cursor: pointer; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: var(--mono); }
.muted { color: var(--ink-3); }
.tiny  { font-size: 12px; }
.bold  { font-weight: 600; }
.hide  { display: none !important; }

/* ============ App shell ============ */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--rail-w, 240px) 1fr;
}
.app.rail-collapsed { --rail-w: 64px; }

/* Side rail */
.rail {
  background: var(--rail-bg);
  border-right: 1px solid var(--line);
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 40;
}
.rail-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), color-mix(in oklab, var(--accent) 60%, var(--ink)));
  display: grid; place-items: center; color: white;
  font-family: var(--serif); font-weight: 500; font-size: 15px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
  flex-shrink: 0;
}
.brand-name { font-family: var(--serif); font-size: 16px; letter-spacing: -0.01em; line-height: 1.05; }
.brand-name .dot { color: var(--accent); }
.brand-sub { font-size: 10px; color: var(--ink-3); margin-top: 3px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }

.rail-collapse {
  margin-left: auto; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; color: var(--ink-3);
}
.rail-collapse:hover { background: var(--line-soft); color: var(--ink); }
.rail-collapsed .brand-text,
.rail-collapsed .brand-mark         { display: none; }
.rail-collapsed .rail-head          { padding: 14px 0; justify-content: center; }
.rail-collapsed .rail-collapse      { margin: 0; }

.rail-body { flex: 1; overflow: auto; padding: 16px 12px 12px; }
.rail-body::-webkit-scrollbar { width: 8px; }
.rail-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.rail-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); margin: 14px 10px 6px; font-weight: 600;
}
.rail-collapsed .rail-section { display: none; }

.rail-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px; color: var(--ink-2);
  font-size: 13.5px; margin-bottom: 1px; cursor: pointer;
  position: relative; width: 100%; text-align: left;
  font-weight: 450;
}
.rail-item:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.rail-item.active {
  background: var(--surface);
  color: var(--accent-ink);
  font-weight: 550;
  box-shadow: 0 1px 2px rgba(20,28,24,.04), 0 0 0 1px var(--line);
}
.rail-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}
.rail-item .ico { width: 18px; height: 18px; flex-shrink: 0; display: grid; place-items: center; color: currentColor; }
.rail-item .ico svg { width: 18px; height: 18px; }
.rail-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item .meta {
  font-size: 11px; color: var(--ink-3);
  background: var(--line-soft); padding: 1px 6px; border-radius: 99px;
}
.rail-item.active .meta { background: var(--accent-2); color: var(--accent-ink); }
.rail-collapsed .rail-item { justify-content: center; padding: 10px 0; gap: 0; }
.rail-collapsed .rail-item .lbl,
.rail-collapsed .rail-item .meta { display: none; }
.rail-collapsed .rail-item.active::before { display: none; }

.rail-foot {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.quick-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rail-collapsed .quick-row { grid-template-columns: 1fr; }
.quick-btn {
  height: 38px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2);
}
.quick-btn:hover { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 50%, var(--line)); text-decoration: none; }

.user-tile {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
}
.user-tile:hover { background: var(--surface-2); text-decoration: none; }
.user-tile .name { font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--ink); }
.user-tile .role { font-size: 11px; color: var(--ink-3); }
.rail-collapsed .user-tile { justify-content: center; padding: 4px; background: transparent; border: 0; }
.rail-collapsed .user-tile .info { display: none; }

/* ============ Main column ============ */
.main { min-width: 0; display: flex; flex-direction: column; }

/* Top bar (page header) */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px var(--pad-x) 0;
  background: var(--bg);
}
.menu-btn { display: none; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); place-items: center; }
.topbar-inner {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  border-bottom: 0;
  padding: 18px 24px 16px;
}
.page-title h1 {
  margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 400; letter-spacing: -0.015em;
  line-height: 1.1;
}
.page-title .kicker {
  font-size: 11px; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 600; margin-bottom: 4px;
}
.page-title .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* Search box (header) */
.search-h {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; width: 280px;
  color: var(--ink-3);
}
.search-h input { background: none; border: 0; outline: 0; width: 100%; color: var(--ink); font-size: 13px; }

/* Breadcrumb strip */
.crumbs {
  display: flex; align-items: center; gap: 8px;
  padding: 12px var(--pad-x);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.crumbs a { color: var(--accent); }
.crumbs .sep { color: var(--ink-4); }
.crumbs .current { color: var(--ink-2); font-weight: 500; }

/* Page surface — most pages live inside this card */
.page {
  margin: 0 var(--pad-x) 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  padding: 24px 24px 28px;
  min-height: calc(100vh - 220px);
}

/* ============ Avatars ============ */
.avatar {
  width: 34px; height: 34px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  display: inline-grid; place-items: center;
  color: var(--accent-ink); font-weight: 600; font-size: 12px;
  flex-shrink: 0; overflow: hidden; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xs { width: 22px; height: 22px; font-size: 9px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 96px; height: 96px; font-size: 32px; border: 4px solid var(--surface); box-shadow: 0 4px 14px rgba(0,0,0,.08); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 9px; font-weight: 550; font-size: 13px;
  background: var(--ink); color: var(--surface);
  transition: transform .08s ease, background .15s, border-color .15s;
  border: 1px solid transparent; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; color: var(--surface); }
.btn svg { width: 15px; height: 15px; }
.btn.accent { background: var(--accent); color: white; }
.btn.warn { background: var(--warn); color: white; }
.btn.danger { background: var(--danger); color: white; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.btn.ghost.accent { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); background: transparent; }
.btn.ghost.accent:hover { background: var(--accent-2); color: var(--accent-ink); }
.btn.link { background: transparent; color: var(--accent); padding: 4px 6px; }
.btn.link:hover { background: var(--accent-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.lg { padding: 11px 18px; font-size: 14.5px; }
.btn.icon { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 550;
  padding: 2px 9px; border-radius: 999px;
  background: var(--line-soft); color: var(--ink-2);
  white-space: nowrap; border: 1px solid transparent;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good   { background: color-mix(in oklab, var(--good) 14%, var(--surface)); color: var(--good); }
.badge.warn   { background: color-mix(in oklab, var(--warn) 16%, var(--surface)); color: var(--warn); }
.badge.danger { background: color-mix(in oklab, var(--danger) 14%, var(--surface)); color: var(--danger); }
.badge.info   { background: color-mix(in oklab, var(--info)  14%, var(--surface)); color: var(--info); }
.badge.accent { background: var(--accent-2); color: var(--accent-ink); }
.badge.outline { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.badge.lg { font-size: 12.5px; padding: 4px 12px; }
.badge.code { font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: 0.02em; }

/* ============ Cards & sections ============ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card.tight { padding: 14px; }
.card.flat { background: var(--surface-2); }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.card-h .more { color: var(--ink-3); font-size: 12.5px; }

.section-h { display: flex; align-items: end; justify-content: space-between; margin: 8px 0 14px; gap: 12px; }
.section-h h2 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.section-h .sub { font-size: 12.5px; color: var(--ink-3); }

.section-title {
  font-family: var(--serif); font-size: 22px; font-weight: 500; letter-spacing: -0.01em;
  margin: 0 0 4px; display: inline-block; padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}

/* ============ Grids ============ */
.grid { display: grid; gap: var(--gap); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-12 { grid-template-columns: 1fr 1fr; }
.g-21 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2,1fr); }
  .g-3, .g-12, .g-21 { grid-template-columns: 1fr; }
}

/* ============ Stat tiles (dashboard) ============ */
.kpi {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.kpi-ico {
  width: 44px; height: 44px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-2); color: var(--accent-ink); flex-shrink: 0;
}
.kpi-ico svg { width: 22px; height: 22px; }
.kpi-ico.warn { background: color-mix(in oklab, var(--warn) 20%, var(--surface)); color: var(--warn); }
.kpi-ico.info { background: color-mix(in oklab, var(--info) 14%, var(--surface)); color: var(--info); }
.kpi-ico.danger { background: color-mix(in oklab, var(--danger) 14%, var(--surface)); color: var(--danger); }
.kpi-body { min-width: 0; flex: 1; }
.kpi .lbl  { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi .v    { font-family: var(--serif); font-size: 26px; line-height: 1.05; letter-spacing: -0.02em; margin-top: 4px; font-weight: 500; }
.kpi .delta { font-size: 11.5px; color: var(--good); margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }

/* ============ Tables ============ */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th .arrow { opacity: .4; font-size: 9px; }
.table th.sort-asc .arrow, .table th.sort-desc .arrow { opacity: 1; color: var(--accent); }
.table td { padding: 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr.selected td { background: color-mix(in oklab, var(--accent) 6%, var(--surface)); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.table-scroll { overflow-x: auto; }
.table-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.table-toolbar .grow { flex: 1; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-top: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }

/* ============ Inputs ============ */
.input {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); outline: 0; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent); }
select.input { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23828b85' stroke-width='2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }
.input.search-ico {
  padding-left: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23828b85' stroke-width='1.8' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
  background-repeat: no-repeat; background-position: 11px center; background-size: 14px 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.field .help { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.field input, .field textarea, .field select {
  padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  outline: 0; font-size: 13.5px; transition: border-color .15s, box-shadow .15s; width: 100%;
}
.field select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23828b85' stroke-width='2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent); }
.field textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.field-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
.field-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.field-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .field-grid, .field-grid.cols-2, .field-grid.cols-4 { grid-template-columns: 1fr; } }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 22px; padding: 0 4px; overflow: auto; }
.tabs button {
  padding: 12px 18px; font-size: 13.5px; color: var(--ink-3); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Section divider with title */
.sec-h { display: flex; align-items: baseline; gap: 12px; margin: 26px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.sec-h h4 { margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 500; letter-spacing: -0.005em; }
.sec-h .desc { font-size: 12px; color: var(--ink-3); }

/* ============ Dropdown menu (vanilla) ============ */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle { display: inline-flex; align-items: center; gap: 6px; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; z-index: 50;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-2); padding: 6px; display: none;
}
.dropdown.open > .dropdown-menu { display: block; animation: fade .14s ease; }
.dropdown-menu.left { right: auto; left: 0; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 11px; border-radius: 8px; color: var(--ink-2); font-size: 13px;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.dropdown-menu a.danger, .dropdown-menu button.danger { color: var(--danger); }
.dropdown-menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.dropdown-info { padding: 12px; border-radius: 8px; background: var(--accent-2); color: var(--accent-ink); margin-bottom: 6px; }
.kebab { width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--ink-3); }
.kebab:hover { background: var(--surface-2); color: var(--ink); }

/* ============ Notice banner ============ */
.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px;
  background: color-mix(in oklab, var(--warn) 12%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--warn) 35%, var(--line));
  color: var(--ink-2); font-size: 13px; margin: 14px 0;
}
.notice .ico { color: var(--warn); flex-shrink: 0; margin-top: 1px; }
.notice strong { color: var(--ink); }
.notice.info { background: color-mix(in oklab, var(--info) 10%, var(--surface)); border-color: color-mix(in oklab, var(--info) 30%, var(--line)); }
.notice.info .ico { color: var(--info); }
.notice.accent { background: var(--accent-2); border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }
.notice.accent .ico { color: var(--accent); }

/* ============ Misc helpers ============ */
.hr { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* Pagination */
.pager { display: flex; align-items: center; gap: 6px; }
.pager button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13px; display: grid; place-items: center; }
.pager button:hover { background: var(--surface-2); color: var(--ink); }
.pager button.active { background: var(--accent); color: white; border-color: var(--accent); font-weight: 600; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .info { font-size: 12.5px; color: var(--ink-3); margin-right: 8px; }

/* ============ Charts (inline SVG / CSS, no Chart.js) ============ */
.chart-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.chart-tab { padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); border: 1px solid var(--line); background: var(--surface); }
.chart-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chart-panel { display: none; }
.chart-panel.active { display: block; }
.chart-sublabel { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin: 0 0 10px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.chart-note { font-size: 11.5px; color: var(--ink-3); margin-top: 12px; }

/* CSS bar chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 220px; padding-top: 10px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .stack { width: 60%; max-width: 46px; border-radius: 5px 5px 0 0; overflow: hidden; display: flex; flex-direction: column-reverse; box-shadow: inset 0 -1px 0 rgba(0,0,0,.05); }
.bars .seg { width: 100%; }
.bars .bar-x { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bars .bar-v { font-size: 11px; color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 42px; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar .label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { background: var(--surface-3); border-radius: 999px; height: 12px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.hbar .val { color: var(--ink-2); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* donut via conic-gradient */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0; position: relative; }
.donut::after { content: ""; position: absolute; inset: 26px; background: var(--surface); border-radius: 50%; }
.donut .center { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; text-align: center; }
.donut .center .v { font-family: var(--serif); font-size: 24px; font-weight: 500; }
.donut .center .l { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.donut-legend span { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }

/* ============ File drop zone (vanilla upload) ============ */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 34px; border: 1.5px dashed var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--ink-3); font-size: 13px; text-align: center; cursor: pointer;
}
.drop:hover, .drop.dragover { border-color: var(--accent); color: var(--ink-2); background: var(--accent-2); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.gallery .pic { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 4/3; background: var(--surface-2); }
.gallery .pic img { width: 100%; height: 100%; object-fit: cover; }
.gallery .pic .rm { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 7px; background: rgba(20,28,24,.6); color: #fff; display: grid; place-items: center; }
.gallery .pic .rm:hover { background: var(--danger); }

/* ============ Cover banner + overlap avatar (user profile) ============ */
.cover { height: 170px; border-radius: 14px; background: linear-gradient(135deg, var(--accent-2), color-mix(in oklab, var(--accent) 50%, var(--surface))); position: relative; overflow: hidden; margin-bottom: 60px; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-avatar { position: absolute; left: 50%; bottom: -50px; transform: translateX(-50%); width: 110px; height: 110px; border-radius: 50%; border: 5px solid var(--surface); background: var(--accent-2); display: grid; place-items: center; color: var(--accent-ink); font-family: var(--serif); font-size: 36px; box-shadow: 0 6px 18px rgba(0,0,0,.10); overflow: hidden; z-index: 3; }
.cover-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ============ Incident hero ============ */
.entity-hero { display: flex; align-items: center; gap: 22px; padding: 22px; background: linear-gradient(135deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.entity-hero h1 { margin: 0; font-family: var(--serif); font-size: 30px; font-weight: 500; letter-spacing: -0.02em; }
.entity-hero .meta { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

/* ============ Toast (AJAX save feedback) ============ */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 15px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 13px; box-shadow: var(--shadow-2); animation: fade .18s ease; }
.toast.good { background: var(--accent); }
.toast.bad { background: var(--danger); }

/* ============ Login ============ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 500px at 70% -10%, var(--accent-2), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px; box-shadow: var(--shadow-2); }
.auth-card .brand-mark { width: 46px; height: 46px; font-size: 20px; margin-bottom: 18px; }
.auth-card h1 { font-family: var(--serif); font-weight: 500; font-size: 24px; margin: 0 0 4px; letter-spacing: -0.01em; }
.auth-card .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 22px; }
.auth-err { font-size: 12.5px; color: var(--danger); margin-top: 10px; min-height: 16px; }

/* ============ Icon sizing ============
   Every icon comes from ic() as a viewBox-only <svg>. Default it to 1em
   so it scales with its text, then override per container where the
   visual weight wants something different. */
svg { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.125em; }

.user-chip svg                                   { width: 14px; height: 14px; }
.dropdown-menu a svg, .dropdown-menu button svg  { width: 16px; height: 16px; }
.dropdown-info svg                               { width: 16px; height: 16px; }
.quick-btn svg                                   { width: 18px; height: 18px; }
.crumbs svg                                      { width: 12px; height: 12px; }
.menu-btn svg                                    { width: 20px; height: 20px; }
.rail-collapse svg                               { width: 14px; height: 14px; }
.kebab svg                                       { width: 16px; height: 16px; }
.notice .ico svg                                 { width: 18px; height: 18px; }
.entity-hero .avatar.lg svg                      { width: 46px; height: 46px; }
.btn.icon svg                                    { width: 16px; height: 16px; }

/* ============ Attendance chips (firefighters / apparatus) ============ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  user-select: none; transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { background: var(--surface-3); }
/* Present / on-scene = solid green pill */
.chip.active {
  background: color-mix(in oklab, var(--good) 18%, var(--surface));
  border-color: color-mix(in oklab, var(--good) 45%, var(--line));
  color: var(--accent-ink);
  font-weight: 600;
}
.chip.active::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--good);
}
/* Excused = solid amber pill (used on training attendance) */
.chip.excused {
  background: color-mix(in oklab, var(--warn) 16%, var(--surface));
  border-color: color-mix(in oklab, var(--warn) 38%, var(--line));
  color: var(--warn);
  font-weight: 600;
}
.chip.excused::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--warn);
}
/* Not on scene = solid red pill */
.chip.absent {
  background: color-mix(in oklab, var(--danger) 12%, var(--surface));
  border-color: color-mix(in oklab, var(--danger) 35%, var(--line));
  color: var(--danger);
  font-weight: 600;
}
.chip.absent::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
  opacity: .8;
}

/* ============ Responsive shell ============ */
.rail-scrim { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; left: 0; top: 0; width: 240px; transform: translateX(-100%); transition: transform .2s ease; }
  .app.rail-open .rail { transform: none; }
  .app.rail-open .rail-scrim { display: block; position: fixed; inset: 0; background: rgba(20,28,24,.35); z-index: 35; }
  .menu-btn { display: grid; }
  .search-h { display: none; }
}
