/* ==========================================================================
   EMMS design system
   Everything visual is a CSS variable. Themes (theme.css) change the variables and the layout
   through data-* attributes on <html>:  data-scheme  data-accent  data-layout  data-side
                                         data-density data-radius data-surface
   ========================================================================== */
:root {
    --sidebar-w: 264px;
    --rail-w: 72px;

    /* accent (overridden by data-accent) */
    --brand: #2563eb;
    --brand-600: #1d4ed8;

    /* light scheme (default) */
    --canvas: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e5e9f0;
    --input-border: #dbe1ea;
    --row-hover: #f7f9fe;

    --ok: #16a34a;
    --bad: #dc2626;
    --warn: #d97706;
    --info: #0891b2;
    --neutral: #64748b;

    --brand-50: color-mix(in srgb, var(--brand) 8%, var(--surface));
    --brand-100: color-mix(in srgb, var(--brand) 16%, var(--surface));
    --brand-text: color-mix(in srgb, var(--brand) 80%, var(--ink));

    /* sidebar / top navigation (data-side="dark" | "light") */
    --side-bg: linear-gradient(180deg, #0b1220 0%, #111a2e 100%);
    --side-text: #9aa7bd;
    --side-text-strong: #ffffff;
    --side-title: #5d6b84;
    --side-hover: rgba(255, 255, 255, .07);
    --side-active: color-mix(in srgb, var(--brand) 26%, transparent);
    --side-active-icon: #93c5fd;
    --side-line: rgba(255, 255, 255, .08);

    --topbar-bg: rgba(255, 255, 255, .82);

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
    --card-shadow: var(--shadow-sm);

    --pad-y: .85rem;      /* table cell padding (density) */
    --pad-x: 1rem;
    --content-pad: 1.5rem;

    /* Bootstrap bridge */
    --bs-primary: var(--brand);
    --bs-body-color: var(--ink-2);
    --bs-body-bg: var(--canvas);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius-sm);
    --bs-link-color: var(--brand);
    --bs-link-hover-color: var(--brand-600);
}

html { font-size: 14.5px; }
body {
    background: var(--canvas);
    color: var(--ink-2);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s, color .2s;
}
body.rtl { font-family: "IBM Plex Sans Arabic", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif; }
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 650; letter-spacing: -.01em; }
a { text-decoration: none; }
::selection { background: color-mix(in srgb, var(--brand) 25%, transparent); }
.text-muted { color: var(--muted) !important; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--side-bg) !important;           /* .offcanvas-lg forces transparent on desktop */
    color: var(--side-text-strong);
    flex-shrink: 0;
    border: 0 !important;
}
@media (min-width: 992px) {
    .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--side-line); border-radius: 6px; }

.sidebar-brand, .topbar-brand {
    display: flex; align-items: center; gap: .8rem; color: var(--side-text-strong);
}
.sidebar-brand { padding: 1.15rem 1.25rem; margin-bottom: .25rem; }
.brand-mark {
    width: 40px; height: 40px; display: grid; place-items: center; flex-shrink: 0;
    font-size: 1.35rem; border-radius: var(--radius-sm); color: #fff;
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 80%, white), var(--brand-600));
    box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 40%, transparent);
}
.sidebar-brand .fw-bold, .topbar-brand .fw-bold { font-size: 1.1rem; letter-spacing: .02em; color: var(--side-text-strong); }
.sidebar-brand .small, .topbar-brand .small { color: var(--side-text); font-size: .82rem; line-height: 1.2; }

.sidebar-nav { padding: .25rem .75rem 2rem; }
.nav-group-title {
    font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .09em;
    color: var(--side-title); padding: 1.1rem .75rem .35rem; white-space: nowrap;
}
.sidebar .nav-link {
    color: var(--side-text); padding: .55rem .75rem; margin: 1px 0;
    display: flex; gap: .7rem; align-items: center;
    border-radius: var(--radius-sm); font-weight: 500; font-size: 1.02rem; white-space: nowrap;
    transition: background .15s, color .15s;
}
.sidebar .nav-link span { overflow: hidden; text-overflow: ellipsis; }
.sidebar .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; flex-shrink: 0; }
.sidebar .nav-link:hover { background: var(--side-hover); color: var(--side-text-strong); }
.sidebar .nav-link.active { background: var(--side-active); color: var(--side-text-strong); position: relative; }
.sidebar .nav-link.active i { color: var(--side-active-icon); opacity: 1; }
.sidebar .nav-link.active::before {
    content: ""; position: absolute; inset-inline-start: -.75rem; top: 20%; bottom: 20%;
    width: 3px; border-radius: 3px; background: var(--brand);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--topbar-bg); backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--line);
    padding: .6rem var(--content-pad); display: flex; align-items: center; gap: .5rem;
    position: sticky; top: 0; z-index: 20; min-height: 60px;
}
.topbar .btn { white-space: nowrap; }
.topbar .btn-light, .topbar .btn-icon {
    background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
    border-radius: 999px; padding: .35rem .85rem; font-weight: 500;
}
.topbar .btn-light:hover, .topbar .btn-icon:hover { background: var(--brand-50); border-color: var(--brand-100); color: var(--ink); }
.topbar .dropdown-toggle::after { margin-inline-start: .45rem; }
.avatar {
    width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700;
    background: var(--brand-100); color: var(--brand-text); margin-inline-end: .35rem; vertical-align: middle;
}
.company-chip { font-size: .8rem; color: var(--muted); padding: .25rem .7rem; border: 1px dashed var(--line); border-radius: 999px; white-space: nowrap; }

.content { padding: calc(var(--content-pad) + .25rem) var(--content-pad) 3rem; max-width: 1600px; width: 100%; margin-inline: auto; }

.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.45rem; font-weight: 700; }

/* ---------- Top navigation (data-layout="top") ---------- */
.topbar-brand, .topnav { display: none; }
.topnav { gap: .15rem; margin-inline-start: 1rem; flex-wrap: wrap; }
.topnav > .nav-link, .topnav .dropdown > .nav-link {
    color: var(--side-text); font-weight: 500; font-size: .9rem; padding: .45rem .8rem; border-radius: var(--radius-sm);
    display: flex; align-items: center; gap: .45rem; white-space: nowrap;
}
.topnav .nav-link i { font-size: 1.05rem; opacity: .85; }
.topnav .nav-link:hover, .topnav .nav-link.show { background: var(--side-hover); color: var(--side-text-strong); }
.topnav .nav-link.active { background: var(--side-active); color: var(--side-text-strong); }
.topnav .dropdown-menu { min-width: 230px; }
.topnav .dropdown-item i { width: 1.4rem; display: inline-block; color: var(--muted); }
.topnav .dropdown-item.active { background: var(--brand-50); color: var(--brand-text); }
.topnav .dropdown-item.active i { color: var(--brand); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--card-shadow); color: var(--ink-2);
}
.card.shadow-sm { box-shadow: var(--card-shadow) !important; }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: .9rem 1.25rem; font-weight: 600; color: var(--ink); }
.card-footer { border-top: 1px solid var(--line); padding: .9rem 1.25rem; }
.card-body { padding: 1.25rem; }

/* ---------- Tables ---------- */
.table-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--card-shadow); overflow-x: auto;
}
.table {
    --bs-table-bg: transparent; --bs-table-color: var(--ink-2); --bs-table-hover-bg: var(--row-hover); --bs-table-hover-color: var(--ink);
    --bs-table-border-color: var(--line); margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: var(--pad-y) var(--pad-x); border-bottom-color: var(--line); vertical-align: middle; }
.table thead th {
    background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .74rem;
    text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; border-bottom: 1px solid var(--line);
}
.table-card .table thead th { position: sticky; top: 0; z-index: 1; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td { white-space: nowrap; color: var(--ink-2); }
.table td:first-child { font-weight: 600; color: var(--ink); }
.table-warning { --bs-table-bg: color-mix(in srgb, var(--warn) 12%, var(--surface)); --bs-table-hover-bg: color-mix(in srgb, var(--warn) 18%, var(--surface)); }
.table-light { --bs-table-bg: var(--surface-2); --bs-table-color: var(--ink); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: embed; text-align: end; white-space: nowrap; }
.dt { direction: ltr; unicode-bidi: isolate; display: inline-block; white-space: nowrap; }

/* Row action buttons -> compact ghost icon buttons */
.table .btn-sm, .table-card .btn-sm { border-radius: calc(var(--radius-sm) - 1px); border-color: transparent; font-size: .9rem; }
.table .btn-sm[title]:has(> i:only-child), .table-card .btn-sm[title]:has(> i:only-child) {   /* icon-only action buttons (they carry a tooltip) become compact squares */
    width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center;
}
.table .btn-outline-primary   { color: var(--brand);   background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
.table .btn-outline-danger    { color: var(--bad);     background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.table .btn-outline-success   { color: var(--ok);      background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.table .btn-outline-warning   { color: var(--warn);    background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.table .btn-outline-secondary { color: var(--neutral); background: color-mix(in srgb, var(--neutral) 12%, var(--surface)); }
.table .btn-outline-primary:hover   { background: var(--brand); color: #fff; }
.table .btn-outline-danger:hover    { background: var(--bad); color: #fff; }
.table .btn-outline-success:hover   { background: var(--ok); color: #fff; }
.table .btn-outline-warning:hover   { background: var(--warn); color: #fff; }
.table .btn-outline-secondary:hover { background: var(--neutral); color: #fff; }

/* ---------- Badges (soft pills) ---------- */
.badge { font-weight: 600; font-size: .72rem; padding: .38em .75em; border-radius: 999px; letter-spacing: .01em; }
.badge.text-bg-primary   { background: var(--brand-100) !important; color: var(--brand-text) !important; }
.badge.text-bg-success   { background: color-mix(in srgb, var(--ok) 16%, var(--surface)) !important;   color: color-mix(in srgb, var(--ok) 72%, var(--ink)) !important; }
.badge.text-bg-danger    { background: color-mix(in srgb, var(--bad) 16%, var(--surface)) !important;  color: color-mix(in srgb, var(--bad) 72%, var(--ink)) !important; }
.badge.text-bg-warning   { background: color-mix(in srgb, var(--warn) 18%, var(--surface)) !important; color: color-mix(in srgb, var(--warn) 70%, var(--ink)) !important; }
.badge.text-bg-info      { background: color-mix(in srgb, var(--info) 16%, var(--surface)) !important;  color: color-mix(in srgb, var(--info) 72%, var(--ink)) !important; }
.badge.text-bg-secondary, .badge.text-bg-dark { background: color-mix(in srgb, var(--neutral) 16%, var(--surface)) !important; color: var(--ink-2) !important; }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; transition: all .15s; }
.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-600); --bs-btn-active-border-color: var(--brand-600);
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--brand) 30%, transparent), 0 4px 10px color-mix(in srgb, var(--brand) 18%, transparent);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-light { --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-border-color: var(--line); --bs-btn-color: var(--ink-2); --bs-btn-hover-color: var(--ink); }
.btn-outline-secondary { --bs-btn-color: var(--ink-2); --bs-btn-border-color: var(--line); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: var(--input-border); background: var(--surface); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.btn-sm { font-size: .85rem; }
.btn.is-loading { pointer-events: none; opacity: .75; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .82rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-control, .form-select {
    border-color: var(--input-border); border-radius: var(--radius-sm); background-color: var(--surface); color: var(--ink);
    padding: .5rem .8rem;
}
.form-control-sm, .form-select-sm { padding: .38rem .7rem; }
.form-control::placeholder { color: var(--muted); opacity: .8; }
.form-control:focus, .form-select:focus {
    background-color: var(--surface); color: var(--ink);
    border-color: color-mix(in srgb, var(--brand) 60%, white); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent);
}
.form-control[readonly] { background: var(--surface-2); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-text { color: var(--muted); }
form.card.card-body { padding: 1rem 1.25rem !important; }
form.card.card-body .form-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.page-header form[role="search"] .form-control {
    min-width: 240px; padding-inline-start: 2.2rem;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 10px center;
}
[dir="rtl"] .page-header form[role="search"] .form-control { background-position: calc(100% - 10px) center; }

/* ---------- Pagination, alerts, dropdowns ---------- */
.pagination { --bs-pagination-border-radius: 8px; --bs-pagination-color: var(--ink-2); --bs-pagination-bg: var(--surface); --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-border-color: var(--line); }
.alert { border: 0; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.alert-success { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: color-mix(in srgb, var(--ok) 75%, var(--ink)); border-inline-start: 4px solid var(--ok); }
.alert-danger  { background: color-mix(in srgb, var(--bad) 11%, var(--surface)); color: color-mix(in srgb, var(--bad) 75%, var(--ink)); border-inline-start: 4px solid var(--bad); }
.alert-info    { background: color-mix(in srgb, var(--info) 11%, var(--surface)); color: color-mix(in srgb, var(--info) 75%, var(--ink)); border-inline-start: 4px solid var(--info); }
.alert-warning { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: color-mix(in srgb, var(--warn) 75%, var(--ink)); border-inline-start: 4px solid var(--warn); }
.dropdown-menu { background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius-sm) + 2px); box-shadow: 0 12px 30px rgba(15, 23, 42, .14); padding: .4rem; --bs-dropdown-link-color: var(--ink-2); --bs-dropdown-link-hover-bg: var(--surface-2); --bs-dropdown-link-hover-color: var(--ink); }
.dropdown-item { border-radius: calc(var(--radius-sm) - 2px); padding: .5rem .75rem; font-size: .9rem; }
.dropdown-item.active, .dropdown-item:active { background: var(--brand); color: #fff; }
.progress { background: var(--surface-2); border-radius: 999px; }
.progress-bar { background: var(--brand); border-radius: 999px; }
hr { border-color: var(--line); opacity: 1; }
.validation-summary-valid { display: none !important; }   /* empty validation summaries must not render a red bar */

/* ---------- Dashboard stat cards ---------- */
.stat-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; box-shadow: var(--card-shadow); height: 100%;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
a:hover > .stat-card { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-100); }
.stat-card .label { color: var(--muted); font-size: .82rem; font-weight: 500; margin-bottom: .2rem; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-icon {
    width: 48px; height: 48px; flex-shrink: 0; display: grid; place-items: center;
    border-radius: var(--radius-sm); font-size: 1.35rem;
}
.stat-icon.primary   { background: var(--brand-100); color: var(--brand-text); }
.stat-icon.success   { background: color-mix(in srgb, var(--ok) 16%, var(--surface));      color: var(--ok); }
.stat-icon.warning   { background: color-mix(in srgb, var(--warn) 16%, var(--surface));    color: var(--warn); }
.stat-icon.danger    { background: color-mix(in srgb, var(--bad) 16%, var(--surface));     color: var(--bad); }
.stat-icon.info      { background: color-mix(in srgb, var(--info) 16%, var(--surface));    color: var(--info); }
.stat-icon.secondary { background: color-mix(in srgb, var(--neutral) 16%, var(--surface)); color: var(--neutral); }

[dir="rtl"] .flip-rtl { display: inline-block; transform: scaleX(-1); }

.tr-key { font-family: Consolas, monospace; font-size: .8rem; color: var(--muted); direction: ltr; }
.tr-missing { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
textarea.tr-input { min-height: 38px; font-size: .9rem; }

/* ---------- Appearance panel ---------- */
.theme-panel { width: min(420px, 94vw); }
.theme-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.theme-card {
    border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .6rem; cursor: pointer; text-align: start;
    transition: border-color .15s, transform .15s; color: var(--ink-2);
}
.theme-card:hover { transform: translateY(-2px); border-color: var(--brand-100); }
.theme-card.selected { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.theme-card .name { font-weight: 600; font-size: .85rem; color: var(--ink); margin-top: .45rem; }
.theme-card .desc { font-size: .72rem; color: var(--muted); }
.mini { height: 64px; border-radius: 8px; border: 1px solid var(--line); display: flex; overflow: hidden; background: #f5f7fb; position: relative; }
.mini .m-side { width: 22%; background: #111a2e; }
.mini .m-main { flex: 1; padding: 6px; display: grid; gap: 4px; align-content: start; }
.mini .m-main i { display: block; height: 8px; border-radius: 3px; background: #dfe5ee; }
.mini .m-main i:first-child { width: 55%; background: var(--m-accent, #2563eb); }
.mini .m-top { position: absolute; inset: 0 0 auto 0; height: 14px; background: #111a2e; }
.mini.m-top-layout .m-main { padding-top: 20px; }
.mini.m-top-layout .m-side { display: none; }
.mini.m-light .m-side { background: #fff; border-inline-end: 1px solid #e5e9f0; }
.mini.m-rail .m-side { width: 11%; }
.mini.m-dark { background: #0b1220; }
.mini.m-dark .m-main i { background: #25324a; }
.mini.m-dark .m-side { background: #070d18; border-inline-end: 1px solid #1c2940; }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.selected { box-shadow: 0 0 0 2px var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: .35rem .8rem; font-size: .82rem; color: var(--ink-2); cursor: pointer; font-weight: 500; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.selected { background: var(--brand); color: #fff; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .content { padding: 0; max-width: none; }
    .card, .table-card { box-shadow: none; }
    .main { margin: 0 !important; }
}

/* ---------- Company logo and report letterhead ---------- */
.brand-logo { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; border-radius: var(--radius-sm); background: #fff; padding: 3px; }
html[data-layout="top"] .topbar-brand .brand-logo { width: 34px; height: 34px; }
.report-letterhead {
    display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .9rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--card-shadow);
}
.rl-company { display: flex; gap: 1rem; align-items: center; }
.rl-logo { max-height: 60px; max-width: 160px; object-fit: contain; }
.rl-name { font-weight: 700; font-size: 1.1rem; color: var(--ink); line-height: 1.2; }
.rl-meta { font-size: .78rem; color: var(--muted); display: flex; gap: .9rem; flex-wrap: wrap; }
.rl-title { text-align: end; }
.rl-report { display: none; font-size: 1.35rem; font-weight: 700; color: var(--ink); }      /* the page title is already on screen */
.rl-period { font-size: .95rem; font-weight: 600; color: var(--brand-text); }
.rl-printed { font-size: .72rem; color: var(--muted); }
@media print {
    @page { margin: 14mm; }
    body { background: #fff !important; color: #000; }
    .report-letterhead { box-shadow: none; border: 0; border-bottom: 2px solid #222; border-radius: 0; padding: 0 0 .6rem; margin-bottom: 1rem; }
    .report-letterhead ~ .page-header { display: none; }
    .rl-report { display: block; }
    .rl-logo { max-height: 70px; }
    .table-card, .card, .stat-card { border-color: #bbb !important; box-shadow: none !important; }
    .table thead th { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .table-card .table thead th { position: static; }
    a { color: inherit; }
    tr { break-inside: avoid; }
    .main { margin: 0 !important; }
}

/* ---------- SweetAlert2, following the active theme ---------- */
.swal2-popup { background: var(--surface); color: var(--ink-2); border-radius: var(--radius); font-family: inherit; border: 1px solid var(--line); }
.swal2-title { color: var(--ink); font-size: 1.15rem; font-weight: 700; }
.swal2-html-container { color: var(--ink-2); font-size: .95rem; }
.swal2-styled.swal2-confirm { background: var(--brand); border-radius: var(--radius-sm); font-weight: 600; box-shadow: none; }
.swal2-styled.swal2-confirm.swal-danger { background: var(--bad); }
.swal2-styled.swal2-cancel { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 600; }
.swal2-styled:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent) !important; }
.swal2-toast { background: var(--surface) !important; color: var(--ink) !important; border: 1px solid var(--line); box-shadow: var(--shadow-md) !important; }
.swal2-toast .swal2-title { font-size: .92rem; font-weight: 600; margin: 0 .5rem; }
.swal2-timer-progress-bar { background: var(--ok) !important; }
.swal2-container { z-index: 2000; }
html[data-scheme="dark"] .swal2-popup .swal2-icon.swal2-success [class^=swal2-success-circular-line], html[data-scheme="dark"] .swal2-popup .swal2-icon.swal2-success .swal2-success-fix { background: transparent; }

/* ==========================================================================
   Sign-in page (professional layout, company branding, light/dark aware)
   ========================================================================== */
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; background: var(--canvas); }
.auth-hero {
    position: relative; overflow: hidden; color: #fff; padding: 2.5rem 3.25rem;
    display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
    background:
        radial-gradient(900px 520px at 0% 0%, color-mix(in srgb, var(--brand) 60%, transparent), transparent 62%),
        radial-gradient(700px 520px at 100% 100%, rgba(14, 165, 233, .32), transparent 60%),
        linear-gradient(160deg, #0a1020, #13203d);
}
.hero-glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; inset-inline-end: -180px; top: 28%; background: radial-gradient(closest-side, rgba(255,255,255,.07), transparent); pointer-events: none; }
.auth-hero .brand { display: flex; align-items: center; gap: .85rem; font-weight: 700; font-size: 1.3rem; position: relative; }
.brand-badge { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; font-size: 1.45rem; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 78%, white), var(--brand-600)); box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 50%, transparent); }
.hero-logo { height: 46px; max-width: 150px; object-fit: contain; border-radius: 10px; background: #fff; padding: 4px; animation: fadeIn .35s ease; }
.hero-copy { position: relative; max-width: 480px; }
.hero-copy h2 { color: #fff; font-size: 2.15rem; font-weight: 800; line-height: 1.25; margin-bottom: .75rem; }
.hero-copy p { color: #b9c6dd; font-size: 1.02rem; margin-bottom: 1.75rem; }
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: .85rem; }
.features li { display: flex; align-items: center; gap: .8rem; color: #e3ebf9; font-weight: 500; }
.f-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.1); color: #8fc0ff; font-size: 1.05rem; }
.hero-foot { position: relative; font-size: .8rem; color: #8493b0; }
.hero-foot .sep { margin-inline: .35rem; opacity: .6; }

.auth-panel { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; background: var(--canvas); }
.panel-top { position: absolute; top: 1.1rem; inset-inline-end: 1.4rem; }
.lang-switch { display: flex; gap: .35rem; }
.lang-switch form { margin: 0; }
.lang-switch button { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: .3rem .8rem; font-size: .8rem; font-weight: 500; cursor: pointer; }
.lang-switch button.active { background: var(--brand-50); color: var(--brand-text); border-color: var(--brand-100); font-weight: 700; }
.panel-foot { position: absolute; bottom: 1rem; font-size: .75rem; color: var(--muted); }

.auth-card {
    width: 420px; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px);
    padding: 2.25rem 2rem 1.75rem; box-shadow: 0 18px 50px rgba(15, 23, 42, .09);
}
.auth-logo { height: 64px; display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }
.auth-mark { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; font-size: 1.7rem; color: #fff; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 78%, white), var(--brand-600)); box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 35%, transparent); }
.auth-logo img { max-height: 64px; max-width: 200px; object-fit: contain; animation: fadeIn .4s ease; }
.auth-card h1 { text-align: center; font-size: 1.5rem; font-weight: 800; margin-bottom: .2rem; }
.auth-sub { text-align: center; color: var(--muted); font-size: .92rem; margin-bottom: 1.5rem; min-height: 1.4em; transition: color .2s; }
.auth-card.branded .auth-sub { color: var(--brand-text); font-weight: 600; }
.field { margin-bottom: 1rem; }
.field .form-label { font-weight: 600; font-size: .83rem; }
.input-icon { position: relative; }
.input-icon > i:first-child { position: absolute; inset-inline-start: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .form-control { padding: .7rem .9rem; padding-inline-start: 2.5rem; border-radius: var(--radius-sm); }
.input-icon .eye { position: absolute; inset-inline-end: .35rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); padding: .35rem .55rem; border-radius: 8px; }
.input-icon .eye:hover { color: var(--ink); background: var(--surface-2); }
.input-icon:has(.eye) .form-control { padding-inline-end: 2.8rem; }
.caps { margin-top: .35rem; font-size: .78rem; color: var(--warn); }
.field-error { color: var(--bad); font-size: .78rem; }
.auth-error { background: color-mix(in srgb, var(--bad) 11%, var(--surface)); color: color-mix(in srgb, var(--bad) 80%, var(--ink)); border-inline-start: 4px solid var(--bad); border-radius: var(--radius-sm); padding: .6rem .85rem; font-size: .85rem; margin-bottom: 1rem; }
.auth-error ul { list-style: none; margin: 0; padding: 0; }
.auth-error.validation-summary-valid { display: none; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin: .25rem 0 1.25rem; font-size: .86rem; }
.row-between .form-check { margin: 0; }
.forgot { font-weight: 600; }
.btn-login { width: 100%; padding: .78rem; font-size: 1rem; display: flex; align-items: center; justify-content: center; gap: .3rem; border-radius: var(--radius-sm); }
.btn-login .bi { font-size: 1.3rem; }
.auth-help { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: .78rem; }
.auth-card.shake { animation: shake .45s ease; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@media (prefers-reduced-motion: reduce) { .auth-card.shake, .hero-logo, .auth-logo img { animation: none; } }
@media (max-width: 991px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-panel { min-height: 100vh; }
    .auth-card { box-shadow: none; border-color: transparent; background: transparent; padding-inline: .5rem; }
}
html[data-scheme="dark"] .auth-card { box-shadow: 0 18px 50px rgba(0, 0, 0, .45); }

/* ---------- Collapsible menu groups ---------- */
.nav-tools { display: flex; justify-content: flex-end; gap: .25rem; padding: .1rem .35rem .25rem; }
.nav-tools button { border: 0; background: transparent; color: var(--side-title); padding: .2rem .45rem; border-radius: 8px; font-size: .95rem; }
.nav-tools button:hover { background: var(--side-hover); color: var(--side-text-strong); }
.sidebar .nav-single { margin: .1rem 0; }
.nav-group { margin-top: .15rem; }
button.nav-group-title {
    width: 100%; display: flex; align-items: center; justify-content: space-between; background: transparent; border: 0;
    padding: .55rem .75rem; border-radius: var(--radius-sm); cursor: pointer; text-align: start;
    font-size: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0; color: var(--side-text); transition: background .15s, color .15s;
}
button.nav-group-title:hover { background: var(--side-hover); color: var(--side-text-strong); }
button.nav-group-title i { font-size: .95rem; transition: transform .2s; }
.nav-group.open > button.nav-group-title { color: var(--side-text-strong); }
.nav-group.open > button.nav-group-title i { transform: rotate(180deg); }
.nav-group-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s ease; }
.nav-group-items > div { overflow: hidden; min-height: 0; }
.nav-group.open .nav-group-items { grid-template-rows: 1fr; }
.nav-group.open .nav-group-items > div { padding-bottom: .3rem; }
@media (prefers-reduced-motion: reduce) { .nav-group-items, button.nav-group-title i { transition: none; } }
/* icon rail: every icon stays visible, no accordion */
html[data-layout="rail"] .nav-group-items { grid-template-rows: 1fr; }
html[data-layout="rail"] .nav-tools { display: none; }
html[data-layout="rail"] .sidebar:not(:hover) button.nav-group-title { display: none; }