/* The Care OS console's look (D:\Care-OS\web\templates\base.html): its colours, Inter, the
   teal gradient sidebar, the white sticky topbar, a 6px control radius against a 12px surface
   radius, 24px of air inside a card. Taken by VALUE so the two consoles read as one family. */
@font-face { font-family: Inter; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+20B9,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: Inter; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  --ink: #16232b; --muted: #5b6b73; --line: #d7dee2; --bg: #f5f7f8; --accent: #0f5c6e; --danger: #a3261b;
  --hair: #e8edf0; --accent-soft: #e9f1f3; --accent-ink: #0c4a59; --field: #fff; --card: #fff;
  --good: #1e6b3f; --good-soft: #e5f4ea; --warn-ink: #7a5300; --warn-soft: #fff6e0; --warn-line: #f0d58a;
  --bad-soft: #fbe8e6;
  --r-xs: 4px; --r-sm: 6px; --r: 12px; --r-pill: 999px;
  --sh-1: 0 4px 30px rgba(15,92,110,.10); --sh-2: 0 6px 20px rgba(22,35,43,.09);
  --pad: 24px; --gap: 16px;
  --side: #0b4554; --side-2: #0f5c6e; --side-ink: #d6e7ec; --side-muted: #8fb3bd; --side-w: 240px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 13px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased; }
h1 { font-size: 19px; font-weight: 700; letter-spacing: -.2px; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 700; letter-spacing: -.1px; }
.card h2 { margin: 0 0 12px; font-size: 14.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
:where(main a) { color: var(--accent); text-decoration: none; font-weight: 500; }
:where(main a):hover { text-decoration: underline; text-underline-offset: 2px; }
.ico { flex: 0 0 auto; }

/* ── app shell ── */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 30; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--side-2) 0%, var(--side) 100%); color: var(--side-ink); overflow-y: auto;
  transition: transform .18s ease, visibility .18s; }
.sidebar .brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar .brand strong { display: block; font-size: 16px; letter-spacing: .2px; }
.sidebar .brand small { display: block; font-size: 12px; color: var(--side-muted); line-height: 1.3; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.14); }
nav.menu { display: block; padding: 10px 10px 24px; }
nav.menu a { display: flex; gap: 10px; align-items: center; padding: 7px 12px; margin: 1px 0; border-radius: var(--r-sm);
  color: var(--side-ink); text-decoration: none; font-weight: 500; font-size: 14px; line-height: 1.3; }
nav.menu a:hover { background: rgba(255,255,255,.09); color: #fff; }
nav.menu a[aria-current="page"] { background: #fff; color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
nav.menu a:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.nav-group-title { padding: 14px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--side-muted); }
.nav-count { margin-left: auto; min-width: 18px; padding: 0 6px; border-radius: 9px; background: #e5484d; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.page { margin-left: var(--side-w); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--hair); padding: 0 20px; min-height: 60px; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; }
.topbar-title { font-weight: 600; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.whoami { display: flex; gap: 8px; align-items: center; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 12.5px; font-weight: 700; }
.whoami-name { font-size: 12.5px; font-weight: 600; } .whoami-role { font-size: 11px; color: var(--muted); }
button.signout { display: inline-flex; gap: 6px; align-items: center; background: #fff; color: var(--accent);
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 7px 14px; }
button.signout:hover { border-color: var(--accent); background: var(--accent-soft); filter: none; }
.nav-open-btn { display: none; background: none; border: 0; color: var(--accent); padding: 6px; }
.nav-scrim { display: none; }
main { max-width: 1180px; margin: 24px auto 64px; padding: 0 20px; }

@media (max-width: 900px) {
  .page { margin-left: 0; }
  html:not(.nav-open) .sidebar { transform: translateX(-100%); visibility: hidden; }
  html.nav-open .sidebar { box-shadow: 0 0 30px rgba(0,0,0,.25); }
  html.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(11,35,43,.35); border: 0; }
  .nav-open-btn { display: inline-flex; }
  .topbar { padding: 0 12px; } .whoami-text, .signout span { display: none; }
  main { padding: 0 16px; margin-top: 16px; }
}

/* ── surfaces ── */
.card { background: var(--card); border: 1px solid var(--hair); border-radius: var(--r); padding: var(--pad);
  box-shadow: var(--sh-1); min-width: 0; }
@media (max-width: 640px) { .card { padding: 16px; } }
.card + .card, .card + .grid, .grid + .card { margin-top: var(--gap); }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.grid > .card { margin-top: 0; } .grid > * { min-width: 0; }
.grid.metrics { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: stretch; margin-bottom: var(--gap); }
.metric { display: flex; gap: 14px; align-items: center; padding: 18px 20px; }
.metric .m-ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); flex: 0 0 auto; }
.metric .m-ico.warn { background: var(--warn-soft); color: var(--warn-ink); }
.metric b { display: block; white-space: nowrap; font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.metric span { color: var(--muted); font-size: 12px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: var(--gap); }
.head .actions { justify-content: flex-end; }

.flash { padding: 11px 14px; border-radius: var(--r-sm); margin-bottom: var(--gap); border: 1px solid; }
.flash.ok { background: var(--good-soft); color: var(--good); border-color: #b9e0c7; }
.flash.err { background: var(--bad-soft); color: var(--danger); border-color: #e9a79f; }
.warn { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--r-sm); padding: 11px 14px;
  margin-bottom: var(--gap); }

/* ── tables ── */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--hair); font-size: 12.5px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .3px; text-transform: uppercase;
  background: #fafbfc; border-bottom: 1px solid var(--line); }
th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover > td { background: #fafcfc; }
.card > .table-wrap:first-child, .card.flush { padding: 0; overflow: hidden; }
tr.reversed td { color: var(--muted); text-decoration: line-through; }
.register-table td { white-space: nowrap; }

.pill { display: inline-block; padding: 2px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.pill.submitted, .pill.pending, .pill.skipped, .pill.queued { background: var(--warn-soft); color: var(--warn-ink); }
.pill.paid, .pill.sent, .pill.cleared, .pill.done { background: var(--good-soft); color: var(--good); }
.pill.rejected, .pill.failed, .pill.bounced, .pill.overdue { background: var(--bad-soft); color: var(--danger); }

/* ── forms ── */
label { display: block; margin: 0 0 4px; font-weight: 600; font-size: 12.5px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font: inherit; background: var(--field); color: var(--ink); }
input::placeholder, textarea::placeholder { color: #9aa8ae; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox] { width: auto; }
textarea { min-height: 90px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
button, a.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent);
  color: #fff; border: 1px solid var(--accent); border-radius: var(--r-sm); padding: 9px 15px; font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; line-height: 1.3; transition: filter .12s, background .12s; }
button:hover:not(:disabled), a.button:hover { filter: brightness(1.12); text-decoration: none; }
button.secondary, a.button.secondary { background: #fff; color: var(--accent); }
button.secondary:hover, a.button.secondary:hover { filter: none; background: var(--accent-soft); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.danger:hover { filter: none; background: var(--bad-soft); }
button.small, a.button.small { padding: 5px 12px; font-size: 12.5px; border-radius: var(--r-xs); }
button.big, a.button.big { padding: 12px 18px; font-size: 14px; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* ── a bill: capture, preview, facts ── */
.capture { border: 2px dashed var(--line); border-radius: var(--r); padding: 22px 16px; text-align: center; background: #fbfcfc; }
.capture.drag { border-color: var(--accent); background: var(--accent-soft); }
.capture .actions { justify-content: center; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; justify-content: center; }
.thumb { position: relative; width: 116px; height: 146px; border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--sh-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .pdf { font-weight: 700; color: var(--muted); font-size: 12px; padding: 6px; text-align: center; word-break: break-all; }
.thumb button { position: absolute; top: 4px; right: 4px; padding: 0 7px; border-radius: var(--r-pill); font-size: 12px;
  background: rgba(22,35,43,.75); border: 0; }
.thumb.busy { opacity: .55; }
.upload-msg { margin-top: 8px; font-size: 12.5px; color: var(--good); }
.upload-msg.err { color: var(--danger); }
dialog.cam { border: 0; border-radius: var(--r); padding: 0; width: min(760px, 96vw); background: #000; color: #fff; }
dialog.cam::backdrop { background: rgba(11,35,43,.75); }
dialog.cam video, dialog.cam canvas { width: 100%; display: block; max-height: 72vh; object-fit: contain; background: #000; }
dialog.cam .actions { padding: 12px; justify-content: space-between; background: #111; }
dialog.cam button.secondary { background: #222; color: #fff; border-color: #444; }
.bill-files { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bill-files a { display: block; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; text-decoration: none; }
.bill-files img { width: 100%; max-height: 320px; object-fit: contain; background: var(--bg); display: block; }
.bill-files span { display: block; padding: 6px 10px; font-size: 12px; color: var(--muted); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.sumline { background: #fff3b0; padding: 8px 10px; border-radius: var(--r-xs); font-size: 14px; font-weight: 600; }
.list-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--hair); }
.list-row:last-child { border-bottom: 0; }
.empty { color: var(--muted); padding: 6px 0; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, var(--side-2) 0%, var(--side) 100%); }
.login { width: 100%; max-width: 380px; }
.login .brand-mark { background: var(--accent); color: #fff; margin-bottom: 12px; }

@media (max-width: 640px) { th.hide-sm, td.hide-sm { display: none; } }
@media print { .sidebar, .topbar { display: none !important; } .page { margin-left: 0; } }
.span-2 { grid-column: span 2; }
@media (max-width: 1000px) { .span-2 { grid-column: auto; } }

/* ── WhatsApp inbox: list · thread, after the Best Hospitals console ── */
main:has(.inbox) { max-width: none; margin: 0; padding: 0; }
main:has(.inbox) > .flash { margin: 12px 16px 0; }
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - 61px);
  background: var(--card); border-top: 0; }
main:has(.inbox > *) .flash ~ .inbox { height: calc(100vh - 61px - 56px); }
.ib-list { border-right: 1px solid var(--hair); display: flex; flex-direction: column; min-height: 0; }
.ib-list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--hair); }
.ib-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.ib-title strong { font-size: 16px; }
.ib-search { position: relative; }
.ib-search input { width: 100%; padding: 8px 10px 8px 32px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--bg); font: inherit; }
.ib-search-ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.ib-threads { overflow-y: auto; flex: 1; }
.ib-thread { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--hair);
  color: var(--ink); text-decoration: none !important; font-weight: 400 !important; }
.ib-thread:hover { background: var(--bg); }
.ib-thread.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.ib-av { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; }
.ib-av.client { background: #7a5300; } .ib-av.unknown { background: #8a979e; }
.ib-tmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ib-trow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ib-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.ib-prev { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-thread.unread .ib-name, .ib-thread.unread .ib-prev { color: var(--ink); font-weight: 700; }
.ib-thread.unread .ib-time { color: var(--good); font-weight: 600; }
.ib-badge { flex: 0 0 auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #1fa855; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.ib-empty { padding: 24px 16px; text-align: center; }

.ib-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #efeae2; }
.ib-chat-head { display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: var(--card);
  border-bottom: 1px solid var(--hair); }
.ib-chat-who { flex: 1; min-width: 0; }
.ib-back { display: none; color: var(--accent); transform: rotate(180deg); }
.ib-win { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: var(--r-pill); white-space: nowrap; }
.ib-win.open { background: var(--good-soft); color: var(--good); }
.ib-win.closed { background: var(--warn-soft); color: var(--warn-ink); }
.ib-msgs { flex: 1; overflow-y: auto; padding: 14px 6% 18px; display: flex; flex-direction: column; gap: 4px; }
.ib-day { text-align: center; margin: 10px 0 6px; }
.ib-day span { background: #fff; color: var(--muted); font-size: 11.5px; padding: 4px 12px; border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.ib-row { display: flex; } .ib-row.out { justify-content: flex-end; }
.ib-bubble { max-width: min(560px, 78%); padding: 6px 9px 4px; border-radius: 8px; background: #fff;
  box-shadow: 0 1px 1px rgba(0,0,0,.10); overflow-wrap: anywhere; }
.ib-row.out .ib-bubble { background: #d9fdd3; }
.ib-row.out .ib-bubble.system { background: #eef6f8; }
.ib-by { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.ib-text { white-space: pre-wrap; font-size: 13.5px; line-height: 1.45; }
.ib-img { display: block; max-width: 280px; max-height: 320px; border-radius: 6px; margin: 2px 0 4px; object-fit: cover; }
.ib-file { display: inline-flex; gap: 6px; align-items: center; padding: 8px 10px; margin: 2px 0 4px; border-radius: 6px;
  background: rgba(0,0,0,.05); font-size: 12.5px; }
.ib-meta { display: flex; gap: 8px; justify-content: flex-end; align-items: center; font-size: 11px; color: var(--muted);
  margin-top: 2px; }
.ib-outcome { margin-right: auto; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-ink); }
.ib-tick.sent { color: #34b7f1; font-weight: 700; } .ib-tick.failed { color: var(--danger); font-weight: 700; }
.ib-err { margin-top: 3px; font-size: 11.5px; color: var(--danger); }
.ib-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px; background: #f0f2f5; }
.ib-attach { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--muted);
  cursor: pointer; flex: 0 0 auto; }
.ib-attach:hover { background: rgba(0,0,0,.06); color: var(--accent); }
.ib-input { flex: 1; min-width: 0; background: #fff; border-radius: 10px; padding: 4px 10px; }
.ib-input textarea { width: 100%; border: 0; outline: 0; resize: none; font: inherit; font-size: 13.5px; padding: 6px 0;
  max-height: 160px; background: transparent; }
.ib-chip { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin: 4px 0 2px; padding: 4px 8px;
  border-radius: 6px; background: var(--accent-soft); font-size: 12px; }
.ib-chip button { border: 0; background: none; font-size: 15px; line-height: 1; padding: 0 4px; color: var(--muted); }
.ib-send { height: 40px; padding: 0 18px; border-radius: var(--r-pill); }
.ib-closed { padding: 12px 18px; background: var(--warn-soft); color: var(--warn-ink); font-size: 12.5px;
  border-top: 1px solid var(--warn-line); }
.ib-placeholder { margin: auto; max-width: 380px; text-align: center; display: flex; flex-direction: column; gap: 8px;
  align-items: center; padding: 24px; }
.ib-ph-ico { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: #fff; color: var(--accent); }

@media (max-width: 900px) {
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 61px); }
  .inbox.has-thread .ib-list, .inbox:not(.has-thread) .ib-chat { display: none; }
  .ib-back { display: flex; }
  .ib-msgs { padding: 12px 10px; }
  .ib-bubble { max-width: 88%; }
}
.ib-chip[hidden] { display: none; }
.ib-input textarea { min-height: 0; height: 32px; border: 0; box-shadow: none; overflow-y: hidden; }
