/* MediLocker — shared tokens and components (patient app, QR landing, hospital app) */

:root {
  --brand: #0F766E;
  --brand-ink: #134E4A;
  --brand-soft: #CCFBF1;
  --bg: #F7F7F4;
  --surface: #FFFFFF;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #5B6472;
  --line: #E5E7EB;
  --line-strong: #CBD0D6;
  --blood: #B91C1C;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --warn-line: #F59E0B;
  --ok: #15803D;
  --ok-soft: #DCFCE7;
  --err: #B91C1C;
  --err-soft: #FEE2E2;
  --identity: #4338CA;
  --identity-soft: #E0E7FF;
  --cover: #B45309;
  --cover-soft: #FEF3C7;
  --medical: #0F766E;
  --medical-soft: #CCFBF1;
  --photo: #7C3AED;
  --photo-soft: #EDE9FE;
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 48px;
  --focus: 0 0 0 3px #fff, 0 0 0 5px #1D4ED8;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 4px 16px rgba(17, 24, 39, .06);
  --shadow-lg: 0 10px 40px rgba(17, 24, 39, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Roboto Mono", monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.no-scroll, html.no-scroll body { overflow: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font); min-height: 100vh;
  overflow-wrap: anywhere;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand-ink); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .95em; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); outline: 2px solid transparent; border-radius: 6px; }
main:focus, h1:focus, [tabindex="-1"]:focus { box-shadow: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 8px; }

.icon { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.text-error { color: var(--err); }
.id-digits { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: .08em; white-space: nowrap; }
.id-lg { font-size: 20px; font-weight: 700; color: var(--brand-ink); }

/* ---------- layout ---------- */
.container { width: 100%; max-width: 480px; margin: 0 auto; padding: 16px 16px 64px; }
.container-wide { max-width: 1240px; padding: 20px 20px 64px; }
.stack > * + * { margin-top: 14px; }
.app-header { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar { max-width: 480px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; min-height: 56px; }
.topbar-admin { max-width: 1240px; padding: 6px 20px; flex-wrap: wrap; }
.brand { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--brand-ink); text-decoration: none; min-height: var(--tap); }
.brand-sub { font-weight: 600; font-size: 13px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-actions .btn-sm { padding: 0 10px; }
@media (max-width: 380px) { .topbar .btn-label { font-size: 14px; } .topbar-actions .btn-sm { padding: 0 8px; gap: 4px; } }
.admin-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; margin-left: 16px; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2); font-weight: 600; }
.nav-link:hover { background: var(--bg); }
.nav-link[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }
.whoami { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; margin-right: 4px; }
.role-chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--identity-soft); color: var(--identity); white-space: nowrap; }
.loading-line { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 32px 0; }

.demo-banner { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 5px 12px; background: #FFF7D6; color: #713F12; font-size: 13px; border-bottom: 1px solid #FCD34D; text-align: center; }
.demo-tag { display: inline-block; background: #713F12; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 1px 7px; border-radius: 4px; }

.screen-title { font-size: 26px; line-height: 1.2; font-weight: 750; letter-spacing: -.01em; margin: 8px 0 6px; }
.screen-sub { color: var(--muted); margin-bottom: 18px; }
.lead { font-size: 17px; margin-bottom: 12px; }
.section-title { font-size: 18px; font-weight: 700; }
.subsection-title { font-size: 16px; font-weight: 700; margin: 26px 0 10px; color: var(--ink); }
.subsection-title:first-child { margin-top: 0; }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); color: var(--brand-ink); font-weight: 600; text-decoration: none; margin-left: -6px; padding: 0 6px; }
.footnote { margin-top: 28px; text-align: center; color: var(--muted); font-size: 14px; }
.link-btn { background: none; border: 0; color: var(--brand-ink); text-decoration: underline; cursor: pointer; min-height: 44px; padding: 0 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 650; font-size: 16px; line-height: 1.2;
  text-decoration: none; cursor: pointer; user-select: none; text-align: center;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn[aria-disabled="true"], .btn.btn-primary[aria-disabled="true"] { background: #9CA3AF; border-color: #9CA3AF; color: #fff; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--brand-ink); }
.btn-secondary { background: var(--surface); color: var(--brand-ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); background: #F0FDFA; }
.btn-ghost { background: transparent; color: var(--brand-ink); }
.btn-ghost:hover:not(:disabled) { background: rgba(15, 118, 110, .08); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #991B1B; }
.btn-danger-text { color: var(--err); }
.btn-sm { min-height: 44px; padding: 0 12px; font-size: 15px; }
.btn-lg { min-height: 54px; font-size: 17px; padding: 0 22px; }
.btn-block { display: flex; width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: rgba(17, 24, 39, .06); }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.row-actions-split { justify-content: space-between; }
.row-actions-start { justify-content: flex-start; }

.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; opacity: .8; }
.spinner-lg { width: 36px; height: 36px; border-width: 3.5px; color: #fff; position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field-label { display: block; font-weight: 650; margin-bottom: 6px; color: var(--ink); }
.field-optional { font-weight: 400; color: var(--muted); }
.field-hint { color: var(--muted); font-size: 14px; margin-top: 6px; }
.field-error { color: var(--err); font-size: 14px; font-weight: 600; margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.field-error:empty { display: none; }
.field-error .icon { margin-top: 2px; }
.input {
  display: block; width: 100%; min-height: var(--tap); padding: 10px 12px;
  font-size: 16px; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: #9CA3AF; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, .22); outline: none; }
.input::placeholder { color: #8A929E; }
.input[disabled] { background: var(--bg); color: var(--muted); }
.has-error .input, .input[aria-invalid="true"] { border-color: var(--err); }
.input-lg { font-size: 20px; min-height: 56px; letter-spacing: .04em; }
.input-sm { min-height: 44px; padding: 8px 10px; font-size: 16px; }
.textarea { min-height: 72px; resize: vertical; line-height: 1.4; }
.select { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.grid-2 { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 420px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.input-prefix { position: relative; }
.input-prefix .prefix { position: absolute; left: 12px; top: 39px; font-size: 20px; color: var(--muted); pointer-events: none; }
.input-prefix .input { padding-left: 56px; }
.readonly-field { margin-bottom: 16px; }
.readonly-value { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 600; }
.field-group { margin-bottom: 16px; }
.field-group .field { margin-bottom: 6px; margin-top: 10px; }
.dob-age-readout { margin-top: 0; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.segmented { display: flex; background: #EEF0EE; border-radius: var(--radius-sm); padding: 4px; gap: 4px; }
.seg-input { position: absolute; opacity: 0; pointer-events: none; }
.seg-label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 8px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink-2); text-align: center; }
.seg-input:checked + .seg-label { background: var(--surface); color: var(--brand-ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg-input:focus-visible + .seg-label { box-shadow: var(--focus); }
.has-error .segmented { box-shadow: 0 0 0 1.5px var(--err); }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-input { position: absolute; opacity: 0; pointer-events: none; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface);
  cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 15px;
}
.chip:hover { border-color: var(--brand); }
.chip-sm { min-height: 40px; padding: 0 12px; font-size: 14px; }
.chip-input:checked + .chip, .chip-toggle[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-input:focus-visible + .chip { box-shadow: var(--focus); }
.blood-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.blood-grid .chip { border-radius: var(--radius-sm); font-size: 18px; font-weight: 750; }
.blood-grid .chip-input:checked + .chip-blood { background: var(--blood); border-color: var(--blood); }
.blood-grid .chip-wide { grid-column: 1 / -1; font-size: 16px; font-weight: 600; }
.has-error .blood-grid .chip { border-color: #F2A3A3; }
.quick-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.quick-chips .chip-sm { min-height: 40px; }

.switch-row { display: flex; align-items: flex-start; margin: 16px 0; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-label { display: flex; gap: 12px; cursor: pointer; align-items: flex-start; min-height: var(--tap); }
.switch-label strong { display: block; }
.switch { position: relative; flex: none; width: 52px; height: 32px; border-radius: 999px; background: #9CA3AF; transition: background .2s; margin-top: 2px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch-input:checked + .switch-label .switch { background: var(--brand); }
.switch-input:checked + .switch-label .switch::after { transform: translateX(20px); }
.switch-input:focus-visible + .switch-label .switch { box-shadow: var(--focus); }
.check-row { display: flex; gap: 12px; align-items: flex-start; }
.check-row label { cursor: pointer; padding-top: 3px; font-weight: 600; }
.check-input { flex: none; width: 26px; height: 26px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.consent { padding: 14px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.consent.has-error { border-color: var(--err); }
.consent-text { max-height: 200px; overflow: auto; font-size: 14px; color: var(--ink-2); margin-bottom: 14px; padding-right: 6px; }
.consent-text p + p { margin-top: 8px; }

/* OTP */
.otp-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-width: 360px; }
.otp-box { width: 100%; min-width: 0; height: 58px; text-align: center; font-size: 26px; font-family: var(--mono); font-weight: 700; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.otp-box:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, .22); }
.dev-hint { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1.5px dashed #A16207; background: #FFFBEB; border-radius: var(--radius-sm); color: #713F12; font-size: 14px; }
.dev-hint code { font-size: 18px; font-weight: 700; }

/* ---------- toasts, modals ---------- */
.toast-host { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-weight: 600; animation: toast-in .2s ease-out; }
.toast-ok { background: #14532D; }
.toast-error { background: #7F1D1D; }
.toast-out { opacity: 0; transition: opacity .3s; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.modal { border: 0; padding: 0; border-radius: var(--radius); width: min(520px, calc(100% - 24px)); max-height: calc(100% - 24px); box-shadow: var(--shadow-lg); background: var(--surface); color: var(--ink); display: flex; flex-direction: column; }
.modal:not([open]) { display: none; }
.modal-wide { width: min(760px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(17, 24, 39, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 20px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-text { color: var(--ink-2); }

/* ---------- notices / empty / skeleton ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); margin: 12px 0; }
.notice > div > * + * { margin-top: 8px; }
.notice-error { background: var(--err-soft); color: #7F1D1D; }
.notice-warn { background: var(--warn-soft); color: #78350F; }
.empty { text-align: center; padding: 28px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; margin: 0 auto 10px; }
.empty-title { font-weight: 700; font-size: 17px; }
.empty-text { color: var(--muted); margin: 6px auto 14px; max-width: 420px; }
.section-empty { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 14px; padding: 8px 12px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.skel { background: linear-gradient(90deg, #ECEDEA 25%, #F4F5F2 50%, #ECEDEA 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 8px; }
.skel-line { display: block; height: 12px; width: 70%; }
.skel-title { height: 18px; width: 40%; margin-bottom: 12px; }
.skel-card { height: 220px; border-radius: var(--radius); margin: 16px 0; }
.skel-block { height: 260px; border-radius: var(--radius); margin: 16px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- badges, avatar ---------- */
.blood-badge { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 999px; background: var(--blood); color: #fff; font-weight: 800; font-size: 14px; white-space: nowrap; flex: none; }
.blood-badge-lg { font-size: 20px; padding: 6px 14px; }
.blood-badge-unknown { background: #6B7280; }
.avatar { flex: none; display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden; background: var(--brand-soft); color: var(--brand-ink); font-weight: 750; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.avatar-btn { cursor: zoom-in; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.status-chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status-warn { background: var(--warn-soft); color: #78350F; border: 1px solid #FCD34D; }

/* ---------- patient home ---------- */
.hero { padding: 18px 0 8px; }
.hero-title { font-size: 28px; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; color: var(--brand-ink); }
.hero-text { margin-top: 10px; color: var(--ink-2); font-size: 17px; }
.big-choices { display: grid; gap: 12px; margin: 22px 0; }
.big-choice { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: var(--radius); border: 1.5px solid var(--line-strong); background: var(--surface); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.big-choice:hover { border-color: var(--brand); }
.big-choice .icon { color: var(--brand); margin-top: 2px; }
.big-choice-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.big-choice-primary .icon { color: #fff; }
.big-choice-primary:hover { background: var(--brand-ink); }
.big-choice-text strong { display: block; font-size: 19px; }
.big-choice-text span { display: block; font-size: 15px; opacity: .9; margin-top: 2px; }
.trust-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; color: var(--ink-2); font-size: 15px; }
.trust-list li { display: flex; gap: 10px; align-items: flex-start; }
.trust-list .icon { color: var(--brand); margin-top: 3px; }

.person-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.person { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); min-height: 72px; box-shadow: var(--shadow); }
.person:hover { border-color: var(--brand); }
.person-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.person-name { font-weight: 700; font-size: 17px; }
.person-meta { color: var(--muted); font-size: 14px; }

/* ---------- wizard ---------- */
.wizard-progress { margin: 4px 0 8px; }
.wizard-step { font-size: 14px; font-weight: 700; color: var(--brand-ink); margin-bottom: 6px; }
.progress { height: 8px; border-radius: 999px; background: #E3E6E2; overflow: hidden; }
.progress-bar { height: 100%; background: var(--brand); border-radius: inherit; transition: width .3s ease; }
.wizard-dots { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; font-size: 12px; color: var(--muted); }
.wizard-dots li { line-height: 1.25; }
.wizard-dots .current { color: var(--brand-ink); font-weight: 700; }
.wizard-dots .done { color: var(--ok); }
.wizard-form { margin-bottom: 8px; }
.wizard-foot { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 80%, rgba(247,247,244,0)); padding: 14px 0 calc(12px + env(safe-area-inset-bottom)); margin-top: 8px; z-index: 5; }
.wizard-buttons { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.wizard-buttons .btn-primary { flex: 1; min-width: 160px; }
.block-reason { color: #78350F; background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.block-reason:empty { display: none; }
.form-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; scroll-margin-top: 80px; }
.form-section-title { font-size: 19px; font-weight: 750; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; padding: 0; }
.form-section > .field-hint { margin: 0 0 16px; }
.form-section-body { margin-top: 12px; }
.wizard-form .form-section-body { margin-top: 0; }
.long-form .form-section-body { margin-top: 4px; }

/* capture targets */
.capture { display: flex; gap: 14px; align-items: center; padding: 14px; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: #FBFBFA; }
.capture.has-file { border-style: solid; border-color: #86EFAC; background: #F0FDF4; }
.capture-empty { flex: none; width: 76px; height: 76px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.capture-round .capture-empty, .capture-round .capture-preview { border-radius: 50%; width: 96px; height: 96px; }
.capture-preview { position: relative; flex: none; width: 92px; height: 92px; border-radius: var(--radius-sm); overflow: hidden; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; }
.capture-preview img { width: 100%; height: 100%; object-fit: cover; }
.capture-round .capture-preview { overflow: visible; }
.capture-round .capture-preview img { border-radius: 50%; }
.capture-tick { position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; border: 2px solid #fff; }
.capture-after { flex: 1; min-width: 0; }
.capture-title { font-weight: 650; margin-bottom: 8px; }
.capture-file { font-size: 13px; color: var(--muted); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-buttons-sm .btn { min-height: 44px; padding: 0 12px; font-size: 15px; }
.capture-after > .btn-ghost { margin-top: 4px; margin-left: -8px; }
@media (max-width: 400px) {
  .capture { flex-direction: column; align-items: stretch; text-align: left; }
  .capture-empty, .capture-preview { align-self: center; }
  .capture .pick-buttons .btn { flex: 1; }
}

/* required documents */
.req-progress { margin-bottom: 14px; }
.req-progress-bar { height: 10px; border-radius: 999px; background: #E3E6E2; overflow: hidden; }
.req-progress-bar span { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width .3s; }
.req-progress-text { margin-top: 6px; color: var(--ink-2); font-size: 15px; }
.req-cards { display: grid; gap: 14px; }
.req-card { border: 1.5px solid var(--line-strong); border-left: 5px solid var(--identity); border-radius: var(--radius); padding: 14px; background: var(--surface); }
.req-card.cat-cover { border-left-color: var(--cover); }
.req-card.cat-photo { border-left-color: var(--photo); }
.req-card.is-done { border-color: #86EFAC; border-left-color: var(--ok); }
.req-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.req-card-title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 750; }
.req-tick { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line-strong); color: transparent; flex: none; }
.req-card.is-done .req-tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.req-card .field { margin-bottom: 12px; }
.req-card .field-hint { margin: 0 0 10px; }
.req-block { margin-top: 12px; color: #78350F; font-size: 14px; }
.req-block:empty { display: none; }

/* other documents */
.id-entries { display: grid; gap: 12px; margin-bottom: 12px; }
.id-entry { border: 1.5px solid var(--line-strong); border-left: 5px solid var(--identity); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.id-entry.cat-cover { border-left-color: var(--cover); }
.id-entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.id-entry-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.choice { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 12px; text-align: left; border-radius: var(--radius-sm); border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 15px; line-height: 1.25; }
.choice:hover { border-color: var(--brand); background: #F0FDFA; }
.choice .icon { color: var(--identity); }

/* drop zones + staged files */
.drop-zone { text-align: center; padding: 20px 14px; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: #FBFBFA; color: var(--ink-2); }
.drop-zone > .icon { margin: 0 auto 6px; color: var(--brand); }
.drop-zone-title { font-weight: 700; }
.drop-zone-text { font-size: 14px; color: var(--muted); margin: 4px 0 12px; }
.drop-zone .pick-buttons { justify-content: center; }
.drop-target { position: relative; }
.drop-overlay { display: none; position: absolute; inset: 0; z-index: 10; border-radius: var(--radius); background: rgba(204, 251, 241, .92); border: 3px dashed var(--brand); color: var(--brand-ink); font-weight: 700; flex-direction: column; align-items: center; justify-content: center; gap: 8px; pointer-events: none; }
.drag-over > .drop-overlay { display: flex; }
.stage-tiles { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stage-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; }
.stage-tile-media { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg); display: grid; place-items: center; margin-bottom: 6px; }
.stage-tile-media img { width: 100%; height: 100%; object-fit: cover; }
.stage-remove { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(17,24,39,.75); color: #fff; display: grid; place-items: center; cursor: pointer; }
.med-text { margin-top: 8px; }
.upload-dialog { position: relative; min-height: 200px; }
.stage-list, .upload-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.stage-row, .upload-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.stage-main, .upload-main { flex: 1; min-width: 0; }
.stage-fields { display: grid; gap: 8px; grid-template-columns: 1fr; margin-top: 6px; }
@media (min-width: 640px) { .stage-fields { grid-template-columns: 1.3fr 1.3fr 1fr; } }
.upload-thumb { flex: none; width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.upload-thumb-icon { display: grid; place-items: center; color: var(--muted); }
.upload-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-meta { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.upload-row.is-error { border-color: #FCA5A5; background: #FEF2F2; }
.upload-row.is-done { border-color: #BBF7D0; }
.upload-actions { flex: none; display: flex; align-items: center; }
.upload-ok { color: var(--ok); }
.upload-summary { font-weight: 650; color: var(--ink-2); }
.upload-summary:empty { display: none; }

/* ---------- gallery ---------- */
.gallery { margin-top: 24px; }
.gallery-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.gallery-count { color: var(--muted); font-weight: 600; }
.gallery-section { margin-bottom: 20px; }
.gallery-section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 750; margin-bottom: 10px; color: var(--ink-2); }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--medical); }
.cat-dot.cat-identity { background: var(--identity); }
.cat-dot.cat-cover { background: var(--cover); }
.count-pill { font-size: 12px; background: #E9EBE7; color: var(--ink-2); border-radius: 999px; padding: 1px 8px; }
.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 4px; scrollbar-width: thin; }
.filter-chips .chip { flex: none; }
.tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; } }
.tile { display: flex; flex-direction: column; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; overflow: hidden; text-align: left; position: relative; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.tile::before { content: ""; position: absolute; top: 0; left: 0; z-index: 2; border-style: solid; border-width: 18px 18px 0 0; border-color: var(--medical) transparent transparent transparent; }
.tile.cat-identity::before { border-top-color: var(--identity); }
.tile.cat-cover::before { border-top-color: var(--cover); }
.tile:hover { border-color: var(--brand); }
.tile:hover .thumb-img { transform: scale(1.03); }
.tile-media { position: relative; display: block; aspect-ratio: 1; background: #EEF0EE; overflow: hidden; }
.thumb-img { width: 100%; height: 100%; object-fit: cover; object-position: top left; transition: transform .2s; }
.thumb-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: var(--medical); background: var(--medical-soft); }
.thumb-fallback.cat-identity { color: var(--identity); background: var(--identity-soft); }
.thumb-fallback.cat-cover { color: var(--cover); background: var(--cover-soft); }
.thumb-fallback.cat-photo { color: var(--photo); background: var(--photo-soft); }
.tile-badge { position: absolute; right: 4px; bottom: 4px; background: rgba(17,24,39,.8); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 4px; }
.tile-info { display: flex; flex-direction: column; gap: 3px; padding: 6px 7px 8px; min-height: 52px; }
.type-chip { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--medical-soft); color: var(--brand-ink); align-self: flex-start; }
.type-chip.cat-identity { background: var(--identity-soft); color: #3730A3; }
.type-chip.cat-cover { background: var(--cover-soft); color: #78350F; }
.type-chip.cat-photo { background: var(--photo-soft); color: #5B21B6; }
.tile-date { font-size: 12px; color: var(--muted); }
.tile-skeleton { cursor: default; }
.tile-skeleton::before { display: none; }

/* ---------- lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 150; background: #0B0F14; color: #F3F4F6; display: flex; flex-direction: column; }
.lb-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 14px; background: rgba(0,0,0,.4); flex-wrap: wrap; }
.lb-heading { display: flex; flex-direction: column; min-width: 0; flex: 1 1 140px; }
.lb-counter { font-size: 12px; color: #C7CBD1; }
.lb-title { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-tools, .lb-tools-image { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.lb-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: var(--radius-sm); border: 0; background: transparent; color: #F3F4F6; cursor: pointer; text-decoration: none; }
.lb-btn:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.lb-btn:disabled { opacity: .35; cursor: default; }
.lb-btn:focus-visible, .lb-nav:focus-visible, .lb-strip-item:focus-visible { box-shadow: 0 0 0 3px #93C5FD; }
.lb-close { background: rgba(255,255,255,.1); }
.lb-middle { position: relative; flex: 1; display: flex; min-height: 0; }
.lb-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; display: grid; place-items: center; cursor: grab; user-select: none; }
.lb-stage.is-zoomed { cursor: move; }
.lb-frame { width: 100%; height: 100%; display: grid; place-items: center; position: relative; }
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center center; will-change: transform; -webkit-user-drag: none; }
.lb-frame-pdf { display: flex; flex-direction: column; padding: 8px; }
.lb-pdf { flex: 1; width: 100%; border: 0; background: #fff; border-radius: 6px; }
.lb-pdf-hint { font-size: 13px; color: #C7CBD1; padding: 6px 0 0; text-align: center; }
.lb-pdf-hint a { color: #A7F3D0; }
.lb-error { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #E5E7EB; text-align: center; padding: 20px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 52px; height: 72px; border: 0; border-radius: var(--radius-sm); background: rgba(0,0,0,.45); color: #fff; cursor: pointer; display: grid; place-items: center; }
.lb-nav:hover { background: rgba(0,0,0,.7); }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
.is-editing .lb-next { right: min(360px, 100%); }
.lb-caption { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 10px 14px; background: rgba(0,0,0,.4); font-size: 14px; }
.lb-cap-title { font-weight: 700; }
.lb-cap-meta { display: inline-flex; align-items: center; gap: 4px; color: #C7CBD1; }
.lb-cap-notes { flex-basis: 100%; color: #E5E7EB; }
.lb-strip { display: none; gap: 6px; padding: 8px 12px 12px; overflow-x: auto; background: rgba(0,0,0,.4); }
@media (min-width: 768px) { .lb-strip { display: flex; } }
.lb-strip-item { flex: none; width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #1F2937; cursor: pointer; opacity: .65; }
.lb-strip-item[aria-current="true"] { border-color: #5EEAD4; opacity: 1; }
.lb-strip-item:hover { opacity: 1; }
.lb-strip-item .thumb-img, .lb-strip-item .thumb-fallback { width: 100%; height: 100%; }
.lb-edit { position: absolute; top: 0; right: 0; bottom: 0; width: min(360px, 100%); background: var(--surface); color: var(--ink); overflow: auto; z-index: 4; padding: 16px; box-shadow: var(--shadow-lg); }
.lb-edit-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; }

/* ---------- MediLocker card ---------- */
.card-top { margin-bottom: 8px; }
.card-stage { display: flex; justify-content: center; margin: 8px 0 14px; }
.ml-card {
  width: 100%; max-width: 420px; aspect-ratio: 85.6 / 54; border-radius: 16px; overflow: hidden;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; color: var(--ink); container-type: inline-size;
}
.ml-card-top { display: flex; justify-content: space-between; align-items: center; padding: 3.2cqw 4.5cqw; background: var(--brand); color: #fff; }
.ml-card-brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 750; font-size: max(13px, 4.2cqw); }
.ml-card-blood { display: inline-flex; align-items: center; gap: 3px; background: var(--blood); color: #fff; border-radius: 999px; padding: .6cqw 2.6cqw; font-weight: 800; font-size: max(13px, 4.2cqw); }
.ml-card-blood.is-unknown { background: #6B7280; font-size: max(11px, 3.2cqw); }
.ml-card-main { flex: 1; display: flex; gap: 3.5cqw; align-items: center; padding: 3cqw 4.5cqw; min-height: 0; }
.ml-card-main .avatar { width: 13cqw !important; height: 13cqw !important; font-size: 4.5cqw !important; align-self: flex-start; }
.ml-card-text { flex: 1; min-width: 0; }
.ml-card-name { font-weight: 750; font-size: 4.8cqw; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ml-card-sub { color: var(--ink-2); font-size: max(12px, 3.6cqw); margin-top: .5cqw; }
.ml-card-idlabel { margin-top: 2.2cqw; font-size: max(10px, 2.6cqw); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ml-card-id { font-size: 5.2cqw; font-weight: 800; color: var(--brand-ink); letter-spacing: .02em; }
.ml-card-qr { flex: none; width: 28cqw; height: 28cqw; image-rendering: pixelated; }
.ml-card-foot { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; font-size: max(11px, 3cqw); padding: 1.8cqw 4.5cqw; }
.ml-card-compact { max-width: 300px; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card-actions .btn { padding: 0 10px; font-size: 15px; }
#print-root { display: none; }

/* ---------- panels, definition lists ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head-main { display: flex; align-items: center; gap: 10px; }
.dl { margin: 0; display: grid; gap: 0; }
.dl-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.dl-row:first-child { border-top: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dl-compact .dl-row { grid-template-columns: 1fr; gap: 2px; padding: 8px 0; }
@media (min-width: 900px) { .dl-2col { grid-template-columns: 1fr 1fr; column-gap: 24px; } .dl-2col .dl-row:nth-child(2) { border-top: 0; } }

/* ---------- finish checklist ---------- */
.finish { background: var(--surface); border: 1.5px solid var(--warn-line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.finish-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.finish-head > .icon { color: var(--warn); margin-top: 3px; }
.finish-title { font-size: 19px; font-weight: 750; }
.finish-intro { color: var(--ink-2); margin-top: 4px; }
.finish-count { font-weight: 700; color: var(--warn); margin-top: 6px; }
.finish-staff { background: #FFFBEB; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.check-item { display: grid; grid-template-columns: 30px 1fr; gap: 6px 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.check-mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); }
.check-item.is-done .check-mark { background: var(--ok); color: #fff; }
.check-title { font-weight: 700; padding-top: 2px; }
.check-missing { color: #78350F; font-size: 14px; }
.check-actions { grid-column: 2; display: grid; gap: 8px; }
.check-number { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.check-number .field { flex: 1 1 200px; margin: 0; }
.check-progress { font-size: 14px; color: var(--ink-2); }
.check-progress:empty { display: none; }
.finish-compact .checklist { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* ---------- demo panels ---------- */
.demo-panel { border: 1.5px dashed #CA8A04; background: #FFFBEB; border-radius: var(--radius); padding: 14px; margin-top: 18px; }
.demo-panel-title { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 750; color: #713F12; margin-bottom: 8px; }
.demo-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.demo-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 10px; background: #fff; border-radius: var(--radius-sm); border: 1px solid #FDE68A; }
.demo-row-main { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.demo-k { color: var(--muted); font-size: 13px; }
.demo-ids { margin-top: 10px; }
.demo-id-list { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }
.demo-patient { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 10px; background: #fff; border: 1px solid #FDE68A; border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
.demo-patient:hover { border-color: #CA8A04; }
.demo-patient-main { flex: 1; display: flex; flex-direction: column; }
.demo-patient-name { font-weight: 700; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }

/* ---------- hospital app ---------- */
.login-wrap { max-width: 460px; margin: 24px auto; }
.login-panel { padding: 24px; }
.search-hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.search-label { display: block; font-size: 22px; font-weight: 750; margin-bottom: 10px; }
.search-row { display: flex; gap: 10px; flex-wrap: wrap; }
.search-field { position: relative; flex: 1 1 320px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input { min-height: 60px; font-size: 20px; padding-left: 48px; border-width: 2px; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }
.search-status { margin-top: 8px; color: var(--ink-2); font-weight: 600; }
.search-status:empty { display: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .icon { grid-row: 1 / 3; color: var(--brand); }
.stat-val { font-size: 24px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }
.result-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.result { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); }
.result:hover, .result:focus-visible { border-color: var(--brand); background: #F0FDFA; }
.result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.result-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 17px; }
.result-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--ink-2); font-size: 14px; }
.result-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }

.patient-layout { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 960px) { .patient-layout { grid-template-columns: 340px 1fr; } .identity { position: sticky; top: 80px; } }
.identity { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.identity-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; margin-bottom: 12px; }
.identity-name { font-size: 21px; font-weight: 800; line-height: 1.2; }
.identity-sub { color: var(--ink-2); }
.allergy-strip { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-soft); color: #78350F; border: 1.5px solid var(--warn-line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.identity-qr { display: flex; gap: 14px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.identity-qr img { width: 132px; height: 132px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; }
.identity-qr-actions { display: flex; flex-direction: column; gap: 8px; }
.patient-main { min-width: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 16px; text-decoration: none; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tab:hover { color: var(--ink); }
.tab-panel:focus-visible { box-shadow: var(--focus); }
.tab-panel .gallery { margin-top: 0; }
.id-list { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 8px; }
.id-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.id-row-label { font-size: 14px; color: var(--muted); }
.id-row .id-digits { font-size: 17px; font-weight: 700; margin-right: 8px; }
.id-row .revealed { background: #FEF9C3; padding: 0 4px; border-radius: 4px; }
.id-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.activity-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.activity-detail { display: block; color: var(--muted); font-size: 13px; }
@media (max-width: 560px) { .activity-row { grid-template-columns: 1fr; gap: 2px; } }

.register-layout { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 960px) { .register-layout { grid-template-columns: 250px 1fr; } .anchor-nav { position: sticky; top: 80px; } }
.anchor-nav { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.anchor-nav ol { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 2px; }
.anchor-nav a { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.anchor-nav a:hover { background: var(--bg); }
.anchor-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-size: 13px; font-weight: 800; flex: none; }
.completeness { border-top: 1px solid var(--line); padding-top: 10px; }
.completeness-title { margin-bottom: 6px; }
.completeness-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 14px; color: #78350F; }
.completeness-list li { display: flex; align-items: center; gap: 6px; }
.completeness-list li.is-done { color: var(--ok); }
.sticky-submit { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 12px 0; background: linear-gradient(to top, var(--bg) 75%, rgba(247,247,244,0)); z-index: 5; }
.long-form .form-section > .field-hint { margin-top: 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 13px; color: var(--muted); font-weight: 700; background: #FAFAF8; }
.table .is-inactive td { color: var(--muted); }

/* ---------- QR landing ---------- */
.em-card { background: var(--surface); border: 2px solid var(--blood); border-radius: var(--radius); padding: 16px; margin: 12px 0 16px; box-shadow: var(--shadow); }
.em-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--blood); margin-bottom: 8px; }
.em-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.em-name { font-size: 26px; font-weight: 800; line-height: 1.15; }
.em-sub { font-size: 17px; color: var(--ink-2); margin-top: 2px; }
.em-id { font-size: 14px; color: var(--muted); margin-top: 6px; }
.em-blood { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.em-blood-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.em-block { padding: 12px; border-radius: var(--radius-sm); background: var(--bg); margin-top: 10px; }
.em-block-warn { background: var(--warn-soft); border: 1.5px solid var(--warn-line); }
.em-block-title { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 750; margin-bottom: 4px; }
.em-block-text { font-size: 17px; white-space: pre-line; }
.em-contact { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.em-contact .btn { margin-top: 10px; }
.em-actions { display: grid; gap: 10px; }

/* ---------- scanner ---------- */
.scan-view { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 15% 22%; border: 3px solid #5EEAD4; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.scan-status { margin-top: 10px; font-weight: 650; }

/* ---------- responsive tweaks ---------- */
@media (max-width: 400px) {
  .screen-title { font-size: 23px; }
  .card-actions { grid-template-columns: 1fr; }
  .wizard-buttons .btn-ghost { padding: 0 12px; }
  .otp-boxes { gap: 6px; }
  .otp-box { height: 52px; font-size: 22px; }
  .lb-tools-image .lb-btn, .lb-tools .lb-btn { width: 44px; height: 44px; }
}
@media (max-width: 720px) {
  .app-admin .app-header { position: static; }
  .admin-nav { margin-left: 0; order: 3; flex-basis: 100%; }
  .whoami > span:not(.role-chip) { display: none; }
}

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

@media (forced-colors: active) {
  .chip-input:checked + .chip, .seg-input:checked + .seg-label { outline: 3px solid CanvasText; }
}

/* ---------- print: only the card, ID-1 size ---------- */
@media print {
  @page { size: 85.6mm 54mm; margin: 0; }
  html.printing-card body > *:not(#print-root) { display: none !important; }
  html.printing-card #print-root { display: block !important; }
  html.printing-card, html.printing-card body { background: #fff; margin: 0; padding: 0; }
  #print-root .ml-card-print {
    width: 85.6mm; height: 54mm; max-width: none; aspect-ratio: auto; border-radius: 3mm; box-shadow: none; border: .2mm solid #D1D5DB;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; container-type: normal;
  }
  #print-root .ml-card-top { padding: 2mm 3.5mm; }
  #print-root .ml-card-brand, #print-root .ml-card-blood { font-size: 3.4mm; }
  #print-root .ml-card-blood { padding: .5mm 2.2mm; }
  #print-root .ml-card-main { padding: 2mm 3.5mm; gap: 2.5mm; }
  #print-root .ml-card-main .avatar { width: 12mm !important; height: 12mm !important; font-size: 4mm !important; }
  #print-root .ml-card-name { font-size: 4mm; }
  #print-root .ml-card-sub { font-size: 2.8mm; }
  #print-root .ml-card-idlabel { font-size: 2mm; margin-top: 1.5mm; }
  #print-root .ml-card-id { font-size: 4.6mm; }
  #print-root .ml-card-qr { width: 25mm; height: 25mm; }
  #print-root .ml-card-foot { font-size: 2.3mm; padding: 1.2mm 3.5mm; }
}
