:root {
  --primary: #1a9e4b;
  --primary-dark: #0e7a38;
  --bg: #f4f6f7;
  --card: #ffffff;
  --border: #dfe4e6;
  --text: #000000;
  --muted: #111111;
  --danger: #b3261e;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary-dark); color: #fff; padding: 12px 24px; flex-wrap: wrap; gap: 12px;
}
.brand-name { font-weight: 700; font-size: 18px; margin-right: 8px; }
.brand-address { opacity: 0.85; font-size: 12px; margin-right: 8px; }
.brand-sub { opacity: 0.8; font-size: 13px; }
.field-error { color: var(--danger); font-size: 12px; margin: -6px 0 10px; }
.tabs { display: flex; gap: 6px; }
.tab-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.3); color: #fff;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.tab-btn.active { background: #fff; color: var(--primary-dark); font-weight: 600; }
.today-summary { font-size: 13px; opacity: 0.9; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-badge {
  font-size: 12px; background: rgba(255,255,255,0.15); padding: 5px 10px; border-radius: 12px;
  text-transform: capitalize;
}
.btn.small { padding: 6px 10px; font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.date-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.date-label input { margin-top: 2px; }

.bill-type-toggle { display: flex; gap: 24px; align-items: center; padding: 12px 20px; }
.bill-type-toggle label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.bill-type-toggle input { width: auto; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.tag.opd { background: #e6f7ec; color: var(--primary-dark); }
.tag.ipd { background: #fdece0; color: #b5561a; }

main { max-width: 1100px; margin: 20px auto; padding: 0 16px 60px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 20px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; color: var(--primary-dark); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media screen and (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.row input, .row select { flex: 1; min-width: 160px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.form-grid .span-2 { grid-column: span 2; }

input, select {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
  background: #fff; color: var(--text);
}

.btn {
  padding: 9px 16px; border-radius: 6px; border: 1px solid var(--primary); background: var(--primary);
  color: #fff; cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--primary-dark); }
.btn.large { font-size: 16px; padding: 12px 24px; }
.btn.primary { background: var(--primary); }
.link-btn { background: none; border: none; color: var(--primary-dark); text-decoration: underline; cursor: pointer; font-size: 13px; }

.results-list { max-height: 180px; overflow-y: auto; margin-bottom: 10px; }
.result-item {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 4px;
  cursor: pointer; font-size: 13px; display: flex; justify-content: space-between;
}
.result-item:hover { background: #eef9f1; }

.or-divider { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0; }

.selected-box { background: #eef9f1; border: 1px solid var(--primary); border-radius: 6px; padding: 8px 10px; margin-top: 8px; font-size: 13px; }
.hidden { display: none !important; }

/* Login */
.login-screen {
  position: fixed; inset: 0; background: linear-gradient(160deg, var(--primary-dark), var(--primary));
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.login-card {
  background: #fff; border-radius: 12px; padding: 32px 30px; width: 320px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.login-card h2 { margin: 0 0 4px; color: var(--primary-dark); }
.login-sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.login-card h3 { margin: 10px 0 14px; font-size: 15px; color: var(--text); }
.login-card input { width: 100%; margin-bottom: 10px; }
.login-card hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cart-table, .data-table { margin-top: 10px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.totals-card { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.totals { display: flex; gap: 24px; flex-wrap: wrap; }
.totals > div { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.totals strong { font-size: 18px; color: var(--text); }
.totals .net strong { color: var(--primary-dark); font-size: 22px; }

.small-btn { padding: 4px 8px; font-size: 12px; border-radius: 4px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.small-btn.danger { color: var(--danger); border-color: var(--danger); }

/* Receipt */
.receipt-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex;
  align-items: flex-start; justify-content: center; overflow-y: auto; z-index: 100; padding: 30px 10px;
}
.receipt-box { background: #fff; width: 380px; padding: 20px; border-radius: 8px; }
.receipt-actions { display: flex; gap: 8px; margin-bottom: 14px; justify-content: flex-end; }
.receipt { font-size: 12px; line-height: 1.25; }
.receipt h3 { margin: 0 0 2px; text-align: center; }
.receipt .address { text-align: center; font-size: 10px; color: #555; margin-bottom: 2px; }
.receipt .center { text-align: center; }
.receipt div { margin: 1px 0; }
.receipt hr { border: none; border-top: 1px dashed #999; margin: 4px 0; }
.receipt table { font-size: 11px; border-collapse: collapse; }
.receipt table td { padding: 1px 0; border: none; }
.receipt .totals-line { display: flex; justify-content: space-between; padding: 0; }
.receipt .grand { font-weight: 700; font-size: 13px; border-top: 1px solid #333; padding-top: 3px; margin-top: 3px; }

.print-only { display: none; }

@media print {
  /* Fix for "one printed page followed by a dozen blank pages": `visibility: hidden` (used
     below to blank out everything except the thing being printed) hides content visually but
     does NOT remove it from layout — an invisible element still takes up its full height. The
     app's current tab underneath the receipt (History's bill list, Admitted Patients, a long
     Pharmacy screen, etc.) can easily be several screens tall, and that invisible height was
     being paginated into a wall of blank printed pages after the one real page. Forcing
     `display: none` on every other direct child of <body> removes that height entirely, so
     only the actual receipt/report/ledger content is ever laid out during print.
     body > * covers <header> and every modal overlay (switch login, refund, edit admission,
     etc.) — all siblings of <main> — in one rule, without having to name each one. */
  /* #appShell (header + main + every tab) and the various modal overlays (switch login,
     refund, ledger, edit admission, etc.) are ALL direct children of <body>, alongside the
     login screen — <main> itself is nested one level deeper, inside #appShell. */
  body:not(.print-report-mode):not(.print-ledger-mode) > *:not(#receiptOverlay) { display: none !important; }
  body.print-report-mode > *:not(#appShell) { display: none !important; }
  body.print-report-mode #appShell > *:not(main) { display: none !important; }
  body.print-report-mode main > *:not(#report) { display: none !important; }
  body.print-ledger-mode > *:not(#appShell) { display: none !important; }
  body.print-ledger-mode #appShell > *:not(main) { display: none !important; }
  body.print-ledger-mode main > *:not(#ledgerModal) { display: none !important; }

  /* Most printers — especially POS/thermal receipt printers — refuse to mark a small strip
     right at the physical paper edge no matter what @page margin CSS asks for. If that
     hardware-enforced strip is bigger than the margin we reserve, the very first lines
     (hospital name, patient name, age/gender) are the first thing to get sliced off, since
     they sit closest to the top edge. 10mm plus the extra top padding below gives real
     breathing room on both narrow receipt rolls and normal A4 printers. */
  body:not(.print-report-mode) * { visibility: hidden; }
  body:not(.print-report-mode):not(.print-ledger-mode) .receipt-box,
  body:not(.print-report-mode):not(.print-ledger-mode) .receipt-box * { visibility: visible; }
  body:not(.print-report-mode) .receipt-box { position: absolute; top: 0; left: 0; width: 100%; max-width: 100%; padding: 8px 18px 12px; box-shadow: none; }
  .no-print { display: none !important; }
  .receipt-overlay { position: static; background: none; padding: 0; }
  /* Bumped +1pt (11px -> 12px, table 11px -> 12px, grand-total 13px -> 14px) and set bold,
     per request — printed output only; the on-screen sizes above (.receipt etc.) are
     untouched so nothing changes in the app itself, only what comes out of the printer. */
  .receipt { font-size: 12px; line-height: 1.2; font-weight: 700; }
  .receipt hr { margin: 3px 0; }
  .receipt .address { font-size: 11px; }
  .receipt table { font-size: 12px; font-weight: 700; }
  .receipt .grand { font-size: 14px; font-weight: 700; }

  body.print-report-mode * { visibility: hidden; }
  body.print-report-mode #reportPrintArea, body.print-report-mode #reportPrintArea * { visibility: visible; }
  body.print-report-mode #reportPrintArea { position: absolute; top: 0; left: 0; width: 100%; max-width: 100%; padding: 8px 6px 12px; box-shadow: none; }
  body.print-report-mode .print-only { display: block !important; }
  body.print-report-mode .data-table { table-layout: fixed; width: 100%; font-size: 12px; font-weight: 700; }
  body.print-report-mode .data-table td, body.print-report-mode .data-table th { word-break: break-word; overflow-wrap: break-word; }

  body.print-ledger-mode * { visibility: hidden; }
  body.print-ledger-mode #ledgerPrintArea, body.print-ledger-mode #ledgerPrintArea * { visibility: visible; }
  body.print-ledger-mode #ledgerPrintArea { position: absolute; top: 0; left: 0; width: 100%; max-width: 100%; padding: 8px 6px 12px; }
  body.print-ledger-mode .print-only { display: block !important; }
  body.print-ledger-mode .data-table { table-layout: fixed; width: 100%; font-size: 12px; font-weight: 700; }
  body.print-ledger-mode .data-table td, body.print-ledger-mode .data-table th { word-break: break-word; overflow-wrap: break-word; }

  /* Left/right margin widened (10mm -> 18mm) per request — receipts printed on A5 sheets
     were sitting too close to the side edges. Top/bottom left at 10mm. */
  @page { margin: 10mm 18mm; }
}

/* IPD bill: grouped sections */
#ledgerBody td { padding-top: 3px; padding-bottom: 3px; }
#ledgerBody tr.ledger-section td { background: #e3ebf3; font-weight: 700; letter-spacing: .3px; padding-top: 2px; padding-bottom: 2px; border-top: 1px solid #9fb0c1; }
#ledgerBody tr.ledger-subtotal td { font-weight: 700; text-align: right; background: #f6f9fc; padding-top: 2px; padding-bottom: 2px; }
#ledgerBody tr.ledger-subtotal td:first-child { text-align: right; }
@media print { #ledgerBody tr.ledger-section td, #ledgerBody tr.ledger-subtotal td { -webkit-print-color-adjust: exact; print-color-adjust: exact; } #ledgerBody tr { page-break-inside: avoid; } }

/* ---- v16 ---- */
.powered-by { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }
.powered-by a, .app-footer a { color: var(--primary, #0f6e5e); font-weight: 600; text-decoration: none; }
.app-footer { text-align: center; padding: 14px 8px 20px; font-size: 12px; color: var(--muted); }
.exp-cash-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.exp-cash-box { flex: 1; min-width: 240px; background: #fff; border: 1px solid var(--border); border-left: 5px solid var(--primary, #0f6e5e); border-radius: 8px; padding: 12px 16px; }
.exp-cash-box .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.exp-cash-box .amt { font-size: 26px; font-weight: 700; margin: 2px 0; }
.exp-cash-box .sub { font-size: 12px; color: var(--muted); }
.exp-cih-line { margin-top: 10px; font-size: 16px; font-weight: 700; }
tr.exp-day td { background: #eef3f2; font-weight: 700; }
tr.exp-voided td { color: #555; text-decoration: line-through; }

/* IPD bill print: compact rows, readable description column, no blank column for on-screen-only buttons.
   Fonts: whole bill 1pt smaller than before (table 9pt -> 8pt); medicine lines 3pt smaller (6pt). */
body.print-ledger-mode #ledgerPrintArea { font-size: 8.5pt; }
body.print-ledger-mode .data-table { font-size: 7pt; }
body.print-ledger-mode #ledgerPrintArea #ledgerBody tr.ledger-med td { font-size: 6pt; }
body.print-ledger-mode #ledgerPrintArea .no-print { display: none !important; }
body.print-ledger-mode #ledgerPrintArea .data-table th:nth-child(1) { width: 20%; }
body.print-ledger-mode #ledgerPrintArea .data-table th:nth-child(2) { width: 42%; }
body.print-ledger-mode #ledgerPrintArea .data-table th:nth-child(3) { width: 11%; }
body.print-ledger-mode #ledgerPrintArea .data-table th:nth-child(4) { width: 10%; }
body.print-ledger-mode #ledgerPrintArea .data-table th:nth-child(5) { width: 17%; }
body.print-ledger-mode #ledgerPrintArea #ledgerBody td { padding: 2px 4px; }
body.print-ledger-mode #ledgerPrintArea #ledgerBody tr.ledger-section td, body.print-ledger-mode #ledgerPrintArea #ledgerBody tr.ledger-subtotal td { padding: 1px 4px; }
#ledgerBody tr.ledger-med td { font-size: 0.85em; }

.ledger-summary { margin-top: 10px; }
.summary-table { border-collapse: collapse; font-size: 13px; }
.summary-table td { padding: 2px 14px 2px 0; }
.summary-table td:last-child { font-weight: 700; }
.in-words { margin-top: 6px; font-size: 13px; }
body.print-ledger-mode .ledger-summary { font-size: 7pt; }
body.print-ledger-mode .summary-table, body.print-ledger-mode .in-words { font-size: 7pt; }

.cash-strip { margin-right: 18px; }
.today-summary .chip { border: 1px solid #b9c7d6; background: #f3f7fb; border-radius: 12px; padding: 1px 8px; cursor: pointer; font-size: inherit; }

/* Collection report print: compact, one or two lines per bill */
body.print-report-mode #reportPrintArea { font-size: 8pt; }
body.print-report-mode .data-table { font-size: 7.5pt; }
body.print-report-mode .data-table td, body.print-report-mode .data-table th { padding: 2px 4px; }
body.print-report-mode #reportPrintArea h3 { font-size: 9.5pt; margin: 8px 0 3px; }
body.print-report-mode #reportPrintArea .totals { gap: 10px; font-size: 8pt; }
body.print-report-mode #reportPrintArea .totals strong { font-size: 10pt; }
body.print-report-mode #repBillsBody tr, body.print-report-mode #repRefundsBody tr { page-break-inside: avoid; }
body.print-report-mode #repBillsBody td:nth-child(1) { width: 13%; }
body.print-report-mode #repBillsBody td:nth-child(2) { width: 11%; }
body.print-report-mode #repBillsBody td:nth-child(3) { width: 22%; }
body.print-report-mode #repBillsBody td:nth-child(4) { width: 34%; }
.staff-mode-table { width: auto; min-width: 60%; }
#repCashBox { margin-top: 12px; }

/* ===== v17 UI: dark black text, WhatsApp-green single-line header, navy selected-patient text ===== */
body, input, select, textarea { color: #000; }
.topbar { background: #25D366; color: #000; flex-wrap: nowrap; padding: 6px 10px; gap: 8px; overflow-x: auto; }
.topbar .brand { white-space: nowrap; flex: 0 0 auto; }
.topbar .brand-name { font-size: 17px; margin-right: 6px; color: #000; }
.topbar .brand-sub { opacity: 1; color: #000; font-size: 14px; font-weight: 600; }
.topbar .tabs { flex-wrap: nowrap; gap: 4px; flex: 0 1 auto; }
.topbar .tab-btn { color: #000; border: 1px solid rgba(0,0,0,0.45); padding: 5px 8px; font-size: 12.5px; white-space: nowrap; }
.topbar .tab-btn.active { background: #fff; color: #000; font-weight: 700; }
.topbar .topbar-right { flex-wrap: nowrap; gap: 6px; white-space: nowrap; flex: 0 0 auto; margin-left: auto; }
.topbar .btn, .topbar a.btn { background: rgba(255,255,255,0.65); color: #000; border: 1px solid rgba(0,0,0,0.45); text-decoration: none; padding: 5px 9px; font-size: 12.5px; }
.topbar .user-badge { background: rgba(255,255,255,0.65); color: #000; font-size: 12px; }
.summary-row { background: #d9f7e5; color: #000; padding: 4px 12px; font-size: 13px; opacity: 1; border-bottom: 1px solid #b6e8c8; }
.summary-row:empty { display: none; }
.today-summary { opacity: 1; }
#selectedPatientText, #selectedAdmitPatientText, #pharmSelectedWalkinPatientText, #pharmSelectedIpdText, #phPatientLine, #ledgerPatientName { color: #0a2a6b; font-weight: 700; }

/* ===== v17: IPD bill print, further compact (non-medicine text 1pt smaller, tighter spacing) ===== */
body.print-ledger-mode #ledgerPrintArea { font-size: 7.5pt; padding: 4px 6px 6px; }
body.print-ledger-mode .data-table { font-size: 6pt; }
body.print-ledger-mode #ledgerPrintArea #ledgerBody tr.ledger-med td { font-size: 6pt; }
body.print-ledger-mode #ledgerPrintArea #ledgerBody td { padding: 1px 3px; line-height: 1.15; }
body.print-ledger-mode #ledgerPrintArea #ledgerBody tr.ledger-section td, body.print-ledger-mode #ledgerPrintArea #ledgerBody tr.ledger-subtotal td { padding: 0 3px; }
body.print-ledger-mode #ledgerPrintArea .data-table th { padding: 1px 3px; }
body.print-ledger-mode #ledgerPrintArea h2 { font-size: 11pt; margin: 2px 0; }
body.print-ledger-mode #ledgerPrintArea h3 { font-size: 8pt; margin: 3px 0 2px; }
body.print-ledger-mode #ledgerPrintArea .print-only.hosp-address-line { margin: 0 0 2px; font-size: 7pt; }
body.print-ledger-mode #ledgerPrintArea .form-grid { gap: 0 8px; margin-bottom: 3px; line-height: 1.2; }
body.print-ledger-mode #ledgerPrintArea .totals-card { margin-top: 3px !important; gap: 6px; }
body.print-ledger-mode #ledgerPrintArea .totals { gap: 14px; }
body.print-ledger-mode #ledgerPrintArea .totals > div { font-size: 6.5pt; }
body.print-ledger-mode #ledgerPrintArea .totals strong { font-size: 9pt; }
body.print-ledger-mode #ledgerPrintArea .totals .net strong { font-size: 10pt; }
body.print-ledger-mode .ledger-summary { margin-top: 3px; font-size: 6pt; }
body.print-ledger-mode .summary-table, body.print-ledger-mode .in-words { font-size: 6pt; margin-top: 2px; }
body.print-ledger-mode .summary-table td { padding: 0 10px 0 0; }

/* Settings page: grouped, professional layout */
.settings-head{display:flex;align-items:baseline;gap:12px;margin:4px 2px 10px}
.settings-head h2{margin:0;font-size:22px}
.settings-nav{display:flex;gap:6px;flex-wrap:wrap;border-bottom:2px solid #d9e2dc;margin-bottom:14px}
.settings-nav button{background:none;border:none;border-bottom:3px solid transparent;margin-bottom:-2px;padding:9px 16px;font-size:14px;font-weight:600;color:#111;cursor:pointer;border-radius:6px 6px 0 0}
.settings-nav button:hover{background:#eef7f1}
.settings-nav button.active{border-bottom-color:#25D366;background:#e8f8ee}
#admin > .card{border:1px solid #dfe7e2;border-radius:10px;box-shadow:0 1px 3px rgba(0,0,0,.06);max-width:1100px}
#admin > .card > h2{font-size:16px;border-bottom:1px solid #e5ece8;padding-bottom:8px;margin-bottom:12px}
#admin > .card.sg-hidden{display:none}

.access-row td{background:#f4faf6;padding:10px 14px}
.access-box{display:flex;flex-wrap:wrap;gap:6px 28px;align-items:flex-start}
.access-box>b{width:100%}
.access-group{min-width:260px}
.access-title{font-weight:700;margin-bottom:4px;border-bottom:1px solid #cfe3d6}
.access-item{display:block;padding:3px 0;cursor:pointer}
.access-item input{margin-right:6px}

/* Settings v2: sidebar layout + display/print zoom */
body{zoom:var(--ui-zoom,1)}
@media print{body{zoom:var(--print-zoom,1)}}
.settings-layout{display:grid;grid-template-columns:270px 1fr;gap:18px;align-items:start}
.settings-side{display:flex;flex-direction:column;gap:2px;background:#fff;border:1px solid #dfe7e2;border-radius:10px;padding:8px;position:sticky;top:8px}
.settings-side button{display:flex;gap:10px;align-items:center;text-align:left;background:none;border:none;border-left:4px solid transparent;border-radius:6px;padding:9px 10px;cursor:pointer;color:#000}
.settings-side button:hover{background:#eef9f1}
.settings-side button.active{background:#e6f7ec;border-left-color:#1a9e4b}
.settings-side .si{font-size:18px;width:26px;text-align:center}
.settings-side b{display:block;font-size:14px}
.settings-side small{display:block;font-size:11.5px;color:#111;opacity:.75}
.settings-content{min-width:0}
.set-label{display:block;font-weight:600;margin:12px 0 4px}
@media(max-width:800px){.settings-layout{grid-template-columns:1fr}.settings-side{position:static;flex-direction:row;flex-wrap:wrap}.settings-side small{display:none}}

/* ===== Dual-tone look (v17) ===== */
body{background:linear-gradient(160deg,#dff5e8 0%,#e8f0fb 55%,#f3ecfa 100%) fixed}
main{padding-top:6px}
.card{background:#fff;border:1px solid #cfe3d6;border-top:4px solid #25D366;border-radius:12px;box-shadow:0 2px 8px rgba(20,80,50,.08);overflow:hidden;padding:0 20px 18px}
.card > h2:first-child,.card > h3:first-child{margin:0 -20px 14px;padding:11px 20px;background:linear-gradient(90deg,#d9f3e3 0%,#e3ecfa 100%);border-bottom:1px solid #cfe3d6;font-size:16px;color:#0b3d22}
.card > .row:first-child h2,.card > .row:first-child h3{color:#0b3d22}
.card > p.hint:first-of-type{margin-top:0}
.totals-card{background:#f3faf6}
.data-table thead th{background:linear-gradient(90deg,#e3f5ea,#e8eefb);color:#000}
.data-table tbody tr:nth-child(even){background:#f6fbf8}
.tab-panel .card:nth-of-type(even){border-top-color:#4a90d9}
.tab-panel .card:nth-of-type(even) > h2:first-child{background:linear-gradient(90deg,#e1ebfa 0%,#dcf3e6 100%)}
/* Settings sections */
.settings-head{background:linear-gradient(90deg,#128C4A,#25D366);color:#fff;padding:12px 18px;border-radius:12px;margin-bottom:14px}
.settings-head h2,.settings-head .hint{color:#fff !important}
.set-section{scroll-margin-top:12px;border-top-width:6px}
.set-section.tone-a{background:#fff;border-top-color:#25D366}
.set-section.tone-b{background:#fbfdff;border-top-color:#4a90d9}
.set-section.tone-b > h2:first-child{background:linear-gradient(90deg,#dce9fa,#e0f5e8)}
.set-section > h2:first-child{font-size:18px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.set-section > h2 small{font-weight:400;font-size:12.5px;color:#111;opacity:.7;margin-left:6px}
.sec-ico{font-size:20px}
.set-section.flash{box-shadow:0 0 0 4px rgba(37,211,102,.45)}
.settings-side{background:linear-gradient(180deg,#e9f9ef,#e6eefb);border:1px solid #cfe3d6}
.settings-side button.active{background:#fff;border-left-color:#25D366;box-shadow:0 1px 4px rgba(0,0,0,.1)}

/* ===== v17: clearer boxes + header polish ===== */
body{background:linear-gradient(160deg,#c3e6d0 0%,#cddff3 55%,#ddd0ef 100%) fixed}
.card{background:#f2f9f5;border:1px solid #8fc4a5;border-top:4px solid #25D366;box-shadow:0 2px 10px rgba(20,80,50,.18)}
.tab-panel .card:nth-of-type(even){background:#f1f6fc;border-color:#9bb9de}
.card input,.card select,.card textarea{background:#fff;border:1px solid #8aa89a}
.data-table{background:#fff}
.selected-box,.results-list{background:#fff}
.totals-card{background:#e6f3ec}
.set-section.tone-a,.set-section.tone-b{background:#f2f9f5}
.set-section.tone-b{background:#f1f6fc}
.topbar .brand-name{font-size:18px;font-weight:700;margin-right:0;color:#000;letter-spacing:.2px}
.logout-icon{font-size:18px;line-height:1;padding:4px 9px !important;font-weight:700}

/* ===== 80 mm / 58 mm thermal receipt printing ===== */
@media print {
  body.rcpt-narrow:not(.print-report-mode):not(.print-ledger-mode) .receipt-box { padding: 1mm 1mm 6mm; }
  body.rcpt-narrow .receipt { font-size: 11px; line-height: 1.25; }
  body.rcpt-narrow .receipt h3 { font-size: 14px; margin: 0 0 2px; text-align: center; }
  body.rcpt-narrow .receipt .address { font-size: 10px; text-align: center; }
  body.rcpt-narrow .receipt table { font-size: 11px; }
  body.rcpt-narrow .receipt .grand { font-size: 13px; }
  body.rcpt-58 .receipt { font-size: 10px; }
  body.rcpt-58 .receipt table { font-size: 10px; }
}

/* ---- v18: doctor accounts, downloads ---- */
.dl-bar { margin: 6px 0; display: flex; gap: 6px; align-items: center; }
.dl-bar.hidden { display: none; }
#doctoraccounts .tag.opd { background:#e6f7ec; color: var(--primary-dark); }
#doctoraccounts .tag { background:#fdece0; color:#b5561a; }
#doctoraccounts .tag.opd { background:#e6f7ec; }
@media print {
  body.print-dr-mode main > *:not(#doctoraccounts) { display: none !important; }
  body.print-ledger-mode.print-dr-mode main > #doctoraccounts { display: block !important; }
  body.print-dr-mode #doctoraccounts > .card:not(#drLedgerCard) { display: none !important; }
  body.print-dr-mode #drLedgerCard, body.print-dr-mode #drLedgerCard * { visibility: visible; }
  body.print-dr-mode #drLedgerCard { position: absolute; top: 0; left: 0; width: 100%; box-shadow: none; }
  .dl-bar { display: none !important; }
}

/* ---- v18: phone / small screens — nothing may be cut off on the right ---- */
@media screen { html, body { max-width: 100%; overflow-x: hidden; } }
@media screen and (max-width: 900px) {
  main, .tab-panel { max-width: 100%; }
  main { padding: 8px !important; }
  .card { padding: 10px; max-width: 100%; box-sizing: border-box; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .data-table td, .data-table th { padding: 6px 8px; }
  .form-grid { grid-template-columns: 1fr !important; }
  .form-grid .span-2 { grid-column: span 1 !important; }
  .grid-2, .cols { grid-template-columns: 1fr !important; }
  .row { flex-wrap: wrap; }
  .row > input, .row > select, .row > button { max-width: 100%; }
  input, select, textarea { max-width: 100%; box-sizing: border-box; font-size: 16px; }
  .totals { gap: 10px; }
  .topbar { padding: 6px 8px; }
  .topbar .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .modal, .modal-box, .modal-content, [id$="Modal"] > div { max-width: 96vw !important; box-sizing: border-box; overflow-x: auto; }
  .receipt-box { max-width: 100%; overflow-x: auto; }
  .settings-layout { grid-template-columns: 1fr; }
}

/* ---- v18: receipt margins come from Settings > Print (applied as padding; @page margin is 0) ---- */
@media print {
  body:not(.print-report-mode):not(.print-ledger-mode) .receipt-box { padding: var(--pm-top, 4mm) var(--pm-side, 4mm) var(--pm-bottom, 6mm) !important; box-sizing: border-box; }
}

/* ---- v18: every box differs slightly from the area around it ---- */
:root { --page-bg: #e9eef2; }
body { background: var(--page-bg) !important; }
.card { background: #ffffff !important; border: 1px solid #b9c6d2 !important; box-shadow: 0 1px 3px rgba(20,40,60,.12); }
.tab-panel .card:nth-of-type(even) { background: #f3f7fb !important; border-color: #a9bfd6 !important; }
.card .card { background: #f6f9fc !important; border: 1px solid #c5d1dc !important; }
.card .card .card { background: #ffffff !important; }
input, select, textarea { background: #fbfdff; border: 1px solid #a6b4c2; }
input:focus, select:focus, textarea:focus { background: #fff; border-color: #1b7f4d; outline: 2px solid rgba(27,127,77,.25); }
.data-table thead th { background: #dde8f0; }
:where(.data-table tbody tr:nth-child(even)) td { background: #f4f8fb; }
:where(.data-table tbody tr:hover) td { background: #e8f4ec; }
.result-item { background: #f4f8fb; border: 1px solid #d3dde6; }
.totals-card, .totals { background: transparent; }

/* ---- v18: phone header — brand + buttons on the first row, full menu on its own scrolling row ---- */
@media screen and (max-width: 900px) {
  .topbar { flex-wrap: wrap !important; overflow: visible !important; }
  .topbar .brand { flex: 1 1 auto; }
  .topbar .topbar-right { flex: 0 0 auto; margin-left: 0; }
  .topbar .tabs { order: 3; flex: 1 1 100% !important; min-width: 100%; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .topbar .tab-btn { flex: 0 0 auto; }
  .topbar .user-badge { display: none; }
}

@media screen and (max-width: 900px) { .topbar .brand-name { font-size: 15px; } .topbar .btn { padding: 4px 7px; } .summary-row { font-size: 12px; } }

/* ---- v18: big, easy-to-tap "back to Pharmacy Home" button ---- */
[data-pharm-nav="home"] { display: inline-block; font-size: 16px !important; font-weight: 700; padding: 10px 18px !important; margin: 4px 0 10px; background: #e6f4ea; color: #0b5d34 !important; border: 2px solid #1b7f4d !important; border-radius: 8px; text-decoration: none; cursor: pointer; }
[data-pharm-nav="home"]:hover { background: #d3ecdc; }
@media screen and (max-width: 900px) { [data-pharm-nav="home"] { font-size: 18px !important; padding: 12px 20px !important; } }
