:root{
  /* eVotaré platform defaults (fallbacks).
     The five tenant theme tokens below are also emitted at runtime by
     page_header() / tenant-theme.css.php from platform_tenant_settings.
     Defaults here are used only on non-tenant pages (sys, marketing). */
  --tenant-primary:#525B5E;
  --tenant-accent:#16a34a;
  --tenant-secondary:#FCF9F4;
  --tenant-bg:#FCF9F4;
  --tenant-text:#111827;
  --tenant-muted:#6b7280;
  --tenant-border:#e5e7eb;
  --tenant-danger-bg:#fff2f2;
  --tenant-danger-border:#f2bcbc;

  /* existing vp tokens mapped to tenant tokens.
     --vp-accent falls back to --vp-primary so legacy callers that only
     ever expected one color don't change behavior until the admin sets
     theme_accent explicitly. */
  --vp-primary: var(--tenant-primary, #525B5E);
  --vp-accent: var(--tenant-accent, var(--tenant-primary, #525B5E));
  --vp-secondary: var(--tenant-secondary, #FCF9F4);
  --vp-bg: var(--tenant-bg, #FCF9F4);
  --vp-text: var(--tenant-text, #111827);
  --vp-muted: var(--tenant-muted, #6b7280);
  --vp-border: var(--tenant-border, #e5e7eb);
  --vp-danger-bg: var(--tenant-danger-bg, #fff2f2);
  --vp-danger-border: var(--tenant-danger-border, #f2bcbc);
}

/* ===== Base layout ===== */

body{
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  margin:0;
  color:var(--vp-text);
  background:#f0f0f0;
}

a{color:var(--vp-accent);text-decoration:none}
a:hover{text-decoration:underline}

table{font-size:14px}
select.input{background:#fff}

/* Tables shouldn't force horizontal scrolling of the whole page */
table { width: 100%; border-collapse: collapse; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Prevent long strings (emails/URLs/code) from blowing out layout */
pre, code { white-space: pre-wrap; word-break: break-word; }

/* ===== Common UI bits ===== */

.card{background:#fff;border:none;border-radius:10px;padding:24px 28px;box-shadow:0 4px 16px rgba(0,0,0,.08)}
.hstack{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.muted{color:var(--vp-muted)}
.btn{display:inline-block;border:1px solid #d1d5db;border-radius:8px;padding:8px 14px;background:#fff;cursor:pointer;font-size:.9rem;color:#374151;font-weight:500}
.btn:hover{background:#f3f4f6;text-decoration:none}
/* Disabled buttons (operator vote controls grey out an action that can't do
   anything — e.g. Prev on the first item, Reset with no ballots). UX only; the
   server still guards every action. No hover, muted, not clickable. */
.btn[disabled],.btn:disabled{opacity:.5;cursor:not-allowed;box-shadow:none}
.btn[disabled]:hover,.btn:disabled:hover{background:#fff;filter:none;text-decoration:none}
.btn-primary[disabled]:hover,.btn-primary:disabled:hover{background:var(--vp-primary);filter:none}
.btn-primary{background:var(--vp-primary);color:#fff;border-color:var(--vp-primary)}
.btn-primary:hover{filter:brightness(.92);background:var(--vp-primary);color:#fff}
.input{width:100%;padding:10px;border:1px solid #ccc;border-radius:6px;font-size:1rem;font-family:inherit}
.input:focus{border-color:var(--vp-primary);outline:none;box-shadow:0 0 0 3px rgba(82,91,94,.18)}
select.input{background:#fff}
.alert{background:var(--vp-danger-bg);border:1px solid var(--vp-danger-border);padding:10px 14px;border-radius:8px}

/* Used on some pages for headings/labels */
.brand{font-weight:700;font-size:22px}

/* ===== Layout safety / responsive defaults ===== */
*, *::before, *::after { box-sizing: border-box; }

html, body { width: 100%; max-width: 100%; overflow-x: clip; }

img, svg, video { max-width: 100%; height: auto; }

/* =========================
   App Shell + Header + Menu
   ========================= */

.app-shell{min-height:100vh;display:flex;flex-direction:column}

/* Content area (readable width + responsive) */
.page-container{
  flex:1;
  width:100%;
  max-width:1480px;
  margin:0 auto;
  padding:20px;

  /* Clip — not scroll — to stop one wide child from dragging the
     whole admin column sideways. Intentionally-wide content (e.g.
     wide voter tables) opts in via the .table-scroll wrapper. */
  overflow-x:clip;
  -webkit-overflow-scrolling:touch;
}

.app-footer{margin-top:18px;color:var(--vp-muted);font-size:12px}

/* ===== Full-width sticky header ===== */
.app-header{
  width:100%;
  margin:0;
  padding:16px 20px;
  min-height: var(--vp-header-h, 110px);
  background:#fff;
  border-bottom:none;
  box-shadow:0 2px 8px rgba(0,0,0,.08);
  position:sticky;
  top:0;
  z-index:50;
}

/*
  Header layout: left-aligned brand + right auth actions
  [hamburger] [org name / tagline]    [auth info]
*/
.app-header-top{
  display:flex;
  align-items:center;
  gap:16px;
  height:100%;
  /* sign-out button is absolutely positioned; brand expands to fill */
}

/* Left column: top row (logo + text) stacked above hamburger */
.app-brand--layout-v2{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:10px;
  min-width:0;
  flex:1;
}

/* Top row inside the left column: logo + org name/tagline side by side */
/* Hamburger label sits to the right of the three lines */
.hamburger-label{
  margin-left:8px;
}

.app-title-main{
  font-weight:800;
  font-size: var(--vp-title-size, 22px);
  line-height:1.1;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:clamp(160px, 45vw, 600px);
}

.app-title-sub{
  font-size: var(--vp-subtitle-size, 13px);
  line-height:1.25;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:clamp(160px, 45vw, 600px);
}

/* Right: auth actions column (kept for views/header.php compatibility) */
.app-actions{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  justify-content:center;
  gap:6px;
  flex-shrink:0;
}

.app-actions-meta{
  display:flex;
  flex-direction:column;
  gap:2px;
  align-items:flex-end;
}

.app-actions-meta .muted{ margin:0; line-height:1.2; }

/* ── Sign-out block (absolutely positioned top-right of .app-header) ── */
.app-header-logout{
  position:absolute;
  top:50%; right:16px;
  transform:translateY(-50%);
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:4px;
  z-index:10;
}

.btn-signout{
  display:inline-block;
  background:linear-gradient(180deg,#e74c3c,#b03025);
  color:#fff;
  text-decoration:none;
  font-size:0.85rem;
  font-weight:700;
  padding:7px 16px;
  border-radius:8px;
  box-shadow:0 3px 0 rgba(0,0,0,0.25),0 4px 10px rgba(0,0,0,0.18);
  white-space:nowrap;
  cursor:pointer;
  border:none;
  transition:filter 0.1s ease,transform 0.08s ease,box-shadow 0.08s ease;
}
.btn-signout:hover{ filter:brightness(1.1); text-decoration:none; color:#fff; }
.btn-signout:active{
  transform:translateY(2px);
  box-shadow:0 1px 0 rgba(0,0,0,0.25),0 2px 4px rgba(0,0,0,0.14);
}

.app-header-user{
  font-size:0.7rem;
  color:rgba(255,255,255,0.85);
  text-align:right;
  line-height:1.35;
  text-shadow:1px 1px 3px rgba(0,0,0,0.4);
}
.app-header-user strong{ color:#fff; }
.app-header-user span{ color:rgba(255,255,255,0.7); }

@media (max-width:768px){
  .btn-signout{ font-size:0.78rem; padding:5px 12px; border-radius:6px; }
  .app-header-logout{ gap:2px; right:10px; }
  .app-header-user{ font-size:0.62rem; }
}

/* Logo image displayed inline in the header, left of org name */
.app-logo-img{
  height: var(--vp-logo-h, 60px);
  max-width:280px;
  object-fit:contain;
  flex-shrink:0;
}

/* ===== Hamburger (bare: no box) ===== */

.hamburger{
  border:0;
  background:transparent;
  padding:4px 0;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:0;
}

.hamburger:focus{
  outline:2px solid var(--vp-primary);
  outline-offset:4px;
}

.hamburger-lines{
  width:22px;
  height:14px;
  position:relative;
  flex-shrink:0;
}

.hamburger-lines span{
  position:absolute;
  left:0;right:0;
  height:2px;
  background:var(--vp-text);
  border-radius:2px;
}

.hamburger-lines span:nth-child(1){top:0}
.hamburger-lines span:nth-child(2){top:6px}
.hamburger-lines span:nth-child(3){bottom:0}

/* ===== 3-zone brand row ===== */

/* Brand top: 3-column grid — left / center / right zones on one horizontal line */
.app-brand-top{
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  width:100%;
  gap:0;
}

/* Each zone is a flex row so logo + text sit side-by-side when in the same zone */
.brand-zone{
  display:flex;
  align-items:center;
  gap:14px;
  min-width:0;
}
.brand-zone-left  { justify-content:flex-start; }
.brand-zone-center{ justify-content:center; }
.brand-zone-right { justify-content:flex-end; }

/* Desktop: the sign-out block (.app-header-logout) is absolutely positioned at
   the top-right and out of flow, so a right-aligned logo/title in the right
   brand zone would render underneath it. Reserve a lane on the right zone so
   they can't overlap. Best-effort width — covers a typical "Signed in as
   <email>" block. Only the right zone is affected, so the default left/center
   logo configs (empty right zone) are byte-identical. Mobile is excluded: there
   the zones flatten (.brand-zone{display:contents}) and the sign-out/switch
   controls move into the drawer. */
@media (min-width: 769px) {
  .brand-zone-right { padding-right: 220px; }
}

/* Brand text block (title + subtitle stacked) */
.app-brand-text{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0;
}

/* ===== Mobile (<=768px — aligned with the hamburger/rail switch) ===== */
@media (max-width: 768px){
  /* min() caps so a smaller configured value still wins on phones */
  .app-header   { min-height: min(var(--vp-header-h, 110px), 72px); padding:14px 16px; }
  .page-container{ padding:16px; }

  .app-header-top{ gap:10px; }

  .app-title-main { font-size: min(var(--vp-title-size, 22px), 18px); }
  .app-title-sub  { font-size: min(var(--vp-subtitle-size, 13px), 12px); }

  .app-logo-img { height: min(var(--vp-logo-h, 60px), 44px); max-width:120px; }

  /* Centre the brand (logo + name) as a group, regardless of the tenant's
     configured 3-zone layout. The hamburger (admin only) and the auth block
     are both absolutely pinned to the header edges, so the brand fills the
     header and centres; symmetric padding keeps it clear of ~100px each side
     (the widest edge is the voter Sign Out button). */
  .app-brand--layout-v2{ align-items:center; }
  .app-brand-top{
    display:flex;
    grid-template-columns:none;
    justify-content:center;
    align-items:center;
    gap:10px;
    padding:0 100px;
    box-sizing:border-box;
  }
  .brand-zone{ display:contents; }                      /* flatten zones: logo + text sit together */
  .app-brand-top a{ order:1; flex:0 0 auto; }           /* logo first, then the name block */
  .app-brand-top .app-brand-text{ order:2; align-items:center; text-align:center !important; min-width:0; }
  .app-title-main, .app-title-sub{ max-width:100%; text-align:center; }
}


/* ===== Popover Menu (anchored-style dropdown) ===== */

.menu-drawer{
  position:fixed;
  inset:0;
  display:none;
  z-index:9999;
  background:transparent;
}
.menu-drawer.open{ display:block; }

.menu-backdrop{
  position:absolute;
  inset:0;
  background:transparent;
}

.menu-panel{
  position:fixed;
  left:16px;
  top:120px;
  width:320px;
  max-width:calc(100vw - 32px);
  max-height:calc(100vh - 140px);
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  background:var(--vp-bg);
  border:1px solid var(--vp-border);
  border-radius:16px;
  padding:12px;
  box-shadow:0 18px 60px rgba(0,0,0,.22);
  opacity:0;
  transform:translateY(-6px);
  transition:opacity .12s ease, transform .12s ease;
}
.menu-drawer.open .menu-panel{
  opacity:1;
  transform:translateY(0);
}

.menu-items{ display:flex; flex-direction:column; gap:10px; margin-top:12px; }
.menu-items .btn{ width:100%; text-align:left; }

/* ── Hamburger drawer: admin two-pane nav (mobile parity with the rail) ──
   Left pane = top-level items; right pane = the selected group's children.
   The drawer only renders for logged-in admin/operator users (never on
   voter/marketing surfaces), so these component styles don't need scoping. */
.menu-panes{ display:flex; gap:8px; align-items:flex-start; }
.menu-nav{ display:flex; flex-direction:column; gap:2px; flex:0 0 auto; min-width:0; }
.menu-nav-row{
  display:flex; align-items:center; gap:10px; width:100%;
  min-height:44px; padding:8px 10px; border-radius:10px; box-sizing:border-box;
  background:transparent; border:0; cursor:pointer;
  font:inherit; font-size:14px; font-weight:600; color:var(--vp-text);
  text-align:left; text-decoration:none;
}
.menu-nav-row:hover{ background:rgba(0,0,0,.05); }
.menu-nav-row.is-active{ background:rgba(29,78,216,.10); color:#1d4ed8; }
.menu-nav-row.is-open{ background:rgba(0,0,0,.06); }
.menu-nav-ico{ font-size:18px; width:22px; text-align:center; flex-shrink:0; }
.menu-nav-lbl{ flex:1; min-width:0; }
.menu-nav-caret{ margin-left:auto; opacity:.5; transition:transform .12s ease; }
.menu-nav-row.is-open .menu-nav-caret{ transform:rotate(90deg); }
.menu-sub-pane{ flex:1 1 auto; min-width:0; }
.menu-sub{ display:none; flex-direction:column; gap:2px; }
.menu-sub.is-open{ display:flex; }
.menu-sub-row{
  display:flex; align-items:center; min-height:44px;
  padding:8px 10px; border-radius:10px; box-sizing:border-box;
  font-size:13px; line-height:1.25; color:var(--vp-text); text-decoration:none;
}
.menu-sub-row:hover{ background:rgba(0,0,0,.05); }
.menu-sub-row.is-active{ background:rgba(29,78,216,.10); color:#1d4ed8; font-weight:600; }
.menu-footer{ margin-top:12px; padding-top:12px; border-top:1px solid var(--vp-border); }
.menu-switch{ margin-bottom:10px; }
.menu-switch-label{ font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--vp-muted,#6b7280); margin-bottom:6px; }
.menu-switch-btn{
  display:block; width:100%; min-height:44px; padding:8px 12px; margin-bottom:6px;
  background:#fff; border:1px solid var(--vp-border,#d1d5db); border-radius:8px;
  color:#1f2937; font:inherit; font-size:13px; font-weight:600; text-align:left; cursor:pointer;
}
.menu-switch-btn:hover{ background:#f3f4f6; border-color:#9ca3af; }
.menu-signout{
  display:flex; align-items:center; justify-content:center;
  width:100%; min-height:44px; box-sizing:border-box;
}

@media (max-width:760px){
  .menu-panel{ left:12px; right:12px; width:auto; }
}


/* ===================================================
   Split-panel layout (votesystem-style card pages)
   =================================================== */

.card-title    { font-size:18px; font-weight:700; margin:0 0 4px; }
.card-subtitle { font-size:13px; color:var(--vp-muted); margin:0 0 20px; }
.section-heading { font-size:15px; font-weight:700; margin:0 0 12px; color:var(--vp-text); }

/* Two-column split inside a card */
.split-layout {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:0;
  align-items:start;
}
.split-col { padding-right:28px; }
.split-col + .split-col {
  padding-right:0;
  padding-left:28px;
  border-left:1px solid var(--vp-border);
}
@media (max-width:900px) {
  .split-layout { grid-template-columns:1fr; }
  .split-col { padding-right:0; }
  .split-col + .split-col {
    padding-left:0;
    border-left:none;
    border-top:1px solid var(--vp-border);
    padding-top:24px;
    margin-top:24px;
  }
}

/* Form rows */
.form-row { display:flex; flex-direction:column; gap:4px; margin-bottom:16px; }
.form-row > label { font-size:13px; font-weight:600; color:var(--vp-text); }
.form-row small  { font-size:12px; color:var(--vp-muted); }
.form-row-inline { display:flex; align-items:center; gap:8px; margin-bottom:12px; font-size:13px; }
.form-actions    { display:flex; gap:8px; align-items:center; margin-top:4px; }

/* Badges */
.badge         { display:inline-block; padding:2px 9px; border-radius:20px; font-size:11px; font-weight:600; }
.badge-success { background:#d1fae5; color:#065f46; }
.badge-muted   { background:#f3f4f6; color:#6b7280; }
.badge-danger  { background:#fee2e2; color:#991b1b; }

/* Button variants */
.btn-secondary { background:#f3f4f6; border-color:#d1d5db; color:#374151; }
.btn-secondary:hover { background:#e5e7eb; }
.btn-danger    { background:#fee2e2; border-color:#fca5a5; color:#991b1b; }
.btn-danger:hover { background:#fecaca; }
.btn-xs        { padding:4px 10px; font-size:12px; border-radius:6px; }

/* Data table */
.vp-table { width:100%; border-collapse:collapse; font-size:13px; }
.vp-table th {
  text-align:left; padding:7px 10px;
  border-bottom:2px solid var(--vp-border);
  font-size:11px; color:var(--vp-muted);
  text-transform:uppercase; letter-spacing:.05em;
  white-space:nowrap;
}
.vp-table td { padding:8px 10px; border-bottom:1px solid var(--vp-border); vertical-align:middle; }
.vp-table tbody tr:hover { background:rgba(0,0,0,.025); }
.vp-table .col-actions { width:1%; white-space:nowrap; }

/* Search/filter input */
.filter-bar { margin-bottom:12px; }
.filter-bar input {
  width:100%; padding:8px 12px;
  border:1px solid var(--vp-border);
  border-radius:10px; font-size:13px;
  background:#fff;
}


/* ─── Admin rail (desktop primary nav) ───────────────────────────── */

/* Flex wrap around the rail + page content. Header (above) and footer
   (below) sit OUTSIDE this wrap so they span the full viewport width.
   Opened by page_header() and closed by page_footer() when an admin
   page is detected. */
.app-body-wrap {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  width: 100%;
  min-height: 0;
}

.app-body-wrap > .page-container {
  flex: 1 1 auto;
  min-width: 0;       /* let the flex item shrink instead of overflowing */
}

.admin-rail {
  flex: 0 0 64px;
  width: 64px;
  background: var(--vp-rail-bg, #fafafa);
  border-right: 1px solid var(--vp-border, #e5e5e5);
  z-index: 50;
  /* Sticky so the rail stays visible as the page content scrolls.
     --rail-top (set inline per-render in admin_rail.php) carries the header
     height so the rail anchors just below the sticky header, not viewport top. */
  position: sticky;
  top: var(--rail-top, 0px);
  align-self: flex-start;
  max-height: 100vh;
  /* No overflow scrolling — mixing overflow-x:visible with
     overflow-y:auto causes browsers to silently force both to auto,
     which clips the hover labels. */
  overflow: visible;
}

/* Spacer reserved for layouts that want padding-top inside the rail.
   Unused in the current layout (rail starts at body-wrap top which is
   already below the header), but the markup still emits one with
   height:0 by default. Inline height set per-render in admin_rail.php. */
.admin-rail__spacer {
  flex-shrink: 0;
}

.admin-rail__nav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

/* Rail item — a wrapper around the icon link plus its hover surface
   (tooltip label OR submenu flyout, depending on whether 'children'
   are present). */
.admin-rail__item {
  position: relative;
  display: block;
  border-left: 3px solid transparent;
  transition: background-color 0.12s ease;
}

.admin-rail__item:hover,
.admin-rail__item:focus-within {
  background: var(--vp-rail-hover-bg, #eef);
}

.admin-rail__item.is-active {
  background: var(--vp-rail-active-bg, #e0e7ff);
  border-left-color: var(--vp-rail-active-accent, #1d4ed8);
}

.admin-rail__item.is-active .admin-rail__icon {
  color: var(--vp-rail-active-fg, #1d4ed8);
}

/* The clickable icon area — same height as before. */
.admin-rail__link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  width: 100%;
  text-decoration: none;
  color: var(--vp-rail-fg, #333);
}

.admin-rail__link:focus { outline: none; }

.admin-rail__icon {
  font-size: 22px;
  line-height: 1;
}

/* Flyout panel — slides out to the right of the rail on hover.
   Every rail item gets one (single-page items get a single-row
   panel; grouped items get a row per child), so the hover UX is
   identical across the rail. */
.admin-rail__flyout {
  position: absolute;
  left: 64px;
  top: 0;
  background: #fff;
  border: 1px solid var(--vp-border, #e5e5e5);
  border-radius: 6px;
  padding: 4px 0;
  /* Fixed width so every flyout looks identical regardless of the
     longest child label. 220px comfortably fits "Vote Screen
     Templates" (the longest current label). */
  width: 220px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-4px);
  transition: opacity 0.12s ease, visibility 0.12s ease, transform 0.12s ease;
  z-index: 51;
}

.admin-rail__item:hover .admin-rail__flyout,
.admin-rail__item:focus-within .admin-rail__flyout,
.admin-rail__item.is-open .admin-rail__flyout {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.admin-rail__flyout-item {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: #1f2937;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.10s ease;
}

.admin-rail__flyout-item:hover,
.admin-rail__flyout-item:focus {
  background: #f3f4f6;
  outline: none;
}

.admin-rail__flyout-item.is-active {
  background: var(--vp-rail-active-bg, #e0e7ff);
  color: var(--vp-rail-active-fg, #1d4ed8);
  font-weight: 600;
}

/* Mobile admin pages: the rail is replaced by the hamburger-driven drawer
   (component styles near .menu-panel above). Hide the rail entirely; the
   hamburger + drawer are no longer suppressed at this width, so they take
   over. The header's Sign Out button and switch-tenant dropdown move into
   the drawer footer — only the "Signed in as" text stays in the header. */
@media (max-width: 768px) {
  body.has-admin-rail .admin-rail { display: none !important; }
  body.has-admin-rail .app-body-wrap { flex-direction: column; }
  body.has-admin-rail .app-header-logout .btn-signout,
  body.has-admin-rail .switch-tenant { display: none !important; }

  /* Icon-only hamburger, pinned to the LEFT edge (mirrors .app-header-logout
     on the right). Bare three lines, no box; >=44x44 tap target. */
  body.has-admin-rail .hamburger{
    position:absolute; left:12px; top:50%; transform:translateY(-50%); z-index:10;
    min-width:44px; min-height:44px; padding:0;
    display:inline-flex; align-items:center; justify-content:center;
    background:transparent; border:0;
  }
  /* White lines with a soft shadow so they read on any tenant header colour
     (matches the white .app-header-user foreground convention). */
  body.has-admin-rail .hamburger-lines span{
    background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.45);
  }
}

/* Below 760px the header shrinks to min(var(--vp-header-h,110px),72px); cap the
   rail's sticky offset the same way so it stays flush under the shrunken header.
   --rail-top equals the header height numerically, so min(--rail-top,72px)
   matches. Placed after the ≤768px block so it wins on source order; 761–768px
   keeps the full-height offset since the header hasn't shrunk yet there. */
@media (max-width: 760px) {
  .admin-rail { top: min(var(--rail-top, 0px), 72px); }
}

/* Desktop: rail replaces the hamburger entirely on admin pages.
 * Scope to body.has-admin-rail so the hamburger still works on
 * non-admin surfaces (the voter portal opens it for the operator menu). */
@media (min-width: 769px) {
  body.has-admin-rail .hamburger,
  body.has-admin-rail .menu-drawer { display: none !important; }
}

/* Voter mobile header: a left hamburger drawer (mirrors the admin has-admin-rail
   pattern). Voter pages have no rail/body class, so key off .hamburger-voter.
   Hidden on desktop — the top-right Sign Out + My profile block is shown there;
   on mobile that Sign Out + My profile move into the drawer, leaving just the
   "Signed in as" name in the header. */
.hamburger-voter{ display:none; }
@media (max-width: 768px) {
  .hamburger-voter{
    display:inline-flex; position:absolute; left:12px; top:50%; transform:translateY(-50%); z-index:10;
    min-width:44px; min-height:44px; padding:0; align-items:center; justify-content:center;
    background:transparent; border:0;
  }
  /* White lines with a soft shadow so they read on any tenant header colour
     (matches the white .app-header-user foreground convention). */
  .hamburger-voter .hamburger-lines span{ background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.45); }
  .app-header-logout--voter .btn-signout,
  .app-header-logout--voter .app-header-user__profile{ display:none !important; }
}

/* Toggle-switch checkbox: a sliding pill that animates off (grey, knob left) →
 * on (green, knob right). Apply to <input type=checkbox class="switch">.
 * Promoted here from an inline copy in admin_sessions.php so every settings
 * surface can use the same control. */
input[type=checkbox].switch {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  position: relative; flex: none; vertical-align: middle; cursor: pointer;
  width: 40px; height: 22px; margin: 0; border-radius: 22px;
  background: #cbd5e1; transition: background .2s ease;
}
input[type=checkbox].switch::before {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .2s ease;
}
input[type=checkbox].switch:checked { background: var(--vp-primary, #1a7a4a); }
input[type=checkbox].switch:checked::before { transform: translateX(18px); }
input[type=checkbox].switch:focus-visible { outline: 2px solid var(--vp-primary, #1a7a4a); outline-offset: 2px; }
input[type=checkbox].switch:disabled { opacity: .5; cursor: not-allowed; }

/* =========================================================================
   Touch targets (coarse pointers only)
   -------------------------------------------------------------------------
   Phones/tablets report `pointer: coarse`; mice/trackpads report `fine`, so
   every rule below matches touch ONLY and leaves desktop density byte-for-byte
   unchanged. It closes the gap the mobile pass left: the base .btn renders
   ~33px tall (under the 44px tap guideline) and is used everywhere (admin
   toolbars, the /vote operator panel, forms).

   Why inline-flex centering instead of bumping padding: dozens of .btn
   instances set their OWN inline padding (admin list actions, operator panel,
   etc.). Growing them via a CSS padding-top/bottom can't win over inline
   padding, and editing that inline padding would also change the DESKTOP
   render. inline-flex + align-items:center makes the label sit centered inside
   the taller box regardless of each button's padding — no per-button edits, no
   desktop change. This mirrors the already-blessed inline pattern on the
   operator "Open" button (admin_operator.php). min-height (not height) lets
   multi-line labels still grow. Every full-width .btn is a <button> (centered
   by the UA already) and none opt into left-aligned text — .menu-items .btn is
   dead CSS — so justify-content:center introduces no regression. */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Desktop admin-rail flyout links. Hidden ≤768px, where the drawer's own
     44px .menu-sub-row takes over — but still shown on wide touchscreens
     (touchscreen laptops, tablets in landscape), where they were ~34px. */
  .admin-rail__flyout-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Header "Switch tenant ▾" disclosure. Its <summary> sets display:inline-block
     inline, so !important is required to switch it to a centering flexbox;
     align-items / min-height aren't set inline so they need no override. */
  .switch-tenant summary {
    min-height: 44px;
    display: inline-flex !important;
    align-items: center;
  }

  /* /verify/public publication-version pills (v1, v2, …) — ~24px otherwise. */
  .ver-pill {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}
