/* Medinet Finance & Accounts — desktop UI */
:root {
  --font: 'Nirmala UI', 'Segoe UI', 'Noto Sans Bengali', 'Hind Siliguri', system-ui, -apple-system, sans-serif;
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --ink: #0f1f33;
  --ink-2: #44546a;
  --ink-3: #6b7a90;
  --brand: #0b5cc2;
  --brand-600: #0a4ea6;
  --brand-50: #e8f1fd;
  --brand-100: #c8dcf8;
  --nav: #062d63;
  --accent: #22b8f0;
  --accent-red: #d7262e;
  --nav-2: #0a3c80;
  --nav-ink: #cfe0f5;
  --blue: #2a78d6;
  --blue-50: #e8f1fc;
  --orange: #eb6834;
  --good: #12805c; --good-bg: #e6f6ef;
  --warn: #b25e09; --warn-bg: #fff4e0;
  --bad: #c02b2b; --bad-bg: #fdecec;
  --info: #1d5fb8; --info-bg: #e8f1fc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 33, 55, .06), 0 2px 8px rgba(16, 33, 55, .05);
  --shadow-lg: 0 18px 50px rgba(10, 30, 55, .22);
  --sidebar-w: 248px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.chip svg.i { width: 15px; height: 15px; }
.list-item .avatar svg.i { width: 17px; height: 17px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: Consolas, 'Cascadia Mono', monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--nav) 0%, #041d42 100%); color: var(--nav-ink); display: flex; flex-direction: column; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid #ffffff12; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(150deg, #2a9df4, #0b5cc2); display: grid; place-items: center; flex: none; box-shadow: 0 6px 16px #0006; }
.brand-logo svg { width: 22px; height: 22px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: #8fa6bf; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.nav::-webkit-scrollbar { width: 6px; } .nav::-webkit-scrollbar-thumb { background: #ffffff22; border-radius: 9px; }
.nav-group { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #6f87a1; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--nav-ink); text-decoration: none; font-size: 14px; margin: 1px 0; position: relative; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: #ffffff10; color: #fff; }
.nav a.active { background: linear-gradient(90deg, #22b8f040, #22b8f012); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: #3cc8ff; }
.nav .badge-count { margin-left: auto; background: #f59e0b; color: #1a1300; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid #ffffff12; font-size: 12px; color: #7f97b0; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 26px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar .crumb { color: var(--ink-3); font-size: 13px; }
.topbar .spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-3); border-radius: 99px; padding: 4px 11px; font-size: 12.5px; color: var(--ink-2); }
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px 4px 4px; cursor: pointer; }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.user-btn .who { text-align: left; line-height: 1.15; }
.user-btn .who b { display: block; font-size: 13px; }
.user-btn .who span { font-size: 11.5px; color: var(--ink-3); }
.content { flex: 1; overflow-y: auto; padding: 22px 26px 40px; }
.content-inner { max-width: 1480px; margin: 0 auto; }
.menu { position: absolute; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 220px; z-index: 50; }
.menu button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--surface-3); }

/* ---------- Page header & tabs ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.tabs .tab-count { background: var(--warn-bg); color: var(--warn); font-size: 11px; border-radius: 99px; padding: 0 7px; margin-left: 4px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15.5px; font-weight: 700; }
.card-head .sub { color: var(--ink-3); font-size: 12.5px; }
.card-body { padding: 16px 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: 1fr; } }

/* KPI tiles */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label { color: var(--ink-3); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .label i { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); }
.kpi .label i svg { width: 16px; height: 16px; }
.kpi .value { font-size: 25px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .foot { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.kpi.good .label i { background: var(--good-bg); color: var(--good); }
.kpi.bad .label i { background: var(--bad-bg); color: var(--bad); }
.kpi.info .label i { background: var(--info-bg); color: var(--info); }
.kpi.warn .label i { background: var(--warn-bg); color: var(--warn); }
.delta-up { color: var(--good); font-weight: 600; }
.delta-down { color: var(--bad); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 14px; line-height: 1.2; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); border-color: #b5c1d1; }
.btn:focus-visible, .input:focus, select:focus, textarea:focus, input:focus { outline: 3px solid #0b5cc240; outline-offset: 1px; border-color: var(--brand); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { background: var(--surface); color: var(--bad); border-color: #f1b8b8; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.solid-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.lg { padding: 12px 20px; font-size: 16px; border-radius: 11px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 34px; height: 34px; padding: 0; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: grid; gap: 5px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field label .req { color: var(--bad); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, input[type=text], input[type=number], input[type=date], input[type=time], input[type=password], input[type=search], input[type=email], input[type=tel], select, textarea {
  width: 100%; border: 1px solid var(--line-strong); background: #fff; border-radius: 9px; padding: 8px 11px; min-height: 38px; font-size: 14.5px; }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--brand); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.input-money { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 34px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { min-width: 260px; flex: 1; max-width: 420px; }
.toolbar select, .toolbar input[type=date] { width: auto; }
.row > input[type=date], .row > select, .row > input[type=number] { width: auto; }
.form-error { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; }
.callout { border-radius: 10px; padding: 11px 14px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; line-height: 1.55; }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout.info { background: var(--info-bg); color: #163f78; }
.callout.warn { background: var(--warn-bg); color: #6b3a05; }
.callout.good { background: var(--good-bg); color: #0d5c41; }
.callout.bad { background: var(--bad-bg); color: #7d1d1d; }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius); }
.card > .table-wrap { border-radius: 0 0 var(--radius) var(--radius); }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.8px; }
table.t th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--ink-2); text-align: left; font-weight: 600; font-size: 12.5px; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tbody tr:hover td { background: #f7fafd; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--line-strong); padding: 9px 12px; }
table.t tr.clickable { cursor: pointer; }
table.t .sub { color: var(--ink-3); font-size: 12px; }
table.t td.actions { white-space: nowrap; text-align: right; }
table.t td.actions .btn { margin-left: 4px; }
table.t tr.group td { background: var(--surface-3); font-weight: 700; color: var(--ink-2); }
.empty { text-align: center; color: var(--ink-3); padding: 40px 20px; }
.empty svg { width: 44px; height: 44px; color: #b8c4d3; display: block; margin: 0 auto 8px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.gray { background: var(--surface-3); color: var(--ink-2); }
.pill { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 12px; background: var(--surface-3); color: var(--ink-2); font-weight: 600; }

/* ---------- Modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(9, 22, 38, .45); display: grid; place-items: center; z-index: 100; padding: 24px; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(640px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; animation: pop .14s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: .6; } }
.modal.wide { width: min(960px, 100%); }
.modal.xwide { width: min(1200px, 100%); }
.modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-head .sub { font-size: 12.5px; color: var(--ink-3); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }

/* toast */
.toasts { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 10px; z-index: 200; }
.toast { background: #0f1f33; color: #fff; border-radius: 11px; padding: 12px 16px; min-width: 280px; max-width: 460px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: pop .16s ease-out; font-size: 14px; }
.toast.good { background: #0c5e44; } .toast.bad { background: #9c2222; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* ---------- Login / setup ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-art { background: radial-gradient(900px 500px at 15% 10%, #1468c8 0%, #062d63 55%, #031634 100%); color: #dbe7f4; padding: 54px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-art::after { content: ''; position: absolute; right: -160px; bottom: -160px; width: 460px; height: 460px; border-radius: 50%; background: radial-gradient(#22b8f055, transparent 70%); }
.auth-art h1 { font-size: 38px; color: #fff; margin-top: auto; line-height: 1.15; }
.auth-art p { color: #a9c1da; font-size: 16px; max-width: 460px; }
.auth-art .features { display: grid; gap: 12px; margin: 26px 0 auto; }
.auth-art .features div { display: flex; gap: 12px; align-items: center; color: #d4e2f1; }
.auth-art .features svg { width: 20px; height: 20px; color: #6fd3ff; flex: none; }
.auth-form { display: grid; place-items: center; padding: 40px; }
.auth-card { width: min(420px, 100%); }
.auth-card h2 { font-size: 26px; }
.auth-card .lead { color: var(--ink-3); margin: 6px 0 24px; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* ---------- Billing POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
@media (max-width: 1250px) { .pos { grid-template-columns: 1fr; } }
.patient-card { display: flex; gap: 14px; align-items: center; }
.patient-card .avatar { width: 46px; height: 46px; font-size: 18px; }
.svc-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; max-height: 320px; overflow-y: auto; padding: 2px; }
.svc { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; cursor: pointer; text-align: left; display: grid; gap: 2px; }
.svc:hover { border-color: var(--brand); background: var(--brand-50); }
.svc b { font-size: 13.5px; }
.svc .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); }
.svc .price { color: var(--ink); font-weight: 700; }
.summary-box { position: sticky; top: 0; }
.sum-row { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.sum-row.total { font-size: 20px; font-weight: 800; border-top: 1px dashed var(--line-strong); margin-top: 6px; padding-top: 12px; }
.sum-row.due { color: var(--bad); font-weight: 700; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pay-methods button { border: 1px solid var(--line-strong); background: #fff; border-radius: 9px; padding: 8px 4px; cursor: pointer; font-weight: 600; font-size: 13px; }
.pay-methods button.active { background: var(--brand-50); border-color: var(--brand); color: var(--brand); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.qty button { border: 0; background: var(--surface-3); width: 26px; height: 30px; cursor: pointer; font-weight: 700; }
.qty input { width: 40px; border: 0; text-align: center; min-height: 30px; padding: 0; border-radius: 0; }
.cart td input.disc { width: 64px; min-height: 30px; padding: 4px 6px; text-align: right; }
.steps { display: flex; gap: 8px; margin-bottom: 14px; }
.steps span { flex: 1; text-align: center; font-size: 12.5px; padding: 6px; border-radius: 8px; background: var(--surface-3); color: var(--ink-3); font-weight: 600; }
.steps span.on { background: var(--brand-50); color: var(--brand); }

/* ---------- Charts ---------- */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: #e8edf3; stroke-width: 1; }
.chart .axis-text { fill: #6b7a90; font-size: 11px; font-family: var(--font); }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip { position: absolute; pointer-events: none; background: #0f1f33; color: #fff; padding: 7px 10px; border-radius: 8px; font-size: 12.5px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: var(--shadow-lg); z-index: 5; }
.chart-tip b { display: block; margin-bottom: 2px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; padding: 5px 0; }
.hbar .track { height: 12px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--blue); border-radius: 0 4px 4px 0; }

/* checklist */
.checklist { display: grid; gap: 8px; }
.checklist a, .checklist div.item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); background: #fff; }
.checklist a:hover { border-color: var(--brand); }
.checklist .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; flex: none; }
.checklist .done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.checklist .tick svg { width: 14px; height: 14px; }

/* list items */
.list-item { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
.dl dt { color: var(--ink-3); } .dl dd { margin: 0; font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.kbd { font-family: Consolas, monospace; font-size: 11.5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: #fff; }

/* help */
.help h3 { font-size: 17px; margin: 22px 0 8px; }
.help h3:first-child { margin-top: 0; }
.help p, .help li { line-height: 1.75; color: var(--ink-2); }
.help ol, .help ul { padding-left: 22px; }
.help-nav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; }
.help-nav a:hover, .help-nav a.active { background: var(--brand-50); color: var(--brand); }

/* ---------- Print ---------- */
.print-only { display: none; }
#print-root { display: none; }
@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block !important; }
  .no-print { display: none !important; }
}
.doc { font-family: var(--font); color: #111; font-size: 12.5px; }
.doc .doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 10px; }
.doc .doc-head h1 { font-size: 20px; }
.doc .doc-title { text-align: center; font-size: 15px; font-weight: 700; margin: 6px 0 10px; letter-spacing: .02em; }
.doc table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.doc th, .doc td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
.doc th { background: #f1f1f1; }
.doc .num { text-align: right; }
.doc .tot td { font-weight: 700; background: #f7f7f7; }
.doc .sign { display: flex; justify-content: space-between; margin-top: 46px; }
.doc .sign div { border-top: 1px solid #333; padding-top: 4px; width: 30%; text-align: center; }
.doc .foot { margin-top: 12px; font-size: 11px; color: #444; text-align: center; }
.doc.receipt { max-width: 760px; margin: 0 auto; }
.doc .stamp { display: inline-block; border: 2px solid; padding: 2px 10px; border-radius: 6px; font-weight: 800; transform: rotate(-6deg); }
.doc .stamp.paid { color: #12805c; } .doc .stamp.due { color: #c02b2b; }

/* ---------- v3 branding ---------- */
.brand-logo:has(img) { background: #fff; padding: 3px; }
.logo-img { width: 100%; height: 100%; object-fit: contain; border-radius: 7px; display: block; }
.doc .doc-head { gap: 12px; }
.doc .doc-logo { height: 54px; max-width: 140px; object-fit: contain; }
.brand-name .red { color: #ff5a60; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 280px; overflow: auto; }
.picker-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.picker-list button:hover, .picker-list button:focus { background: var(--brand-50); }
.picker-chosen { margin-top: 6px; min-height: 24px; }
.picker-chosen .chip { gap: 6px; }
.link-btn { border: 0; background: none; color: var(--bad); cursor: pointer; font-weight: 700; padding: 0 4px; }
.brand-preview { display: flex; align-items: center; gap: 18px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); }
.swatch { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; }
.swatch i { width: 22px; height: 22px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 1px #0002; }
tr.group-row td { background: var(--brand-50); font-weight: 700; }
.topbar { border-bottom: 3px solid var(--brand); }
.report-body .card { overflow-x: auto; }
.report-body { min-width: 0; }
.tabs { flex-wrap: wrap; row-gap: 2px; }

/* ---------- v4 print: letterhead, A5/A4 ---------- */
.doc .letterhead { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid #d7262e; padding-bottom: 6px; margin-bottom: 8px; }
.doc .letterhead .doc-logo { height: 58px; width: 58px; object-fit: contain; flex: none; }
.doc .letterhead .lh-text { flex: 1; line-height: 1.3; }
.doc .letterhead h1 { font-size: 21px; color: #062d63; letter-spacing: .2px; }
.doc .letterhead .lh-sub { font-weight: 600; color: #333; }
.doc .letterhead .lh-bn { font-weight: 700; color: #b3121b; font-size: 1.05em; }
.doc .letterhead .lh-addr, .doc .letterhead .lh-contact { font-size: 11.5px; color: #333; }
.doc .letterhead .lh-meta { text-align: right; font-size: 10.5px; color: #555; flex: none; }
.doc .doc-title { border: 1.5px solid #111; border-radius: 4px; display: table; margin: 6px auto 8px; padding: 2px 16px; }
.doc .doc-sub { text-align: center; margin: -4px 0 8px; font-size: 11.5px; }
.doc .kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 18px; margin: 4px 0 6px; }
.doc .kv div { display: flex; gap: 6px; } .doc .kv b { min-width: 92px; font-weight: 600; }
.doc .words { font-style: italic; margin: 4px 0; }
.doc .notes { border: 1px solid #999; border-radius: 4px; padding: 4px 8px; margin-top: 8px; font-size: 11px; text-align: center; }
.doc .depts { display: flex; justify-content: space-around; font-weight: 700; font-size: 11px; margin-top: 6px; }
.doc .barcode { font-family: 'Libre Barcode 39', monospace; font-size: 30px; line-height: 1; }
/* A5 = half of A4: compact type so a whole invoice/receipt fits on one page */
.doc.paper-a5 { font-size: 10.5px; }
.doc.paper-a5 .letterhead .doc-logo { height: 44px; width: 44px; }
.doc.paper-a5 .letterhead h1 { font-size: 16px; }
.doc.paper-a5 .letterhead .lh-addr, .doc.paper-a5 .letterhead .lh-contact { font-size: 9.5px; }
.doc.paper-a5 .letterhead .lh-meta { font-size: 8.5px; }
.doc.paper-a5 .doc-title { font-size: 12.5px; }
.doc.paper-a5 th, .doc.paper-a5 td { padding: 2px 4px; }
.doc.paper-a5 .sign { margin-top: 30px; }
.doc.paper-a5 .kv b { min-width: 74px; }
.doc.paper-a4 { font-size: 12px; }
.btn.ghost { background: transparent; }
/* v4: role editor */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; max-height: 52vh; overflow: auto; padding-right: 4px; }
.perm-group { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px 8px; margin: 0; }
.perm-group legend { padding: 0 4px; }
.perm-group label.perm { display: flex; gap: 6px; align-items: flex-start; padding: 3px 0; font-size: 13px; }
.perm-group input:disabled + span { opacity: .45; }
.pill.soft { background: var(--brand-50, #eaf2fb); color: var(--brand, #1565c0); }
.role-item { align-items: flex-start; }
.dropzone { display: flex; gap: 8px; align-items: center; justify-content: center; border: 2px dashed var(--line); border-radius: 10px; padding: 14px; color: var(--ink-2); cursor: pointer; font-size: 13px; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-50, #eef5fc); }
.gl-lines { overflow-x: auto; }
.gl-lines input { width: 100%; box-sizing: border-box; }
.gl-lines td { vertical-align: top; }

/* =====================================================================
   v5.0 — notifications, quick search, feature centre, cash closing, QR, mobile layout
   ===================================================================== */
.menu-btn { display: none; }
.search-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3); border-radius: 99px; padding: 5px 8px 5px 12px; cursor: pointer; font-size: 13px; min-width: 220px; }
.search-btn:hover { border-color: var(--brand); color: var(--ink-2); }
.search-btn span:first-of-type { flex: 1; text-align: left; }
.bell { position: relative; }
.bell svg { width: 20px; height: 20px; }
.bell-count { position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; border-radius: 99px; background: var(--accent-red); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; line-height: 1; }
.notif-panel { position: fixed; right: 16px; width: min(400px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 90px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 60; display: flex; flex-direction: column; overflow: hidden; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.notif-list { overflow-y: auto; }
.notif { display: flex; gap: 11px; padding: 11px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: #f3f8ff; }
.notif.unread .t { font-weight: 700; }
.notif .avatar { width: 32px; height: 32px; flex: none; }
.notif .avatar svg { width: 16px; height: 16px; }
.notif .k-approval { background: var(--warn-bg); color: var(--warn); } .notif .k-request { background: var(--info-bg); color: var(--info); }
.notif .k-cash_closing { background: var(--good-bg); color: var(--good); } .notif .k-alert { background: var(--bad-bg); color: var(--bad); }
.notif .t { font-size: 13.5px; line-height: 1.35; } .notif .b { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; } .notif .w { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.modal.qs-modal { width: min(620px, 100%); align-self: start; margin-top: 8vh; }
.qs-results { display: grid; gap: 2px; max-height: 55vh; overflow-y: auto; }
.qs-row { display: flex; gap: 12px; align-items: center; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 9px; cursor: pointer; width: 100%; }
.qs-row.sel, .qs-row:hover { background: var(--brand-50); }
.qs-row svg { width: 17px; height: 17px; color: var(--ink-3); }
.feature-group { font-size: 15px; color: var(--ink-2); margin-top: 6px; }
.feature-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; align-content: start; }
.feature.on { border-color: #9fd8c2; box-shadow: inset 3px 0 0 var(--good); }
.feature.locked { background: var(--surface-2); }
.feature.locked b { color: var(--ink-2); }
.feature .badge svg { width: 12px; height: 12px; }
input.switch { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: 99px; background: #c6d0dc; position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
input.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #0003; transition: left .15s; }
input.switch:checked { background: var(--good); }
input.switch:checked::after { left: 21px; }
input.switch:disabled { opacity: .5; cursor: not-allowed; }
.ai-summary { display: flex; gap: 12px; align-items: flex-start; background: linear-gradient(120deg, #eef6ff, #f3fbf7); border: 1px solid #d6e6f7; border-radius: 10px; padding: 12px 14px; line-height: 1.7; }
.ai-summary > svg { width: 22px; height: 22px; color: var(--brand); flex: none; margin-top: 3px; }
a.alert-link { text-decoration: none; align-items: center; }
a.alert-link:hover { filter: brightness(.97); }
.note-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.note-grid label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.note-grid label span { width: 70px; flex: none; text-align: right; }
.note-grid input { min-height: 34px; text-align: right; }
.closing-var { font-size: 15px; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; }
.pair-code { font-family: Consolas, monospace; font-size: 30px; font-weight: 800; letter-spacing: .12em; color: var(--brand); }
.qr { display: inline-block; line-height: 0; }
.qr svg { display: block; }
.qr-box { display: flex; align-items: center; gap: 8px; font-size: 10.5px; line-height: 1.3; max-width: 230px; }
.qr-box .qr { border: 1px solid #ddd; padding: 2px; background: #fff; }
.nav-backdrop { display: none; }

/* ---------- phones & small tablets ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; height: 100dvh; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); z-index: 130; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(9, 22, 38, .45); z-index: 120; }
  .main { height: 100dvh; }
  .menu-btn { display: inline-flex; }
  .topbar { height: 56px; padding: 0 8px 0 6px; gap: 6px; }
  .topbar h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .topbar .date-chip, .user-btn .who, .search-btn span { display: none; }
  .search-btn { min-width: 0; border: 0; background: none; padding: 8px; }
  .search-btn svg { width: 20px; height: 20px; }
  .user-btn { border: 0; padding: 2px; }
  .content { padding: 14px 12px 70px; -webkit-overflow-scrolling: touch; }
  .page-head { margin-bottom: 12px; } .page-head h2 { font-size: 19px; }
  .grid-2, .grid-3, .grid-main { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; } .kpi .value { font-size: 19px; } .kpi .label { font-size: 12px; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], input[type=email], input[type=tel], select, textarea { font-size: 16px; }
  .search input, .toolbar .search { min-width: 0 !important; max-width: none; width: 100%; }
  .overlay { padding: 0; place-items: end stretch; }
  .modal, .modal.wide, .modal.xwide, .modal.narrow, .modal.qs-modal { width: 100%; max-height: 94dvh; border-radius: 16px 16px 0 0; margin: 0; align-self: end; }
  .modal-body { padding: 14px; } .modal-head, .modal-foot { padding: 12px 14px; }
  .modal-foot { flex-wrap: wrap; border-radius: 0; } .modal-foot .btn { flex: 1 1 auto; }
  .card-head { padding: 12px 14px; flex-wrap: wrap; } .card-body { padding: 12px 14px; }
  .toasts { left: 10px; right: 10px; bottom: 10px; } .toast { min-width: 0; max-width: none; }
  .tabs button { padding: 9px 10px; }
  .hbar { grid-template-columns: 90px 1fr auto; }
  table.t { font-size: 13px; } table.t td, table.t th { padding: 8px 9px; }
  .notif-panel { right: 6px; left: 6px; width: auto; }
  .btn { min-height: 38px; }
}
@media (max-width: 420px) { .grid-4 { grid-template-columns: 1fr; } }
@media print { .qr-box { break-inside: avoid; } }
/* grid children must be allowed to shrink (wide tables scroll inside .table-wrap instead of widening the page) */
.stack > *, .stack-sm > *, .grid > * { min-width: 0; }
@media (max-width: 900px) { .page-head > div:first-child { min-width: 0; flex: 1 1 100%; } .page-head .row { flex-wrap: wrap; } .row > input[type=date], .row > select { max-width: 100%; } }

/* ---------- v6.0: shortcuts, palette, Q&A, automation, premium wizard ---------- */
.qs-row { width: 100%; }
.qs-star { border: 0; background: none; font-size: 17px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.qs-star.on { color: #e0a100; }
.qs-star:hover { background: var(--surface-3); }
.qs-hint { line-height: 1.7; }
.qs-hint b { font-family: Consolas, monospace; color: var(--brand); }
.hk-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.hk-group h4 { margin: 0 0 6px; font-size: 13.5px; color: var(--ink-2); }
.hk-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.hk-row:last-child { border-bottom: 0; }
.hk-list { display: grid; gap: 0 28px; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.hk-key { min-width: 120px; justify-content: center; }
.hk-key.hk-capture { background: var(--brand-50); border-color: var(--brand); color: var(--brand); }
.kbd + .kbd { margin-left: 2px; }
input.calc-flash { background: #e6f7ef !important; transition: background .6s; }
.qa-text { font-size: 15.5px; font-weight: 600; line-height: 1.6; }
.qa-ex { border: 0; cursor: pointer; }
.table.compact td, .table.compact th { padding: 6px 10px; font-size: 13px; }
.wiz-step { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.wiz-n { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); font-weight: 700; font-size: 13px; }
.wiz-n svg { width: 14px; height: 14px; }
.wiz-step.done .wiz-n { background: var(--good); color: #fff; }
.pre-wrap { white-space: pre-wrap; word-break: break-all; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12.5px; }
@media (max-width: 700px) { .hk-list { grid-template-columns: 1fr; } .hk-key { min-width: 90px; } }

/* ---------- v7.0 Laboratory (LIS) ---------- */
.lab-strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; }
.lab-strip .chip { text-decoration: none; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #b8c2cf; flex: none; }
.dot.on { background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.dot.off { background: #dc2626; }
.dot.plan { background: #b8c2cf; }
.lab-prog { min-width: 140px; }
.lab-prog .bar { display: flex; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.lab-prog .bar span { display: block; height: 100%; }
.lab-prog .ap { background: var(--good); } .lab-prog .vf { background: var(--info); } .lab-prog .pd { background: #e8a33a; }
.lab-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.lab-head h2 { font-size: 20px; }
.lab-meta { display: flex; gap: 22px; flex-wrap: wrap; }
.lab-table td { vertical-align: middle; }
.lab-table .lab-val { font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lab-table .lab-val b.abn { color: var(--bad); }
.lab-table .lab-in { width: 120px; padding: 5px 8px; }
.lab-table select.lab-in { width: 150px; }
.lab-flag { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; margin-left: 2px; }
.flag-h { background: var(--bad-bg); color: var(--bad); }
.flag-l { background: var(--info-bg); color: var(--info); }
.flag-crit { background: var(--bad); color: #fff; }
tr.lab-crit-row td { background: #fff5f5; }
tr.lab-new-code td { background: #fff8eb; }
.raw-msg { background: #0f1f33; color: #d6e4f5; padding: 12px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; word-break: break-all; max-height: 420px; overflow: auto; }
.lab-mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.lab-mcard { padding: 14px 16px; cursor: pointer; transition: box-shadow .15s, transform .15s; border-left: 4px solid var(--line-strong); }
.lab-mcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.lab-mcard.live { border-left-color: var(--good); } .lab-mcard.testing { border-left-color: #e8a33a; } .lab-mcard.retired { opacity: .6; }
.lab-mcard h3 { font-size: 15px; }
.lab-info-item { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 10px; align-items: center; }
.lab-range-row { gap: 6px; flex-wrap: nowrap; }
.lab-link-list { max-height: 50vh; overflow: auto; display: grid; gap: 4px; }
@media (max-width: 760px) { .lab-info-item { grid-template-columns: 1fr; } .lab-range-row { flex-wrap: wrap; } .lab-in { width: 90px; } }
/* sample labels 50 × 25 mm */
.labels .lab-label { width: 50mm; height: 25mm; padding: 1.2mm 2mm; box-sizing: border-box; overflow: hidden; page-break-after: always; font-family: Arial, var(--font); color: #000; display: flex; flex-direction: column; justify-content: space-between; }
.lab-label .ll-top, .lab-label .ll-bot { display: flex; justify-content: space-between; gap: 4px; font-size: 7.5pt; line-height: 1.1; white-space: nowrap; overflow: hidden; }
.lab-label .ll-bot b { font-size: 8.5pt; letter-spacing: .5px; }
.lab-label .bc svg { width: 100%; height: 9mm; display: block; }
.lab-label .ll-tests { font-size: 6.5pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* printed lab report */
.doc.lab-report .lr-sec { margin-top: 10px; page-break-inside: avoid; }
.doc.lab-report .lr-sec-title { font-weight: 800; font-size: 13px; border-bottom: 1.5px solid #111; margin-bottom: 2px; padding-bottom: 2px; text-transform: uppercase; letter-spacing: .03em; }
.doc.lab-report th, .doc.lab-report td { border: 0; border-bottom: 1px dotted #bbb; padding: 3px 6px; }
.doc.lab-report td.abn { font-weight: 800; }
.doc.lab-report sup { font-size: 8px; }
