/* ==========================================================================
   HatirlApp design system  (assets/css/app.css)
   Loaded AFTER Bootstrap 5.3 and legacy style.css. See docs/UI.md.
   1. Tokens   2. Base   3. Bootstrap overrides   4. App shell   5. Components
   6. Guest / public layouts   7. Dark theme extras   8. Utilities / print
   ========================================================================== */

/* 1. TOKENS ---------------------------------------------------------------- */
:root {
    /* brand (derived from assets/img/logo.svg: #4F8EF7 / #2563EB / #1A3FAA) */
    --brand-50: #eff6ff;
    --brand-100: #dbeafe;
    --brand-200: #bfdbfe;
    --brand-300: #93c5fd;
    --brand-400: #4f8ef7;
    --brand-500: #3b74f0;
    --brand-600: #2563eb;
    --brand-700: #1d4ed8;
    --brand-800: #1a3faa;
    --brand-900: #172f7a;
    --brand: var(--brand-600);
    --brand-hover: var(--brand-700);
    --brand-soft: var(--brand-50);
    --brand-soft-text: var(--brand-700);

    /* neutrals */
    --gray-25: #fcfcfd;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* semantic */
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --info: #0369a1;
    --info-soft: #e0f2fe;

    /* surfaces (theme aware) */
    --app-bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-hover: #f1f5f9;
    --border: #e5e9f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #5b6b82;
    --text-faint: #8492a6;

    /* sidebar (always dark navy, both themes) */
    --sb-bg: #0f1b3d;
    --sb-bg-2: #142350;
    --sb-text: #b6c2df;
    --sb-text-strong: #ffffff;
    --sb-hover: rgba(255, 255, 255, .07);
    --sb-active-bg: rgba(79, 142, 247, .22);
    --sb-active-text: #ffffff;
    --sb-border: rgba(255, 255, 255, .09);
    --sb-label: #7f8fb5;

    /* shape, depth, spacing, type */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, .1), 0 2px 6px -2px rgba(15, 23, 42, .06);
    --shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, .25);
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, .35);
    --space-1: .25rem; --space-2: .5rem; --space-3: 1rem; --space-4: 1.5rem; --space-5: 2rem; --space-6: 3rem;
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    --fs-xs: .75rem; --fs-sm: .8125rem; --fs-base: .9375rem; --fs-lg: 1.0625rem; --fs-xl: 1.25rem; --fs-2xl: 1.5rem; --fs-3xl: 1.875rem;

    /* layout */
    --sidebar-w: 264px;
    --sidebar-w-rail: 72px;
    --topbar-h: 60px;
    --content-max: 1480px;

    /* Bootstrap bridge */
    --bs-primary: var(--brand-600);
    --bs-primary-rgb: 37, 99, 235;
    --bs-link-color: var(--brand-600);
    --bs-link-color-rgb: 37, 99, 235;
    --bs-link-hover-color: var(--brand-800);
    --bs-body-font-family: var(--font-sans);
    --bs-body-font-size: var(--fs-base);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--app-bg);
    --bs-border-color: var(--border);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
    --bs-border-radius-xl: var(--radius-lg);
    --bs-secondary-color: var(--text-muted);
    --bs-emphasis-color: var(--text);
    --bs-success: #16a34a; --bs-success-rgb: 22, 163, 74;
    --bs-danger: #dc2626; --bs-danger-rgb: 220, 38, 38;
    --bs-warning: #f59e0b; --bs-warning-rgb: 245, 158, 11;
    --bs-info: #0284c7; --bs-info-rgb: 2, 132, 199;
    color-scheme: light;
}

html[data-theme="dark"] {
    --app-bg: #0b1220;
    --surface: #111a2e;
    --surface-2: #16213a;
    --surface-hover: #1b2846;
    --border: #22304d;
    --border-strong: #33456b;
    --text: #e6ebf5;
    --text-muted: #9aa8c2;
    --text-faint: #7686a3;
    --brand: #5b9bff;
    --brand-hover: #82b4ff;
    --brand-soft: rgba(91, 155, 255, .14);
    --brand-soft-text: #9cc2ff;
    --success: #4ade80; --success-soft: rgba(74, 222, 128, .14);
    --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .14);
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, .15);
    --info: #38bdf8; --info-soft: rgba(56, 189, 248, .14);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, .55);
    --shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, .7);
    --focus-ring: 0 0 0 3px rgba(91, 155, 255, .45);
    --sb-bg: #0a1226;
    --sb-bg-2: #0e1934;
    --bs-link-color: #7fb0ff; --bs-link-color-rgb: 127, 176, 255;
    --bs-link-hover-color: #a9caff;
    --bs-body-color: var(--text);
    --bs-body-bg: var(--app-bg);
    --bs-border-color: var(--border);
    --bs-secondary-color: var(--text-muted);
    color-scheme: dark;
}

/* 2. BASE ------------------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    background: var(--app-bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 650; letter-spacing: -.01em; }
h1, .h1 { font-size: var(--fs-3xl); } h2, .h2 { font-size: var(--fs-2xl); } h3, .h3 { font-size: 1.3rem; }
h4, .h4 { font-size: var(--fs-xl); } h5, .h5 { font-size: var(--fs-lg); } h6, .h6 { font-size: var(--fs-base); }
a { text-underline-offset: 2px; }
.text-muted, .form-text { color: var(--text-muted) !important; }
hr { border-color: var(--border); opacity: 1; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus, .page-link:focus { outline: none; box-shadow: var(--focus-ring) !important; }
::selection { background: var(--brand-200); color: var(--gray-900); }
.tabular, .tabular-nums { font-variant-numeric: tabular-nums; }
.visually-hidden-focusable:focus { z-index: 2000; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 3000; background: var(--brand); color: #fff; padding: .5rem 1rem; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; color: #fff; }

/* 3. BOOTSTRAP OVERRIDES --------------------------------------------------- */
/* cards */
.card {
    --bs-card-bg: var(--surface);
    --bs-card-border-color: var(--border);
    --bs-card-border-radius: var(--radius-lg);
    --bs-card-inner-border-radius: calc(var(--radius-lg) - 1px);
    --bs-card-cap-bg: var(--surface);
    --bs-card-cap-padding-y: .9rem;
    --bs-card-spacer-y: 1.1rem;
    --bs-card-spacer-x: 1.25rem;
    --bs-card-color: var(--text);
    box-shadow: var(--shadow-xs);
}
.card.shadow-sm, .card.shadow { box-shadow: var(--shadow-sm) !important; }
.card.border-0 { border: 1px solid var(--border) !important; }
.card-header { font-weight: 600; border-bottom-color: var(--border); }
.card-footer { background: var(--surface-2); border-top-color: var(--border); }
.card-header.bg-white, .card-footer.bg-white { background: var(--surface) !important; }

/* buttons */
.btn { --bs-btn-border-radius: var(--radius-sm); --bs-btn-font-weight: 550; --bs-btn-padding-x: .95rem; --bs-btn-padding-y: .45rem; font-size: var(--fs-base); transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn-sm { --bs-btn-padding-x: .65rem; --bs-btn-padding-y: .28rem; --bs-btn-font-size: var(--fs-sm); }
.btn-lg { --bs-btn-padding-y: .65rem; --bs-btn-font-size: 1.05rem; }
.btn-primary { --bs-btn-bg: var(--brand-600); --bs-btn-border-color: var(--brand-600); --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700); --bs-btn-active-bg: var(--brand-800); --bs-btn-active-border-color: var(--brand-800); --bs-btn-disabled-bg: var(--brand-600); --bs-btn-disabled-border-color: var(--brand-600); --bs-btn-focus-shadow-rgb: 37, 99, 235; }
.btn-outline-primary { --bs-btn-color: var(--brand-600); --bs-btn-border-color: var(--brand-600); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-active-bg: var(--brand-700); --bs-btn-active-border-color: var(--brand-700); }
.btn-success { --bs-btn-bg: #16a34a; --bs-btn-border-color: #16a34a; --bs-btn-hover-bg: #15803d; --bs-btn-hover-border-color: #15803d; --bs-btn-active-bg: #166534; --bs-btn-active-border-color: #166534; }
.btn-outline-success { --bs-btn-color: #15803d; --bs-btn-border-color: #16a34a; --bs-btn-hover-bg: #16a34a; --bs-btn-hover-border-color: #16a34a; }
.btn-danger { --bs-btn-bg: #dc2626; --bs-btn-border-color: #dc2626; --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c; }
.btn-outline-danger { --bs-btn-color: #dc2626; --bs-btn-border-color: #dc2626; --bs-btn-hover-bg: #dc2626; --bs-btn-hover-border-color: #dc2626; }
.btn-warning { --bs-btn-bg: #f59e0b; --bs-btn-border-color: #f59e0b; --bs-btn-color: #1f2937; --bs-btn-hover-bg: #d97706; --bs-btn-hover-border-color: #d97706; --bs-btn-hover-color: #fff; }
.btn-light { --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--border-strong); --bs-btn-color: var(--text); --bs-btn-hover-bg: var(--surface-hover); --bs-btn-hover-border-color: var(--border-strong); --bs-btn-hover-color: var(--text); }
.btn-outline-secondary { --bs-btn-color: var(--gray-600); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-bg: var(--surface-hover); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border-strong); --bs-btn-active-bg: var(--surface-hover); --bs-btn-active-color: var(--text); }
html[data-theme="dark"] .btn-outline-secondary { --bs-btn-color: var(--text-muted); }
html[data-theme="dark"] .btn-outline-primary { --bs-btn-color: #7fb0ff; }
html[data-theme="dark"] .btn-outline-danger { --bs-btn-color: #f87171; }
html[data-theme="dark"] .btn-outline-success { --bs-btn-color: #4ade80; }
html[data-theme="dark"] .btn-outline-primary:hover, html[data-theme="dark"] .btn-outline-danger:hover, html[data-theme="dark"] .btn-outline-success:hover { color: #fff; }
.btn-link { --bs-btn-color: var(--brand); }

/* forms */
.form-control, .form-select {
    --bs-border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
    font-size: var(--fs-base);
    padding: .5rem .75rem;
}
.form-control-sm, .form-select-sm { font-size: var(--fs-sm); padding: .3rem .6rem; }
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus, .form-select:focus { border-color: var(--brand-400); background-color: var(--surface); color: var(--text); }
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: var(--surface-2); opacity: 1; color: var(--text-muted); }
.form-label { font-weight: 550; font-size: var(--fs-sm); color: var(--text); margin-bottom: .35rem; }
.form-check-input { border-color: var(--border-strong); background-color: var(--surface); }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-muted); border-radius: var(--radius-sm); }
.invalid-feedback { font-size: var(--fs-sm); }

/* tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--surface-2);
    --bs-table-hover-bg: var(--surface-hover);
    --bs-table-hover-color: var(--text);
    font-size: var(--fs-sm);
    margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: .7rem .9rem; }
.table > thead > tr > th, .table thead th {
    font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 650;
    color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-light, .table > thead.table-light > tr > th, thead.table-light th { --bs-table-bg: var(--surface-2); --bs-table-color: var(--text-muted); background: var(--surface-2); color: var(--text-muted); }
.table-dark { --bs-table-bg: var(--gray-800); }
.table-responsive { border-radius: inherit; }
.card > .table-responsive:first-child > .table thead th:first-child { border-top-left-radius: var(--radius-lg); }
.card > .table-responsive:first-child > .table thead th:last-child { border-top-right-radius: var(--radius-lg); }

/* badges */
.badge { font-weight: 600; letter-spacing: .01em; border-radius: 999px; padding: .38em .7em; font-size: .72rem; }
.badge.bg-success { background-color: var(--success-soft) !important; color: var(--success) !important; }
.badge.bg-danger { background-color: var(--danger-soft) !important; color: var(--danger) !important; }
.badge.bg-warning { background-color: var(--warning-soft) !important; color: var(--warning) !important; }
.badge.bg-info { background-color: var(--info-soft) !important; color: var(--info) !important; }
.badge.bg-primary { background-color: var(--brand-soft) !important; color: var(--brand-soft-text) !important; }
.badge.bg-secondary, .badge.bg-light { background-color: var(--surface-hover) !important; color: var(--text-muted) !important; border: 1px solid var(--border); }
.badge.bg-dark { background-color: var(--gray-800) !important; color: #fff !important; }
.badge.text-dark { color: inherit !important; }
.badge.bg-warning.text-dark { color: var(--warning) !important; }
.badge.rounded-pill { padding-inline: .8em; }

/* alerts */
.alert { border-radius: var(--radius); border-width: 1px; font-size: var(--fs-base); padding: .8rem 1rem; box-shadow: none; }
.alert-success { --bs-alert-bg: var(--success-soft); --bs-alert-color: var(--success); --bs-alert-border-color: transparent; border-left: 4px solid #16a34a; }
.alert-danger { --bs-alert-bg: var(--danger-soft); --bs-alert-color: var(--danger); --bs-alert-border-color: transparent; border-left: 4px solid #dc2626; }
.alert-warning { --bs-alert-bg: var(--warning-soft); --bs-alert-color: var(--warning); --bs-alert-border-color: transparent; border-left: 4px solid #f59e0b; }
.alert-info { --bs-alert-bg: var(--info-soft); --bs-alert-color: var(--info); --bs-alert-border-color: transparent; border-left: 4px solid #0284c7; }
.alert-primary { --bs-alert-bg: var(--brand-soft); --bs-alert-color: var(--brand-soft-text); --bs-alert-border-color: transparent; border-left: 4px solid var(--brand-600); }
.alert-secondary, .alert-light { --bs-alert-bg: var(--surface-2); --bs-alert-color: var(--text); --bs-alert-border-color: var(--border); }
.alert a { font-weight: 600; }
.alert-danger ul { padding-left: 1.1rem; }

/* modals / dropdowns / offcanvas / tooltips */
.modal-content { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-size: var(--fs-lg); font-weight: 650; }
.modal-backdrop.show { opacity: .5; }
.dropdown-menu { --bs-dropdown-bg: var(--surface); --bs-dropdown-border-color: var(--border); --bs-dropdown-link-color: var(--text); --bs-dropdown-link-hover-bg: var(--surface-hover); --bs-dropdown-link-hover-color: var(--text); --bs-dropdown-link-active-bg: var(--brand-600); --bs-dropdown-divider-bg: var(--border); --bs-dropdown-border-radius: var(--radius); --bs-dropdown-item-padding-y: .5rem; --bs-dropdown-item-padding-x: .9rem; box-shadow: var(--shadow-md); font-size: var(--fs-sm); padding: .35rem; }
.dropdown-item { border-radius: var(--radius-sm); }
.dropdown-item i { width: 1.25rem; color: var(--text-muted); }
.dropdown-item.text-danger i { color: inherit; }

/* nav tabs / pills / list-group */
.nav-tabs { --bs-nav-tabs-border-color: var(--border); --bs-nav-tabs-link-active-bg: transparent; --bs-nav-tabs-link-active-border-color: transparent transparent var(--brand-600); --bs-nav-tabs-link-hover-border-color: transparent; border-bottom: 1px solid var(--border); gap: .25rem; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--text-muted); font-weight: 550; padding: .65rem .95rem; white-space: nowrap; margin-bottom: -1px; }
.nav-tabs .nav-link:hover { color: var(--text); border-color: var(--border-strong); }
.nav-tabs .nav-link.active { color: var(--brand); background: transparent; border-color: var(--brand-600); }
.nav-pills .nav-link { border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 550; }
.nav-pills .nav-link.active { background: var(--brand-600); color: #fff; }
.list-group { --bs-list-group-bg: var(--surface); --bs-list-group-color: var(--text); --bs-list-group-border-color: var(--border); --bs-list-group-action-hover-bg: var(--surface-hover); --bs-list-group-action-hover-color: var(--text); --bs-list-group-active-bg: var(--brand-600); --bs-list-group-active-border-color: var(--brand-600); --bs-list-group-border-radius: var(--radius); }
.list-group-item:hover { background-color: var(--surface-hover); }
.list-group-item.active:hover { background-color: var(--brand-600); }

/* pagination */
.pagination { --bs-pagination-color: var(--text); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-hover-bg: var(--surface-hover); --bs-pagination-hover-color: var(--brand); --bs-pagination-hover-border-color: var(--border); --bs-pagination-active-bg: var(--brand-600); --bs-pagination-active-border-color: var(--brand-600); --bs-pagination-disabled-bg: var(--surface-2); --bs-pagination-disabled-color: var(--text-faint); --bs-pagination-disabled-border-color: var(--border); --bs-pagination-border-radius: var(--radius-sm); --bs-pagination-focus-color: var(--brand); --bs-pagination-focus-bg: var(--surface-hover); gap: .25rem; flex-wrap: wrap; }
.page-link { border-radius: var(--radius-sm) !important; font-size: var(--fs-sm); min-width: 2.1rem; text-align: center; }
.progress { background: var(--surface-hover); border-radius: 999px; }
.accordion { --bs-accordion-bg: var(--surface); --bs-accordion-border-color: var(--border); --bs-accordion-color: var(--text); --bs-accordion-active-bg: var(--brand-soft); --bs-accordion-active-color: var(--brand-soft-text); --bs-accordion-btn-bg: var(--surface); --bs-accordion-btn-color: var(--text); }
.toast { --bs-toast-bg: var(--surface); --bs-toast-color: var(--text); --bs-toast-border-color: var(--border); }
.bg-light, .bg-white { background-color: var(--surface) !important; }
.bg-light { background-color: var(--surface-2) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--border) !important; }
.text-dark { color: var(--text) !important; }
.text-secondary { color: var(--text-muted) !important; }
.text-primary { color: var(--brand) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.link-primary { color: var(--brand) !important; }
code { color: var(--brand-800); background: var(--brand-soft); padding: .1em .35em; border-radius: 4px; font-size: .85em; }
html[data-theme="dark"] code { color: #9cc2ff; }
pre code { background: transparent; padding: 0; }
.swal2-popup { border-radius: var(--radius-lg) !important; font-family: var(--font-sans) !important; }
.swal2-styled.swal2-confirm { border-radius: var(--radius-sm) !important; }
.swal2-styled.swal2-cancel { border-radius: var(--radius-sm) !important; }
.iti { width: 100%; }
.iti__selected-dial-code { font-size: .875rem; }
html[data-theme="dark"] .swal2-popup { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .swal2-title, html[data-theme="dark"] .swal2-html-container { color: var(--text); }
html[data-theme="dark"] .iti__country-list { background: var(--surface); color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .iti__country.iti__highlight { background: var(--surface-hover); }
html[data-theme="dark"] .iti__dial-code { color: var(--text-muted); }

/* 4. APP SHELL ------------------------------------------------------------- */
.app-shell { min-height: 100vh; }

/* sidebar */
.app-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--sb-bg) 0%, var(--sb-bg-2) 100%);
    color: var(--sb-text);
    border-right: 1px solid var(--sb-border);
    transition: width .2s ease, transform .25s ease;
}
.sb-brand { display: flex; align-items: center; gap: .65rem; height: var(--topbar-h); padding: 0 1rem; border-bottom: 1px solid var(--sb-border); flex-shrink: 0; }
.sb-brand-link { display: flex; align-items: center; gap: .65rem; color: var(--sb-text-strong); text-decoration: none; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; min-width: 0; flex: 1; }
.sb-brand-link:hover { color: #fff; }
.sb-brand-link img { width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; }
.sb-brand-name { white-space: nowrap; overflow: hidden; }
.sb-pro { font-size: .58rem; font-weight: 700; letter-spacing: .06em; background: var(--brand-400); color: #0b1b45; padding: .15rem .4rem; border-radius: 4px; margin-left: .35rem; vertical-align: middle; }
.sb-close { display: none; background: none; border: 0; color: var(--sb-text); font-size: 1.1rem; width: 36px; height: 36px; border-radius: 8px; }
.sb-close:hover { background: var(--sb-hover); color: #fff; }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: .6rem .65rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.sb-group { margin-bottom: .35rem; }
.sb-label { font-size: .66rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--sb-label); padding: .85rem .75rem .35rem; white-space: nowrap; }
.sb-link {
    display: flex; align-items: center; gap: .8rem;
    padding: .55rem .75rem; margin: 1px 0;
    color: var(--sb-text); text-decoration: none; border-radius: 9px;
    font-size: .9rem; font-weight: 520; line-height: 1.25;
    position: relative; transition: background-color .12s, color .12s;
    white-space: nowrap;
}
.sb-link i { width: 1.2rem; text-align: center; font-size: .95rem; flex-shrink: 0; opacity: .9; }
.sb-link .sb-text { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.sb-link:hover { background: var(--sb-hover); color: #fff; }
.sb-link:focus-visible { outline: 2px solid var(--brand-300); outline-offset: -2px; }
.sb-link.active { background: var(--sb-active-bg); color: var(--sb-active-text); font-weight: 620; }
.sb-link.active::before { content: ''; position: absolute; left: -.65rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-400); }
.sb-link.active i { color: var(--brand-300); opacity: 1; }
.sb-badge { background: #f59e0b; color: #1f1300; font-size: .66rem; font-weight: 700; border-radius: 999px; padding: .1rem .45rem; flex-shrink: 0; }

.sb-admin { margin-top: .5rem; border-top: 1px solid var(--sb-border); padding-top: .35rem; }
.sb-toggle { width: 100%; background: none; border: 0; text-align: left; }
.sb-toggle .sb-chevron { margin-left: auto; font-size: .7rem; width: auto; transition: transform .2s; opacity: .7; }
.sb-toggle[aria-expanded="true"] .sb-chevron { transform: rotate(180deg); }
.sb-toggle i.sb-crown { color: #fbbf24; }
.sb-sub { display: none; padding-left: .25rem; }
.sb-sub.is-open { display: block; }
.sb-sub .sb-label { padding-top: .6rem; padding-left: .6rem; }
.sb-sub .sb-link { padding-top: .45rem; padding-bottom: .45rem; font-size: .86rem; }

.sb-footer { flex-shrink: 0; padding: .75rem; border-top: 1px solid var(--sb-border); display: flex; flex-direction: column; gap: .65rem; }
.sb-credit { background: rgba(255,255,255,.06); border: 1px solid var(--sb-border); border-radius: 12px; padding: .8rem .85rem; }
.sb-credit-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sb-credit-k { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--sb-label); font-weight: 650; }
.sb-credit-v { font-size: 1.55rem; font-weight: 750; color: #fff; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sb-credit-v small { font-size: .72rem; font-weight: 500; color: var(--sb-text); margin-left: .25rem; }
.sb-credit-coin { width: 34px; height: 34px; border-radius: 10px; background: rgba(251,191,36,.16); color: #fbbf24; display: grid; place-items: center; }
.sb-credit-sub { font-size: .75rem; color: var(--sb-text); margin: .5rem 0 .65rem; display: flex; align-items: center; gap: .4rem; }
.sb-credit-sub.soon { color: #fcd34d; } .sb-credit-sub.expired { color: #fca5a5; }
.sb-credit .btn { width: 100%; --bs-btn-padding-y: .4rem; background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.sb-credit .btn:hover { background: var(--brand-400); border-color: var(--brand-400); }
.sb-credit-mini { display: none; }
.sb-user { display: flex; align-items: center; gap: .7rem; padding: .35rem .25rem; min-width: 0; }
.sb-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-400), var(--brand-800)); color: #fff; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; font-size: .85rem; }
.sb-user-meta { min-width: 0; flex: 1; line-height: 1.25; }
.sb-user-name { color: #fff; font-size: .85rem; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-role { color: var(--sb-label); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-logout { background: none; border: 0; color: var(--sb-text); width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; }
.sb-logout:hover { background: rgba(248,113,113,.18); color: #fecaca; }

/* main column */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; min-width: 0; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020; height: var(--topbar-h);
    display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}
.tb-btn { width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text-muted); display: inline-grid; place-items: center; flex-shrink: 0; }
.tb-btn:hover { background: var(--surface-hover); color: var(--text); }
.tb-hamburger { display: none; }
.tb-title { font-size: 1.1rem; font-weight: 650; margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.tb-slot { display: flex; align-items: center; gap: .5rem; }
.tb-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .75rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-soft-text); font-weight: 650; font-size: var(--fs-sm); text-decoration: none; white-space: nowrap; border: 1px solid transparent; }
.tb-chip:hover { border-color: var(--brand-300); color: var(--brand-soft-text); }
.tb-chip i { color: #d97706; }
.tb-chip.low { background: var(--danger-soft); color: var(--danger); } .tb-chip.low i { color: var(--danger); }
.tb-user { display: inline-flex; align-items: center; gap: .55rem; padding: .2rem .55rem .2rem .25rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: var(--fs-sm); font-weight: 600; }
.tb-user:hover, .tb-user.show { background: var(--surface-hover); }
.tb-user .sb-avatar { width: 28px; height: 28px; font-size: .72rem; }
.tb-user .tb-uname { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-toggle .fa-sun { display: none; }
html[data-theme="dark"] .theme-toggle .fa-moon { display: none; }
html[data-theme="dark"] .theme-toggle .fa-sun { display: inline; }

.impersonate-bar { background: #fef3c7; color: #78350f; border-bottom: 1px solid #fcd34d; padding: .5rem 1.5rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; font-size: var(--fs-sm); font-weight: 550; }
.impersonate-bar .btn { margin-left: auto; }
html[data-theme="dark"] .impersonate-bar { background: #3b2a06; color: #fde68a; border-color: #7c5a10; }

.app-content { flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 1.5rem 1.5rem 2rem; min-width: 0; }
/* legacy pages wrap their body in .container: neutralise so it fills the shell */
.app-content .container, .app-content .container-fluid, .app-content .container-lg, .app-content .container-xl { max-width: none; padding-left: 0; padding-right: 0; }
.app-content > .alert:first-child { margin-top: 0; }
.app-footer { padding: 1rem 1.5rem 1.5rem; text-align: center; color: var(--text-faint); font-size: var(--fs-xs); }
.app-footer a { color: var(--text-muted); text-decoration: none; margin: 0 .4rem; } .app-footer a:hover { color: var(--brand); text-decoration: underline; }
.sb-overlay { display: none; position: fixed; inset: 0; z-index: 1035; background: rgba(8, 15, 35, .55); opacity: 0; transition: opacity .2s; }

/* fullbleed layout mode: @section('layout','fullbleed') — page fills the viewport, only inner panes scroll (docs/UI.md) */
body.app-fullbleed { --topbar-h: 48px; overflow: hidden; height: 100vh; height: 100dvh; }
.app-fullbleed .app-shell { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.app-fullbleed .app-main { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.app-fullbleed .app-topbar { position: relative; flex: 0 0 auto; padding: 0 1rem; }
.app-fullbleed .tb-title { font-size: 1rem; }
.app-fullbleed .impersonate-bar { flex: 0 0 auto; padding: .3rem 1rem; }
.app-fullbleed .app-content { flex: 1 1 auto; min-height: 0; max-width: none; margin: 0; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.app-fullbleed .app-content > .alert { margin: .5rem; flex: 0 0 auto; }

/* collapsed icon rail (desktop) */
@media (min-width: 992px) {
    html[data-sidebar="collapsed"] { --sidebar-w: var(--sidebar-w-rail); }
    html[data-sidebar="collapsed"] .sb-brand { justify-content: center; padding: 0; }
    html[data-sidebar="collapsed"] .sb-brand-name, html[data-sidebar="collapsed"] .sb-text, html[data-sidebar="collapsed"] .sb-chevron,
    html[data-sidebar="collapsed"] .sb-badge, html[data-sidebar="collapsed"] .sb-credit, html[data-sidebar="collapsed"] .sb-user-meta,
    html[data-sidebar="collapsed"] .sb-sub .sb-label { display: none; }
    html[data-sidebar="collapsed"] .sb-brand-link { flex: 0; }
    html[data-sidebar="collapsed"] .sb-label { height: 1px; background: var(--sb-border); margin: .6rem .5rem; padding: 0; font-size: 0; }
    html[data-sidebar="collapsed"] .sb-link { justify-content: center; padding: .65rem 0; }
    html[data-sidebar="collapsed"] .sb-link.active::before { left: -.65rem; }
    html[data-sidebar="collapsed"] .sb-sub { display: block; padding-left: 0; }
    html[data-sidebar="collapsed"] .sb-sub .sb-label { display: block; }
    html[data-sidebar="collapsed"] .sb-toggle { display: none; }
    html[data-sidebar="collapsed"] .sb-credit-mini { display: grid; place-items: center; height: 42px; border-radius: 10px; background: rgba(251,191,36,.14); color: #fbbf24; text-decoration: none; position: relative; }
    html[data-sidebar="collapsed"] .sb-credit-mini b { position: absolute; bottom: -2px; right: 2px; font-size: .6rem; background: #0f1b3d; color: #fff; border-radius: 6px; padding: 0 .3rem; border: 1px solid var(--sb-border); }
    html[data-sidebar="collapsed"] .sb-user { justify-content: center; padding: 0; }
    html[data-sidebar="collapsed"] .sb-logout { display: none; }
    html[data-sidebar="collapsed"] .sb-user form { display: none; }
}
/* tooltips for rail come from title attr (native). */

/* mobile off-canvas */
@media (max-width: 991.98px) {
    :root { --sidebar-w: 288px; }
    .app-sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); }
    html.sidebar-open .app-sidebar { transform: none; }
    html.sidebar-open .sb-overlay { display: block; opacity: 1; }
    html.sidebar-open body { overflow: hidden; }
    .app-main { margin-left: 0 !important; }
    .sb-close { display: inline-grid; place-items: center; }
    .tb-hamburger { display: inline-grid; }
    .tb-collapse { display: none; }
    .app-topbar { padding: 0 .75rem; gap: .5rem; }
    .app-content { padding: 1rem .875rem 1.5rem; }
    .impersonate-bar { padding: .5rem .875rem; }
}
@media (max-width: 575.98px) {
    .tb-user .tb-uname, .tb-chip .tb-chip-label { display: none; }
    .tb-title { font-size: 1rem; }
    .tb-slot:empty { display: none; }
    .tb-slot .btn .btn-label { display: none; }
}
@media (prefers-reduced-motion: reduce) { .app-sidebar, .app-main, .sb-overlay, .sb-link { transition: none; } }
@media (min-width: 992px) { html.sb-preload .app-sidebar, html.sb-preload .app-main { transition: none; } }

/* 5. COMPONENTS ------------------------------------------------------------ */
/* page-header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header-title { font-size: var(--fs-2xl); font-weight: 700; margin: 0; display: flex; align-items: center; gap: .6rem; }
.page-header-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 1.05rem; flex-shrink: 0; }
.page-header-sub { color: var(--text-muted); margin: .25rem 0 0; font-size: var(--fs-base); }
.page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.page-header .breadcrumb { margin: 0 0 .35rem; font-size: var(--fs-sm); }

/* stat-card */
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.15rem; box-shadow: var(--shadow-xs); display: flex; align-items: center; gap: .9rem; height: 100%; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s, border-color .15s; }
a.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--border-strong); color: inherit; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }
.stat-icon.primary { background: var(--brand-soft); color: var(--brand); }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-icon.secondary { background: var(--surface-hover); color: var(--text-muted); }
.stat-body { min-width: 0; flex: 1; }
.stat-label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { overflow-wrap: anywhere; font-size: 1.65rem; font-weight: 750; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-trend { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.stat-trend.up { color: var(--success); } .stat-trend.down { color: var(--danger); }
/* tinted stat cards (project-wide, 2026-10-09): soft colour wash from the card's `color`, icon as a faint corner watermark */
.stat-card { --c: var(--brand); position: relative; overflow: hidden; background: color-mix(in srgb, var(--c) 11%, var(--surface)); border-color: color-mix(in srgb, var(--c) 28%, var(--border)); }
.stat-card.c-primary { --c: var(--brand); } .stat-card.c-info { --c: var(--info); } .stat-card.c-success { --c: var(--success); }
.stat-card.c-warning { --c: var(--warning); } .stat-card.c-danger { --c: var(--danger); } .stat-card.c-secondary { --c: #7c5cd6; }
.stat-card .stat-icon { position: absolute; right: -.35rem; top: -.35rem; width: auto; height: auto; background: none; display: block; font-size: 4.4rem; line-height: 1; color: var(--c); opacity: .16; transform: rotate(-12deg); pointer-events: none; }
.stat-card .stat-body { position: relative; z-index: 1; }
.stat-card .stat-label { color: color-mix(in srgb, var(--c) 70%, var(--text-muted)); }
.stat-card .stat-value { overflow-wrap: anywhere; }

/* card component */
.ui-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden; }
.ui-card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ui-card-title { font-size: var(--fs-lg); font-weight: 650; margin: 0; display: flex; align-items: center; gap: .55rem; }
.ui-card-title i { color: var(--brand); }
.ui-card-body { padding: 1.25rem; }
.ui-card-body.flush { padding: 0; }
.ui-card-foot { padding: .75rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); }

/* empty-state */
.empty-state { text-align: center; padding: 2.5rem 1.25rem; color: var(--text-muted); }
.empty-state-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--surface-hover); color: var(--text-faint); display: grid; place-items: center; font-size: 1.6rem; margin: 0 auto 1rem; }
.empty-state h3 { font-size: var(--fs-lg); margin-bottom: .35rem; }
.empty-state p { max-width: 420px; margin: 0 auto 1rem; }

/* status-badge */
.status-badge { display: inline-flex; align-items: center; gap: .4rem; padding: .28rem .65rem; border-radius: 999px; font-size: .72rem; font-weight: 650; line-height: 1.2; white-space: nowrap; }
.status-badge i { font-size: .68rem; }
.status-badge.success { background: var(--success-soft); color: var(--success); }
.status-badge.warning { background: var(--warning-soft); color: var(--warning); }
.status-badge.danger { background: var(--danger-soft); color: var(--danger); }
.status-badge.info { background: var(--info-soft); color: var(--info); }
.status-badge.primary { background: var(--brand-soft); color: var(--brand-soft-text); }
.status-badge.secondary { background: var(--surface-hover); color: var(--text-muted); }
.status-badge .fa-spinner { animation: fa-spin 1.5s linear infinite; }

/* filter-bar */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 1rem; box-shadow: var(--shadow-xs); }
.filter-bar .filter-field { display: flex; flex-direction: column; gap: .25rem; min-width: 150px; flex: 0 1 auto; }
.filter-bar .filter-field label { font-size: var(--fs-xs); font-weight: 650; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.filter-bar .filter-grow { flex: 1 1 240px; }
.filter-bar .filter-actions { display: flex; gap: .5rem; margin-left: auto; }
@media (max-width: 575.98px) { .filter-bar .filter-field { flex: 1 1 100%; } .filter-bar .filter-actions { width: 100%; } .filter-bar .filter-actions .btn { flex: 1; } }

/* data-table wrapper */
.data-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden; }
.data-table-scroll { overflow: auto; max-height: var(--dt-max-h, none); -webkit-overflow-scrolling: touch; }
.data-table.sticky .data-table-scroll { --dt-max-h: 70vh; }
.data-table.sticky thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--border); }
.data-table-head { padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.data-table-foot { padding: .7rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-muted); }
.data-table .table tbody tr:last-child td { border-bottom: 0; }
.data-table.compact .table > :not(caption) > * > * { padding: .5rem .75rem; }

/* misc helpers used by components */
.avatar-circle { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.section-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 700; margin: 1.5rem 0 .6rem; }

/* 6. GUEST / PUBLIC LAYOUTS ------------------------------------------------ */
.guest-body { background: var(--surface); }
.guest-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.guest-form-side { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 2.5rem 1.5rem; background: var(--surface); }
.guest-form-inner { width: 100%; max-width: 420px; }
.guest-logo { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; margin-bottom: 2rem; }
.guest-logo img { width: 44px; height: 44px; }
.guest-logo span { font-size: 1.45rem; font-weight: 750; color: var(--brand-800); letter-spacing: -.02em; }
html[data-theme="dark"] .guest-logo span { color: #cfe0ff; }
.guest-title { font-size: 1.6rem; font-weight: 750; margin-bottom: .35rem; }
.guest-sub { color: var(--text-muted); margin-bottom: 1.5rem; }
.guest-brand-side { position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center; background: radial-gradient(1200px 600px at 100% 0%, rgba(79,142,247,.55), transparent 60%), linear-gradient(140deg, var(--brand-800) 0%, #0f1b3d 100%); }
.guest-brand-side::after { content: ''; position: absolute; width: 520px; height: 520px; right: -160px; bottom: -200px; border-radius: 50%; background: rgba(255,255,255,.05); }
.guest-brand-inner { position: relative; z-index: 1; max-width: 520px; }
.guest-brand-side h2 { color: #fff; font-size: 2rem; font-weight: 750; line-height: 1.2; margin-bottom: 1rem; }
.guest-brand-side p { color: #cfdcf7; font-size: 1.05rem; }
.guest-feature { display: flex; gap: .85rem; align-items: flex-start; margin-top: 1.25rem; color: #e3ecff; }
.guest-feature i { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.12); display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.guest-feature b { display: block; color: #fff; }
.guest-feature span { font-size: var(--fs-sm); color: #b9caee; }
.guest-foot { margin-top: 2rem; font-size: var(--fs-xs); color: var(--text-faint); text-align: center; }
.guest-foot a { color: var(--text-muted); }
.guest-foot-inner { width: 100%; max-width: 420px; }
@media (max-width: 991.98px) {
    .guest-split { grid-template-columns: 1fr; }
    .guest-brand-side { display: none; }
    .guest-form-side { min-height: 100vh; justify-content: flex-start; padding-top: 2.5rem; background: linear-gradient(180deg, var(--brand-50), var(--surface) 240px); }
    html[data-theme="dark"] .guest-form-side { background: linear-gradient(180deg, #0f1b3d, var(--surface) 240px); }
}
.guest-mobile-strip { display: none; }

/* public (patient) pages */
.public-body { background: linear-gradient(180deg, var(--brand-50) 0, var(--app-bg) 320px) no-repeat, var(--app-bg); min-height: 100vh; }
.public-wrap { max-width: 520px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.public-clinic { text-align: center; padding: .5rem 0 1.25rem; }
.public-clinic-logo { max-width: 160px; max-height: 80px; object-fit: contain; display: block; margin: 0 auto .6rem; }
.public-clinic-mark { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, var(--brand-400), var(--brand-800)); color: #fff; display: grid; place-items: center; font-size: 1.6rem; font-weight: 750; margin: 0 auto .6rem; }
.public-clinic-name { font-size: 1.15rem; font-weight: 700; margin: 0; }
.public-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); padding: 1.5rem 1.25rem; }
.public-foot { text-align: center; margin-top: 1.5rem; font-size: var(--fs-xs); color: var(--text-faint); }
.public-foot a { color: var(--text-muted); }

/* 7. LEGACY PAGE HELPERS (dark mode + inline-styled pages) ----------------- */
html[data-theme="dark"] .kpi-card, html[data-theme="dark"] .stat-box, html[data-theme="dark"] .main-card { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text); }
html[data-theme="dark"] .list-group-item:hover { background-color: var(--surface-hover); }
html[data-theme="dark"] #drResult { background: var(--surface-2); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
html[data-theme="dark"] .bg-white { background-color: var(--surface) !important; }
html[data-theme="dark"] .table-light, html[data-theme="dark"] .table-light > th, html[data-theme="dark"] .table-light > td { --bs-table-bg: var(--surface-2); --bs-table-color: var(--text-muted); }
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
html[data-theme="dark"] .form-select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239aa8c2' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }
.fc, .fc-theme-standard td, .fc-theme-standard th { border-color: var(--border); }

/* 8. UTILITIES / PRINT ----------------------------------------------------- */
.rounded-xl { border-radius: var(--radius-lg) !important; }
.shadow-soft { box-shadow: var(--shadow-sm) !important; }
.gap-y-3 { row-gap: 1rem; }
.min-w-0 { min-width: 0; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cursor-pointer { cursor: pointer; }
@media print {
    .app-sidebar, .app-topbar, .sb-overlay, .app-footer, .impersonate-bar { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { max-width: none; padding: 0; }
    body { background: #fff; }
}

/* dark-mode safety net for legacy pages that hardcode dark text colours (phase 2 removes the need) */
html[data-theme="dark"] .app-content :is(h1,h2,h3,h4,h5,h6,.fw-bold,.fw-semibold,[class*="title"],[class*="value"],[class*="-num"],[class*="heading"]):not([class*="text-"]):not(.btn):not(.badge):not(.status-badge) { color: var(--text); }
