/* Family Privilege Card (Sri Sri Holistic Hospitals colours) — shared tokens and components (family pages and staff app) */

:root {
  --brand: #11456A;
  --brand-ink: #0B3350;
  --brand-soft: #E6F4EC;
  --teal: #1C8A93;
  --green: #63B45A;
  --bg: #F6F8F7;
  --surface: #FFFFFF;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #5B6472;
  --line: #E5E7EB;
  --line-strong: #CBD0D6;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --ok: #15803D;
  --ok-soft: #DCFCE7;
  --err: #B91C1C;
  --err-soft: #FEE2E2;
  --gold: #FDE68A;
  --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);
  --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%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); min-height: 100vh; overflow-wrap: break-word; }
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; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); outline: 2px solid transparent; border-radius: 6px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: .04em; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: 520px; margin: 0 auto; padding: 16px 16px 72px; }
.container-wide { max-width: 1120px; padding: 20px 20px 72px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-between { justify-content: space-between; }
.app-header { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar { max-width: 520px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 16px; min-height: 56px; }
.topbar-wide { max-width: 1120px; padding: 6px 20px; flex-wrap: wrap; }
.brand { 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); white-space: nowrap; }
.brand-logo { height: 36px; width: auto; }
.poster-logo { height: 64px; width: auto; margin: 0 auto 10px; }
.brand-sub { font-weight: 700; font-size: 14px; color: var(--brand-ink) !important; color: var(--muted); border-left: 1px solid var(--line); padding-left: 8px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; margin-left: 12px; }
.nav-link { display: inline-flex; align-items: center; 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 { color: var(--ink-2); font-size: 14px; }
@media (max-width: 720px) { .nav { order: 3; flex-basis: 100%; margin-left: 0; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; } .nav-link { white-space: nowrap; } }

.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; }
.section-title { font-size: 18px; font-weight: 700; }
.loading-line { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 32px 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- 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; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { 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: #F1F8F4; }
.btn-ghost { background: transparent; color: var(--brand-ink); }
.btn-ghost:hover:not(:disabled) { background: rgba(17, 69, 106, .08); }
.btn-danger-text { color: var(--err); }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 15px; }
.btn-lg { min-height: 54px; font-size: 17px; }
.btn-block { display: flex; width: 100%; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel > .section-title { margin-bottom: 12px; }
.notice { border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid var(--line); background: var(--surface); }
.notice-ok { background: var(--ok-soft); border-color: #86EFAC; color: #14532D; }
.notice-warn { background: var(--warn-soft); border-color: #FCD34D; color: #713F12; }
.notice-err { background: var(--err-soft); border-color: #FCA5A5; color: #7F1D1D; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--line); color: var(--ink-2); white-space: nowrap; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-err { background: var(--err-soft); color: var(--err); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-brand { background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- forms ---------- */
.field { display: block; }
.field-label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 5px; }
.field-label .opt { font-weight: 400; color: var(--muted); font-size: 13px; }
.input { display: block; width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
textarea.input { min-height: 84px; resize: vertical; }
.input:focus-visible { border-color: #1D4ED8; }
.field.has-error .input { border-color: var(--err); background: #FFFBFB; }
.field-error { color: var(--err); font-size: 14px; margin-top: 4px; }
.field-hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 380px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 15px; }
.check:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.consent { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.consent input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.member-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface); }
.member-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.member-no { font-weight: 700; color: var(--brand-ink); }
details.more { border-top: 1px dashed var(--line-strong); margin-top: 12px; padding-top: 4px; }
details.more > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--brand-ink); font-weight: 600; }
details.more[open] > summary { margin-bottom: 6px; }

/* ---------- the virtual card ---------- */
.vcard { position: relative; overflow: hidden; border-radius: 18px; padding: 20px; color: #fff; background: linear-gradient(135deg, #11456A 0%, #0B3350 62%, #1C8A93 135%); border-bottom: 6px solid var(--green); box-shadow: 0 10px 30px rgba(17, 69, 106, .35); }
.vcard-logo { display: inline-block; background: #fff; border-radius: 10px; padding: 6px 10px; position: relative; z-index: 1; }
.vcard-logo img { height: 34px; width: auto; }
.vcard-title { margin-top: 12px; }
.vcard-hospital, .vcard-label, .vcard-issued { color: #CFE0EA; }
.vcard::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .07); pointer-events: none; }
.vcard-hospital { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-soft); }
.vcard-title { font-size: 20px; font-weight: 750; margin-top: 2px; }
.vcard-body { display: flex; gap: 14px; align-items: flex-end; justify-content: space-between; margin-top: 18px; }
.vcard-no { font-family: var(--mono); font-size: 24px; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.vcard-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-soft); margin-top: 12px; }
.vcard-value { font-size: 16px; font-weight: 650; }
.vcard-meta { display: flex; gap: 22px; }
.vcard-qr { flex: none; width: 116px; height: 116px; padding: 6px; border-radius: 10px; background: #fff; position: relative; z-index: 1; }
.vcard-qr img { width: 100%; height: 100%; }
.vcard.is-off { filter: grayscale(1); opacity: .8; }
@media (max-width: 380px) { .vcard-no { font-size: 20px; } .vcard-qr { width: 96px; height: 96px; } }

.benefit { display: flex; gap: 12px; align-items: center; }
.benefit + .benefit { margin-top: 12px; }
.screen-title { color: var(--brand-ink); }
.benefit-pct { flex: none; min-width: 68px; padding: 8px 6px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand-ink); font-size: 20px; font-weight: 800; text-align: center; }
.benefit-label { font-weight: 700; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; padding-top: 0; }

/* ---------- staff app ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 720px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-num { font-size: 28px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-link { cursor: pointer; }
.table tr.is-link:hover td { background: #F1F8F4; }
.table th.num { text-align: right; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.calc { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg); }
.calc .total { font-weight: 750; font-size: 18px; }
.poster { text-align: center; }
.poster-qr { width: 260px; height: 260px; margin: 14px auto; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }

.toast-host { position: fixed; left: 0; right: 0; bottom: 16px; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); max-width: 100%; }
.toast-err { background: var(--err); }

@media print {
  .app-header, .no-print, .toast-host { display: none !important; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
  .panel { box-shadow: none; border: 0; }
  .vcard { -webkit-print-color-adjust: exact; print-color-adjust: exact; box-shadow: none; }
}

.vcard-issued { font-size: 13px; color: var(--brand-soft); margin-top: 2px; }

/* ---------- AI poster designer ---------- */
.designer { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .designer { grid-template-columns: 1fr; } }
.designer-chat { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 72px; }
@media (max-width: 900px) { .designer-chat { position: static; } }
.chat-log { display: flex; flex-direction: column; gap: 8px; min-height: 220px; max-height: 52vh; overflow-y: auto; padding: 4px 2px; }
.chat-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; }
.chat-assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-pending { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea { min-height: 48px; resize: none; }
.chat-quick:empty { display: none; }
.version-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.version-strip:empty { display: none; }
.version-chip { display: flex; flex-direction: column; align-items: flex-start; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-weight: 700; }
.version-chip span { font-weight: 400; font-size: 12px; color: var(--muted); }
.version-chip.is-current { border-color: var(--brand); background: var(--brand-soft); }
.poster-stage { max-width: 640px; margin: 0 auto; }
.poster-empty { aspect-ratio: 210 / 297; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 32px; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }

/* The sheet: every size inside is in cqw (1% of the sheet's width), so screen, A4 and A3 look the same. */
.poster-sheet { --navy: #11456A; --navy2: #0B3350; --accent: #63B45A; --accent-ink: #0B3350;
  container-type: inline-size; aspect-ratio: 210 / 297; width: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: #0F1F2B; border: 1px solid var(--line); box-shadow: var(--shadow); font-family: var(--font); }
.ps-accent-teal { --accent: #1C8A93; --accent-ink: #fff; }
.ps-accent-gold { --accent: #F2B33D; --accent-ink: #3A2A00; }
.ps-logo { height: 9cqw; width: auto; }
.ps-logo-chip { display: inline-block; align-self: flex-start; background: #fff; border-radius: 1.6cqw; padding: 1.4cqw 2.2cqw; }
.ps-top { padding: 4cqw 7cqw 0; display: flex; justify-content: center; }
.ps-top .ps-logo { height: 9.5cqw; }
.ps-card-name { font-size: 2.4cqw; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin-top: 2.2cqw; }
.ps-headline { font-size: 7.2cqw; line-height: 1.05; font-weight: 800; letter-spacing: -.01em; color: var(--navy2); margin: 1.2cqw 0 0; }
.ps-sub { font-size: 3.1cqw; line-height: 1.3; color: #4A5B66; margin-top: 1.6cqw; }
.ps-rest { flex: 1; display: flex; flex-direction: column; padding: 0 7cqw 3cqw; min-height: 0; overflow: hidden; }
.ps-classic .ps-rest { text-align: center; align-items: center; }
.ps-offers { display: flex; flex-wrap: wrap; gap: 2cqw; margin-top: 3cqw; }
.ps-classic .ps-offers { justify-content: center; }
.ps-offer { display: flex; align-items: center; gap: 2cqw; background: var(--accent); color: var(--accent-ink); border-radius: 2cqw; padding: 1.4cqw 2.6cqw; }
.ps-offer-pct { font-size: 5.8cqw; font-weight: 800; line-height: 1; display: flex; align-items: baseline; gap: .8cqw; }
.ps-offer-pct span { font-size: 1.9cqw; letter-spacing: .08em; }
.ps-offer-label { font-size: 2.7cqw; font-weight: 700; line-height: 1.15; max-width: 22cqw; text-align: left; }
.ps-bullets { list-style: none; margin: 3cqw 0 0; padding: 0; text-align: left; display: grid; gap: 1.3cqw; }
.ps-bullets li { position: relative; padding-left: 4.6cqw; font-size: 3.05cqw; line-height: 1.25; font-weight: 600; }
.ps-bullets li::before { content: ""; position: absolute; left: 0; top: .6cqw; width: 2.5cqw; height: 2.5cqw; border-radius: 50%; background: var(--accent); }
.ps-qrbox { margin-top: auto; padding-top: 2.4cqw; display: flex; align-items: center; gap: 4cqw; align-self: stretch; }
.ps-classic .ps-qrbox { flex-direction: column; gap: 1.6cqw; }
.ps-qr { flex: none; width: 26cqw; height: 26cqw; padding: 1.4cqw; background: #fff; border: .5cqw solid var(--navy); border-radius: 2.4cqw; }
.ps-qr img { width: 100%; height: 100%; }
.ps-cta { font-size: 3.6cqw; line-height: 1.2; font-weight: 800; color: var(--navy2); }
.ps-footer { background: var(--navy2); color: #CFE0EA; padding: 2.2cqw 7cqw; display: flex; justify-content: space-between; gap: 3cqw; font-size: 2.4cqw; border-bottom: 1.4cqw solid #63B45A; }
.ps-band { background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%); padding: 4.5cqw 7cqw 4.5cqw; display: flex; flex-direction: column; }
.ps-band .ps-headline, .ps-side .ps-headline { color: #fff; }
.ps-band .ps-sub, .ps-side .ps-sub { color: #D5E6EE; }
.ps-band .ps-headline { font-size: 8.2cqw; }
.ps-bold .ps-qrbox { padding-top: 1.6cqw; }
.ps-cols { flex: 1; display: grid; grid-template-columns: 46% 54%; min-height: 0; }
.ps-side { background: linear-gradient(160deg, var(--navy) 0%, var(--navy2) 100%); padding: 6cqw 5cqw; display: flex; flex-direction: column; }
.ps-side .ps-headline { font-size: 6.4cqw; }
.ps-side .ps-offer-label { max-width: 20cqw; }
.ps-main { overflow: hidden; }
.ps-main .ps-bullets li { font-size: 3.2cqw; }
.ps-side .ps-offers { flex-direction: column; margin-top: auto; padding-top: 4cqw; }
.ps-main { padding: 6cqw 5cqw 4cqw; display: flex; flex-direction: column; }
.ps-main .ps-bullets { margin-top: 0; }
.ps-main .ps-qrbox { flex-direction: column; align-items: flex-start; gap: 2.4cqw; }
.ps-main .ps-qr { width: 32cqw; height: 32cqw; }

@media print {
  body:has(.poster-sheet) { margin: 0; }
  body:has(.poster-sheet) main { padding: 0; max-width: none; }
  body:has(.poster-sheet) .designer, body:has(.poster-sheet) .stack > * + * { display: block; margin: 0; }
  .poster-stage { max-width: none; margin: 0; }
  .poster-sheet { width: 100vw; height: 100vh; aspect-ratio: auto; border: 0; box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- home page: registration QR ---------- */
.home-register { display: flex; gap: 16px; align-items: center; }
.home-qr { flex: none; width: 150px; height: 150px; padding: 8px; background: #fff; border: 2px solid var(--brand); border-radius: var(--radius); }
.home-qr img { width: 100%; height: 100%; }
@media (max-width: 420px) { .home-register { flex-direction: column; text-align: center; } }

.input[readonly] { background: var(--bg); color: var(--ink-2); }
.ps-side { min-width: 0; }
.ps-side .ps-offer { padding: 1.2cqw 2cqw; gap: 1.4cqw; }
.ps-side .ps-offer-pct { font-size: 4.8cqw; }
.ps-side .ps-offer-label { font-size: 2.4cqw; max-width: 16cqw; }
