/* Arpan — design system. White surfaces, deep navy structure, subtle gold accent. */
:root {
  --navy-950: #071330;
  --navy-900: #0b1d40;
  --navy-800: #13295a;
  --navy-700: #1d3a77;
  --navy-600: #2d4f94;
  --navy-200: #c7d3ea;
  --navy-100: #e3e9f5;
  --navy-50: #f1f4fa;
  --gold-700: #7d5f1c;
  --gold-600: #96752a;
  --gold-500: #b8923f;
  --gold-300: #dcc48c;
  --gold-100: #f6efdd;
  --gold-50: #fbf8ef;

  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --line: #e2e6ee;
  --line-strong: #cdd4e0;
  --ink: #0d1a33;
  --ink-2: #3f4b62;
  --ink-3: #5d6880;

  --ok: #1b7046;  --ok-bg: #e6f3ec;  --ok-line: #b9dcc8;
  --warn: #8a5300; --warn-bg: #fcf1df; --warn-line: #efd3a4;
  --err: #b0261b; --err-bg: #fcebe9; --err-line: #f1c2bd;

  --morning: var(--gold-700); --morning-bg: var(--gold-100);
  --evening: var(--navy-700); --evening-bg: var(--navy-100);

  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(11, 29, 64, .06), 0 1px 1px rgba(11, 29, 64, .04);
  --shadow-2: 0 6px 18px -6px rgba(11, 29, 64, .16), 0 2px 4px rgba(11, 29, 64, .05);
  --shadow-3: 0 24px 48px -16px rgba(7, 19, 48, .32);

  --font: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-brand: 'Fraunces', Georgia, serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --sidebar: 252px;
  --topbar: 56px;
  --tabbar: 64px;
  --demobar: 0px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* .field and friends set display, which would otherwise beat the hidden attribute */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font); font-feature-settings: 'tnum' 0;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--gold-300); color: var(--navy-950); }
a { color: var(--navy-700); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; color: var(--ink); }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.125rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
.num, td.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.xs { font-size: .8125rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-lg { width: 26px; height: 26px; }
.i-sm { width: 16px; height: 16px; }
* { scrollbar-color: var(--line-strong) transparent; }

/* ---------- App shell ---------- */
.shell { min-height: calc(100dvh - var(--demobar)); }
.sidebar { display: none; }
.topbar {
  position: sticky; top: var(--demobar); z-index: 30; height: var(--topbar);
  display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px;
  background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.0625rem; font-weight: 650; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand-mini { font-family: var(--font-brand); font-weight: 600; color: var(--navy-900); font-size: 1.0625rem; flex: 1; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink-2); flex: none;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--navy-50); color: var(--navy-900); }
.main { padding: 16px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom)); max-width: 1240px; margin: 0 auto; }
.page-head { margin-bottom: 14px; }
/* Phones/tablets: the top bar shows the title and Back, so only the subtitle and every action button stay here. */
.page-head h1, .page-head .crumb { display: none; }
.page-head p { color: var(--ink-3); font-size: .875rem; margin-bottom: 8px; }
.page-head > .row-wrap { gap: 8px; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); text-decoration: none; font-size: .75rem; font-weight: 600; background: none; border: 0; min-height: 44px;
}
.tab[aria-current='page'] { color: var(--navy-900); }
.tab[aria-current='page'] .i { stroke-width: 2.1; }
.tab-primary .tab-orb {
  width: 48px; height: 48px; margin-top: -18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy-900); color: #fff; box-shadow: 0 0 0 4px var(--surface), var(--shadow-2);
}
.tab-primary .tab-orb .i { width: 24px; height: 24px; }
.tab-primary { color: var(--navy-900); }

@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: var(--sidebar) 1fr; }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: var(--demobar); height: calc(100dvh - var(--demobar));
    background: var(--navy-900); color: var(--navy-100); padding: 20px 14px; overflow-y: auto;
  }
  .brand { padding: 4px 10px 20px; border-bottom: 1px solid rgba(255, 255, 255, .08); margin-bottom: 14px; }
  .brand-name { font-family: var(--font-brand); font-size: 1.3rem; font-weight: 600; color: #fff; letter-spacing: -.01em; }
  .brand-name span { color: var(--gold-300); }
  .brand-sub { font-size: .8125rem; color: var(--navy-200); }
  .nav-group { display: grid; gap: 2px; margin-bottom: 16px; }
  .nav-label { font-size: .75rem; color: #9fb0d3; padding: 8px 10px 4px; font-weight: 600; }
  .nav-link {
    display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; color: #d5ddef; text-decoration: none; font-weight: 500;
    transition: background-color .15s var(--ease), color .15s var(--ease);
  }
  .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
  .nav-link[aria-current='page'] { background: rgba(220, 196, 140, .14); color: #fff; box-shadow: inset 0 0 0 1px rgba(220, 196, 140, .25); }
  .nav-link[aria-current='page'] .i { color: var(--gold-300); }
  .nav-cta { background: var(--gold-500); color: var(--navy-950); font-weight: 650; margin-bottom: 6px; }
  .nav-cta:hover { background: var(--gold-300); color: var(--navy-950); }
  .nav-cta .i { color: var(--navy-950) !important; }
  .side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; gap: 10px; }
  .side-foot .who { flex: 1; min-width: 0; }
  .side-foot .who-name { color: #fff; font-weight: 600; font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-foot .who-role { font-size: .8125rem; color: var(--gold-300); }
  .side-foot .icon-btn { color: var(--navy-200); }
  .side-foot .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
  .main { padding: 28px 36px 56px; }
  .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
  .page-head h1 { font-size: 1.625rem; }
  .page-head h1 { display: block; }
  .page-head .crumb { display: inline-flex; }
  .page-head p { color: var(--ink-3); margin-top: 4px; font-size: inherit; margin-bottom: 0; }
  .crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); text-decoration: none; font-size: .875rem; margin-bottom: 6px; }
  .crumb:hover { color: var(--navy-800); }
}

/* ---------- Primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-pad { padding: 16px; }
@media (min-width: 768px) { .card-pad { padding: 20px; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 1rem; }
.card-head a { font-size: .875rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.card-head a:hover { text-decoration: underline; }
.stack { display: grid; gap: 16px; }
.stack-lg { display: grid; gap: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2, .grid-3 { display: grid; gap: 16px; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.section-title { font-size: .9375rem; font-weight: 650; color: var(--ink-2); margin: 8px 0 -4px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: .9375rem; text-decoration: none; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--navy-900); color: #fff; box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--navy-800); }
.btn-gold { background: var(--gold-500); color: var(--navy-950); }
.btn-gold:hover { background: #c9a453; }
.btn-secondary { background: var(--surface); color: var(--navy-900); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--navy-600); background: var(--navy-50); }
.btn-ghost { background: transparent; color: var(--navy-800); }
.btn-ghost:hover { background: var(--navy-50); }
.btn-danger { background: var(--surface); color: var(--err); border-color: var(--err-line); }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn .spinner { width: 16px; height: 16px; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: .8125rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.badge .i { width: 14px; height: 14px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge-err { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.badge-neutral { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.badge-morning { background: var(--morning-bg); color: var(--morning); border-color: #ead9b0; }
.badge-evening { background: var(--evening-bg); color: var(--evening); border-color: var(--navy-200); }
.badge-gold { background: var(--gold-50); color: var(--gold-700); border-color: var(--gold-300); }
.badge-dim { background: transparent; color: var(--ink-3); border-color: var(--line); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--navy-100); color: var(--navy-800); font-weight: 700; font-size: .875rem; letter-spacing: .02em;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.25rem; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-btn { position: relative; flex: none; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.avatar-btn:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.avatar-cam { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-900); color: #fff; border: 2px solid var(--surface); }
.avatar.inactive { background: #eceef2; color: var(--ink-3); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 600; font-size: .9375rem; color: var(--ink); }
.field .hint { font-size: .8125rem; color: var(--ink-3); }
.field .error { font-size: .875rem; color: var(--err); display: flex; gap: 6px; align-items: flex-start; }
.field .error .i { width: 16px; height: 16px; margin-top: 2px; }
.input, .select {
  width: 100%; min-width: 0; min-height: 48px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 1rem; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder { color: #737d92; }
.input:hover, .select:hover { border-color: #aab4c6; }
.input:focus, .select:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(45, 79, 148, .16); }
.input[aria-invalid='true'] { border-color: var(--err); box-shadow: 0 0 0 3px rgba(176, 38, 27, .1); }
.input:disabled { background: var(--surface-2); color: var(--ink-3); }
.input-icon { position: relative; }
.input-icon > .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-icon .input { padding-left: 44px; }
.input-icon .clear { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6880' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.prefix-input { display: flex; align-items: stretch; }
.prefix-input .prefix { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-right: 0; border-radius: 10px 0 0 10px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; }
.prefix-input .input { border-radius: 0 10px 10px 0; }
.form-grid { display: grid; gap: 18px; }
@media (min-width: 768px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: 1 / -1; } }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background-color .2s var(--ease); pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--navy-800); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold-500); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; background: var(--navy-50); border: 1px solid var(--line); border-radius: 11px; gap: 2px; max-width: 100%; overflow-x: auto; }
.segmented button, .segmented a {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: .9375rem;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
}
.segmented [aria-pressed='true'], .segmented [aria-current='page'] { background: var(--surface); color: var(--navy-900); box-shadow: var(--shadow-1); }

/* ---------- Notices ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid; font-size: .9375rem; }
.notice .i { margin-top: 1px; }
.notice-info { background: var(--navy-50); border-color: var(--navy-100); color: var(--navy-800); }
.notice-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.notice-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.notice-err { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.notice strong { display: block; color: inherit; }
.notice p { color: var(--ink-2); }
.sim-tag { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 700; color: var(--gold-700); background: var(--gold-50); border: 1px dashed var(--gold-300); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); display: grid; justify-items: center; gap: 8px; }
.empty .i { width: 32px; height: 32px; color: var(--navy-200); }
.empty h3 { color: var(--ink); }
.skeleton { background: linear-gradient(90deg, #eef1f6 0%, #f6f8fb 50%, #eef1f6 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.stat { padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.stat:nth-child(2n) { border-right: 0; }
.stat:nth-last-child(-n+2) { border-bottom: 0; }
.stat-label { font-size: .8125rem; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat-label .i { width: 15px; height: 15px; }
.stat-value { font-size: 1.625rem; font-weight: 700; color: var(--navy-900); font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.stat-sub { font-size: .8125rem; color: var(--ink-3); }
@media (min-width: 768px) {
  .stats.four { grid-template-columns: repeat(4, 1fr); }
  .stats.four .stat { border-bottom: 0; }
  .stats.four .stat:nth-child(2n) { border-right: 1px solid var(--line); }
  .stats.four .stat:last-child { border-right: 0; }
  .stats.three { grid-template-columns: repeat(3, 1fr); }
  .stats.three .stat { border-bottom: 0; border-right: 1px solid var(--line); }
  .stats.three .stat:last-child { border-right: 0; }
  .stats.six { grid-template-columns: repeat(3, 1fr); }
  .stats.six .stat { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .stats.six .stat:nth-child(3n) { border-right: 0; }
  .stats.six .stat:nth-last-child(-n+3) { border-bottom: 0; }
}
@media (max-width: 767px) { .stats.three { grid-template-columns: repeat(3, 1fr); } .stats.three .stat { border-bottom: 0; } .stats.three .stat:nth-child(2n) { border-right: 1px solid var(--line); } .stats.three .stat:last-child { border-right: 0; } .stats.three .stat-value { font-size: 1.375rem; } }
@media (min-width: 1100px) { .stats.six { grid-template-columns: repeat(6, 1fr); } .stats.six .stat { border-bottom: 0; } .stats.six .stat:nth-child(3n) { border-right: 1px solid var(--line); } .stats.six .stat:last-child { border-right: 0; } }

/* ---------- Dashboard ---------- */
.action-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action {
  display: flex; flex-direction: column; justify-content: space-between; gap: 18px; min-height: 120px; padding: 16px;
  border-radius: var(--r-lg); text-decoration: none; border: 1px solid var(--line); background: var(--surface); color: var(--navy-900); box-shadow: var(--shadow-1);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.action:hover { box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.action:active { transform: scale(.985); }
.action .i { width: 28px; height: 28px; }
.action-title { font-size: 1.125rem; font-weight: 700; }
.action-sub { font-size: .875rem; color: var(--ink-3); }
.action-main { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.action-main .action-sub { color: var(--navy-200); }
.action-main .i { color: var(--gold-300); }
.action-main:hover { background: var(--navy-800); }
@media (min-width: 768px) { .action { flex-direction: row; align-items: center; justify-content: flex-start; min-height: 96px; padding: 20px 22px; } .action .i { width: 32px; height: 32px; } }

.dash { display: grid; gap: 16px; }
@media (min-width: 1100px) { .dash { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; } .dash .full { grid-column: 1 / -1; } }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 64px; text-decoration: none; color: inherit; }
a.item, button.item { transition: background-color .15s var(--ease); width: 100%; border: 0; background: none; text-align: left; }
a.item:hover, button.item:hover { background: var(--surface-2); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: .875rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-end { display: flex; align-items: center; gap: 6px; flex: none; color: var(--ink-3); }
.item .chev { color: var(--line-strong); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-morning { background: var(--gold-500); }
.dot-evening { background: var(--navy-600); }

/* ---------- Tables (become cards under 768px) ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-size: .8125rem; font-weight: 650; color: var(--ink-3); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; transition: background-color .15s var(--ease); }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table .num { text-align: right; }
.table th.num { text-align: right; }
.cell-member { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-member .avatar { width: 34px; height: 34px; font-size: .75rem; }
.cell-member a { color: var(--ink); font-weight: 600; text-decoration: none; }
.cell-member a:hover { text-decoration: underline; }
@media (max-width: 767px) {
  table.table.responsive thead { display: none; }
  table.table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.responsive tbody tr:last-child { border-bottom: 0; }
  .table.responsive td { padding: 3px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--ink-3); font-size: .875rem; font-weight: 600; text-align: left; flex: none; }
  .table.responsive td.lead { padding-bottom: 6px; text-align: left; }
  .table.responsive td.lead::before { display: none; }
  .table.responsive .num { text-align: right; }
}

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: .875rem; color: var(--ink-3); flex-wrap: wrap; }
.pager .row { gap: 6px; }

.toolbar { display: grid; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
@media (min-width: 768px) { .toolbar { grid-template-columns: minmax(220px, 1fr) auto; align-items: center; } }
.toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .filters .select, .toolbar .filters .input { min-height: 44px; width: auto; }
.toolbar .filters input[type='date'] { min-width: 150px; }

/* ---------- Scanner ---------- */
.scanner-layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .scanner-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.viewfinder {
  position: relative; aspect-ratio: 1 / 1; max-height: 52vh; width: 100%; border-radius: var(--r-lg); overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #1d2c4f 0%, #0a1430 70%); display: grid; place-items: center; color: #c7d3ea;
}
@media (min-width: 900px) { .viewfinder { max-height: none; } }
.vf-frame { position: relative; width: 62%; aspect-ratio: 1; }
.vf-frame i { position: absolute; width: 28%; height: 28%; border: 3px solid var(--gold-300); }
.vf-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.vf-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.vf-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.vf-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.vf-line { position: absolute; left: 6%; right: 6%; height: 2px; top: 10%; background: linear-gradient(90deg, transparent, var(--gold-300), transparent); animation: scanline 2.4s var(--ease) infinite alternate; }
@keyframes scanline { to { top: 88%; } }
.vf-status { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: rgba(7, 19, 48, .78); color: #fff; font-size: .9375rem; text-align: center; }
.vf-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.vf-top .sim-tag { background: rgba(251, 248, 239, .95); }
.vf-busy .vf-line { animation-duration: .6s; }
.vf-error .vf-frame i { border-color: #f1a49c; }
/* ---------- Attendance confirmation ---------- */
.identity { display: flex; gap: 14px; align-items: center; }
.identity h2 { font-size: 1.375rem; }
.identity-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); font-size: .9375rem; margin-top: 4px; }
.identity-meta span { display: inline-flex; gap: 6px; align-items: center; }
.identity-meta .i { width: 16px; height: 16px; color: var(--ink-3); }
.verify-note { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--gold-50); border: 1px solid var(--gold-100); color: var(--gold-700); font-size: .875rem; }
.verify-note .i { width: 18px; height: 18px; }
.sessions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.session-btn {
  position: relative; display: grid; gap: 10px; align-content: start; text-align: left; padding: 16px; min-height: 148px;
  border-radius: var(--r-lg); border: 1.5px solid var(--line-strong); background: var(--surface);
  transition: border-color .15s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease), transform .1s var(--ease);
}
.session-btn:hover:not(:disabled) { border-color: var(--navy-700); box-shadow: var(--shadow-2); }
.session-btn:active:not(:disabled) { transform: scale(.985); }
.session-btn .s-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.session-btn.morning .s-icon { background: var(--morning-bg); color: var(--morning); }
.session-btn.evening .s-icon { background: var(--evening-bg); color: var(--evening); }
.s-name { font-size: 1.125rem; font-weight: 700; color: var(--ink); }
.s-state { font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.session-btn.available .s-state { color: var(--navy-700); }
.session-btn.available::after { content: 'Tap to record'; font-size: .8125rem; color: var(--ink-3); }
.session-btn.done { background: var(--surface-2); border-style: solid; border-color: var(--line); cursor: not-allowed; }
.session-btn.done .s-state { color: var(--ok); display: flex; gap: 6px; align-items: center; }
.session-btn.done .s-state .i { width: 16px; height: 16px; }
.session-btn.just-done { border-color: var(--ok-line); background: var(--ok-bg); }
.session-btn .s-detail { font-size: .8125rem; color: var(--ink-3); }
.session-btn.busy { cursor: progress; }
.session-btn .s-busy { position: absolute; top: 16px; right: 16px; color: var(--navy-700); }
.result { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); border: 1px solid; animation: rise .32s var(--ease) both; }
.result .i { width: 24px; height: 24px; flex: none; }
.result strong { display: block; font-size: 1.0625rem; }
.result-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.result-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.result-err { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.result p { color: var(--ink-2); font-size: .9375rem; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Leaderboards ---------- */
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 56px; }
.lb li:last-child { border-bottom: 0; }
.lb .rank { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .875rem; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.lb .rank.r1 { background: var(--gold-500); color: var(--navy-950); border-color: var(--gold-500); }
.lb .rank.r2 { background: var(--gold-100); color: var(--gold-700); border-color: var(--gold-300); }
.lb .rank.r3 { background: var(--gold-50); color: var(--gold-700); border-color: var(--gold-100); }
.lb .who { min-width: 0; }
.lb .who a { color: var(--ink); font-weight: 600; text-decoration: none; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb .who a:hover { text-decoration: underline; }
.lb .who span { font-size: .8125rem; color: var(--ink-3); }
.lb .score { text-align: right; font-variant-numeric: tabular-nums; }
.lb .score strong { font-size: 1.125rem; color: var(--navy-900); display: block; line-height: 1.1; }
.lb .score span { font-size: .75rem; color: var(--ink-3); }
.lb .tie { font-size: .6875rem; color: var(--gold-700); font-weight: 700; display: block; text-align: center; }
.lb-preview .lb li { padding: 8px 16px; min-height: 52px; }
.rule { font-size: .875rem; color: var(--ink-3); padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .bar-m { fill: var(--gold-500); }
.chart .bar-e { fill: var(--navy-700); }
.chart .line { fill: none; stroke: var(--navy-700); stroke-width: 2.25; stroke-linejoin: round; }
.chart .area { fill: rgba(45, 79, 148, .09); }
.chart .pt { fill: var(--surface); stroke: var(--navy-700); stroke-width: 2; }
.legend { display: flex; gap: 16px; font-size: .875rem; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Profile / QR ---------- */
.profile-grid { display: grid; gap: 16px; }
@media (min-width: 1024px) { .profile-grid { grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); align-items: start; } }
.dl { display: grid; grid-template-columns: 1fr; margin: 0; }
.dl > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--ink-3); font-weight: 600; font-size: .9375rem; }
.dl dd { margin: 0; text-align: right; font-weight: 500; display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.qr-card { text-align: center; display: grid; justify-items: center; gap: 12px; }
.qr-box { width: 208px; max-width: 100%; aspect-ratio: 1; padding: 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-token { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .8125rem; color: var(--ink-3); word-break: break-all; }
.qr-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* Printable member card */
.member-card { width: 100%; max-width: 340px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-2); text-align: left; }
.member-card .mc-head { background: var(--navy-900); color: #fff; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.member-card .mc-head b { font-family: var(--font-brand); font-weight: 600; font-size: 1.05rem; }
.member-card .mc-head b span { color: var(--gold-300); }
.member-card .mc-head small { color: var(--gold-300); font-size: .75rem; }
.member-card .mc-body { display: flex; gap: 14px; padding: 16px; align-items: center; }
.member-card .mc-qr { width: 120px; flex: none; }
.member-card .mc-name { font-weight: 700; font-size: 1.0625rem; line-height: 1.25; }
.member-card .mc-no { color: var(--ink-3); font-size: .875rem; font-variant-numeric: tabular-nums; }
.member-card.mc-atm { width: min(85.6mm, 100%); aspect-ratio: 85.6 / 53.98; container-type: inline-size; display: flex; flex-direction: column; border-radius: 3.2mm; }
.mc-atm .mc-body { flex: 1; min-height: 0; padding: 3.5cqw 4.5cqw; gap: 4cqw; align-items: stretch; justify-content: space-between; }
.mc-atm .mc-qr { width: auto; height: 100%; aspect-ratio: 1; }
.mc-atm .mc-qr svg { width: 100%; height: 100%; display: block; }
.mc-atm .mc-photo { height: 100%; aspect-ratio: 3 / 4; border-radius: 2.5cqw; overflow: hidden; background: var(--navy-100); color: var(--navy-800); display: grid; place-items: center; border: 1px solid var(--line); }
.mc-atm .mc-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mc-atm .mc-info { border-top: max(2px, .9cqw) solid var(--gold-500); padding: 2.2cqw 4.5cqw 2.6cqw; display: flex; align-items: center; justify-content: space-between; gap: 3cqw; }
.mc-atm .mc-who { min-width: 0; display: grid; gap: .6cqw; }
.mc-atm .mc-name { font-size: 5.6cqw; font-weight: 700; line-height: 1.2; color: var(--ink); }
.mc-atm .mc-name.mc-long { font-size: 4.6cqw; }
.mc-atm .mc-name.mc-xlong { font-size: 3.8cqw; }
.mc-atm .mc-no { color: var(--navy-800); font-size: 3.4cqw; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mc-atm .mc-mobile { flex: none; white-space: nowrap; font-size: 3.8cqw; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.member-card .mc-foot { border-top: 3px solid var(--gold-500); padding: 8px 16px; font-size: .75rem; color: var(--ink-3); }

/* ---------- Login ---------- */
.login { min-height: calc(100dvh - var(--demobar)); display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(90% 60% at 50% 0%, var(--navy-50), var(--bg)); }
.login-card { width: 100%; max-width: 460px; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-logo { display: block; width: min(100%, 320px); height: auto; margin: 0 auto 4px; }
.brand-logo { display: block; width: 100%; max-width: 210px; height: auto; }
.topbar-logo { display: block; height: 38px; width: auto; }
.page-logo { display: block; width: min(64%, 220px); height: auto; margin: 0 auto 14px; }
.member-card .mc-head .mc-logo { display: block; height: 30px; width: auto; }
.login-mark { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: var(--navy-900); display: grid; place-items: center; color: var(--gold-300); box-shadow: var(--shadow-2); }
.login-mark .i { width: 30px; height: 30px; }
.login-brand h1 { font-family: var(--font-brand); font-weight: 600; font-size: 1.75rem; color: var(--navy-900); }
.login-brand h1 span { color: var(--gold-600); }
.role-opt { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1.5px solid var(--line-strong); border-radius: var(--r-lg); cursor: pointer; background: var(--surface); transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.role-opt:hover { border-color: var(--navy-600); }
.role-opt:has(input:checked) { border-color: var(--navy-800); background: var(--navy-50); box-shadow: 0 0 0 3px rgba(45, 79, 148, .12); }
.role-opt input { margin-top: 4px; accent-color: var(--navy-800); width: 18px; height: 18px; flex: none; }
.role-opt strong { display: block; }
.role-opt span { font-size: .875rem; color: var(--ink-3); }

/* ---------- Overlays ---------- */
dialog { border: 0; padding: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-3); max-width: min(480px, calc(100vw - 32px)); width: 100%; color: var(--ink); }
dialog::backdrop { background: rgba(7, 19, 48, .45); }
dialog[open] { animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg-body { padding: 20px; display: grid; gap: 12px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 20px; flex-wrap: wrap; }
dialog.sheet { margin: auto 0 0; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
dialog.sheet[open] { animation: slideup .26s var(--ease); }
@keyframes slideup { from { transform: translateY(24px); opacity: .6; } }
.sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 10px auto 4px; }
.sheet .list .item { min-height: 56px; }

.toasts { position: fixed; z-index: 60; left: 16px; right: 16px; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
@media (min-width: 1024px) { .toasts { left: auto; right: 24px; bottom: 24px; justify-items: end; } }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; max-width: 420px; padding: 12px 14px; border-radius: 12px; background: var(--navy-950); color: #fff; box-shadow: var(--shadow-3); font-size: .9375rem; animation: rise .25s var(--ease); }
.toast .i { color: var(--gold-300); }
.toast.err .i { color: #f6a39a; }

/* ---------- Misc ---------- */
.kv-inline { display: flex; gap: 16px; flex-wrap: wrap; font-size: .875rem; color: var(--ink-3); }
.kv-inline b { color: var(--ink); font-variant-numeric: tabular-nums; }
.formula { font-size: .875rem; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 6px; }
.formula code { font-family: inherit; font-weight: 600; color: var(--navy-800); }
.blocked { max-width: 520px; margin: 40px auto; text-align: center; display: grid; gap: 12px; justify-items: center; }
.blocked .i { width: 40px; height: 40px; color: var(--navy-600); }
.hide-sm { display: none; }
@media (min-width: 1024px) { .hide-sm { display: revert; } .show-sm { display: none !important; } }
.only-desktop { display: none; }
@media (min-width: 1024px) { .only-desktop { display: revert; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .vf-line { display: none; }
}

@media print {
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: grid !important; gap: 16px; padding: 0; }
  .member-card { width: 340px; box-shadow: none; break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .member-card.mc-atm { width: 85.6mm; height: 53.98mm; } /* real ATM-card size */
}
#print-root { display: none; }

/* Grid/flex children may shrink below their content width (prevents phone-width overflow). */
.stack > *, .stack-lg > *, .grid-2 > *, .grid-3 > *, .dash > *, .profile-grid > *, .scanner-layout > *, .action-pair > *, .sessions > * { min-width: 0; }
.action > div, .identity > div, .row > div, .spread > div, .toggle-row > div { min-width: 0; overflow-wrap: anywhere; }
.action-pair, .sessions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-head h2 { white-space: nowrap; }
@media (max-width: 767px) {
  .table.responsive.compact tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; }
  .table.responsive.compact td.lead { grid-column: 1 / -1; }
}

/* ---------- Production additions ---------- */
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewfinder .vf-frame, .viewfinder .vf-line, .viewfinder .vf-status, .viewfinder .vf-top { z-index: 1; }
.pw-field { position: relative; }
.pw-field .input { padding-right: 52px; }
.pw-field .pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; }
.secret-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border: 1px dashed var(--gold-300); background: var(--gold-50); border-radius: var(--r); }
.secret-box code { font: 600 1.0625rem/1.4 ui-monospace, Menlo, monospace; color: var(--navy-900); word-break: break-all; flex: 1 1 200px; }
.admin-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-top: 1px solid var(--line); }
.admin-row:first-child { border-top: 0; }
.admin-row .item-main { flex: 1 1 200px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.vf-tool { cursor: pointer; min-height: 32px; }
.member-li { display: flex; align-items: center; }
.member-li > .item { flex: 1; min-width: 0; }
.member-li > .icon-btn { flex: none; margin-right: 8px; color: var(--err); }
td.act { width: 56px; text-align: right; }
td.act .icon-btn { color: var(--err); }
/* Loading: while a screen refreshes (filter, page), the old content dims after a short delay instead of flickering. */
#main[aria-busy="true"] > *:not(.sk) { opacity: .55; transition: opacity .15s ease .12s; }
/* First paint before the scripts run: a neutral app-shell placeholder. */
.boot-sk { min-height: 100dvh; display: grid; grid-template-rows: var(--topbar) 1fr; }
.boot-sk .boot-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.boot-sk .boot-side { display: none; }
.boot-sk .boot-main { padding: 24px 16px; width: 100%; max-width: 1240px; margin: 0 auto; display: grid; gap: 16px; align-content: start; }
.boot-sk .boot-block { height: 120px; border-radius: var(--r-lg); }
@media (min-width: 1024px) {
  .boot-sk { grid-template-columns: var(--sidebar) 1fr; grid-template-rows: 1fr; }
  .boot-sk .boot-top { display: none; }
  .boot-sk .boot-side { display: block; background: var(--navy-900); }
  .boot-sk .boot-main { padding: 32px; }
}

/* ---------- Member picker (families, programs) ---------- */
.pick-list { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.pick-list button.item:disabled { cursor: default; opacity: .7; }
.pick-list button.item:disabled:hover { background: none; }
/* Number, age and mobile tell same-name members apart, so never cut them off. */
.pick-list .item-sub, .list-wrap .item-sub { white-space: normal; }
/* Rows with buttons: the name keeps at least 200px; the buttons drop below it on a phone instead of squeezing it. */
.list-wrap .item-main { flex: 1 1 200px; }

/* ---------- Housie ---------- */
.hs-qr { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; width: min(100%, 260px); margin: 0 auto; }
.hs-qr svg { display: block; width: 100%; height: auto; }
.hs-board { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
@media (min-width: 600px) { .hs-board { gap: 6px; } }
/* The running game is two screens (owner, 2026-12-03): the live board fills the first, players and winners the second. */
.hs-page { display: grid; gap: 16px; align-content: start; min-height: calc(100dvh - var(--topbar) - var(--tabbar) - 40px); }
.hs-page + .hs-page { padding-top: 16px; scroll-margin-top: calc(var(--topbar) + 8px); }
.hs-live { display: grid; gap: 16px; align-items: start; }
.hs-side { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.hs-side .hs-qr { width: 100%; padding: 4px; }
.hs-now {
  min-width: 72px; height: 72px; padding: 0 14px; border-radius: 20px; display: grid; place-items: center; flex: none;
  background: var(--gold-500); color: var(--navy-950); font-size: 2.5rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.hs-down { justify-self: center; display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--ink-3); font: inherit; font-size: .875rem; padding: 8px 12px; border-radius: 999px; cursor: pointer; }
.hs-down:hover { background: var(--navy-50); color: var(--navy-800); }
@media (min-width: 900px) {
  .hs-live { grid-template-columns: minmax(0, 1fr) 280px; }
  .hs-side { grid-template-columns: 1fr; }
  .hs-side .hs-qr { width: min(100%, 220px); padding: 8px; }
  /* The board is sized by the screen height so the whole first screen fits without scrolling. */
  .hs-board-card .hs-board { width: min(100%, calc((100dvh - 490px) * 10 / 9)); margin: 0 auto; }
  .hs-now { min-width: 96px; height: 96px; font-size: 3.5rem; border-radius: 24px; }
}
@media (min-width: 1024px) { .hs-page { min-height: calc(100dvh - 150px); } }
.hs-num {
  aspect-ratio: 1; min-width: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  color: var(--navy-900); font-weight: 650; font-size: clamp(.8125rem, 2.6vw, 1.0625rem); font-variant-numeric: tabular-nums; padding: 0;
  transition: background .15s var(--ease), transform .1s var(--ease);
}
.hs-num:hover:not(:disabled) { background: var(--navy-50); border-color: var(--navy-600); }
.hs-num:active:not(:disabled) { transform: scale(.94); }
.hs-num[aria-pressed='true'] { background: var(--navy-900); border-color: var(--navy-900); color: #fff; text-decoration: line-through; text-decoration-color: var(--gold-300); cursor: default; }
.hs-last {
  min-width: 56px; height: 56px; padding: 0 10px; border-radius: 28px; display: grid; place-items: center; flex: none;
  background: var(--gold-500); color: var(--navy-950); font-size: 1.625rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.hs-play { min-height: 100dvh; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.hs-wrap { max-width: 560px; margin: 0 auto; display: grid; gap: 16px; }
.hs-head { display: flex; align-items: center; gap: 12px; }
.hs-head > div:not(.hs-last) { flex: 1; }
.hs-head p { margin: 0; }
.hs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--gold-100); color: var(--gold-700); flex: none; }
.hs-ticket {
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; padding: 6px; border-radius: var(--r);
  background: var(--navy-900); box-shadow: var(--shadow-2);
}
.hs-cell {
  aspect-ratio: 1 / 1.15; display: grid; place-items: center; border-radius: 6px; background: #fff; position: relative;
  color: var(--navy-900); font-weight: 700; font-size: clamp(.9375rem, 4.6vw, 1.375rem); font-variant-numeric: tabular-nums;
}
button.hs-cell { border: 0; padding: 0; font-family: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button.hs-cell:active:not(:disabled) { transform: scale(.94); }
button.hs-cell:disabled { cursor: default; }
.hs-cell.blank { background: var(--navy-800); }
.hs-cell.hit { background: var(--gold-100); color: var(--ink-3); }
.hs-cell.hit::after { content: ''; position: absolute; inset: 18%; border-radius: 50%; border: 3px solid var(--err); opacity: .85; }
.hs-called { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.hs-called span { flex: none; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 18px; display: grid; place-items: center; background: var(--navy-50); color: var(--navy-900); font-weight: 650; font-variant-numeric: tabular-nums; }
.hs-called span.now { background: var(--gold-500); color: var(--navy-950); }
.hs-won { animation: hs-pop .4s var(--ease); }
@keyframes hs-pop { from { transform: scale(.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hs-won { animation: none; } .hs-num { transition: none; } }
.hs-past { border-top: 1px solid var(--line); }
.hs-past:first-child { border-top: 0; }
.hs-past > summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; }
.hs-past > summary::-webkit-details-marker { display: none; }
.hs-past > summary:hover { background: var(--surface-2); }
.hs-past[open] > summary { background: var(--surface-2); border-bottom: 1px solid var(--line); }
.hs-past .list { background: var(--surface); }

/* ---------- Points bars (Housie board, projector) ---------- */
.pbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pbars li { display: grid; grid-template-columns: 2ch minmax(0, 11rem) 1fr 4.5ch; align-items: center; gap: 10px; font-size: .9375rem; }
.pb-rank { color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: right; }
.pb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pb-name small { font-weight: 400; color: var(--ink-3); }
.pb-track { height: 14px; border-radius: 999px; background: var(--navy-50); overflow: hidden; }
.pb-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--navy-700), var(--gold-500)); transition: width .4s var(--ease); }
.pb-val { text-align: right; }
@media (max-width: 480px) { .pbars li { grid-template-columns: 2ch minmax(0, 7.5rem) 1fr 4ch; gap: 8px; font-size: .875rem; } }
@media (prefers-reduced-motion: reduce) { .pb-fill { transition: none; } }

/* ---------- Projector view (2026-12-03: number, full 1–90 chart, winners, points; fits one screen) ---------- */
dialog.proj-dlg, dialog.qr-dlg { max-width: 100vw; width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
dialog.proj-dlg { background: var(--navy-950); color: #fff; }
dialog.qr-dlg { background: #fff; }
.proj { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; padding: clamp(12px, 2.4vw, 32px); gap: clamp(12px, 2vw, 24px); }
.proj-head { display: flex; align-items: center; gap: clamp(12px, 2vw, 24px); }
.proj-head > div:first-child { flex: 1; min-width: 0; }
.proj-head h2 { font-family: var(--font-brand); font-size: clamp(1.5rem, 3vw, 2.5rem); color: var(--gold-300); }
.proj-head p { margin: 0; color: var(--navy-200); font-size: clamp(.9375rem, 1.5vw, 1.25rem); }
.proj-last { font-size: clamp(3rem, 8vh, 6.5rem); font-weight: 700; line-height: 1; color: var(--navy-950); background: var(--gold-300); border-radius: 20px; padding: .08em .3em; min-width: 1.6em; text-align: center; font-variant-numeric: tabular-nums; }
.proj-body { display: grid; gap: clamp(12px, 2vw, 32px); min-height: 0; overflow: auto; }
@media (min-width: 900px) { .proj-body { grid-template-columns: minmax(0, 1fr) minmax(280px, 32%); overflow: hidden; } }
.proj-board { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: clamp(3px, .5vw, 8px); align-self: start; justify-self: center;
  width: min(100%, calc((100dvh - clamp(120px, 14vh, 170px) - clamp(24px, 4.8vw, 64px) - 24px) * 10 / 9)); aspect-ratio: 10 / 9; }
.proj-board span { display: grid; place-items: center; border-radius: 8px; background: rgba(255, 255, 255, .06); color: rgba(255, 255, 255, .45);
  font-weight: 700; font-size: clamp(.875rem, min(2.2vw, 3.6vh), 2.25rem); font-variant-numeric: tabular-nums; }
.proj-board span.on { background: var(--gold-300); color: var(--navy-950); }
.proj-board span.now { background: #fff; color: var(--navy-950); box-shadow: 0 0 0 4px var(--gold-500); }
.proj-side { min-height: 0; overflow: auto; display: grid; align-content: start; gap: 12px; }
.proj-side h3 { color: var(--gold-300); font-size: clamp(1.0625rem, 1.6vw, 1.5rem); margin: 0; }
.proj .pbars li { font-size: clamp(.9375rem, 1.3vw, 1.25rem); grid-template-columns: 2.5ch minmax(0, 12rem) 1fr 5ch; }
.proj .pb-track { height: clamp(14px, 1.6vw, 22px); background: rgba(255, 255, 255, .1); }
.proj .pb-rank, .proj .pb-name small, .proj .muted { color: var(--navy-200); }

/* Winners: name left, prize under it, points on the right (manager screen and projector) */
.hs-winlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.hs-winlist li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; background: var(--gold-50); }
.hw-main { flex: 1; min-width: 0; display: grid; }
.hw-main b { overflow-wrap: anywhere; }
.hw-main small { color: var(--ink-3); font-weight: 400; }
.hw-prize { display: inline-flex; align-items: center; gap: 4px; font-size: .875rem; color: var(--gold-700); }
.hw-pts { text-align: right; font-size: 1.125rem; line-height: 1.1; color: var(--navy-900); }
.hw-pts small { display: block; font-size: .75rem; font-weight: 500; color: var(--ink-3); }
.proj-winlist li { background: rgba(255, 255, 255, .08); font-size: clamp(1rem, 1.4vw, 1.375rem); }
.proj-winlist .hw-main small, .proj-winlist .hw-pts small { color: var(--navy-200); }
.proj-winlist .hw-prize { color: var(--gold-300); font-size: .8em; }
.proj-winlist .hw-pts { color: #fff; font-size: 1.2em; }
.hs-wins-card { gap: 8px; display: grid; }
.hs-wins-card h2 { font-size: 1.0625rem; }
@media (min-width: 900px) {
  /* A fixed height keeps the board in place when winners arrive; more than fit scroll inside. */
  .hs-wins { height: 112px; overflow: auto; }
  .hs-wins .hs-winlist { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

/* Full-screen QR code */
.qrfs { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; padding: clamp(10px, 1.6vw, 20px); gap: 8px; }
.qrfs-head { display: flex; align-items: center; gap: 12px; }
.qrfs-head h2 { flex: 1; font-size: clamp(1.25rem, 3vw, 2.25rem); color: var(--navy-900); }
.qrfs-qr { min-height: 0; display: grid; place-items: center; }
.qrfs-qr svg { display: block; height: 100%; width: auto; max-width: 100%; aspect-ratio: 1; }
.qrfs-foot { margin: 0; text-align: center; color: var(--ink-2); font-size: clamp(.9375rem, 1.6vw, 1.25rem); }

/* ---------- Prize points editor, PIN inputs ---------- */
.pts-summary { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--gold-50); color: var(--ink); }
.pts-table { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pts-row { display: grid; grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1.6fr); gap: 8px 16px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.pts-row:first-child { border-top: 0; }
.pts-row > div:first-child { display: grid; gap: 2px; min-width: 0; }
.pts-headrow { background: var(--navy-50); font-size: .75rem; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.pts-inputs { display: flex; flex-wrap: wrap; gap: 8px; }
.pts-in { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 600; color: var(--ink-2); }
.pts-in .input { width: 84px; }
.pts-in span { min-width: 2.2em; text-align: right; }
@media (max-width: 600px) { .pts-inputs { justify-content: flex-end; } }
@media (max-width: 600px) {
  .pts-headrow { display: none; }
  .pts-row { grid-template-columns: 1fr auto; }
  .pts-row > div:first-child { grid-column: 1 / -1; }
}
.pin-input { font-size: 1.5rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; max-width: 12rem; }

/* ---------- Member dashboard (/m) ---------- */
.md-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.md-total { display: grid; justify-items: end; line-height: 1.1; }
.md-total b { font-size: 2.5rem; color: var(--navy-900); }
.md-total span { color: var(--ink-2); font-weight: 600; }
.md-total small { color: var(--gold-700); font-weight: 600; margin-top: 4px; }
.md-badges { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Member app (/m): tabs, hero, stats, activity, boards ---------- */
.md-page { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.md-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(6, 1fr); max-width: 560px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(11, 29, 64, .06); padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 600px) { .md-tabs { bottom: 12px; border: 1px solid var(--line); border-radius: 16px; padding-bottom: 0; } }
.md-tabs a { display: grid; justify-items: center; gap: 2px; padding: 9px 4px 8px; font-size: .75rem; font-weight: 600; color: var(--ink-3); text-decoration: none; min-height: 56px; }
.md-tabs a { min-width: 0; }
.md-tabs a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 400px) { .md-tabs a { font-size: .6875rem; padding-inline: 2px; } }
.md-tabs a[aria-current='page'] { color: var(--navy-900); }
.md-tabs a[aria-current='page'] .i { color: var(--gold-600); }
.md-hero-card { border-radius: var(--r-lg); padding: 20px; color: #fff; background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); box-shadow: var(--shadow-2); display: grid; gap: 14px; }
.md-hero-top { display: flex; align-items: center; gap: 14px; }
.md-hero-top h2 { color: #fff; font-size: 1.25rem; }
.md-hero-top p { margin: 2px 0 0; color: var(--navy-200); font-size: .875rem; }
.md-hero-top .avatar { background: var(--gold-300); color: var(--navy-950); }
.md-hero-pts { display: flex; align-items: baseline; gap: 8px; }
.md-hero-pts b { font-size: 3rem; line-height: 1; color: var(--gold-300); }
.md-hero-pts span { color: var(--navy-100); font-weight: 600; }
.md-rank { justify-self: start; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: #fff; font-size: .875rem; font-weight: 600; text-decoration: none; }
.md-hero-slim { grid-template-columns: 1fr 1fr; align-items: end; }
.md-hero-slim span { display: block; color: var(--navy-200); font-size: .8125rem; font-weight: 600; }
.md-hero-slim b { display: block; font-size: 2rem; line-height: 1.1; color: var(--gold-300); }
.md-hero-slim small { color: var(--navy-200); }
.md-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 480px) { .md-stats { grid-template-columns: repeat(4, 1fr); } }
.md-stats-3 { grid-template-columns: repeat(3, 1fr) !important; padding: 12px; }
.md-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 2px; }
.md-stat .i { color: var(--gold-600); }
.md-stat b { font-size: 1.375rem; color: var(--navy-900); }
.md-stat span { font-size: .8125rem; color: var(--ink-3); }
.md-break { list-style: none; margin: 0; padding: 12px 16px; display: grid; gap: 10px; }
.md-break li { display: grid; grid-template-columns: 18px minmax(0, 9.5rem) 1fr 4.5ch; align-items: center; gap: 10px; font-size: .9375rem; }
.md-break .i { color: var(--gold-600); }
.md-act { min-height: 56px; }
.md-act-ic { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--gold-50); color: var(--gold-700); }
.md-plus { color: var(--ok); }
.md-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.md-chips button { flex: none; border: 1px solid var(--line-strong); background: var(--surface); color: var(--navy-900); border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 600; font-size: .875rem; min-height: 40px; cursor: pointer; }
.md-chips button[aria-pressed='true'] { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }
.md-lb li.md-me { background: var(--gold-50); }
.md-prog h2 { font-size: 1.125rem; }
.lb .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.req { color: var(--err); font-weight: 700; }

/* ---------- Weight trend: graph + side-to-side timeline (2026-12-03) ---------- */
.wt-chart { padding: 8px 12px 0; }
.wt-chart .chart { width: 100%; height: auto; display: block; }
.wt-line { list-style: none; margin: 0; padding: 12px 16px 16px; display: flex; gap: 0; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; }
.wt-line li { flex: none; width: 128px; display: grid; gap: 2px; justify-items: center; text-align: center; position: relative; padding-top: 22px; scroll-snap-align: end; }
.wt-line li::before { content: ''; position: absolute; top: 7px; left: 0; right: 0; height: 2px; background: var(--line-strong); }
.wt-line li:first-child::before { left: 50%; }
.wt-line li:last-child::before { right: 50%; }
.wt-dot { position: absolute; top: 2px; left: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%; background: var(--navy-700); box-shadow: 0 0 0 3px var(--surface); }
.wt-line li:last-child .wt-dot { background: var(--gold-500); }
.wt-diff.down { color: var(--ok, #1a7f4b); font-weight: 650; }
.wt-diff.up { color: var(--err); font-weight: 650; }

/* ---------- Countdowns (2026-12-03) ---------- */
.cd-card { display: grid; gap: 6px; padding: 16px; border-radius: var(--r-lg); background: var(--navy-900); color: #fff; box-shadow: var(--shadow-2); }
.cd-card h3 { color: var(--gold-300); font-size: 1rem; margin: 0; }
.cd-card .cd-time { font-size: clamp(1.5rem, 7vw, 2.25rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cd-card .cd-sub { color: var(--navy-200); font-size: .875rem; }
.cd-card.cd-done .cd-time { font-size: 1.125rem; white-space: pre-line; }
.cd-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
