/* =============================================================================
   Grace Fellowship Operations Hub — base styles
   Plain CSS, no framework/build step. Organized top to bottom:
   tokens -> layout shell -> nav -> components -> forms -> tables -> utilities
   ============================================================================= */

:root {
  /* This app only ships a light theme, but never SAYS so — on a browser/OS
     set to dark mode, the browser then renders native form controls (a
     <select>'s own dropdown popup, date pickers, scrollbars) in ITS dark
     theme while everything else on the page stays light. For a <select>
     that shows up as a mismatched dark popup with a pale halo/seam around
     its edges where it overlaps the page's own (light) modal and shadow —
     "a white shade to the right and bottom of the dropdown list". Declaring
     the scheme explicitly is the standard fix: native controls then match
     the page instead of the OS.
  */
  color-scheme: light;
  --color-bg: #f6f7f4;
  --color-surface: #ffffff;
  --color-surface-alt: #f0f2ed;
  --color-border: #dde1d8;
  --color-text: #24291f;
  --color-text-muted: #5c6555;
  --color-primary: #3f6b3a;
  --color-primary-dark: #2c4d29;
  --color-primary-light: #e7efe2;
  --color-accent: #a8722f;
  --color-danger: #b3352c;
  --color-danger-light: #fbe9e7;
  /* Darkened from #a5760c: at the .72rem badge size that failed WCAG AA
     against --color-warning-light (3.66:1). Now ~4.9:1. */
  --color-warning: #8a6208;
  --color-warning-light: #fdf3dd;
  --color-success: #2f7a4d;
  --color-success-light: #e5f4ea;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 15, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 30, 15, 0.08);
  --sidebar-width: 240px;
  --topbar-height: 60px;
  /* Overridden at runtime from org_settings.brand_font (see
     js/branding.js FONT_OPTIONS + applyBranding() in js/app.js) — this
     default is what Demo Mode and a brand-new org start with. */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}
h1, h2, h3, h4 { font-weight: 650; line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }
a { color: var(--color-primary-dark); }
small, .text-muted { color: var(--color-text-muted); }

#app-shell { min-height: 100%; display: flex; flex-direction: column; }

#demo-banner {
  background: var(--color-warning-light);
  color: #6b4d05;
  border-bottom: 1px solid var(--color-warning);
  padding: 8px 16px;
  font-size: .82rem;
  text-align: center;
}
#demo-banner code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

/* The demo's "show me a church / charity / club" switch. Sits inline at the
   end of the banner text and wraps onto its own line on a phone. */
.demo-switch { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: 10px; }
.demo-switch-label { opacity: .8; }
.demo-switch-btn {
  font: inherit; cursor: pointer; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--color-warning); background: rgba(255,255,255,.6); color: inherit;
}
.demo-switch-btn:hover { background: #fff; }
.demo-switch-btn.is-current { background: #6b4d05; border-color: #6b4d05; color: #fff; cursor: default; }

/* ---------- Topbar ---------- */
#topbar {
  height: var(--topbar-height);
  background: var(--color-primary-dark);
  color: #fff;
  position: sticky; top: 0; z-index: 40;
}
.topbar-inner {
  height: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  max-width: 1400px; margin: 0 auto;
  /* min-width:0 + the .auth-slot rules below stop the identity cluster
     (bell + name + role badge + Switch Role + Sign out) from pushing the bar
     wider than the viewport on a phone, which used to give EVERY signed-in
     page a horizontal scrollbar and leave the topbar's green background
     ending mid-screen. */
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { font-size: 1.4rem; display: inline-flex; align-items: center; flex-shrink: 0; }
/* A logo, unlike the emoji mark, is usually a wordmark — wider than it is
   tall. Allowing real width (and letting object-fit keep the proportions)
   is what stops one being squeezed down to an illegible smudge; the topbar
   still gets its name and menu because .brand-name can ellipsize. */
.brand-mark.has-logo { font-size: 0; }
/* The white chip matters: logos are usually drawn in dark ink for a light
   page, and the topbar is a dark brand color — without it, half of a typical
   logo is invisible. Padding keeps the artwork off the edges of the chip. */
.brand-logo {
  height: 26px; max-width: 190px; width: auto; object-fit: contain; display: block;
  background: #fff; padding: 4px 8px; border-radius: 6px;
}
@media (max-width: 640px) { .brand-logo { height: 22px; max-width: 130px; padding: 3px 6px; } }
/* Product name after the organization's name: same line, visibly secondary,
   with a middle dot as the separator. */
.brand-product { font-weight: 500; opacity: .78; white-space: nowrap; }
.brand-product::before { content: "·"; margin-right: 8px; opacity: .7; }
/* On a phone the topbar has no room for both — the organization's own name
   wins (the browser tab still says "Operations Hub"). */
@media (max-width: 600px) { .brand-product { display: none !important; } }
.nav-toggle {
  display: none;
  margin-left: auto;
  background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer;
}
#nav-toggle[hidden] { display: none; }
.auth-slot { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.auth-slot .who { font-size: .85rem; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-slot .role-badge {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  background: rgba(255,255,255,.15); padding: 2px 8px; border-radius: 999px;
}

/* ---------- Universal search (js/globalSearch.js) ---------- */
.global-search { position: relative; min-width: 0; }
.global-search-input {
  width: 160px; max-width: 40vw; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
  color: #fff; border-radius: 999px; padding: 5px 12px; font-size: .85rem; transition: width .15s ease;
}
.global-search-input::placeholder { color: rgba(255,255,255,.65); }
.global-search-input:focus { width: 240px; background: #fff; color: var(--color-text); outline: none; }
.global-search-input:focus::placeholder { color: var(--color-text-muted); }
.global-search-results {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; width: 320px; max-width: 80vw;
  max-height: 70vh; overflow-y: auto; background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 6px 0;
}
.global-search-group-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted);
  padding: 6px 12px 2px;
}
.global-search-result { display: flex; flex-direction: column; gap: 1px; padding: 6px 12px; text-decoration: none; color: inherit; }
.global-search-result:hover, .global-search-result:focus { background: var(--color-surface-alt); }
.global-search-result-title { font-size: .88rem; font-weight: 600; }
.global-search-result-subtitle { font-size: .76rem; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.global-search-empty { padding: 12px; font-size: .85rem; color: var(--color-text-muted); text-align: center; }
@media (max-width: 760px) {
  .global-search-input { width: 36px; padding: 5px 8px; }
  .global-search-input::placeholder { color: transparent; }
  .global-search-input:focus { width: 180px; }
  .global-search-input:focus::placeholder { color: var(--color-text-muted); }
}

/* ---------- Layout ---------- */
#layout { display: flex; flex: 1; max-width: 1400px; margin: 0 auto; width: 100%; }
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 16px 10px;
  min-height: calc(100vh - var(--topbar-height));
}
.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-text-muted); margin: 14px 8px 4px;
}
.nav-links a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--color-text); text-decoration: none; font-size: .93rem;
}
.nav-links a:hover { background: var(--color-surface-alt); }
.nav-links a.active { background: var(--color-primary-light); color: var(--color-primary-dark); font-weight: 600; }

/* ---------- Accordion nav groups ---------- */
.nav-group { margin-top: 6px; }
.nav-group-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  background: none; border: none; text-align: left; font: inherit;
  font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-text-muted); padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.nav-group-toggle:hover { background: var(--color-surface-alt); color: var(--color-text); }
.nav-group.open > .nav-group-toggle { color: var(--color-primary-dark); background: var(--color-primary-light); }
.nav-group-chevron { display: inline-block; transition: transform .15s ease; font-size: .78rem; }
.nav-group.open .nav-group-chevron { transform: rotate(90deg); }
.nav-group-body { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 2px 4px; }
.nav-group-body[hidden] { display: none; }

/* Nested sub-accordion inside a nav group (currently just Administration's
   "Implementation Configuration") — a native <details>/<summary>, collapsed
   by default, for low-frequency setup screens that shouldn't compete with
   the regularly-used items alongside them. */
.nav-subgroup { margin-top: 2px; }
.nav-subgroup > summary {
  display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  padding: 8px 10px; border-radius: var(--radius-sm); font-size: .84rem; color: var(--color-text-muted);
}
.nav-subgroup > summary::-webkit-details-marker { display: none; }
.nav-subgroup > summary:hover { background: var(--color-surface-alt); color: var(--color-text); }
.nav-subgroup-chevron { display: inline-block; transition: transform .15s ease; font-size: .72rem; }
.nav-subgroup[open] > summary .nav-subgroup-chevron { transform: rotate(90deg); }
.nav-subgroup-body { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 2px 14px; }

/* Admin "combine several config screens in one page" accordion (e.g.
   Categories & Criteria) — same idea as the nav accordion above, applied to
   page content instead of nav links. */
.admin-accordion-section {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  margin-bottom: 12px; background: var(--color-surface);
}
.admin-accordion-section > summary {
  cursor: pointer; list-style: none; padding: 12px 16px; font-weight: 700; font-size: .95rem;
}
.admin-accordion-section > summary::-webkit-details-marker { display: none; }
.admin-accordion-section > summary::before { content: "▸ "; display: inline-block; transition: transform .15s ease; }
.admin-accordion-section[open] > summary::before { transform: rotate(90deg); }
.admin-accordion-body { padding: 0 16px 16px; }
.admin-accordion-body .page-header { display: none; }

.main-content { flex: 1; padding: 20px 24px 60px; min-width: 0; }
/* Signed-out visitors get no sidebar chrome — just the public page. */
#layout.no-sidebar .sidebar { display: none; }

/* ---------- Collapsible sidebar (desktop only — "more space for the
   work") ---------- */
/* Branded and labeled, not a tiny unlabeled icon — the original
   icon-only/outline version was too easy to miss entirely. */
.sidebar-collapse-btn {
  display: flex; align-items: center; gap: 6px; margin: 0 0 12px auto;
  background: var(--color-primary-light); border: 1px solid var(--color-primary); border-radius: var(--radius-sm);
  padding: 6px 10px; line-height: 1; cursor: pointer; color: var(--color-primary-dark);
  font-size: .82rem; font-weight: 600; box-shadow: var(--shadow-sm);
}
.sidebar-collapse-btn:hover { background: var(--color-primary); color: #fff; }
.sidebar-expand-btn {
  display: none; position: sticky; top: calc(var(--topbar-height) + 10px); z-index: 5;
  align-items: center; gap: 4px; align-self: flex-start; margin: 10px 0 0 6px;
  background: var(--color-primary); border: 1px solid var(--color-primary-dark); border-radius: var(--radius-sm);
  padding: 10px 6px; cursor: pointer; color: #fff; box-shadow: var(--shadow-md);
  writing-mode: vertical-rl; font-size: .78rem; font-weight: 600; letter-spacing: .02em;
}
.sidebar-expand-btn:hover { background: var(--color-primary-dark); }
@media (min-width: 861px) {
  #layout.sidebar-collapsed .sidebar { width: 0; min-width: 0; padding: 0; border-right: none; overflow: hidden; }
  #layout.sidebar-collapsed .sidebar-collapse-btn { display: none; }
  #layout.sidebar-collapsed .sidebar-expand-btn { display: flex; }
}
/* The collapse feature is desktop-only — the phone slide-out menu already
   starts hidden off-canvas and has its own ☰ toggle, so never show the
   expand handle there even if the collapsed state was set on a wider
   screen earlier. */
@media (max-width: 860px) { .sidebar-expand-btn { display: none !important; } }
#footer {
  text-align: center; padding: 18px; color: var(--color-text-muted); font-size: .82rem;
  border-top: 1px solid var(--color-border);
}
#footer p { margin: 0; }
/* Quiet on purpose: findable by staff who look for it, invisible to a
   visitor who doesn't. Hidden once signed in (nav.js renderAuthSlot). */
.footer-staff { margin-top: 6px !important; }
.footer-staff a { color: var(--color-text-muted); font-size: .78rem; }
.footer-staff a[hidden] { display: none; }

/* ---------- Cards & general components ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; }
.page-header { margin-bottom: 18px; }
.page-header p { color: var(--color-text-muted); margin-top: 4px; }

.grid { display: grid; gap: 16px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-tile .stat-label { font-size: .8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-tile .stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }
.stat-tile .stat-sub { font-size: .8rem; color: var(--color-text-muted); margin-top: 2px; }

/* ---------- Metric boxes (department dashboard cards, roster stats) ---------- */
.metric-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: box-shadow .12s ease;
}
.metric-box:hover { box-shadow: var(--shadow-sm); }
.metric-box.metric-accent-green { border-left-color: var(--color-success); }
.metric-box.metric-accent-amber { border-left-color: var(--color-warning); }
.metric-box.metric-accent-blue { border-left-color: var(--color-primary); }
.metric-box.metric-accent-red { border-left-color: var(--color-danger); }
.amount-negative { color: var(--color-danger); }
.metric-label { font-size: .74rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .03em; }
.metric-value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }
.metric-value-sm { font-size: 1rem; font-weight: 600; margin-top: 4px; }
.metric-box-title { font-weight: 700; margin-bottom: 10px; font-size: 1.02rem; }
.metric-box-row { display: flex; gap: 18px; margin-bottom: 10px; }
.metric-box-row > div { flex: 1; }
.dept-metric-box { display: flex; flex-direction: column; }
.dept-metric-box .btn { align-self: flex-start; margin-top: 2px; }
.dept-metrics-grid { align-items: stretch; }

.badge {
  display: inline-block; font-size: .72rem; padding: 2px 9px; border-radius: 999px;
  background: var(--color-surface-alt); color: var(--color-text-muted); font-weight: 600;
}
.badge.success { background: var(--color-success-light); color: var(--color-success); }
.badge.warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge.danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge.primary { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); padding: 8px 14px; font-size: .9rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  transition: background .12s ease;
}
button:hover, .btn:hover { background: var(--color-surface-alt); }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-link { background: none; border: none; color: var(--color-primary-dark); padding: 0; text-decoration: underline; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-primary); outline-offset: 2px;
}

/* ---------- Forms ---------- */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: #fff; color: var(--color-text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--color-primary-light); border-color: var(--color-primary); }
.field { margin-bottom: 14px; }
.field-hint { font-size: .78rem; color: var(--color-text-muted); margin-top: 3px; }
/* Three-column form layout (People, My Profile). Drops to two columns on a
   tablet and one on a phone, so a field is never squeezed to unusable.
   minmax(0, 1fr) and min-width:0 matter: without them a grid column refuses
   to shrink below its content, and inputs spill out of the card. */
.field-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.field-grid-3 > .field { min-width: 0; }
.field-grid-3 input, .field-grid-3 select, .field-grid-3 textarea { max-width: 100%; }
@media (max-width: 1000px) { .field-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* One column from tablet-portrait down: on a phone, two columns left the
   phone number, street and emergency contact boxes too cramped to type in. */
@media (max-width: 760px) { .field-grid-3 { grid-template-columns: 1fr; } }
.field-grid-3 .u-span-2 { grid-column: span 2; }
@media (max-width: 600px) { .field-grid-3 .u-span-2 { grid-column: span 1; } }

/* A titled block of related fields inside a long form. */
.form-section { border-top: 1px solid var(--color-border); padding-top: 14px; margin-top: 6px; }
.form-section:first-of-type { border-top: none; padding-top: 0; }
.form-section-title {
  margin: 0 0 10px; font-size: .76rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--color-text-muted);
}
.form-section[hidden] { display: none; }

/* Dialling code + number as one control: the code stays just wide enough
   for "+000", and the number takes all the space that is left. */
.phone-row { display: flex; gap: 6px; min-width: 0; }
.phone-row .phone-code { width: 4.25rem; flex: 0 0 auto; text-align: center; }
.phone-row input[type="tel"] { flex: 1 1 auto; min-width: 0; }

/* The red * marking a required field (see markRequiredFields in util.js). */
.required-mark { color: var(--color-danger); margin-left: 3px; font-weight: 700; }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
/* min-width was a flat 180px, so a two-up row needed ~448px of viewport once
   modal + backdrop padding was counted — every side-by-side form field
   (Date/Amount, First/Last name, Min/Max age...) overflowed the screen on a
   360px phone. Clamping to the available width lets the row wrap to one
   column instead. */
.field-row .field { flex: 1 1 180px; min-width: min(180px, 100%); }
fieldset { border: 1px solid var(--color-border); border-radius: var(--radius); margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* A <select> inside a table cell inherits width:100% from the rule above,
   but an auto-layout table column shrinks to fit its content first — the
   two fight and the select ends up squeezed too narrow to show its full
   selected option (e.g. "In Progress" on the Tasks page). Giving it a fixed
   natural width instead of 100% breaks that feedback loop. */
.table-wrap select { width: auto; min-width: 132px; }

/* ---------- Tables ---------- */
/* Wide/long tables scroll inside their own box, capped at most of the
   viewport, with a sticky header row. This replaces an older "double
   rotateX(180deg)" trick that put the horizontal scrollbar on top: that
   trick mirrored the scroll container, so touch-swipe and trackpad scroll
   ran BACKWARDS inside every table, and it made a sticky header impossible
   (sticky cannot work under a transformed ancestor). The capped height keeps
   the horizontal scrollbar on screen — the original goal — while the column
   labels stay visible however far down a 300-row ledger you scroll. */
.table-wrap {
  overflow: auto;
  max-height: min(70vh, 900px);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.table-wrap thead th { position: sticky; top: 0; z-index: 1; }
/* Inside a modal the modal body already scrolls — don't nest a second
   vertical scroller there. */
.modal-body .table-wrap { max-height: none; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--color-text-muted); background: var(--color-surface-alt); }
tbody tr:hover { background: var(--color-surface-alt); }
td.wrap, th.wrap { white-space: normal; }
/* A wrapping column that also needs real estate to be readable (e.g. Tasks
   & To-Do's Description) — combine with .wrap: class="wrap col-wide". */
td.col-wide, th.col-wide { min-width: 260px; }
/* Single-line, fixed-width, ellipsis-truncated cell — used for Finance
   table Notes columns so a long note doesn't blow out the row height or
   push more useful columns off-screen, letting more records fit on one
   screen. Full text is still available via the row's Edit action (and as
   a hover tooltip, from the cell's title attribute) — nothing is lost,
   just collapsed until the record is opened. */
td.cell-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Money columns: right-aligned with tabular figures so decimal points line
   up down the column and a Treasurer can scan for an order-of-magnitude
   mistake without reading every digit. Apply as class="num" on both the
   <th> and the <td>. */
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- Reusable sortable/searchable/filterable/paginated table
   (js/dataTable.js) — dense rows, no zebra striping, bottom-only
   pagination, matching the Songbook Hub app's table UX. ---------- */
.data-table-wrap .table-toolbar { margin-bottom: 10px; }
/* A second horizontal scrollbar, mirrored with the real one at the bottom
   of .table-wrap (js/dataTable.js keeps scrollLeft in sync both ways) — a
   wide table can run well past a screenful of ROWS, and the native
   scrollbar at the very bottom of a (possibly 900px-tall) .table-wrap is
   easy to lose track of. overflow-y is hidden so this strip is never
   anything but a scrollbar: the spacer inside gives it the table's own
   scrollable width without rendering the table a second time. Hidden
   entirely (js/dataTable.js sets dt-top-scroll[hidden]) when the table
   already fits without scrolling. */
.dt-top-scroll { overflow-x: auto; overflow-y: hidden; height: 16px; margin-bottom: 2px; }
.dt-top-scroll-spacer { height: 1px; }
.data-table-wrap .dt-search { flex: 1 1 200px; max-width: 340px; }
.data-table th[data-sort-key] { padding: 0; }
.sort-btn {
  width: 100%; display: flex; align-items: center; gap: 4px; justify-content: inherit;
  background: none; border: none; cursor: pointer; font: inherit; text-transform: inherit;
  letter-spacing: inherit; color: inherit; padding: 9px 10px; white-space: nowrap;
}
.sort-btn:hover { color: var(--color-primary-dark); }
.sort-glyph { opacity: .55; font-size: .8em; }
/* Every row stays a single line — long cell content is ellipsis-clipped
   rather than wrapping to a second line, which would both inflate row
   height (fewer records visible per screen) and misalign columns across
   rows. A badge (e.g. Status) still renders its full label on that one
   line; it just never wraps either. */
.data-table td, .data-table th { padding: 6px 10px; line-height: 1.3; font-size: .85rem; }
.data-table td { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table td .badge { white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: none; }
/* One separate dropdown per filter field (Status, Type, Role, …) rather
   than every field merged into one combined "Filters" button — each is
   its own small host+toggle+panel, so there's no shared state to mix up
   between fields and no single oversized panel to scan through. */
.dt-filter-host { position: relative; }
.dt-filter-toggle { white-space: nowrap; }
.dt-filter-caret { opacity: .6; font-size: .75em; }
.dt-filter-badge {
  display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 2px; border-radius: 999px;
  background: var(--color-primary); color: #fff; font-size: .72rem; line-height: 16px; text-align: center;
}
.dt-filter-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 5; min-width: 180px; max-width: 280px;
  max-height: 60vh; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: 8px; display: flex; flex-direction: column; gap: 2px;
}
/* `display: flex` above has the same specificity as the UA stylesheet's
   `[hidden] { display: none }` and comes later, so it was winning and
   making the `hidden` attribute a no-op — every filter panel rendered open
   at all times, which is what made the dropdowns look like they never
   closed and let them cover the top scrollbar row. */
.dt-filter-panel[hidden] { display: none; }
.dt-filter-option { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: .85rem; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm); }
.dt-filter-option:hover { background: var(--color-surface-alt); }
/* The global `input { width: 100% }` rule (styles.css:384) otherwise
   stretches each checkbox to fill the row, shoving its label off to the
   right with a big empty gap in between — looking like the whole list is
   right-aligned instead of a normal left-aligned checkbox list. */
.dt-filter-option input { margin: 0; width: auto; }
.dt-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px;
}
.dt-page-size select { width: auto; min-width: 0; display: inline-block; margin-left: 4px; }
.pagination { display: flex; align-items: center; gap: 2px; }
.page-btn {
  min-width: 28px; height: 28px; padding: 0 6px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; cursor: pointer; font: inherit; color: inherit;
}
.page-btn:hover:not(:disabled) { background: var(--color-surface-alt); }
.page-btn:disabled { opacity: .4; cursor: default; }
.page-btn.current { background: var(--color-primary); border-color: var(--color-primary-dark); color: #fff; }
.page-gap { padding: 0 4px; color: var(--color-text-muted); }

/* ---------- Volunteer Availability month grid (js/modules/volunteerAvailability.js) ---------- */
.va-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.va-grid-header { margin-top: 12px; margin-bottom: 0; }
.va-cell-weekday { text-align: center; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--color-text-muted); padding: 4px 0; }
.va-cell {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
  cursor: pointer; font: inherit; gap: 2px; min-height: 44px;
}
.va-cell:hover { background: var(--color-surface-alt); }
.va-cell-blank { visibility: hidden; cursor: default; }
.va-cell-day { font-size: .85rem; }
.va-cell-status { font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.va-cell-today { border-color: var(--color-primary); border-width: 2px; }
.va-cell-selected { outline: 3px solid var(--color-primary-dark); outline-offset: -3px; }
.va-cell-weekday-clickable { cursor: pointer; background: var(--color-surface); border: 1px solid var(--color-border); }
.va-cell-weekday-clickable:hover { background: var(--color-primary-light); color: var(--color-primary-dark); }
.va-cell-weekday[disabled] { cursor: default; opacity: 1; }
.va-cell.av-available { background: var(--color-primary-light); border-color: var(--color-primary); }
.va-cell.av-unavailable { background: var(--color-danger-light); border-color: var(--color-danger); }
.va-cell.av-tentative { background: #fff6da; border-color: #d8b74a; }
@media (max-width: 560px) {
  .va-cell { min-height: 36px; }
  .va-cell-day { font-size: .75rem; }
}

/* Section dividers on the Reports & Export page — groups simpler reports
   (Directory & Program) ahead of the busier, filter-heavy Finance ones, so
   the page reads as organized sections rather than one long undifferentiated
   grid of cards. */
.reports-section-heading { margin: 22px 0 10px; font-size: 1rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.reports-section-heading:first-of-type { margin-top: 4px; }
/* Inverse of .no-print (below, in @media print): hidden on screen, shown
   only when printing — for a plain-text stand-in of a live form control
   (e.g. Judge Onboarding's status <select>) so a printed page shows a
   readable badge instead of an interactive dropdown. */
.print-only { display: none; }
.table-empty { padding: 30px; text-align: center; color: var(--color-text-muted); }
.table-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.table-toolbar input[type="search"], .table-toolbar select { width: auto; min-width: 160px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,25,15,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: var(--radius); max-width: 620px; width: 100%;
  padding: 22px; box-shadow: var(--shadow-md);
}
@media (max-width: 600px) {
  .modal-backdrop { padding: 16px 8px; }
  .modal { padding: 16px; }
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-close { background: none; border: none; font-size: 1.3rem; padding: 0 4px; }
.modal-body { max-height: 70vh; overflow-y: auto; }
/* Reports & Export opens its report cards (filters + View/Export) inside a
   modal instead of inline on the page — strip the card's own border/shadow/
   padding there so it doesn't double-box inside the modal's own frame. */
.modal-body > .card { border: none; box-shadow: none; padding: 0; }
/* The card's own <h3> repeats the modal header's title right above it —
   drop it there without touching the same card when it's NOT in a modal
   (reports.js no longer renders these cards inline, but keep this scoped
   to .modal-body rather than deleting the heading from the markup itself,
   in case something else ever reuses these builder functions outside a
   modal). */
.modal-body > .card > h3:first-child { display: none; }
.modal-footer:not(:empty) { margin-top: 14px; }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; top: 72px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--color-text); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); font-size: .88rem; max-width: 320px;
}
.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-danger); }
.toast-alert { display: block; width: 100%; text-align: left; border: none; cursor: pointer; font: inherit; }
.toast-alert.alert-assigned { background: var(--color-primary-dark); }
.toast-alert.alert-message { background: var(--color-text); }
.toast-alert.alert-overdue { background: var(--color-danger); }

/* ---------- App-level banners (Demo Mode, database version) ---------- */
.app-banner {
  padding: 10px 16px; font-size: .85rem; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.app-banner-warning {
  background: var(--color-warning-light); color: #5d4304;
  border-bottom: 1px solid var(--color-warning);
}
.app-banner code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

/* ---------- "Our Team" (public) ---------- */
.team-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.team-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
.team-photo {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  background: var(--color-primary-light); display: flex; align-items: center; justify-content: center;
}
.team-photo img { width: 100%; height: 100%; object-fit: cover; }
.team-initials { font-size: 1.9rem; font-weight: 700; color: var(--color-primary-dark); }
.team-name { margin: 0; font-size: 1.05rem; }
.team-role { margin: 2px 0 0; color: var(--color-primary-dark); font-weight: 600; font-size: .9rem; }
.team-about { margin: 0; font-size: .9rem; color: var(--color-text-muted); }
.team-details { margin: 0; font-size: .82rem; }
.team-details dt { font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .03em; font-size: .7rem; margin-top: 6px; }
.team-details dd { margin: 1px 0 0; }

/* Photo chooser in the People form and My Profile. */
.photo-picker { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.photo-picker .photo-thumb {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  background: var(--color-primary-light); display: flex; align-items: center; justify-content: center;
}
.photo-picker .photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-picker .team-initials { font-size: 1.2rem; }
.photo-picker input[type="file"] { width: auto; max-width: 100%; }

/* ---------- Dashboard: My Hub ----------
   The personal half of the dashboard every role sees first. Cards pair up
   side by side on a wide screen and stack on a phone; lists are compact so a
   week's worth of items fits without scrolling past the programs table. */
.hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.hub-grid:empty { display: none; }
@media (max-width: 900px) { .hub-grid { grid-template-columns: 1fr; } }
.hub-grid > .card, .my-hub > .card { margin-bottom: 16px; }
.hub-card { min-width: 0; }
.hub-list { list-style: none; margin: 0; padding: 0; }
.hub-list li { padding: 9px 0; border-bottom: 1px solid var(--color-border); }
.hub-list li:last-child { border-bottom: none; }
.hub-item-main { line-height: 1.35; overflow-wrap: anywhere; }
.hub-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 3px; font-size: .82rem; }
.hub-overdue { color: var(--color-danger); font-weight: 600; }
.hub-giving-actions { margin-top: 12px; }

/* People sorted by household: a heavier rule where one family ends. */
tr.household-break td { border-top: 2px solid var(--color-border); }

/* ---------- Public landing page ---------- */
.hero {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  color: #fff; border-radius: var(--radius); padding: 40px 30px; margin-bottom: 24px;
}
.hero h1 { font-size: 2rem; margin-bottom: 8px; }
.hero p { opacity: .95; max-width: 640px; }
.public-section { margin-bottom: 30px; }

/* ---------- About Operations Hub (#/about) ----------
   A page about the software rather than the organization. It reuses the
   public site's hero and cards so it inherits the org's branding; only the
   bits with no equivalent elsewhere are defined here. */
.about-hero { padding: 46px 30px; }
.about-kicker {
  text-transform: uppercase; letter-spacing: .09em; font-size: .74rem;
  font-weight: 700; opacity: .8; margin-bottom: 10px;
}
.about-hero h1 { font-size: 2.3rem; line-height: 1.15; max-width: 18ch; }
.about-cta { margin-top: 22px; }
@media (max-width: 640px) {
  .about-hero { padding: 30px 20px; }
  .about-hero h1 { font-size: 1.7rem; }
  .about-cta .btn { flex: 1 1 100%; text-align: center; }
}
.btn-lg { padding: 11px 22px; font-size: 1rem; }
/* A second button ON the hero: the normal .btn is a light chip, which
   disappears against the hero's brand-color gradient. */
.btn-on-hero { background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }
.btn-on-hero:hover { background: rgba(255,255,255,.15); }

.about-promise { text-align: center; }
.about-promise-icon { font-size: 1.9rem; line-height: 1; margin-bottom: 8px; }
.about-promise h3 { margin-bottom: 6px; }
.about-promise p { margin: 0; font-size: .88rem; }

.about-section-title { margin-bottom: 14px; }
/* Two columns of feature cards that fill naturally, so a group with five
   points and one with three do not leave a hole between them. */
.about-features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .about-features { grid-template-columns: 1fr; } }
.about-feature h3 { margin-bottom: 4px; }
.about-feature-lead { margin-bottom: 10px; font-size: .88rem; }
.about-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.about-list li { font-size: .9rem; line-height: 1.45; }

.about-demo h2, .about-closing h2 { margin-bottom: 6px; }
.about-contact { text-align: center; }
.about-contact h2 { margin-bottom: 8px; }
.about-contact-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
.about-contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.about-contact-list a { overflow-wrap: anywhere; }
.about-closing { text-align: center; }
.about-closing .btn-row { justify-content: center; margin-top: 16px; }

/* The topbar's signed-out sign-in button: readable on the brand color
   without competing with the organization's own name beside it. */
.btn-signin { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.6); color: #fff; }
.btn-signin:hover { background: rgba(255,255,255,.28); }
.program-card, .event-card { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px; background: #fff; }
.login-box { max-width: 380px; margin: 60px auto; }

/* ---------- Roster & Staffing ---------- */
.teacher-list { display: flex; flex-direction: column; gap: 10px; }
.teacher-card { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--color-surface-alt); }
.teacher-card-name { font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.avail-row { display: flex; gap: 4px; }
.avail-dot {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff; background: #c7ccc0; cursor: default;
}
.avail-dot.avail-available { background: var(--color-success); }
.avail-dot.avail-tentative { background: var(--color-warning); }
.avail-dot.avail-unavailable { background: var(--color-danger); }
.avail-dot.avail-unknown { background: #c7ccc0; color: #55594e; }
.avail-exceptions { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.avail-exception-row { font-size: .8rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------- Help & Guides (QRG / FAQ accordions) ---------- */
.qrg-card summary, .faq-item summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
}
.qrg-card summary::-webkit-details-marker, .faq-item summary::-webkit-details-marker { display: none; }
.qrg-card summary::before, .faq-item summary::before {
  content: "▸"; display: inline-block; font-size: .8rem; color: var(--color-text-muted);
  transition: transform .15s ease;
}
.qrg-card[open] summary::before, .faq-item[open] summary::before { transform: rotate(90deg); }
.qrg-title { font-size: 1.05rem; font-weight: 700; }
.qrg-list { margin: 14px 0 0; padding-left: 22px; }
.qrg-list li { margin-bottom: 9px; }
.faq-item { border-bottom: 1px solid var(--color-border); padding: 10px 2px; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary { font-weight: 600; }
.faq-item p { margin: 8px 0 0 20px; color: var(--color-text-muted); }

/* ---------- Misc ---------- */
.view-page { min-height: 40px; }
/* Don't flash "Loading…" for a page that answers quickly — only show it
   once a load has taken longer than a moment. */
.loading { color: var(--color-text-muted); padding: 30px; text-align: center; animation: loading-in .01s linear .35s both; }
@keyframes loading-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .loading { animation: none; } }
.divider { border: none; border-top: 1px solid var(--color-border); margin: 18px 0; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Notification bell (topbar) ---------- */
.nav-bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; font-size: 1.05rem;
  text-decoration: none; color: #fff; opacity: .9;
}
.nav-bell:hover { background: rgba(255,255,255,.15); opacity: 1; }
.notif-badge {
  position: absolute; top: -3px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--color-danger); color: #fff; font-size: .65rem;
  font-weight: 700; line-height: 16px; text-align: center;
}

/* ---------- Messages inbox ---------- */
.data-table tbody tr.msg-unread { font-weight: 700; }
.dot-unread {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-primary);
}

/* ---------- Sticky notes widget ---------- */
/* Opened via the "Quick Notes" link in the sidebar, right below Help &
   Guides — see nav.js. Toggled by setting/clearing the `hidden` attribute,
   so the [hidden] rule below MUST win over the plain .notes-panel rule's
   `display: flex` (same pattern as .nav-group-body[hidden] above) — without
   it the panel never actually disappears when "closed". */
.notes-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 90; width: 300px; max-height: 70vh;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden;
}
.notes-panel[hidden] { display: none; }
.notes-panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--color-border);
}
.notes-panel-header h3 { font-size: .95rem; margin: 0; }
.notes-panel-close { background: none; border: none; font-size: 1.2rem; line-height: 1; padding: 2px 4px; color: var(--color-text-muted); }
.notes-list { overflow-y: auto; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.sticky-note {
  border-radius: var(--radius-sm); padding: 8px; box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,.06);
}
.sticky-note-toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.sticky-note-toolbar button { background: none; border: none; padding: 2px 4px; font-size: .85rem; box-shadow: none; }
.sticky-note-toolbar button:hover { background: rgba(0,0,0,.06); border-radius: 4px; }
.sticky-pin.active { filter: none; opacity: 1; }
.sticky-pin:not(.active) { opacity: .4; }
.sticky-colors { display: flex; gap: 4px; margin-left: auto; }
.sticky-color-dot { width: 14px; height: 14px; border-radius: 50%; padding: 0; border: 1px solid rgba(0,0,0,.15); }
.sticky-color-yellow { background: #fff3b0; }
.sticky-color-pink { background: #ffd6e7; }
.sticky-color-blue { background: #cfe8ff; }
.sticky-color-green { background: #d3f2d6; }
.sticky-color-purple { background: #e6d9fb; }
.sticky-note.sticky-yellow { background: #fffbe6; }
.sticky-note.sticky-pink { background: #fff0f6; }
.sticky-note.sticky-blue { background: #eef7ff; }
.sticky-note.sticky-green { background: #eefbef; }
.sticky-note.sticky-purple { background: #f6f0fe; }
.sticky-note .sticky-body {
  width: 100%; border: none; background: transparent; resize: vertical; font: inherit;
  color: var(--color-text); padding: 2px 4px;
}
.sticky-note .sticky-body:focus { outline: none; }

/* ---------- Public chat widget (js/chatWidget.js) ---------- */
/* Bottom-right by default (org_settings.chat_widget_position, set in Org
   Settings → Ticketing — Website Chat) — the ".chat-widget-left" modifier
   class below moves both the bubble and panel to the left instead. The
   signed-in-staff-only Quick Notes panel also lives bottom-right, but the
   two never show at once (one is signed-out-visitor-only), so there is no
   actual overlap regardless of which side the admin picks. */
/* A circular button with "Chat with us" curved around its inner rim (the
   SVG ring text) and the icon in the center — a smaller footprint than the
   old wide pill button, while still being readable without a hover. */
.chat-widget-bubble {
  position: fixed; right: 22px; bottom: 22px; z-index: 90; width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center; padding: 0;
  border-radius: 999px; border: none; background: var(--color-primary); color: #fff;
  font-size: 1rem; font-weight: 600; box-shadow: var(--shadow-md); cursor: pointer; white-space: nowrap;
}
.chat-widget-bubble-icon { font-size: 1.4rem; line-height: 1; position: relative; z-index: 1; }
.chat-widget-bubble-ring { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.chat-widget-bubble-ring text, .chat-widget-bubble-ring textPath {
  fill: #fff; font-size: 8.5px; font-weight: 600; letter-spacing: .1px;
}
.chat-widget-bubble[hidden] { display: none; }
/* A waiting reply from the agent while the panel is closed. */
.chat-widget-bubble-badge {
  position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 999px;
  background: var(--color-danger, #d64545); border: 2px solid var(--color-primary); z-index: 2;
  animation: chat-widget-badge-pulse 1.6s ease-in-out infinite;
}
.chat-widget-bubble-badge[hidden] { display: none; }
@keyframes chat-widget-badge-pulse {
  0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); }
}
.chat-widget-panel {
  position: fixed; right: 22px; bottom: 90px; z-index: 90; width: 320px; max-height: 70vh;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden;
}
.chat-widget-panel[hidden] { display: none; }
.chat-widget-bubble.chat-widget-left { right: auto; left: 22px; }
.chat-widget-panel.chat-widget-left { right: auto; left: 22px; }

/* Running inside widget.html as another site's iframe (public/embed.js):
   the HOST page positions and sizes the iframe itself (it knows nothing
   about chat_widget_position — that's communicated separately, see
   notifyHost() in js/chatWidget.js), so the widget just fills whatever
   box it's given rather than placing itself in a page corner. */
.chat-widget-bubble.chat-widget-embedded {
  position: relative; width: 100%; height: 100%; border-radius: 0; padding: 0; justify-content: center;
}
.chat-widget-bubble.chat-widget-embedded .chat-widget-bubble-ring { display: none; }
.chat-widget-panel.chat-widget-embedded {
  position: static; width: 100%; height: 100%; max-height: none; border-radius: 0; border: none;
}
.chat-widget-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--color-border); background: var(--color-primary); color: #fff;
}
.chat-widget-header h3 { font-size: .95rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-widget-avatar { font-size: 1.3rem; line-height: 1; }
.chat-widget-avatar[hidden] { display: none; }
.chat-widget-avatar img { width: 24px; height: 24px; border-radius: 999px; object-fit: cover; display: block; }
.chat-identity-photo-preview { width: 36px; height: 36px; border-radius: 999px; object-fit: cover; }
.chat-widget-close { background: none; border: none; font-size: 1.2rem; line-height: 1; padding: 2px 4px; color: #fff; }
/* overflow-y: auto is the fix for "Start chat isn't visible until I zoom
   out" — the name-gate form (welcome message + greeting + name/email/phone
   + message box + button) can be taller than the panel's fixed height at
   normal zoom; .chat-widget-panel clips overflow, so without its own
   scrollbar the button was simply rendered off the bottom, unreachable.
   Zooming out shrank the CSS-px content enough to fit, which is why it
   "worked" at 50%. */
.chat-widget-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 10px 12px 12px; gap: 8px; overflow-y: auto; }
/* align-items: flex-start (not the flex default of stretch) keeps "Start
   chat" sized to its own text instead of stretching to the panel's full
   width — the text/email/phone/message inputs stay full-width regardless,
   since they already set their own width: 100% explicitly. */
.chat-widget-start { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.chat-widget-start .field, .chat-widget-start .field-row { width: 100%; }
/* #chat-widget-body (the flex column everything sits in) defaults its
   children to align-items: stretch — fine for the thread/forms, which are
   already full-width on their own terms, but it also stretched the
   "Start new chat" button (renderClosedThread()) to the panel's full
   width with nothing else asking it to. */
.chat-widget-self-sized-btn { align-self: flex-start; }
.chat-widget-start-btn { padding: 11px 22px; font-size: 1rem; }
.chat-widget-thread { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.chat-widget-msg { max-width: 85%; padding: 6px 10px; border-radius: var(--radius-sm); font-size: .88rem; }
.chat-widget-msg-staff { align-self: flex-start; background: var(--color-surface-alt); }
.chat-widget-msg-me { align-self: flex-end; background: var(--color-primary-light); }
.chat-widget-reply { display: flex; gap: 6px; }
.chat-widget-reply input { flex: 1; }
.chat-widget-agents { margin: 0 0 8px; }
.chat-widget-welcome { font-weight: 600; margin: 0 0 8px; }
.chat-widget-end { align-self: center; margin-top: 4px; font-size: .82rem; }
.chat-widget-attach-btn { display: flex; align-items: center; cursor: pointer; font-size: 1.2rem; padding: 0 2px; }
.chat-widget-attachment-img { max-width: 100%; max-height: 160px; border-radius: var(--radius-sm); display: block; margin-bottom: 4px; }
.ticket-msg-attachment-img { max-width: 240px; max-height: 200px; border-radius: var(--radius-sm); display: block; margin: 4px 0; }
/* A Google Meet link an agent pasted into a message (see "Start Google
   Meet" in ticketing.js and linkifyMeetLinks() in util.js), rendered as a
   button instead of a bare URL — for both the staff thread and the
   visitor-facing widget. */
.meet-call-link {
  display: inline-flex; align-items: center; gap: 4px; margin: 4px 0; padding: 4px 10px;
  border-radius: var(--radius-sm); background: var(--color-success, #2e7d32); color: #fff;
  font-weight: 600; font-size: .85rem; text-decoration: none;
}
.meet-call-link:hover { filter: brightness(1.1); }

/* A fixed 320px/90px-from-bottom panel is fine on a laptop, but on a phone
   screen it either overflows the viewport width or leaves barely any room
   to type — so below the app's usual mobile breakpoint the panel instead
   fills the whole screen (same full-bleed treatment as the embedded-iframe
   case above, just triggered by viewport size instead of being embedded)
   and the bubble grows into an easier thumb target. */
@media (max-width: 600px) {
  /* A slightly larger touch target, tucked closer to the corner, on a
     phone screen. */
  .chat-widget-bubble:not(.chat-widget-embedded) { width: 68px; height: 68px; right: 14px; bottom: 14px; }
  .chat-widget-bubble.chat-widget-left:not(.chat-widget-embedded) { left: 14px; }
  .chat-widget-panel:not(.chat-widget-embedded) {
    inset: 0; right: 0; bottom: 0; width: 100%; height: 100%; max-height: none; border-radius: 0; border: none;
  }
  /* Email/phone were sharing one row at a fixed 180px basis each — on a
     phone that's wider than half the screen, so both boxes shrank down
     small instead of wrapping to their own line. Stack them full-width,
     same as the name field above them. The basis reset is needed too:
     unchanged, each field's 180px *width* basis becomes a 180px *height*
     basis the moment the row turns into a column, leaving a huge gap. */
  .chat-widget-start .field-row { flex-direction: column; }
  .chat-widget-start .field-row .field { flex: 1 1 auto; min-width: 0; }
}

/* ---------- Volunteer signup (public page) ---------- */
.volunteer-slot-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px;
}

/* Quick Notes is an action, so it is a <button> — styled to sit in the nav
   exactly like its neighbouring links. */
.nav-links .nav-action-link {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: var(--radius-sm); border: none; background: none;
  color: var(--color-text); font: inherit; font-size: .93rem; font-weight: 400; text-align: left;
}
.nav-links .nav-action-link:hover { background: var(--color-surface-alt); }

/* Honeypot for the public forms (util.js publicFormGuardHtml): moved off
   screen rather than display:none, which some bots know to skip. */
.hp-field { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* Backdrop behind the phone menu (see setMobileNav in js/nav.js). Sits
   below the sidebar (z-index 50) and above everything else. */
.nav-scrim {
  position: fixed; inset: var(--topbar-height) 0 0 0; z-index: 45;
  background: rgba(20, 25, 15, .38);
}
.nav-scrim[hidden] { display: none; }
/* No slide-out menu on wide screens, so never a backdrop either. */
@media (min-width: 861px) { .nav-scrim { display: none !important; } }

/* ---------- Responsive nav ---------- */
/* Below ~600px the identity cluster still could not fit: the name and role
   badge are redundant there (both are on My Profile, one tap away) while
   "Sign out" is not. Dropping them is what finally removes the last of the
   horizontal page scroll on a phone. */
@media (max-width: 600px) {
  /* The Demo Mode banner was five lines tall on a phone — more than the
     topbar and page title together. */
  #demo-banner { font-size: .74rem; padding: 6px 10px; line-height: 1.35; }
  .demo-switch { display: flex; justify-content: center; margin: 6px 0 0; width: 100%; }
  .auth-slot .who, .auth-slot .role-badge { display: none; }
  .topbar-inner { gap: 8px; padding: 0 10px; }
  .toast-host { right: 8px; left: 8px; }
  .toast { max-width: none; }
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-height); bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 16px; }
}

/* ---------- Print (Help & Guides "Print this page") ---------- */
@media print {
  #topbar, .sidebar, #toast-host, #footer, .no-print, .notes-panel, .chat-widget-bubble, .chat-widget-panel, #demo-banner { display: none !important; }
  .print-only { display: inline-block !important; }
  #layout { display: block; max-width: none; }
  .main-content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  /* Force every collapsed <details> open so the printed page is complete,
     not just whichever QRG section happened to be expanded on screen. */
  details:not([open]) > *:not(summary) { display: block !important; }
  .qrg-card summary::before, .faq-item summary::before { content: ""; }
  /* Paper has no scrollbar: print every table in full, in normal flow. */
  .table-wrap { overflow: visible; max-height: none; }
  .table-wrap thead th { position: static; }
}

/* Printing a single open modal (e.g. a program/event signup list) instead of
   the whole page behind it — see printModal() in util.js. Only takes effect
   while body.printing-modal is set, and only during printing itself. */
@media print {
  body.printing-modal #topbar,
  body.printing-modal #layout,
  body.printing-modal #toast-host,
  body.printing-modal .notes-panel { display: none !important; }
  body.printing-modal .modal-backdrop {
    position: static; display: block; background: none; padding: 0; height: auto;
  }
  body.printing-modal .modal {
    box-shadow: none; max-width: none; width: 100%; max-height: none;
  }
  body.printing-modal .modal-body { max-height: none; overflow-y: visible; }
  body.printing-modal .modal-close, body.printing-modal .no-print { display: none !important; }
}

/* ---------- Competition certificates (printed via printModal(), one per
   participant — see openCertificatesModal() in competitionDetail.js) ---------- */
.certificate-sheet { display: flex; flex-direction: column; gap: 18px; }
.certificate {
  border: 3px double var(--color-accent, #8a6d3b); border-radius: 10px;
  padding: 28px; text-align: center; background: #fffdf7;
}
.certificate-inner { max-width: 480px; margin: 0 auto; }
.cert-eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--color-muted, #777); margin: 0 0 6px; }
.certificate h2 { font-family: Georgia, "Times New Roman", serif; margin: 0 0 14px; font-size: 1.5rem; }
.cert-presented { margin: 0; font-size: .85rem; color: var(--color-muted, #777); }
.cert-name { font-family: Georgia, "Times New Roman", serif; font-size: 1.6rem; margin: 4px 0 12px; border-bottom: 1px solid var(--color-border, #ddd); display: inline-block; padding-bottom: 4px; }
.cert-detail { margin: 2px 0; font-size: .9rem; }
.cert-rank { margin-top: 12px; font-weight: 700; font-size: 1.1rem; color: var(--color-accent, #8a6d3b); }
@media print {
  .certificate { break-inside: avoid; page-break-after: always; }
  .certificate:last-child { page-break-after: auto; }
}


/* =============================================================================
   Utilities
   Replaced ~120 one-off inline style="" attributes across the modules, so
   spacing and type can be adjusted in one place. !important is deliberate
   (the Bootstrap convention for utilities): they replaced INLINE styles,
   which outranked every component rule, and must keep doing so.
   ============================================================================= */
.u-m0 { margin: 0 !important; }
.u-mt-0 { margin-top: 0 !important; }
/* .u-mt-sm/.u-ml-xs were already used in a few places (ticketing.js) without
   ever being defined, so those elements silently got no margin at all —
   adding them here fixes those too, not just the new dashboard use. */
.u-mt-sm { margin-top: 8px !important; }
.u-ml-xs { margin-left: 4px !important; }
.u-mt-8 { margin-top: 8px !important; }
.u-mt-10 { margin-top: 10px !important; }
.u-mt-12 { margin-top: 12px !important; }
.u-mt-16 { margin-top: 16px !important; }
.u-mb-10 { margin-bottom: 10px !important; }
.u-mb-16 { margin-bottom: 16px !important; }
.u-mb-20 { margin-bottom: 20px !important; }
.u-my-10 { margin-top: 10px !important; margin-bottom: 10px !important; }
.u-block-tight { display: block !important; margin: 4px 0 !important; }
.u-text-xs { font-size: .75rem !important; }
.u-text-80 { font-size: .8rem !important; }
.u-text-82 { font-size: .82rem !important; }
.u-text-sm { font-size: .85rem !important; }
.u-dim { opacity: .85; }
.u-caption { opacity: .85; margin-bottom: 2px !important; }
.u-w-auto { width: auto !important; }
.u-inline-auto { width: auto !important; display: inline-flex !important; }
.u-flex-1 { flex: 1 !important; }
.u-prewrap { white-space: pre-wrap !important; }
.u-center { text-align: center !important; }
.u-maxw-340 { max-width: 340px !important; }
.u-page-narrow { max-width: 560px !important; margin-left: auto !important; margin-right: auto !important; }
.u-page-wide { max-width: 960px !important; margin: 0 auto 20px !important; }
.u-scroll-240 { max-height: 240px; overflow-y: auto; }
.u-scroll-box { max-height: 240px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 8px; }
.u-callout-warning { background: var(--color-warning-light) !important; border-color: var(--color-warning) !important; }
.score-cell { width: 80px; }
