/* ENT OPD Manager — mobile-first stylesheet */
:root {
  --brand: #0d366b; --brand-2: #2a78d6; --brand-soft: #e8f1fc;
  --bg: #f4f5f7; --surface: #ffffff; --line: #e3e4e8; --line-2: #ecebe7;
  --text: #16181d; --text-2: #52514e; --muted: #7a7a76;
  --ok: #0f7a3d; --ok-bg: #e6f5ec; --warn: #8a5a00; --warn-bg: #fff4dc;
  --err: #b42318; --err-bg: #fdecea; --info-bg: #e8f1fc;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --side: 240px; --top: 56px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif; color: var(--text); background: var(--bg); line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
code { background: #f1f1ef; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.ic { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.strong { font-weight: 600; }
.inline { display: inline; }
.count { font-size: .8em; font-weight: 600; background: var(--brand-soft); color: var(--brand); border-radius: 99px; padding: 2px 10px; vertical-align: middle; }

/* ---------- App shell ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--top); background: var(--brand); color: #fff; display: flex; align-items: center; gap: 8px; padding: 0 12px; z-index: 30; padding-top: env(safe-area-inset-top); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #fff; color: var(--brand); font-weight: 800; font-size: .75rem; letter-spacing: .5px; flex: none; }
.logo.lg { width: 56px; height: 56px; font-size: 1.05rem; border-radius: 14px; background: var(--brand); color: #fff; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.who { display: none; flex-direction: column; text-align: right; font-size: .85rem; margin-right: 6px; }
.who small { opacity: .75; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.content .icon-btn { color: var(--text-2); }
.content .icon-btn:hover { background: var(--bg); }

.sidebar { position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); background: var(--surface); border-right: 1px solid var(--line); padding: 12px 8px; overflow-y: auto; z-index: 25; transform: translateX(-100%); transition: transform .2s ease; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: var(--text-2); font-weight: 500; }
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--brand-soft); color: var(--brand); }
.scrim { display: none; }
body.nav-open .sidebar { transform: none; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 20; }

.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: flex; z-index: 30; }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .72rem; color: var(--muted); }
.bottomnav a.active { color: var(--brand); font-weight: 600; }
.bottomnav a:hover { text-decoration: none; }

.content { padding: calc(var(--top) + 16px) 14px calc(80px + env(safe-area-inset-bottom)); max-width: 1280px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px 14px; }
.only-mobile { display: inline-grid; }

@media (min-width: 900px) {
  .sidebar { transform: none; }
  .scrim, .bottomnav, .only-mobile { display: none !important; }
  .content { margin-left: var(--side); padding: calc(var(--top) + 24px) 28px 40px; }
  .who { display: flex; }
}

/* ---------- Cards, grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr; }
.grid.tight { gap: 0 12px; }
@media (min-width: 760px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.page-title { font-size: 1.45rem; margin: 0 0 .5rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.page-head .page-title { margin: 0; }
.hello { margin-bottom: 12px; }
.hello .page-title { margin: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0a2b56; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.block { width: 100%; }
.btn.lg { min-height: 50px; font-size: 1.05rem; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn .ic { width: 18px; height: 18px; }
.link-btn { background: none; border: 0; color: var(--brand-2); font: inherit; cursor: pointer; padding: 6px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Forms ---------- */
.form label, .filters label { display: block; font-weight: 600; font-size: .9rem; color: var(--text-2); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; min-height: 44px; padding: 9px 12px; border: 1px solid #cfd2d8; border-radius: 10px; background: #fff; color: var(--text); font: inherit; font-size: 16px; /* 16px stops iOS zoom */ }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(42, 120, 214, .25); border-color: var(--brand-2); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; margin: 0; display: inline-block; accent-color: var(--brand); vertical-align: middle; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); margin: 10px 0; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; font-size: .9rem; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea { margin-top: 0; }
.err-text { color: var(--err); display: block; margin-top: 4px; }
.warn-text { color: var(--warn); }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: grid; place-items: center; padding: 0 12px; background: var(--bg); border: 1px solid #cfd2d8; border-right: 0; border-radius: 10px 0 0 10px; color: var(--text-2); font-weight: 600; }
.input-prefix input { border-radius: 0 10px 10px 0; font-size: 1.15rem; letter-spacing: 1px; }
.reg-form { max-width: 640px; }
.otp-input { font-size: 1.8rem !important; letter-spacing: 12px; text-align: center; font-weight: 700; }
details.more { margin: 6px 0 12px; }
details.more summary { cursor: pointer; color: var(--brand-2); font-weight: 600; padding: 6px 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-opt { margin: 0 !important; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; border: 1px solid #cfd2d8; border-radius: 99px; background: #fff; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg-opt input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg-opt input:focus-visible + span { outline: 3px solid rgba(42, 120, 214, .35); }

.filters { padding: 12px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; }
.filter-row label { margin: 0; flex: 1 1 140px; }
.filter-row > select, .filter-row > input { flex: 1 1 150px; width: auto; margin: 0; }
.search-box { flex: 3 1 240px; position: relative; }
.search-box .ic { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search-box input { margin: 0; padding-left: 40px; }
.dash-filters .custom-range { display: none; }
.dash-filters.show-custom .custom-range { display: block; }
.dash-filters .presets { margin-bottom: 10px; }

/* ---------- Alerts, badges, chips ---------- */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid transparent; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe5cd; }
.alert.err { background: var(--err-bg); color: var(--err); border-color: #f5c2bd; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #f3dca6; }
.alert.info { background: var(--info-bg); color: var(--brand); border-color: #c8dcf5; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; background: #eef0f3; color: var(--text-2); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.red { background: var(--err-bg); color: var(--err); }
.badge.green { background: var(--ok-bg); color: var(--ok); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 8px 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); font-size: .82rem; }
label.chip { margin: 0; }
.pill { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 8px; background: var(--bg); border-radius: 99px; font-size: .82rem; }

/* ---------- Tiles (KPIs) ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-height: 96px; }
.tile-label { color: var(--text-2); font-size: .85rem; font-weight: 600; }
.tile-value { font-size: 1.7rem; font-weight: 750; letter-spacing: -.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.tile-sub { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tile.skeleton { background: linear-gradient(90deg, #f0f1f3 25%, #e7e8eb 50%, #f0f1f3 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.delta { font-weight: 700; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--err); }

.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 760px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.quick-btn { display: flex; align-items: center; gap: 10px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.quick-btn:hover { text-decoration: none; border-color: var(--brand-2); }
.quick-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Tables (become cards on phones) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafafa; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table tr.deleted td { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, .25); }
.table tr.warn-row td { background: #fffaf0; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.empty { text-align: center; color: var(--muted); padding: 30px; }
.table.mini th, .table.mini td { padding: 6px 8px; }
.table-wrap { overflow-x: auto; }
@media (max-width: 759px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table.responsive td { border: 0; padding: 3px 0; display: flex; gap: 10px; }
  .table.responsive td::before { content: attr(data-label); flex: 0 0 92px; color: var(--muted); font-size: .8rem; font-weight: 600; }
  .table.responsive td.actions { justify-content: flex-end; }
  .table.responsive td.actions::before, .table.responsive td.empty::before { display: none; }
  .perm-matrix td::before { flex-basis: 50%; }
}
.perm-matrix .group-row td { background: #f6f7f9; font-weight: 700; color: var(--brand); }
.perm-matrix .yes { color: var(--ok); font-weight: 800; }
.perm-matrix .no { color: #c3c2b7; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 12px 0; }

/* lists */
.plist { list-style: none; margin: 0; padding: 0; }
.plist li a { display: flex; flex-direction: column; padding: 10px 2px; border-bottom: 1px solid var(--line-2); color: var(--text); }
.plist li:last-child a { border-bottom: 0; }
.plist .pname { font-weight: 600; }
.plist .pmeta { font-size: .85rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 6px 0 6px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline li.current::before { background: var(--brand-2); }
.timeline li.current a { font-weight: 700; }
.timeline li.deleted { opacity: .55; }
.danger-zone { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 12px; }
.danger-zone summary { color: var(--err); cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.success-card { background: var(--ok-bg); border-color: #bfe5cd; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }

.lookup { margin-top: 8px; padding: 10px; border-radius: 10px; background: var(--info-bg); font-size: .9rem; }
.lookup-head { font-weight: 600; margin-bottom: 6px; color: var(--brand); }
.lookup-item { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid #c8dcf5; border-radius: 8px; padding: 9px 10px; margin-top: 6px; font: inherit; cursor: pointer; color: var(--text); }
.lookup-item small { color: var(--muted); display: block; }
.lookup-item.picked { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(13, 54, 107, .2); }

/* ---------- Auth ---------- */
.auth-card { width: 100%; max-width: 420px; padding: 28px 22px; }
.auth-card.wide { max-width: 560px; }
.auth-brand { text-align: center; margin-bottom: 16px; }
.auth-brand h1 { font-size: 1.35rem; margin: 12px 0 4px; }
.log { padding-left: 20px; font-size: .9rem; }

/* ---------- Choice cards (export) ---------- */
.choice-cards { display: grid; gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .choice-cards { grid-template-columns: 1fr 1fr; } }
.choice { display: flex !important; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; margin: 0 !important; color: var(--text) !important; }
.choice input { margin-top: 3px; }
.choice small { display: block; font-weight: 400; color: var(--text-2); margin-top: 4px; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- Dashboard ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1000px) { .chart-grid { grid-template-columns: 1fr 1fr; } .chart-card.span-2 { grid-column: span 2; } }
.chart-card { margin: 0; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 280px; }
.chart-table { max-height: 280px; overflow: auto; }

/* ---------- AI assistant ---------- */
.ai-form { display: flex; gap: 8px; align-items: center; }
.ai-form input { margin: 0; flex: 1; min-height: 52px; font-size: 16px; border-radius: 26px; padding: 0 18px; }
.mic-btn { flex: none; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 12px rgba(13, 54, 107, .3); }
.mic-btn .ic { width: 26px; height: 26px; }
.mic-btn.on { background: var(--err); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(180, 35, 24, .5); } 70% { box-shadow: 0 0 0 16px rgba(180, 35, 24, 0); } 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0); } }
@media (max-width: 520px) { .ai-form { flex-wrap: wrap; } .ai-form input { flex-basis: calc(100% - 66px); } .ai-form .btn { width: 100%; } }
.ai-status { min-height: 1.4em; margin: 8px 4px; font-size: .9rem; color: var(--muted); }
.ai-status.working { color: var(--brand-2); }
.ai-status.err { color: var(--err); }
.ai-status.ok { color: var(--ok); }
.lang-switch { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--text-2); }
.lang-switch label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-weight: 500; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.chip-btn { border: 1px solid #c8dcf5; background: var(--brand-soft); color: var(--brand); border-radius: 99px; padding: 7px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.chip-btn.ghost { background: #fff; border-color: var(--line); color: var(--text-2); }
.ai-answer .ai-q { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.ai-summary { font-size: 1rem; margin: 8px 0; }
.big-number { font-size: 2.6rem; font-weight: 800; color: var(--brand); letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.hbar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.hbar span { display: block; height: 14px; border-radius: 0 4px 4px 0; background: var(--brand-2); }
.hbar b { font-variant-numeric: tabular-nums; font-size: .88rem; }

/* settings */
.checks { list-style: none; padding: 0; margin: 0 0 12px; }
.checks li { padding: 6px 0; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; }
.checks li.pass b { color: var(--ok); }
.checks li.fail b { color: var(--warn); }
.checks small { color: var(--muted); }
.wa-preview { white-space: pre-wrap; background: #e7fbe5; padding: 12px; border-radius: 10px; font-family: inherit; }
.perm-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .perm-grid { grid-template-columns: 1fr 1fr; } }
.perm-grid label.check { margin: 6px 0; }

@media print {
  .topbar, .sidebar, .bottomnav, .filters, .row-actions, .actions { display: none !important; }
  .content { margin: 0; padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* ================= Billing ================= */
.grid.three { grid-template-columns: 1fr; }
.grid.four { grid-template-columns: 1fr 1fr; }
@media (min-width: 760px) { .grid.three { grid-template-columns: repeat(3, 1fr); } .grid.four { grid-template-columns: repeat(4, 1fr); } }
.r { text-align: right; }
.due-text { color: var(--err); }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 10px 14px; color: var(--text-2); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; }
.card-head.pad { padding: 14px 16px 0; }

.items-head, .item-row { display: grid; grid-template-columns: minmax(180px, 3fr) 1fr 1fr 0.7fr 1fr 40px; gap: 8px; align-items: center; }
.items-head { font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; padding: 0 2px 6px; border-bottom: 1px solid var(--line); }
.items-head span:nth-child(3), .items-head span:nth-child(4), .items-head span:nth-child(5) { text-align: right; }
.item-row { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.item-row label { margin: 0 !important; }
.item-row input, .item-row select { margin: 0; }
.item-row .i-rate, .item-row .i-qty { text-align: right; }
.item-row .i-rate.ro { background: #f6f7f9; color: var(--text-2); }
.item-row .i-rate.changed { border-color: #e2a400; background: #fffaf0; }
.item-row .i-unit { color: var(--muted); font-size: .85rem; }
.item-row .i-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.only-mobile-label { display: none; }
#addItem { margin-top: 10px; }
@media (max-width: 759px) {
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr; background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
  .item-row .lbl-svc { grid-column: 1 / -1; }
  .item-row .i-unit { grid-column: 1 / -1; }
  .item-row .i-amt { text-align: left; font-size: 1.05rem; }
  .item-row .i-del { justify-self: end; }
  .only-mobile-label { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
}
.totals { background: #f8fafd; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; align-self: start; }
.totals > div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.totals .net { border-top: 2px solid var(--brand); margin-top: 6px; padding-top: 10px; font-size: 1.25rem; color: var(--brand); }
.totals .due b { color: var(--err); }
.totals .words { display: block; font-style: italic; color: var(--text-2); font-size: .88rem; }
.totals .alert { display: block; margin: 8px 0 0; }
.sticky-actions { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; gap: 10px; background: rgba(244, 245, 247, .94); backdrop-filter: blur(6px); padding: 10px 0; z-index: 5; }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }

.bill-layout { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1100px) { .bill-layout { grid-template-columns: minmax(0, 1fr) 340px; } .bill-side { position: sticky; top: calc(var(--top) + 16px); } }
.bill-paper { padding: 22px; }
.bp-head { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; border-bottom: 2px solid var(--brand); padding-bottom: 10px; }
.bp-logo { width: 64px; height: 64px; object-fit: contain; }
.bp-hosp h2 { margin: 0; color: var(--brand); font-size: 1.35rem; }
.bp-hosp h2 small { font-size: .7em; }
.bp-hosp div { font-size: .82rem; color: var(--text-2); }
.bp-doc { grid-column: 1 / -1; font-size: .82rem; color: var(--text-2); }
@media (min-width: 700px) { .bp-head { grid-template-columns: 64px 1fr auto; } .bp-doc { grid-column: auto; text-align: right; } }
.bp-title { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--brand); color: #fff; font-weight: 700; padding: 7px 12px; border-radius: 6px; margin: 10px 0; font-size: .9rem; }
.bp-grid { display: grid; grid-template-columns: 110px 1fr; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 0 0 12px; font-size: .9rem; }
.bp-grid dt, .bp-grid dd { padding: 6px 10px; border-bottom: 1px solid var(--line-2); margin: 0; }
.bp-grid dt { color: var(--muted); font-size: .8rem; background: #fafbfc; }
@media (min-width: 700px) { .bp-grid { grid-template-columns: 110px 1fr 120px 1fr; } .bp-grid dd.wide { grid-column: span 3; } }
.bp-items th { background: var(--brand-soft); color: var(--brand); }
.bp-items td.r, .bp-items th.r { text-align: right; }
.bp-bottom { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 12px; }
@media (min-width: 700px) { .bp-bottom { grid-template-columns: 1fr 280px; } }
.bp-bottom .words { font-style: italic; }
.bp-terms { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 14px; font-size: .85rem; color: var(--text-2); }
.bp-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; font-size: .85rem; }
.bp-sign .sigline { display: block; border-bottom: 1px solid #333; height: 44px; margin-bottom: 4px; }
.bp-mlc { text-align: center; font-weight: 800; border: 2px solid #111; width: max-content; margin: 18px auto 0; padding: 4px 18px; letter-spacing: 1px; }
.mini-list { list-style: none; padding: 0; margin: 6px 0; font-size: .88rem; }
.mini-list li { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.inline-details { display: inline; }
.inline-details summary { display: inline; color: var(--err); cursor: pointer; font-size: .8rem; margin-left: 4px; }
.inline-details form { display: flex; gap: 6px; margin-top: 6px; }
.inline-details input { margin: 0; min-height: 34px; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-form input, .row-form select { width: auto; flex: 1 1 140px; margin: 0; }
.row-form input.narrow { flex: 0 0 70px; }
.row-form label.check { margin: 0; }
.form-row-cell { padding: 8px 12px !important; }
.pkg-row { margin-bottom: 8px; }
.branding { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.brand-prev { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
