/* ==========================================================================
   STACIL Voting Platform -- Design System
   app.css
   ========================================================================== */

/* --- Font imports --------------------------------------------------------
   Display serif switched from Cormorant Garamond to Fraunces (redesign,
   see brief Section 4): loaded with the optical-size axis so it can run
   from body-adjacent sizes up to genuinely large ceremonial sizes
   (certificates, published results, big stat numbers) without looking
   stretched. Josefin Sans / DM Sans / Space Mono are unchanged. */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,500;1,9..144,600&family=Josefin+Sans:wght@400;600;700&family=DM+Sans:ital,wght@0,400;0,500;0,600;1,400&family=Space+Mono:wght@400;700&display=swap');

/* --- CSS Variables (Light Theme) ---------------------------------------- */
:root {
  --navy:         #1A2F6B;
  --navy-dark:    #111E4A;
  --navy-light:   #2B4494;

  /* Heading/accent text colour. Same navy brand tone in light mode. This
     is kept as a SEPARATE variable from --navy on purpose: --navy itself
     is also used as a background colour elsewhere (sidebar, chat bubble,
     theme toggle track) and can't be lightened globally in dark mode
     without washing those out. Every heading/label that uses navy as
     TEXT reads --heading-navy instead, so backgrounds keep their brand
     navy while text stays legible against dark surfaces. */
  --heading-navy: #1A2F6B;

  --gold:         #C9A829;
  --gold-light:   #E8D080;
  --gold-dark:    #A88A1E;
  /* --gold-dark (#A88A1E) reads fine as a BACKGROUND (button hover,
     decorative gradients) but only manages 3.32:1 contrast as TEXT on a
     white/off-white surface -- comfortably under WCAG AA's 4.5:1 for
     normal text, and part of why gold accents read as "dull" in light
     mode rather than as a crisp, confident accent. Darkening --gold-dark
     itself to fix that would in turn wreck the button-hover background
     (navy-dark text on it would drop from 4.83:1 to ~3.2:1) -- a
     background and a text color pull in opposite directions on the same
     token. --gold-ink is the dedicated text/icon variant: same hue
     family, darkened and slightly more saturated for 5:1+ contrast on
     white. Used anywhere gold appears as small text or an icon glyph
     directly on a light surface (.eyebrow, the checklist progress pill,
     list-row icons, the active rail item's icon, command-palette result
     icons, "Published" badge text). */
  --gold-ink:     #8A6B0F;

  --white:        #FFFFFF;
  --off-white:    #F4F2EE;
  --surface:      #FFFFFF;
  --surface-2:    #ECEEF6;
  --surface-3:    #E0E3EF;

  --text-primary: #141428;
  --text-muted:   #5A6A8A;
  --text-light:   #8A9ABB;
  --text-inverse: #FFFFFF;

  --success:      #0D7F5F;
  --success-bg:   #D1FAE5;
  --warning:      #B45A0A;
  --warning-bg:   #FEF3C7;
  --danger:       #C02020;
  --danger-bg:    #FEE2E2;
  /* Text/icon variants of the three status tokens, same idea as
     --gold-ink next to --gold-dark: --success/--warning/--danger stay
     exactly as they are for BACKGROUND use (solid buttons, badges, the
     toggle track) where a saturated, slightly darker tone reads right
     and pairs correctly with white text on top. In light mode the raw
     tokens already read fine as small text too (4.1-6:1 against white,
     off-white, and their own pale -bg tints), so these start out equal
     to the base tokens here -- dark mode is where they diverge, because
     the same darkened tones drop to 2.3-3.9:1 against every dark
     surface, well under the 4.5:1 small-text floor. See the dark-mode
     block below for the brightened values and the selectors that use
     these (toast/badge/chip text and icons) rather than the raw tokens. */
  --success-ink:  #0D7F5F;
  --warning-ink:  #B45A0A;
  --danger-ink:   #C02020;
  --border:       #D8DBE8;
  --border-2:     #C8CCE0;
  --border-strong: rgba(26,47,107,0.22);

  --ease: cubic-bezier(0.16,1,0.3,1);
  --hairline-top: inset 0 1px 0 rgba(255,255,255,0.55);

  --font-display: 'Fraunces', Georgia, serif;
  --font-ui:      'Josefin Sans', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'Space Mono', 'Courier New', monospace;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 1px rgba(17,30,74,0.04), 0 2px 4px rgba(17,30,74,0.05);
  --shadow:    0 1px 2px rgba(17,30,74,0.05), 0 3px 8px rgba(17,30,74,0.06), 0 12px 24px -8px rgba(17,30,74,0.14);
  --shadow-lg: 0 2px 4px rgba(17,30,74,0.06), 0 8px 16px rgba(17,30,74,0.08), 0 32px 64px -16px rgba(17,30,74,0.30);
  --shadow-xl: 0 4px 8px rgba(17,30,74,0.08), 0 16px 32px rgba(17,30,74,0.12), 0 48px 96px -24px rgba(17,30,74,0.4);
}

/* --- Dark Theme ---------------------------------------------------------- */
[data-theme="dark"] {
  /* #1A2F6B (navy) on #151828 (dark surface) is ~1.4:1 contrast -- close to
     invisible. This lighter tone gives ~7.5:1 against both dark surfaces
     while still reading unmistakably as "navy blue", not generic white. */
  --heading-navy: #8FA8E8;
  --off-white:    #0C0E18;
  --surface:      #151828;
  --surface-2:    #1E2238;
  --surface-3:    #252A45;
  --text-primary: #E4E8F4;
  --text-muted:   #8A9ABB;
  --text-light:   #5A6A8A;
  --text-inverse: #141428;
  --border:       #2A3060;
  --border-2:     #343878;
  --success-bg:   rgba(13,127,95,0.15);
  --warning-bg:   rgba(180,90,10,0.15);
  --danger-bg:    rgba(192,32,32,0.15);
  /* Brightened text/icon tones -- checked against every dark surface
     (--surface, --surface-2, --surface-3, --off-white) AND against each
     status's own --*-bg tint over those surfaces: all comfortably clear
     4.5:1 (5.0-9.9:1 across the combinations actually used), instead of
     the 2.3-3.9:1 the raw --success/--warning/--danger tokens drop to
     here. The raw tokens themselves are untouched by this block on
     purpose -- they're still correct for BACKGROUND use (see --success/
     --warning/--danger's own comment in :root), and brightening them
     directly would wash out .btn-danger/.btn-success's white-on-solid
     text and the badge backgrounds that rely on the darker, saturated
     tone. --danger-ink's value matches the coral already used by
     .danger-zone-head below -- that fix predates this token existing,
     so it's folded in here as the named variable instead of staying a
     one-off hardcoded color. */
  --success-ink:  #4FD9A8;
  --warning-ink:  #F2A94A;
  --danger-ink:   #F17878;
  --border-strong: rgba(232,208,128,0.3);
  --hairline-top: inset 0 1px 0 rgba(232,208,128,0.1);
  /* --gold-dark's remaining consumers here are backgrounds only (button
     hover, the two decorative gradients) -- every text/icon use of gold
     moved to --gold-ink (see :root), which needs its own dark-mode value
     for the same reason. Brightening --gold-dark here too, even though
     nothing uses it for text anymore, still matters for those
     backgrounds: a lighter gold hover state reads as "lighting up" against
     a dark button, which fits dark mode's mood better than the muted
     antique tone light mode wants. */
  --gold-dark:    #E8D080;
  --gold-ink:     #E8D080;
  --shadow-sm:    0 1px 1px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.25);
  --shadow:       0 2px 4px rgba(0,0,0,0.3), 0 3px 10px rgba(0,0,0,0.3), 0 14px 28px -8px rgba(0,0,0,0.4);
  --shadow-lg:    0 4px 8px rgba(0,0,0,0.35), 0 16px 32px rgba(0,0,0,0.35), 0 40px 80px -20px rgba(0,0,0,0.6);
}

/* --- Base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--off-white);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
  font-variant-numeric: tabular-nums;
}
/* Fine grain: the difference between a flat vector fill and a surface
   that reads as physical paper/card stock. A near-invisible noise layer
   over the whole page, multiplied over light backgrounds and overlaid
   (brighter blend) in dark mode where multiply would just look muddy. */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 2000; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.025;
  mix-blend-mode: multiply;
}
[data-theme="dark"] body::before { opacity: 0.05; mix-blend-mode: overlay; }
::selection { background: var(--gold-light); color: var(--navy-dark); }

h1,h2,h3,h4,.font-display { font-family: var(--font-display); line-height: 1.15; }
.font-ui    { font-family: var(--font-ui); }
.font-mono  { font-family: var(--font-mono); }
.font-body  { font-family: var(--font-body); }

a { text-decoration: none; color: inherit; }
img { display: block; }
input,select,textarea,button { font: inherit; }

/* Tailwind's preflight (assets/css/tailwind.css) sets `color: inherit` on
   form elements, so in dark mode they correctly pick up the page's
   near-white text color -- but it doesn't set a `background`, so any
   input/textarea/select that isn't using the .input class below (there
   were 14 view files doing this with ad hoc `style="border-color:..."`
   only) keeps the browser's default white background. Near-white text on
   a white box is exactly the "text is nearly invisible in dark mode" bug.
   This is a base-level default, lowest CSS specificity, so it never
   overrides .input, an inline style, or any other more specific rule --
   it only fills in the gap for fields that never set a background/color
   of their own. */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"]):not([type="range"]):not([type="color"]),
textarea,
select {
  background: var(--surface);
  color: var(--text-primary);
}
input::placeholder, textarea::placeholder { color: var(--text-light); }
/* Chrome/Safari autofill paints its own background over the rule above;
   without this, an autofilled field reverts to a pale box in dark mode
   regardless of what's set on the element itself. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  transition: background-color 9999s ease-in-out 0s;
}

/* Keyboard focus */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 3px;
}

/* Alpine.js */
[x-cloak] { display: none !important; }

/* =========================================================================
   BUTTONS
   ========================================================================= */
.btn {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.96) !important; }

.btn-primary {
  background: var(--gold);
  color: var(--navy-dark);
  border-color: var(--gold);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(201,168,41,0.4);
  background: var(--gold-dark);
  border-color: var(--gold-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border-color: var(--border-2);
}
[data-theme="dark"] .btn-secondary { color: var(--text-primary); }
.btn-secondary:hover {
  transform: translateY(-2px);
  background: var(--surface-2);
  border-color: var(--navy-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding: 0.5rem 0.75rem;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }

/* =========================================================================
   FORM INPUTS
   ========================================================================= */
.input {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,47,107,0.12);
  outline: none;
}
[data-theme="dark"] .input:focus { box-shadow: 0 0 0 3px rgba(43,68,148,0.25); }
.input::placeholder { color: var(--text-light); }

textarea.input { resize: vertical; min-height: 80px; }
select.input { cursor: pointer; }

.input-label {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.375rem;
}

/* =========================================================================
   CARDS
   ========================================================================= */
.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.card-body { padding: 1.5rem; }
.card-elevated { box-shadow: var(--shadow-sm), var(--hairline-top); }
.card-elevated:hover { box-shadow: var(--shadow), var(--hairline-top); }

/* =========================================================================
   EYEBROW + SECTION DIVIDER
   ========================================================================= */
.eyebrow {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-ink);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
}
.section-divider .divider-line { flex: 1; height: 1px; background: var(--gold); opacity: 0.4; }
.section-divider .divider-cross { width: 16px; height: 16px; flex-shrink: 0; }

/* =========================================================================
   STATUS BADGES
   ========================================================================= */
/* Raised-pill recipe (brief 7.5): a rounded pill with a subtle
   top-to-bottom gradient *within the same hue* plus a faint inset
   highlight along the top edge, so every small badge-like element in the
   product (status pills, the cron badge, checklist counters, nav count
   badges) shares one consistent "badge" language instead of several flat
   fills competing. Applied here as a background-image layered under the
   badge's own flat background-color via multiple backgrounds, so each
   status keeps its own hue while gaining the same raised treatment. */
.badge {
  --tag-glow: transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-ui);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.8rem 0.4rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 4px 10px -3px var(--tag-glow);
}
/* The glossy highlight: a soft light sweep across the top third of the
   pill, the actual thing that separates a "flat colored rectangle" from
   something that reads as a considered, tactile UI element rather than
   a default browser tag. Layered on with ::before rather than a second
   background on the element itself so it composites over any of the
   solid fills below without each one needing its own gradient. */
.badge::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 55%);
  pointer-events: none;
}
.badge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 0 0 2.5px rgba(255,255,255,0.55);
}
.badge svg { flex-shrink: 0; position: relative; }
.badge > span:not(.badge-dot) { position: relative; }
/* Solid, confident fills rather than a pale translucent tint over the
   card background -- a status pill is meant to be read at a glance
   across a whole list of elections, and a 15-25% opacity wash of color
   doesn't carry enough visual weight to do that, in either theme. Every
   one of these works unmodified in both light and dark mode: they're
   fully-saturated colors sitting as their own small "island" rather
   than text blending into a page background, so they don't need a
   separate dark-mode variant the way page text does -- which also
   closes off an entire class of "forgot to theme this one" bugs
   (.badge-ended's old --navy-on-dark-surface bug could not recur under
   this recipe, since there's no page-background-relative text color
   left to forget). */
.badge-draft     { color: #fff; background: #5C6788; --tag-glow: rgba(92,103,136,0.35); }
.badge-scheduled { color: #fff; background: var(--warning); --tag-glow: rgba(180,90,10,0.45); }
.badge-active    { color: #fff; background: var(--success); --tag-glow: rgba(13,127,95,0.5); }
.badge-paused    { color: #fff; background: var(--warning); --tag-glow: rgba(180,90,10,0.45); }
.badge-ended     { color: #fff; background: var(--navy); --tag-glow: rgba(26,47,107,0.4); }
.badge-published { color: var(--navy-dark); background: var(--gold); --tag-glow: rgba(201,168,41,0.55); border-color: rgba(17,30,74,0.15); }
.badge-archived  { color: var(--gold-light); background: var(--navy-dark); border-color: rgba(232,208,128,0.4); }

.badge-active .badge-dot.is-live { animation: pulse-dot 1.6s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.6), 0 0 0 0 rgba(13,127,95,0.45); } 70% { box-shadow: 0 0 0 2.5px rgba(255,255,255,0.55), 0 0 0 7px rgba(13,127,95,0); } }

/* Cron health badge (admin dashboard) -- same pill recipe as the status
   badges above, reusing the same pulse-dot animation for the "healthy"
   state. See views/_components/cron_health_badge.php. */
.badge-cron-ok       { background: var(--success); color: #fff; --tag-glow: rgba(13,127,95,0.5); }
.badge-cron-fallback { background: var(--warning); color: #fff; --tag-glow: rgba(180,90,10,0.45); }
.badge-cron-down     { background: var(--danger);  color: #fff; --tag-glow: rgba(192,32,32,0.45); }

.badge-cron-ok .badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

/* =========================================================================
   VOTER LAYOUT -- Split-screen hero design
   Every voter-facing page has a church-photo panel on the left and the
   form on the right. On mobile they stack vertically.
   ========================================================================= */
.voter-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

@media (min-width: 900px) {
  .voter-shell {
    grid-template-columns: 420px 1fr;
    grid-template-rows: 1fr;
  }
}

/* Left panel: church photo + branding */
.voter-brand-panel {
  position: relative;
  overflow: hidden;
  min-height: 240px;
  background: var(--navy-dark);
}

@media (min-width: 900px) {
  .voter-brand-panel {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: unset;
  }
}

.voter-brand-panel .brand-photo {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 0.45;
  transition: opacity 0.3s ease;
}

[data-theme="dark"] .voter-brand-panel .brand-photo { opacity: 0.25; }

.voter-brand-panel .brand-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(17,30,74,0.6) 0%,
    rgba(17,30,74,0.85) 60%,
    rgba(17,30,74,0.97) 100%
  );
}

.voter-brand-content {
  position: relative;
  z-index: 2;
  height: 100%;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2rem 2.5rem;
}

@media (min-width: 900px) {
  .voter-brand-content { min-height: 100vh; justify-content: space-between; padding: 3rem 2.5rem; }
}

/* Right panel: form content */
.voter-content-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.5rem;
  transition: background-color 0.25s ease;
}

@media (min-width: 900px) {
  .voter-content-panel { padding: 4rem 3.5rem; }
}

/* =========================================================================
   CONSTELLATION -- subtle mouse-reactive light animation
   Placed only on the two surfaces that are always dark navy regardless of
   theme and carry no real photography or interactive content: the brand
   panel above, and the site footer (see PUBLIC FOOTER below). Sits above
   the photo/gradient, below the actual panel content (z-index 2).
   ========================================================================= */
.constellation-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  display: block;
}

/* The floating gold cross-rule in the brand panel */
.brand-cross-rule {
  width: 48px;
  height: 2px;
  background: var(--gold);
  margin: 1rem 0;
  position: relative;
}
.brand-cross-rule::after {
  content: '';
  position: absolute;
  left: 22px; top: -3px;
  width: 2px; height: 8px;
  background: var(--gold);
}

/* =========================================================================
   BALLOT CANDIDATE CARDS
   ========================================================================= */
.candidate-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, transform 200ms ease, box-shadow 200ms ease, background 160ms ease;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.candidate-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-2);
}
.candidate-card .candidate-photo {
  width: 96px; height: 96px;
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  overflow: hidden;
  border: 3px solid var(--border);
}
.candidate-card.is-selected {
  border-color: var(--navy);
  border-width: 2px;
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(26,47,107,0.12);
}
[data-theme="dark"] .candidate-card.is-selected { background: var(--surface-3); }
.candidate-card .selected-badge {
  position: absolute;
  top: -10px; right: -10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0);
  transition: transform 220ms cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 2px 8px rgba(201,168,41,0.4);
}
.candidate-card.is-selected .selected-badge { transform: scale(1); }
.candidate-card.is-abstain { border-style: dashed; background: transparent; }
.candidate-name { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.candidate-bio  { font-family: var(--font-body); font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; line-height: 1.4; }

/* =========================================================================
   ADMIN / STEWARD SIDEBAR LAYOUT
   ========================================================================= */
.app-layout { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--navy-dark);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.app-sidebar .sidebar-logo-area,
.app-sidebar .nav-section,
.app-sidebar > div:last-child {
  position: relative;
  z-index: 1;
}
.app-sidebar .sidebar-logo-area {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.app-sidebar .nav-section {
  padding: 0.75rem 0;
}
.app-sidebar .nav-label-group {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.3);
  padding: 0.75rem 1.25rem 0.35rem;
}
.app-sidebar .nav-item {
  font-family: var(--font-ui);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1.25rem;
  color: rgba(255,255,255,0.65);
  border-left: 3px solid transparent;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
  text-decoration: none;
}
.app-sidebar .nav-item svg { flex-shrink: 0; }
.app-sidebar .nav-item:hover { color: white; background: rgba(255,255,255,0.06); }
.app-sidebar .nav-item.is-active { border-left-color: var(--gold); color: white; background: rgba(255,255,255,0.08); }

@media (max-width: 1024px) {
  .app-sidebar { width: 68px; }
  .app-sidebar .nav-text,
  .app-sidebar .sidebar-wordmark,
  .app-sidebar .nav-label-group { display: none; }
  .app-sidebar .nav-item { justify-content: center; padding: 0.8rem; }
}

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  transition: background 0.25s ease, border-color 0.25s ease;
}
.app-topbar h1 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .app-topbar { padding: 0.625rem 1rem; }
  .app-topbar h1 { font-size: 1.05rem !important; }
}

.app-content {
  flex: 1;
  padding: 1.25rem;
  background: var(--off-white);
  transition: background 0.25s ease;
}
@media (min-width: 640px)  { .app-content { padding: 1.75rem; } }
@media (min-width: 1024px) { .app-content { padding: 2.5rem 2.5rem; } }

/* =========================================================================
   DASHBOARD HERO BANNER (admin + steward)
   Shorter cousin of the polling-booth photo backdrop -- same slow crossfade
   mechanism (boothPhotoFade keyframe, defined further down), sized for a
   header strip rather than a full stage.
   ========================================================================= */
.staff-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  min-height: 200px;
  display: flex;
  align-items: flex-end;
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
}
@media (max-width: 640px) {
  .staff-hero { min-height: 150px; padding: 1.25rem 1.25rem; border-radius: var(--radius-lg); margin-bottom: 1.5rem; }
}
.staff-hero-backdrop { position: absolute; inset: 0; z-index: 0; }
.staff-hero-fade {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  animation: boothPhotoFade 18s ease-in-out infinite;
}
.staff-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(17,30,74,0.92) 0%, rgba(17,30,74,0.75) 45%, rgba(17,30,74,0.35) 100%);
}
[data-theme="dark"] .staff-hero-overlay {
  background: linear-gradient(100deg, rgba(9,11,20,0.95) 0%, rgba(9,11,20,0.82) 45%, rgba(9,11,20,0.45) 100%);
}
.staff-hero-content { position: relative; z-index: 1; }

/* =========================================================================
   DASHBOARD GUIDE LINK
   Opens the Administrator Guide / Steward Guide PDF (see
   views/admin/dashboard.php and views/steward/dashboard.php). Lives
   inline in the hero's text row, right beside "N elections active" --
   NOT floated over the open photo area. That's deliberate: the hero's
   own gradient overlay already darkens the bottom-left corner enough for
   the greeting text above to read clearly, so this link can simply sit
   in that same already-legible strip and stay genuinely translucent,
   rather than needing an opaque badge of its own on top of the carousel.
   ========================================================================= */
.staff-hero-subrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 0.5rem;
  column-gap: 1rem;
  margin-top: 0.35rem;
}
.staff-hero-subrow > p { margin-top: 0 !important; }

.hero-guide-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.32);
  color: #FFFFFF;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.hero-guide-link:hover,
.hero-guide-link:focus-visible {
  background: rgba(255,255,255,0.2);
  border-color: var(--gold-light);
  transform: translateY(-1px);
}
.hero-guide-link svg { flex-shrink: 0; color: var(--gold-light); }


/* =========================================================================
   ELECTION SETUP WIZARD
   Mobile-first: base rules are the single-column phone layout (horizontal
   scrolling step tabs, full-width panel below); the >=900px query turns
   the tabs into a proper left-hand step list next to the panel.
   ========================================================================= */
.setup-wizard {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
@media (min-width: 900px) {
  .setup-wizard { flex-direction: row; align-items: flex-start; gap: 2rem; }
}

.setup-steps {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}
@media (min-width: 900px) {
  .setup-steps {
    flex-direction: column;
    width: 200px;
    flex-shrink: 0;
    overflow-x: visible;
    position: sticky;
    top: 84px;
    gap: 0.2rem;
  }
}
.setup-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
@media (min-width: 900px) {
  .setup-step { border-radius: 8px; white-space: normal; width: 100%; }
}
.setup-step:hover { border-color: var(--navy); color: var(--heading-navy); }
.setup-step.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.setup-step svg { flex-shrink: 0; width: 15px; height: 15px; }
.setup-step-dot {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(128,128,128,0.25); color: transparent;
  font-size: 9px; transition: background 200ms ease, color 200ms ease;
}
.setup-step-dot.is-done { background: var(--success); color: #fff; }
.setup-step.is-active .setup-step-dot:not(.is-done) { background: rgba(255,255,255,0.35); }

.setup-progress {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-ui); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
  margin-bottom: 0.75rem;
}
@media (min-width: 900px) { .setup-progress { display: none; } /* dots in the step list already show this */ }
.setup-progress-track { flex: 1; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.setup-progress-fill { height: 100%; background: var(--gold); transition: width 400ms ease; }

.setup-panel-wrap { flex: 1; min-width: 0; }
.setup-panel { animation: setupFade 220ms ease; }
@keyframes setupFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.setup-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
}
@media (min-width: 640px) { .setup-card { padding: 1.75rem; } }

.setup-step-nav {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 0.75rem; margin-top: 1.25rem;
}
.setup-step-nav #setupBackBtn { justify-self: start; }
.setup-step-nav #setupNextBtn { justify-self: end; }
.setup-step-nav-label {
  font-family: var(--font-ui); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); text-align: center; flex-shrink: 0;
}
@media (max-width: 380px) { .setup-step-nav-label { display: none; } }

.setup-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }
.setup-list-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.9rem; border-radius: 10px;
  background: var(--off-white); border: 1px solid var(--border);
  animation: setupItemIn 240ms ease;
}
[data-theme="dark"] .setup-list-item { background: var(--surface-2, rgba(255,255,255,0.03)); }
@keyframes setupItemIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
.setup-list-item .grow { flex: 1; min-width: 0; }
.setup-list-item .name { font-family: var(--font-body); font-size: 0.88rem; color: var(--text-primary); font-weight: 500; }
.setup-list-item .meta { font-family: var(--font-ui); font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.setup-list-empty {
  text-align: center; padding: 2rem 1rem; color: var(--text-light);
}
.setup-list-empty .icon-badge {
  width: 48px; height: 48px; border-radius: 50%; background: var(--gold-bg, rgba(201,168,41,0.12));
  color: var(--gold-ink); display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.75rem; font-size: 20px;
}
.setup-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 0.65rem; font-weight: 600; overflow: hidden;
}
.setup-avatar img { width: 100%; height: 100%; object-fit: cover; }

.setup-form-row { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.5rem; }
@media (min-width: 560px) { .setup-form-row { flex-direction: row; align-items: flex-end; } }
.setup-form-row .field { flex: 1; min-width: 0; }

.setup-toast {
  font-family: var(--font-body); font-size: 0.82rem; padding: 0.65rem 0.9rem;
  border-radius: 8px; margin-bottom: 0.85rem; display: none;
}
.setup-toast.is-success { display: block; background: var(--success-bg, rgba(13,127,95,0.12)); color: var(--success-ink); }
.setup-toast.is-error { display: block; background: var(--danger-bg); color: var(--danger-ink); }

.setup-checklist-row {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem;
  border-radius: 10px; background: var(--off-white); border: 1px solid var(--border); margin-bottom: 0.6rem;
}
[data-theme="dark"] .setup-checklist-row { background: var(--surface-2, rgba(255,255,255,0.03)); }

/* =========================================================================
   GUIDED SETUP TOUR
   Self-contained "spotlight" walkthrough of the Election Setup wizard
   (views/admin/elections/setup.php + assets/js/guided-tour.js). Every
   colour reads from the shared theme variables above, so it needs no
   dark-mode overrides of its own -- it just inherits whichever theme is
   active on <html data-theme="...">.

   Structure: .tour-trigger-btn (the always-visible entry point, lives in
   the page header row) opens an overlay of three fixed layers stacked in
   this order: .tour-scrim (full-viewport dim + click guard, so the tour
   is look-but-don't-touch), .tour-veil (the animated cutout box that
   sits exactly over whichever element is being explained, built with
   the "giant box-shadow" spotlight technique so the dimming and the
   cutout are a single element), and .tour-card (the copy + controls,
   positioned by JS relative to the veil with a small pointer arrow).
   ========================================================================= */
.setup-header-row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem;
}
.tour-trigger-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1.5px solid var(--border-2);
  background: var(--surface);
  color: var(--heading-navy);
  font-family: var(--font-ui); font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  cursor: pointer; flex-shrink: 0;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.tour-trigger-btn svg { flex-shrink: 0; color: var(--gold-ink); transition: transform 200ms ease; }
.tour-trigger-btn:hover { border-color: var(--gold); background: var(--surface-2); transform: translateY(-1px); }
.tour-trigger-btn:hover svg { transform: rotate(-12deg); }
.tour-trigger-btn:active { transform: scale(0.96); }
/* One-time invitation ring, shown until an admin has opened the tour at
   least once (tracked in localStorage by guided-tour.js), so the button
   asks for attention on a brand-new election without nagging forever. */
.tour-trigger-btn.is-new { border-color: var(--gold); box-shadow: 0 0 0 0 rgba(201,168,41,0.5); animation: tourInviteRing 2.2s ease-out infinite; }
@keyframes tourInviteRing {
  0%   { box-shadow: 0 0 0 0 rgba(201,168,41,0.45); }
  70%  { box-shadow: 0 0 0 9px rgba(201,168,41,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,168,41,0); }
}

.tour-scrim {
  position: fixed; inset: 0; z-index: 5000;
  background: transparent;
  opacity: 0; pointer-events: none;
  transition: background 260ms ease, opacity 260ms ease;
}
.tour-scrim.is-open { pointer-events: auto; opacity: 1; }
.tour-scrim.is-dim { background: rgba(10,12,24,0.6); }
[data-theme="dark"] .tour-scrim.is-dim { background: rgba(4,5,12,0.72); }

.tour-veil {
  position: fixed; z-index: 5001;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(10,12,24,0.6);
  opacity: 0; pointer-events: none;
  transition: opacity 220ms ease, top 340ms var(--ease), left 340ms var(--ease), width 340ms var(--ease), height 340ms var(--ease);
}
[data-theme="dark"] .tour-veil { box-shadow: 0 0 0 9999px rgba(4,5,12,0.72); }
.tour-veil.is-active { opacity: 1; }
.tour-veil::after {
  content: ''; position: absolute; inset: -4px; border-radius: 16px;
  border: 2px solid var(--gold);
  animation: tourRingPulse 1.8s ease-in-out infinite;
}
@keyframes tourRingPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,168,41,0.45); opacity: 0.9; }
  50%      { box-shadow: 0 0 0 6px rgba(201,168,41,0); opacity: 0.55; }
}

.tour-card {
  position: fixed; z-index: 5002;
  width: 336px; max-width: calc(100vw - 1.5rem);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 1.15rem 1.25rem 1.25rem;
  opacity: 0; visibility: hidden;
  transform: translateY(8px) scale(0.97);
  transition: opacity 240ms var(--ease), transform 240ms var(--ease), top 340ms var(--ease), left 340ms var(--ease);
}
.tour-card.is-visible { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.tour-card:focus { outline: none; }

.tour-card-arrow {
  position: absolute; width: 14px; height: 14px; z-index: -1;
  background: var(--surface); border: 1px solid var(--border-2);
  transform: rotate(45deg);
}
.tour-card-arrow--top    { top: -7px; }
.tour-card-arrow--bottom { bottom: -7px; }
.tour-card-arrow--left   { left: -7px; }
.tour-card-arrow--right  { right: -7px; }

.tour-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.6rem; }
.tour-card-eyebrow {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-ui); font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold-ink);
}
.tour-card-eyebrow .dot { opacity: 0.5; color: var(--text-light); }
.tour-card-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.tour-card-close:hover { background: var(--surface-3); color: var(--text-primary); }

.tour-card-title {
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
  color: var(--heading-navy); margin-bottom: 0.4rem; line-height: 1.25;
}
.tour-card-body {
  font-family: var(--font-body); font-size: 0.84rem; line-height: 1.55;
  color: var(--text-muted);
}

.tour-progress-track { height: 4px; border-radius: 3px; background: var(--border); overflow: hidden; margin: 0.95rem 0 0.85rem; }
.tour-progress-fill { height: 100%; background: var(--gold); border-radius: 3px; transition: width 320ms var(--ease); }

.tour-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.tour-skip-btn {
  background: none; border: none; padding: 0.4rem 0.2rem; cursor: pointer;
  font-family: var(--font-ui); font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light);
  transition: color 150ms ease;
}
.tour-skip-btn:hover { color: var(--text-muted); text-decoration: underline; }
.tour-nav-group { display: flex; align-items: center; gap: 0.5rem; }
.tour-nav-group .btn { padding: 0.5rem 1rem; font-size: 0.68rem; }
.tour-nav-group .btn svg { width: 12px; height: 12px; }

/* Mobile: anchoring a card next to a target that might be off-screen (or
   have the on-screen keyboard fighting for space) gets unreliable below
   ~640px, so the card becomes a fixed bottom sheet instead -- the veil
   still finds and rings the real element, the card just always answers
   "where do I read about it" from the same predictable place. */
@media (max-width: 640px) {
  .tour-card.is-sheet {
    left: 0 !important; right: 0; bottom: 0; top: auto !important;
    width: 100%; max-width: 100%;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    transform: translateY(100%);
    box-shadow: 0 -8px 32px rgba(17,30,74,0.24);
  }
  .tour-card.is-sheet.is-visible { transform: translateY(0); }
  .tour-card.is-sheet .tour-card-arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tour-trigger-btn.is-new { animation: none; box-shadow: 0 0 0 2px rgba(201,168,41,0.5); }
  .tour-veil::after { animation: none; opacity: 0.85; }
  .tour-veil, .tour-card { transition: opacity 200ms ease !important; }
  .tour-card { transform: none !important; }
  .tour-card.is-sheet { transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .staff-hero-fade { animation: none !important; opacity: 0; }
  .staff-hero-fade:first-child { opacity: 1; }
}

/* =========================================================================
   DARK MODE TOGGLE BUTTON
   ========================================================================= */
.theme-toggle {
  width: 38px; height: 22px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: background 200ms ease;
  flex-shrink: 0;
}
.theme-toggle .toggle-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 200ms ease, background 200ms ease;
}
[data-theme="dark"] .theme-toggle { background: var(--navy); border-color: var(--navy-light); }
[data-theme="dark"] .theme-toggle .toggle-knob { transform: translateX(16px); background: var(--gold); }

.theme-toggle-wrap { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.theme-toggle-icon {
  flex-shrink: 0;
  color: var(--gold-dark);
  opacity: 1;
  transform: rotate(0deg) scale(1);
  transition: opacity 320ms ease, transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1), color 320ms ease;
}
.theme-toggle-icon-moon { color: var(--text-light); opacity: 0.3; transform: rotate(-35deg) scale(0.7); }
[data-theme="dark"] .theme-toggle-icon-sun { color: var(--text-light); opacity: 0.3; transform: rotate(35deg) scale(0.7); }
[data-theme="dark"] .theme-toggle-icon-moon { color: var(--gold-light); opacity: 1; transform: rotate(0deg) scale(1); }
@media (prefers-reduced-motion: reduce) {
  .theme-toggle-icon { transition: opacity 120ms ease, color 120ms ease; transform: none !important; }
}

/* =========================================================================
   RESULTS BAR (public + admin)
   ========================================================================= */
.result-bar-wrap {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.result-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 1.2s cubic-bezier(0.16,1,0.3,1);
}

/* =========================================================================
   ASYMMETRIC STAT CLUSTER
   Replaces a row of identical tiles with one larger "hero" stat (the
   number that matters most on this page) beside a 1x1 + 2x1 stack of
   smaller ones -- visual hierarchy instead of four boxes competing
   equally for attention.
   ========================================================================= */
.stat-cluster { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1rem; margin: 1.6rem 0; }
.stat-hero { padding: 1.7rem 1.8rem; display: flex; flex-direction: column; justify-content: center; }
.stat-hero .stat-label,
.stat-tile-sm .stat-label {
  font-family: var(--font-ui); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.4rem;
}
.stat-hero .stat-num { font-family: var(--font-display); font-size: 3.2rem; font-weight: 600; color: var(--heading-navy); line-height: 1; }
.stat-hero .stat-sub { font-size: 0.8rem; color: var(--text-light); margin-top: 0.4rem; }
.stat-cluster-side { display: flex; flex-direction: column; gap: 1rem; }
.stat-tile-sm-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; flex: 1; }
.stat-tile-sm { padding: 1rem 1.15rem; display: flex; flex-direction: column; justify-content: center; }
.stat-num-sm { font-family: var(--font-display); font-size: 1.85rem; font-weight: 600; color: var(--heading-navy); line-height: 1; margin-top: 0.15rem; }
@media (max-width: 760px) {
  .stat-cluster { grid-template-columns: 1fr; }
  .stat-hero .stat-num { font-size: 2.6rem; }
}

/* =========================================================================
   TOASTS
   ========================================================================= */
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  box-shadow: var(--shadow-xl);
  font-family: var(--font-body);
  font-size: 0.875rem;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  color: var(--text-primary);
  max-width: 360px;
}
.toast.toast-success { border-left-color: var(--success-ink); }
.toast.toast-error   { border-left-color: var(--danger-ink); }
.toast.toast-warning { border-left-color: var(--warning-ink); }
.toast .toast-progress {
  position: absolute; bottom: 0; left: 0;
  height: 2px; background: currentColor; opacity: 0.3; width: 100%;
}

/* =========================================================================
   HELP CHAT BUBBLE
   ========================================================================= */
.chat-bubble {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(26,47,107,0.4);
  z-index: 1000;
  border: 2px solid rgba(255,255,255,0.15);
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.chat-bubble:hover { transform: scale(1.08); box-shadow: 0 12px 36px rgba(26,47,107,0.5); }

.chat-panel {
  position: fixed;
  bottom: 5.25rem; right: 1.5rem;
  width: 360px;
  max-width: calc(100vw - 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  /* Without this, a flex child that doesn't shrink correctly (see
     .chat-panel-body below) can visually spill past this fixed-height
     box instead of being clipped -- belt-and-braces alongside the
     min-height fix so nothing ever renders outside the rounded card. */
  overflow: hidden;
  /* BUGFIX (auto-scroll "not working" on mobile): this was a flat
     height: 480px, anchored `bottom: 5.25rem` from the LAYOUT viewport.
     Mobile Safari/Chrome don't shrink the layout viewport when the
     on-screen keyboard opens (they resize the *visual* viewport
     instead), so a fixed-position element anchored to the bottom of the
     layout viewport stays exactly where it was -- now hidden behind the
     keyboard. The JS was correctly scrolling the message list to its own
     bottom the whole time; that bottom was just no longer on screen. A
     responsive cap here, plus the VisualViewport handling in
     chat_widget.php's togglePanel()/keyboard listener, keeps the whole
     panel (not just its content) inside whatever space is actually
     visible. dvh (dynamic viewport height) is preferred where supported
     since it already accounts for mobile browser chrome; vh is the
     fallback for browsers without it.
  */
  height: 480px;
  height: min(480px, 78vh);
  height: min(480px, 78dvh);
}

/* The scrollable message list inside .chat-panel. A flex item's default
   minimum size is auto (i.e. sized to its content), not 0 -- so without
   an explicit min-height here, some mobile/WebKit browsers let this
   grow to fit all messages instead of becoming internally scrollable,
   which silently breaks the JS "scroll to bottom on new message" logic
   (scrollTop = scrollHeight is a no-op if there's nothing to scroll).
   -webkit-overflow-scrolling gives proper momentum scrolling on iOS. */
.chat-panel-body {
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* "X is typing..." bubble -- used in the visitor widget and in the
   admin / steward live chat screens (both sides of the conversation
   share this one rule, via .typing-indicator).
   BUGFIX 6: the bubble is shown/hidden with Alpine's x-show, which
   toggles plain `display: none` <-> visible. Every browser restarts a
   CSS animation from scratch (including its animation-delay) when an
   element goes from display:none back to displayed -- so every single
   time the bubble appeared, dot 2 and dot 3 spent their first 0.15s/
   0.3s rendered at the browser's *default* span appearance (opacity 1,
   no offset) rather than the animation's own 0% keyframe (opacity 0.5,
   translateY(0)), because no fill-mode was set to apply that keyframe
   during the delay. The visible result: dot 1 starts mid-bounce while
   dots 2/3 sit fully bright and still for a beat, then all three
   suddenly snap into the same rhythm -- looking out of sync at the
   exact moment the indicator appears, on both the visitor widget and
   the admin/steward screens, every time. animation-fill-mode: backwards
   makes a delayed dot adopt its 0% keyframe state immediately, so all
   three dots are already in the correct bounce state before their
   delay even ends. */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.6rem 0.85rem;
  border-radius: 1rem;
  background: var(--surface-2);
}
.typing-indicator span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s infinite ease-in-out backwards;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* =========================================================================
   GOLD PROGRESS BAR (top of viewport)
   ========================================================================= */
#gold-progress-bar {
  position: fixed; top: 0; left: 0;
  height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-light));
  z-index: 9999;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(201,168,41,0.5);
}

/* =========================================================================
   SCROLL REVEAL
   ========================================================================= */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
/* transform: none (not translateY(0)) once revealed -- ANY non-"none"
   transform value, including a zero-distance translateY(0), makes an
   element establish a new containing block for its position:fixed/
   absolute descendants per spec. .danger-zone carries this class and
   also has overflow:hidden, and it contains the delete-confirmation
   modal (position:fixed; inset:0, meant to fill the whole viewport).
   With translateY(0) left in place after the reveal finished, that
   "fixed" modal silently stopped being fixed to the viewport and
   instead got boxed into -- and clipped by -- .danger-zone's own small
   card-sized area, which is exactly the clipped/cut-off dialog seen in
   testing. transform: none carries zero visual difference from
   translateY(0) (both mean "no offset") but, unlike it, does NOT create
   a containing block, so position:fixed descendants correctly escape to
   the real viewport again. */
.reveal.is-visible { opacity: 1; transform: none; }

/* =========================================================================
   TABLES
   ========================================================================= */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 120ms ease; }
.data-table tbody tr:hover { background: var(--surface-2); }

/* =========================================================================
   REDESIGN COMPONENT SYSTEM (Section 7 of the redesign brief)
   Tabs, workspace nav, breadcrumb, resource rows, empty states, skeletons,
   modal, command palette, mobile nav, and the rotating gold focal ring.
   Appended as its own block rather than interleaved with the original
   system above so the diff against the pre-redesign file stays legible.
   ========================================================================= */

/* --- 7.2 Tabs ------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
}
.tab-indicator {
  position: absolute;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 8px -1px rgba(201,168,41,0.6);
  transition: left 280ms var(--ease), width 280ms var(--ease);
  pointer-events: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.85rem 0.1rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 150ms ease, border-color 200ms cubic-bezier(0.16,1,0.3,1);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.tab:hover { color: var(--heading-navy); }
.tab.is-active { color: var(--heading-navy); border-color: var(--gold); }
.tabs.has-indicator .tab.is-active { border-color: transparent; }
.tab + .tab { margin-left: 0; }
@media (min-width: 480px) { .tabs { gap: 2rem; } }

/* --- Election Workspace: sticky vertical rail -----------------------------
   A real second navigation rail beside the content, not another row of
   pills above it -- this is what actually reads as "a workspace" rather
   than "a page with extra tabs." Collapses to the old horizontal
   icon-strip only below 760px, where a fixed-width sidebar-within-a-
   sidebar no longer makes sense. */
.workspace-shell { display: flex; gap: 2rem; align-items: flex-start; position: relative; }
/* A visible spine down the gap itself -- relying on empty space alone to
   read as "these are different regions" didn't hold up once the rail and
   the cards beside it have near-identical surfaces (same light gradient,
   same border weight). A drawn line removes any ambiguity regardless of
   viewport width or zoom. */
.workspace-shell::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: calc(224px + 1rem);
  width: 1px; background: var(--border);
}
@media (max-width: 900px) { .workspace-shell::before { display: none; } }
.workspace-rail {
  width: 224px; flex-shrink: 0;
  position: sticky; top: calc(72px + 1.5rem);
  /* Deliberately recessed rather than matching the content cards' own
     surface -- a subtle navy-tinted wash instead of the same near-white
     gradient every card beside it uses, so this reads at a glance as
     "the navigation panel," not "one more card in the row." */
  background: linear-gradient(180deg, rgba(26,47,107,0.05) 0%, rgba(26,47,107,0.02) 100%);
  border: 1px solid rgba(26,47,107,0.08);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  box-shadow: var(--hairline-top);
}
[data-theme="dark"] .workspace-rail {
  background: linear-gradient(180deg, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.1) 100%);
  border-color: rgba(0,0,0,0.35);
}
.rail-back {
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-ui); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em;
  color: var(--text-muted); padding: 0.15rem 0.5rem 0.6rem;
}
.rail-back:hover { color: var(--heading-navy); }
.rail-back svg { width: 13px; height: 13px; flex-shrink: 0; }
.rail-election-name {
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
  color: var(--heading-navy); padding: 0.3rem 0.5rem 0.15rem; line-height: 1.25;
  overflow-wrap: break-word;
}
.rail-status { padding: 0 0.5rem 0.85rem; }
.rail-divider { height: 1px; background: var(--border); margin: 0.6rem 0.2rem 0.7rem; }
.rail-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.58rem 0.65rem; border-radius: 9px; font-family: var(--font-body); font-size: 0.85rem;
  color: var(--text-primary); margin-bottom: 1px; position: relative;
  transition: background 150ms ease;
}
.rail-item svg { width: 16px; height: 16px; stroke: var(--text-muted); flex-shrink: 0; }
/* Flex items default to min-width:auto, so long unbreakable label text
   (e.g. "3 offices, 5 candidates") refused to shrink and pushed the count
   badge past the rail's right edge instead of yielding to it. Letting the
   label shrink and ellipsize -- while the badge stays flex-shrink:0 --
   means the count is always fully visible and the label gives way first. */
.rail-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item:hover { background: var(--surface-3); }
.rail-item.is-active {
  background: linear-gradient(90deg, rgba(201,168,41,0.16) 0%, rgba(201,168,41,0.06) 100%);
  color: var(--navy-dark); font-weight: 600;
}
.rail-item.is-active svg { stroke: var(--gold-ink); }
.rail-item.is-active::before {
  content: ''; position: absolute; left: -0.85rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--gold); border-radius: 2px;
  box-shadow: 0 0 6px 0 rgba(201,168,41,0.4);
}
[data-theme="dark"] .rail-item.is-active {
  background: linear-gradient(90deg, rgba(232,208,128,0.16) 0%, rgba(232,208,128,0.05) 100%); color: #fff;
}
[data-theme="dark"] .rail-item.is-active::before { box-shadow: 0 0 10px 1px rgba(232,208,128,0.6); }
.rail-badge {
  margin-left: auto; flex-shrink: 0; font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700; color: var(--text-primary);
  background: rgba(120,140,200,0.16); padding: 0.1rem 0.45rem; border-radius: 20px; white-space: nowrap;
}
[data-theme="dark"] .rail-badge { background: rgba(255,255,255,0.12); }
/* Solid fill, not a tint -- this needs to read as an alert, not as
   another quiet metadata pill. White-on-solid-red doesn't need
   per-theme tuning since it's already maximally distinct from every
   surface color in the palette, light or dark. */
.rail-badge.is-danger { color: #fff; background: var(--danger); }
/* Sits below its own divider (see _workspace.php) since it isn't a
   workspace section like the items above it -- styled in the gold accent
   used for CTAs/highlights elsewhere (tour-trigger-btn, is-active rail
   items) so it reads as "helpful shortcut", not another page tab. Never
   gets an .is-active state; it always just opens the tour and leaves. */
.rail-item-tour { color: var(--gold-dark); }
.rail-item-tour svg { stroke: var(--gold-ink); }
.rail-item-tour:hover { background: rgba(201,168,41,0.1); }
[data-theme="dark"] .rail-item-tour:hover { background: rgba(232,208,128,0.1); }
.workspace-content { flex: 1; min-width: 0; }

/* Message Templates preview panel (views/admin/elections/invite_templates.php) */
.preview-panel { transition: opacity 150ms ease; }
.preview-panel.is-loading { opacity: 0.55; }

@media (max-width: 900px) {
  .workspace-shell { flex-direction: column; }
  .workspace-rail {
    width: 100%; position: sticky; top: 0; z-index: 80;
    display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0.3rem;
    padding: 0.7rem; border-radius: var(--radius); align-items: center;
    scrollbar-width: none;
  }
  .workspace-rail::-webkit-scrollbar { display: none; }
  .rail-election-name, .rail-status, .rail-back, .rail-divider { display: none; }
  .rail-item {
    flex-direction: column; gap: 0.25rem; font-size: 0.62rem; padding: 0.5rem 0.7rem;
    white-space: nowrap; flex-shrink: 0; text-align: center;
  }
  .rail-item.is-active::before { left: 50%; top: auto; bottom: -0.4rem; transform: translateX(-50%); width: 60%; height: 3px; }
  .rail-badge { display: none; }
}

/* --- 5.2 Election Workspace: top bar + persistent nested nav (legacy
   horizontal variant, kept for other tab strips e.g. Invitations/Monitor
   sub-tabs which use .tabs, not this rail) ------------------------------- */
.workspace-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.workspace-leave {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  transition: color 150ms ease;
  flex-shrink: 0;
}
.workspace-leave:hover { color: var(--heading-navy); }
.workspace-heading {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}
.workspace-heading h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--heading-navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60vw;
}
@media (max-width: 640px) { .workspace-heading h1 { max-width: 48vw; font-size: 1.05rem; } }

.workspace-nav {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.workspace-nav::-webkit-scrollbar { display: none; }
.workspace-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid transparent;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.workspace-nav-item:hover { color: var(--heading-navy); background: var(--surface-2); }
.workspace-nav-item.is-active {
  color: var(--navy-dark);
  background: var(--gold);
  border-color: var(--gold);
}
[data-theme="dark"] .workspace-nav-item.is-active { color: var(--navy-dark); }
.workspace-nav-item svg { flex-shrink: 0; width: 14px; height: 14px; }
.workspace-nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.12);
  font-size: 0.6rem;
  line-height: 1;
}
.workspace-nav-item.is-active .workspace-nav-count { background: rgba(17,30,74,0.22); }
.workspace-nav-count.is-danger { background: var(--danger); color: #fff; }

/* --- Launch checklist card (matches reference recipe exactly) ---------- */
.checklist-card { border: 1px dashed var(--border-strong); background: linear-gradient(165deg, var(--surface-2) 0%, var(--surface-3) 100%); }
.checklist-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.checklist-head h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; color: var(--heading-navy); }
.checklist-progress {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; color: var(--navy-dark);
  background: var(--gold);
  padding: 0.28rem 0.7rem; border-radius: 20px; box-shadow: 0 2px 6px -1px rgba(201,168,41,0.5);
}
.checklist-items { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.6rem; }
@media (max-width: 900px) { .checklist-items { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .checklist-items { grid-template-columns: 1fr; } }
.check-item {
  display: flex; align-items: flex-start; gap: 0.55rem; padding: 0.6rem 0.7rem;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  font-family: var(--font-body); font-size: 0.8rem; color: var(--text-primary); text-decoration: none;
  transition: border-color 150ms ease;
}
.check-item:hover { border-color: var(--gold); }
.check-item .cbox { width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.check-item.done .cbox { background: linear-gradient(165deg, #4A9068 0%, var(--success) 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.3); }
.check-item.done .cbox svg { width: 11px; height: 11px; stroke: #fff; }
.check-item.pending .cbox { border: 1.5px solid var(--border-strong); }
.check-item.done { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }

/* --- Danger Zone: colored header band instead of a plain red border ---- */
.danger-zone { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.danger-zone-head {
  padding: 0.6rem 1.1rem;
  background: linear-gradient(90deg, rgba(192,32,32,0.14) 0%, rgba(192,32,32,0.04) 100%);
  border-bottom: 1px solid rgba(192,32,32,0.25);
  display: flex; align-items: center; gap: 0.5rem;
}
[data-theme="dark"] .danger-zone-head { background: linear-gradient(90deg, rgba(232,90,90,0.18) 0%, rgba(232,90,90,0.05) 100%); }
.danger-zone-head svg { color: var(--danger-ink); flex-shrink: 0; }
.danger-zone-head span {
  font-family: var(--font-ui); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--danger-ink);
}
.danger-zone-body { padding: 1.1rem; }

/* --- Certification "star moment" card ----------------------------------
   The one card in the whole app that gets an always-on top accent strip
   rather than a plain border -- this is the destination admins reach for
   right before publishing, so it should feel like the ceremonial moment
   it is. */
.cert-card {
  position: relative;
  border-top: 3px solid var(--gold);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}
.cert-card::after {
  content: '';
  position: absolute; top: -3px; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
  opacity: 0.8;
}
.cert-preview {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.1rem;
  background: var(--off-white);
  text-align: center;
}
[data-theme="dark"] .cert-preview { background: rgba(0,0,0,0.2); }
.cert-preview-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; color: var(--heading-navy); }
.cert-preview-sig { max-height: 44px; margin: 0.5rem auto 0; display: block; }
.cert-preview-label { font-family: var(--font-ui); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-light); margin-top: 0.4rem; }
/* --- 7.3 Breadcrumb -------------------------------------------------------
   The real "how do I get back" affordance for a page reached with no
   browser history (bookmark, shared link, fresh tab) -- shows every level
   at once rather than a single "back one step" link. */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 0.85rem;
}
.breadcrumb a { color: var(--text-muted); transition: color 150ms ease; }
.breadcrumb a:hover { color: var(--heading-navy); }
.breadcrumb .crumb-sep { opacity: 0.5; }
.breadcrumb .crumb-current { color: var(--heading-navy); font-weight: 700; }

/* --- 7.4 Resource / action list rows -------------------------------------- */
.list-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 150ms ease, background 150ms ease;
}
.list-row:hover { border-color: var(--border-2); }
.list-row + .list-row { margin-top: 0.6rem; }
.list-row-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(201,168,41,0.12);
  color: var(--gold-ink);
}
[data-theme="dark"] .list-row-icon { background: rgba(201,168,41,0.18); color: var(--gold-light); }
.list-row-body { flex: 1; min-width: 0; }
.list-row-title { font-family: var(--font-body); font-weight: 600; color: var(--heading-navy); font-size: 0.92rem; }
.list-row-desc { font-family: var(--font-body); font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
.list-row-action { flex-shrink: 0; }

/* --- 7.8 Empty states ------------------------------------------------------ */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--border);
  background: var(--surface);
}
.empty-state-icon {
  width: 52px; height: 52px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  color: var(--text-light);
}
.empty-state.is-reassuring .empty-state-icon { background: var(--success-bg); color: var(--success-ink); }
.empty-state-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--heading-navy); }
.empty-state-desc { font-family: var(--font-body); font-size: 0.85rem; color: var(--text-muted); margin-top: 0.4rem; max-width: 32em; margin-left: auto; margin-right: auto; }
.empty-state-action { margin-top: 1.25rem; }

/* --- 7.9 Skeleton loaders --------------------------------------------------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: translateX(-100%);
  animation: skeletonSweep 1.4s ease-in-out infinite;
}
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent); }
@keyframes skeletonSweep { 100% { transform: translateX(100%); } }
.skeleton-text { height: 0.85em; margin: 0.3em 0; }
.skeleton-line { height: 14px; }

/* --- 7.6 Modal (generalized) ----------------------------------------------
   One Alpine-driven recipe for every confirmation dialog in the product,
   replacing every remaining browser confirm(). Markup pattern:
   <div x-data="{open:false}"> trigger <div class="modal-root" x-show="open" x-cloak> ... */
.modal-root { position: fixed; inset: 0; z-index: 300; overflow-y: auto; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10,12,24,0.55); }
.modal-center { position: relative; min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-panel {
  width: 100%; max-width: 420px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
}
.modal-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-icon.is-danger { background: var(--danger-bg); color: var(--danger-ink); }
.modal-icon.is-warning { background: var(--warning-bg); color: var(--warning-ink); }

/* --- 7.10 Command palette (functional global search) ----------------------- */
.cmdk-root { position: fixed; inset: 0; z-index: 400; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(10,12,24,0.6); backdrop-filter: blur(2px); }
.cmdk-panel {
  position: relative;
  width: calc(100% - 2rem); max-width: 580px;
  margin: 9vh auto 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.cmdk-input-row { display: flex; align-items: center; gap: 0.6rem; border-bottom: 1px solid var(--border); padding: 0 1.1rem; }
.cmdk-input-row svg { flex-shrink: 0; color: var(--text-muted); }
.cmdk-input {
  width: 100%;
  padding: 1rem 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.cmdk-input:focus { outline: none; }
.cmdk-input::placeholder { color: var(--text-light); }
.cmdk-list { max-height: min(56vh, 420px); overflow-y: auto; padding: 0.5rem; }
.cmdk-group-label {
  font-family: var(--font-ui); font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-light); padding: 0.65rem 0.75rem 0.3rem;
}
.cmdk-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
}
.cmdk-item.is-active { background: linear-gradient(90deg, rgba(201,168,41,0.16) 0%, rgba(201,168,41,0.04) 100%); }
.cmdk-item-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--gold-ink);
}
.cmdk-item-body { min-width: 0; flex: 1; }
.cmdk-item-title { font-weight: 600; color: var(--heading-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item-sub { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.cmdk-loading { padding: 2rem 1rem; text-align: center; color: var(--text-light); font-size: 0.8rem; }
.cmdk-hint {
  padding: 0.55rem 1rem; border-top: 1px solid var(--border);
  font-family: var(--font-ui); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-light);
  display: flex; gap: 1rem; align-items: center;
}
.cmdk-hint kbd { font-family: var(--font-mono); font-size: 0.66rem; background: var(--surface-3); border: 1px solid var(--border-2); padding: 0.05rem 0.35rem; border-radius: 4px; }
.cmdk-trigger {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.7rem; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); font-family: var(--font-ui); font-size: 0.72rem;
  cursor: pointer; transition: border-color 150ms ease, color 150ms ease;
}
.cmdk-trigger:hover { color: var(--heading-navy); border-color: var(--border-2); }
@media (max-width: 640px) { .cmdk-trigger .cmdk-trigger-label, .cmdk-trigger kbd { display: none; } .cmdk-trigger { padding: 0.5rem; } }

/* --- 7.11 The rotating gold light ------------------------------------------
   A thin highlight that continuously travels a card's border, reserved
   for genuinely-focal cards: the Certification card (always on), the
   headline stat and the currently-active election card (status-driven,
   see the PHP that renders class="card-glow"). Uses an animated
   conic-gradient masked down to a ring via mask-composite: exclude. Needs
   position:relative on the host and NO overflow:hidden, or the ring gets
   silently clipped at the card edge. */
@property --angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
.card-glow { position: relative; }
.card-glow::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(from var(--angle), transparent 0%, var(--gold-light) 12%, var(--gold) 20%, transparent 35%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: cardGlowRotate 4s linear infinite;
  opacity: 0.55;
  pointer-events: none;
}
[data-theme="dark"] .card-glow::before {
  opacity: 0.9;
  filter: drop-shadow(0 0 6px rgba(201,168,41,0.55));
}
@keyframes cardGlowRotate { to { --angle: 360deg; } }
@media (prefers-reduced-motion: reduce) {
  .card-glow::before { animation: none; opacity: 0.35; }
}

/* --- 11. Mobile global nav: bottom tab bar + slide-over drawer ------------- */
.mobile-tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 250;
  background: var(--navy-dark);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 0.4rem 0.25rem calc(0.4rem + env(safe-area-inset-bottom));
  align-items: stretch;
  justify-content: space-around;
}
@media (max-width: 1024px) { .mobile-tabbar { display: flex; } }
.mobile-tabbar-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.55);
  font-family: var(--font-ui);
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex: 1;
  position: relative;
}
.mobile-tabbar-item.is-active { color: #fff; }
.mobile-tabbar-item.is-active svg { color: var(--gold); }
.mobile-tabbar-badge {
  position: absolute; top: 0; right: 18%;
  min-width: 14px; height: 14px; padding: 0 3px;
  border-radius: 999px; background: var(--gold); color: var(--navy-dark);
  font-size: 0.55rem; font-weight: 700; line-height: 14px; text-align: center;
}
@media (max-width: 1024px) {
  .app-content { padding-bottom: 5rem; }
}
.mobile-drawer-backdrop { position: fixed; inset: 0; z-index: 240; background: rgba(10,12,24,0.55); display: none; }
.mobile-menu-trigger { display: none; }
@media (max-width: 1024px) {
  .app-sidebar { display: none; }
  .app-sidebar.is-open {
    display: flex;
    position: fixed; inset: 0 auto 0 0;
    width: 280px;
    z-index: 260;
    box-shadow: var(--shadow-xl);
  }
  .mobile-menu-trigger { display: inline-flex; }
}

/* --- Responsive data tables: stacked cards below sm -----------------------
   Opt-in via data-stack-table on the wrapping element that also has the
   table -- .data-table keeps working untouched on wider viewports. */
@media (max-width: 640px) {
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.25rem 0;
    overflow: hidden;
  }
  .stack-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.9rem;
    border-bottom: 1px dashed var(--border);
    text-align: right;
  }
  .stack-table td:last-child { border-bottom: none; }
  .stack-table td::before {
    content: attr(data-label);
    font-family: var(--font-ui);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
  }
}

/* =========================================================================
   REDUCED MOTION
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
  .badge-active .badge-dot { animation: none; }
  .candidate-card:hover { transform: none; }
  .skeleton::after { display: none; }
}

/* =========================================================================
   BOOTH MODE -- slow, ambient photo crossfade behind the passkey card.
   Deliberately no arrows/dots/pause controls -- this isn't a browsable
   gallery, just a quiet backdrop. Autoplay only; a static first photo is
   shown for reduced-motion users instead of relying on the global rule
   above (which would otherwise flash every photo near-instantly).
   ========================================================================= */
.booth-stage {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
}

.booth-photo-backdrop { position: absolute; inset: 0; z-index: 0; }

.booth-photo-fade {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  animation: boothPhotoFade 40s ease-in-out infinite;
}

@keyframes boothPhotoFade {
  0%   { opacity: 0; }
  7%   { opacity: 1; }
  25%  { opacity: 1; }
  38%  { opacity: 0; }
  100% { opacity: 0; }
}

.booth-photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(17,30,74,0.55) 0%, rgba(17,30,74,0.82) 100%);
}
[data-theme="dark"] .booth-photo-overlay {
  background: linear-gradient(180deg, rgba(12,14,24,0.72) 0%, rgba(12,14,24,0.92) 100%);
}

.booth-stage-content { position: relative; z-index: 1; width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .booth-photo-fade { animation: none !important; opacity: 0; }
  .booth-photo-fade:first-child { opacity: 1; }
}

/* =========================================================================
   PUBLIC LAYOUT NAV
   ========================================================================= */
.public-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  transition: background 0.25s ease;
}
.public-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  min-height: 68px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}
/* The brand block is the thing that should give up space first -- nav
   links and the theme toggle are functional, the wordmark is decorative.
   min-width:0 is the actual fix: flex items default to min-width:auto,
   which stops text-overflow/ellipsis from ever kicking in no matter what
   you set on the child -- that's why this was overflowing the fixed-height
   bar on narrow screens instead of truncating. */
.public-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  min-width: 0;
  flex-shrink: 1;
}
.public-nav-brand-crest { width: 42px; height: 42px; flex-shrink: 0; }
.public-nav-brand-text { min-width: 90px; }
.public-nav-brand-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading-navy);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.public-nav-brand-subtitle {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-ink);
  white-space: nowrap;
}
.public-nav-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem 1.25rem;
  flex: 1 1 auto;
  min-width: 0;
}
@media (max-width: 640px) {
  .public-nav-inner { padding: 0.625rem 1rem; }
  .public-nav-brand-crest { width: 34px; height: 34px; }
  .public-nav-brand-title { font-size: 0.82rem; }
  .public-nav-brand-subtitle { display: none; }
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .nav-links { font-size: 0.66rem; gap: 0.3rem 1rem; }
}
.nav-links-short { display: none; }
@media (max-width: 640px) {
  .nav-links-long { display: none; }
  .nav-links-short { display: inline; }
}
.nav-links a:hover { color: var(--navy); }
[data-theme="dark"] .nav-links a:hover { color: var(--gold-light); }

.nav-vote-btn {
  padding: 0.55rem 1.5rem;
  font-size: 0.7rem;
  flex-shrink: 0;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .nav-vote-btn { padding: 0.5rem 1rem; font-size: 0.62rem; }
}

/* =========================================================================
   PUBLIC FOOTER
   ========================================================================= */
.public-footer {
  position: relative;
  overflow: hidden;
  background: var(--navy-dark);
  color: rgba(255,255,255,0.75);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

/* =========================================================================
   CAROUSEL (landing page hero)
   ========================================================================= */
.carousel-wrap { position: relative; width: 100%; height: 100%; overflow: hidden; }
.carousel-slide { position: absolute; inset: 0; }
.carousel-slide img { width: 100%; height: 100%; object-fit: cover; }
.carousel-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(
    180deg,
    rgba(17,30,74,0.20) 0%,
    rgba(17,30,74,0.55) 50%,
    rgba(17,30,74,0.88) 100%
  );
}

/* Slow Ken Burns drift on the hero carousel images. Two alternating
   directions (zoom toward one corner, then the other) so consecutive
   slides don't all pan the same way. The parent slide wrapper already
   clips overflow (see the carousel component's own overflow-hidden),
   so the extra scale here never spills past the hero edges. Runs on
   loop rather than being tied to the active slide's lifetime -- a
   hidden slide's animation simply pauses while display:none and
   resumes on its next turn, so the motion never looks like it's
   restarting from a jump cut. */
.carousel-kenburns {
  transform-origin: center center;
  will-change: transform;
}
.carousel-kenburns-a { animation: carouselKenburnsA 14s ease-in-out infinite alternate; }
.carousel-kenburns-b { animation: carouselKenburnsB 14s ease-in-out infinite alternate; }
@keyframes carouselKenburnsA {
  0%   { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.12) translate(-1.5%, -1%); }
}
@keyframes carouselKenburnsB {
  0%   { transform: scale(1.08) translate(1%, 1.5%); }
  100% { transform: scale(1.16) translate(-1%, -0.5%); }
}
@media (prefers-reduced-motion: reduce) {
  .carousel-kenburns-a, .carousel-kenburns-b { animation: none; transform: scale(1); }
}

/* =========================================================================
   MESSAGE TEMPLATE EDITOR: default/customized badge, copy button
   (views/admin/elections/invite_templates.php, views/admin/settings/messages.php)
   ========================================================================= */
.tmpl-field-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.tmpl-field-label-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.tmpl-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-family: var(--font-ui); font-size: 0.6rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  transition: background 200ms ease, color 200ms ease;
}
.tmpl-badge--default { background: var(--surface-3); color: var(--text-muted); }
.tmpl-badge--custom { background: rgba(201,168,41,0.16); color: var(--gold-ink); }
.tmpl-actions { display: flex; align-items: center; gap: 0.4rem; }
.tmpl-icon-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--font-ui); font-size: 0.65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-light); background: transparent; border: 1px solid transparent;
  padding: 0.3rem 0.55rem; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.tmpl-icon-btn:hover { background: var(--surface-2); color: var(--heading-navy); border-color: var(--border); }
.tmpl-icon-btn:active { transform: scale(0.95); }
.tmpl-icon-btn.is-confirmed { color: var(--success-ink); }
.tmpl-icon-btn svg { flex-shrink: 0; }

/* =========================================================================
   PHONE PREVIEW MOCKUP
   A self-contained "screenshot" look, deliberately NOT reskinned by
   data-theme="dark" -- this simulates what a voter's phone actually shows,
   which doesn't change with the admin's own dashboard theme preference.
   ========================================================================= */
.phone-preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; }
.phone-preview {
  opacity: 0; animation: phoneMount 0.65s var(--ease) both;
}
@keyframes phoneMount {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .phone-preview { animation: none; opacity: 1; }
}

.phone-shell {
  position: relative;
  width: 250px;
  max-width: 100%;
  aspect-ratio: 250 / 508;
  margin: 0 auto;
  padding: 12px;
  border-radius: 2.6rem;
  background: linear-gradient(155deg, #3a3d46 0%, #1c1e24 42%, #101116 100%);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 0 0 1px rgba(0,0,0,0.4),
    0 18px 40px -12px rgba(10,12,24,0.5),
    0 6px 16px -6px rgba(10,12,24,0.4);
}
/* Side buttons, purely decorative -- a couple of raised strokes on the
   bezel edge read instantly as "phone" even at a glance. */
.phone-shell::before, .phone-shell::after {
  content: ""; position: absolute; background: #101116;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset;
}
.phone-shell::before { left: -2px; top: 90px; width: 3px; height: 46px; border-radius: 2px 0 0 2px; }
.phone-shell::after { right: -2px; top: 130px; width: 3px; height: 70px; border-radius: 0 2px 2px 0; }

.phone-screen {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 1.9rem;
  background: #ffffff;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35) inset;
}
.phone-island {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 78px; height: 20px; border-radius: 12px; background: #0b0c10;
  z-index: 5;
}
.phone-statusbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px 2px; color: #101116; flex-shrink: 0;
}
.phone-time { font-family: -apple-system, 'DM Sans', system-ui, sans-serif; font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em; }
.phone-status-icons { display: flex; align-items: center; gap: 5px; color: #101116; }

.phone-app-header {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px 9px; flex-shrink: 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: #f7f7f9; color: #101116;
}
.phone-app-header--whatsapp {
  background: linear-gradient(180deg, #128C7E 0%, #0f7a6d 100%);
  color: #fff; border-bottom-color: rgba(0,0,0,0.12);
}
.phone-app-header--mail { background: #f7f7f9; color: #101116; padding-bottom: 8px; }
.phone-back { flex-shrink: 0; opacity: 0.85; }
.phone-app-header--whatsapp .phone-back { color: #fff; }
.phone-app-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: var(--navy); display: flex; align-items: center; justify-content: center;
}
.phone-app-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.phone-app-titles { flex: 1; min-width: 0; }
.phone-app-name { font-family: 'DM Sans', system-ui, sans-serif; font-size: 12.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-app-sub { font-size: 9.5px; opacity: 0.6; line-height: 1.2; }
.phone-headicon { flex-shrink: 0; opacity: 0.85; }
.phone-app-header-title { font-family: 'DM Sans', system-ui, sans-serif; font-size: 13.5px; font-weight: 700; }

.phone-app-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 10px 8px;
  background: #f2f2f7;
  display: flex; flex-direction: column; justify-content: flex-start; gap: 6px;
}
/* Bottom-anchor a short message (empty space above it, like a real
   just-opened chat thread) using margin-top:auto on the last item rather
   than justify-content:flex-end on the scroll container -- flex-end
   combined with overflow-y:auto clips and hides the START of the content
   the moment a longer message no longer fits, with no way to scroll back
   to it (a well-known flexbox+overflow interaction). margin-top:auto
   gives the same bottom-anchored look when everything fits, and falls
   back to correct, fully-scrollable top-anchored behavior the moment it
   doesn't. */
.phone-app-header--whatsapp ~ .phone-app-body {
  background-color: #ece5dd;
  background-image: radial-gradient(rgba(0,0,0,0.035) 1px, transparent 1px);
  background-size: 13px 13px;
}
.phone-bubble-row { display: flex; flex-direction: column; align-items: flex-start; margin-top: auto; }
.phone-bubble {
  position: relative;
  max-width: 82%;
  padding: 9px 13px 8px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13.2px; line-height: 1.42;
  white-space: pre-wrap; word-break: break-word;
  background: #e9e9eb; color: #101116;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.06);
  transform-origin: bottom left;
}
.phone-bubble--whatsapp { background: #ffffff; box-shadow: 0 1px 0.5px rgba(0,0,0,0.15); }
.phone-bubble-time {
  font-size: 9.5px; color: #8e8e93; margin: 3px 0 0 6px; font-family: 'DM Sans', system-ui, sans-serif;
}
.phone-typing {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 10px 14px; border-radius: 16px; border-bottom-left-radius: 4px;
  background: #e9e9eb; width: fit-content; margin-top: auto;
}
.phone-app-header--whatsapp ~ .phone-app-body .phone-typing { background: #ffffff; }
.phone-typing span { width: 6px; height: 6px; border-radius: 50%; background: #9a9aa2; animation: typing-bounce 1.2s infinite ease-in-out backwards; }
.phone-typing span:nth-child(2) { animation-delay: 0.15s; }
.phone-typing span:nth-child(3) { animation-delay: 0.3s; }

.phone-app-inputbar {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-top: 1px solid rgba(0,0,0,0.08); background: #fbfbfd;
}
.phone-app-inputbar span {
  flex: 1; font-size: 11.5px; color: #8e8e93; background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1); border-radius: 999px; padding: 6px 12px;
}
.phone-app-inputbar svg { color: #128C7E; flex-shrink: 0; }

.phone-mail-meta { display: flex; align-items: center; gap: 9px; padding: 10px 12px 0; flex-shrink: 0; }
.phone-mail-avatar {
  width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--navy); display: flex; align-items: center; justify-content: center;
}
.phone-mail-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.phone-mail-fromto { flex: 1; min-width: 0; }
.phone-mail-from { font-family: 'DM Sans', system-ui, sans-serif; font-size: 12px; font-weight: 700; color: #101116; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-mail-to { font-size: 10px; color: #8e8e93; }
.phone-mail-time { font-size: 10px; color: #8e8e93; flex-shrink: 0; }
.phone-mail-subject { font-family: 'DM Sans', system-ui, sans-serif; font-size: 13.5px; font-weight: 700; color: #101116; padding: 8px 12px 8px; line-height: 1.3; }
.phone-mail-body { flex: 1; min-height: 0; border-top: 1px solid rgba(0,0,0,0.07); background: #F4F2EE; }
.phone-mail-body iframe { width: 100%; height: 100%; border: 0; display: block; background: #F4F2EE; }

.phone-preview-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  width: 250px; max-width: 100%; font-size: 0.72rem; color: var(--text-light); font-family: var(--font-ui);
}
.phone-copy-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: none; border: none; color: var(--text-light);
  font-family: var(--font-ui); font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  cursor: pointer; padding: 0.15rem 0.3rem; border-radius: var(--radius-sm);
  transition: color 150ms ease, background 150ms ease;
}
.phone-copy-btn:hover { color: var(--heading-navy); background: var(--surface-2); }
.phone-copy-btn.is-copied { color: var(--success-ink); }

.phone-flag-banner {
  display: flex; align-items: flex-start; gap: 0.4rem;
  width: 250px; max-width: 100%;
  font-size: 0.72rem; line-height: 1.4; color: var(--warning-ink);
  background: var(--warning-bg); border: 1px solid rgba(180,90,10,0.25);
  border-radius: var(--radius); padding: 0.5rem 0.65rem;
}
.phone-flag-banner svg { flex-shrink: 0; margin-top: 0.1rem; }

/* Loading dim while an AJAX preview round-trip is in flight -- reuses the
   same convention as the old .preview-panel.is-loading. */
.phone-preview-wrap.is-loading .phone-shell { opacity: 0.6; }
.phone-preview-wrap.is-loading .phone-preview-meta { opacity: 0.6; }
.phone-shell { transition: opacity 200ms ease; }
.phone-preview-meta { transition: opacity 200ms ease; }

@media (max-width: 480px) {
  .phone-shell { width: 220px; }
  .phone-preview-meta, .phone-flag-banner { width: 220px; }
}

/* =========================================================================
   BANNED / FLAGGED WORDS ADMIN UI (views/admin/settings/banned_words.php)
   ========================================================================= */
.bw-chip-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.bw-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.4rem 0.4rem 0.85rem;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-primary);
  animation: bwChipIn 0.3s var(--ease) both;
}
@keyframes bwChipIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .bw-chip { animation: none; } }
.bw-chip input {
  border: none; background: transparent; font-family: var(--font-mono); font-size: 0.8rem;
  color: var(--text-primary); width: 8ch; padding: 0;
}
.bw-chip input:focus { outline: none; }
.bw-chip-edit, .bw-chip-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; border: none; background: transparent;
  color: var(--text-light); cursor: pointer; flex-shrink: 0; transition: background 150ms ease, color 150ms ease;
}
.bw-chip-edit:hover { background: var(--surface-3); color: var(--heading-navy); }
.bw-chip-remove:hover { background: var(--danger-bg); color: var(--danger-ink); }
.bw-chip.is-default { border-style: dashed; }
.bw-empty-state {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 1rem 1.1rem; border-radius: var(--radius); border: 1px dashed var(--border);
  color: var(--text-muted); font-size: 0.85rem;
}
.bw-add-row { display: flex; gap: 0.6rem; }
.bw-add-row input {
  flex: 1; padding: 0.65rem 1rem; border-radius: var(--radius); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.85rem; background: var(--surface);
}
@media (max-width: 420px) {
  .bw-add-row { flex-wrap: wrap; }
  .bw-add-row input { flex-basis: 100%; }
  .bw-add-row button { flex: 1; }
}

/* Generic on/off switch -- used for "suspicious word checking" here, but
   deliberately not banned-words-specific (unprefixed) since any future
   single-feature toggle can reuse it. */
.toggle-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.toggle-switch input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: pointer; z-index: 1;
}
.toggle-switch-track {
  width: 44px; height: 24px; border-radius: 999px; flex-shrink: 0;
  background: var(--surface-3); border: 1px solid var(--border);
  position: relative; transition: background 200ms ease, border-color 200ms ease;
}
.toggle-switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 200ms ease;
}
.toggle-switch input:checked ~ .toggle-switch-track { background: var(--success); border-color: var(--success); }
.toggle-switch input:checked ~ .toggle-switch-track .toggle-switch-thumb { transform: translateX(20px); }
.toggle-switch input:focus-visible ~ .toggle-switch-track { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .toggle-switch-track, .toggle-switch-thumb { transition: none; }
}

/* =========================================================================
   VOTING MODE PICKER -- elections._form.php's "Vote from Home" vs
   "On-site Accreditation" choice. Two selectable cards rather than a
   single .toggle-switch above, since (unlike an on/off feature switch)
   both states here need their own explanation, not just "on" vs "off".
   ========================================================================= */
.voting-mode-card {
  display: flex; flex-direction: column; gap: 0.4rem; text-align: left;
  padding: 1rem 1.1rem; border-radius: var(--radius); border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.voting-mode-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.voting-mode-card.is-selected {
  border-color: var(--heading-navy); background: var(--surface-2); box-shadow: 0 0 0 1px var(--heading-navy);
}
[data-theme="dark"] .voting-mode-card.is-selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.voting-mode-icon {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--heading-navy);
  transition: background 150ms ease, color 150ms ease;
}
.voting-mode-card.is-selected .voting-mode-icon { background: var(--heading-navy); color: #fff; }
[data-theme="dark"] .voting-mode-card.is-selected .voting-mode-icon { background: var(--gold); color: var(--navy-dark); }
.voting-mode-title { font-weight: 600; font-size: 0.85rem; color: var(--heading-navy); }
.voting-mode-desc { font-size: 0.78rem; color: var(--text-muted); line-height: 1.55; }
@media (prefers-reduced-motion: reduce) {
  .voting-mode-card { transition: none; }
  .voting-mode-card:hover { transform: none; }
}

/* =========================================================================
   FLAGGED-WORD "SEND ANYWAY" CONFIRMATION MODAL
   Shared by Message Templates (per-election + Settings default) forms --
   markup lives in views/_components/flagged_word_modal.php, styled with
   the existing .modal-* system (7.6) plus a couple of local tweaks.
   ========================================================================= */
.fw-modal-word-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.6rem 0 0.9rem; }
.fw-modal-word {
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600;
  color: var(--warning-ink); background: var(--warning-bg);
  padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid rgba(180,90,10,0.25);
}
