/* ---- theme: PIMA crimson on deep slate ---- */
:root {
  --sidebar-w: 256px; --sidebar-bg: #14202e; --sidebar-fg: #b9c4d0;
  --accent: #d4151c; --accent-dark: #a90f15; --accent-soft: rgba(212,21,28,.14);
  --ink: #1d2733; --line: #e3e8ee;
  --bs-primary: #d4151c; --bs-primary-rgb: 212,21,28; --bs-link-color: #b8121a; --bs-link-hover-color: #8c0d13;
  --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif; --bs-body-color: var(--ink);
}
body { background: #f3f5f8; color: var(--ink); }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent-dark); --bs-btn-hover-border-color: var(--accent-dark); --bs-btn-active-bg: #8c0d13; --bs-btn-active-border-color: #8c0d13; --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); box-shadow: 0 1px 2px rgba(169,15,21,.3); }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-active-bg: var(--accent-dark); --bs-btn-active-border-color: var(--accent-dark); }
.btn, .form-control, .form-select { border-radius: 8px; }
.form-control:focus, .form-select:focus, .btn:focus-visible { border-color: #e86a6f; box-shadow: 0 0 0 .22rem rgba(212,21,28,.18); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 3px rgba(20,32,46,.05); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; border-radius: 12px 12px 0 0 !important; }
.table > :not(caption) > * > * { padding-top: .6rem; padding-bottom: .6rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6978; background: #f7f9fb; border-bottom: 1px solid var(--line); }
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: #fdf3f3; }
.pagination { --bs-pagination-active-bg: var(--accent); --bs-pagination-active-border-color: var(--accent); --bs-pagination-color: var(--accent-dark); }
.badge.bg-primary { background-color: var(--accent) !important; }
h4, h5 { letter-spacing: -.01em; }

.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: linear-gradient(180deg, #1a2a3c 0%, var(--sidebar-bg) 100%); color: var(--sidebar-fg); flex: 0 0 var(--sidebar-w); overflow-y: auto; box-shadow: 2px 0 12px rgba(20,32,46,.15); }
.sidebar::-webkit-scrollbar { width: 6px; } .sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 16px 18px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); border-top: 3px solid var(--accent); }
.brand-logo { width: 44px; height: 44px; flex: 0 0 44px; background: #fff; border-radius: 12px; display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.brand-logo img { width: 32px; height: auto; }
.brand-text { font-weight: 700; font-size: 1.08rem; line-height: 1.15; }
.brand-text small { display: block; font-weight: 500; font-size: .68rem; letter-spacing: .28em; color: #ef8a8e; }
.menu { padding: 8px 10px 24px; }
.menu-section { padding: 16px 12px 5px; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: #6f8195; }
.menu-link { display: block; padding: 8px 12px; margin: 1px 0; border-radius: 8px; color: var(--sidebar-fg); text-decoration: none; font-size: .91rem; transition: background .12s, color .12s; }
.menu-link.sub { padding-left: 30px; }
.menu-link i { width: 1.4em; display: inline-block; opacity: .85; }
.menu-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.menu-link.active { background: var(--accent-soft); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.menu-link.active i { color: #ff8c91; opacity: 1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; padding: 10px 24px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020; }
.user-chip { background: #f1f4f8; border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; font-size: .85rem; color: #3d4b5a; }
.content { padding: 24px; }
.perm-table th, .perm-table td { vertical-align: middle; }
.perm-table .sec td { background: #e9eef4; font-weight: 600; }
.perm-table td.flag { text-align: center; width: 90px; }

/* login */
.login-wrap { max-width: 460px; padding-top: 7vh; padding-bottom: 5vh; }
.login-card { border: 0; border-radius: 18px; box-shadow: 0 18px 50px rgba(20,32,46,.18); border-top: 5px solid var(--accent); }
.login-logo { width: 110px; height: auto; }
body:not(:has(.app)) { background: radial-gradient(1200px 600px at 50% -10%, #fbe3e4 0%, #f3f5f8 60%); min-height: 100vh; }

/* dashboard */
.welcome-logo { width: 54px; height: auto; }
.tile { position: relative; overflow: hidden; transition: transform .12s, box-shadow .12s; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20,32,46,.1); }
.tile-title { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #6b7a8a; }
.tile .fs-4 { font-weight: 700 !important; letter-spacing: -.02em; }
.tile a { color: var(--ink); }
.bar { background: linear-gradient(180deg, #e8474d, var(--accent-dark)); opacity: .85; transition: opacity .12s; }
.bar:hover { opacity: 1; }
.dc-body { min-height: 130px; transition: opacity .15s; }
.vb { display: flex; align-items: flex-end; height: 110px; }
.vb-col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; cursor: default; border-radius: 3px 3px 0 0; }
.vb-col:hover, .vb-col:focus { background: rgba(0,0,0,.05); outline: none; }
.vb-bar { width: 100%; border-radius: 3px 3px 0 0; }
.vb-col:hover .bar, .vb-col:focus .bar, .hb:hover .bar, .hb:focus .bar { opacity: 1; }
.hb { display: flex; align-items: center; gap: .5rem; padding: 2px 0; cursor: default; border-radius: 4px; }
.hb:hover, .hb:focus { background: rgba(0,0,0,.04); outline: none; }
.hb.hb-click { cursor: pointer; }
.hb-name { flex: 0 0 34%; max-width: 34%; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { flex: 1 1 auto; }
.hb-fill { height: 14px; border-radius: 0 3px 3px 0; }
.hb-val { flex: 0 0 auto; min-width: 4.5rem; text-align: right; font-size: .82rem; font-variant-numeric: tabular-nums; }
.chart-tip { position: fixed; z-index: 2000; pointer-events: none; background: #14202e; color: #fff; border-radius: 6px; padding: .4rem .65rem; font-size: .8rem; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.chart-tip[hidden] { display: none; }
.chart-tip .ct-h { color: #aab6c3; font-size: .72rem; }
.chart-tip .ct-v { font-weight: 700; font-size: .95rem; }

/* OPD list: one compact toolbar row + a thin totals strip */
.opd-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.opd-filters { display: flex; flex: 1 1 520px; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.opd-filters input[type=date] { width: 140px; flex: 0 0 140px; }
.opd-filters select { width: 150px; flex: 0 1 150px; }
.opd-filters input[name=q] { flex: 1 1 160px; min-width: 140px; max-width: 260px; }
.opd-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 6px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.opd-stats div { display: flex; align-items: baseline; gap: 8px; }
.opd-stats span { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #6b7a8a; }
.opd-stats b { font-size: 1.1rem; letter-spacing: -.01em; }

@media (max-width: 991px) {
  .sidebar { position: fixed; z-index: 1030; left: 0; top: 0; bottom: 0; transform: translateX(-105%); visibility: hidden; transition: transform .2s, visibility .2s; }
  .sidebar.open { transform: none; visibility: visible; }
}

/* the validation summary tag helper renders an (empty) element even when there is nothing to show */
.validation-summary-valid { display: none; }

/* ---- reports ---- */
.report-head { text-align: center; margin-bottom: 10px; }
.report-hospital { font-size: 1.25rem; font-weight: 700; }
.report-addr { font-size: .8rem; color: #555; }
.report-title { font-size: 1.05rem; font-weight: 600; margin-top: 4px; }
.report-sub { font-size: .85rem; color: #444; }
.report-table { background: #fff; font-size: .88rem; }
.report-table th { background: #37474f; color: #fff; font-weight: 600; white-space: nowrap; }
.report-table td.num, .report-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-table .r-group td { background: #e3eaf1; font-weight: 700; }
.report-table .r-sub td { background: #f2f5f8; font-weight: 600; }
.report-table .r-subtotal td { font-weight: 600; border-top: 1px solid #9aa7b3; }
.report-table .r-section td { background: #cfd8dc; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .8rem; }
.report-table .r-total td { font-weight: 700; border-top: 2px solid #37474f; background: #f7f9fb; }
.report-table .r-grand td { font-weight: 800; border-top: 3px double #37474f; background: #e8eef3; }
.report-table .ind1 { padding-left: 1.2rem !important; } .report-table .ind2 { padding-left: 2.4rem !important; }
.report-table a { text-decoration: none; }
.statement { max-width: 820px; margin-left: auto; margin-right: auto; }
.report-foot { margin-top: 12px; font-size: .75rem; color: #666; }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .alert { display: none !important; }
  .content { padding: 0 !important; }
  .report-table { font-size: 10.5px; }
  .report-table th { background: #fff !important; color: #000 !important; border-bottom: 2px solid #000; }
  .report-table .r-group td, .report-table .r-sub td, .report-table .r-section td, .report-table .r-grand td, .report-table .r-total td { background: #fff !important; }
  @page { size: A4; margin: 12mm; }
}

/* document entry grid: floating product / patient search results (never clipped by the table) */
.res-box { position: fixed; z-index: 2000; max-height: 320px; max-width: 92vw; overflow-y: auto; border-radius: 10px; }
.doc-grid td { vertical-align: middle; }
.doc-grid .pinfo { color: #5b6978; }

/* sale screen: the selected registered patient */
.chosen-patient { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; background: #e8f5ec; border: 1px solid #b9dcc4; border-radius: 10px; }

/* ---- trial balance: compact rows, collapsible heads, sticky header ---- */
:root { --topbar-h: 53px; }
.tb { font-size: .8rem; margin-bottom: .5rem; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: clip; }
.tb th, .tb td { padding: 1px 8px; line-height: 1.3; border-color: #eef1f5; }
.tb.tb-comfy th, .tb.tb-comfy td { padding: 6px 10px; line-height: 1.45; }
.tb thead th { position: sticky; top: var(--topbar-h); z-index: 6; background: #2b3a4b !important; color: #fff !important; border-bottom: 0; text-transform: none; letter-spacing: 0; font-size: .78rem; }
.tb thead tr:nth-child(2) th { top: calc(var(--topbar-h) + 22px); background: #34465a !important; font-weight: 500; }
.tb tbody tr.tb-a:hover > td { background: #fff7e6; }
.tb tbody tr.tb-a td a { color: var(--ink); text-decoration: none; } .tb tbody tr.tb-a td a:hover { color: var(--accent-dark); text-decoration: underline; }
.tb .r-group td { background: #e6ecf3; font-size: .8rem; position: relative; }
.tb .r-sub td { background: #f3f6fa; }
.tb .r-subtotal td { background: #fafbfd; }
.tb .r-grand td { background: #2b3a4b; color: #fff; border-top: 0; font-size: .85rem; }
.tb .tb-sub { font-size: .74rem; }
.tb-toggle { border: 0; background: transparent; padding: 0 6px 0 0; line-height: 1; color: #52606f; cursor: pointer; }
.tb-toggle i { display: inline-block; transition: transform .15s; font-size: .75rem; }
tr.is-collapsed .tb-toggle i { transform: rotate(-90deg); }
.tb td.tb-sum { visibility: hidden; font-weight: 700; }
tr.is-collapsed td.tb-sum { visibility: visible; }
.tb.tb-searching tr.r-group, .tb.tb-searching tr.r-sub, .tb.tb-searching tr.r-subtotal { display: none; }
.tb-find { width: 210px; }
@media print {
  .tb { font-size: 10px; border: 0; }
  .tb th, .tb td { padding: 1px 4px; }
  .tb thead th { position: static; background: #fff !important; color: #000 !important; }
  .tb .r-grand td { background: #fff; color: #000; border-top: 2px solid #000; }
  .tb-toggle { display: none; } .tb td.tb-sum { visibility: hidden !important; }
}

/* trial balance: the Period columns stand out */
.tb td.per { background: #fff6dc; box-shadow: inset 1px 0 0 #f1d98a, inset -1px 0 0 #f1d98a; font-weight: 500; }
.tb tbody tr.tb-a:hover > td.per { background: #ffefbf; }
.tb .r-group td.per { background: #f5e6b8; } .tb .r-sub td.per { background: #fbefcb; } .tb .r-subtotal td.per { background: #fdf3d3; }
.tb .r-grand td.per { background: #7a5a00; color: #fff; box-shadow: none; }
.tb thead th.per { background: #8a6400 !important; color: #fff !important; }
.tb thead tr:nth-child(2) th.per { background: #9b7208 !important; }
@media print { .tb td.per { background: transparent; box-shadow: none; border-left: 1px solid #bbb; border-right: 1px solid #bbb; } .tb .r-grand td.per, .tb thead th.per { background: transparent !important; color: #000 !important; } }

/* ---- left menu: foldable sections and an icon-only rail ---- */
.sidebar { transition: width .18s ease, flex-basis .18s ease; }
button.menu-section { display: flex; align-items: center; gap: 4px; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
button.menu-section .chev { margin-left: auto; font-size: .7rem; transition: transform .15s; }
/* section headers: readable size, hover / open states; items slide open and shut */
.menu-group { margin: 3px 0; }
button.menu-section { padding: 9px 12px; margin: 0; border-radius: 8px; font-size: .9rem; font-weight: 600; text-transform: none; letter-spacing: .01em; color: #dbe4ee; transition: background .15s, color .15s; }
button.menu-section > i:first-child { width: 1.4em; font-size: 1rem; color: #7f93a8; transition: color .15s; }
button.menu-section:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-group:not(.collapsed) > button.menu-section { background: rgba(255,255,255,.07); color: #fff; }
.menu-group:not(.collapsed) > button.menu-section > i:first-child { color: #ff8c91; }
button.menu-section .chev { transition: transform .25s ease; }
.menu-group.collapsed .chev { transform: rotate(-90deg); }
.menu-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .28s ease, opacity .2s ease; }
.menu-inner { overflow: hidden; min-height: 0; margin: 2px 0 2px 18px; padding-left: 4px; border-left: 1px solid rgba(255,255,255,.1); }
.menu-group.collapsed .menu-items { grid-template-rows: 0fr; opacity: 0; }
.menu-group.collapsed .menu-inner { visibility: hidden; transition: visibility 0s .28s; }   /* folded links cannot be tabbed to */
.menu-link.sub { padding: 7px 12px 7px 14px; font-size: .88rem; }
@media (prefers-reduced-motion: reduce) { .menu-items, button.menu-section .chev { transition: none; } }
@media (min-width: 992px) {
  html.sidebar-mini .sidebar { width: 68px; flex-basis: 68px; overflow-x: hidden; }
  html.sidebar-mini .sidebar .lbl, html.sidebar-mini .brand-text, html.sidebar-mini button.menu-section .chev { display: none; }
  html.sidebar-mini .sidebar .brand { justify-content: center; padding: 12px 0; }
  html.sidebar-mini .menu { padding: 8px 6px 24px; }
  html.sidebar-mini .menu-link, html.sidebar-mini .menu-link.sub { padding: 9px 0; text-align: center; }
  html.sidebar-mini .menu-link i { width: auto; margin: 0; font-size: 1.15rem; }
  html.sidebar-mini button.menu-section { justify-content: center; padding: 6px 0 2px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,.1); border-radius: 0; font-size: .85rem; }
  html.sidebar-mini .menu-group.collapsed .menu-items { grid-template-rows: 1fr; opacity: 1; }   /* the rail always shows every icon */
  html.sidebar-mini .menu-inner { margin: 0; padding: 0; border: 0; visibility: visible; }
  html.sidebar-mini .menu-link.sub { padding: 9px 0; }
}
@media (max-width: 991px) { #sbToggle { display: none !important; } }

/* report pages: saved filter sets and quick period chips */
.saved-menu { min-width: 260px; max-height: 360px; overflow-y: auto; }
.saved-list .list-group-item { border: 0; }
.period-chips .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* trial balance: comparison columns */
.tb td.cmpcol { background: #eef5ff; box-shadow: inset 1px 0 0 #cfe0f7; }
.tb .r-group td.cmpcol { background: #dbe8fa; } .tb .r-sub td.cmpcol { background: #e6effb; } .tb .r-subtotal td.cmpcol { background: #eef5ff; }
.tb .r-grand td.cmpcol { background: #234a73; color: #fff; box-shadow: none; }
.tb thead th.cmpcol { background: #2f5d8a !important; color: #fff !important; }
.tb td.num { white-space: nowrap; }
@media print { .tb td.cmpcol { background: transparent; box-shadow: none; border-left: 1px solid #bbb; } .tb thead th.cmpcol, .tb .r-grand td.cmpcol { background: transparent !important; color: #000 !important; } }

/* service-charge voucher: admitted patient list and balance card */
.patient-list { max-height: 250px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.patient-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid #eef1f5; padding: 7px 12px; }
.patient-row:last-child { border-bottom: 0; }
.patient-row:hover { background: #fff7e6; }
.patient-row.sel { background: #fde8e9; box-shadow: inset 3px 0 0 var(--accent); }
.pr-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pr-sub { font-size: .78rem; color: #6b7a8a; }
.pr-due { text-align: right; font-weight: 700; white-space: nowrap; }
.pr-due small { display: block; font-size: .65rem; font-weight: 500; color: #8a97a5; text-transform: uppercase; letter-spacing: .05em; }
.patient-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fbfcfe; min-height: 150px; }
.pc-bal td { padding: 1px 0; font-size: .85rem; }

/* service-charge voucher: the patient list is a dropdown under the search box */
.patient-select { position: relative; }
.patient-select .patient-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 40; max-height: 300px; box-shadow: 0 10px 28px rgba(20,32,46,.18); }

/* ---- headline tiles above a report ---- */
.kpi-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 14px; }
.kpi { flex: 1 1 150px; background: #fff; border: 1px solid #dfe5ec; border-left: 4px solid #37474f; border-radius: 10px; padding: 8px 14px; box-shadow: 0 1px 3px rgba(20,32,46,.06); }
.kpi.good { border-left-color: #1b8a5a; } .kpi.bad { border-left-color: #d4151c; }
.kpi-l { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #6b7a8a; }
.kpi-v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; color: #1d2b3a; }
.kpi.bad .kpi-v { color: #b3121a; }
@media print { .kpi { box-shadow: none; border-color: #999; padding: 3px 8px; } .kpi-v { font-size: .95rem; } }

/* ---- report charts (drawn with plain HTML) and the summary table beside them ---- */
.sum-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin: 0 0 16px; }
.sum-tbl { flex: 1 1 340px; max-width: 520px; margin: 0; }
.chart { flex: 1 1 320px; max-width: 520px; background: #fff; border: 1px solid #dfe5ec; border-radius: 10px; padding: 10px 14px 8px; }
.chart-t { text-align: center; font-weight: 700; font-size: .9rem; margin-bottom: 8px; color: #1d2b3a; }
.hb { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: .82rem; }
.hb-l { flex: 0 0 110px; text-align: right; color: #37474f; } .hb-l a { text-decoration: none; }
.hb-track { flex: 1; display: flex; background: #f2f5f8; border-radius: 4px; overflow: hidden; min-height: 22px; }
.hb-1, .hb-2 { color: #fff; font-size: .75rem; line-height: 22px; text-align: center; min-width: 0; overflow: hidden; }
.hb-1, .lg1, .cb-1 { background: #2f80ed; } .hb-2, .lg2, .cb-2 { background: #eb5757; }
.cb-wrap { display: flex; align-items: flex-end; gap: 3px; height: 150px; overflow-x: auto; padding-bottom: 2px; }
.cb { flex: 1 1 14px; min-width: 14px; max-width: 46px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.cb-bar { width: 100%; flex: 1; display: flex; flex-direction: column-reverse; justify-content: flex-start; }
.cb-bar i { display: block; width: 100%; min-height: 0; } .cb small { font-size: .62rem; color: #6b7a8a; writing-mode: vertical-rl; transform: rotate(180deg); margin-top: 3px; white-space: nowrap; }
.chart-leg { text-align: center; font-size: .75rem; color: #6b7a8a; margin-top: 6px; }
.chart-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; }
@media print { .chart { border-color: #999; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---- generic report table: compact rows by default, comfortable on request, header stays in view ---- */
#rep { border-collapse: separate; border-spacing: 0; }
#rep th, #rep td { padding: 2px 8px; line-height: 1.3; }
#rep.rep-comfy th, #rep.rep-comfy td { padding: 7px 10px; line-height: 1.45; }
#rep thead th { position: sticky; top: var(--topbar-h); z-index: 5; }
#rep tbody tr:not(.r-sub):not(.r-subtotal):not(.r-section):hover > td { background: #fff7e6; }
@media print { #rep thead th { position: static; } #rep th, #rep td { padding: 1px 6px; } }
.report-table td.dt, .report-table th.dt { white-space: nowrap; }
.sum-tbl.rep-comfy th, .sum-tbl.rep-comfy td { padding: 7px 10px; line-height: 1.45; } .sum-tbl th, .sum-tbl td { padding: 2px 8px; line-height: 1.3; }
.grp-head { cursor: pointer; user-select: none; } .grp-chev { display: inline-block; font-size: .7rem; transition: transform .15s; }
tr.grp-closed .grp-chev { transform: rotate(-90deg); } tr.grp-hidden { display: none; }

.vb-two { gap: 1px; }
.vb-two .vb-bar { flex: 1 1 0; width: auto; }
.vb-bar.vb-2 { background: linear-gradient(180deg, #4f8fd6, #2b6cb0); }
.donut-wrap { display: flex; align-items: center; gap: 1rem; }
.donut { width: 130px; height: 130px; flex: 0 0 auto; }
.donut circle { cursor: default; transition: stroke-width .12s; }
.donut circle:hover, .donut circle:focus { stroke-width: 7.5; outline: none; }
.donut-t { font-size: 4.6px; font-weight: 700; fill: var(--ink); }
.donut-legend { flex: 1 1 auto; min-width: 0; }
.dl { display: flex; align-items: center; gap: .4rem; font-size: .82rem; padding: 2px 0; cursor: default; }
.dl:hover { background: rgba(0,0,0,.04); }
.dl-sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.dl-n { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-v { font-variant-numeric: tabular-nums; }

/* ---- night mode (screen only; printing stays black on white) ---- */
@media screen {
[data-bs-theme="dark"] {
  --ink: #e3e9f0; --line: #2c3a4b; --bs-body-bg: #0f1822; --bs-body-color: #e3e9f0; --bs-link-color: #ff7b80; --bs-link-hover-color: #ffa3a6;
  --bs-secondary-color: #9fb0c1; --bs-border-color: #2c3a4b; --bs-tertiary-bg: #16222f; --sidebar-bg: #0b121a;
}
[data-bs-theme="dark"] body { background: #0f1822; }
[data-bs-theme="dark"] body:not(:has(.app)) { background: radial-gradient(1200px 600px at 50% -10%, #3a1418 0%, #0f1822 60%); }
[data-bs-theme="dark"] .sidebar { background: linear-gradient(180deg, #121c28 0%, #0b121a 100%); }
[data-bs-theme="dark"] .card, [data-bs-theme="dark"] .card-header, [data-bs-theme="dark"] .card-footer, [data-bs-theme="dark"] .login-card { background: #16222f; }
[data-bs-theme="dark"] .card-footer { border-top-color: var(--line); }
[data-bs-theme="dark"] .topbar { background: rgba(15,24,34,.92); }
[data-bs-theme="dark"] .user-chip { background: #1b2a3a; color: #c5d1dd; }
[data-bs-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--ink); --bs-table-border-color: var(--line); --bs-table-striped-bg: rgba(255,255,255,.03); }
[data-bs-theme="dark"] .table thead th { background: #1b2a3a; color: #9fb0c1; }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { --bs-table-hover-bg: #22313f; --bs-table-hover-color: var(--ink); }
[data-bs-theme="dark"] .perm-table .sec td { background: #1f2f40; }
[data-bs-theme="dark"] .tile-title, [data-bs-theme="dark"] .opd-stats span, [data-bs-theme="dark"] .kpi-l, [data-bs-theme="dark"] .pr-sub, [data-bs-theme="dark"] .doc-grid .pinfo { color: #94a5b6; }
[data-bs-theme="dark"] .opd-stats, [data-bs-theme="dark"] .kpi, [data-bs-theme="dark"] .chart, [data-bs-theme="dark"] .patient-list, [data-bs-theme="dark"] .tb { background: #16222f; border-color: var(--line); }
[data-bs-theme="dark"] .kpi-v, [data-bs-theme="dark"] .chart-t, [data-bs-theme="dark"] .hb-l { color: #e3e9f0; }
[data-bs-theme="dark"] .kpi.bad .kpi-v { color: #ff7b80; }
[data-bs-theme="dark"] .hb-track { background: #223142; }
[data-bs-theme="dark"] .patient-card { background: #1a2836; }
[data-bs-theme="dark"] .patient-row:hover { background: #22313f; }
[data-bs-theme="dark"] .patient-row.sel { background: #3a1d22; }
[data-bs-theme="dark"] .chosen-patient { background: #14352a; border-color: #1f5a43; }
[data-bs-theme="dark"] .report-table { background: #16222f; color: var(--ink); }
[data-bs-theme="dark"] .report-addr, [data-bs-theme="dark"] .report-sub, [data-bs-theme="dark"] .report-foot { color: #9fb0c1; }
[data-bs-theme="dark"] .report-table .r-group td { background: #223142; }
[data-bs-theme="dark"] .report-table .r-sub td { background: #1b2a3a; }
[data-bs-theme="dark"] .report-table .r-total td { background: #1b2a3a; border-top-color: #5b6c7e; }
[data-bs-theme="dark"] .report-table .r-grand td { background: #223142; border-top-color: #5b6c7e; }
[data-bs-theme="dark"] .tb th, [data-bs-theme="dark"] .tb td { border-color: #223142; }
[data-bs-theme="dark"] .tb tbody tr.tb-a:hover > td { background: #2a3a1f; }
[data-bs-theme="dark"] .tb .r-group td { background: #1f2f40; }
[data-bs-theme="dark"] .tb .r-sub td { background: #1a2836; }
[data-bs-theme="dark"] .tb .r-subtotal td { background: #182431; }
[data-bs-theme="dark"] .tb-toggle { color: #9fb0c1; }
[data-bs-theme="dark"] .tb td.per { background: #3a3012; box-shadow: inset 1px 0 0 #6b5a20, inset -1px 0 0 #6b5a20; }
[data-bs-theme="dark"] .tb .r-group td.per { background: #4a3c14; } [data-bs-theme="dark"] .tb .r-sub td.per { background: #3f3413; } [data-bs-theme="dark"] .tb .r-subtotal td.per { background: #3a3012; }
[data-bs-theme="dark"] .tb tbody tr.tb-a:hover > td.per { background: #54441a; }
[data-bs-theme="dark"] .tb td.cmpcol { background: #14283f; box-shadow: inset 1px 0 0 #28496e; }
[data-bs-theme="dark"] .tb .r-group td.cmpcol { background: #1a3452; } [data-bs-theme="dark"] .tb .r-sub td.cmpcol { background: #172f4a; } [data-bs-theme="dark"] .tb .r-subtotal td.cmpcol { background: #14283f; }
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus { border-color: #e86a6f; }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: #b9c4d0; --bs-btn-border-color: #3a4b5e; --bs-btn-hover-bg: #26364a; --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .dc-body .bar { opacity: .95; }
[data-bs-theme="dark"] .vb-col:hover, [data-bs-theme="dark"] .vb-col:focus, [data-bs-theme="dark"] .hb:hover, [data-bs-theme="dark"] .hb:focus, [data-bs-theme="dark"] .dl:hover { background: rgba(255,255,255,.07); }
[data-bs-theme="dark"] .chart-tip { background: #e3e9f0; color: #14202e; }
[data-bs-theme="dark"] .chart-tip .ct-h { color: #5b6978; }
[data-bs-theme="dark"] .welcome-logo, [data-bs-theme="dark"] .login-logo { background: #fff; border-radius: 10px; padding: 3px; }
}

/* ---- mobile / tablet ---- */
.tabbar, .nav-backdrop { display: none; }
@media (max-width: 991.98px) {
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 1025; background: rgba(8,14,22,.55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .sidebar { width: min(300px, 86vw); flex-basis: auto; }
  .topbar { padding: 8px 12px; gap: 2px; }
  .content { padding: 14px 12px 84px; }                                 /* room for the bottom tab bar */
  h4 { font-size: 1.15rem; }
  .form-control, .form-select { font-size: 16px; }                      /* stops iOS zooming into fields */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; }
  .card-header { flex-wrap: wrap; }
  .dc-range { max-width: 150px; }
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut { align-self: center; }
  .hb-name { flex-basis: 40%; max-width: 40%; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .tb thead th { position: static; }                                    /* sticky headers need the page as scroller */
  .welcome-logo { width: 42px; }
  .res-box { left: 4vw !important; width: 92vw !important; }
  .chart-tip { max-width: 70vw; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(20,32,46,.08); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; border: 0; background: transparent; color: #5b6978; text-decoration: none; font-size: .68rem; font-weight: 600; border-radius: 10px; }
  .tabbar i { font-size: 1.25rem; line-height: 1.2; }
  .tabbar a.on { color: var(--accent); background: var(--accent-soft); }
  [data-bs-theme="dark"] .tabbar { background: #121c28; }
  [data-bs-theme="dark"] .tabbar a, [data-bs-theme="dark"] .tabbar button { color: #9fb0c1; }
  [data-bs-theme="dark"] .tabbar a.on { color: #ff8c91; }
}
@media (max-width: 575.98px) {
  .row.g-3 > [class*="col-6"] .fs-4 { font-size: 1.1rem !important; }   /* four tiles fit two per row without wrapping the figures */
  .tile .card-body { padding: .6rem .75rem !important; }
  .opd-stats { gap: 6px 14px; }
  .kpi { flex-basis: 45%; }
  .welcome h4 { font-size: 1.05rem; }
}
@media print { .tabbar, .nav-backdrop { display: none !important; } }

/* ---- Attendance reports (sheet, summary, individual) ---- */
.att-checks { display: flex; flex-wrap: wrap; gap: 2px 10px; padding-top: 4px; }
.att-checks label { font-size: 12px; font-weight: 600; margin: 0; cursor: pointer; }
.att-scroll { overflow-x: auto; }
.att-table { border-collapse: collapse; font-size: 12px; }
.att-table th, .att-table td { border: 1px solid #c9d3e6; padding: 3px 5px; text-align: center; white-space: nowrap; }
.att-table thead th { background: #4a67a1; color: #fff; font-weight: 700; }
.att-table thead th.att-sub { background: #9db4e3; color: #1c2b4a; font-weight: 600; font-size: 11px; }
.att-table .att-name { text-align: left; font-weight: 700; color: #2f4a8a; min-width: 150px; position: sticky; left: 0; background: #fff; z-index: 1; }
.att-table thead th.att-name { color: #fff; background: #4a67a1; z-index: 2; }
.att-table .att-we, .att-table thead th.att-we { background: #ffff00 !important; color: #222; }
.att-dow { font-weight: 400; font-size: 10px; opacity: .85; margin-left: 3px; }
.att-sheet td.att-t { font-size: 11px; min-width: 62px; color: #1c2b4a; background: #fff; }
.att-sheet td.att-n { font-size: 11px; min-width: 38px; background: #dfe8fb; color: #1c2b4a; }
.att-sheet td.att-lm { background: #c9d8f6; font-weight: 700; }
.att-sheet td.att-we { background: #ffff00; }
.att-summary th.att-vert { padding: 0; height: 90px; vertical-align: bottom; min-width: 26px; }
.att-summary th.att-vert span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); padding: 4px 0; font-weight: 600; }
.att-summary th.att-num { background: #eef1f6; color: #2f4a8a; }
.att-summary th.att-tot, .att-summary td.att-tot-v { min-width: 34px; font-weight: 700; }
.att-summary th.att-tot { background: #7f98c9; } .att-summary th.att-tot-a { background: #5f7fc0; }
.att-summary td.att-tot-v { background: #fff; color: #1c2b4a; } .att-summary td.att-tot-a { background: #cfe0f6; }
.att-summary td.att-c { min-width: 26px; font-weight: 600; background: #fff; color: #1c2b4a; }
.att-summary td.att-late { background: #ffe0b2; color: #7a3e00; }
.att-summary tfoot td { background: #eef1f6; font-weight: 700; color: #1c2b4a; }
.att-person { font-weight: 700; color: #2f4a8a; font-size: 15px; margin: 4px 0; }
.att-ind { min-width: 640px; }
.att-ind td, .att-ind th { color: #1c2b4a; } .att-ind td { background: #fff; }
.att-ind thead th.att-duty, .att-ind td.att-duty { background: #6a9be8; color: #fff; }
.att-ind thead th.att-sub2 { background: #4a67a1; font-weight: 600; }
.att-ind thead th.att-red { background: #ff0000; color: #fff; } .att-ind thead th.att-red2 { background: #ff0000; color: #fff; font-weight: 600; }
.att-ind td.att-dayc { text-align: right; font-weight: 600; } .att-ind td.att-t2 { text-align: right; padding-right: 8px; }
.att-ind td.att-redv { color: #e00000; text-align: right; }
.att-ind tr.att-we-row td:not(.att-duty) { background: #ffff00; }
.att-ind tfoot td { background: #eef1f6; font-weight: 700; }
.att-print { display: none; }
@media print {
    .att-screen { display: none !important; } .att-print { display: block; }
    .att-pblock { break-after: page; margin-bottom: 8px; } .att-pblock:last-child { break-after: auto; }
    .att-table { font-size: 10px; } .att-table th, .att-table td { -webkit-print-color-adjust: exact; print-color-adjust: exact; padding: 2px 3px; }
    .att-table .att-name { position: static; }
    .att-scroll { overflow: visible; }
}

.att-key { display: inline-block; min-width: 24px; padding: 0 5px; border: 1px solid #c9d3e6; text-align: center; font-weight: 700; color: #1c2b4a; margin-right: 3px; }
.att-ind-block { margin-bottom: 2px; }
@media print { .att-person { break-before: auto; } .att-ind-block + div + .att-person { break-before: page; } }
