/* ==========================================================================
   MedEMR design system - shared by every page (Site.Master, login, portal).
   Same class names as the MedManagement / MedPayroll admin masters
   (card, btn, page-banner, stat-card, data-table, nav-group ...) so pages can be
   moved across. Mobile-first: phones, tablets, desktops, iPhone / iPad notches.
   ========================================================================== */
:root {
    --primary: #0f766e; --primary-dark: #115e59; --primary-light: #5eead4; --primary-soft: #ccfbf1;
    --success: #16a34a; --danger: #dc2626; --warning: #f59e0b; --info: #0284c7;
    --gray-50: #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0; --gray-300: #cbd5e1; --gray-500: #64748b;
    --gray-600: #475569; --gray-700: #334155; --gray-800: #1e293b; --gray-900: #0f172a;
    --radius-sm: 8px; --radius-md: 12px;
    --shadow: 0 1px 3px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.05);
    --transition: .2s ease; --sidebar-width: 260px; --topbar-height: 60px;
    --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body { font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif; background: var(--gray-50); color: var(--gray-900); font-size: 14px; line-height: 1.45; }
a { color: inherit; }
code { background: var(--gray-100); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
/* iOS zooms into inputs smaller than 16px - keep form controls at 16px on touch screens */
@media (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }

/* ---------- primitives ---------- */
.card { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 700; padding-bottom: 12px; border-bottom: 2px solid var(--gray-100); margin-bottom: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-title i { color: var(--primary); }
.card-title .spacer, .spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 18px; min-height: 42px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; border: none; cursor: pointer; transition: var(--transition); text-decoration: none; white-space: nowrap; font-family: inherit; }
.btn-primary { background: var(--primary); color: #fff; } .btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); } .btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: not-allowed; }
.btn.is-busy::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.alert-box { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert-error { background: #fdecea; color: #b91c1c; } .alert-info { background: #e0f2fe; color: #075985; }
.alert-success { background: #ecfdf5; color: #047857; } .alert-warning { background: #fffbeb; color: #b45309; }
.form-control-custom { width: 100%; padding: 11px 14px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: #fff; transition: var(--transition); color: var(--gray-900); }
.form-control-custom:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
label.lbl { display: block; font-size: 12.5px; font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.form-row > div { flex: 1; min-width: 200px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-success { background: #dcfce7; color: #166534; } .badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; } .badge-info { background: #e0f2fe; color: #075985; } .badge-muted { background: var(--gray-100); color: var(--gray-700); }
.muted { color: var(--gray-500); font-size: 12.5px; }
.page-banner { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); border-radius: var(--radius-md); padding: 22px 24px; color: #fff; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-banner h1 { margin: 0 0 4px; font-size: 19px; display: flex; align-items: center; gap: 10px; }
.page-banner p { margin: 0; font-size: 13px; opacity: .92; max-width: 720px; }
.page-banner .btn-back { background: rgba(255,255,255,.16); color: #fff; }
.page-banner .btn-back:hover { background: rgba(255,255,255,.28); }
.page-banner.dark { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 16px; border-left: 4px solid var(--primary); }
.stat-card .stat-value { font-size: 22px; font-weight: 800; } .stat-card .stat-label { font-size: 10.5px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; background: var(--gray-800); color: #fff; white-space: nowrap; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.feature-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.feature-list li { display: flex; gap: 10px; align-items: flex-start; background: var(--gray-50); border: 1px solid var(--gray-100); border-radius: 10px; padding: 10px 12px; }
.feature-list li i { color: var(--primary); margin-top: 3px; }
.feature-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.feature-row:last-child { border-bottom: none; }
.feature-row .feature-label { font-weight: 600; color: var(--gray-700); } .feature-row .feature-hint { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--gray-300); transition: var(--transition); border-radius: 999px; }
.toggle-switch .slider::before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; transition: var(--transition); border-radius: 50%; }
.toggle-switch input:checked + .slider { background: var(--success); }
.toggle-switch input:checked + .slider::before { transform: translateX(20px); }
.toggle-switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---------- page loader + toasts ---------- */
#mmPageLoader { position: fixed; inset: 0; background: rgba(248,250,252,.85); z-index: 2000; display: flex; align-items: center; justify-content: center; transition: opacity .25s; }
#mmPageLoader.hide { opacity: 0; pointer-events: none; }
.mm-ring { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; margin: 0 auto 10px; }
.mm-pl-text { font-weight: 700; color: var(--primary-dark); font-size: 13px; text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-host { position: fixed; right: calc(16px + var(--safe-right)); bottom: calc(16px + var(--safe-bottom)); z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--gray-900); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; animation: toastIn .2s ease; }
.toast.ok i { color: #4ade80; } .toast.err i { color: #f87171; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* ---------- app shell ---------- */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: var(--sidebar-width); background: var(--gray-900); color: #fff; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; transition: transform var(--transition), width var(--transition); padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); padding-left: var(--safe-left); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-size: 16px; font-weight: 800; } .brand-name .accent { color: var(--primary-light); }
.brand-sub { font-size: 9px; font-weight: 700; letter-spacing: .6px; color: #64748b; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; -webkit-overflow-scrolling: touch; }
.nav-link, .nav-group-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 20px; font-size: 13.5px; font-weight: 500; color: #cbd5e1; text-decoration: none; background: none; border: none; border-left: 3px solid transparent; font-family: inherit; text-align: left; cursor: pointer; }
.nav-link i, .nav-group-btn .nav-icon { width: 18px; text-align: center; color: #94a3b8; }
.nav-link:hover, .nav-group-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(20,184,166,.16); color: #fff; border-left-color: var(--primary-light); }
.nav-link.active i { color: var(--primary-light); }
.nav-group-btn .nav-label { flex: 1; } .nav-group-btn .nav-caret { font-size: 11px; color: #64748b; transition: transform var(--transition); }
.nav-group.open > .nav-group-btn { color: #fff; } .nav-group.open > .nav-group-btn .nav-caret { transform: rotate(180deg); }
.nav-group.has-active > .nav-group-btn { border-left-color: var(--primary-light); }
.nav-children { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.nav-group.open > .nav-children { max-height: 900px; }
.nav-children a { display: flex; align-items: center; gap: 10px; padding: 9px 20px 9px 50px; font-size: 13px; color: #94a3b8; text-decoration: none; border-left: 3px solid transparent; }
.nav-children a:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-children a.active { color: var(--primary-light); font-weight: 700; border-left-color: var(--primary-light); background: rgba(20,184,166,.1); }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.user-meta { flex: 1; min-width: 0; } .u-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-role { font-size: 9.5px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .4px; }
.footer-logout { background: rgba(255,255,255,.08); border: none; color: #e2e8f0; font-size: 12px; font-weight: 700; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-decoration: none; }
.footer-logout:hover { background: var(--danger); }
.powered-by { text-align: center; font-size: 10px; color: #475569; padding: 0 0 8px; }
.powered-by a { color: var(--primary-light); text-decoration: none; font-weight: 700; }
.sidebar-backdrop { display: none; }
.main-area { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; }
.topbar { min-height: var(--topbar-height); background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 12px; padding: var(--safe-top) calc(16px + var(--safe-right)) 0 16px; position: sticky; top: 0; z-index: 50; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--gray-200); background: #fff; color: var(--gray-700); font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; text-decoration: none; }
.icon-btn:hover { background: var(--gray-50); color: var(--primary); }
.sidebar-toggle { display: none; }
.content-area { padding: 20px calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) 20px; flex: 1; }
.app-footer { text-align: center; color: var(--gray-500); font-size: 11.5px; padding: 10px 10px calc(14px + var(--safe-bottom)); }

/* ---------- master search + scanner ---------- */
.master-search { flex: 1; max-width: 640px; position: relative; }
.ms-box { display: flex; align-items: center; background: var(--gray-100); border-radius: 999px; padding: 0 6px 0 14px; border: 1px solid transparent; }
.ms-box:focus-within { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.ms-box > i { color: var(--gray-500); }
.ms-box input { flex: 1; border: none; background: transparent; padding: 10px; font-family: inherit; font-size: 14px; outline: none; min-width: 0; color: var(--gray-900); }
.ms-btn { border: none; background: none; width: 36px; height: 36px; border-radius: 50%; color: var(--gray-600); cursor: pointer; font-size: 15px; flex-shrink: 0; }
.ms-btn:hover { background: var(--primary-soft); color: var(--primary); }
.ms-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border-radius: var(--radius-md); box-shadow: 0 16px 40px rgba(15,23,42,.18); border: 1px solid var(--gray-200); max-height: min(70vh, 480px); overflow-y: auto; display: none; z-index: 300; }
.ms-results.open { display: block; }
.ms-section { padding: 8px 14px 4px; font-size: 10.5px; font-weight: 800; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.ms-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; text-decoration: none; color: var(--gray-900); }
.ms-item:hover, .ms-item.focus { background: var(--gray-50); }
.ms-item .ms-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ms-item b { display: block; font-size: 13.5px; } .ms-item span { font-size: 12px; color: var(--gray-500); }
.ms-empty { padding: 18px; text-align: center; color: var(--gray-500); font-size: 13px; }
.scan-sheet { position: fixed; inset: 0; background: rgba(15,23,42,.75); z-index: 2500; display: none; align-items: center; justify-content: center; padding: 16px; }
.scan-sheet.open { display: flex; }
.scan-panel { background: #fff; border-radius: 16px; width: min(460px, 100%); overflow: hidden; }
.scan-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 800; border-bottom: 1px solid var(--gray-100); }
.scan-view { background: #000; aspect-ratio: 1 / 1; position: relative; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-view #scanFallback { width: 100%; height: 100%; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(94,234,212,.9); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none; }
.scan-foot { padding: 12px 16px calc(14px + var(--safe-bottom)); display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--gray-500); }
.nfc-pulse { width: 110px; height: 110px; margin: 30px auto; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 42px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 16px rgba(15,118,110,.08); } }

/* ---------- notification bell ---------- */
.notif-badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid #fff; }
.notif-panel { position: absolute; top: 48px; right: 0; width: min(340px, calc(100vw - 24px)); max-height: 440px; background: #fff; border-radius: var(--radius-md); box-shadow: 0 16px 40px rgba(15,23,42,.18); border: 1px solid var(--gray-200); display: none; flex-direction: column; overflow: hidden; z-index: 300; }
.notif-panel.open { display: flex; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--gray-100); font-weight: 800; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item { display: block; padding: 11px 16px; border-bottom: 1px solid var(--gray-100); text-decoration: none; }
.notif-item.unread { background: #f0fdfa; }
.notif-item b { font-size: 13px; display: block; } .notif-item span { font-size: 12px; color: var(--gray-500); }
.notif-wrap { position: relative; }

/* ---------- dashboard tiles ---------- */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.module-tile { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 16px; text-decoration: none; display: flex; flex-direction: column; gap: 6px; border: 2px solid transparent; transition: transform .12s, border-color .12s; }
.module-tile:hover { transform: translateY(-2px); border-color: var(--primary); }
.mt-ic { width: 42px; height: 42px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.mt-t { font-weight: 800; font-size: 14.5px; } .mt-s { font-size: 12.5px; color: var(--gray-500); }

/* ---------- install banner (all systems) + iOS sheet ---------- */
.install-btn { display: none; } .install-btn.show { display: inline-flex; }
.sheet { position: fixed; inset: 0; z-index: 2600; background: rgba(15,23,42,.6); display: none; align-items: flex-end; justify-content: center; }
.sheet.open { display: flex; }
.sheet-body { background: #fff; width: min(520px, 100%); border-radius: 18px 18px 0 0; padding: 22px 22px calc(22px + var(--safe-bottom)); }
.sheet-body h3 { margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.sheet-body ol { padding-left: 20px; line-height: 1.9; }
.sheet-body .ios-share { display: inline-flex; width: 26px; height: 26px; border-radius: 6px; background: var(--gray-100); align-items: center; justify-content: center; color: #0a84ff; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-body { border-radius: 18px; } }

/* ---------- auth pages ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
             background: radial-gradient(1000px 520px at -10% -20%, #14b8a6 0%, transparent 55%), linear-gradient(150deg, #0b2321 0%, #115e59 55%, #0f766e 100%); }
.auth-card { background: #fff; border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); width: min(440px, 100%); padding: 26px 24px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.auth-brand .brand-mark { width: 46px; height: 46px; border-radius: 12px; }
.auth-brand h1 { margin: 0; font-size: 21px; } .auth-brand h1 .accent { color: var(--primary); }
.auth-sub { color: var(--gray-500); margin: 0 0 18px; font-size: 13px; }
.method-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; background: var(--gray-100); padding: 5px; border-radius: 12px; margin-bottom: 16px; }
.method-tabs button { border: none; background: none; padding: 9px 4px; border-radius: 9px; font-family: inherit; font-size: 12px; font-weight: 700; color: var(--gray-600); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.method-tabs button i { font-size: 16px; }
.method-tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.method-panel { display: none; } .method-panel.active { display: block; }
.field { margin-bottom: 14px; } .field .pw { position: relative; }
.field .pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: none; color: var(--gray-500); width: 36px; height: 36px; cursor: pointer; }
.pin-input { letter-spacing: 12px; text-align: center; font-size: 22px !important; font-weight: 800; }
.bio-hero { text-align: center; padding: 8px 0 4px; }
.bio-hero .bio-ic { width: 84px; height: 84px; border-radius: 24px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-size: 38px; margin-bottom: 10px; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--gray-500); font-size: 12px; margin: 16px 0; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--gray-200); }
.auth-foot { text-align: center; color: rgba(255,255,255,.7); font-size: 12px; margin-top: 16px; }
.auth-foot b { color: var(--primary-light); }
.auth-wrap { width: min(440px, 100%); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
    .sidebar { transform: translateX(-105%); } .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; } .sidebar-toggle { display: inline-flex; }
    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90; }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .topbar { gap: 8px; padding-left: 10px; }
    .content-area { padding: 14px 12px calc(14px + var(--safe-bottom)); }
    .page-banner { padding: 18px; } .page-banner h1 { font-size: 17px; }
    .hide-sm { display: none !important; }
    .card { padding: 16px; }
    .form-row > div { min-width: 100%; }
}
@media print { .sidebar, .topbar, .no-print, .toast-host { display: none !important; } .main-area { margin-left: 0; } .card { box-shadow: none; } }
@media (display-mode: standalone) { .install-btn { display: none !important; } }

/* ---------- module pages (lists, filters, forms, tabs) ---------- */
.nav-section { padding: 14px 20px 4px; font-size: 10px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: #64748b; }
.where-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--gray-700); background: var(--gray-100); padding: 8px 12px; border-radius: 999px; text-decoration: none; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.where-chip i { color: var(--primary); }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filter-bar > div { flex: 1; min-width: 150px; }
.filter-bar > div[style*="flex:0"] { flex: 0 0 auto !important; min-width: 0; }
.filter-bar label, .form-row label { display: block; font-size: 12.5px; font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.form-row label.req::after, label.req::after { content: " *"; color: var(--danger); }
.empty-state { padding: 30px !important; text-align: center; color: var(--gray-500); font-size: 13px; }
.empty-state i { margin-right: 6px; }
.data-table tr:hover td { background: #f0fdfa; }
.data-table .num { text-align: right; }
.data-table .row-actions { white-space: nowrap; text-align: right; }
.data-table .row-actions .btn { margin-left: 4px; }
.data-table tr.row-off td { opacity: .55; }
.data-table .pager td { background: #fff !important; border: none; padding-top: 12px; }
.data-table .pager a, .data-table .pager span { display: inline-block; padding: 5px 10px; margin-right: 4px; border-radius: 6px; background: var(--gray-100); text-decoration: none; font-weight: 600; }
.data-table .pager span { background: var(--primary); color: #fff; }
.section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--primary-dark); margin: 18px 0 10px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv .k { color: var(--gray-500); font-weight: 600; }
.inline-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.inline-check input { width: 17px; height: 17px; accent-color: var(--primary); }
.admin-tabs { display: flex; gap: 6px; background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-tab-btn { flex: 1; min-width: 110px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px; border: none; background: none; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--gray-500); font-family: inherit; cursor: pointer; }
.admin-tab-btn.active { background: var(--primary); color: #fff; }
.admin-tab-panel { display: none; } .admin-tab-panel.active { display: block; }
.perm-table td, .perm-table th { text-align: center; } .perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }
.perm-group td { background: var(--gray-50) !important; font-weight: 800; color: var(--primary-dark); text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 700; background: var(--gray-100); color: var(--gray-700); padding: 3px 9px; border-radius: 999px; margin: 2px 4px 2px 0; }
.logo-thumb { width: 38px; height: 38px; border-radius: 9px; object-fit: contain; background: var(--gray-50); border: 1px solid var(--gray-200); }
.pre { white-space: pre-wrap; font-family: Consolas, monospace; font-size: 12px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 12px; max-height: 420px; overflow: auto; }

/* ---------- patient card (prints at ID-1 card size) ---------- */
.pcard { width: 342px; height: 216px; border-radius: 14px; background: linear-gradient(135deg, #0f766e, #115e59); color: #fff; padding: 14px 16px; position: relative; overflow: hidden; box-shadow: 0 10px 30px rgba(15,23,42,.25); }
.pcard .pc-top { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; }
.pcard .pc-top img { width: 26px; height: 26px; border-radius: 6px; background: #fff; }
.pcard .pc-name { font-size: 17px; font-weight: 800; margin-top: 12px; line-height: 1.15; max-width: 200px; }
.pcard .pc-meta { font-size: 11.5px; opacity: .9; margin-top: 4px; line-height: 1.5; max-width: 200px; }
.pcard .pc-qr { position: absolute; right: 14px; top: 44px; background: #fff; border-radius: 8px; padding: 5px; width: 104px; height: 104px; }
.pcard .pc-qr img, .pcard .pc-qr canvas { width: 100%; height: 100%; }
.pcard .pc-bar { position: absolute; left: 12px; right: 12px; bottom: 8px; background: #fff; border-radius: 6px; height: 46px; display: flex; align-items: center; justify-content: center; }
.pcard .pc-bar svg { height: 42px; max-width: 100%; }
@media print { .pcard { box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; } .pcard { transform: scale(.92); transform-origin: left top; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* live search: thin progress bar under the filter bar while results load */
.filter-bar { position: relative; }
.filter-bar.live-busy::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--primary), transparent); background-size: 200% 100%; animation: liveBar 1s linear infinite; }
@keyframes liveBar { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Make a payment (Patient Bills) ---------- */
.pay-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: none; border-radius: 14px; padding: 0; box-shadow: 0 20px 60px rgba(15,23,42,.35); }
.pay-dialog::backdrop { background: rgba(15,23,42,.55); }
.pay-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--primary); color: #fff; }
.pay-dialog-head h2 { margin: 0; font-size: 17px; }
.pay-close { background: none; border: none; color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.pay-dialog > :not(.pay-dialog-head) { margin-left: 18px; margin-right: 18px; }
.pay-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 14px; margin-bottom: 14px; padding: 12px; background: var(--gray-50, #f8fafc); border: 1px solid var(--gray-200, #e5e7eb); border-radius: 10px; font-size: 13px; }
.pay-summary span { display: block; font-size: 11px; color: var(--gray-500, #6b7280); text-transform: uppercase; letter-spacing: .4px; }
.pay-summary .pay-balance { grid-column: 1 / -1; border-top: 1px dashed var(--gray-300, #cbd5e1); padding-top: 8px; }
.pay-summary .pay-balance b { font-size: 20px; color: #b91c1c; }
.pay-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0 16px; border-top: 1px solid var(--gray-100, #f1f5f9); }
.pay-done { border-left: 4px solid #16a34a; }
.pay-done-head { display: flex; gap: 12px; align-items: flex-start; }
.pay-done-head > i { color: #16a34a; font-size: 26px; }
.pay-done-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
@media (max-width: 520px) { .pay-summary { grid-template-columns: 1fr; } }
.pay-patient { border-left: 4px solid var(--primary); }
.pay-patient-who { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; }
.pay-patient-who > div:first-child { flex: 1 1 260px; }
.pay-patient-who h2 { margin: 2px 0 4px; font-size: 20px; }
.pay-patient-due { display: flex; flex-direction: column; align-items: flex-end; }
.pay-patient-due span { font-size: 12px; color: var(--gray-500, #6b7280); }
.pay-patient-due b { font-size: 26px; color: #b91c1c; line-height: 1.2; }
.pay-patient-due.ok b { color: #16a34a; }
@media (max-width: 640px) { .pay-patient-due { align-items: flex-start; } }

/* ---------- Telehealth video room ---------- */
.th-room { background: #0b1220; border-radius: 16px; overflow: hidden; color: #e2e8f0; box-shadow: 0 10px 30px rgba(2,6,23,.35); }
.th-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: #111a2e; }
.th-top b { color: #fff; font-size: 15px; }
.th-sub { font-size: 12.5px; color: #94a3b8; margin-top: 2px; }
.th-sub .ok { color: #4ade80; } .th-sub .warn { color: #fbbf24; } .th-sub .bad { color: #f87171; }
.th-timer { font-variant-numeric: tabular-nums; margin-left: 6px; color: #cbd5e1; }
.th-top-actions { display: flex; gap: 8px; }
.th-main { display: flex; min-height: 62vh; }
.th-stage { position: relative; flex: 1; background: #020617; min-height: 62vh; display: flex; align-items: center; justify-content: center; }
.th-remote { width: 100%; height: 100%; max-height: 78vh; object-fit: contain; background: #020617; }
.th-local { position: absolute; right: 16px; top: 16px; width: 22%; max-width: 240px; min-width: 110px; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.25); background: #1e293b; transform: scaleX(-1); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.th-wait { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; background: radial-gradient(circle at center, #1e293b 0, #020617 70%); }
.th-wait #thWaitText { font-size: 18px; font-weight: 600; color: #fff; }
.th-hint { font-size: 13px; color: #94a3b8; max-width: 460px; }
.th-avatar { width: 84px; height: 84px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #7c3aed); display: flex; align-items: center; justify-content: center; font-size: 34px; color: #fff; animation: thpulse 2s infinite; }
@keyframes thpulse { 0% { box-shadow: 0 0 0 0 rgba(124,58,237,.5); } 70% { box-shadow: 0 0 0 22px rgba(124,58,237,0); } 100% { box-shadow: 0 0 0 0 rgba(124,58,237,0); } }
.th-controls { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 10px; padding: 10px 14px; background: rgba(15,23,42,.75); backdrop-filter: blur(8px); border-radius: 999px; z-index: 3; }
.th-btn { position: relative; width: 48px; height: 48px; border-radius: 50%; border: none; background: #334155; color: #fff; font-size: 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.th-btn:hover { background: #475569; }
.th-btn.off { background: #f1f5f9; color: #b91c1c; }
.th-btn.on { background: #6366f1; }
.th-btn.th-end { background: #dc2626; width: 58px; }
.th-btn.th-end:hover { background: #b91c1c; }
.th-badge { display: none; position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; line-height: 18px; }
.th-chat { display: flex; width: 340px; flex: none; flex-direction: column; background: #fff; color: #0f172a; border-left: 1px solid #e2e8f0; }
.th-chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid #e2e8f0; }
.th-x { border: none; background: none; font-size: 22px; cursor: pointer; color: #64748b; }
.th-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; max-height: 62vh; }
.th-empty { color: #94a3b8; font-size: 12.5px; text-align: center; margin: auto 0; }
.th-msg { max-width: 85%; align-self: flex-start; }
.th-msg.me { align-self: flex-end; text-align: right; }
.th-who { font-size: 11px; color: #94a3b8; margin-bottom: 2px; }
.th-bubble { display: inline-block; text-align: left; padding: 8px 11px; border-radius: 14px; background: #f1f5f9; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.th-msg.me .th-bubble { background: linear-gradient(135deg, #6366f1, #7c3aed); color: #fff; }
.th-send { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #e2e8f0; }
.th-send input { flex: 1; border: 1px solid #cbd5e1; border-radius: 10px; padding: 9px 11px; font: inherit; }
.th-backup { padding: 10px 16px; font-size: 13px; background: #111a2e; color: #cbd5e1; }
.th-backup a { color: #a5b4fc; }
.th-list .live td { background: #f0fdf4; }
@media (max-width: 1000px) {
  .th-main { flex-direction: column; }
  .th-chat { width: auto; border-left: none; border-top: 1px solid #e2e8f0; }
  .th-msgs { max-height: 40vh; }
}
@media (max-width: 640px) {
  .th-stage, .th-main { min-height: 70vh; }
  .th-local { width: 34%; right: 10px; top: 10px; }
  .th-controls { gap: 6px; padding: 8px 10px; bottom: 12px; }
  .th-btn { width: 42px; height: 42px; font-size: 16px; }
  .th-btn.th-end { width: 50px; }
}

/* chat is always on screen; on narrow screens it sits under the video */
.th-chat-head .th-badge { display: none; }
.th-wait .btn { margin-top: 6px; }
/* floating call window (CallWindow.aspx) */
body.th-mini-body { margin: 0; background: #0b1220; }
.th-room.th-mini { border-radius: 0; box-shadow: none; min-height: 100vh; display: flex; flex-direction: column; }
.th-mini .th-top { padding: 8px 10px; }
.th-mini .th-top b { font-size: 13.5px; }
.th-mini .th-main { flex-direction: column; flex: 1; min-height: 0; }
.th-mini .th-stage { min-height: 0; height: 52vh; flex: none; }
.th-mini .th-remote { max-height: 52vh; }
.th-mini .th-local { width: 30%; min-width: 80px; right: 8px; top: 8px; }
.th-mini .th-controls { gap: 5px; padding: 6px 8px; bottom: 8px; }
.th-mini .th-btn { width: 38px; height: 38px; font-size: 15px; }
.th-mini .th-btn.th-end { width: 46px; }
.th-mini .th-chat { width: auto; flex: 1; min-height: 0; border-left: none; border-top: 1px solid #e2e8f0; }
.th-mini .th-msgs { max-height: none; flex: 1; }
.th-mini .th-wait #thWaitText { font-size: 15px; }
.th-mini .th-avatar { width: 56px; height: 56px; font-size: 24px; }

/* ---------- Vital signs colours ---------- */
.vs-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-weight: 700; font-size: 13px; white-space: nowrap; border: 1px solid transparent; }
.vs-pill small { font-weight: 600; font-size: 11px; opacity: .9; }
.vs-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.vs-green { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.vs-amber { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.vs-red { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.vs-red .vs-dot { animation: vsblink 1.2s infinite; }
@keyframes vsblink { 50% { opacity: .25; } }
tr.vs-row-red td { background: #fff5f5; }
tr.vs-row-red td:first-child { box-shadow: inset 4px 0 0 #dc2626; }
tr.vs-row-amber td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
.vs-in-green { border-color: #10b981 !important; background: #f0fdf4 !important; }
.vs-in-amber { border-color: #f59e0b !important; background: #fffbeb !important; }
.vs-in-red { border-color: #dc2626 !important; background: #fef2f2 !important; box-shadow: 0 0 0 3px rgba(220,38,38,.15) !important; }
.vs-tag { font-size: 12px; font-weight: 700; margin-top: 3px; min-height: 16px; background: none !important; border: none !important; }
.vs-tag.vs-green { color: #047857; } .vs-tag.vs-amber { color: #b45309; } .vs-tag.vs-red { color: #b91c1c; }
.vs-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.vs-legend details { flex-basis: 100%; }
.vs-legend summary { cursor: pointer; color: var(--primary, #0f766e); font-weight: 600; font-size: 12.5px; }
.vs-ranges { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; }
.vs-ranges th, .vs-ranges td { padding: 6px 8px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
.vs-ranges th:nth-child(2) { color: #047857; } .vs-ranges th:nth-child(3) { color: #b45309; } .vs-ranges th:nth-child(4) { color: #b91c1c; }

/* ---------- Reports, exports & document views (billing, pharmacy, lab, radiology) ---------- */
.rpt-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.rpt-tab { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--gray-200, #e5e7eb); color: var(--gray-700, #374151); font-weight: 600; font-size: 13px; text-decoration: none; }
.rpt-tab:hover { border-color: var(--primary, #0f766e); color: var(--primary, #0f766e); }
.rpt-tab.active { background: var(--primary, #0f766e); border-color: var(--primary, #0f766e); color: #fff; }
.rpt-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.rpt-filter > div { min-width: 150px; }
.rpt-filter label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-600, #4b5563); margin-bottom: 4px; }
.rpt-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rpt-quick a { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--gray-50, #f9fafb); border: 1px solid var(--gray-200, #e5e7eb); color: var(--gray-700, #374151); text-decoration: none; }
.rpt-quick a:hover { border-color: var(--primary, #0f766e); color: var(--primary, #0f766e); }
.export-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.btn-pdf { background: #b91c1c; color: #fff !important; border-color: #b91c1c; }
.btn-pdf:hover { background: #991b1b; }
.btn-xlsx { background: #15803d; color: #fff !important; border-color: #15803d; }
.btn-xlsx:hover { background: #166534; }
.rpt-cols { display: flex; gap: 4px; align-items: stretch; overflow-x: auto; padding-top: 8px; }
.rpt-col { flex: 1 0 18px; max-width: 56px; display: flex; flex-direction: column; align-items: center; }
.rpt-stack { height: 170px; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--gray-200, #e5e7eb); }
.rpt-stack i { flex: 1; max-width: 18px; background: var(--primary, #0f766e); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.rpt-stack i.alt { background: #f59e0b; }
.rpt-col:hover .rpt-stack i { opacity: 1; }
.rpt-col span { font-size: 10px; color: var(--gray-500, #6b7280); margin-top: 4px; white-space: nowrap; }
.rpt-hbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; gap: 6px 10px; align-items: center; font-size: 13px; }
.rpt-hbar .track { height: 12px; background: var(--gray-100, #f3f4f6); border-radius: 999px; overflow: hidden; }
.rpt-hbar .track b { display: block; height: 100%; background: var(--primary, #0f766e); border-radius: 999px; }
.rpt-hbar .track b.amber { background: #f59e0b; } .rpt-hbar .track b.red { background: #dc2626; } .rpt-hbar .track b.blue { background: #2563eb; }
.rpt-hbar .val { text-align: right; font-weight: 700; white-space: nowrap; }
.rpt-legend { display: flex; gap: 14px; font-size: 12px; color: var(--gray-600, #4b5563); margin-top: 8px; }
.rpt-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--primary, #0f766e); margin-right: 5px; vertical-align: -1px; }
.rpt-legend span.alt::before { background: #f59e0b; }
.rpt-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.doc-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 20px; }
.doc-head .k { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--gray-500, #6b7280); font-weight: 700; }
.doc-head .v { font-weight: 700; margin-top: 2px; }
.doc-totals { margin-left: auto; max-width: 340px; display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 14px; }
.doc-totals .last { border-top: 2px solid var(--primary, #0f766e); padding-top: 8px; font-size: 17px; font-weight: 800; color: var(--primary, #0f766e); }
.data-table tr.total td { font-weight: 800; background: var(--gray-50, #f9fafb); border-top: 2px solid var(--gray-300, #d1d5db); }
.data-table tr.row-red td { background: #fff5f5; } .data-table tr.row-red td:first-child { box-shadow: inset 4px 0 0 #dc2626; }
.data-table tr.row-amber td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
.data-table tr.row-muted td { color: var(--gray-400, #9ca3af); }
.catalog-tools summary::-webkit-details-marker { display: none; }
.catalog-tools[open] summary { margin-bottom: 4px !important; }
@media print { .rpt-tabs, .rpt-filter, .export-btns, .page-banner .banner-actions { display: none !important; } }
