/* Enablement Tracker styles. Design rules: docs/design.md
   Colour means stage (invited / registered / attended / no-show), never decoration. */

@font-face { font-family: "Atkinson Next"; font-weight: 400; font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-next-400.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Next"; font-weight: 600; font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-next-600.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Next"; font-weight: 700; font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-next-700.woff2") format("woff2"); }

/* ===== Design tokens ======================================================
   Light is the default; dark applies when the system prefers it (unless the
   user picked light) or when the user picked dark. All pairs meet WCAG 2.2 AA. */
:root {
  color-scheme: light;

  /* Neutrals: surfaces, text, rules */
  --ground: #eef1ee;        /* page background */
  --paper: #ffffff;         /* sheets, tables, inputs, sidebar */
  --raised: #ffffff;        /* menus, dialogs, toasts */
  --hover: #f3f6f4;         /* row / item hover */
  --selected: #e4eaf6;      /* active nav item, selected rows */
  --ink: #20262b;           /* text, 15:1 on paper */
  --ink-2: #56616a;         /* secondary text, 6.3:1 on paper */
  --line: #d3d9d6;          /* rules between rows */
  --edge: #7e8a93;          /* control borders, 3.5:1 on paper */
  --ink-hover: #3a444c;     /* primary button hover */
  --on-fill: #ffffff;       /* text on stage fills */

  /* Brand = registered: one accent, used for links, focus and active state */
  --brand: #2b4c9b;
  --brand-text: #2b4c9b;    /* 8:1 on paper */
  --focus: #2b4c9b;

  /* Stages (fills). Colour means stage; see docs/design.md */
  --invited: #b9c2c9;
  --registered: #2b4c9b;
  --attended: #1e7f55;
  --noshow: #b5452e;
  --declined: #a8740a;
  --pending-fill: #56616a;

  /* Semantic text colours */
  --success-text: #1e7f55;
  --danger-text: #b5452e;
  --warning-text: #8a5a00;
  --danger-soft: #fbefec;

  /* Type scale: 12 / 14 / 16 / 20 / 24 / 30 */
  --t-xs: 0.75rem;
  --t-sm: 0.875rem;
  --t-base: 1rem;
  --t-md: 1.25rem;
  --t-lg: 1.5rem;
  --t-xl: 1.875rem;

  /* Spacing on a 4px grid */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem;
  --s-5: 1.25rem; --s-6: 1.5rem; --s-8: 2rem; --s-10: 2.5rem; --s-12: 3rem;

  /* Radius by hierarchy: controls < sheets < overlays */
  --radius-control: 4px;
  --radius-sheet: 8px;
  --radius-overlay: 12px;

  /* Shadows only for things floating above the page */
  --shadow-overlay: 0 8px 24px rgb(16 24 32 / 0.14), 0 1px 3px rgb(16 24 32 / 0.08);

  --sidebar-w: 15rem;
  --measure: 70ch;
  --ease: 160ms ease-out;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #14181b; --paper: #1c2125; --raised: #242a2f; --hover: #232a2f; --selected: #24304a;
    --ink: #e6ebe8; --ink-2: #a5b0b7; --line: #2e353b; --edge: #6b7780; --ink-hover: #c9d0cc;
    --brand: #3556b0; --brand-text: #93abf0; --focus: #93abf0;
    --invited: #47515a; --registered: #3556b0; --declined: #e0a33a;
    --success-text: #5cc595; --danger-text: #f2917c; --warning-text: #e9b35a; --danger-soft: #3a2420;
    --shadow-overlay: 0 8px 24px rgb(0 0 0 / 0.5), 0 1px 3px rgb(0 0 0 / 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #14181b; --paper: #1c2125; --raised: #242a2f; --hover: #232a2f; --selected: #24304a;
  --ink: #e6ebe8; --ink-2: #a5b0b7; --line: #2e353b; --edge: #6b7780; --ink-hover: #c9d0cc;
  --brand: #3556b0; --brand-text: #93abf0; --focus: #93abf0;
  --invited: #47515a; --registered: #3556b0; --declined: #e0a33a;
  --success-text: #5cc595; --danger-text: #f2917c; --warning-text: #e9b35a; --danger-soft: #3a2420;
  --shadow-overlay: 0 8px 24px rgb(0 0 0 / 0.5), 0 1px 3px rgb(0 0 0 / 0.4);
}

/* ---- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 400 var(--t-base)/1.5 "Atkinson Next", system-ui, sans-serif;
}
/* Figures line up where numbers are compared; prose keeps proportional figures. */
.table, .facts, .when, .mini, .turnout-bar, .input { font-variant-numeric: tabular-nums; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
h1 { font-size: var(--t-lg); line-height: 1.2; font-weight: 700; }
h2 { font-size: var(--t-md); line-height: 1.3; font-weight: 700; }
h3 { font-size: var(--t-base); font-weight: 700; }
a { color: var(--brand-text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: var(--t-sm); }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.prose { max-width: var(--measure); white-space: pre-line; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Layout -------------------------------------------------------------- */
.page { max-width: 75rem; margin: 0 auto; padding: var(--s-6) var(--s-4) var(--s-12); }
@media (min-width: 64rem) { .page { padding: var(--s-8) var(--s-8) var(--s-12); } }
.stack > * + * { margin-top: 1.5rem; }
.stack-tight > * + * { margin-top: 0.5rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.row-end { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.spread { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.split { display: grid; gap: 1.5rem; }
.form-grid { display: grid; gap: 1.25rem; }
@media (min-width: 64rem) {
  .split { grid-template-columns: 2fr 1fr; align-items: start; }
}
@media (min-width: 40rem) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .full { grid-column: 1 / -1; }
}

/* ---- App shell: sidebar + app bar ---------------------------------------- */
.skip { position: absolute; left: var(--s-2); top: var(--s-2); z-index: 60; padding: var(--s-2) var(--s-3);
  background: var(--raised); color: var(--ink); border-radius: var(--radius-control); box-shadow: var(--shadow-overlay); }
.skip:not(:focus) { width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); box-shadow: none; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: 17rem;
  display: flex; flex-direction: column; gap: var(--s-4);
  background: var(--paper); border-right: 1px solid var(--line); padding: var(--s-4) var(--s-3);
  transform: translateX(-100%); transition: transform var(--ease);
}
.nav-open .sidebar { transform: none; box-shadow: var(--shadow-overlay); }
.backdrop { position: fixed; inset: 0; z-index: 30; background: rgb(10 14 18 / 0.45); }
.main-col { min-width: 0; }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 0 var(--s-2); min-height: 2.5rem; }
.brand { display: flex; align-items: center; gap: var(--s-3); min-width: 0; color: var(--ink); text-decoration: none; }
.brand-name { min-width: 0; font-weight: 700; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name small { display: block; overflow: hidden; text-overflow: ellipsis; font-weight: 400; font-size: var(--t-xs); color: var(--ink-2); }
/* The mark is a tiny turnout strip: attended / registered / invited */
.brand-mark { flex: none; display: flex; width: 1.5rem; height: 0.6rem; border-radius: 2px; overflow: hidden; }
.brand-mark i { display: block; }
.brand-mark i:nth-child(1) { width: 45%; background: var(--attended); }
.brand-mark i:nth-child(2) { width: 30%; background: var(--registered); }
.brand-mark i:nth-child(3) { flex: 1; background: var(--invited); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--s-3); min-height: 2.75rem; padding: 0 var(--s-3);
  border-radius: 6px; color: var(--ink-2); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--selected); color: var(--ink); }
.nav a[aria-current="page"] .icon { color: var(--brand-text); }
.icon { flex: none; width: 1.25rem; height: 1.25rem; }

.sidebar-foot { margin-top: auto; position: relative; }
.user-button {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 2.75rem; padding: var(--s-1) var(--s-2);
  border: 0; border-radius: 6px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.user-button:hover { background: var(--hover); }
.avatar {
  flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--selected); color: var(--brand-text); font-weight: 700; font-size: var(--t-sm);
}
.user-email { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-sm); }

.icon-button {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-button:hover { background: var(--hover); color: var(--ink); }

/* Menus (user menu; later: row menus) */
.menu {
  position: absolute; z-index: 50; min-width: 15rem; padding: var(--s-2);
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-sheet); box-shadow: var(--shadow-overlay);
}
.sidebar-foot .menu { left: 0; right: 0; bottom: calc(100% + var(--s-2)); }
.menu-label { padding: var(--s-2) var(--s-2) var(--s-1); font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-2) 0; }
.menu-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 2.5rem; padding: 0 var(--s-2);
  border: 0; border-radius: 6px; background: transparent; color: var(--ink); font: inherit; font-size: var(--t-sm);
  text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; border-radius: 6px; background: var(--ground); }
.segmented button {
  display: flex; align-items: center; justify-content: center; gap: var(--s-1); min-height: 2.25rem;
  border: 0; border-radius: 5px; background: transparent; color: var(--ink-2); font: inherit; font-size: var(--t-xs); font-weight: 600; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.segmented .icon { width: 1rem; height: 1rem; }

.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-2);
  min-height: 3.5rem; padding: 0 var(--s-4); background: var(--ground); border-bottom: 1px solid var(--line);
}
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0; padding: 0; list-style: none; font-size: var(--t-sm); }
.crumbs li { display: flex; align-items: center; gap: var(--s-2); color: var(--ink-2); min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--edge); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }

@media (min-width: 64rem) {
  .sidebar { width: var(--sidebar-w); transform: none; transition: width var(--ease); }
  .main-col { margin-left: var(--sidebar-w); transition: margin-left var(--ease); }
  .backdrop, .nav-close { display: none !important; }
  .appbar { padding: 0 var(--s-8); }
}
/* Collapsed sidebar (desktop): icons only; labels stay available to screen readers */
@media (min-width: 64rem) {
  :root[data-sidebar="collapsed"] { --sidebar-w: 4.5rem; }
  [data-sidebar="collapsed"] .brand-name,
  [data-sidebar="collapsed"] .nav-label,
  [data-sidebar="collapsed"] .user-email { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  [data-sidebar="collapsed"] .sidebar-head { justify-content: center; padding: 0; }
  [data-sidebar="collapsed"] .nav a, [data-sidebar="collapsed"] .user-button { justify-content: center; padding: 0; }
  [data-sidebar="collapsed"] .sidebar-foot .menu { left: 0; right: auto; }
}

/* ---- Page head ----------------------------------------------------------- */
.page-head p { color: var(--ink-2); margin-top: 0.25rem; max-width: var(--measure); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin-top: 0.75rem; }
.facts dt { color: var(--ink-2); }

/* ---- Sheets (paper on the ground) ---------------------------------------- */
.sheet { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sheet); }
.sheet-pad { padding: 1.25rem; }
.sheet-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.empty { padding: 2rem 1.25rem; max-width: 36rem; }
.empty p { color: var(--ink-2); margin: 0.25rem 0 1rem; }

/* details/summary panels (invite, import) */
details.sheet > summary {
  cursor: pointer; padding: 1rem 1.25rem; font-weight: 700; list-style: none;
}
details.sheet > summary::-webkit-details-marker { display: none; }
details.sheet > summary::before { content: "+"; display: inline-block; width: 1.25rem; color: var(--ink-2); }
details.sheet[open] > summary::before { content: "−"; }
details.sheet[open] > summary { border-bottom: 1px solid var(--line); }
details.sheet > .sheet-pad { padding-top: 1rem; }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.5rem; padding: 0.45rem 1rem;
  font-family: inherit; font-size: var(--t-sm); font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap;
  border: 1px solid var(--edge); border-radius: var(--radius-control);
  background: var(--paper); color: var(--ink); cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn-danger { color: var(--danger-text); border-color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); text-decoration: underline; }
.btn-quiet:hover { color: var(--ink); background: transparent; }
.btn-sm { min-height: 2rem; padding: 0.25rem 0.65rem; }
.btn-block { width: 100%; }

/* Segmented attendance switch */
.switch { display: inline-flex; border: 1px solid var(--edge); border-radius: var(--radius-control); overflow: hidden; }
.switch button {
  font-family: inherit; font-size: var(--t-sm); font-weight: 600; line-height: 1; padding: 0.5rem 0.7rem; min-height: 2rem;
  border: 0; border-left: 1px solid var(--edge); background: var(--paper); color: var(--ink-2); cursor: pointer;
}
.switch button:first-child { border-left: 0; }
.switch button:hover { color: var(--ink); background: var(--hover); }
.switch button[aria-pressed="true"] { color: var(--on-fill); cursor: default; }
.switch button[aria-pressed="true"].is-attended { background: var(--attended); }
.switch button[aria-pressed="true"].is-no_show { background: var(--noshow); }
.switch button[aria-pressed="true"].is-pending { background: var(--pending-fill); }

/* ---- Forms --------------------------------------------------------------- */
.label { display: block; margin-bottom: 0.3rem; font-size: var(--t-sm); font-weight: 600; }
.req { color: var(--danger-text); }
.input {
  display: block; width: 100%; min-height: 2.5rem; padding: 0.45rem 0.7rem;
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--edge); border-radius: var(--radius-control);
}
.input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.input-error { border-color: var(--danger-text); }
.input-inline { width: auto; display: inline-block; }
textarea.input { resize: vertical; }
.hint { margin-top: 0.3rem; font-size: var(--t-sm); color: var(--ink-2); }
.error { margin-top: 0.3rem; font-size: var(--t-sm); color: var(--danger-text); }
.checkbox { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.pick-list { max-height: 18rem; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-control); }
.pick-list label { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.5rem 0.75rem; cursor: pointer; border-top: 1px solid var(--line); }
.pick-list label:first-child { border-top: 0; }
.pick-list label:hover { background: var(--hover); }

/* ---- Tables -------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  position: sticky; top: calc(3.5rem + 1px); z-index: 2; background: var(--paper);
  text-align: left; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  padding: 0.75rem 1.25rem 0.5rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.sheet > .table-wrap:first-child .table th:first-child,
.sheet-head + * .table th:first-child { border-top-left-radius: var(--radius-sheet); }
.table tbody tr:hover td { background: var(--hover); }
.table tbody tr:has(input[name="invitation_ids"]:checked) td { background: var(--selected); }
.table td { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table a:not(.btn) { color: var(--ink); font-weight: 600; text-decoration: none; }
.table a:not(.btn):hover { text-decoration: underline; }
.sub { display: block; font-size: var(--t-sm); color: var(--ink-2); }
.table .actions { text-align: right; white-space: nowrap; }

/* ---- Status: swatch + word, same colours as the turnout strip ------------ */
.status { display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap; }
.status::before { content: ""; width: 0.65rem; height: 0.65rem; border-radius: 2px; background: var(--invited); }
.status-registered::before { background: var(--registered); }
.status-attended::before { background: var(--attended); }
.status-no_show::before { background: var(--noshow); }
.status-declined::before { background: var(--declined); }
.status-pending::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--edge); }

/* ---- Turnout strip: the one bold element --------------------------------- */
.turnout-bar {
  position: relative; height: 2.75rem; border-radius: 3px; overflow: hidden;
  background: var(--invited); color: var(--ink); font-weight: 700;
}
.turnout-bar .seg { position: absolute; inset: 0 auto 0 0; }
.turnout-bar .seg-registered { background: var(--registered); }
.turnout-bar .seg-attended { background: var(--attended); }
.turnout-bar .tag {
  position: absolute; top: 50%; transform: translateY(-50%); white-space: nowrap; font-size: var(--t-sm);
}
.turnout-bar .seg .tag { right: 0.6rem; color: var(--on-fill); }
.turnout-bar > .tag { right: 0.6rem; }
.turnout-note { margin-top: 0.6rem; color: var(--ink-2); max-width: var(--measure); }
.turnout-note strong { color: var(--ink); }
.turnout-empty { height: 2.75rem; border: 1px dashed var(--edge); border-radius: 3px; display: flex; align-items: center; padding: 0 0.75rem; color: var(--ink-2); }

.mini-bar { position: relative; width: 7.5rem; height: 0.5rem; border-radius: 2px; overflow: hidden; background: var(--invited); }
.mini-bar .seg { position: absolute; inset: 0 auto 0 0; }
.mini-bar .seg-registered { background: var(--registered); }
.mini-bar .seg-attended { background: var(--attended); }
.mini { display: flex; align-items: center; gap: 0.6rem; white-space: nowrap; font-size: var(--t-sm); }

/* ---- Ranked strips (top topics, people, channels, types) -----------------
   Length = invited, scaled to the longest row; segments = stage outcome.
   A 2px paper gap separates segments so adjacent colours never touch. */
.rank-strips { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.rank-strips li { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr 4.5rem; align-items: center; gap: var(--s-3); }
.rs-label { min-width: 0; line-height: 1.3; }
.rs-label > a, .rs-label > strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-label .sub { display: block; color: var(--ink-2); font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-track { display: block; min-width: 0; }
.rs-strip { display: flex; height: 0.875rem; min-width: 4px; border-radius: 3px; overflow: hidden; }
.rs-seg { display: block; height: 100%; min-width: 2px; }
.rs-seg + .rs-seg { border-left: 2px solid var(--paper); }
.rs-attended { background: var(--attended); }
.rs-noshow { background: var(--noshow); }
.rs-registered { background: var(--registered); }
.rs-declined { background: var(--declined); }
.rs-invited { background: var(--invited); }
.rs-value { text-align: right; white-space: nowrap; font-size: var(--t-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rs-value strong { color: var(--ink); font-size: var(--t-base); }
.stage-key { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); font-size: var(--t-sm); color: var(--ink-2); }
.chart-note { color: var(--ink-2); font-size: var(--t-sm); margin: 0 0 var(--s-4); }
.chart-group > .stage-key { margin-bottom: var(--s-3); }
.split-even { display: grid; gap: 1.5rem; }
@media (min-width: 64rem) { .split-even { grid-template-columns: 1fr 1fr; align-items: start; } }
@media (max-width: 40rem) {
  /* Label on its own line, strip and number below */
  .rank-strips li { grid-template-columns: 1fr auto; gap: var(--s-1) var(--s-3); }
  .rs-label { grid-column: 1 / -1; }
}

/* ---- Notice (action needed) ---------------------------------------------- */
.notice { border-left: 4px solid var(--noshow); }

/* ---- Lists of events ----------------------------------------------------- */
.event-list li { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; justify-content: space-between; align-items: baseline; padding: 0.75rem 1.25rem; border-top: 1px solid var(--line); }
.event-list li:first-child { border-top: 0; }
.event-list a { color: var(--ink); font-weight: 600; flex: 1 1 12rem; }
.when { color: var(--ink-2); font-size: var(--t-sm); min-width: 9rem; }

/* ---- Filters ------------------------------------------------------------- */
.tabs { display: inline-flex; gap: 1rem; }
.tabs a { color: var(--ink-2); text-decoration: none; padding-bottom: 0.2rem; border-bottom: 2px solid transparent; }
.tabs a[aria-current="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }

/* ---- Login --------------------------------------------------------------- */
.auth { max-width: 24rem; margin: 0 auto; padding: 5rem 1rem; }
.auth h1 { margin-bottom: 0.25rem; }

/* ---- Chart --------------------------------------------------------------- */
.chart { height: 16rem; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---- Small helpers (keep templates free of static inline styles) ---------- */
.mt-xs { margin-top: 0.4rem; }
.mt { margin-top: 1rem; }
.measure { max-width: var(--measure); }
.w-form { max-width: 44rem; }
.w-form-wide { max-width: 48rem; }

/* ---- Roll on phones: one block per person, attendance switch in reach ----- */
@media (max-width: 40rem) {
  .roll thead { display: none; }
  .roll, .roll tbody, .roll td { display: block; }
  .roll tr { display: grid; grid-template-columns: 2rem 1fr; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
  .roll tbody tr:last-child { border-bottom: 0; }
  .roll td { padding: 0.2rem 0; border-bottom: 0; grid-column: 2; }
  .roll td:first-child { grid-column: 1; grid-row: 1 / span 4; }
  .roll td.actions { text-align: left; }
}

/* ===== Tables, filters, feedback, forms ==================================== */

.js .js-hide { display: none; }

/* Search + filter chips */
.search-row { display: flex; gap: var(--s-2); }
.search { max-width: 28rem; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s-1); min-height: 2rem; padding: 0 var(--s-3);
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; text-decoration: none;
}
.chip:hover { color: var(--ink); border-color: var(--edge); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.is-removable { background: var(--selected); border-color: transparent; color: var(--ink); }

/* Sortable headers */
.sort { display: inline-flex; align-items: center; gap: var(--s-1); color: inherit; text-decoration: none; }
.sort:hover, .sort.is-active { color: var(--ink); }
.sort-mark { font-size: var(--t-xs); color: var(--edge); }
.sort.is-active .sort-mark { color: var(--brand-text); }
th.num .sort { flex-direction: row-reverse; }

[data-live-region][aria-busy="true"] .sheet { opacity: 0.6; transition: opacity var(--ease); }
.list-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); }

/* Bulk bar: floats at the bottom of the roll once someone is selected */
.bulkbar {
  position: sticky; bottom: var(--s-4); z-index: 5; margin: var(--s-3);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--radius-sheet); box-shadow: var(--shadow-overlay);
}
.bulk-count { font-weight: 700; margin-right: var(--s-2); }

/* Toasts */
.toasts {
  position: fixed; z-index: 70; right: var(--s-4); bottom: var(--s-4); left: var(--s-4);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s-3);
  width: min(26rem, 100%); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  background: var(--raised); color: var(--ink); border: 1px solid var(--line);
  border-left: 4px solid var(--edge); border-radius: var(--radius-sheet); box-shadow: var(--shadow-overlay);
  animation: toast-in var(--ease);
}
.toast > span { flex: 1; padding-top: 2px; }
.toast-success { border-left-color: var(--attended); }
.toast-error { border-left-color: var(--noshow); }
.toast-close {
  flex: none; width: 1.75rem; height: 1.75rem; border: 0; border-radius: var(--radius-control);
  background: transparent; color: var(--ink-2); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.toast-close:hover { background: var(--hover); color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* Confirm dialog */
.dialog {
  width: min(28rem, calc(100% - 2rem)); padding: var(--s-6); border: 1px solid var(--line);
  border-radius: var(--radius-overlay); background: var(--raised); color: var(--ink); box-shadow: var(--shadow-overlay);
}
.dialog::backdrop { background: rgb(10 14 18 / 0.5); }
.dialog[open] { animation: toast-in var(--ease); }
.dialog h2 { font-size: var(--t-md); }
.dialog p { margin-top: var(--s-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-6); }
.btn-danger-solid { background: var(--noshow); border-color: var(--noshow); color: var(--on-fill); }
.btn-danger-solid:hover { filter: brightness(0.92); background: var(--noshow); }

/* Busy buttons */
.btn.is-busy, .switch button.is-busy { cursor: progress; }
.btn.is-busy::after, .switch button.is-busy::after {
  content: ""; width: 0.9em; height: 0.9em; margin-left: var(--s-1); border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms: grouped sections + sticky save bar */
.form-section { margin: 0; padding: var(--s-5); border: 0; border-bottom: 1px solid var(--line); min-width: 0; }
.form-section legend { float: left; width: 100%; padding: 0; margin-bottom: var(--s-4); font-weight: 700; }
.form-section legend + * { clear: both; }
.form-section .facts { margin-top: var(--s-4); }
.form-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: var(--s-2);
  padding: var(--s-4) var(--s-5); background: var(--paper);
  border-radius: 0 0 var(--radius-sheet) var(--radius-sheet);
  border-top: 1px solid var(--line);
}

/* Lists on phones: one block per row, labelled values */
@media (max-width: 40rem) {
  .table th { position: static; }
  .stack-sm thead { display: none; }
  .stack-sm, .stack-sm tbody, .stack-sm td { display: block; }
  /* Title first, related values share a line, only numbers keep a label */
  .stack-sm tr { display: flex; flex-wrap: wrap; column-gap: var(--s-4); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
  .stack-sm td.inline { width: auto; }
  .stack-sm td.cell-title { order: -1; }
  .stack-sm .muted-sm { color: var(--ink-2); }
  .stack-sm tbody tr:last-child { border-bottom: 0; }
  .stack-sm td { width: 100%; padding: var(--s-1) 0; border: 0; text-align: left; }
  .stack-sm td:empty { display: none; }
  .stack-sm td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-2); font-size: var(--t-sm); }
  .stack-sm td.num { text-align: left; }
  .stack-sm .actions { text-align: left; }
  .search { max-width: none; }
  .toasts { align-items: stretch; }
  .bulkbar { margin: var(--s-2); }
}

/* ===== Dashboard, reports, command palette ================================= */

/* Needs attention */
.count {
  display: inline-grid; place-items: center; min-width: 1.5rem; height: 1.5rem; padding: 0 var(--s-1);
  margin-left: var(--s-1); border-radius: 999px; background: var(--noshow); color: var(--on-fill);
  font-size: var(--t-xs); font-weight: 700; vertical-align: 2px;
}
.attention-list li {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4);
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line);
}
.attention-list li:first-child { border-top: 0; }
.attention-what { flex: 1 1 14rem; min-width: 0; }
.attention-what a { color: var(--ink); font-weight: 600; }

/* Period picker */
.period { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-2); }
.period-custom > summary { list-style: none; cursor: pointer; }
.period-custom > summary::-webkit-details-marker { display: none; }
.period-custom[open] { flex-basis: 100%; }
.period-custom[open] > summary { margin-bottom: var(--s-3); }

/* Change vs previous period */
.deltas { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--s-3); margin: 0; }
.delta-item { padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--radius-control); }
.delta-item dt { font-size: var(--t-sm); color: var(--ink-2); }
.delta-item dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-2); margin: var(--s-1) 0 0; }
.delta-now { font-size: var(--t-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.delta { font-size: var(--t-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.delta-up { color: var(--success-text); }
.delta-down { color: var(--danger-text); }
.delta-flat { color: var(--ink-2); font-weight: 600; }
.delta-before { font-size: var(--t-sm); color: var(--ink-2); }

/* Keycaps */
.kbd {
  display: inline-block; min-width: 1.4rem; padding: 0 var(--s-1); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: var(--radius-control); background: var(--paper);
  font-family: inherit; font-size: var(--t-xs); font-weight: 600; line-height: 1.5; color: var(--ink-2); text-align: center;
}

/* Palette trigger in the app bar */
.palette-trigger {
  margin-left: auto; display: inline-flex; align-items: center; gap: var(--s-2); min-height: 2.5rem;
  padding: 0 var(--s-2) 0 var(--s-3); border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink-2); font: inherit; font-size: var(--t-sm); cursor: pointer;
}
.palette-trigger:hover { border-color: var(--edge); color: var(--ink); }
.palette-trigger .icon { width: 1rem; height: 1rem; }
@media (max-width: 40rem) {
  .palette-trigger { padding: 0; width: 2.75rem; justify-content: center; }
  .palette-trigger-text, .palette-trigger .kbd { display: none; }
}

/* Palette */
.palette {
  width: min(36rem, calc(100% - 2rem)); margin-top: 12vh; padding: 0; border: 1px solid var(--line);
  border-radius: var(--radius-overlay); background: var(--raised); color: var(--ink); box-shadow: var(--shadow-overlay);
}
.palette::backdrop { background: rgb(10 14 18 / 0.45); }
.palette[open] { animation: toast-in var(--ease); }
.palette-input { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); border-bottom: 1px solid var(--line); color: var(--ink-2); }
.palette-input input { flex: 1; min-height: 3.25rem; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: var(--t-base); }
.palette-input input:focus { outline: none; }
.palette-list { max-height: min(24rem, 55vh); overflow-y: auto; padding: var(--s-2); }
.palette-list [role="option"] {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: 2.75rem; padding: var(--s-2) var(--s-3); border-radius: 6px; cursor: pointer;
}
.palette-list [aria-selected="true"] { background: var(--selected); }
.palette-label { min-width: 0; font-weight: 600; }
.palette-label .sub { font-weight: 400; }
.palette-kind { flex: none; font-size: var(--t-xs); color: var(--ink-2); }
.palette-empty { padding: var(--s-4) var(--s-3); color: var(--ink-2); }
.palette-empty:empty { display: none; }
.palette-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line); font-size: var(--t-xs); color: var(--ink-2); }
@media (max-width: 40rem) { .palette-foot { display: none; } }

/* Shortcut help */
.shortcut-list { display: grid; gap: var(--s-2); margin: var(--s-4) 0 0; }
.shortcut-list div { display: grid; grid-template-columns: 6rem 1fr; align-items: center; gap: var(--s-3); }
.shortcut-list dd { margin: 0; }

/* ===== Mobile and touch polish ============================================== */

.turnout-legend { display: none; }
.swatch { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 2px; margin-right: var(--s-1); vertical-align: 0; }
.swatch-attended { background: var(--attended); }
.swatch-registered { background: var(--registered); }
.swatch-invited { background: var(--invited); }
.swatch-noshow { background: var(--noshow); }
.swatch-declined { background: var(--declined); }

@media (max-width: 40rem) {
  /* The strip is too narrow for labels: show a legend instead */
  .turnout-bar .tag { display: none; }
  .turnout-legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin-top: var(--s-2); font-size: var(--t-sm); font-weight: 600; }
  /* Chip rows scroll sideways in one line instead of wrapping */
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .period { flex-direction: column; }
  /* Breadcrumbs: keep the parent and the current page only */
  .crumbs li:not(:nth-last-child(-n+2)) { display: none; }
  .crumbs li:nth-last-child(2)::before { display: none; }
  .crumbs ol { flex-wrap: nowrap; min-width: 0; }
  .crumbs { min-width: 0; }
  .crumbs a, .crumbs [aria-current="page"] { display: block; max-width: 13ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Touch: every target at least 44px (WCAG 2.5.8 asks 24; 44 is the comfortable size) */
.hit { display: inline-grid; place-items: center; }
@media (max-width: 40rem), (pointer: coarse) {
  .btn, .btn-sm, .chip, .switch button, .menu-item, .segmented button, .palette-trigger,
  .nav a, .user-button, .sort { min-height: 2.75rem; }
  .icon-button, .toast-close { width: 2.75rem; height: 2.75rem; }
  .btn-quiet.btn-sm { min-width: 2.75rem; }
  .hit { min-width: 2.75rem; min-height: 2.75rem; margin: -0.6rem; cursor: pointer; }
  .checkbox { width: 1.3rem; height: 1.3rem; }
  .pick-list label { min-height: 2.75rem; align-items: center; }
  .palette-list [role="option"] { min-height: 3rem; }
}

/* ===== Partners ============================================================== */

/* Logo or initials; logos are pre-scaled server-side, so object-fit only letterboxes */
.partner-mark {
  flex: none; display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem;
  border-radius: 6px; object-fit: contain; background: var(--paper); border: 1px solid var(--line);
}
.partner-initials { background: var(--selected); color: var(--brand-text); font-weight: 700; font-size: var(--t-sm); border-color: transparent; }
.partner-mark-lg { width: 3rem; height: 3rem; }
.partner-mark-xl { width: 5rem; height: 5rem; font-size: var(--t-lg); }
[data-sidebar="collapsed"] .brand .partner-mark { width: 2.25rem; height: 2.25rem; }

.nav-sep { border: 0; border-top: 1px solid var(--line); margin: var(--s-2) var(--s-2); }

.partner-list li {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5);
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line);
}
.partner-list li:first-child { border-top: 0; }
.partner-list li:hover { background: var(--hover); }
.partner-open { flex: 1 1 18rem; display: flex; align-items: center; gap: var(--s-4); min-width: 0; color: var(--ink); text-decoration: none; }
.partner-open:hover .partner-name { text-decoration: underline; }
.partner-text { min-width: 0; }
.partner-name { display: block; font-weight: 700; font-size: var(--t-md); line-height: 1.3; }
.partner-turnout { flex: none; }

.logo-field { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-5); }
.file-input { font: inherit; font-size: var(--t-sm); color: var(--ink-2); max-width: 100%; }
.file-input::file-selector-button {
  margin-right: var(--s-3); min-height: 2.5rem; padding: 0 var(--s-4); border: 1px solid var(--edge);
  border-radius: var(--radius-control); background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.danger-zone { border-color: var(--noshow); }
.danger-zone h2 { color: var(--danger-text); font-size: var(--t-md); }
.grow-field { flex: 1 1 16rem; }
/* Partner names can be long: up to two lines in the sidebar, then an ellipsis */
.brand-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
