/*
 * CareLink HMS design system.
 * Every colour is a token below. Themes (blue, green, red) only re-declare the brand tokens,
 * so re-theming is a one-file change. Structure: shell, components, print, responsive.
 */

/* ---- Tokens ------------------------------------------------------------------------------- */
:root {
    --primary: #1a6fd1;
    --primary-dark: #0f4c9a;
    --primary-soft: #e8f1fc;
    --accent: #14a38f;
    --sidebar-bg: #0b2a4a;
    --sidebar-text: #b9cadf;
    --sidebar-muted: #7f95b0;
    --sidebar-active: rgba(255, 255, 255, .12);

    --success: #1a8a4f;
    --warning: #d99100;
    --danger: #d13b3b;
    --info: #0b93b3;

    --bg: #f3f6fa;
    --surface: #ffffff;
    --text: #1d2939;
    --muted: #667487;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

    --bs-primary: var(--primary);
    --bs-primary-rgb: 26, 111, 209;
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-dark);
    --bs-body-font-family: var(--font);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--border);
}

[data-theme="green"] {
    --primary: #0f8a5f;
    --primary-dark: #0a6a48;
    --primary-soft: #e2f5ec;
    --accent: #e0a100;
    --sidebar-bg: #0a3a2b;
    --sidebar-text: #b5d3c6;
    --sidebar-muted: #7ea593;
    --bs-primary-rgb: 15, 138, 95;
}

[data-theme="red"] {
    --primary: #c62839;
    --primary-dark: #9b1c2b;
    --primary-soft: #fce8ea;
    --accent: #1f7a8c;
    --sidebar-bg: #3b1017;
    --sidebar-text: #dbbcc1;
    --sidebar-muted: #a98088;
    --bs-primary-rgb: 198, 40, 57;
}

/* Display mode is a per-device preference; it does not change the hospital's brand theme. */
[data-mode="dark"] {
    --bg: #101820;
    --surface: #17232e;
    --text: #edf4f8;
    --muted: #aec0cd;
    --border: #2b3c4a;
    --primary-soft: color-mix(in srgb, var(--primary) 22%, #17232e);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 26px rgba(0, 0, 0, .18);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-bg: #1c2a36;
    --bs-secondary-bg: #1c2a36;
    --bs-light: #20303d;
    --bs-light-rgb: 32, 48, 61;
    --bs-emphasis-color: var(--text);
}
[data-mode="dark"] .form-control, [data-mode="dark"] .form-select { background-color: #13202a; border-color: #3a4c59; color: var(--text); }
[data-mode="dark"] .form-control::placeholder { color: #91a5b4; }
[data-mode="dark"] .form-label { color: #d6e3eb; }
[data-mode="dark"] .card, [data-mode="dark"] .modal-content, [data-mode="dark"] .dropdown-menu, [data-mode="dark"] .list-group-item { background-color: var(--surface); color: var(--text); border-color: var(--border); }
[data-mode="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); }
[data-mode="dark"] .btn-light { --bs-btn-bg: #20303d; --bs-btn-border-color: #304553; --bs-btn-color: var(--text); --bs-btn-hover-bg: #2a4050; --bs-btn-hover-border-color: #405969; --bs-btn-hover-color: #fff; }
[data-mode="dark"] .dropdown-item { color: var(--text); }
[data-mode="dark"] .dropdown-item:hover, [data-mode="dark"] .dropdown-item:focus { background: var(--primary-soft); color: var(--text); }
[data-mode="dark"] .vital { background: #13202a; }
[data-mode="dark"] .bed.occupied { background: #2b1a20; }
[data-mode="dark"] .bed.maintenance { background: #1c2a36; }
[data-mode="dark"] .test-picker label:hover { background: #20303d; }
[data-mode="dark"] .print-sheet, [data-mode="dark"] .id-card { color: #1d2939; }

/* ---- Base --------------------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: .925rem; }
a { text-decoration: none; }
h1, h2, h3, h4, h5, h6 { font-weight: 650; letter-spacing: -.01em; }
.text-muted { color: var(--muted) !important; }
.text-primary { color: var(--primary) !important; }
.bg-primary-soft { background: var(--primary-soft); }
::selection { background: var(--primary); color: #fff; }

.btn { border-radius: 9px; font-weight: 550; padding: .5rem 1rem; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { min-height: 32px; padding: .25rem .65rem; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-dark); --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark); --bs-btn-active-border-color: var(--primary-dark); --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary); }
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary-dark); --bs-btn-active-border-color: var(--primary-dark); }
.form-control, .form-select { border-radius: 9px; border-color: #cfd8e3; min-height: 42px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .18); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-label { font-weight: 550; font-size: .82rem; color: #344054; margin-bottom: .3rem; }
.input-group .btn { min-height: 42px; }
.badge-soft { font-weight: 600; padding: .38em .65em; border-radius: 6px; }
.nav-tabs { border-bottom-color: var(--border); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
.nav-tabs .nav-link { color: var(--muted); font-weight: 550; border: 0; border-bottom: 2px solid transparent; padding: .7rem 1rem; }
.nav-tabs .nav-link:hover { color: var(--primary); }
.nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.page-link { color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.modal-content { border: 0; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(16, 24, 40, .25); }
.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }

/* ---- Shell: sidebar + topbar -------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 264px; position: fixed; inset: 0 auto 0 0; background: var(--sidebar-bg); color: var(--sidebar-text);
    display: flex; flex-direction: column; z-index: 1040; transition: transform .25s ease; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.15rem 1.25rem; color: #fff; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); display: grid; place-items: center; font-size: 1.25rem; flex: none; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { line-height: 1.2; min-width: 0; }
.brand-text strong { display: block; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--sidebar-muted); font-size: .72rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .75rem 1rem; }
.nav-group { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--sidebar-muted); padding: 1rem .75rem .4rem; font-weight: 650; }
.nav-item-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; margin-bottom: 2px; border-radius: 9px; color: var(--sidebar-text); font-weight: 500; min-height: 44px; }
.nav-item-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 .4rem; border-radius: 11px; background: #fff; color: var(--sidebar-bg); font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; line-height: 1; }
.nav-item-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-user { display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .who { min-width: 0; flex: 1; line-height: 1.25; }
.sidebar-user .who strong { display: block; color: #fff; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who small { color: var(--sidebar-muted); font-size: .72rem; }
.sidebar-user .btn-logout { color: var(--sidebar-text); border: 0; background: transparent; width: 40px; height: 40px; border-radius: 9px; }
.sidebar-user .btn-logout:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(9, 16, 28, .55); z-index: 1035; }

.main { margin-left: 264px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; }
.topbar h1 { font-size: 1.1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; border: 0; background: transparent; font-size: 1.6rem; width: 44px; height: 44px; border-radius: 10px; color: var(--text); }
.clock { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.content { padding: 1.5rem; flex: 1; }
.app-footer { padding: 1rem 1.5rem; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--border); }

.bell-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px;
    background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; display: inline-grid; place-items: center; line-height: 1; }
.alert-menu { width: 340px; max-width: 90vw; max-height: 420px; overflow-y: auto; }
.alert-menu .alert-row { display: block; width: 100%; text-align: left; padding: .6rem .9rem; border: 0; border-bottom: 1px solid var(--border); background: transparent; }
.alert-menu .alert-row:hover { background: var(--primary-soft); }
.alert-menu .alert-row.unread { background: #fce9e9; }
.alert-menu .alert-row .when { color: var(--muted); font-size: .72rem; }

/* ---- Components --------------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h2 { font-size: 1.35rem; margin: 0; }
.page-head p { margin: .15rem 0 0; color: var(--muted); }
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 650; padding: .9rem 1.15rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-body { padding: 1.15rem; }
.section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 1.25rem 0 .75rem; }

.stat-card { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem 1.15rem; height: 100%; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; background: var(--primary-soft); color: var(--primary); flex: none; }
.stat-icon.success { background: #e3f6ec; color: var(--success); }
.stat-icon.warning { background: #fdf3dc; color: var(--warning); }
.stat-icon.danger { background: #fce9e9; color: var(--danger); }
.stat-icon.info { background: #dff4f8; color: var(--info); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .8rem; }

.table-modern { margin: 0; --bs-table-bg: transparent; }
.table-modern thead th { background: #f7f9fc; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; border-bottom: 1px solid var(--border); white-space: nowrap; padding: .75rem 1rem; }
.table-modern td { padding: .8rem 1rem; vertical-align: middle; border-color: var(--border); }
.table-modern tbody tr:hover { background: #fafcff; }
.table-modern .actions { white-space: nowrap; text-align: right; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.list-tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); }
.list-tools .search { flex: 1 1 220px; position: relative; }
.list-tools .search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.list-tools .search input { padding-left: 2.3rem; }
.list-tools .form-select, .list-tools .form-control { width: auto; }
.list-foot { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; padding: .85rem 1.15rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .82rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.5rem; color: #b6c2d2; display: block; margin-bottom: .5rem; }

.detail-list { display: grid; grid-template-columns: 9.5rem 1fr; gap: .55rem 1rem; margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 500; }
.detail-list dd { margin: 0; word-break: break-word; }

.triage-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: .4rem; }
.triage-dot.red { background: var(--danger); box-shadow: 0 0 0 3px rgba(209, 59, 59, .2); }
.triage-dot.yellow { background: var(--warning); }
.triage-dot.green { background: var(--success); }
.alert { border-radius: 10px; border: 0; }
.alert-gunshot { background: var(--danger); color: #fff; font-weight: 600; }

.patient-avatar { width: 84px; height: 84px; border-radius: 16px; object-fit: cover; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 2rem; font-weight: 700; flex: none; }
.staff-cell { display: flex; align-items: center; gap: .65rem; min-width: 210px; }
.staff-avatar, .profile-avatar { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; flex: none; overflow: hidden; }
.staff-avatar img, .profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar { width: 58px; height: 58px; font-size: 1.15rem; }
.vitals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.vital { background: #f7f9fc; border-radius: 10px; padding: .7rem .85rem; }
.vital small { color: var(--muted); display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.vital strong { font-size: 1.05rem; }

.bars { display: flex; align-items: flex-end; gap: .5rem; height: 150px; padding-top: 1rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 36px; background: var(--primary); border-radius: 6px 6px 2px 2px; min-height: 3px; opacity: .9; transition: opacity .15s; }
.bar:hover { opacity: 1; }
.bar-label { font-size: .7rem; color: var(--muted); margin-top: .35rem; }
.bar-value { font-size: .68rem; color: var(--muted); margin-bottom: .2rem; white-space: nowrap; }

.ward-block { margin-bottom: 1.5rem; }
.bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; }
.bed { border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; background: var(--surface); position: relative; border-left: 4px solid var(--success); }
.bed.occupied { border-left-color: var(--danger); background: #fff8f8; }
.bed.maintenance { border-left-color: #98a2b3; background: #f4f5f7; }
.bed strong { display: block; }
.bed small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.theme-option { display: block; cursor: pointer; }
.theme-option input { position: absolute; opacity: 0; }
.theme-card { border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.theme-option input:checked + .theme-card { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), .15); }
.theme-option input:focus-visible + .theme-card { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-preview { display: flex; height: 64px; border-radius: 8px; overflow: hidden; margin-bottom: .75rem; }
.theme-preview span { flex: 1; }
.theme-preview .side { flex: 0 0 28%; }

.typeahead { position: relative; }
.typeahead-menu { position: absolute; z-index: 1050; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(16, 24, 40, .16); max-height: 280px; overflow-y: auto; display: none; }
.typeahead-menu.show { display: block; }
.typeahead-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: .6rem .85rem; min-height: 44px; }
.typeahead-item:hover, .typeahead-item:focus, .typeahead-item.active { background: var(--primary-soft); outline: none; }
.typeahead-item small { display: block; color: var(--muted); }
.typeahead-chosen { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .8rem; background: var(--primary-soft); border-radius: 9px; margin-top: .4rem; font-weight: 550; }

.test-picker { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: .4rem; }
.test-picker label { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 8px; cursor: pointer; min-height: 44px; }
.test-picker label:hover { background: #f5f8fc; }
.test-picker .price { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }

.toast-stack { position: fixed; top: 76px; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; max-width: min(92vw, 380px); }
.install-btn { display: none; }

/* ---- Login --------------------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.login-hero { background: linear-gradient(150deg, var(--primary-dark), var(--primary) 55%, var(--accent)); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero .brand-mark { background: rgba(255, 255, 255, .18); width: 56px; height: 56px; font-size: 1.8rem; }
.login-hero h1 { font-size: 2.1rem; max-width: 18ch; line-height: 1.15; }
.login-hero ul { list-style: none; padding: 0; margin: 1.5rem 0 0; opacity: .92; }
.login-hero li { margin-bottom: .6rem; display: flex; gap: .6rem; align-items: center; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.login-box { width: 100%; max-width: 400px; }
.login-box .brand-mark { display: none; }

/* ---- Patient portal ------------------------------------------------------------------------ */
.portal-top { position: sticky; top: 0; z-index: 1020; background: var(--surface); border-bottom: 1px solid var(--border); }
.portal-top-inner { max-width: 1040px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; }
.portal-brand { display: flex; align-items: center; gap: .65rem; color: var(--text); min-width: 0; margin-right: auto; }
.portal-brand strong { display: block; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-brand small { color: var(--muted); font-size: .72rem; }
.portal-brand .brand-mark { color: #fff; }
.portal-nav { display: flex; gap: .25rem; }
.portal-nav a { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .8rem; border-radius: 9px; color: var(--muted); font-weight: 550; min-height: 40px; }
.portal-nav a:hover { background: var(--primary-soft); color: var(--primary); }
.portal-nav a.active { background: var(--primary-soft); color: var(--primary); }
.portal-main { max-width: 1040px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.portal-foot { max-width: 1040px; margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .78rem; text-align: center; }
.portal-hero { background: linear-gradient(135deg, var(--primary-soft), var(--surface)); }
.portal-bottomnav { display: none; }
a.stat-card:hover { border-color: var(--primary); }

/* ---- Print --------------------------------------------------------------------------------- */
.print-sheet { max-width: 820px; margin: 1.5rem auto; background: #fff; padding: 2rem; border: 1px solid var(--border); border-radius: var(--radius); }
.print-sheet .letterhead { display: flex; gap: 1rem; align-items: center; border-bottom: 2px solid var(--primary); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.print-sheet .letterhead img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.receipt-sheet { max-width: 420px; }
.id-card { width: 340px; height: 214px; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: #fff; display: flex; flex-direction: column; margin: 1rem auto; }
.id-card .band { background: var(--primary); color: #fff; padding: .55rem .9rem; font-weight: 650; font-size: .85rem; }
.id-card .body { display: flex; gap: .9rem; padding: .9rem; flex: 1; }
.id-card .patient-avatar { width: 76px; height: 92px; border-radius: 8px; font-size: 1.6rem; }

@media print {
    @page { margin: 12mm; }
    body { background: #fff !important; }
    .sidebar, .topbar, .sidebar-overlay, .no-print, .list-tools, .list-foot, .app-footer, .toast-stack, .btn, .nav-tabs, .alert-dismissible .btn-close { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; }
    .card, .print-sheet { box-shadow: none !important; border: 0 !important; }
    .print-sheet { margin: 0; padding: 0; max-width: none; }
    .tab-content > .tab-pane { display: block !important; opacity: 1 !important; }
    a { color: inherit !important; }
}

/* ---- Responsive ---------------------------------------------------------------------------- */
@media (max-width: 1023.98px) {
    .sidebar { transform: translateX(-100%); width: 280px; visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
    .sidebar.open { transform: translateX(0); visibility: visible; transition: transform .25s ease; box-shadow: 8px 0 32px rgba(0, 0, 0, .25); }
    .sidebar-overlay.show { display: block; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .topbar { padding: 0 1rem; }
    .content { padding: 1.15rem; }
}

@media (max-width: 991.98px) {
    .portal-nav { display: none; }
    .portal-bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; background: var(--surface); border-top: 1px solid var(--border);
        padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(16, 24, 40, .06); }
    .portal-bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; color: var(--muted); font-size: .68rem; font-weight: 550; border-radius: 10px; }
    .portal-bottomnav a i { font-size: 1.25rem; }
    .portal-bottomnav a.active { color: var(--primary); background: var(--primary-soft); }
    .portal-main { padding-bottom: 5.5rem; }
    .portal-foot { padding-bottom: 5.5rem; }
}

@media (max-width: 767.98px) {
    body { font-size: .95rem; }
    .content { padding: .9rem; }
    .clock { display: none; }
    .topbar h1 { font-size: 1rem; }
    .page-head h2 { font-size: 1.2rem; }
    .btn, .form-control, .form-select { min-height: 44px; }
    .btn-sm { min-height: 40px; padding: .3rem .8rem; }
    .stat-value { font-size: 1.3rem; }
    .list-tools .form-select, .list-tools .form-control, .list-tools .btn { width: 100%; }
    .list-tools > form, .list-tools .search { width: 100%; flex-basis: 100%; }
    .detail-list { grid-template-columns: 1fr; gap: .1rem; }
    .detail-list dt { margin-top: .6rem; }
    .table-modern td, .table-modern th { padding: .65rem .75rem; }
    .print-sheet { padding: 1rem; margin: 0; border-radius: 0; }
    .login-wrap { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .login-box .brand-mark { display: grid; margin-bottom: 1rem; }
    .toast-stack { top: 68px; left: 1rem; right: 1rem; max-width: none; }
    .modal-dialog { margin: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
