/* Layout: calm clinic back-office. Pale sage paper, white working surfaces,
   jade for actions, semantic green / amber / red only for attendance state. */
:root {
  --bg: #F1F4F1;
  --surface: #FFFFFF;
  --surface-2: #F7F9F7;
  --ink: #15201C;
  --muted: #5A6862;
  --line: #DBE2DD;
  --accent: #0E6E5C;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEEE8;
  --dark: #1F2B27;
  --ok: #24744A;      --ok-soft: #DDF0E3;
  --warn: #9A5B00;    --warn-soft: #FBEBCF;
  --bad: #B3261E;     --bad-soft: #F8DEDB;
  --shadow: 0 1px 2px rgba(21, 32, 28, .06), 0 8px 24px rgba(21, 32, 28, .06);

  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Instrument Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --r: 12px;
  --r-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1412; --surface: #161E1B; --surface-2: #1B2521; --ink: #E4EBE7; --muted: #97A69F; --line: #2A3531;
    --accent: #3DBE9F; --accent-ink: #04221B; --accent-soft: #143A31; --dark: #E4EBE7;
    --ok: #6BCB92; --ok-soft: #173826; --warn: #F0B35A; --warn-soft: #3A2A10; --bad: #F2877E; --bad-soft: #401A17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1412; --surface: #161E1B; --surface-2: #1B2521; --ink: #E4EBE7; --muted: #97A69F; --line: #2A3531;
  --accent: #3DBE9F; --accent-ink: #04221B; --accent-soft: #143A31; --dark: #E4EBE7;
  --ok: #6BCB92; --ok-soft: #173826; --warn: #F0B35A; --warn-soft: #3A2A10; --bad: #F2877E; --bad-soft: #401A17;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--accent); }
img { max-width: 100%; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.sub { color: var(--muted); font-size: .8rem; }
.nowrap { white-space: nowrap; }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.pad { padding: 16px 20px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 600; color: var(--accent); }

/* Layout */
.page { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 16px; }
.page.narrow { max-width: 560px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; display: grid; gap: 4px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { display: block; font-family: var(--font-display); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { display: block; font-size: .75rem; color: var(--muted); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background:
    radial-gradient(circle at 50% 42%, var(--accent-ink) 0 5px, transparent 6px),
    conic-gradient(from 210deg, var(--accent) 0 300deg, var(--accent-soft) 300deg);
}
.who { display: flex; align-items: center; gap: 10px; }
.who-name { color: var(--muted); font-size: .9rem; white-space: nowrap; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 12px; min-width: 0; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card.flush > h2 { border-bottom: 1px solid var(--line); }

/* Buttons */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font: 600 .95rem/1 var(--font-body); padding: 11px 16px; min-height: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.dark { background: var(--dark); color: var(--bg); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 7px 12px; min-height: 34px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.huge { width: 100%; min-height: 64px; font-size: 1.2rem; border-radius: 16px; }
.danger-text { color: var(--bad) !important; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 8px; width: 34px; height: 34px; font-size: 1.3rem; line-height: 1; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* Forms */
.field { display: grid; gap: 5px; min-width: 0; }
.field label { font-weight: 600; font-size: .85rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=month], select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; min-height: 42px;
}
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 16px; margin: 0; display: grid; gap: 10px; }
legend { font-weight: 600; padding: 0 6px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { width: 170px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.day-chip input { position: absolute; opacity: 0; }
.day-chip span { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .85rem; }
.day-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.day-chip input:focus-visible + span { outline: 3px solid var(--accent-soft); }

/* Pills, notices */
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.notice { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.notice.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.notice.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.link-notice { text-decoration: none; font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table .num { text-align: right; }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.row-rejected td { background: color-mix(in srgb, var(--bad-soft) 45%, transparent); }
tr.row-off td { color: var(--muted); }
.staff-cell { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.staff-name { font-weight: 600; }
.staff-meta { color: var(--muted); font-size: .8rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .75rem; flex: none; }
.time-cell { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); cursor: zoom-in; flex: none; display: inline-block; }
.thumb.empty { cursor: default; }
.photo-large { display: block; width: 100%; max-width: 480px; border-radius: var(--r); margin: 0 auto; }

/* Admin */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { color: var(--ink); }
.tabs .tab-kiosk { margin-left: auto; color: var(--accent); }
.admin-body { display: grid; gap: 16px; min-width: 0; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.stat-accent .stat-value { color: var(--accent); }
.stat-warn .stat-value { color: var(--warn); }
.attempts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.attempts li { display: flex; gap: 12px; align-items: flex-start; }
.loc-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: left; }
.copy-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; overflow-wrap: anywhere; flex: 1 1 240px; }

/* Sheets (dialogs) */
.sheet-wrap { position: fixed; inset: 0; background: rgba(10, 18, 15, .45); display: grid; place-items: center; padding: 16px; z-index: 20; overflow-y: auto; }
.sheet { background: var(--surface); border-radius: 16px; width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: var(--shadow); }
.sheet-wide { width: min(760px, 100%); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sheet-body { padding: 20px; display: grid; gap: 16px; }
.sheet-section { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 12px; }
.sheet-section.first { border-top: 0; padding-top: 0; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
@media (max-width: 560px) {
  .sheet-wrap { place-items: end stretch; padding: 0; }
  .sheet, .sheet-wide { width: 100%; border-radius: 16px 16px 0 0; max-height: 92dvh; }
}

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--dark); color: var(--bg); padding: 12px 16px; border-radius: 10px; max-width: min(460px, calc(100vw - 32px)); z-index: 30; transition: .2s; font-weight: 500; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-bad { background: var(--bad); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }

/* Auth + demo */
.auth { gap: 16px; }
.demo-list { display: grid; gap: 8px; }
.demo-account { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; text-align: left;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; font: inherit; color: var(--ink); cursor: pointer; }
.demo-account:hover { border-color: var(--accent); }
.demo-name { font-weight: 600; }
.demo-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* Staff clock */
.clock-card { text-align: center; gap: 6px; padding: 28px 20px; }
.big-time { font-family: var(--font-display); font-size: clamp(3rem, 12vw, 4.5rem); font-weight: 700; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.clock-status { margin: 10px 0 14px; }
.clock-action { display: grid; gap: 10px; }
.result { border-radius: 16px; padding: 22px 16px; display: grid; gap: 6px; justify-items: center; }
.result.ok { background: var(--ok-soft); color: var(--ok); }
.result.bad { background: var(--bad-soft); color: var(--bad); }
.result.pending { background: var(--surface-2); color: var(--muted); }
.result .btn { margin-top: 8px; color: inherit; border-color: currentColor; }
.result-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; background: currentColor; }
.result-icon { color: inherit; }
.result.ok .result-icon, .kiosk-overlay.ok .result-icon { background: var(--ok); color: #fff; }
.result.bad .result-icon, .kiosk-overlay.bad .result-icon { background: var(--bad); color: #fff; }
.result-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; }
.rejected summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.rejected ul { margin: 8px 0 0; padding-left: 18px; font-size: .9rem; }

/* Camera */
.cam { display: grid; gap: 8px; }
.cam-frame { position: relative; border-radius: 16px; overflow: hidden; background: #0b0f0d; aspect-ratio: 3 / 4; max-height: 60dvh; width: 100%; max-width: 420px; margin: 0 auto; }
.cam-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-guide { position: absolute; inset: 12% 18%; border: 3px dashed rgba(255, 255, 255, .75); border-radius: 50%; pointer-events: none; }
.cam-status { text-align: center; font-weight: 600; }

/* Welcome steps */
.steps { list-style: none; counter-reset: s; padding: 0; margin: 8px 0 0; display: grid; gap: 14px; }
.steps li { counter-increment: s; position: relative; padding: 14px 16px 14px 56px; border: 1px solid var(--line); border-radius: var(--r); display: grid; gap: 8px; }
.steps li::before { content: counter(s); position: absolute; left: 16px; top: 13px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.steps li.current { border-color: var(--accent); }
.steps li.current::before { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.steps li.done::before { content: '✓'; background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* Kiosk (full screen, always dark for a wall-mounted tablet) */
.kiosk { min-height: 100dvh; background: #0B110F; color: #E6EDE9; display: grid; grid-template-rows: auto 1fr; }
.kiosk .muted { color: #93A39C; }
.kiosk .btn.ghost { color: #E6EDE9; border-color: #2E3A35; }
.kiosk-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; flex-wrap: wrap; }
.kiosk-gps { font-size: .8rem; padding: 4px 10px; border-radius: 999px; background: #1C2723; }
.kiosk-gps.ok { color: #7FD6A4; }
.kiosk-gps.bad { color: #F2877E; }
.kiosk-body { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; padding: 0 20px 20px; align-items: center; }
.kiosk-cam { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.kiosk-cam .cam-guide { inset: 10% 30%; }
.kiosk-side { display: grid; gap: 12px; }
.kiosk-time { font-family: var(--font-display); font-size: clamp(3rem, 8vw, 6rem); font-weight: 700; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kiosk-lead { font-size: 1.3rem; }
.kiosk-status { color: #7FD6A4; font-weight: 600; font-size: 1.1rem; }
.kiosk-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 20px; }
.kiosk-overlay.ok { background: rgba(20, 70, 45, .88); }
.kiosk-overlay.bad { background: rgba(110, 25, 20, .88); }
.kiosk-overlay .result-icon { width: 72px; height: 72px; font-size: 2.4rem; }
.kiosk-name { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.kiosk-kind { font-size: 1.2rem; }
@media (max-width: 760px) {
  .kiosk-body { grid-template-columns: 1fr; }
  .kiosk-time { font-size: 3rem; }
}

@media (max-width: 560px) {
  .topbar { padding: 10px 16px; }
  .who-name { display: none; }
  .filters .field { width: calc(50% - 6px); }
  .table th, .table td { padding: 9px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
