/* Clinic Care: an operator console. White navigation rail, quiet neutrals, one blue accent,
   status colours only for patient state, and a WhatsApp-faithful chat. */
:root {
  --page: #f6f7f9;
  --surface: #ffffff;
  --sunken: #f9fafb;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #eaecf0;
  --line-2: #d0d5dd;
  --brand: #2a78d6;
  --brand-hover: #256abf;
  --brand-soft: #eef4fd;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #eef0f3;
  --axis: #d0d5dd;
  --critical: #d03b3b;
  --critical-ink: #b42318;
  --critical-soft: #fef3f2;
  --warning: #fab219;
  --warning-ink: #93600a;
  --warning-soft: #fffaeb;
  --good: #0ca30c;
  --good-ink: #067647;
  --good-soft: #ecfdf3;
  --wa-green: #00a884;
  --wa-teal: #008069;
  --wa-bg: #efeae2;
  --wa-out: #d9fdd3;
  --wa-tick: #53bdeb;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 24px -4px rgba(16, 24, 40, 0.08), 0 8px 8px -4px rgba(16, 24, 40, 0.03);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ================= shell ================= */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.rail { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px 14px; min-height: 0; }
.logo { display: flex; align-items: center; gap: 10px; padding: 2px 10px 22px; }
.logo .mark { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #2a78d6, #1c5cab); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.logo b { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; display: block; line-height: 1.2; }
.logo span { font-size: 12px; color: var(--muted); display: block; line-height: 1.2; }
.nav { display: grid; gap: 2px; }
.nav .group { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a .badge { margin-left: auto; }
.rail .me { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 6px 0; display: flex; align-items: center; gap: 10px; }
.rail .me .who { flex: 1; min-width: 0; }
.rail .me b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .me span { display: block; font-size: 12px; color: var(--muted); }
.iconbtn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: none; display: grid; place-items: center; color: var(--muted); cursor: pointer; flex: none; }
.iconbtn:hover { background: var(--sunken); color: var(--ink); border-color: var(--line); }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.topbar .grow { flex: 1; }
.mode-pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--warning-soft); color: var(--warning-ink); border: 1px solid #fedf89; }
.mode-pill.live { background: var(--good-soft); color: var(--good-ink); border-color: #abefc6; }
.view { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.view.fill { overflow: hidden; display: flex; }
.content { padding: 24px 28px 48px; max-width: 1360px; margin: 0 auto; display: grid; gap: 20px; }

/* ================= common bits ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer; box-shadow: var(--shadow-sm); white-space: nowrap; }
.btn:hover { background: var(--sunken); color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--critical-ink); border-color: #fecdca; }
.btn.danger:hover { background: var(--critical-soft); }
.btn.ghost { border-color: transparent; box-shadow: none; background: none; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn.sm svg.i { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-sm); background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 14px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line-2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--sunken); color: var(--ink); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--critical); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.badge.soft { background: var(--sunken); color: var(--ink-2); border: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 650; flex: none; color: #fff; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; }
.card-head h2 { font-size: 15px; font-weight: 650; margin: 0; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-head .grow { flex: 1; }
.card-body { padding: 16px 20px 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 28px 16px; font-size: 14px; }
.empty svg.i { width: 28px; height: 28px; color: var(--faint); display: block; margin: 0 auto 8px; }

/* status labels: colour + icon + words, never colour alone */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px 2px 6px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.status svg.i { width: 13px; height: 13px; stroke-width: 2.2; }
.status.critical { background: var(--critical-soft); color: var(--critical-ink); border-color: #fecdca; }
.status.warning { background: var(--warning-soft); color: var(--warning-ink); border-color: #fedf89; }
.status.good { background: var(--good-soft); color: var(--good-ink); border-color: #abefc6; }
.status.neutral { background: var(--sunken); color: var(--ink-2); border-color: var(--line); }
.tag { font-size: 11px; color: var(--faint); font-weight: 500; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 100; font-size: 14px; max-width: min(520px, calc(100% - 32px)); }
.toast.error { background: var(--critical-ink); }

/* ================= overview ================= */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.015em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .grow { flex: 1; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); background: var(--critical-soft); border: 1px solid #fecdca; color: var(--critical-ink); font-weight: 600; }
.banner .grow { flex: 1; }
.banner .btn { box-shadow: none; }
.banner.warn { background: var(--warning-soft); border-color: #fedf89; color: var(--warning-ink); font-weight: 500; }
/* Auto-replies */
#ans { display: flex; flex-direction: column; gap: 16px; }
.kpis.tiers { grid-template-columns: repeat(4, minmax(0, 1fr)); }
table.data tr.off td { opacity: .55; }
table.data tr.editing td { background: var(--sunken); }
.ans-form { display: grid; gap: 10px; padding: 4px 0; }
.ans-opts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 14px; }
.ans-opts .grow { flex: 1; }
.ans-opts label { display: flex; align-items: center; gap: 6px; }
@media (max-width: 900px) { .kpis.tiers { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpis { display: grid; grid-template-columns: 1.35fr repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.kpi .value small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.kpi.hero .value { font-size: 52px; }
.kpi.hero { position: relative; overflow: hidden; }
.kpi .spark { margin-top: auto; }
.delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--critical-ink); }
.charts { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart text { font-family: var(--font); }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 140px; z-index: 5; transform: translate(-50%, -100%); white-space: nowrap; }
.tip b { display: block; font-size: 12px; margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tip .row span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tip .row strong { font-variant-numeric: tabular-nums; }
.linkbtn { background: none; border: 0; color: var(--brand); font-weight: 600; font-size: 13px; cursor: pointer; padding: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; background: var(--sunken); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover { background: #fafbfc; }
.tablewrap { overflow-x: auto; }
.attn { display: grid; grid-template-columns: minmax(0, 1fr); }
.attn a { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); color: inherit; }
.attn a:hover { background: #fafbfc; }
.attn .t { flex: 1; min-width: 0; }
.attn .t b { font-weight: 600; }
.attn .t p { margin: 2px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-who { display: flex; align-items: center; gap: 10px; }
.cell-who b { font-weight: 600; display: block; }

/* ================= inbox ================= */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr) 320px; flex: 1; min-height: 0; background: var(--surface); }
.inbox.no-profile { grid-template-columns: 340px minmax(0, 1fr); }
.convs { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.convs .tools { padding: 14px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; height: 36px; background: var(--surface); }
.search input { border: 0; outline: none; flex: 1; min-width: 0; font-size: 14px; background: none; }
.search svg.i { color: var(--faint); width: 16px; height: 16px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { background: var(--brand-soft); color: var(--brand); }
.tabs .badge { height: 18px; min-width: 18px; font-size: 10px; }
.convlist { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.conv:hover { background: #fafbfc; }
.conv.on { background: var(--brand-soft); }
.conv.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.conv .t { flex: 1; min-width: 0; }
.conv .top { display: flex; align-items: baseline; gap: 6px; }
.conv .top b { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .top time { font-size: 12px; color: var(--muted); flex: none; }
.conv.unread .top time { color: var(--wa-green); font-weight: 600; }
.conv .prev { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.conv .prev p { margin: 0; flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .prev p { color: var(--ink); font-weight: 500; }
.conv .unread-dot { min-width: 20px; height: 20px; border-radius: 999px; background: var(--wa-green); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.conv .flags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head { height: 64px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.thread-head .t { flex: 1; min-width: 0; }
.thread-head .t b { font-weight: 650; font-size: 15px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .t span { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .acts { display: flex; gap: 8px; align-items: center; flex: none; }
.btn.icon-only { width: 32px; padding: 0; }
.thread-head .back { display: none; }
.wall { flex: 1; overflow-y: auto; background: var(--wa-bg); padding: 16px 6%; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.wall::before { content: ""; }
.composer { flex: none; border-top: 1px solid var(--line); background: #f0f2f5; padding: 10px 14px 12px; display: grid; gap: 8px; }
.quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.quick button { flex: none; border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.quick button:hover { border-color: var(--brand); color: var(--brand); }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; font-size: 14px; min-height: 42px; max-height: 120px; background: var(--surface); line-height: 1.4; }
.composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.composer .send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--wa-green); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.composer .send svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.composer .note { font-size: 12px; color: var(--muted); }

.profile { border-left: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.profile .sec { padding: 18px 18px; border-bottom: 1px solid var(--line); }
.profile .id { text-align: center; }
.profile .id .avatar { margin: 0 auto 10px; }
.profile .id b { font-size: 16px; font-weight: 650; display: block; }
.profile h3 { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 10px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 500; }
.meds { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.meds li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.meds .pill { width: 28px; height: 28px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.meds .pill svg.i { width: 15px; height: 15px; }
.meds b { font-weight: 600; display: block; }
.steps { list-style: none; margin: 0; padding: 0; position: relative; }
.steps li { display: flex; gap: 12px; padding: 0 0 14px; position: relative; font-size: 13px; }
.steps li:not(:last-child)::before { content: ""; position: absolute; left: 9px; top: 22px; bottom: 2px; width: 2px; background: var(--line); }
.steps .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface); flex: none; display: grid; place-items: center; }
.steps .dot.done { background: var(--good); border-color: var(--good); color: #fff; }
.steps .dot.warn { background: var(--critical); border-color: var(--critical); color: #fff; }
.steps .dot svg.i { width: 12px; height: 12px; stroke-width: 3; }
.steps b { font-weight: 600; display: block; }
.pop { position: absolute; z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 14px; display: grid; gap: 10px; width: 260px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 400; color: var(--ink); background: var(--surface); width: 100%; box-shadow: var(--shadow-sm); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.field .filled { background: #fffbeb; border-color: #f5c451; }
::placeholder { color: var(--faint); opacity: 1; }

/* WhatsApp-style bubbles (shared by inbox and phone) */
.day-chip { align-self: center; background: #fff; color: #54656f; font-size: 12px; padding: 4px 10px; border-radius: 8px; margin: 10px 0 6px; box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13); }
.sys { align-self: center; max-width: 86%; text-align: center; font-size: 12px; padding: 5px 10px; border-radius: 8px; margin: 6px 0; display: inline-flex; gap: 6px; align-items: center; }
.sys svg.i { width: 14px; height: 14px; }
.sys.critical { background: #fde8e7; color: var(--critical-ink); }
.sys.warning { background: #fff4d6; color: var(--warning-ink); }
.sys.good { background: #e3f6e8; color: var(--good-ink); }
.sys.secure { background: #fff5c4; color: #54656f; }
.msg { max-width: min(78%, 520px); display: flex; flex-direction: column; margin-top: 2px; }
.msg.first { margin-top: 8px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
.msg .by { font-size: 11px; color: #667781; margin: 0 4px 2px; align-self: flex-end; }
.bubble { position: relative; padding: 6px 8px 8px 9px; border-radius: 8px; font-size: 14.2px; line-height: 19px; color: #111b21; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13); }
.msg.in .bubble { background: #fff; }
.msg.out .bubble { background: var(--wa-out); }
.msg.first.in .bubble { border-top-left-radius: 0; }
.msg.first.out .bubble { border-top-right-radius: 0; }
.msg.first.in .bubble::before { content: ""; position: absolute; top: 0; left: -8px; border-top: 0 solid transparent; border-right: 8px solid #fff; border-bottom: 13px solid transparent; }
.msg.first.out .bubble::before { content: ""; position: absolute; top: 0; right: -8px; border-left: 8px solid var(--wa-out); border-bottom: 13px solid transparent; }
.bubble .meta { float: right; margin: 6px 0 -5px 10px; font-size: 11px; color: #667781; display: inline-flex; align-items: center; gap: 3px; line-height: 15px; position: relative; top: 4px; }
.bubble .meta svg { width: 16px; height: 11px; }
.bubble .failed { color: var(--critical-ink); font-size: 12px; display: block; }
.wa-btns { display: grid; gap: 2px; margin-top: 2px; }
.wa-btns button, .wa-btns span { background: #fff; border: 0; border-radius: 8px; padding: 9px; font-size: 14px; color: #027eb5; font-weight: 500; text-align: center; box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13); display: flex; align-items: center; justify-content: center; gap: 6px; }
.wa-btns button { cursor: pointer; }
.wa-btns button:hover { background: #f7f8fa; }
.wa-btns button:disabled { color: #8696a0; cursor: default; }
.wa-btns svg { width: 16px; height: 16px; }
.inbox .wa-btns span { color: #8696a0; font-size: 13px; padding: 6px; }

/* ================= patients ================= */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chipbtn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.chipbtn.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ================= new visit ================= */
.visit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 20px; align-items: start; }
.drop { border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: var(--sunken); min-height: 340px; display: grid; place-items: center; text-align: center; padding: 24px; position: relative; overflow: hidden; cursor: pointer; }
.drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.drop .big { width: 56px; height: 56px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-md); display: grid; place-items: center; margin: 0 auto 14px; color: var(--brand); }
.drop .big svg.i { width: 26px; height: 26px; }
.drop b { font-size: 15px; display: block; }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #1d2939; }
.drop .scanning { position: absolute; inset: 0; background: rgba(16, 24, 40, 0.55); color: #fff; display: grid; place-items: center; font-weight: 600; }
.drop .scanning::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: #6bd5ff; box-shadow: 0 0 12px #6bd5ff; animation: scan 1.6s ease-in-out infinite; }
@keyframes scan { 0% { top: 8%; } 50% { top: 92%; } 100% { top: 8%; } }
.checks { margin: 0; padding: 10px 14px 10px 32px; background: #fffbeb; border: 1px solid #fedf89; border-radius: 8px; font-size: 13px; color: var(--warning-ink); }
.form { display: grid; gap: 14px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.days { display: flex; gap: 8px; flex-wrap: wrap; }
.days label { border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.days label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.days input { margin: 0; accent-color: var(--brand); }
.formmsg { font-size: 13px; min-height: 18px; }
.formmsg.error { color: var(--critical-ink); }
.formmsg.ok { color: var(--good-ink); }

/* ================= realistic phone ================= */
.stage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 36px; align-items: start; }
.device { width: 380px; height: 790px; background: #0b0b0c; border-radius: 54px; padding: 12px; box-shadow: 0 0 0 2px #2b2b2e, 0 30px 60px -12px rgba(16, 24, 40, 0.35); position: relative; flex: none; }
.device::after { content: ""; position: absolute; top: 24px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #1a1a1d; box-shadow: inset 0 0 0 2px #26262a; z-index: 5; }
.screen { width: 100%; height: 100%; border-radius: 42px; overflow: hidden; background: var(--wa-bg); display: flex; flex-direction: column; position: relative; }
.sbar { height: 38px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 6px 26px 0 30px; font-size: 13.5px; font-weight: 600; color: #111b21; background: #fff; }
.sbar .icons { display: flex; gap: 5px; align-items: center; }
.sbar svg { height: 13px; }
.wa-head { height: 58px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 6px 0 4px; background: #fff; border-bottom: 1px solid #e9edef; }
.wa-head .back { width: 32px; height: 40px; display: grid; place-items: center; color: #111b21; }
.wa-head .back svg { width: 22px; height: 22px; }
.wa-head .ava { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #2a78d6, #1c5cab); display: grid; place-items: center; flex: none; }
.wa-head .name { flex: 1; min-width: 0; padding-left: 6px; }
.wa-head .name b { display: flex; align-items: center; gap: 4px; font-size: 16px; font-weight: 600; color: #111b21; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-head .name span { display: block; font-size: 12.5px; color: #667781; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-head .name span.typing { color: var(--wa-green); font-weight: 500; }
.wa-head .acts { display: flex; gap: 2px; color: #111b21; }
.wa-head .acts svg { width: 22px; height: 22px; margin: 0 7px; }
.wa-wall { flex: 1; overflow-y: auto; padding: 8px 14px 6px; display: flex; flex-direction: column; gap: 2px; min-height: 0; background-color: var(--wa-bg); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23d9d2c5' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round' opacity='.75'%3E%3Ccircle cx='18' cy='20' r='7'/%3E%3Cpath d='M62 12l6 10h-12z'/%3E%3Cpath d='M98 18c4-6 12-2 8 4l-8 8-8-8c-4-6 4-10 8-4z'/%3E%3Crect x='12' y='62' width='14' height='10' rx='3'/%3E%3Cpath d='M56 62c6 0 10 4 10 10M50 74c0-8 6-14 14-14'/%3E%3Cpath d='M92 64l10 10M102 64l-10 10'/%3E%3Ccircle cx='30' cy='104' r='4'/%3E%3Cpath d='M62 98h14v10H62z M66 98v-4h6v4'/%3E%3Cpath d='M98 100c2-4 8-4 10 0s-4 8-5 9c-1-1-7-5-5-9z'/%3E%3C/g%3E%3C/svg%3E"); }
.wa-wall { scrollbar-width: none; }
.wa-wall::-webkit-scrollbar { display: none; }
.wa-wall .msg { max-width: 84%; }
.wa-wall .bubble { font-size: 14.5px; line-height: 19.5px; }
.wa-bar { flex: none; display: flex; gap: 6px; align-items: flex-end; padding: 6px 8px 10px; background: transparent; }
.wa-input { flex: 1; min-height: 46px; background: #fff; border-radius: 24px; display: flex; align-items: center; gap: 4px; padding: 0 12px; box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13); color: #8696a0; }
.wa-input svg { width: 22px; height: 22px; flex: none; }
.wa-input input { flex: 1; min-width: 0; border: 0; outline: none; font-size: 16px; padding: 10px 4px; background: none; color: #111b21; }
.wa-input input::placeholder { color: #8696a0; }
.wa-send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--wa-green); color: #fff; display: grid; place-items: center; flex: none; cursor: pointer; box-shadow: 0 1px 2px rgba(11, 20, 26, 0.2); }
.wa-send svg { width: 22px; height: 22px; }
.homebar { height: 22px; flex: none; display: grid; place-items: center; background: var(--wa-bg); }
.homebar i { width: 120px; height: 4px; border-radius: 4px; background: #111b21; opacity: 0.85; }
.typing-bubble { align-self: flex-start; background: #fff; border-radius: 8px; border-top-left-radius: 0; padding: 10px 12px; display: flex; gap: 4px; margin-top: 8px; box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13); }
.typing-bubble i { width: 7px; height: 7px; border-radius: 50%; background: #8696a0; animation: blink 1.2s infinite; }
.typing-bubble i:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
.pop-in { animation: popin 0.22s ease-out; }
@keyframes popin { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.side-panel { display: grid; gap: 16px; min-width: 0; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.controls select { height: 36px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; background: var(--surface); font-weight: 500; }
.live-alert { border-left: 4px solid var(--critical); }
.live-alert.warning { border-left-color: var(--warning); }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(208, 59, 59, 0.45); } 100% { box-shadow: 0 0 0 14px rgba(208, 59, 59, 0); } }
body.present .rail, body.present .topbar, body.present .presenter-only { display: none !important; }
body.present .app { grid-template-columns: 1fr; }
body.present .content { max-width: 1100px; padding-top: 32px; }

/* ================= login ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth .pitch { background: linear-gradient(160deg, #0d366b, #1c5cab 60%, #2a78d6); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .pitch h2 { font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 14px; max-width: 18ch; }
.auth .pitch p { color: #cde2fb; max-width: 44ch; font-size: 15px; margin: 0; }
.auth .formside { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth form { width: min(380px, 100%); display: grid; gap: 16px; }
.auth h1 { font-size: 24px; margin: 0; letter-spacing: -0.015em; }

/* ================= small screens ================= */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi.hero { grid-column: 1 / -1; }
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox .profile { display: none; }
  .inbox.show-profile .profile { display: block; position: absolute; right: 0; top: 60px; bottom: 0; width: 320px; background: var(--surface); box-shadow: var(--shadow-lg); z-index: 20; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .rail { order: 2; flex-direction: row; padding: 0 0 env(safe-area-inset-bottom, 0px); border-right: 0; border-top: 1px solid var(--line); }
  .rail .logo, .rail .me, .nav .group { display: none; }
  .nav { display: flex; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 8px 4px 6px; border-radius: 0; flex: 1; align-items: center; position: relative; }
  .nav a.active { background: none; }
  .nav a .badge { position: absolute; top: 4px; left: 50%; margin-left: 6px; height: 16px; min-width: 16px; font-size: 10px; }
  .topbar { padding: 0 16px; height: 54px; }
  .topbar .crumb { display: none; }
  .nav a span { white-space: nowrap; }
  .content { padding: 16px 16px 32px; }
  .charts, .split, .visit { grid-template-columns: minmax(0, 1fr); }
  .kpi.hero .value { font-size: 44px; }
  .inbox { grid-template-columns: 1fr; position: relative; }
  .inbox .thread { display: none; }
  .inbox.open .convs { display: none; }
  .inbox.open .thread { display: flex; }
  .thread-head .back { display: grid; }
  .thread-head .acts .btn span { display: none; }
  .wall { padding: 12px 10px; }
  .stage { grid-template-columns: 1fr; justify-items: center; }
  .device { transform: scale(0.92); transform-origin: top center; margin-bottom: -60px; }
  .auth { grid-template-columns: 1fr; }
  .auth .pitch { display: none; }
  .form .row3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 24px; }
  .form .row2, .form .row3 { grid-template-columns: 1fr; }
  .device { transform: scale(0.86); margin-bottom: -110px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ================= "see it live" sign-up (/try) ================= */
.auth.try { min-height: 100vh; min-height: 100dvh; }
.auth.try .pitch h2 { font-size: 30px; }
.try-points { margin: 18px 0 0; padding-left: 18px; color: #cde2fb; font-size: 15px; display: grid; gap: 8px; }
.try-form { width: min(460px, 100%) !important; gap: 14px !important; }
.try-head { display: grid; gap: 6px; }
.try-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.try-progress span { height: 4px; border-radius: 4px; background: var(--line-2); }
.try-progress span.on { background: var(--brand); }
.try-stepno { margin: 0; }
.try-step { border: 0; padding: 0; margin: 0; display: grid; gap: 14px; min-width: 0; }
.try-step[hidden] { display: none; }
.try-step legend { padding: 0; margin-bottom: 2px; display: grid; gap: 4px; }
.try-step legend h1 { font-size: 22px; }
.try-step legend .muted { font-size: 13px; }
.try-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span { display: inline-block; padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--ink); background: var(--surface); transition: background .12s, border-color .12s; }
.chips label:hover span { border-color: var(--brand); }
.chips input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-soft); }
.try-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; font-weight: 400; color: var(--ink-2); }
.try-consent input { margin-top: 2px; accent-color: var(--brand); }
.try-msg { margin: 0; min-height: 0; }
.try-msg:empty { display: none; }
.try-nav { display: flex; gap: 10px; }
.try-nav .btn { height: 44px; flex: 1; justify-content: center; }
.try-nav #try-back { flex: 0 0 auto; padding: 0 18px; }
.try-nav [hidden] { display: none; }
.try-signin { margin: 0; text-align: center; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
/* Without JavaScript every step shows, with plain submit. */
.try-form:not(.js) .try-progress, .try-form:not(.js) .try-stepno, .try-form:not(.js) #try-next, .try-form:not(.js) #try-back { display: none; }
@media (max-width: 900px) {
  .auth.try { grid-template-rows: auto 1fr; }
  .auth.try .pitch { display: block; padding: 14px 16px; }
  .auth.try .pitch h2 { font-size: 18px; margin: 8px 0 0; max-width: none; }
  .auth.try .pitch > p, .auth.try .try-points { display: none; }
  .auth.try .formside { place-items: start center; padding: 16px; }
  .try-step legend h1 { font-size: 20px; }
}
@media (max-width: 340px) { .try-row { grid-template-columns: 1fr; } }

/* ================= public demo: "try it as a patient" strip ================= */
.try-strip { display: flex; align-items: center; gap: 14px; padding: 10px 28px; background: #e8f5ee; border-bottom: 1px solid #b7e2c8; flex: none; }
.try-strip[hidden] { display: none; }
.try-strip p { margin: 0; font-size: 13.5px; color: #14532d; flex: 1; line-height: 1.45; }
.try-strip p a { color: inherit; font-weight: 600; }
.try-strip .btn { flex: none; background: #1f9d55; border-color: #1f9d55; white-space: nowrap; }
.mode-pill { white-space: nowrap; }
@media (max-width: 900px) {
  .try-strip { padding: 8px 12px; gap: 10px; }
  .try-strip p { font-size: 12.5px; }
  .try-strip .btn { height: 34px; padding: 0 12px; font-size: 13px; }
}
.composer[hidden] { display: none; }
.viewonly-note { flex: none; padding: 10px 16px; font-size: 12.5px; color: var(--muted); background: var(--surface-2, #f6f7f9); border-top: 1px solid var(--line); }

/* ================= phone layout for overview cards ================= */
@media (max-width: 600px) {
  /* Legend sits under the chart title instead of squeezing it */
  .card-head { flex-wrap: wrap; }
  .card-head .legend { flex-basis: 100%; gap: 6px 14px; }
  .card-head:has(.legend) .grow { display: none; }
  /* Needs attention: badge and time stack on the right, patient words truncate */
  .attn a { padding: 12px 16px; gap: 10px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; }
  .attn a > .avatar { grid-row: 1 / 3; align-self: center; }
  .attn a .t { grid-row: 1 / 3; align-self: center; }
  .attn a .status { grid-column: 3; grid-row: 1; justify-self: end; align-self: end; }
  .attn a .muted.small { grid-column: 3; grid-row: 2; justify-self: end; align-self: start; font-size: 11.5px; }
  .card-head { padding: 14px 16px 0; }
}
