/* Jamat Attendance — prototype 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; }
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 { display: none; }

.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 p { color: var(--ink-3); margin-top: 4px; }
  .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.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-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-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: 768px) { .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; }
}
#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; }
