/* Paywise HMIS — design system.
   Calm, dense-but-readable, and legible at arm's length on a ward tablet. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --ink: #14181f;
  --ink-2: #4a5260;
  --ink-3: #7b8494;
  --line: #e3e6ea;
  --line-2: #eef0f3;
  --brand: #1257c8;
  --brand-ink: #0b3f96;
  --brand-soft: #e8f0fe;
  /* Several components (profile tool tabs, setup progress, picker hover) read the accent. */
  --accent: #1257c8;
  --accent-soft: #e8f0fe;
  --good: #0f7a4a;
  --good-soft: #e4f5ec;
  --warn: #9a6300;
  --warn-soft: #fdf3e0;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --sidebar: #0f1724;
  --sidebar-ink: #b9c2d0;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.fineprint { font-size: 12px; color: var(--ink-3); margin: 10px 0 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px;
  background: var(--line-2); border: 1px solid var(--line); color: var(--ink-2);
}
code { font-family: var(--mono); font-size: 12.5px; }

/* ── Boot ──────────────────────────────────────────────────────────────── */
.boot {
  position: fixed; inset: 0; display: grid; place-content: center; gap: 18px;
  justify-items: center; background: var(--bg); z-index: 100;
}
.boot-mark { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.boot-mark span { color: var(--brand); }
.boot-logo { height: 28px; width: auto; max-width: 60vw; filter: drop-shadow(0 2px 10px rgba(0,0,0,.35)); }
.boot-spinner, .spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ─────────────────────────────────────────────────────────────── */
.auth-screen { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-brand {
  background: linear-gradient(155deg, #0f1724 0%, #142a52 55%, #0b3f96 100%);
  color: #eaf0fb; padding: 56px 60px; display: flex; flex-direction: column; gap: 20px;
}
.auth-logo { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.auth-logo span { color: #7fb0ff; }
.auth-brand-logo { height: 30px; width: auto; max-width: 70%; align-self: flex-start; filter: drop-shadow(0 2px 10px rgba(0,0,0,.35)); }
/* Small screens hide the left brand column, so the card carries the logo. */
.auth-card-logo { display: none; }
.auth-brand h1 { font-size: 34px; line-height: 1.2; margin: 24px 0 0; max-width: 12ch; letter-spacing: -.02em; }
.auth-brand > p { color: #b7c6e2; max-width: 46ch; margin: 0; }
.auth-points { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.auth-points li { color: #cbd8ee; font-size: 14px; padding-left: 22px; position: relative; }
.auth-points li::before { content: "\2713"; position: absolute; left: 0; color: #7fb0ff; }
.auth-foot { margin-top: auto; font-size: 13px; }
.auth-foot a { color: #9dc0ff; }

/* ABDM status note on the login screen (was rendered with no styles at all) */
.abdm-progress {
  margin-top: auto; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid rgba(127, 176, 255, .28); border-radius: 10px;
  background: rgba(127, 176, 255, .08);
}
.abdm-progress strong { display: block; color: #fff; font-size: 13px; }
.abdm-progress .muted { color: #9fb4d8; font-size: 12px; line-height: 1.5; }
.pulse {
  flex: none; margin-top: 4px; width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .55);
  animation: pulse-ring 1.8s ease-out infinite;
}
@keyframes pulse-ring {
  70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.auth-panel {
  display: grid; place-items: center; padding: 40px 28px;
  background: linear-gradient(160deg, #eef4ff 0%, #f0faf5 45%, #fdf6e8 100%);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid #2f7fe0;
  border-radius: 14px; padding: 30px 28px; box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.01em; }
.auth-card > .muted { margin: 0 0 18px; font-size: 14px; }
.auth-form { display: grid; gap: 14px; }
.auth-form h3 { margin: 2px 0 -4px; font-size: 17px; letter-spacing: -.01em; }
.auth-form > .muted { margin: -6px 0 0; font-size: 13px; }
.auth-msg { min-height: 20px; font-size: 13px; margin: 12px 0 0; }
.auth-msg.error { color: var(--bad); }
.auth-msg.info { color: var(--brand); }

/* Hospital preview on the login screen (name + logo, like the CMS college lookup) */
.facility-preview {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  padding: 10px 12px; border: 1px solid #d8e7fb; border-radius: 10px;
  background: #f2f7fe;
}
.facility-logo { width: 38px; height: 38px; border-radius: 8px; object-fit: contain; background: var(--surface); padding: 3px; }
.facility-preview-text { display: grid; gap: 1px; min-width: 0; }
.facility-preview-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facility-preview-text .muted { font-size: 12px; }

.auth-links { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; }
.auth-links.hidden { display: none; }
.link {
  border: 0; background: none; padding: 0; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--brand); cursor: pointer; text-decoration: none;
}
.link:hover { text-decoration: underline; color: var(--brand-ink); }
.auth-msg .link { color: var(--brand); }

.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-rule {
  display: flex; align-items: center; gap: 10px; font-size: 11px;
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
}
.auth-rule::before, .auth-rule::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Platform billing — pay methods */
.pay-methods { display: grid; gap: 12px; }
.pay-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.pay-row .muted { margin: 2px 0 0; font-size: 13px; }
.pay-row .qr { width: 96px; height: 96px; flex-shrink: 0; }
.pay-row .qr svg { width: 96px; height: 96px; }

/* Flagged patients — red highlight in duplicate search + profile banner */
.flag-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: #fdecec; border: 1px solid #f3b7b7; color: #b3261e;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.flag-banner {
  margin: 10px 0 0; padding: 10px 14px; border-radius: 10px;
  background: #fdecec; border: 1px solid #f3b7b7; color: #b3261e;
  font-size: 13.5px; font-weight: 600;
}
.btn.danger { border-color: #f3b7b7; color: #b3261e; }
.btn.danger:hover { background: #fdecec; border-color: #e29090; }

label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; background: var(--line-2); padding: 3px; border-radius: 9px; }
.tabs.bar { margin-bottom: 20px; }
.tab {
  flex: 1; border: 0; background: transparent; padding: 7px 12px; border-radius: 7px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  font: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #d2d7de; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  width: 34px; height: 34px; cursor: pointer; font-size: 15px; color: var(--ink-2);
}

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
/* Single 1fr track: with the sidebar display:none, .main auto-places into
   the only remaining track. (grid-template-columns: 0 1fr collapses .main
   into the 0px track instead.) */
.shell.sidebar-hidden { grid-template-columns: 1fr; }
.shell.sidebar-hidden .sidebar { display: none; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 12px; }
.sidebar-logo { height: 20px; width: auto; display: block; margin: 14px auto 0; }
.logo { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.logo span { color: #7fb0ff; }
.plat-logo { height: 26px; width: auto; margin-right: 10px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: #6b7688; padding: 6px 8px; font-weight: 700;
}
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; background: none; border: 0; cursor: pointer; text-align: left;
  border-radius: 6px;
}
.nav-group-title:hover { color: #9aa7b8; background: rgba(255, 255, 255, .04); }
.nav-chev { font-style: normal; font-size: 9px; transition: transform .18s ease; }
.nav-group.collapsed .nav-chev { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 7px;
  color: var(--sidebar-ink); font-size: 13.5px; text-decoration: none;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-icon { width: 16px; text-align: center; opacity: .85; font-size: 13px; }
.sidebar-foot { padding: 12px 16px 16px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; }
.facility { color: #fff; font-weight: 600; margin-bottom: 4px; }
.badge {
  display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 20px;
  background: rgba(255, 255, 255, .1);
}
.badge.good { background: rgba(52, 199, 123, .18); color: #74e6ac; }
.badge.warn { background: rgba(255, 186, 68, .16); color: #ffcd7a; }

.main {
  display: flex; flex-direction: column; min-width: 0;
  /* The workspace is a query container: the dashboard's card grid keys off
     THIS width, so opening or closing the sidebar re-packs the cards
     instantly — viewport media queries can't see a sidebar toggle. */
  container-type: inline-size;
}
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.global-search {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface-2); color: var(--ink-3); font: inherit; font-size: 13px;
  cursor: pointer; text-align: left;
}
.global-search span { flex: 1; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-ink); display: grid; place-content: center; font-size: 12px; font-weight: 700;
}
.who { display: flex; flex-direction: column; line-height: 1.2; }
.who strong { font-size: 13px; }
.who em { font-style: normal; font-size: 11px; color: var(--ink-3); }

.breadcrumbs { padding: 12px 26px 0; font-size: 12.5px; color: var(--ink-3); display: flex; gap: 7px; }
.breadcrumbs i { font-style: normal; opacity: .5; }
.view { padding: 16px 22px 44px; outline: none; }

/* ── Page furniture ────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; margin: 0; letter-spacing: -.02em; }
.page-head .muted { margin: 3px 0 0; font-size: 13.5px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.card.alert { border-color: #f4c4c0; }
/* Light pastel accents — every card carries one tone; alert keeps its red. */
.card--blue { border-top: 3px solid #2f7fe0; }
.card--blue > .card-head { background: linear-gradient(180deg, #f2f7fe, var(--surface-2)); }
.card--green { border-top: 3px solid var(--good); }
.card--green > .card-head { background: linear-gradient(180deg, var(--good-soft), var(--surface-2)); }
.card--amber { border-top: 3px solid #d99a1f; }
.card--amber > .card-head { background: linear-gradient(180deg, var(--warn-soft), var(--surface-2)); }
.card--violet { border-top: 3px solid #7a5af8; }
.card--violet > .card-head { background: linear-gradient(180deg, #f6f3ff, var(--surface-2)); }
.card--teal { border-top: 3px solid #0e9f8a; }
.card--teal > .card-head { background: linear-gradient(180deg, #e8f7f4, var(--surface-2)); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
.card-head h2 { font-size: 13.5px; margin: 0; letter-spacing: -.005em; }
.card-body { padding: 14px 16px; }
/* Sub-headings inside cards (dashboard stock watch, ABDM transaction log) */
.card-sub, .card-title { margin: 10px 0 4px; }
.card-sub {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 700;
}
.card-title { font-size: 14px; letter-spacing: -.005em; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat {
  background: linear-gradient(180deg, var(--surface) 55%, #f2f6fc);
  border: 1px solid var(--line); border-top: 3px solid #c7d6ee;
  border-radius: var(--radius);
  padding: 11px 13px; box-shadow: var(--shadow);
}
.stat[data-tone="blue"] { border-top-color: #2f7fe0; background: linear-gradient(180deg, var(--surface) 55%, #f2f7fe); }
.stat[data-tone="blue"] .stat-value { color: #1d5fb8; }
.stat[data-tone="green"] { border-top-color: var(--good); background: linear-gradient(180deg, var(--surface) 55%, var(--good-soft)); }
.stat[data-tone="green"] .stat-value { color: var(--good); }
.stat[data-tone="amber"] { border-top-color: #d99a1f; background: linear-gradient(180deg, var(--surface) 55%, var(--warn-soft)); }
.stat[data-tone="amber"] .stat-value { color: #9a6300; }
.stat[data-tone="violet"] { border-top-color: #7a5af8; background: linear-gradient(180deg, var(--surface) 55%, #f6f3ff); }
.stat[data-tone="violet"] .stat-value { color: #6d4af0; }
.stat[data-tone="red"] { border-top-color: var(--bad); background: linear-gradient(180deg, var(--surface) 55%, var(--bad-soft)); }
.stat[data-tone="red"] .stat-value { color: var(--bad); }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; }
.stat-value { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin: 3px 0 1px; }
.stat-hint { font-size: 12px; color: var(--ink-3); }
.stat-link { transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.stat-link:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 24, 40, .1); }

/* ── Pending-action chips ─────────────────────────────────────────────── */
.pending-chips { margin: 0 0 14px; }
.pending-chips {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px;
}
.chip-stat {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, var(--surface) 50%, var(--brand-soft));
  border: 1px solid var(--line); border-left: 3px solid #2f7fe0; border-radius: var(--radius);
  padding: 9px 12px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.chip-stat:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip-count {
  min-width: 28px; text-align: center; font-size: 16px; font-weight: 800;
  border-radius: 999px; padding: 2px 8px; background: #2f7fe0; color: #fff;
}

/* ── Reports & MIS ─────────────────────────────────────────────────────── */
.mis-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }

/* ── Plan & platform billing ───────────────────────────────────────────── */
/* The current-plan card reads like every other card: small labels, normal
   weight values — not oversized bold stat tiles. */
.plan-facts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px 18px; margin: 0; padding: 4px 0;
}
.plan-facts > div { display: flex; flex-direction: column; gap: 2px; }
.plan-facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
.plan-facts dd { margin: 0; font-size: 14px; color: var(--ink); font-weight: 400; }

.upi-qr-img { width: 150px; height: 150px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

.blank-frame { width: 100%; height: 62vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

/* ── Daycare live-search pickers ───────────────────────────────────────── */
.svc-picker { position: relative; }
.svc-input { width: 100%; }
.svc-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); max-height: 260px; overflow: auto;
}
.svc-row {
  display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line-2); padding: 8px 12px; cursor: pointer;
}
.svc-row:hover, .svc-row:focus-visible { background: var(--brand-soft); }
.svc-name { font-weight: 600; }
.svc-meta { font-size: 11.5px; color: var(--ink-3); }
.svc-none { padding: 8px 12px; margin: 0; font-size: 12.5px; color: var(--ink-3); }
.mis-nav { display: flex; align-items: center; gap: 8px; }
.mis-month { font-size: 17px; font-weight: 800; min-width: 150px; text-align: center; letter-spacing: -.01em; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.hbars { display: grid; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: minmax(96px, 1.1fr) 1.6fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { background: var(--line-2); border: 1px solid var(--line); border-radius: 999px; height: 10px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 999px; min-width: 3px; }
.hbar-value { font-weight: 650; white-space: nowrap; }
.hbar-value em { font-weight: 400; color: var(--ink-3); }
.gender-strip { display: flex; border-radius: 8px; overflow: hidden; height: 34px; font-size: 12px; box-shadow: inset 0 0 0 1px var(--line); }
.gseg { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; min-width: 44px; }
.gender-key { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin: 10px 0 14px; flex-wrap: wrap; }
.gender-key i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.hmis-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 12px; }
.hmis-tile { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.hmis-tile .hmis-v { font-size: 19px; font-weight: 750; letter-spacing: -.01em; }
.hmis-tile .hmis-l { font-size: 11px; text-transform: uppercase; letter-spacing: .045em; color: var(--ink-3); font-weight: 700; margin-top: 2px; line-height: 1.35; }
.hmis-tile[data-tone="red"] .hmis-v { color: var(--bad); }
.hmis-tile[data-tone="amber"] .hmis-v { color: #9a6300; }
.chip-count.warn { background: #b7791f; }
.chip-count.bad { background: var(--danger); }
.chip-label { font-size: 13px; font-weight: 600; }


.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.form-grid legend { font-size: 12px; font-weight: 700; color: var(--ink-2); padding: 0 6px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.form-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.form-inline input { width: auto; min-width: 180px; }
.filter-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.inline-label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.inline-label input { width: auto; }
.mini-select { width: auto; padding: 5px 9px; font-size: 12.5px; }
.search-input { font-size: 16px; padding: 12px 14px; }
.results-area { margin-top: 14px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: -4px -4px 0; padding: 4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr[data-id] { cursor: pointer; }
.row-actions { display: flex; gap: 6px; }
.empty { color: var(--ink-3); font-size: 13.5px; margin: 6px 0; }

.pill {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kv-grid.tight { gap: 8px; }
.kv-grid > div { display: flex; flex-direction: column; gap: 2px; }
.kv-grid span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 700; }
.kv-grid strong { font-size: 14px; font-weight: 600; }

.chip-list, .plain-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.plain-list { flex-direction: column; gap: 4px; font-size: 13.5px; }
.chip {
  font-size: 12.5px; padding: 3px 10px; border-radius: 20px;
  background: var(--line-2); color: var(--ink-2);
}
/* Dashboard filter chips (lab board). */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
button.chip {
  border: 1px solid transparent; cursor: pointer;
  background: var(--surface-2); color: var(--ink-2); font: inherit;
}
button.chip:hover { border-color: var(--brand); color: var(--brand); }
button.chip.on { background: var(--brand); color: #fff; font-weight: 600; }
.chip.danger { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.chip-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-choice {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 20px;
}
.chip-choice input { width: auto; }

.steps { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--ink-2); display: grid; gap: 6px; }
.code-block {
  display: block; background: var(--sidebar); color: #d5deed; padding: 12px 14px;
  border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 10px 0;
}
.code-block.scroll { max-height: 420px; overflow-y: auto; }
.qr { margin: 14px 0; display: inline-block; background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.qr svg { display: block; width: 260px; height: 260px; }
/* Scannable verification QR on printed records (timeline viewer, receipts).
   The image is an embedded data URL so it survives the print dialog. */
.verify-box {
  display: flex; align-items: center; gap: 12px;
  margin-top: 10px; padding: 8px;
  border: 1px solid #c8d6e5; border-radius: 8px;
  width: max-content; max-width: 100%;
}
.verify-box .qr { width: 84px; height: 84px; margin: 0; padding: 0; border: 0; flex-shrink: 0; }
.verify-box .tiny { word-break: break-all; }

/* ── Milestones ────────────────────────────────────────────────────────── */
.milestone-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-bottom: 18px; }
.milestone {
  text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; cursor: pointer; font: inherit;
  box-shadow: var(--shadow); transition: border-color .12s, transform .12s;
}
.milestone:hover { border-color: var(--brand); transform: translateY(-1px); }
.ms-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ms-tag { font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--brand); }
.milestone h3 { margin: 0 0 6px; font-size: 15px; letter-spacing: -.01em; }
.milestone p { margin: 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }

/* ── Patient workspace ─────────────────────────────────────────────────── */
.patient-header {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px; display: flex; gap: 20px;
  align-items: flex-start; flex-wrap: wrap; box-shadow: var(--shadow);
}
.ph-identity h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.ph-photo {
  width: 64px; height: 64px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  float: left; margin: 0 14px 6px 0; box-shadow: var(--shadow);
}
.photo-preview {
  max-width: 170px; max-height: 170px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); margin-top: 8px; display: block;
}
.photo-field .field-head {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); font-weight: 700; display: block; margin-bottom: 4px;
}
.ph-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.ph-meta .abha { color: var(--brand); font-weight: 600; }
.ph-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.alert-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.alert { font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: var(--radius-sm); }
.alert.danger { background: var(--bad-soft); color: var(--bad); border: 1px solid #f4c4c0; }
.alert.info { background: var(--brand-soft); color: var(--brand-ink); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 20px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 12px 10px; }
.tl-dot {
  position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--line);
}
.tl-item.external .tl-dot { background: #7a5af8; }
.tl-item.lab .tl-dot, .tl-item.radiology .tl-dot { background: var(--warn); }
.tl-item.invoice .tl-dot { background: var(--good); }
.tl-top { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; color: var(--ink-3); }
.tl-kind { text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.tl-title { font-weight: 600; font-size: 14px; margin: 2px 0; }
.tl-title .btn { margin-left: 8px; }
.tl-summary { font-size: 13px; color: var(--ink-2); }
.tl-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--ink-3); }

.result-ok {
  background: var(--good-soft); border: 1px solid #bfe3d0; border-radius: var(--radius-sm);
  padding: 12px 14px; margin-top: 12px; font-size: 13.5px;
}

/* ── ABHA: consent, masked Aadhaar, OTP resend, production mode ──────── */
.text-danger { color: var(--bad); }
.consent-box {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
  margin: 0 0 4px; background: var(--surface-2); font-size: 13px; min-width: 0;
}
.consent-box legend { font-weight: 600; padding: 0 6px; }
.consent-lead { margin: 0 0 6px; }
.consent-line { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; font-weight: 400; line-height: 1.45; }
.consent-line input[type="checkbox"] { width: auto; margin-top: 3px; flex: none; }
.consent-attest { border-top: 1px dashed var(--line); padding-top: 8px; }
.consent-name { display: grid; gap: 4px; margin: 8px 0 2px; font-weight: 600; }
.consent-name input { max-width: 360px; font-weight: 400; }
.consent-terms { margin: 8px 0; }
.consent-terms summary { cursor: pointer; color: var(--accent, inherit); }
.consent-terms > p { max-height: 220px; overflow: auto; padding: 8px 10px; margin: 6px 0 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); line-height: 1.5; }
.aadhaar-field { display: flex; gap: 8px; align-items: center; }
.aadhaar-field input { flex: 1; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.aadhaar-field .btn { flex: none; white-space: nowrap; }
.otp-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.abha-address-input { display: flex; align-items: center; gap: 0; }
.abha-address-input input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.abha-address-input .suffix {
  padding: 8px 10px; border: 1px solid var(--line); border-left: 0; background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-2); font-weight: 600;
}
.abha-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.result-ok .kv { display: flex; gap: 10px; align-items: baseline; margin: 4px 0; }
.result-ok .kv > span { min-width: 110px; color: var(--ink-3); font-size: 12.5px; }
/* Production mode (platform setting) hides technical identifiers. */
body.mode-production .dev-only { display: none !important; }
.doc-preview { min-height: 420px; }
.doc-frame { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }

/* ── Palette, toasts, panels ───────────────────────────────────────────── */
.palette { position: fixed; inset: 0; background: rgba(15, 23, 36, .45); z-index: 200; display: grid; place-items: start center; padding-top: 12vh; }
.palette-box { width: min(620px, 92vw); background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(16, 24, 40, .28); overflow: hidden; }
.palette-box input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 18px; font-size: 15px; }
.palette-box input:focus { box-shadow: none; }
.palette-results { list-style: none; margin: 0; padding: 6px; max-height: 46vh; overflow-y: auto; }
.palette-results li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.palette-results li.active, .palette-results li:hover { background: var(--brand-soft); }
.pk { font-size: 10.5px; font-weight: 800; text-transform: uppercase; color: var(--brand); min-width: 56px; }
.pl { flex: 1; }
.ps { color: var(--ink-3); font-size: 12px; }
.empty-item { color: var(--ink-3); }
.palette-foot { padding: 8px 14px; border-top: 1px solid var(--line-2); font-size: 11.5px; color: var(--ink-3); }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 300; }
.toast {
  background: var(--sidebar); color: #eef2f8; padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: 0 8px 24px rgba(16, 24, 40, .22); max-width: 380px;
  animation: rise .2s ease-out;
}
.toast.success { background: #10603f; }
.toast.error { background: #8f221c; }
.toast.warn { background: #7a4f06; }
.toast.out { opacity: 0; transition: opacity .25s; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 14px; padding: 24px 0; }
.panel-error, .panel-empty {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; text-align: center;
}
.panel-error { border-color: #f4c4c0; background: var(--bad-soft); display: grid; gap: 6px; }
.panel-empty h2 { margin: 0 0 6px; font-size: 16px; }
.panel-empty .btn { margin-top: 12px; }

.only-mobile { display: none; }

/* ── Platform console ──────────────────────────────────────────────────── */
.plat-shell { max-width: 1180px; margin: 0 auto; padding: 22px; }
.plat-top {
  display: flex; align-items: center; gap: 16px; margin-bottom: 22px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.plat-top .logo { color: var(--ink); }
.plat-nav { display: flex; gap: 4px; margin-left: 20px; }
.plat-nav button {
  border: 0; background: transparent; font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); padding: 7px 12px; border-radius: 7px; cursor: pointer;
}
.plat-nav button.active { background: var(--brand-soft); color: var(--brand-ink); }

/* ── Slide-over drawer: act on one row without losing the worklist ────────── */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 36, .38);
  display: flex; justify-content: flex-end;
  animation: scrim-in .12s ease-out;
}
@keyframes scrim-in { from { opacity: 0; } }
.drawer {
  width: min(760px, 100%); background: var(--bg);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(16, 24, 40, .18);
  animation: drawer-in .16s ease-out;
  overflow: hidden;
}
/* The StarApp lab bench needs room: parameter, value, low–high range, unit,
   method, remark and print columns never fit a 760px panel. */
.drawer.wide { width: min(1120px, 100%); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: .4; } }
.drawer.busy { opacity: .6; pointer-events: none; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.drawer-head p { margin: 3px 0 0; font-size: 13px; }
.drawer-body { padding: 14px 16px 32px; overflow-y: auto; flex: 1; }
.drawer-body .card { margin-bottom: 12px; }
.drawer-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; padding: 11px 14px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.drawer-meta > div { display: flex; flex-direction: column; gap: 3px; }
.drawer-meta .muted { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }

/* Dashboard hero strip + fluid card grid (every role's landing screen). */
.dash-hero {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 15px 18px; border-radius: 14px;
  background: linear-gradient(120deg, #e8f1ff 0%, #eefaf3 55%, #fdf8ec 100%);
  border: 1px solid #dbe7fb; box-shadow: var(--shadow);
}
.dash-hero h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.dash-hero .muted { margin: 3px 0 0; font-size: 13px; color: var(--ink-2); }
.dash-hero-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  grid-auto-flow: row dense;
  gap: 16px; align-items: stretch;
}
.dash-grid > .card { margin-bottom: 0; display: flex; flex-direction: column; }
.dash-grid > .card > .card-body { flex: 1; }
/* A card hidden for being empty must not leave a ghost grid cell behind. */
.dash-grid > :empty { display: none; }
/* The Scan & Share arrivals card carries every field — give it the whole
   row and let its table scroll inside the card instead of blowing out the
   dashboard grid and clipping at the viewport edge. */
.dash-grid > * { min-width: 0; }
#shareArrivalsCard { grid-column: 1 / -1; min-width: 0; }
#shareArrivalsCard .table-wrap { overflow-x: auto; }
/* Cards size to their content; wide tables claim two columns and dense
   packing fills the gaps the narrower cards leave behind. */
.dash-grid > .card.span-2 { grid-column: span 2; }
/* Column count tracks the WORKSPACE (container queries on .main), not the
   viewport: hiding the sidebar widens .main, which instantly repacks the
   cards — no dead blank rows, no squeezed tables. */
@container (min-width: 1180px) {
  .dash-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
@container (min-width: 1480px) {
  .dash-grid { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
}
@container (max-width: 980px) {
  .dash-grid > .card.span-2 { grid-column: auto; }
}

/* Income page stream bars (finance) */
.stream-bars { display: flex; flex-direction: column; gap: 8px; }
.stream-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface);
}
.stream-name { font-weight: 600; }
.stream-amount { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Cards inside the dashboard grid fill their column at every workspace
   width: wide screens pack more columns, narrow screens collapse to one —
   no fixed pairings, no dead whitespace at the row ends. */

/* Period tabs for the OPD billing page */
.tab-strip { display: flex; gap: 6px; margin: 4px 0 12px; flex-wrap: wrap; }
.tab-strip .tab {
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.tab-strip .tab.active {
  background: var(--accent, #1a4f8b); border-color: var(--accent, #1a4f8b); color: #fff;
}

/* Sticky one-tap actions inside the consultation drawer — save, record notes,
   sign — so the doctor never hunts for them while scrolling a long note. */
.drawer-quickbar {
  position: sticky; top: 0; z-index: 6;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 10px 14px; margin: 0 0 12px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(16, 24, 40, .08);
}

/* Compact order catalogue: collapsible, searchable checkbox list with a
   sticky Place-order bar — the catalogue can run to hundreds of rows and the
   order button must stay reachable without scrolling to the end. */
.picker-bar { display: flex; justify-content: flex-end; margin: -4px 0 2px; }
.picker-list {
  max-height: 42vh; overflow-y: auto;
  margin-top: 4px; padding: 0 12px 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.picker-list fieldset { padding-top: 10px; }
/* Order-catalogue rows (lab / radiology pickers) — compact grid rows with an
   inline rate input and a save-to-master tick per line. */
.picker-list .check-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px; align-items: center;
  padding: 5px 8px; border-bottom: 1px solid var(--line-2);
}
.picker-list .check-row:hover { background: var(--surface-2); }
.picker-list .check-row.checked { background: var(--brand-soft); }
.pick-select { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
.pick-select input[type=checkbox] { flex: none; margin: 0; }
.pick-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.pick-code {
  flex: none; font-style: normal; font-size: 10.5px; color: var(--ink-3);
  font-family: var(--mono); background: var(--line-2); border: 1px solid var(--line);
  padding: 0 5px; border-radius: 4px; letter-spacing: .02em;
}
.pick-meta { flex: none; font-size: 11.5px; white-space: nowrap; }
.pick-rate { display: flex; align-items: center; gap: 8px; }
.rate-input {
  width: 92px; padding: 3px 8px; font-size: 12.5px; text-align: right;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
.rate-input:focus { border-color: var(--brand); outline: none; }
.rate-input:disabled { background: var(--line-2); color: var(--ink-3); }
.pick-save { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.pick-save input { margin: 0; }
.pick-save:has(input:disabled) { opacity: .5; }
.picker-actions {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 10px 0 2px; margin-top: 14px;
  background: var(--bg); border-top: 1px solid var(--line);
}
.picker-actions .muted { margin-right: auto; }

/* Form + layout helpers used by the workflow benches */
.stack { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.stack h3 { margin: 4px 0 0; font-size: 14px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); }
.row-gap { display: flex; gap: 8px; align-items: center; }
/* Finance document-template editor — section/field row builders */
.sec-row .sec-title { flex: 1; }
.field-row .f-label { flex: 1.8; }
.field-row .f-type { flex: 0.9; }
.field-row .f-extra { flex: 1.6; }
.field-row .checkbox { flex: 0.6; white-space: nowrap; }
.result-row { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr .7fr; gap: 8px; margin-bottom: 8px; }
.result-ref { grid-column: 1 / -1; margin-top: -4px; }

/* StarApp-style lab result entry grid — one table per test, the bench types
   only the Result column; ranges/units/methods are pre-filled from master. */
.lab-section { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; }
.lab-section-head {
  display: flex; align-items: baseline; gap: 10px; padding: 8px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
table.lab-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lab-grid th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); background: var(--surface-1); padding: 6px 8px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.lab-grid td { padding: 4px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.lab-grid tr:last-child td { border-bottom: 0; }
table.lab-grid .c-sno { width: 30px; text-align: right; }
table.lab-grid .c-param { min-width: 170px; }
table.lab-grid .c-param input, table.lab-grid .c-param select { margin-bottom: 4px; }
table.lab-grid .c-value { width: 140px; }
table.lab-grid .c-ref { width: 110px; white-space: nowrap; }
table.lab-grid .c-unit { width: 90px; }
table.lab-grid .c-meth { width: 90px; white-space: nowrap; }
table.lab-grid .c-remark { width: 150px; }
table.lab-grid .c-print { width: 46px; text-align: center; }
table.lab-grid input:not([type="checkbox"]) { width: 100%; box-sizing: border-box; }
table.lab-grid .lab-value { font-variant-numeric: tabular-nums; font-weight: 600; }
table.lab-grid .lab-flag {
  display: inline-block; min-width: 56px; margin-left: 6px; font-size: 11px; font-weight: 700;
}
table.lab-grid tr.row-high td { background: var(--bad-soft, #fdecec); }
table.lab-grid tr.row-high .lab-flag { color: var(--bad, #c0392b); }
table.lab-grid tr.row-low td { background: var(--warn-soft, #fef6e8); }
table.lab-grid tr.row-low .lab-flag { color: var(--warn, #b9770e); }
.free-select { font-size: 12px; }
.tiny { font-size: 11.5px; }
.note {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--warn); font-size: 13px;
}
.total-line { text-align: right; font-size: 14px; margin: 10px 2px 0; }
.due { color: var(--red, #c0392b); font-weight: 600; }
.up { color: var(--red, #c0392b); font-weight: 600; }
.down { color: var(--good, #1e8449); font-weight: 600; }
.summary { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; font-size: 13.5px; }
.summary dt { color: var(--ink-3); }
.summary dd { margin: 0; }
.summary.nested { grid-template-columns: minmax(90px, auto) 1fr; gap: 2px 10px; font-size: 12.5px; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(.93); }

/* Medication administration record grid */
table.mar th, table.mar td { vertical-align: top; }
table.mar .slot { text-align: center; min-width: 62px; }
table.mar .slot.muted { color: var(--ink-3); }

/* ── Voice dictation ──────────────────────────────────────────────────────── */
.dictate-panel { display: flex; align-items: center; gap: 14px; padding: 8px 0 4px; }

/* Inline dictation on a single note field. */
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mic-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; font: inherit; font-size: 12px; line-height: 1.6;
  color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer;
}
.mic-btn:hover:not(:disabled) { color: var(--brand); border-color: var(--brand); }
.mic-btn:disabled { opacity: .5; cursor: not-allowed; }
.mic-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.mic-btn.recording { color: var(--danger); border-color: var(--danger); }
.mic-btn.recording .mic-dot { animation: mic-pulse 1s ease-in-out infinite; }
.mic-btn.busy { color: var(--brand); border-color: var(--brand); }
.mic-btn.busy .mic-dot { animation: mic-pulse .6s linear infinite; }
.mic-row { display: inline-flex; align-items: center; gap: .45rem; }
.mic-status { font-size: 11px; color: var(--muted); white-space: nowrap; }
.mic-status.listening { color: var(--danger); font-weight: 600; }
.mic-status.stopped { color: var(--muted); }
@keyframes mic-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) {
  .mic-btn.recording .mic-dot, .mic-btn.busy .mic-dot { animation: none; }
}
.btn.big { font-size: 15px; padding: 11px 20px; }
.type-instead { margin-top: 14px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.type-instead summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.verbatim {
  margin: 8px 0; padding: 11px 14px;
  border-left: 3px solid var(--brand); background: var(--brand-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; line-height: 1.55;
}
.uncertain { margin: 6px 0 0; padding-left: 20px; font-size: 13px; color: var(--warn); }

/* Progress rail through the dictation stages */
.stage-rail { display: flex; gap: 6px; list-style: none; margin: 0 0 16px; padding: 0; flex-wrap: wrap; }
.stage-rail li {
  flex: 1 1 0; min-width: 92px; text-align: center;
  padding: 7px 8px; font-size: 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-3);
}
.stage-rail li.done { background: var(--good-soft); border-color: #bde3ce; color: var(--good); }
.stage-rail li.current { box-shadow: 0 0 0 2px var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }

.checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox input { width: auto; }

/* ── ICU bed grid ─────────────────────────────────────────────────────────── */
.icu-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
}
.icu-bed {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
  cursor: pointer; transition: border-color .12s, transform .12s;
}
.icu-bed:hover { border-color: var(--brand); transform: translateY(-1px); }
.icu-bed:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icu-bed.free { background: var(--surface-2); cursor: default; box-shadow: none; }
.icu-bed.free:hover { border-color: var(--line); transform: none; }
.icu-bed.alerting { border-color: #f4c4c0; background: var(--bad-soft); }
.icu-bed header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.icu-patient { margin: 0; font-size: 13.5px; font-weight: 600; }
.icu-bed p { margin: 2px 0; }
.vitals {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; margin: 10px 0 6px;
}
.vital {
  display: flex; flex-direction: column; gap: 1px;
  padding: 5px 7px; border-radius: var(--radius-sm); background: var(--surface-2);
  font-size: 11px; color: var(--ink-3);
}
.vital strong { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.vital.alarm { background: var(--bad-soft); color: var(--bad); }
.vital.alarm strong { color: var(--bad); }

/* Department screens */
.checklist-rail { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.screen-label { align-self: center; font-size: 13px; color: var(--ink-2); }
.grn-line {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px 14px; margin: 0 0 10px;
}
.grn-line legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.code-block {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; overflow: auto; max-height: 360px;
  font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word;
}

@media (max-width: 700px) {
  .result-row { grid-template-columns: 1fr 1fr; }
  .summary { grid-template-columns: 1fr; gap: 2px 0; }
  .summary dd { margin-bottom: 8px; }
  .icu-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1080px) {
  .grid-2, .grid-side { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card-logo { display: block; height: 26px; width: auto; max-width: 70%; margin: 0 auto 16px; }
  .shell { grid-template-columns: 1fr; }
  .shell.sidebar-hidden { grid-template-columns: 1fr; }
  .shell.sidebar-hidden .sidebar { display: flex; }
  .only-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 258px; z-index: 40;
    transform: translateX(-100%); transition: transform .18s ease-out;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 23, 36, .4); }
  .view { padding: 14px 16px 40px; }
  .breadcrumbs { padding: 10px 16px 0; }
  .topbar { padding: 10px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .who { display: none; }
}

/* Room for the browser's own page header/footer without overlapping content. */
@page { margin: 14mm 12mm 16mm; }

/* Half-page (A5) printing for invoices and OPD bills — half the paper. */
@page half { size: 148mm 210mm; margin: 8mm 8mm 10mm; }

@media print {
  .sidebar, .topbar, .breadcrumbs, .page-actions, .toasts, .mis-toolbar { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .card { box-shadow: none; border-color: #ccc; }

  /* Compact A5 layout — the named page box shrinks the sheet itself. */
  body.print-half .print-target { page: half; font-size: 10.5px; }
  body.print-half .print-target h3 { font-size: 13px; margin: 4px 0; }
  body.print-half .print-target .print-head { margin-bottom: 6px; }
  body.print-half .print-letterhead { padding-bottom: 6px; margin-bottom: 8px; }
  body.print-half .print-letterhead img { height: 30px; width: 30px; }
  body.print-half .print-target table th,
  body.print-half .print-target table td { padding: 3px 6px; }
  body.print-half .print-target .summary dt,
  body.print-half .print-target .summary dd { padding: 3px 0; }
  body.print-half .print-footer { padding-top: 6px; margin-top: 8px; font-size: 9.5px; }

  /* Printing a record panel: only that panel goes on the page. */
  body.printing-drawer > *:not(.drawer-scrim) { display: none !important; }
  body.printing-drawer .drawer-scrim {
    position: static; display: block; background: none; padding: 0;
  }
  body.printing-drawer .drawer {
    position: static; width: auto; max-width: none;
    box-shadow: none; border: 0; overflow: visible;
  }
  body.printing-drawer .drawer-head,
  body.printing-drawer .drawer-actions { display: none !important; }
  body.printing-drawer .print-area { color: #000; }
  body.printing-drawer .print-letterhead { border-color: #000; }
  thead { display: table-header-group; }
  tr, .card { break-inside: avoid; }
}

/* ── Printed-record letterhead + footer (patient-file record panels) ─────── */
.print-letterhead {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 14px;
}
.print-letterhead img { height: 48px; width: 48px; object-fit: contain; flex: none; }
.print-letterhead .pl-name { font-size: 1.12rem; font-weight: 700; }
.print-letterhead .pl-line { font-size: .78rem; color: var(--muted); }
.print-footer {
  margin-top: 22px; border-top: 1px solid var(--line); padding-top: 8px;
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: .75rem; color: var(--muted);
}

/* Timeline entries that resolve to a record open in place. */
/* Visit-grouped timeline cards — one expandable card per OPD encounter / IPD
   stay / calendar day, so the patient file no longer reads as one endless list. */
.tl-groups { display: flex; flex-direction: column; gap: 10px; }
.tl-visit {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.tl-visit summary {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; cursor: pointer; list-style: none;
  background: var(--surface-2); font-size: 13.5px;
}
.tl-visit summary::-webkit-details-marker { display: none; }
.tl-visit .tl-visit-kind {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3);
}
.tl-visit .tl-visit-title { font-weight: 600; }
.tl-visit .tl-visit-meta { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.tl-visit .timeline { margin: 0; padding: 6px 12px 10px; }
/* Visit-card tones — OPD blue, IPD violet, day-groups teal. */
.tl-visit--opd { border-top: 3px solid #2f7fe0; }
.tl-visit--opd summary { background: linear-gradient(90deg, #f2f7fe, var(--surface-2)); }
.tl-visit--opd .tl-visit-kind { color: #1d5fb8; font-weight: 700; }
.tl-visit--ipd { border-top: 3px solid #7a5af8; }
.tl-visit--ipd summary { background: linear-gradient(90deg, #f6f3ff, var(--surface-2)); }
.tl-visit--ipd .tl-visit-kind { color: #6d4af0; font-weight: 700; }
.tl-visit--day { border-top: 3px solid #0e9f8a; }
.tl-visit--day summary { background: linear-gradient(90deg, #e8f7f4, var(--surface-2)); }
.tl-visit--day .tl-visit-kind { color: #0b7f6c; font-weight: 700; }
.tl-item.openable { cursor: pointer; border-radius: 8px; }
.tl-item.openable:hover, .tl-item.openable:focus-visible {
  background: var(--accent-soft); outline: none;
}
.tl-open {
  margin-left: 8px; font-size: .72rem; font-weight: 600;
  color: var(--brand); opacity: 0; transition: opacity .12s;
}
.tl-item.openable:hover .tl-open, .tl-item.openable:focus-visible .tl-open { opacity: 1; }
.print-head { margin-bottom: 10px; }
.print-head h3 { margin: 0 0 2px; }
.raw-json { max-height: 460px; overflow: auto; font-size: .78rem; }

/* ── Patient picker (type-ahead replacing raw UHID fields) ─────────────── */
.patient-picker { display: block; }
.pp-results {
  position: relative; z-index: 30; margin-top: 4px;
  max-height: 320px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); box-shadow: 0 12px 28px rgba(6, 12, 26, .16);
}
.pp-option {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  width: 100%; padding: 9px 12px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.pp-option:last-child { border-bottom: 0; }
.pp-option:hover, .pp-option:focus-visible { background: var(--accent-soft); outline: none; }
.pp-name { font-weight: 600; }
.pp-meta { grid-column: 1; font-size: .82rem; color: var(--muted); }
.pp-tags { grid-column: 2; grid-row: 1 / span 2; align-self: center; display: flex; gap: 4px; flex-wrap: wrap; }
.pp-chosen { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* ── Clickable stat tiles + first-run setup guide ──────────────────────── */
.stat-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.stat-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.setup-progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 12px; }
.setup-progress span { display: block; height: 100%; background: var(--accent); }
.setup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.setup-step { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.setup-step.done { opacity: .6; }
.setup-step.next { border-color: var(--accent); background: var(--accent-soft); }
.setup-mark { color: var(--good); font-weight: 700; text-align: center; }
.setup-text { display: flex; flex-direction: column; gap: 1px; }

/* Diagnosis code catalogue suggestions (consultation note drawer) */
.dx-suggest { max-height: 220px; overflow: auto; border: 1px solid var(--line);
  border-radius: 8px; padding: 4px; background: var(--panel); }
.dx-item { display: flex; gap: 10px; width: 100%; text-align: left; padding: 7px 9px;
  border: 0; background: transparent; border-radius: 6px; cursor: pointer;
  align-items: baseline; }
.dx-item:hover, .dx-item:focus { background: var(--accent-soft); }
.dx-item code { font-weight: 600; min-width: 64px; }
.dx-item span { color: var(--text); font-size: .92em; }

.draft-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.draft-list li { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); }

/* ABHA profile tools — one tab per action */
.ptab-tabs { flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.abha-photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.ptab-tabs .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ptab[hidden] { display: none; }
.ptab { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; }

/* Staff dialog — additional-role checkboxes */
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; margin-top: 6px; }

/* Cross-page patient context banner (2026-09-12) */
.patient-context-banner { display: flex; align-items: center; gap: 10px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 14px; }
.patient-context-banner .pc-label { font-size: .82em; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); }
.patient-context-banner a { font-weight: 700; color: var(--accent); }

/* Live queue — process buttons + fee (enh 40) */
.queue-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.queue-actions .btn { padding: 3px 8px; font-size: .82em; }
.fee-cell { font-weight: 700; color: var(--accent); white-space: nowrap; }

/* Offline blank patient sheet (enh 40) */
.blank-sheet { background: #fff; color: #111; border: 1px solid var(--line);
  border-radius: 10px; padding: 22px; margin-bottom: 12px; }
.blank-sheet-head { text-align: center; border-bottom: 2px solid #000; padding-bottom: 8px; }
.blank-sheet-head h2 { margin: 0; font-size: 1.35em; }
.blank-sheet-head p { margin: 2px 0; font-size: .85em; color: #333; }
.blank-sheet-details { width: 100%; border-collapse: collapse; margin: 12px 0; }
.blank-sheet-details td { border: 1px solid #000; padding: 6px; font-size: .92em; }
.blank-sheet-details td:first-child, .blank-sheet-details td:nth-child(3) { font-weight: 600; background: #f4f4f4; }
.blank-sheet-lines h4 { margin: 14px 0 4px; font-size: .95em; }
.blank-line { border-bottom: 1px solid #999; height: 26px; }
.blank-sheet-foot { text-align: center; font-size: .8em; color: #555; margin-top: 16px; }

/* OT notes — template picker chips (enh 38) */
.ot-note { border-left: 3px solid var(--accent-soft); padding: 6px 10px; margin-bottom: 8px; }
.ot-note h4 { margin: 0 0 4px; }
.template-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.template-chips .btn { font-size: .84em; }

/* Doctor fee editor slots (enh 35) */
.fee-slot-row { display: grid; grid-template-columns: 1fr 80px 80px 90px 28px; gap: 8px; align-items: center; margin-bottom: 6px; }

/* ── enh 40: offline blank sheet (hospital letterhead + patient details) ──── */
.blank-sheet { background: #fff; border: 1px solid var(--line, #e2e8f0); padding: 20px; }
.blank-sheet-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 12px; }
.blank-sheet-head .bs-logo { max-height: 60px; max-width: 170px; object-fit: contain; flex: none; }
.blank-sheet-head h2 { margin: 0; font-size: 1.25em; text-transform: uppercase; letter-spacing: .03em; }
.blank-sheet-head p { margin: 2px 0 0; font-size: 12px; color: #555; }
.blank-sheet-details { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.blank-sheet-details td { border: 1px solid #999; padding: 6px; font-size: 13px; }
.bs-body { display: grid; grid-template-columns: 34% 1fr; gap: 20px; }
.bs-wellness { border-right: 1px solid #999; padding-right: 10px; }
.bs-wellness h4, .bs-writing h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid #777; padding-bottom: 3px; }
.wellness-row { display: flex; align-items: flex-end; margin: 9px 0; font-size: 12.5px; }
.wellness-row span:first-child { white-space: nowrap; margin-right: 6px; }
.wellness-line { flex: 1; border-bottom: 1px dotted #666; height: 1.1em; }
.blank-sheet-space .blank-line { border-bottom: 1px solid #bbb; height: 30px; }
.blank-sheet-foot { text-align: center; font-size: 11px; color: #777; margin-top: 16px; }

/* Ward board — per-ward bed status summary chips */
.bed-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* ── enh 40: live queue process buttons + doctor fee ──────────────────────── */
.queue-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.queue-actions .btn { padding: 3px 8px; font-size: 12px; }
.queue-fee { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── enh 38: OT note template picker ──────────────────────────────────────── */
.ot-tpl-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line, #e2e8f0); }
