/* Convention Ops (v2) — hand-rolled, no framework, light+dark. */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #1a2333; --ink-dim: #66707f;
  --line: #e2e5ea; --accent: #2456c4; --accent-ink: #ffffff;
  --ok: #1a7f4b; --warn: #a05a00; --err: #b3261e; --lead: #5b3fa8;
  --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 4px 16px rgba(20, 30, 50, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d; --panel: #1a212b; --ink: #e8ebf0; --ink-dim: #94a0b0;
    --line: #2a3341; --accent: #6d9bff; --accent-ink: #0d1524;
    --ok: #4fc98a; --warn: #e0a34e; --err: #ff7a70; --lead: #b39cf0;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
/* explicit theme override (e.g. a host page's theme toggle) beats the OS preference */
:root[data-theme="dark"] {
  --bg: #12161d; --panel: #1a212b; --ink: #e8ebf0; --ink-dim: #94a0b0;
  --line: #2a3341; --accent: #6d9bff; --accent-ink: #0d1524;
  --ok: #4fc98a; --warn: #e0a34e; --err: #ff7a70; --lead: #b39cf0;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
:root[data-theme="light"] {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #1a2333; --ink-dim: #66707f;
  --line: #e2e5ea; --accent: #2456c4; --accent-ink: #ffffff;
  --ok: #1a7f4b; --warn: #a05a00; --err: #b3261e; --lead: #5b3fa8;
  --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 4px 16px rgba(20, 30, 50, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
}
/* App-shell scroll (operator request 2026-07-09): the shell is exactly one
   viewport tall and ONLY <main> scrolls — the header + tab ribbon can never
   scroll out of view. dvh keeps iOS Safari's collapsing address bar honest. */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
code { background: var(--line); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
h1, h2, h3, h4 { margin: 0 0 8px; }
.sub { color: var(--ink-dim); font-size: 12.5px; }
.dim { color: var(--ink-dim); }
.empty { color: var(--ink-dim); padding: 24px; text-align: center; }
.loading { color: var(--ink-dim); padding: 24px; }
.right { margin-left: auto; }
.spacer { flex: 1; }

/* top bar + tabs */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.conv-select, .persona-select { max-width: 300px; }
.conv-name { color: var(--ink-dim); }
.identity { display: flex; align-items: center; gap: 10px; }
.demo-pill {
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
}
.demo-pill.admin { background: var(--accent); color: var(--accent-ink); }
.tabs {
  display: flex; align-items: center; gap: 2px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  overflow-x: auto; white-space: nowrap;
}
.tab {
  border: 0; background: none; color: var(--ink-dim); padding: 10px 13px;
  font: inherit; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-group {
  margin-left: 16px; padding-right: 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px; color: var(--ink-dim);
}
/* min-height:0 lets the flex child actually shrink so overflow-y engages —
   without it the shell grows past the viewport and nothing scrolls. */
main { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px; }

/* layout */
.view-split { display: flex; gap: 16px; align-items: flex-start; }
.view-plain { max-width: 1100px; }   /* reading measure — prose stays narrow */
/* Data-wide surfaces (2026-07-09 desktop review): card grids, tables, and
   matrices scan BETTER wide — width converts scrolling into scanning. Capped
   so rows never get absurd on ultra-wide monitors; reading surfaces
   (Templates, Setup forms) deliberately keep .view-plain. */
.view-wide { max-width: 1720px; }
.rail {
  width: 250px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; box-shadow: var(--shadow);
  /* sticky is now relative to the scrolling <main>; cap the rail to the space
     actually below the frozen header + tabs so its bottom never clips. */
  position: sticky; top: 0; max-height: calc(100dvh - 130px); overflow-y: auto;
}
.rail-group { margin-top: 14px; display: flex; flex-direction: column; gap: 5px; }
.rail-group h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-dim); margin: 0 0 2px; }
.view-main { flex: 1; min-width: 0; }

/* stats */
.counts { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.stat b { font-size: 18px; }
.stat span { font-size: 11.5px; color: var(--ink-dim); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
table.roster { border-collapse: collapse; width: 100%; }
table.roster th, table.roster td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.roster th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-dim); position: sticky; top: 0; background: var(--panel); }
table.roster th.sortable { cursor: pointer; }
table.roster tbody tr { cursor: pointer; }
table.roster tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
table.roster tr.archived { opacity: .5; }
table.roster td .sub { font-size: 11.5px; }

/* badges + buttons + inputs */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1.5px 8px;
  border-radius: 9px; background: var(--line); color: var(--ink-dim); margin-right: 4px;
}
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.full { background: color-mix(in srgb, var(--err) 15%, transparent); color: var(--err); }
.badge.lead { background: color-mix(in srgb, var(--lead) 15%, transparent); color: var(--lead); }
/* approval-status indicators (R-020 slice 1): a hollow amber ring for in-flight
   (Pending/Sent) and a filled red dot for needs-attention (Not Approved/Moved),
   rendered before a volunteer's name. --warn / --err carry both themes. */
.appr-ring { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--warn); vertical-align: middle; margin-right: 5px; }
.appr-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: var(--err); vertical-align: middle; margin-right: 5px; }
/* Approvals view (R-020 slice 2): needs-attention feed + per-congregation lists */
.approvals .needs-attention { margin: 4px 0 18px; }
.approvals .needs-attention h3 { margin: 0 0 8px; }
.approvals .attn-row { display: flex; gap: 12px; align-items: center;
  justify-content: space-between; padding: 8px 10px; margin-bottom: 6px;
  border: 1px solid var(--line); border-left: 3px solid var(--warn);
  border-radius: 8px; background: var(--panel); }
.approvals .attn-body { min-width: 0; }
.approvals .cong-block { margin-bottom: 18px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.approvals .cong-head { display: flex; flex-wrap: wrap; gap: 8px 14px;
  align-items: center; }
.approvals .cong-head h3 { margin: 0; }
.approvals .cong-contact { display: flex; flex-direction: column; font-size: 13px; }
.approvals .cong-actions { margin-left: auto; display: flex; gap: 8px; }
.approvals .appr-people { list-style: none; margin: 10px 0 0; padding: 0; }
.approvals .appr-people li { display: flex; align-items: baseline; gap: 8px;
  padding: 4px 0; border-top: 1px solid var(--line); }
.approvals .appr-people li .sub { margin-left: auto; text-align: right; }
/* duplicate-volunteer safeguards (R-017): inline amber warnings under Add-flow
   fields. Uses --warn so it reads correctly in both light and dark themes;
   :empty collapses the container so no gap shows when there's nothing to warn. */
.dup-warning { display: flex; flex-direction: column; gap: 3px; margin: -6px 0 12px; }
.dup-warning:empty { display: none; }
.dup-warning .dup-row { color: var(--warn); font-size: 12px; }
.dup-warning .dup-hint { color: var(--warn); font-size: 11.5px; font-weight: 600; }
.btn {
  font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 7px 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); margin-top: 12px; }
.btn.ghost { background: none; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--ink-dim); font-size: 13px; }
.icon-btn:hover { color: var(--err); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; width: 100%; max-width: 100%;
}
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
input:disabled, select:disabled { opacity: .55; }
.search { margin-bottom: 4px; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; padding: 2px 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-dim); }
.field-hint { font-size: 11.5px; color: var(--ink-dim); }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow); }

/* EMA / Badges screen (R-019 slice 4): the toolbar's right-hand action cluster
   wraps under the department picker on phones (§8b — no horizontal page scroll);
   the roster reuses table.roster + .table-wrap. */
.ema-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ema-actions .sub { color: var(--ink-dim); font-size: 12px; }
table.ema-roster td label.check { justify-content: center; }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 15, 25, .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50;
  overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 460px; border: 1px solid var(--line);
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 0; }
.modal-body { padding: 12px 18px; max-height: 65vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 16px; }
.drawer-section { margin: 16px 0 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--ink-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .7px; }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  opacity: 0; transition: all .25s; z-index: 100; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--err); color: #fff; }

/* org chart */
.orgchart { display: flex; flex-direction: column; gap: 20px; }
.org-dept { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.org-node { margin: 6px 0; }
.org-card {
  display: inline-flex; flex-direction: column; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg); min-width: 180px;
}
.org-card.lead { border-color: color-mix(in srgb, var(--lead) 50%, var(--line)); }
.org-children { margin-left: 26px; padding-left: 14px; border-left: 2px solid var(--line); }

/* convention committee panel (org chart) */
.committee-row { display: flex; flex-wrap: wrap; gap: 10px; }
.committee-row .org-card { flex: 0 1 220px; }
.committee-support { margin-top: 12px; }

/* org setup */
.org-setup { display: flex; flex-direction: column; gap: 4px; }
.org-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
}
.org-row.archived { opacity: .55; }
.org-row.depth-1 { margin-left: 26px; }
.org-row.depth-2 { margin-left: 52px; }
.org-row.depth-3 { margin-left: 78px; }
.org-row.depth-4 { margin-left: 104px; }
.org-actions { margin-left: auto; display: flex; gap: 6px; }

/* schedule */
.loc-block { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.loc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* captain-management panel + location delete row (schedule dialogs) */
.captain-mgr { display: flex; flex-direction: column; gap: 10px; }
.captain-list { display: flex; flex-direction: column; gap: 2px; }
.captain-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.loc-delete { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
/* R-021 duplicate row in the edit-location dialog: input + its own button */
.loc-duplicate { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.loc-duplicate .btn { align-self: flex-start; }

/* R-021 lanyards: EMA-screen section switch + checkout table widgets */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { padding: 7px 14px; background: transparent; border: 0; cursor: pointer;
  color: var(--ink-dim); font-size: 13.5px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.lan-qty { width: 70px; }
.lan-sig { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lan-sig-input { width: 120px; }

/* Shift-card shade states (operator 2026-07-09): open (under-filled) cards
   render a shade LIGHTER than staffed ones so vacancies pop out of the grid;
   at-risk/late (R-021 arrival coloring) tint amber/red and are declared
   AFTER .open so a no-show wins over a vacancy. Works in both themes:
   mixing toward --panel lightens, mixing --warn/--err into --bg tints. */
.shift-card.open { background: color-mix(in srgb, var(--panel) 65%, var(--bg)); }
/* R-021 morning check-in: at-risk shift cards + arrival indicators + board */
.shift-card.at-risk { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset;
  background: color-mix(in srgb, var(--warn) 12%, var(--bg)); }
.shift-card.late { border-color: var(--err); box-shadow: 0 0 0 1px var(--err) inset;
  background: color-mix(in srgb, var(--err) 14%, var(--bg)); }
.arr-ok { color: var(--ok); font-weight: 700; margin-right: 4px; }
.arr-no { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--warn); margin-right: 6px; flex: 0 0 auto; }
.checkin-board .board-row { display: flex; justify-content: space-between;
  align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.checkin-board .board-status { display: flex; align-items: center; gap: 8px; }

/* Setup → Roadmap embed */
.roadmap-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.roadmap-frame { width: 100%; height: calc(100vh - 150px); border: 1px solid var(--line);
  border-radius: 12px; background: #fff; }

/* R-028 reusable phone card row (Roster now; other screens in R-029) */
.m-card-list { display: flex; flex-direction: column; gap: 8px; }
.m-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; }
.m-card.tappable { cursor: pointer; }
.m-card.tappable:active { border-color: var(--accent); }
.m-card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 2px; }

/* R-028 My Assignments: next-shift hero + badge button */
.my-view .conv-card { margin-bottom: 10px; }
.my-next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.my-next-time { font-size: 19px; font-weight: 700; margin: 4px 0 6px; }
.my-captain a { color: var(--accent); text-decoration: none; }
.my-badge-btn { width: 100%; max-width: 420px; padding: 12px; font-size: 15px; margin: 4px 0 14px; }
.my-past { opacity: .55; }

/* R-028 mobile: floating check-in action + setup sheet + bigger phone tabs */
.fab {
  position: fixed; right: 16px; bottom: 18px; z-index: 40;
  background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: 999px; padding: 14px 20px; font: inherit; font-weight: 700;
  font-size: 14.5px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
body.has-fab main { padding-bottom: 84px; }   /* the FAB must never shadow the last row */
.setup-sheet { display: flex; flex-direction: column; gap: 8px; }
.setup-sheet .btn.wide { width: 100%; text-align: left; padding: 12px 14px; }
@media (max-width: 640px) {
  .tab { padding: 13px 14px; min-height: 44px; }   /* comfortable thumb targets */
}

/* R-025 logins: temp-password one-time display + login-screen hint */
.temp-pw { font-size: 20px; letter-spacing: 1px; padding: 6px 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.temp-pw-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.login-hint { margin-top: 10px; }
/* the base .btn.danger rule (line ~157) carries margin-top for the
   delete-location dialog; inline table buttons must not inherit that */
.btn.danger.small { margin-top: 0; }

/* R-022 support: report dialog + admin inbox/activity screen */
.support-msg { max-width: 420px; overflow-wrap: anywhere; }
.support-actions { white-space: nowrap; }
.support-actions .btn + .btn { margin-left: 6px; }
.support-shot { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.modal textarea { width: 100%; resize: vertical; }
.day-head { margin: 14px 0 8px; color: var(--ink-dim); font-size: 12.5px; }
.shift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.shift-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--bg); }
.shift-time { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.shift-people { list-style: none; margin: 8px 0; padding: 0; }
.shift-people li { display: flex; justify-content: space-between; padding: 2px 0; }

/* permissions grid */
.perm-grid { border-collapse: collapse; width: 100%; }
.perm-grid th, .perm-grid td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.perm-grid th { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-dim); }
.perm-resource { text-align: left !important; font-weight: 600; white-space: nowrap; }
.perm-na { color: var(--line); }
.perm-grid select { font-size: 12px; padding: 4px 6px; min-width: 110px; }
select.perm-set { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
.perm-legend { flex: 1; }
.perm-note { margin-top: 10px; }

/* conventions */
.conv-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.conv-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; box-shadow: var(--shadow);
}
.conv-actions { display: flex; gap: 6px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 34px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow);
}
.login-err { color: var(--err); margin: 0; min-height: 1em; font-size: 13px; }
.demo-link { color: var(--accent); text-align: center; font-size: 13px; text-decoration: none; margin-top: 6px; }

/* multi-choice inline */
.multi { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* ---------------------------------------------------------------------------
   Responsive capability layer — desktop-primary, phone/tablet-CAPABLE
   (v1 parity: key men and captains work the roster + schedule from phones
   in the field). Desktop layout is untouched above 1024px.
   --------------------------------------------------------------------------- */

/* tablet (641–1024px): keep the two-pane layout, slim the chrome */
@media (max-width: 1024px) {
  .rail { width: 210px; padding: 10px; }
  main { padding: 12px; }
  .topbar { padding: 8px 12px; gap: 10px; }
  .conv-select, .persona-select { max-width: 200px; }
  table.roster th, table.roster td { padding: 8px 9px; }
}

/* the Filters toggle only exists on phones (roster.js renders it always) */
.filters-toggle { display: none; }

/* phone (≤760px): single column, collapsible filters, thumb-sized targets */
@media (max-width: 760px) {
  .view-split { flex-direction: column; }
  .rail { width: 100%; position: static; max-height: none; }
  /* filter rail collapses behind a toggle so the table isn't pushed offscreen */
  .filters-toggle { display: inline-flex; align-items: center; gap: 6px; }
  .rail.collapsible { display: none; }
  .rail.collapsible.open { display: block; }
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .brand { font-size: 15px; }
  .identity { margin-left: auto; }
  main { padding: 10px 8px; }
  /* 16px inputs stop iOS Safari from zooming the page on focus */
  input, select, textarea { font-size: 16px; }
  .btn { padding: 9px 14px; }       /* ≥40px tap targets */
  .icon-btn { padding: 8px; font-size: 15px; }
  .stat { padding: 6px 10px; }
  .stat b { font-size: 16px; }
  table.roster th, table.roster td { padding: 8px 8px; font-size: 13px; }
  /* Modals go near-fullscreen instead of floating cards — as a FLEX COLUMN
     capped at the viewport, with the BODY scrolling internally and the
     header + footer pinned (Save/Cancel always reachable). The previous
     max-height:none override let content taller than the screen spill PAST
     the panel background — transparent fields floating over the page
     (operator iPhone report 2026-07-08, IMG_1914). Short dialogs still
     shrink to fit; only tall ones pin to the viewport cap. */
  .modal-overlay { padding: 12px 8px; align-items: flex-start; }
  .modal, .modal.wide {
    max-width: none;
    display: flex; flex-direction: column;
    max-height: calc(100vh - 24px);      /* fallback */
    max-height: calc(100dvh - 24px);     /* iOS URL-bar-aware */
  }
  .modal-body { max-height: none; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
  /* R-028: the check-in board is a TRUE takeover on phones — edge to edge,
     no floating chrome, the whole screen is the board at 6 AM. */
  .modal-overlay:has(.modal.fullscreen) { padding: 0; }
  .modal.fullscreen {
    width: 100vw; border-radius: 0; border: 0;
    height: 100vh; height: 100dvh; max-height: none;
  }
  .org-children { margin-left: 12px; padding-left: 8px; }
  .org-row.depth-1 { margin-left: 12px; }
  .org-row.depth-2 { margin-left: 24px; }
  .org-row.depth-3 { margin-left: 36px; }
  .org-row.depth-4 { margin-left: 48px; }
  .org-card { min-width: 0; width: 100%; }
  .conv-card { flex-wrap: wrap; }
  .shift-grid { grid-template-columns: 1fr; }
  /* wide grids scroll inside .table-wrap, never the page */
  .perm-grid select { min-width: 90px; }
}

/* print sheet: hidden on screen; when printing, ONLY the sheet shows */
#print-sheet { display: none; }
@media print {
  body > *:not(#print-sheet) { display: none !important; }
  #print-sheet { display: block; color: #000; background: #fff; font-size: 12px; }
  #print-sheet h1 { font-size: 18px; margin: 0 0 2px; }
  #print-sheet h2 { font-size: 15px; margin: 14px 0 4px; }
  #print-sheet h3 { font-size: 13px; margin: 10px 0 3px; }
  #print-sheet .print-meta { color: #555; margin: 0 0 10px; }
  #print-sheet table { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
  #print-sheet th, #print-sheet td { border: 1px solid #999; padding: 3px 6px; text-align: left; }
  #print-sheet th { background: #eee; }
}

/* ── Message templates (R-008) ─────────────────────────────────────────────
   templateBlock / templateSection (js/templates.js): expandable copy blocks
   with the two placeholder classes visually distinct — resolved values get a
   green underline, human blanks an amber chip (same language as the R-008
   mockups). The 💬 quick-text button rides roster phone cards. */
.tpl-section { margin: 14px 0; }
.tpl-section > h3 { margin-bottom: 8px; }
.tpl-block { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 10px; overflow: hidden; }
.tpl-block > summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; cursor: pointer; list-style: none; }
.tpl-block > summary::-webkit-details-marker { display: none; }
.tpl-block > summary::after { content: '▾'; margin-left: auto; color: var(--ink-dim); }
.tpl-block[open] > summary::after { content: '▴'; }
.tpl-aud { font-size: 11px; padding: 2px 8px; border-radius: 99px;
  border: 1px solid var(--accent); color: var(--accent); }
.tpl-facts { flex-basis: 100%; }
.tpl-body { padding: 10px 12px; border-top: 1px solid var(--line);
  font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.tpl-actions { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.tpl-resolved { color: var(--ok); border-bottom: 1px dotted var(--ok); }
.tpl-blank { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-radius: 4px; padding: 0 3px; font-weight: 600; }
.tpl-sms { flex: 0 0 auto; }
.m-card-contact { display: flex; align-items: center; gap: 8px; justify-content: space-between; }

/* text-style button (forgot-password on the login card) */
.link-btn { background: none; border: 0; padding: 0; margin: 6px 0 0;
  color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* needs-attention congregation grouping (operator request 2026-07-09) */
.approvals .attn-group-head { display: flex; align-items: center; gap: 10px;
  justify-content: space-between; margin: 14px 0 6px; }
.approvals .attn-group-head h4 { margin: 0; font-size: 13px; }

/* ── Desktop-width review (2026-07-09) — Approvals multi-column ──────────── */
/* Congregation blocks: responsive grid, 2–3 across on wide screens. */
.approvals .cong-grid { display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 14px; align-items: start; }
.approvals .cong-grid .cong-block { margin-bottom: 0; }
/* Needs-attention: masonry columns; a congregation group never splits. */
.approvals .attn-groups { columns: 460px; column-gap: 14px; }
.approvals .attn-group { break-inside: avoid; margin-bottom: 14px; }
@media (max-width: 640px) {
  .approvals .cong-grid { grid-template-columns: 1fr; }
  .approvals .attn-groups { columns: 1; }
}

/* ── Workflow control rail (2026-07-09) — shared grammar: scope → status →
   actions. Used by EMA/Badges, Schedule, and Setup → Logins; Roster's filter
   rail predates it and stays at 250px. */
.rail.rail-wide { width: 290px; }          /* control rails need the extra room */
.rail .seg { display: flex; width: 100%; }
.rail .seg button { flex: 1; }
.rail-counts { flex-direction: column; align-items: stretch; gap: 6px; margin: 0; }
.rail-counts .stat { flex-direction: row; align-items: baseline; gap: 8px; padding: 6px 10px; }
.rail .rail-group .btn { width: 100%; }
.rail .tpl-section { margin: 0; }
.rail .tpl-section > h3 { display: none; }  /* the rail-group h4 is the label */
.rail-counts .stat.attn b { color: var(--warn); }  /* at-risk count lights amber */

/* R-034: merge-field palette in the template editor */
.tpl-palette { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tpl-palette-tier { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-dim); margin: 0 3px 0 6px; }
.tpl-palette-tier:first-child { margin-left: 0; }
.tpl-chip { border: 1px solid var(--line); background: var(--bg); color: var(--accent);
  border-radius: 99px; padding: 2px 9px; font-size: 12px; cursor: pointer; font-family: inherit; }
.tpl-chip:hover { border-color: var(--accent); }
.tpl-subject { font-weight: 600; border-top: 1px solid var(--line); }

/* R-015: lanyard location-badge labels (print sheet). Sized for standard
   4x3 badge sleeves: two labels across a Letter page, dashed cut guides.
   Label anatomy (operator spec): sub-dept small on top, LOCATION dominant,
   report-to line below. */
@media print {
  .loc-badge-grid { display: grid; grid-template-columns: repeat(2, 3.9in); gap: 0; }
  .loc-badge { width: 3.9in; height: 2.55in; border: 1px dashed #999;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 0.15in; page-break-inside: avoid; box-sizing: border-box; }
  .loc-badge-sub { font-size: 13px; color: #333; text-transform: uppercase; letter-spacing: .08em; }
  .loc-badge-name { font-size: 30px; font-weight: 800; line-height: 1.1; margin: 8px 0; color: #000; }
  .loc-badge-report { font-size: 13px; color: #333; }
}

/* R-030 shell — 📣 text-blast dialog. The coming-soon block uses --warn so it
   reads as "not live yet" in both themes; the disabled Send inside it keeps
   the primary shape so the finished feature needs zero visual redesign. */
.blast-estimate { font-weight: 600; }
.blast-coming-soon {
  margin-top: 14px; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--warn); border-left: 4px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
.blast-coming-soon p { margin: 6px 0 10px; font-size: 13px; }
.blast-coming-soon .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* R-037 — WhatsApp text-blast join flow. The volunteer card leads with the
   WhatsApp green only on its primary action; the coverage board reuses the
   badge tones (err/warn/ok) so status reads like every other board. */
.wa-join { border-left: 4px solid #25d366; }
.wa-join h3 { margin: 0 0 4px; font-size: 15px; }
.wa-actions { margin-top: 8px; }
.wa-btn { background: #25d366; border-color: #25d366; color: #06281a; }
.wa-rejoin { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.wa-rejoin summary { cursor: pointer; font-size: 12.5px; color: var(--sub); }
.wa-rejoin summary:hover { color: var(--text); }
.wa-rejoin p { margin: 8px 0 10px; }

.wa-funnel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 12px 0; max-width: 720px; }
.wa-stage { background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px; text-align: center; }
.wa-n { font-size: 22px; font-weight: 800; }
.wa-stage.err .wa-n { color: var(--err); }
.wa-stage.warn .wa-n { color: var(--warn); }
.wa-stage.wa .wa-n { color: #25d366; }
.wa-stage.ok .wa-n { color: var(--ok); }
.wa-lbl { font-size: 11px; color: var(--sub); }

.wa-table { max-width: 900px; }
.wa-table td { vertical-align: top; }
.wa-dept td { background: var(--panel); font-weight: 700; font-size: 12px; }
.wa-rowbtns { white-space: nowrap; text-align: right; }
.wa-rowbtns .btn { margin-left: 6px; }
.wa-manual { font-style: italic; }
.wa-nolink { color: var(--warn); }
.wa-qr { display: block; margin: 10px auto; background: #fff;
  border-radius: 8px; padding: 8px; }
.wa-grant-list { max-height: 300px; overflow-y: auto; margin-top: 8px; }
.wa-grant-row { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }

/* R-039 — readable activity-log changes: glance chips on clickable rows,
   inline Before/After detail with the raw value one glance beneath. */
.act-row { cursor: pointer; }
.act-row:hover td { background: color-mix(in srgb, var(--line) 28%, transparent); }
.act-chip { display: inline-block; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 2px 9px; font-size: 12px; margin: 1px 4px 1px 0;
  white-space: nowrap; }
.act-chip.ok { color: var(--ok); border-color: var(--ok); }
.act-chip.err { color: var(--err); border-color: var(--err); }
.act-more { color: var(--sub); }
.act-detail > td { background: color-mix(in srgb, var(--panel) 55%, transparent); }
.act-panel { padding: 4px 2px 8px; }
.act-meta { margin-bottom: 8px; }
.act-diff { font-size: 13px; max-width: 780px; border-collapse: collapse; }
.act-diff th { text-align: left; color: var(--sub); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .04em; padding: 4px 10px 4px 0; }
.act-diff td { padding: 5px 14px 5px 0; vertical-align: top;
  border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.act-rawval { font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
.act-raw { margin-top: 8px; }
.act-raw summary { cursor: pointer; font-size: 12px; color: var(--sub); }
.act-raw pre { font-size: 11px; overflow-x: auto; background: var(--panel);
  padding: 8px 10px; border-radius: 6px; margin: 6px 0 0; }
