/* =====================================================================
   M&E design system — the ONE stylesheet every page uses.
   Minimal, flat (no gradients), Poppins, one accent colour.
   Pages should use these tokens/classes instead of their own colours.
   ===================================================================== */

:root {
    /* Accent (teal) */
    --primary: #0f766e;
    --primary-hover: #115e59;
    --primary-soft: #e6f4f2;
    --primary-ink: #0b4f4a;

    /* Neutrals */
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f5;
    --border: #e4e7eb;
    --border-strong: #d0d5dc;
    --text: #111827;
    --text-2: #374151;
    --muted: #6b7280;

    /* Status (always paired with an icon or label) */
    --success: #15803d;  --success-soft: #e8f5ec;
    --warning: #b45309;  --warning-soft: #fdf3e4;
    --danger:  #b91c1c;  --danger-soft:  #fbeaea;
    --info:    #1d4ed8;  --info-soft:    #e8eefc;

    /* Chart palette — validated (CVD + contrast); use in this fixed order */
    --c1: #0d9488; --c2: #eb6834; --c3: #2a78d6; --c4: #eda100;
    --c5: #e87ba4; --c6: #6250d6; --c7: #e34948;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(17, 24, 39, .05);
    --shadow-md: 0 4px 16px rgba(17, 24, 39, .08);
    --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Bootstrap bridge: makes every stock component match */
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-success: #15803d;
    --bs-success-rgb: 21, 128, 61;
    --bs-danger: #b91c1c;
    --bs-danger-rgb: 185, 28, 28;
    --bs-warning: #b45309;
    --bs-warning-rgb: 180, 83, 9;
    --bs-info: #1d4ed8;
    --bs-info-rgb: 29, 78, 216;
    --bs-body-font-family: var(--font);
    --bs-body-color: #111827;
    --bs-body-bg: #f6f7f9;
    --bs-border-color: #e4e7eb;
    --bs-secondary-color: #6b7280;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #115e59;
    --bs-link-hover-color-rgb: 17, 94, 89;
    --bs-border-radius: 8px;
    --bs-border-radius-lg: 12px;
    --bs-focus-ring-color: rgba(15, 118, 110, .25);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 600; color: var(--text); letter-spacing: -.01em; }
h1, .h1 { font-size: 1.6rem; }
h2, .h2 { font-size: 1.3rem; }
h3, .h3 { font-size: 1.15rem; }
h4, .h4, h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: .9rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
.text-muted, .text-secondary { color: var(--muted) !important; }
.small, small { font-size: .82rem; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-soft); }
.tabular { font-variant-numeric: tabular-nums; }
.sb-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.brand-script {
    position: relative;
    font-family: 'Oleo Script', 'Pacifico', cursive;
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1;
    letter-spacing: .2px;
    white-space: nowrap;
    padding-bottom: 5px;
}

    /* swash underline */
    .brand-script::after {
        content: "";
        position: absolute;
        left: 6%;
        right: 0;
        bottom: 0;
        height: 3px;
        background: currentColor;
        border-radius: 100% 0 100% 0 / 100% 0 100% 0;
        opacity: .85;
    }
/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: .25rem 0 0; font-size: .9rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.section-title { font-size: .95rem; font-weight: 600; margin: 0 0 .75rem; }
.eyebrow { font-size: .72rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Cards ---------- */
.card, .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header, .card-footer { background: transparent; border-color: var(--border); padding: .9rem 1.25rem; }
.card-header { font-weight: 600; }
.card-body, .panel { padding: 1.25rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.panel-head h2, .panel-head h3 { font-size: .95rem; margin: 0; }
.card-link-hover { transition: border-color .15s ease, box-shadow .15s ease; }
.card-link-hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.stat .label { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.stat .label i { color: var(--primary); }
.stat .value { font-size: 1.65rem; font-weight: 600; line-height: 1.2; margin-top: .3rem; }
.stat .value small { font-size: .85rem; color: var(--muted); font-weight: 400; }
.stat .delta { font-size: .78rem; margin-top: .15rem; color: var(--muted); }
.delta-up { color: var(--success) !important; }
.delta-down { color: var(--danger) !important; }

/* ---------- Buttons ---------- */
.btn { font-weight: 500; font-size: .875rem; border-radius: var(--radius-sm); padding: .5rem 1rem; box-shadow: none !important; transition: background-color .15s, border-color .15s, color .15s; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg { padding: .7rem 1.4rem; font-size: .95rem; }
.btn-primary, .btn-modern, .btn-success {
    --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: var(--primary-hover); --bs-btn-active-border-color: var(--primary-hover);
    --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary);
    --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff;
    background: var(--bs-btn-bg); color: #fff; border: 1px solid var(--bs-btn-border-color);
}
.btn-primary:hover, .btn-modern:hover, .btn-success:hover { background: var(--primary-hover); color: #fff; }
.btn-outline-primary, .btn-light, .btn-secondary, .btn-outline-secondary, .btn-ghost {
    --bs-btn-bg: var(--surface); --bs-btn-color: var(--text-2); --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-bg: var(--surface-2); --bs-btn-active-color: var(--text); --bs-btn-active-border-color: var(--border-strong);
}
.btn-outline-primary { --bs-btn-color: var(--primary); }
.btn-danger, .btn-outline-danger {
    --bs-btn-bg: var(--surface); --bs-btn-color: var(--danger); --bs-btn-border-color: #f0c4c4;
    --bs-btn-hover-bg: var(--danger); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--danger);
    --bs-btn-active-bg: var(--danger); --bs-btn-active-color: #fff;
}
.btn-danger.solid { --bs-btn-bg: var(--danger); --bs-btn-color: #fff; --bs-btn-border-color: var(--danger); }
.btn-warning, .btn-info, .btn-dark { --bs-btn-bg: var(--text); --bs-btn-color: #fff; --bs-btn-border-color: var(--text); --bs-btn-hover-bg: #000; --bs-btn-hover-color: #fff; }
.btn-link { color: var(--primary); text-decoration: none; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }

/* ---------- Forms ---------- */
.form-label { font-size: .82rem; font-weight: 500; color: var(--text-2); margin-bottom: .35rem; }
.form-control, .form-select {
    font-size: .9rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: .55rem .8rem; background-color: var(--surface); color: var(--text);
}
.form-control::placeholder { color: #9ca3af; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .15); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(15, 118, 110, .15); border-color: var(--primary); }
.form-text { color: var(--muted); font-size: .78rem; }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: 1.25rem; }
.toolbar .form-select, .toolbar .form-control { width: auto; min-width: 160px; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; --bs-table-striped-bg: var(--surface-2); --bs-table-hover-bg: #f8fafb; font-size: .875rem; margin: 0; color: var(--text); }
.table > :not(caption) > * > * { padding: .75rem 1rem; border-bottom-color: var(--border); }
.table thead th { font-size: .75rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
.table-dark, .table-primary, .table-success, .table-light { --bs-table-bg: var(--surface-2); --bs-table-color: var(--text); }

/* ---------- Badges / chips ---------- */
.badge { font-weight: 500; font-size: .72rem; padding: .3em .65em; border-radius: 999px; }
.chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 500; padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.chip-primary, .bg-primary-soft { background: var(--primary-soft) !important; color: var(--primary-ink) !important; border-color: transparent; }
.chip-success, .bg-success, .text-bg-success { background: var(--success-soft) !important; color: var(--success) !important; border-color: transparent; }
.chip-warning, .bg-warning, .text-bg-warning { background: var(--warning-soft) !important; color: var(--warning) !important; border-color: transparent; }
.chip-danger, .bg-danger, .text-bg-danger { background: var(--danger-soft) !important; color: var(--danger) !important; border-color: transparent; }
.chip-info, .bg-info, .text-bg-info { background: var(--info-soft) !important; color: var(--info) !important; border-color: transparent; }
.bg-primary, .text-bg-primary { background: var(--primary) !important; color: #fff !important; }
.bg-secondary, .text-bg-secondary { background: var(--surface-2) !important; color: var(--text-2) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); font-size: .875rem; border: 1px solid transparent; padding: .8rem 1rem; }
.alert-success { background: var(--success-soft); color: #14532d; border-color: #cfe9d7; }
.alert-danger { background: var(--danger-soft); color: #7f1d1d; border-color: #f3cfcf; }
.alert-warning { background: var(--warning-soft); color: #78350f; border-color: #f4dfbf; }
.alert-info, .alert-primary, .alert-secondary { background: var(--info-soft); color: #1e3a8a; border-color: #d3ddf7; }

/* ---------- Nav tabs / pills ---------- */
.nav-tabs { border-bottom: 1px solid var(--border); gap: .25rem; }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--muted) !important; font-weight: 500; font-size: .875rem; padding: .6rem .9rem !important; border-radius: 0; background: none; }
.nav-tabs .nav-link:hover { color: var(--text) !important; }
.nav-tabs .nav-link.active { color: var(--primary) !important; border-bottom-color: var(--primary); background: none; }
.nav-pills .nav-link { color: var(--text-2) !important; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { background: var(--primary-soft); color: var(--primary-ink) !important; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented a, .segmented button { border: 0; background: none; font-size: .8rem; font-weight: 500; color: var(--muted); padding: .35rem .75rem; border-radius: 6px; }
.segmented .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Modals / dropdowns ---------- */
.modal-content { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.modal-header, .modal-footer { border-color: var(--border); padding: 1rem 1.25rem; }
.modal-header { background: var(--surface) !important; color: var(--text) !important; }
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-header .btn-close { filter: none !important; }
.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); padding: .35rem; font-size: .875rem; }
.dropdown-item { border-radius: 6px; padding: .45rem .7rem; color: var(--text-2); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.dropdown-item.active, .dropdown-item:active { background: var(--primary-soft); color: var(--primary-ink); }

/* ---------- Pagination / list group / progress ---------- */
.pagination { --bs-pagination-color: var(--text-2); --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); --bs-pagination-border-color: var(--border); --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-focus-box-shadow: none; font-size: .85rem; }
.list-group { --bs-list-group-border-color: var(--border); border-radius: var(--radius); font-size: .9rem; }
.list-group-item.active { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--border); }
.progress { background: var(--surface-2); border-radius: 999px; height: 8px; }
.progress-bar { background: var(--primary); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 1.6rem; color: var(--border-strong); margin-bottom: .75rem; display: block; }
.empty h3 { font-size: 1rem; color: var(--text); margin-bottom: .35rem; }

/* ---------- AI components ---------- */
.ai-badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .72rem; font-weight: 500; color: var(--primary-ink); background: var(--primary-soft); padding: .2rem .55rem; border-radius: 999px; }
.ai-panel { border: 1px solid var(--border); border-left: 3px solid var(--primary); background: var(--surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.insight-list { display: grid; gap: .75rem; }
.insight { display: flex; gap: .75rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.insight .ico { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 30px; display: grid; place-items: center; font-size: .85rem; }
.insight.positive .ico { background: var(--success-soft); color: var(--success); }
.insight.negative .ico { background: var(--danger-soft); color: var(--danger); }
.insight.neutral .ico { background: var(--info-soft); color: var(--info); }
.insight.warning .ico { background: var(--warning-soft); color: var(--warning); }
.insight h4 { font-size: .875rem; margin: 0 0 .15rem; }
.insight p { font-size: .84rem; margin: 0; color: var(--text-2); }
.chat-log { display: flex; flex-direction: column; gap: .75rem; max-height: 420px; overflow-y: auto; padding: .25rem; }
.chat-msg { max-width: 88%; padding: .7rem .9rem; border-radius: var(--radius); font-size: .875rem; line-height: 1.55; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.ai { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.skeleton { background: var(--surface-2); border-radius: 6px; height: .9rem; margin-bottom: .5rem; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Rendered markdown (AI narratives) */
.md { font-size: .92rem; line-height: 1.7; color: var(--text-2); }
.md h1, .md h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); color: var(--text); }
.md h3, .md h4 { font-size: .95rem; margin: 1.15rem 0 .4rem; color: var(--text); }
.md > :first-child { margin-top: 0; }
.md ul, .md ol { padding-left: 1.25rem; }
.md li { margin-bottom: .3rem; }
.md blockquote { border-left: 3px solid var(--border-strong); margin: .75rem 0; padding: .25rem 1rem; color: var(--muted); font-style: italic; }
.md table { width: 100%; border-collapse: collapse; margin: .75rem 0; font-size: .85rem; }
.md th, .md td { border: 1px solid var(--border); padding: .45rem .7rem; text-align: left; }
.md th { background: var(--surface-2); font-weight: 500; }
.md strong { color: var(--text); font-weight: 600; }

/* Horizontal bar rows (distribution lists without a chart lib) */
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr 48px; align-items: center; gap: .75rem; font-size: .84rem; padding: .3rem 0; }
.bar-row .track { background: var(--surface-2); height: 8px; border-radius: 999px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--c1); border-radius: 999px; }
.bar-row .num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Brand mark ---------- */
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 34px; background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700; letter-spacing: -.02em; }
.brand-mark.lg { width: 48px; height: 48px; flex-basis: 48px; font-size: 1rem; border-radius: 12px; }

/* ---------- Auth / standalone pages ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2.25rem 2rem; box-shadow: var(--shadow-md); }
.auth-card .brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.75rem; font-weight: 600; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: .35rem; }
.auth-card .sub { color: var(--muted); font-size: .88rem; margin-bottom: 1.5rem; }
.auth-foot { text-align: center; margin-top: 1.25rem; font-size: .82rem; color: var(--muted); }

/* ---------- App shell (sidebar + topbar) ---------- */
:root { --sb-w: 248px; --sb-w-collapsed: 68px; }
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 20; }
.topbar .crumb { font-size: .9rem; font-weight: 500; color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .user-btn { display: flex; align-items: center; gap: .55rem; background: none; border: 0; padding: .3rem .5rem; border-radius: var(--radius-sm); color: var(--text-2); font-size: .85rem; }
.topbar .user-btn:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-size: .75rem; font-weight: 600; }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); color: var(--text-2); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.content { flex: 1; padding: 1.75rem 1.5rem 2.5rem; }
.content > .container, .content > .container-fluid { max-width: 1280px; padding: 0; }
.app-foot { padding: 1rem 1.5rem; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); background: var(--surface); }

.sidebar {
    width: var(--sb-w); flex: 0 0 var(--sb-w); position: sticky; top: 0; height: 100vh; align-self: flex-start;
    display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border);
    overflow-x: hidden; overflow-y: auto; transition: width .2s ease, flex-basis .2s ease, transform .2s ease; z-index: 30;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 1rem; border-bottom: 1px solid var(--border); }
.sb-brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 600; font-size: 1rem; white-space: nowrap; }
.sb-brand:hover { color: var(--text); }
.sb-close { display: none; background: none; border: 0; color: var(--muted); font-size: 1.1rem; }
.sb-group-title { padding: 1.1rem 1.25rem .35rem; font-size: .7rem; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: #9ca3af; white-space: nowrap; }
.sb-link { display: flex; align-items: center; gap: .75rem; margin: 1px .6rem; padding: .55rem .75rem; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; font-size: .875rem; white-space: nowrap; transition: background .15s, color .15s; }
.sb-link i { width: 1.1rem; text-align: center; font-size: .95rem; color: var(--muted); }
.sb-link:hover { background: var(--surface-2); color: var(--text); }
.sb-link.active { background: var(--primary-soft); color: var(--primary-ink); }
.sb-link.active i { color: var(--primary); }
.sb-spacer { flex: 1; }
.sb-foot { padding: .5rem 0 1rem; border-top: 1px solid var(--border); }
.sb-backdrop { display: none; }

@media (min-width: 992px) {
    html.sb-collapsed .sidebar { width: var(--sb-w-collapsed); flex-basis: var(--sb-w-collapsed); }
    html.sb-collapsed .sb-label, html.sb-collapsed .sb-brand-text, html.sb-collapsed .sb-group-title { display: none; }
    html.sb-collapsed .sb-head { justify-content: center; padding: 0; }
    html.sb-collapsed .sb-link { justify-content: center; padding-left: 0; padding-right: 0; }
}
@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); flex-basis: auto; transform: translateX(-100%); box-shadow: var(--shadow-md); }
    html.sb-open .sidebar { transform: none; }
    html.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(17, 24, 39, .35); z-index: 25; }
    .sb-close { display: block; }
    .content { padding: 1.25rem 1rem 2rem; }
    .topbar { padding: 0 1rem; }
}

/* Page loader: thin flat bar */
#page-loader-bar { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--primary); z-index: 9999; opacity: 0; transition: width .3s ease; }
#page-loader-bar.active { opacity: 1; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- Print (reports) ---------- */
@media print {
    .sidebar, .topbar, .app-foot, .no-print, .sb-backdrop { display: none !important; }
    body, .content { background: #fff !important; padding: 0 !important; }
    .card, .panel, .stat, .ai-panel { box-shadow: none !important; break-inside: avoid; }
}
