/* WHapp — styles. Tokens mirror worldhealthapp.com (DM Sans, red-600 primary,
   white + gray-50 surfaces, gray-950 headings, pill buttons, 16px cards).
   Logical properties throughout so RTL works by flipping `dir`. */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* Surfaces & neutrals (Tailwind gray scale, as on the site) */
  --paper: #FFFFFF; --surface: #FFFFFF; --surface-2: #F9FAFB; --surface-3: #F3F4F6;
  --ink: #030712; --ink-2: #4B5563; --ink-3: #6B7280;
  --line: #F3F4F6; --line-2: #E5E7EB; --line-3: #D1D5DB;
  /* Brand */
  --red: #DC2626; --red-700: #B91C1C; --red-50: #FEF2F2; --red-100: #FEE2E2; --red-ink: #991B1B;
  --amber: #D97706; --amber-50: #FFFBEB; --amber-ink: #92400E;
  --green: #059669; --green-50: #ECFDF5; --green-ink: #065F46;
  --cyan: #22B8CF; --cyan-50: #ECFEFF;
  --focus: #DC2626;
  --radius: 16px; --radius-s: 8px; --pill: 9999px;
  --shadow-sm: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1);
  --shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 4px 6px -1px rgba(0,0,0,.1);
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --fs-0: 0.875rem; --fs-1: 1rem; --fs-2: 1.25rem; --fs-3: 1.5rem; --fs-4: 2rem; --fs-5: 3rem;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.5; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.025em; color: var(--ink); }
h1 { font-size: var(--fs-4); } h2 { font-size: var(--fs-3); } h3 { font-size: var(--fs-2); letter-spacing: -0.01em; } h4 { font-size: var(--fs-1); font-weight: 600; letter-spacing: 0; }
p { margin: 0 0 .75em; max-width: 68ch; }
a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 2px; }
small, .muted { color: var(--ink-3); font-size: var(--fs-0); }
.quiet { color: var(--ink-3); }
.lede { color: var(--ink-3); font-weight: 300; font-size: 1.125rem; line-height: 1.6; }
.eyebrow { display: block; font-size: 12px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--red); margin-bottom: 14px; }
ul, ol { padding-inline-start: 1.25em; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; background: var(--surface-3); padding: 0 .3em; border-radius: 4px; }

/* Focus and motion */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--pill); z-index: 100; }
.skip:focus { top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* App shell */
.shell { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; display: block; }
.topbar .grow { flex: 1; }
.passport { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border: 1px solid var(--line-3); border-radius: var(--pill); background: #fff; color: var(--ink-2); font: inherit; font-size: var(--fs-0); font-weight: 500; cursor: pointer; transition: border-color .2s; }
.passport:hover { border-color: var(--ink-3); color: var(--ink); }
.passport b { font-weight: 600; color: var(--ink); }
.passport .arrow { color: var(--red); }
.passport.travelling { border-color: var(--red); background: var(--red-50); }
.body { display: grid; grid-template-columns: 240px 1fr; }
.sidenav { border-inline-end: 1px solid var(--line); padding: 20px 12px; background: var(--surface-2); }
.sidenav .who { padding: 4px 12px 18px; }
.sidenav .who b { display: block; font-weight: 600; }
.sidenav .who span { color: var(--ink-3); font-size: var(--fs-0); }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--pill); color: var(--ink-2); font-size: var(--fs-0); font-weight: 500; text-decoration: none; min-height: 44px; transition: color .15s, background .15s; }
.sidenav a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.sidenav a:hover { color: var(--ink); }
.sidenav .badge-n { margin-inline-start: auto; }
main { padding: 32px clamp(16px, 4vw, 40px) 96px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--ink-3); font-weight: 300; }
@media (max-width: 860px) {
  .body { grid-template-columns: 1fr; }
  .sidenav { position: fixed; bottom: 0; inset-inline: 0; border-inline-end: 0; border-top: 1px solid var(--line-2); padding: 6px; display: flex; overflow-x: auto; gap: 2px; z-index: 20; background: #fff; }
  .sidenav .who { display: none; }
  .sidenav a { flex: 1 0 auto; flex-direction: column; gap: 2px; padding: 8px 10px; font-size: .75rem; text-align: center; min-width: 72px; border-radius: var(--radius-s); }
  .sidenav a[aria-current="page"] { box-shadow: none; background: var(--red-50); color: var(--red-ink); }
  .sidenav .badge-n { margin: 0; }
  .passport .label { display: none; }
  .topbar { padding: 0 16px; }
}

/* Buttons — pill, as on the site */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 24px; border-radius: var(--pill); border: 1px solid var(--red); background: var(--red); color: #fff; font: inherit; font-size: var(--fs-0); font-weight: 600; cursor: pointer; text-decoration: none; transition: background .2s, border-color .2s, color .2s; }
.btn:hover { background: var(--red-700); border-color: var(--red-700); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--ink-2); border-color: var(--line-3); }
.btn.secondary:hover { background: transparent; border-color: var(--ink-3); color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--red); padding-inline: 12px; }
.btn.ghost:hover { background: var(--red-50); border-color: transparent; }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.emergency { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.btn.emergency:hover { background: #1F2937; border-color: #1F2937; }
.btn.small { min-height: 36px; padding: 6px 16px; font-size: .8125rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Cards and panels */
.card { background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 14px; }
.card h3 { margin-top: 0; }
.card.bar { border-inline-start: 4px solid var(--red); }
.card.bar.amber { border-inline-start-color: var(--amber); }
.card.bar.red { border-inline-start-color: var(--red); background: var(--red-50); border-color: var(--red-100); border-inline-start-color: var(--red); }
.card.bar.mint { border-inline-start-color: var(--green); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.notice { padding: 14px 18px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); }
.notice.amber { background: var(--amber-50); color: var(--amber-ink); border-color: #FDE68A; }
.notice.red { background: var(--red-50); color: var(--red-ink); border-color: var(--red-100); }
.notice.mint { background: var(--green-50); color: var(--green-ink); border-color: #A7F3D0; }
.notice.teal { background: var(--cyan-50); color: #155E75; border-color: #A5F3FC; }
.notice p:last-child { margin-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }

/* Chips, badges, status */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: var(--pill); border: 1px solid var(--line-2); background: #fff; font-size: .8125rem; font-weight: 500; color: var(--ink-2); }
.chip.mint { background: var(--green-50); color: var(--green-ink); border-color: transparent; }
.chip.amber { background: var(--amber-50); color: var(--amber-ink); border-color: transparent; }
.chip.red { background: var(--red-50); color: var(--red-ink); border-color: transparent; }
.chip.grey { background: var(--surface-3); color: var(--ink-2); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge-n { display: inline-flex; min-width: 22px; height: 22px; padding: 0 6px; align-items: center; justify-content: center; border-radius: var(--pill); background: var(--red); color: #fff; font-size: .75rem; font-weight: 700; }
.status { font-weight: 600; font-size: var(--fs-0); }
.status.active, .status.accepted, .status.completed, .status.settled, .status.approved, .status.attested, .status.verified, .status.acknowledged, .status.released, .status.delivered { color: var(--green-ink); }
.status.expired, .status.used, .status.requested, .status.pending, .status.submitted, .status.held, .status.notified, .status.reported, .status.scheduled { color: var(--amber-ink); }
.status.revoked, .status.declined, .status.cancelled, .status.rejected { color: var(--red-ink); }

/* Forms */
label { display: block; font-weight: 500; font-size: var(--fs-0); margin-bottom: 6px; color: var(--ink); }
.field { margin-bottom: 16px; }
.field .hint { font-weight: 300; color: var(--ink-3); font-size: var(--fs-0); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=number], input[type=search], input[type=tel], select, textarea { width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-3); border-radius: var(--radius-s); background: #fff; color: var(--ink); font: inherit; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--red); outline: none; box-shadow: 0 0 0 3px rgba(220,38,38,.12); }
textarea { min-height: 96px; resize: vertical; }
.check { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: #fff; cursor: pointer; font-weight: 500; font-size: var(--fs-0); min-height: 48px; transition: border-color .15s, background .15s; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--red); }
.check .sub { display: block; color: var(--ink-3); font-size: .8125rem; font-weight: 300; }
.check:has(input:checked) { border-color: var(--red); background: var(--red-50); }
.checks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.segmented { display: inline-flex; border: 1px solid var(--line-3); border-radius: var(--pill); overflow: hidden; background: #fff; }
.segmented button { font: inherit; font-size: var(--fs-0); font-weight: 500; border: 0; background: transparent; color: var(--ink-2); padding: 9px 18px; min-height: 42px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 600; }
.form-error { color: var(--red-ink); background: var(--red-50); border: 1px solid var(--red-100); padding: 10px 14px; border-radius: var(--radius-s); margin-bottom: 12px; font-size: var(--fs-0); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-0); }
th, td { text-align: start; padding: 12px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { color: var(--ink-3); font-weight: 600; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.table-wrap { overflow-x: auto; }

/* Consent matrix — the centrepiece */
.matrix { overflow-x: auto; }
.matrix table { border-collapse: separate; border-spacing: 3px; font-size: .8125rem; }
.matrix th { border: 0; padding: 4px 6px; white-space: nowrap; text-transform: none; letter-spacing: 0; font-size: .8125rem; }
.matrix thead th { writing-mode: vertical-rl; transform: rotate(180deg); text-align: start; height: 140px; font-weight: 500; color: var(--ink-3); padding: 0 4px; }
.matrix thead th:first-child { writing-mode: horizontal-tb; transform: none; height: auto; }
.matrix td { border: 0; padding: 0; }
.matrix .cell { display: block; width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--line-3); background: #fff; }
.matrix .who { text-align: start; font-weight: 600; white-space: nowrap; color: var(--ink); }
.matrix .who small { display: block; font-weight: 400; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8125rem; color: var(--ink-3); margin-top: 10px; }
.legend .cell { display: inline-block; border: 1.5px solid var(--line-3); background: #fff; width: 16px; height: 16px; vertical-align: -3px; margin-inline-end: 6px; border-radius: 4px; }

/* Timeline (audit) */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-2); font-size: var(--fs-0); }
.timeline time { color: var(--ink-3); }
.timeline .act { font-weight: 600; }
.timeline .denied .act { color: var(--red-ink); }
.timeline .emergency .act { color: var(--red-ink); }
@media (max-width: 600px) { .timeline li { grid-template-columns: 1fr; gap: 2px; } }

/* Scope banner (provider) */
.scope { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--line-2); background: #fff; box-shadow: var(--shadow-sm); }
.scope .can h4 { color: var(--green-ink); } .scope .cannot h4 { color: var(--ink-3); }
.scope ul { margin: 0; padding-inline-start: 1.1em; font-size: var(--fs-0); }
@media (max-width: 600px) { .scope { grid-template-columns: 1fr; } }

/* Boundary panel (employer / family) */
.boundary { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: var(--line-2); }
.boundary > div { padding: 18px 20px; background: #fff; }
.boundary .can { background: var(--green-50); color: var(--green-ink); }
.boundary .cannot { background: var(--surface-2); }
.boundary ul { margin: 6px 0 0; padding-inline-start: 1.1em; font-size: var(--fs-0); }
@media (max-width: 600px) { .boundary { grid-template-columns: 1fr; } }

/* Provider result */
.provider { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.provider .name { font-size: var(--fs-2); font-weight: 700; margin: 0; }
.assurance { font-size: .8125rem; margin-top: 8px; }
.assurance .ok { color: var(--green-ink); } .assurance .no { color: var(--ink-3); }
.slots { display: flex; gap: 8px; flex-wrap: wrap; }
.slot { font: inherit; font-size: .8125rem; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line-3); border-radius: 10px; background: #fff; color: var(--ink); cursor: pointer; }
.slot[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Dialog / sheet */
dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(720px, 94vw); width: 100%; background: #fff; color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(3,7,18,.45); }
dialog .dlg { padding: 24px 28px; max-height: 85vh; overflow: auto; }
dialog header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
dialog header h2 { margin: 0; }
.x { font: inherit; background: transparent; border: 0; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; color: var(--ink-2); font-size: 1.4rem; }
.x:hover { background: var(--surface-3); }

/* Toast */
.toasts { position: fixed; inset-inline-end: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: 420px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: var(--fs-0); }
.toast.err { background: var(--red); color: #fff; }
@media (max-width: 860px) { .toasts { bottom: 80px; } }

/* Sign-in — hero in the site's style */
.signin { max-width: 1152px; margin: 0 auto; padding: 48px 24px; display: grid; gap: 48px; grid-template-columns: minmax(300px, 460px) 1fr; }
.signin h1 { font-size: var(--fs-5); line-height: 1.04; letter-spacing: -0.025em; margin-bottom: 20px; }
.signin h1 .accent { color: var(--red); display: block; }
.signin .lede { max-width: 34ch; margin-bottom: 28px; }
.signin .card { padding: 26px 28px; }
.personas { display: grid; gap: 8px; }
.persona { text-align: start; font: inherit; background: #fff; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 16px; cursor: pointer; color: var(--ink); display: grid; gap: 2px; transition: border-color .2s; }
.persona:hover { border-color: var(--ink-3); }
.persona b { font-weight: 600; font-size: var(--fs-0); }
.persona small { color: var(--ink-3); font-weight: 300; font-size: .8125rem; }
.persona-group h3 { margin: 22px 0 10px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
@media (max-width: 860px) { .signin { grid-template-columns: 1fr; padding: 28px 16px; } .signin h1 { font-size: 2.25rem; } }

/* Emergency sheet */
.em-numbers { display: flex; gap: 12px; flex-wrap: wrap; }
.em-number { background: var(--red); color: #fff; border-radius: var(--radius); padding: 16px 22px; text-decoration: none; display: grid; min-width: 140px; }
.em-number b { font-size: var(--fs-4); line-height: 1; letter-spacing: -0.02em; }
.em-number span { font-size: .8125rem; opacity: .9; margin-top: 4px; }

/* Jurisdiction switch summary */
.switch-list { list-style: none; padding: 0; margin: 0; }
.switch-list li { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); align-items: start; font-size: var(--fs-0); }
.switch-list .reason { grid-column: 1 / -1; color: var(--ink-3); font-weight: 300; }

/* Misc */
.empty { padding: 32px; text-align: center; color: var(--ink-3); font-weight: 300; border: 1px dashed var(--line-3); border-radius: var(--radius); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: 18px; overflow-x: auto; }
.tabs button { font: inherit; font-size: var(--fs-0); font-weight: 500; background: transparent; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 10px 14px; min-height: 44px; cursor: pointer; color: var(--ink-3); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--red); font-weight: 600; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 60px; }
.spark span { flex: 1; background: var(--red); opacity: .7; border-radius: 2px 2px 0 0; min-width: 3px; }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.num { font-variant-numeric: tabular-nums; }
.big { font-size: var(--fs-4); font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
[dir="rtl"] .matrix thead th { transform: rotate(180deg) scaleX(-1); }

/* Cell colours (matrix and legend) */
.cell.on { background: var(--red) !important; border-color: var(--red) !important; }
.cell.soon { background: var(--amber) !important; border-color: var(--amber) !important; }
.cell.events { background: repeating-linear-gradient(135deg, var(--red) 0 4px, #fff 4px 8px) !important; border-color: var(--red) !important; }

tr.needs-review td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
