/* Member Helix — shared styles */
@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,600;12..96,700;12..96,800&family=Geist:wght@400;500;600;700&display=swap");

:root {
  --paper: #f2f4f3;
  --surface: #ffffff;
  --sunk: #e9ecec;
  --ink: #18202b;
  --ink-2: #364152;
  --muted: #5a6472;
  --faint: #8a93a0;
  --line: #e2e5ea;
  --line-2: #d3d8df;
  --violet: #4b32e6;
  --violet-2: #3a22cf;
  --violet-soft: #ecebfd;
  --cyan: #0096b7;
  --cyan-soft: #e2f4f8;
  --present: #0e9f6e;
  --present-soft: #e3f5ee;
  --absent: #d93f4c;
  --absent-soft: #fbe9eb;
  --excused: #c98a0b;
  --excused-soft: #fbf2dc;
  --display: "Bricolage Grotesque", "Geist", system-ui, sans-serif;
  --ui: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow-pop: 0 18px 48px -12px rgba(24, 32, 43, 0.28), 0 2px 6px rgba(24, 32, 43, 0.08);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { font-family: var(--display); margin: 0; letter-spacing: -0.01em; line-height: 1.15; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 21px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--violet); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:hover { background: #f7f8f9; border-color: #c4cad3; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn.primary:hover { background: var(--violet-2); border-color: var(--violet-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.danger { color: var(--absent); }
.btn.danger:hover { background: var(--absent-soft); border-color: #f1c4c9; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn svg { width: 17px; height: 17px; flex: none; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--faint); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(75, 50, 230, 0.14); }
.input::placeholder, .textarea::placeholder { color: #a3abb6; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--violet); }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: #c9ced6; transition: background 0.2s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--violet); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2.5px solid var(--violet); outline-offset: 2px; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-family: var(--display); font-weight: 650; font-size: 15px; padding: 0; margin-bottom: 10px; }

.seg { display: inline-flex; padding: 3px; background: var(--sunk); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(24,32,43,.12); }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-pad { padding: 20px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { flex: 1; }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.chip.present { background: var(--present-soft); color: #08744f; }
.chip.absent { background: var(--absent-soft); color: #b12a36; }
.chip.excused { background: var(--excused-soft); color: #8d6107; }
.chip.violet { background: var(--violet-soft); color: var(--violet-2); }
.chip.cyan { background: var(--cyan-soft); color: #00718a; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-family: var(--display); font-weight: 700; font-size: 13px; color: #fff; letter-spacing: 0.02em;
}
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }

table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fafbfb; position: sticky; top: 0; z-index: 1; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: #f8f9fa; }
.table .who { display: flex; align-items: center; gap: 12px; }
.table .who b { display: block; font-weight: 600; }
.table .who small { color: var(--faint); font-size: 12px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1000; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-pop); display: flex; align-items: center; gap: 10px; max-width: min(560px, 92vw);
  animation: toast-in 0.28s var(--ease);
}
.toast.error { background: #8f1d28; }
.toast .btn { height: 28px; background: rgba(255,255,255,.14); border: 0; color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }

/* ---------- Overlay / drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(24, 32, 43, 0.38); z-index: 500; animation: fade 0.2s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 501;
  display: flex; flex-direction: column; box-shadow: var(--shadow-pop); animation: slide-in 0.28s var(--ease);
}
.drawer.wide { width: min(760px, 100vw); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { flex: 1; }
.drawer-body { flex: 1; overflow: auto; padding: 22px; }
.drawer-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfb; }
.modal {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%); width: min(560px, 94vw); max-height: 76vh; overflow: auto;
  background: var(--surface); border-radius: var(--r-lg); z-index: 501; box-shadow: var(--shadow-pop); animation: pop 0.22s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0.4; } }
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.98); } }

/* ---------- Command palette ---------- */
.palette { top: 14vh; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.palette input { border: 0; border-bottom: 1px solid var(--line); height: 56px; padding: 0 20px; font-size: 17px; width: 100%; }
.palette input:focus { outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow: auto; }
.palette li { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.palette li[aria-selected="true"] { background: var(--violet-soft); }
.palette li small { color: var(--faint); margin-left: auto; font-size: 12px; }
.palette .group { padding: 8px 12px 4px; font-size: 12px; color: var(--faint); font-weight: 600; }
.kbd { font-size: 11px; font-weight: 600; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--muted); background: #fff; }

/* ---------- QR scanner ---------- */
.scanner { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #0d1219; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 14%; border-radius: 18px; box-shadow: 0 0 0 999px rgba(13, 18, 25, 0.45); }
.scanner .frame::before, .scanner .frame::after { content: ""; position: absolute; inset: 0; border-radius: 18px; border: 3px solid rgba(255,255,255,.9); clip-path: polygon(0 0, 22% 0, 22% 3px, 3px 3px, 3px 22%, 0 22%, 0 78%, 3px 78%, 3px calc(100% - 3px), 22% calc(100% - 3px), 22% 100%, 78% 100%, 78% calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) 78%, 100% 78%, 100% 22%, calc(100% - 3px) 22%, calc(100% - 3px) 3px, 78% 3px, 78% 0, 100% 0, 100% 100%, 0 100%); }
.scanner .scanline { position: absolute; left: 16%; right: 16%; height: 2px; background: linear-gradient(90deg, transparent, var(--cyan), transparent); top: 50%; animation: scan 2.2s ease-in-out infinite; }
.scanner .msg { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: #fff; font-size: 13px; font-weight: 500; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.scanner.flash { animation: flash 0.5s ease; }
@keyframes scan { 0%,100% { top: 20%; } 50% { top: 78%; } }
@keyframes flash { 0% { box-shadow: inset 0 0 0 0 var(--present); } 30% { box-shadow: inset 0 0 0 8px var(--present); } 100% { box-shadow: inset 0 0 0 0 transparent; } }

/* ---------- Spinner / skeleton ---------- */
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(75, 50, 230, .2); border-top-color: var(--violet); animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, #eceff1 25%, #f6f7f8 50%, #eceff1 75%); background-size: 200% 100%; animation: skel 1.3s infinite; border-radius: 8px; }
@keyframes skel { to { background-position: -200% 0; } }
.loading { display: grid; place-items: center; padding: 60px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
}
