/* ==========================================================================
   Soul Sounds Academy (SSA) — shell
   Base, atmosphere, the sidebar and app bar, surfaces, form controls, and
   every overlay the app opens (dialogs, the command palette, selects, the
   date picker, hover panels and toasts).
   ========================================================================== */

/* ---------------- Base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
  background: var(--bg);
}
/* Sign-in and the overture keep their original typefaces */
#screen-login, .overture {
  --font-display: var(--font-display-login);
  --font-ui: var(--font-ui-login);
  font-family: var(--font-ui);
  font-feature-settings: "ss01", "cv11";
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
h1, h2, h3, h4, p, dl, dd, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img, svg, canvas { display: block; }
[hidden] { display: none !important; }
::selection { background: rgb(var(--brass-rgb) / 0.32); color: var(--text-1); }

:focus-visible { outline: 2px solid var(--focus-border); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 16px; top: -60px; z-index: 300;
  padding: 10px 16px; border-radius: var(--r-ctl);
  background: var(--brass); color: var(--brass-ink); font-weight: 600; text-decoration: none;
  transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus { top: 16px; }

/* Type helpers the app still emits */
.t-2 { color: var(--text-2); }
.t-3 { color: var(--text-3); font-size: var(--fs-xs); }
.num, .money { font-variant-numeric: tabular-nums; }
strong { font-weight: 600; color: var(--text-1); }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-3);
}
/* The screen number: a plain numeral and a hairline, quieter than the label */
.eyebrow__n {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-3); opacity: 0.7;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.eyebrow__n::after { content: ""; width: 14px; height: 1px; background: currentColor; }
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 0 3px rgb(var(--brass-rgb) / 0.16), 0 0 12px rgb(var(--brass-rgb) / 0.7);
}
.dot--live { animation: dot-pulse 2.4s var(--ease-out) infinite; }
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgb(var(--brass-rgb) / 0.16), 0 0 12px rgb(var(--brass-rgb) / 0.7); }
  50% { box-shadow: 0 0 0 6px rgb(var(--brass-rgb) / 0.04), 0 0 18px rgb(var(--brass-rgb) / 0.9); }
}

.scroll-slim { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.scroll-slim::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll-slim::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }

/* ---------------- Atmosphere ---------------- */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; contain: strict; }
.ambient__aurora { position: absolute; inset: -20%; }
.ambient__aurora i {
  position: absolute; display: block; border-radius: 50%;
  mix-blend-mode: screen;
  animation: aurora-drift 26s var(--ease-out) infinite alternate;
}
:root[data-theme="paper"] .ambient__aurora i { mix-blend-mode: multiply; }
.ambient__aurora i:nth-child(1) { width: 56vw; height: 56vw; left: 46%; top: -10%; background: radial-gradient(circle, var(--aurora-1) 0%, transparent 70%); }
.ambient__aurora i:nth-child(2) { width: 50vw; height: 50vw; left: 4%; top: 8%; background: radial-gradient(circle, var(--aurora-2) 0%, transparent 70%); animation-duration: 34s; animation-delay: -8s; }
.ambient__aurora i:nth-child(3) { width: 44vw; height: 44vw; left: 28%; top: 58%; background: radial-gradient(circle, var(--aurora-3) 0%, transparent 70%); animation-duration: 40s; animation-delay: -14s; }
@keyframes aurora-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vw, 4vh, 0) scale(1.12); }
  100% { transform: translate3d(-5vw, -3vh, 0) scale(0.94); }
}
.ambient__grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgb(var(--paper-rgb) / 0.028) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(var(--paper-rgb) / 0.028) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 60% 0%, #000 10%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 60% 0%, #000 10%, transparent 70%);
}
body.not-authenticated .ambient__grid { display: none; }

/* The cursor carries a faint pool of light across the page (ui.js moves it) */
.cursor-glow {
  position: fixed; left: 0; top: 0; z-index: 1;
  width: 560px; height: 560px; margin: -280px 0 0 -280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(var(--brass-rgb) / 0.06), transparent 62%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms var(--ease-out);
  will-change: transform;
}
body.authenticated .cursor-glow.is-on { opacity: 1; }
:root[data-theme="paper"] .cursor-glow { background: radial-gradient(circle, rgb(var(--brass-rgb) / 0.07), transparent 62%); }

/* ---------------- App frame ---------------- */
.sidebar, .appbar, .main, .footer { position: relative; z-index: 2; }
body.authenticated { padding-left: var(--sidebar-w); }
body.not-authenticated .sidebar,
body.not-authenticated .appbar,
body.not-authenticated .footer { display: none; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  position: fixed; z-index: 40;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgb(var(--brass-rgb) / 0.045), transparent 30%),
    rgb(var(--bg-rgb) / 0.72);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}
.sidebar__top { padding: 0 8px 22px; }

.wordmark { display: inline-flex; flex-direction: column; gap: 10px; text-decoration: none; }
.wordmark__logo {
  --logo-h: 40px;
  display: block; flex: none;
  height: var(--logo-h);
  width: calc(var(--logo-h) * 334 / 156);
  background: var(--gold-grad);
  -webkit-mask: url("../img/logo.png") center / contain no-repeat;
          mask: url("../img/logo.png") center / contain no-repeat;
  transition: filter var(--dur-base) var(--ease-out);
}
.wordmark:hover .wordmark__logo { filter: brightness(1.15) drop-shadow(0 0 12px rgb(var(--brass-rgb) / 0.4)); }
.wordmark__sub {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-3);
}

.sidebar__label {
  padding: 0 12px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-3);
}
.tabs { flex: 1 1 auto; min-height: 0; }
.tabs__list { position: relative; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.tabs__list > li { position: relative; z-index: 1; }
.tab {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 42px; padding: 0 12px;
  border-radius: 12px;
  color: var(--text-2);
  font-size: var(--fs-base);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.tab__icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  transition: color var(--dur-base) var(--ease-out), transform 420ms var(--ease-rise);
}
.tab:hover { color: var(--text-1); background: var(--surface); }
.tab:hover .tab__icon { transform: translateX(1px) scale(1.06); }
.tab[aria-current="page"] { color: var(--text-1); background: var(--surface-2); }
.tab[aria-current="page"] .tab__icon { color: var(--brass); filter: drop-shadow(0 0 8px rgb(var(--brass-rgb) / 0.5)); }
/* With the travelling indicator (ui.js) the active background is the indicator itself */
.tabs.has-indicator .tab[aria-current="page"] { background: transparent; }
.tabs__indicator {
  position: absolute; left: 0; top: 0; z-index: 0;
  width: 100%; height: 42px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgb(var(--brass-rgb) / 0.12), var(--surface-2) 60%);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.04);
  pointer-events: none;
  opacity: 0;
}
.tabs__indicator::before {
  content: ""; position: absolute; left: -15px; top: 50%;
  width: 3px; height: 18px; margin-top: -9px;
  border-radius: 0 3px 3px 0;
  background: var(--brass);
  box-shadow: 0 0 12px rgb(var(--brass-rgb) / 0.9);
}
body[data-role="frontdesk"] .tabs__list li:has([data-tab="dashboard"]),
body[data-role="frontdesk"] .tabs__list li:has([data-tab="profits"]),
body[data-role="frontdesk"] .tabs__list [data-tab="dashboard"],
body[data-role="frontdesk"] .tabs__list [data-tab="profits"] { display: none; }
body[data-role="frontdesk"] #screen-dashboard,
body[data-role="frontdesk"] #screen-profits { display: none !important; }

.sidebar__bottom { display: flex; flex-direction: column; gap: 12px; }

.sidebar__quick {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px;
  border: 1px solid rgb(var(--brass-rgb) / 0.25);
  border-radius: 14px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgb(var(--brass-rgb) / 0.16), transparent 60%),
    var(--surface);
  text-align: left;
  transition: border-color var(--dur-base) var(--ease-out), transform 300ms var(--ease-rise);
}
.sidebar__quick:hover { border-color: rgb(var(--brass-rgb) / 0.55); }
.sidebar__quick:active { transform: scale(0.98); }
.sidebar__quick-icon {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--gold-grad); color: var(--brass-ink);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.3) inset, 0 1px 2px rgb(0 0 0 / 0.28);
}
.sidebar__quick-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sidebar__quick-text { display: flex; flex-direction: column; line-height: 1.25; }
.sidebar__quick-text strong { font-size: var(--fs-sm); font-weight: 600; }
.sidebar__quick-text small { font-size: var(--fs-2xs); color: var(--text-3); }

/* Palette: a segmented control with a sliding thumb */
.palette {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr) auto; align-items: center;
  padding: 3px; gap: 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.palette__sw {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  height: 30px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-3);
  transition: color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.palette__sw svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.palette__sw svg .fill { fill: currentColor; stroke: none; }
.palette__sw:hover { color: var(--text-1); }
.palette__sw[aria-checked="true"] { color: var(--brass); background: var(--surface-3); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 1px 2px rgb(0 0 0 / 0.2); }
.palette__sw[aria-checked="true"] svg { animation: sw-pop 500ms var(--ease-rise); }
@keyframes sw-pop { from { transform: rotate(-40deg) scale(0.6); } }
.palette__name {
  padding: 0 8px 0 6px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
  min-width: 64px; text-align: right;
}

/* Account */
.topbar__user {
  align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 8px 8px 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.user-pill { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-pill__avatar {
  position: relative;
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--brass), var(--brass-deep), rgb(var(--violet-rgb)), var(--brass));
  color: var(--brass-ink);
  font-weight: 700; font-size: var(--fs-sm);
}
.user-pill__avatar::before {
  content: attr(data-initial);
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-solid);
  color: var(--brass);
  font-family: var(--font-display); font-size: 17px; font-style: italic;
}
.user-pill__avatar::after {
  content: ""; position: absolute; right: -1px; bottom: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--positive); border: 2px solid var(--surface-solid);
}
.user-pill__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-pill__name { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pill__role { font-size: var(--fs-2xs); color: var(--text-3); }
.topbar__logout {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--text-2);
  transition: color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.topbar__logout:hover { color: var(--ember); border-color: rgb(var(--ember-rgb) / 0.45); background: rgb(var(--ember-rgb) / 0.08); }
.topbar__logout-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.topbar__logout-arrow { transition: transform 300ms var(--ease-rise); }
.topbar__logout:hover .topbar__logout-arrow { transform: translateX(2px); }

/* ---------------- Collapsible sidebar (icon rail) ----------------
   html.is-rail narrows --sidebar-w, which also moves the page (body's
   padding-left). Labels are only hidden from view, never from screen
   readers. Rows clip their labels, so as the rail widens again the text
   is uncovered rather than spilling out. Desktop only: at 960px and
   below the sidebar is a top bar with nothing to collapse. */
.sidebar__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sidebar__toggle {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; margin-top: 6px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-3);
  transition: color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.sidebar__toggle:hover { color: var(--text-1); background: var(--surface-2); border-color: var(--line); }
.sidebar__toggle:focus-visible { outline: 2px solid var(--focus-border); outline-offset: 2px; }
.sidebar__toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.sidebar__toggle-chev { transform-box: fill-box; transform-origin: center; transition: transform 280ms var(--ease-rise); }

/* Only while the toggle is used (app.js sets .is-rail-moving for the
   duration), so signing in or reloading never slides the page in */
.is-rail-moving .sidebar { transition: width var(--dur-slow) var(--ease-rise); }
.is-rail-moving body.authenticated { transition: padding-left var(--dur-slow) var(--ease-rise); }
.is-rail-moving .sidebar__toggle-chev { transition-duration: var(--dur-slow); }
.tab, .sidebar__quick { overflow: hidden; }
.tab__label, .sidebar__quick-text > * { white-space: nowrap; }

@media (min-width: 641px) {
  :root.is-rail { --sidebar-w: var(--sidebar-drag, 76px); }   /* --sidebar-drag: only mid-drag (app.js) */
  .is-rail .sidebar__toggle-chev { transform: scaleX(-1); }
  .is-rail .sidebar__top { flex-direction: column; align-items: center; gap: 14px; padding: 0 0 22px; }
  .is-rail .sidebar__toggle { margin-top: 0; }
  /* The rail is too narrow for the logo: it moves to the app bar, full size */
  .is-rail .sidebar .wordmark { display: none; }
  .is-rail .appbar__brand { display: inline-flex; }
  .is-rail .appbar__org { display: none; }
  .is-rail .wordmark__text, .is-rail .palette__name, .is-rail .user-pill__who { display: none; }
  .is-rail .sidebar__label { visibility: hidden; }   /* keeps its height, so the tabs don't jump */
  .is-rail .tab__label, .is-rail .sidebar__quick-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  }
  .is-rail .tab { justify-content: center; gap: 0; padding: 0; }
  .is-rail .sidebar__quick { justify-content: center; padding: 6px; }
  .is-rail .palette { grid-template-columns: 1fr; }
  .is-rail .palette__sw { height: 26px; }
  .is-rail .topbar__user { flex-direction: column; gap: 10px; padding-inline: 0; }
  .is-rail .user-pill { flex: none; }

  /* The label, as a tooltip beside each icon */
  .is-rail .tabs__list > li::after {
    content: attr(data-tip);
    position: absolute; left: calc(100% + 14px); top: 50%;
    padding: 5px 10px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-2);
    font-size: var(--fs-xs); font-weight: 500; color: var(--text-1); white-space: nowrap;
    opacity: 0; transform: translate(-4px, -50%);
    transition: opacity 150ms var(--ease-out), transform 200ms var(--ease-out);
    pointer-events: none;
  }
  .is-rail .tabs__list > li:hover::after,
  .is-rail .tabs__list > li:focus-within::after { opacity: 1; transform: translate(0, -50%); }
}

/* ---------------- Resizable sidebar (desktop) ----------------
   Dragging the edge sets --sidebar-user (app.js), between a minimum that
   still fits the labels and the default 256px; dragging further in snaps
   to the icon rail above. Only the desktop sidebar resizes: the tablet
   rail and the phone top bar keep their own widths. */
.sidebar { container: sidebar / inline-size; }
.sidebar__resizer { display: none; }
@media (min-width: 961px) {
  :root:not(.is-rail) { --sidebar-w: var(--sidebar-user, 256px); }
  .sidebar__resizer {
    display: block;
    position: absolute; top: 0; bottom: 0; right: -5px; z-index: 5;
    width: 10px;
    cursor: col-resize;
    touch-action: none;
    outline: none;
  }
  /* A hairline of the palette's gold, only on hover, focus or while dragging */
  .sidebar__resizer::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 4px;
    width: 2px; border-radius: 2px;
    background: rgb(var(--brass-rgb) / 0.55);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
  }
  .sidebar__resizer:hover::after,
  .sidebar__resizer:focus-visible::after,
  .is-resizing .sidebar__resizer::after { opacity: 1; }
  .sidebar__resizer:focus-visible::after { background: var(--focus-border); }
}
/* While dragging: the width follows the pointer with no easing, and the
   page never selects text or flickers to another cursor */
.is-resizing, .is-resizing * { cursor: col-resize !important; user-select: none !important; }
.is-resizing .sidebar, .is-resizing body.authenticated { transition: none; }
/* Letting go between the rail and the narrowest open width: it settles to
   the nearer of the two with a short ease, never a jump */
.is-rail-snap .sidebar { transition: width 220ms var(--ease-out); }
.is-rail-snap body.authenticated { transition: padding-left 220ms var(--ease-out); }

/* As the sidebar narrows, text gives way cleanly instead of being cut */
.tab__label, .sidebar__quick-text, .sidebar__quick-text > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user-pill__role { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Container widths are the sidebar's content box: its width less 29px of
   padding and border (so 207px here is a sidebar about 236px wide) */
@container sidebar (max-width: 207px) {
  .palette__name, .wordmark__sub { display: none; }   /* a label and a tagline: they go, rather than wrap */
  .palette { grid-template-columns: repeat(3, 1fr); }
}
@container sidebar (max-width: 187px) {   /* a sidebar about 216px wide */
  .sidebar__quick-text small { display: none; }
}

/* Tablet / intermediate viewports (641px - 960px): Keep sidebar on the left as a clean icon rail */
@media (min-width: 641px) and (max-width: 960px) {
  :root { --sidebar-w: 76px; }
  .sidebar__toggle { display: none; }
  .sidebar__top { flex-direction: column; align-items: center; gap: 14px; padding: 0 0 22px; }
  .sidebar .wordmark { display: none; }          /* the rail is too narrow: */
  .appbar .appbar__brand { display: inline-flex; }   /* the logo sits in the app bar */
  .wordmark__text, .palette__name, .user-pill__who { display: none; }
  .sidebar__label { visibility: hidden; }
  .tab__label, .sidebar__quick-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  }
  .tab { justify-content: center; gap: 0; padding: 0; }
  .sidebar__quick { justify-content: center; padding: 6px; }
  .palette { grid-template-columns: 1fr; }
  .palette__sw { height: 26px; }
  .topbar__user { flex-direction: column; gap: 10px; padding-inline: 0; }
  .user-pill { flex: none; }
  .tabs__list > li::after {
    content: attr(data-tip);
    position: absolute; left: calc(100% + 14px); top: 50%;
    padding: 5px 10px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-2);
    font-size: var(--fs-xs); font-weight: 500; color: var(--text-1); white-space: nowrap;
    opacity: 0; transform: translate(-4px, -50%);
    transition: opacity 150ms var(--ease-out), transform 200ms var(--ease-out);
    pointer-events: none;
  }
  .tabs__list > li:hover::after,
  .tabs__list > li:focus-within::after { opacity: 1; transform: translate(0, -50%); }
}
/* Phones: the sidebar is a top bar with nothing to collapse */
@media (max-width: 640px) {
  .sidebar__toggle { display: none; }
}
.reduce-motion.is-rail-moving .sidebar, .reduce-motion.is-rail-moving body.authenticated { transition: none; }

/* ---------------- App bar ---------------- */
.appbar {
  position: sticky; top: 0; z-index: 35;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  height: var(--appbar-h);
  padding: 0 var(--gutter);
  border-bottom: 1px solid transparent;
  background: rgb(var(--bg-rgb) / 0);
  transition: background-color 300ms var(--ease-out), border-color 300ms var(--ease-out), backdrop-filter 300ms;
}
.appbar.is-scrolled {
  background: rgb(var(--bg-rgb) / 0.72);
  border-bottom-color: var(--line);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
/* The logo in the app bar: shown only while the sidebar is an icon rail */
.appbar__brand { display: none; flex: none; align-items: center; margin-right: 6px; text-decoration: none; border-radius: 6px; }
.appbar__brand .wordmark__logo { --logo-h: 40px; }   /* the same size as in the full sidebar */
.appbar__brand:hover .wordmark__logo { filter: brightness(1.15); }
.appbar__brand:focus-visible { outline: 2px solid var(--focus-border); outline-offset: 4px; }
.appbar__crumb { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: var(--fs-sm); }
.appbar__org { color: var(--text-3); white-space: nowrap; }
.appbar__sep { width: 8px; height: 12px; fill: none; stroke: var(--text-3); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.appbar__here { color: var(--text-1); font-weight: 500; white-space: nowrap; display: inline-block; }
.appbar__end { display: flex; align-items: center; gap: 10px; }
.appbar__date { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; margin-right: 6px; }
.appbar__search {
  display: inline-flex; align-items: center; gap: 10px;
  height: 36px; min-width: 260px; padding: 0 6px 0 12px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface);
  color: var(--text-3);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.appbar__search:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--text-2); }
.appbar__search svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.appbar__search span { flex: 1; text-align: left; }
.appbar__search .kbd { pointer-events: none; }

/* ---------------- Main ---------------- */
.main {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-5) var(--gutter) var(--s-10);
  min-height: calc(100vh - var(--appbar-h) - 60px);
}
body.not-authenticated .main { max-width: none; padding: 0; min-height: 100vh; }

.footer { padding: 0 var(--gutter) var(--s-6); }
.footer__inner {
  max-width: calc(var(--content-max) - 2 * var(--gutter));
  margin: 0 auto;
  display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap;
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--text-3);
}
.footer__year { font-family: var(--font-mono); letter-spacing: 0.04em; }

/* ---------------- Surfaces ---------------- */
.card, .panel, .stat, .pf-month, .admin-ops__group, .setup {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
:root[data-theme="paper"] .card,
:root[data-theme="paper"] .panel,
:root[data-theme="paper"] .stat,
:root[data-theme="paper"] .pf-month,
:root[data-theme="paper"] .admin-ops__group,
:root[data-theme="paper"] .setup { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* Spotlight: a pool of gold follows the cursor inside a card, and its
   border catches the light nearest the pointer (ui.js sets --mx / --my) */
[data-spotlight], .pf-month { --mx: -500px; --my: -500px; isolation: isolate; }
:is([data-spotlight], .pf-month)::before,
:is([data-spotlight], .pf-month)::after {
  content: ""; position: absolute; inset: 0; z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 500ms var(--ease-out);
}
:is([data-spotlight], .pf-month)::before {
  background: radial-gradient(520px circle at var(--mx) var(--my), rgb(var(--brass-rgb) / 0.075), transparent 42%);
}
:is([data-spotlight], .pf-month)::after {
  inset: -1px;
  padding: 1px;
  background: radial-gradient(260px circle at var(--mx) var(--my), rgb(var(--brass-rgb) / 0.65), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
:is([data-spotlight], .pf-month):hover::before,
:is([data-spotlight], .pf-month):hover::after,
:is([data-spotlight], .pf-month):focus-within::after { opacity: 1; }
:is([data-spotlight], .pf-month) > * { position: relative; z-index: 1; }

.panel { padding: var(--s-6); }
.panel__head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); flex-wrap: wrap; }
.panel__head .eyebrow { margin-bottom: 6px; }
.panel__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-xl);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.panel__tools { display: flex; align-items: center; gap: var(--s-3); }
.panel__meta { font-size: var(--fs-xs); color: var(--text-3); font-family: var(--font-mono); letter-spacing: 0.02em; }

/* ---------------- Controls ---------------- */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 22px; padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.kbd:empty { display: none; }

.field { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label, .form__label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.field--compact { flex-direction: row; align-items: center; gap: 8px; }

.input,
.form input[type="text"], .form input[type="number"], .form input[type="date"], .form input[type="month"],
.form input[type="search"], .form input[type="password"], .form input[type="email"], .form input[type="file"],
.form textarea,
.toolbar input[type="search"] {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
  color: var(--text-1);
  font-size: var(--fs-base);
  outline: none;
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
  appearance: none; -webkit-appearance: none;
}
.form input[type="file"] { padding: 9px 12px; height: auto; font-size: var(--fs-sm); color: var(--text-2); }
.form input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 6px 12px;
  border: 1px solid rgb(var(--brass-rgb) / 0.4); border-radius: 8px;
  background: rgb(var(--brass-rgb) / 0.08); color: var(--brass);
  font: inherit; font-weight: 500; cursor: pointer;
}
.input::placeholder, .form input::placeholder, .toolbar input::placeholder { color: var(--text-3); }
.input:hover, .form input:hover, .toolbar input:hover { border-color: var(--line-hot); background: var(--input-bg-hot); }
.input:focus, .form input:focus, .form textarea:focus, .toolbar input:focus {
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring);
  background: var(--input-bg-hot);
}
.form input[readonly] { color: var(--text-2); background: transparent; border-style: dashed; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { opacity: 0.4; }

.field__icon {
  position: absolute; left: 13px; top: 50%;
  width: 15px; height: 15px; margin-top: -7.5px;
  fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
  transition: stroke var(--dur-base) var(--ease-out);
}
.field--search { flex: 1 1 280px; max-width: 420px; }
.toolbar .field--search input, .field--search input[type="search"] { padding-left: 38px; padding-right: 64px; }
.field--search:focus-within .field__icon { stroke: var(--brass); }
.field--search .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); cursor: pointer; }
.field__clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
  font-size: 16px; line-height: 1; cursor: pointer;
  transition: color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.field__clear[hidden] { display: none; }
.field__clear:hover, .field__clear:focus-visible { color: var(--text-1); background: var(--surface-3, var(--line)); }
.field--search:has(.field__clear:not([hidden])) .kbd { display: none; }

/* ---------------- Forms (dialogs) ---------------- */
.form { display: flex; flex-direction: column; gap: var(--s-4); }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.form__field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form__hint { font-size: var(--fs-xs); color: var(--text-3); }
.form__error { font-size: var(--fs-xs); color: var(--ember); min-height: 0; }
.form__error:empty { display: none; }
.form__text { color: var(--text-2); line-height: var(--lh-body); }
.form__field.is-invalid input, .form__field.is-invalid .sel__btn, .form__field.is-invalid .dp__btn {
  border-color: rgb(var(--ember-rgb) / 0.8);
  box-shadow: 0 0 0 4px rgb(var(--ember-rgb) / 0.12);
}
.form__field.is-invalid .form__error { animation: err-in 260ms var(--ease-out); }

/* Class checklist */
.checklist {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow-y: auto;
  padding: 4px; margin: 0 -4px;
}
.check {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--input-bg);
  cursor: pointer;
  transition: border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}
.check:hover { border-color: var(--line-hot); }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check__box {
  position: relative; flex: none;
  width: 20px; height: 20px;
  border: 1.5px solid var(--line-hot);
  border-radius: 6px;
  transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out), transform 300ms var(--ease-rise);
}
.check__box::after {
  content: ""; position: absolute; inset: 0;
  background: var(--brass-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.4l2.4 2.4 4.6-5' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.4l2.4 2.4 4.6-5' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
  transform: scale(0.4); opacity: 0;
  transition: transform 300ms var(--ease-rise), opacity 150ms var(--ease-out);
}
.check input:checked ~ .check__box { background: var(--gold-grad); border-color: transparent; box-shadow: 0 0 14px -2px rgb(var(--brass-rgb) / 0.6); }
.check input:checked ~ .check__box::after { transform: none; opacity: 1; }
.check:has(input:checked) { border-color: rgb(var(--brass-rgb) / 0.45); background: rgb(var(--brass-rgb) / 0.06); }
.check input:focus-visible ~ .check__box { outline: 2px solid var(--focus-border); outline-offset: 2px; }
.check__text { display: flex; justify-content: space-between; gap: 12px; flex: 1; min-width: 0; font-size: var(--fs-sm); }
.check__text .t-2 { font-family: var(--font-mono); font-size: var(--fs-xs); }

/* Fee cards: registration fee, 4-month bundle, payment plan sections */
.form-card {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4);
  border: 1px solid rgb(var(--brass-rgb) / 0.3);
  border-radius: 14px;
  background: rgb(var(--brass-rgb) / 0.045);
}
.form-card[hidden] { display: none; }
.form-card--dashed { border-style: dashed; }
.form-card--quiet { border-color: var(--line-strong); background: var(--surface); }
.form-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-3); }
.form-card__title { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-1); }
.form-card__sub { display: block; margin-top: 2px; font-size: var(--fs-xs); line-height: var(--lh-snug); color: var(--text-2); }
.form-card .form__row { align-items: start; }
.form-card__check .check { height: 42px; }
.form-card__check { padding-top: calc(var(--fs-xs) * 1.5 + 6px); }   /* lines the checkbox up with the input beside it */
@media (max-width: 640px) { .form-card__check { padding-top: 0; } }
.form-note {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-xs);
  background: rgb(var(--brass-rgb) / 0.08);
  font-size: var(--fs-xs); line-height: var(--lh-snug);
  color: var(--text-2);
}
.form-note strong { color: var(--text-1); font-weight: 600; }
.form-note__save { color: var(--positive); font-weight: 600; }
.form input.input--figure { font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.check__text strong { font-weight: 600; }
.check__note { display: block; margin-top: 2px; font-size: var(--fs-xs); line-height: var(--lh-snug); color: var(--text-2); }

/* Payment plan: a three-way segmented control (same family as the palette switcher) */
/* The three plan panels share one grid cell: the cell is always as tall as the
   tallest panel, so switching plans never resizes the dialog (or toggles its
   scrollbar). Inactive panels keep their space but are invisible and unfocusable. */
.plan-panels { display: grid; }
.plan-panels > .plan-panel { grid-area: 1 / 1; }
.plan-panels > .plan-panel.is-off { visibility: hidden; }
.form__hint--2l { line-height: 1.5; min-height: 3em; }   /* the amount hint is one or two lines depending on the plan */

.plan-switch {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.plan-switch__thumb {
  /* One highlight that slides between the options (--i = active index, set by app.js) */
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 10px) / 3);                       /* 3px padding each side + two 2px gaps */
  border-radius: 9px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px rgb(var(--brass-rgb) / 0.4), 0 1px 2px rgb(0 0 0 / 0.16);
  transform: translateX(calc(var(--i, 0) * (100% + 2px)));
  transition: transform var(--dur-slow) var(--ease-emphasis);
  pointer-events: none;
}
.plan-switch__opt {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2);
  font: inherit; text-align: center; cursor: pointer;
  transition: color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.plan-switch__opt strong { font-size: var(--fs-sm); font-weight: 600; color: inherit; }
.plan-switch__opt small { font-size: var(--fs-2xs); color: var(--text-3); }
.plan-switch__opt:hover { color: var(--text-1); background: var(--surface-2); }
.plan-switch__opt[aria-pressed="true"] { color: var(--brass); background: transparent; }   /* the thumb draws the highlight */
.plan-switch__opt:focus-visible { outline: 2px solid var(--focus-border); outline-offset: 2px; }

/* ---------------- Chips ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-1);
}
.chip .t-2 { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); }
.chip--online { border-color: rgb(var(--online-rgb) / 0.35); background: rgb(var(--online-rgb) / 0.1); color: var(--online); }
.chip--standard { border-color: rgb(var(--brass-rgb) / 0.35); background: rgb(var(--brass-rgb) / 0.1); color: var(--brass); }
.chip--accent { height: 22px; padding: 0 8px; flex: none; border-color: rgb(var(--brass-rgb) / 0.35); background: rgb(var(--brass-rgb) / 0.1); color: var(--brass); font-size: var(--fs-2xs); font-weight: 600; }
.chip__x {
  display: grid; place-items: center;
  width: 18px; height: 18px; margin-right: -5px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-3);
  font-size: 14px; line-height: 1;
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), transform 300ms var(--ease-rise);
}
.chip__x:hover { background: rgb(var(--ember-rgb) / 0.16); color: var(--ember); transform: rotate(90deg); }

/* ---------------- Custom select ---------------- */
.sel { position: relative; min-width: 150px; }
.sel__native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.sel__btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; height: 42px; padding: 0 12px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
  color: var(--text-1);
  text-align: left;
  font-size: var(--fs-base);
  transition: border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.sel__btn:hover { border-color: var(--line-hot); background: var(--input-bg-hot); }
.sel__btn[aria-expanded="true"], .sel__btn:focus-visible { border-color: var(--focus-border); box-shadow: var(--focus-ring); outline: none; }
.sel__btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sel__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel__chev { width: 12px; height: 12px; flex: none; color: var(--text-3); transition: transform 300ms var(--ease-rise); }
.sel__btn[aria-expanded="true"] .sel__chev { transform: rotate(180deg); color: var(--brass); }
.field--compact .sel { min-width: 140px; }
.field--compact .sel__btn { height: 34px; font-size: var(--fs-sm); }

.sel__list {
  position: fixed; z-index: 200;
  list-style: none; margin: 0; padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  transition: opacity 160ms var(--ease-out), transform 260ms var(--ease-rise);
  scrollbar-width: thin;
}
.sel__list.is-above { transform-origin: bottom center; transform: translateY(6px) scale(0.98); }
.sel__list.is-open { opacity: 1; transform: none; }
.sel__opt {
  position: relative;
  padding: 9px 12px 9px 32px;
  border-radius: 9px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out);
}
.sel__list.is-open .sel__opt { animation: opt-in 280ms var(--ease-rise) both; }
.sel__list.is-open .sel__opt:nth-child(2) { animation-delay: 15ms; }
.sel__list.is-open .sel__opt:nth-child(3) { animation-delay: 30ms; }
.sel__list.is-open .sel__opt:nth-child(4) { animation-delay: 45ms; }
.sel__list.is-open .sel__opt:nth-child(5) { animation-delay: 60ms; }
.sel__list.is-open .sel__opt:nth-child(n+6) { animation-delay: 75ms; }
@keyframes opt-in { from { opacity: 0; transform: translateY(-4px); } }
.sel__opt.is-active { background: var(--surface-3); color: var(--text-1); }
.sel__opt[aria-selected="true"] { color: var(--text-1); font-weight: 500; }
.sel__opt[aria-selected="true"]::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  background: var(--brass);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.4l2.6 2.6L10 3' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.4l2.6 2.6L10 3' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------------- Date & month picker ---------------- */
.dp { position: relative; }
.dp__native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.dp__btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; height: 42px; padding: 0 12px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
  text-align: left;
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.dp__btn:hover { border-color: var(--line-hot); }
.dp__btn[aria-expanded="true"], .dp__btn:focus-visible { border-color: var(--focus-border); box-shadow: var(--focus-ring); outline: none; }
.dp__text.is-empty { color: var(--text-3); }
.dp__icon { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.dp__btn[aria-expanded="true"] .dp__icon { color: var(--brass); }

.dp__popup {
  position: fixed; z-index: 210;
  width: 296px; padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-3);
  opacity: 0; transform: translateY(-6px) scale(0.97);
  transform-origin: top left;
  transition: opacity 160ms var(--ease-out), transform 280ms var(--ease-rise);
}
.dp__popup.is-above { transform-origin: bottom left; transform: translateY(6px) scale(0.97); }
.dp__popup.is-open { opacity: 1; transform: none; }
.dp__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dp__title { font-family: var(--font-display); font-size: var(--fs-lg); }
.dp__nav {
  display: grid; place-items: center;
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 9px;
  background: transparent; color: var(--text-2);
  transition: background-color var(--dur-base), color var(--dur-base);
}
.dp__nav svg { width: 12px; height: 12px; }
.dp__nav:hover { background: var(--surface-3); color: var(--text-1); }
.dp__dows, .dp__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp__dow { text-align: center; font-family: var(--font-mono); font-size: 10px; color: var(--text-3); padding: 4px 0; text-transform: uppercase; }
.dp__cell, .dp__mcell {
  height: 34px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-1);
  font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
  transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out), transform 200ms var(--ease-rise);
}
.dp__cell:hover, .dp__mcell:hover { background: var(--surface-3); }
.dp__cell:active, .dp__mcell:active { transform: scale(0.92); }
.dp__cell.is-other { color: var(--text-3); }
.dp__cell.is-today, .dp__mcell.is-current { box-shadow: inset 0 0 0 1px rgb(var(--brass-rgb) / 0.55); color: var(--brass); }
.dp__cell.is-selected, .dp__mcell.is-selected { background: var(--gold-grad); color: var(--brass-ink); font-weight: 600; box-shadow: 0 6px 16px -6px rgb(var(--brass-rgb) / 0.7); }
.dp__mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp__mcell { height: 44px; }
.dp__foot { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.dp__quick { border: 0; background: none; color: var(--brass); font-size: var(--fs-xs); font-weight: 500; padding: 4px 6px; border-radius: 6px; }
.dp__quick:hover { background: rgb(var(--brass-rgb) / 0.1); }

/* ---------------- Dialog ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: var(--s-5);
}
.modal__overlay {
  position: absolute; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal:not([hidden]) .modal__overlay { animation: fade-in 260ms var(--ease-out); }
.modal__panel {
  position: relative;
  display: flex; flex-direction: column;
  width: min(580px, 100%);
  max-height: min(88vh, 860px);
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background:
    radial-gradient(120% 60% at 50% -10%, rgb(var(--brass-rgb) / 0.08), transparent 60%),
    var(--surface-solid);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  outline: none;
}
.modal:not([hidden]) .modal__panel { animation: modal-in 520ms var(--ease-rise); }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(0.965); filter: blur(4px); } }
@keyframes fade-in { from { opacity: 0; } }

.modal__stave { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; padding: 14px 24px 0; }
.modal__stave i { height: 3px; border-radius: 3px; background: var(--line-strong); }
.modal__stave i.is-past { background: rgb(var(--brass-rgb) / 0.45); }
.modal__stave i.is-now { background: var(--brass); box-shadow: 0 0 10px rgb(var(--brass-rgb) / 0.9); }
.modal:not([hidden]) .modal__stave i { animation: stave-in 600ms var(--ease-rise) both; }
.modal__stave i:nth-child(1) { animation-delay: 40ms; } .modal__stave i:nth-child(2) { animation-delay: 70ms; }
.modal__stave i:nth-child(3) { animation-delay: 100ms; } .modal__stave i:nth-child(4) { animation-delay: 130ms; }
.modal__stave i:nth-child(5) { animation-delay: 160ms; } .modal__stave i:nth-child(6) { animation-delay: 190ms; }
.modal__stave i:nth-child(7) { animation-delay: 220ms; } .modal__stave i:nth-child(8) { animation-delay: 250ms; }
.modal__stave i:nth-child(9) { animation-delay: 280ms; } .modal__stave i:nth-child(10) { animation-delay: 310ms; }
.modal__stave i:nth-child(11) { animation-delay: 340ms; } .modal__stave i:nth-child(12) { animation-delay: 370ms; }
@keyframes stave-in { from { transform: scaleX(0); opacity: 0; } }

.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); padding: 20px 24px 6px; }
.modal__title { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-2xl); line-height: 1.05; letter-spacing: -0.01em; }
.modal__sub { margin-top: 6px; color: var(--text-2); font-size: var(--fs-sm); }
.modal__body { padding: 16px 24px 20px; overflow-y: auto; }
.modal:not([hidden]) .modal__body > * { animation: rise-in 520ms var(--ease-rise) both; }
.modal:not([hidden]) .modal__body > *:nth-child(2) { animation-delay: 50ms; }
.modal:not([hidden]) .modal__body > *:nth-child(3) { animation-delay: 100ms; }
.modal:not([hidden]) .modal__body > *:nth-child(4) { animation-delay: 150ms; }
.modal__foot {
  display: flex; justify-content: flex-end; align-items: center; gap: var(--s-2);
  padding: 16px 24px 20px;
  border-top: 1px solid var(--line);
  background: rgb(0 0 0 / 0.12);
}
:root[data-theme="paper"] .modal__foot { background: var(--bg-2); }
.modal__foot:empty { display: none; }
.modal__foot [data-act="danger"] { margin-right: auto; }

/* Command palette (the dialog in its is-cmdk form) */
.modal__panel.is-cmdk { width: min(640px, 100%); align-self: start; margin-top: 12vh; }
.modal__panel.is-cmdk .modal__stave { display: none; }
.modal__panel.is-cmdk .modal__head { padding-top: 18px; }
.modal__panel.is-cmdk .modal__title { font-size: var(--fs-xl); }
.modal__panel.is-cmdk .modal__body { gap: 10px; padding-bottom: 12px; }
.cmdk__input {
  width: 100%; height: 52px; padding: 0 16px 0 46px;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.25'/%3E%3Cpath d='m10.2 10.2 3.3 3.3'/%3E%3C/svg%3E") 16px center / 18px no-repeat,
    var(--input-bg);
  font-size: var(--fs-md);
  outline: none;
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.cmdk__input:focus { border-color: var(--focus-border); box-shadow: var(--focus-ring); }
.cmdk__list { position: relative; list-style: none; max-height: 50vh; overflow-y: auto; margin: 0 -8px; padding: 4px 8px; scrollbar-width: thin; }
.cmdk__group {
  padding: 12px 12px 6px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--text-3);
}
.cmdk__item {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 12px;
  border-radius: 11px;
  cursor: pointer;
  color: var(--text-2);
  transition: color 120ms var(--ease-out);
}
.cmdk__item.is-active { color: var(--text-1); }
.cmdk__item .t-2 { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.cmdk__item.is-active::after {
  content: "↵"; font-size: 12px; color: var(--brass); margin-left: 8px;
}
.cmdk__list.is-fresh .cmdk__item { animation: opt-in 360ms var(--ease-rise) both; }
.cmdk__list.is-fresh .cmdk__item:nth-of-type(2) { animation-delay: 20ms; }
.cmdk__list.is-fresh .cmdk__item:nth-of-type(3) { animation-delay: 40ms; }
.cmdk__list.is-fresh .cmdk__item:nth-of-type(4) { animation-delay: 60ms; }
.cmdk__list.is-fresh .cmdk__item:nth-of-type(n+5) { animation-delay: 80ms; }
.cmdk__marker {
  position: absolute; left: 8px; right: 8px; z-index: 0;
  border-radius: 11px;
  background: linear-gradient(90deg, rgb(var(--brass-rgb) / 0.14), var(--surface-3));
  border: 1px solid rgb(var(--brass-rgb) / 0.25);
  transform: translateY(var(--marker-shift, 0px));
  pointer-events: none;
}
.cmdk__empty { padding: 28px 12px; text-align: center; color: var(--text-3); }

/* ---------------- Hover panel ---------------- */
.hpanel {
  position: fixed; z-index: 150;
  max-width: 320px; min-width: 220px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-3);
  font-size: var(--fs-sm);
  pointer-events: none;
  opacity: 0;
  /* Arrives as a fade with the slightest drift, never a pop */
  transform: translateY(2px);
  transition: opacity 180ms var(--ease-out), transform 220ms var(--ease-out);
}
.hpanel.is-above { transform: translateY(-2px); }
.hpanel.is-open { opacity: 1; transform: none; }
.hpanel__title { font-family: var(--font-display); font-size: var(--fs-lg); line-height: 1.15; margin-bottom: 10px; }
.hpanel__rows { display: flex; flex-direction: column; gap: 6px; }
.hpanel__row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.hpanel__num { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.hpanel__num.is-negative { color: var(--ember); }
.hpanel__line { color: var(--text-2); line-height: 1.5; }
.hpanel__line strong { color: var(--brass); }
.hpanel__cta { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--brass) !important; font-family: var(--font-mono); font-size: 10.5px !important; letter-spacing: 0.04em; text-transform: uppercase; }
.hpanel__methods { display: flex; flex-direction: column; gap: 4px; padding: 6px 0 4px; }
.hpanel__split { display: flex; height: 6px; border-radius: 6px; overflow: hidden; gap: 2px; margin-bottom: 4px; }
.hpanel__split-seg { width: var(--w); height: 100%; border-radius: 3px; animation: split-draw 500ms var(--ease-rise) both; transform-origin: left; }
.hpanel__split-seg--standard, .hpanel__swatch--standard { background: var(--brass); }
.hpanel__split-seg--online, .hpanel__swatch--online { background: var(--online); }
@keyframes split-draw { from { transform: scaleX(0); } }
.hpanel__key { display: inline-flex; align-items: center; gap: 6px; }
.hpanel__swatch { width: 8px; height: 8px; border-radius: 2px; }
.hpanel__method { font-size: var(--fs-xs); }
.hpanel__months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; }
.hpanel__month { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); padding: 3px 4px; border-radius: 6px; }
.hpanel__month .t-3 { font-size: 10px; }
.hpanel__month.is-hot { background: var(--surface-3); }
.hpanel__month.is-none { opacity: 0.5; }
.hpanel__month .cell { width: 12px; height: 12px; border-radius: 3px; }


/* ---------------- Toasts ---------------- */
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 500;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%;
  padding: 14px 10px 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: toast-in 520ms var(--ease-rise);
  overflow: hidden;
  position: relative;
}
.toast::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brass);
}
.toast:has(.cell--unpaid)::before { background: var(--ember); }
.toast:has(.cell--upcoming)::before { background: var(--text-3); }
.toast > .cell { margin-top: 2px; flex: none; }
.toast__text { flex: 1; min-width: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-2); padding-top: 1px; }
.toast .btn--icon { margin: -4px 0 -4px auto; }
.toast.is-leaving { animation: toast-out 260ms var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(0.98); } }

/* ---------------- Payment cells (shared: matrix, legend, toasts) ---------------- */
.cell {
  position: relative; display: inline-block; flex: none;
  width: 20px; height: 20px;
  border-radius: 6px;
  vertical-align: middle;
}
.cell--paid, .cell--online {
  background: var(--cell-paid-bg);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.12) inset, 0 4px 12px -4px rgb(var(--brass-rgb) / 0.7);
}
.cell--online {
  border-radius: 50%;
  background: var(--cell-online-bg);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.12) inset, 0 4px 12px -4px rgb(var(--online-rgb) / 0.7);
}
.cell--paid:not(.cell--draw)::after, .cell--online:not(.cell--draw)::after {
  content: ""; position: absolute; inset: 0;
  background: var(--cell-paid-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.4l2.4 2.4 4.6-5' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 13px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.4l2.4 2.4 4.6-5' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.cell--online:not(.cell--draw)::after { background: var(--cell-online-ink); }
.cell--draw svg { position: absolute; inset: 0; width: 100%; height: 100%; padding: 3px; fill: none; stroke: var(--cell-paid-ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cell--online.cell--draw svg { stroke: var(--cell-online-ink); }
.cell--draw path { stroke-dasharray: 12; stroke-dashoffset: 12; animation: draw-check 460ms 120ms var(--ease-out) forwards; }
.cell--draw { animation: cell-pop 220ms var(--ease-out); }   /* a brief settle; the drawn check is the confirmation */
@keyframes draw-check { to { stroke-dashoffset: 0; } }
@keyframes cell-pop { from { transform: scale(0.9); } }
.cell--unpaid {
  border: 1.5px solid rgb(var(--ember-rgb) / 0.85);
  background:
    repeating-linear-gradient(-45deg, rgb(var(--ember-rgb) / 0.32) 0 2px, transparent 2px 5px),
    rgb(var(--ember-rgb) / 0.08);
}
.cell--upcoming { border: 1.5px dashed var(--cell-upcoming); }
.cell--none::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%;
  background: var(--text-3); opacity: 0.6;
}

/* ---------------- Skeleton ---------------- */
.skeleton { display: flex; flex-direction: column; gap: var(--s-6); padding-top: var(--s-4); }
.skeleton i, .skeleton__bar {
  display: block;
  border-radius: 10px;
  background:
    linear-gradient(100deg, transparent 20%, rgb(var(--paper-rgb) / 0.06) 40%, transparent 60%) 0 0 / 200vw 100% no-repeat,
    var(--surface-2);
  animation: skeleton-sweep 1.6s linear infinite;
}
.skeleton__head { display: flex; flex-direction: column; gap: 12px; }
.skeleton__bar--title { width: 280px; height: 44px; }
.skeleton__bar--lede { width: 440px; max-width: 80%; height: 14px; }
.skeleton__tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
.skeleton__tiles i { height: 120px; border-radius: var(--r-card); }
.skeleton__rows { display: flex; flex-direction: column; gap: 10px; }
.skeleton__row { display: flex; align-items: center; gap: var(--s-5); }
.skeleton__row > .skeleton__bar { width: 200px; height: 16px; flex: none; }
.skeleton__cells { display: flex; gap: 10px; }
.skeleton__cells i { width: 20px; height: 20px; border-radius: 6px; }
@keyframes skeleton-sweep { from { background-position: -100vw 0, 0 0; } to { background-position: 100vw 0, 0 0; } }

/* ---------------- Responsive shell ---------------- */
@media (max-width: 1180px) {
  .appbar__date { display: none; }
  .appbar__search { min-width: 0; }
}
@media (max-width: 960px) {
  .appbar { position: relative; height: 56px; }
  .appbar__org, .appbar__sep { display: none; }
  .appbar__search span, .appbar__search .kbd { display: none; }
  .appbar__search { width: 38px; height: 38px; padding: 0; justify-content: center; }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  body.authenticated { padding-left: 0; }
  .sidebar {
    position: sticky; top: 0;
    width: auto; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 10px 16px 0;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar__top { flex: 1; padding: 0; }
  .wordmark { flex-direction: row; align-items: center; }
  .wordmark__logo { --logo-h: 28px; }
  .wordmark__sub { display: none; }
  .sidebar__bottom { flex-direction: row; align-items: center; gap: 8px; }
  .sidebar__quick, .palette__name, .user-pill__who, .sidebar__label { display: none; }
  .palette { grid-template-columns: repeat(3, 1fr); }
  .palette__sw { width: 30px; height: 28px; }
  .topbar__user { width: auto; padding: 0; border: 0; }
  .tabs { order: 3; flex-basis: 100%; min-width: 0; margin: 4px -16px 0; }   /* min-width: the tab strip scrolls instead of widening the page */
  .tabs__list { flex-direction: row; gap: 4px; overflow-x: auto; padding: 4px 16px 10px; scrollbar-width: none; }
  .tabs__list::-webkit-scrollbar { display: none; }
  .tab { height: 38px; padding: 0 14px; white-space: nowrap; }
  .tab__icon { width: 18px; height: 18px; }
  .tabs__indicator::before { left: 50%; top: auto; bottom: -11px; width: 18px; height: 3px; margin: 0 0 0 -9px; border-radius: 3px 3px 0 0; }
  .form__row { grid-template-columns: 1fr; }
  .modal { padding: 0; place-items: end stretch; }
  .modal__panel { width: 100%; max-height: 92vh; border-radius: 24px 24px 0 0; }
  .modal:not([hidden]) .modal__panel { animation: sheet-in 520ms var(--ease-rise); }
  @keyframes sheet-in { from { transform: translateY(40%); opacity: 0; } }
  .modal__panel.is-cmdk { margin-top: 0; align-self: end; }
  .appbar__record span { display: none; }
  .appbar__record { width: 38px; padding: 0; }
  .skeleton__tiles { grid-template-columns: 1fr 1fr; }
  .toasts { right: 16px; bottom: 16px; }
}
