:root {
  --bg: #f5f7f8; --card: #fff; --ink: #14272e; --muted: #5d7279; --line: #dde5e8;
  --accent: #0b7a75; --accent-ink: #fff; --danger: #b3261e; --warn: #9a5b00;
  --hi: #b3261e; --lo: #1f5fbf; --ok: #1b7a3d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
#who { display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 800; }
main { max-width: 1040px; margin: 24px auto; padding: 0 16px 64px; }
h2 { margin: 0 0 12px; font-size: 20px; } h3 { margin: 20px 0 8px; font-size: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); font-weight: 600; }
button, .btn { font: inherit; border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #7cc6c1; outline-offset: 1px; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.row > div { display: flex; flex-direction: column; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: #e8f1f2; color: #28535a; }
.badge.lab { background: #e5eefc; color: #1d4a8a; } .badge.doctor { background: #e8f5ec; color: #1b6b37; }
.badge.revoked, .badge.expired { background: #f6e4e2; color: var(--danger); } .badge.active { background: #e8f5ec; color: #1b6b37; }
.flag-H, .flag-HH { color: var(--hi); font-weight: 700; } .flag-L, .flag-LL { color: var(--lo); font-weight: 700; } .flag-N { color: var(--ok); }
.muted { color: var(--muted); font-size: 13px; } .empty { color: var(--muted); padding: 24px; text-align: center; }
.drop { border: 2px dashed #b7c8cc; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); background: #fafcfc; cursor: pointer; }
.drop.over { border-color: var(--accent); background: #eef8f7; }
.code { font: 700 28px ui-monospace, monospace; letter-spacing: .12em; background: #eef8f7; border: 1px solid #b8dedb; padding: 14px 18px; border-radius: 10px; display: inline-block; }
.error { color: var(--danger); } .actions { display: flex; gap: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #14272e; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; } #toast.err { background: var(--danger); }
.check { display: inline-flex; gap: 6px; align-items: center; margin: 0 12px 6px 0; font-size: 14px; color: var(--ink); }
@media (max-width: 640px) { .card { overflow-x: auto; } .top { padding: 10px 14px; } }

/* ---- auth, onboarding, admin */
.auth-wrap { display: grid; place-items: start center; padding-top: 4vh; }
.auth-card { width: 100%; max-width: 420px; padding: 26px; }
.stack { display: flex; flex-direction: column; gap: 12px; } .stack input { width: 100%; }
.wide { width: 100%; padding: 11px 14px; font-weight: 600; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0; }
.links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
button.link { border: 0; background: none; padding: 4px 0; color: var(--accent); text-decoration: underline; }
.notice { background: #eef8f7; border: 1px solid #b8dedb; padding: 10px 12px; border-radius: 8px; }
.devbox { margin-top: 16px; font-size: 13px; background: #fff8e6; border: 1px solid #ecd9a6; color: #5c4400; padding: 10px 12px; border-radius: 8px; word-break: break-word; }
code { font-family: ui-monospace, monospace; background: #eef2f3; padding: 1px 5px; border-radius: 4px; } code.key { font-size: 15px; letter-spacing: .08em; word-break: break-all; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.role-card { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 18px; border-radius: 12px; }
.role-card:hover { border-color: var(--accent); background: #f4fbfa; } .role-icon { font-size: 28px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; margin: 12px 0; } .facts dt { color: var(--muted); } .facts dd { margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #e8f1f2; color: var(--ink); border-radius: 99px; padding: 2px 4px 2px 10px; margin: 6px 4px 0 0; font-size: 13px; }
.chip .x { border: 0; background: none; padding: 0 6px; font-size: 16px; line-height: 1; color: var(--muted); }
a { color: var(--accent); }

/* ---- phone layout: bottom navigation, bigger touch targets, safe areas */
@media (max-width: 640px) {
  main { margin: 12px auto; padding: 0 10px calc(84px + env(safe-area-inset-bottom)); }
  .top { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); } .who-name { display: none; }
  button, input, select { min-height: 44px; } .chip .x, button.link { min-height: 0; }
  .row > div, .row > div > input, .row > div > select { width: 100%; } .row > button { width: 100%; }
  .tabs.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; margin: 0; background: var(--card); border-top: 1px solid var(--line); border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom); flex-wrap: nowrap; justify-content: space-around; gap: 0; }
  .tabs.bottom button { flex: 1; padding: 10px 2px; font-size: 12px; border-bottom: 0; border-top: 3px solid transparent; min-height: 56px; }
  .tabs.bottom button[aria-selected="true"] { border-color: var(--accent); }
  table { font-size: 13px; } .code { font-size: 22px; } #toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
