/* =====================================================================
   Business Invoicing — design system
   Built on Bootstrap 5.3 CSS variables. Light + dark themes.
   ===================================================================== */

:root,
[data-bs-theme="light"] {
    --bi-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    /* Professional blue + high-contrast slate text (WCAG AA on all surfaces) */
    --bi-primary: #2563eb;
    --bi-primary-rgb: 37, 99, 235;
    --bi-primary-hover: #1d4ed8;
    --bi-primary-soft: #eaf1ff;
    --bi-primary-text: #1d4ed8;

    --bi-bg: #f3f5f9;
    --bi-surface: #ffffff;
    --bi-surface-2: #f7f9fc;
    --bi-border: #dde3ec;
    --bi-text: #1e293b;
    --bi-text-muted: #4b5a6e;
    --bi-heading: #0f172a;

    --bi-nav-bg: #ffffff;
    --bi-nav-text: #334155;
    --bi-nav-hover-bg: #f1f5f9;

    --bi-success: #047857;  --bi-success-soft: #e7f7ef;
    --bi-warning: #b45309;  --bi-warning-soft: #fdf3e1;
    --bi-danger: #be123c;   --bi-danger-soft: #fdecef;
    --bi-info: #0369a1;     --bi-info-soft: #e6f4fb;
    --bi-neutral: #3f4b5c;  --bi-neutral-soft: #eef1f5;

    --bi-radius: 12px;
    --bi-radius-sm: 8px;
    --bi-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .05);
    --bi-shadow-lg: 0 12px 32px -12px rgba(15, 23, 42, .22);
    --bi-topbar-h: 64px;

    /* Bootstrap bridges */
    --bs-body-font-family: var(--bi-font);
    --bs-body-bg: var(--bi-bg);
    --bs-body-color: var(--bi-text);
    --bs-primary: var(--bi-primary);
    --bs-primary-rgb: var(--bi-primary-rgb);
    --bs-link-color: var(--bi-primary);
    --bs-link-color-rgb: var(--bi-primary-rgb);
    --bs-link-hover-color: var(--bi-primary-hover);
    --bs-border-color: var(--bi-border);
    --bs-border-radius: var(--bi-radius-sm);
    --bs-secondary-color: var(--bi-text-muted);
    --bs-tertiary-bg: var(--bi-surface-2);
    --bs-emphasis-color: var(--bi-heading);
    --bs-focus-ring-color: rgba(var(--bi-primary-rgb), .25);
}

[data-bs-theme="dark"] {
    --bi-primary: #60a5fa;
    --bi-primary-rgb: 96, 165, 250;
    --bi-primary-hover: #93c5fd;
    --bi-primary-soft: rgba(96, 165, 250, .14);
    --bi-primary-text: #bfdbfe;

    --bi-bg: #0d1320;
    --bi-surface: #151c2c;
    --bi-surface-2: #111827;
    --bi-border: #263042;
    --bi-text: #e2e8f0;
    --bi-text-muted: #a3b1c4;
    --bi-heading: #f8fafc;

    --bi-nav-bg: #151c2c;
    --bi-nav-text: #cbd5e1;
    --bi-nav-hover-bg: rgba(148, 163, 184, .1);

    --bi-success: #34d399;  --bi-success-soft: rgba(52, 211, 153, .13);
    --bi-warning: #fbbf24;  --bi-warning-soft: rgba(251, 191, 36, .13);
    --bi-danger: #fb7185;   --bi-danger-soft: rgba(251, 113, 133, .13);
    --bi-info: #38bdf8;     --bi-info-soft: rgba(56, 189, 248, .13);
    --bi-neutral: #cbd5e1;  --bi-neutral-soft: rgba(148, 163, 184, .13);

    --bi-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --bi-shadow-lg: 0 12px 32px -12px rgba(0, 0, 0, .6);

    --bs-body-bg: var(--bi-bg);
    --bs-body-color: var(--bi-text);
    --bs-border-color: var(--bi-border);
    --bs-tertiary-bg: var(--bi-surface-2);
    --bs-secondary-bg: var(--bi-surface-2);
}

/* ---------- Base ---------- */
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--bi-font); background: var(--bi-bg); color: var(--bi-text); font-size: .9375rem; line-height: 1.55; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { color: var(--bi-heading); font-weight: 650; letter-spacing: -.012em; }
.text-muted, .text-body-secondary { color: var(--bi-text-muted) !important; }
a { text-decoration: none; }
::selection { background: rgba(var(--bi-primary-rgb), .2); }
.tabular { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid rgba(var(--bi-primary-rgb), .6); outline-offset: 2px; }

/* ---------- Shell: horizontal top navigation ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topnav {
    position: sticky; top: 0; z-index: 1030;
    background: var(--bi-nav-bg); border-bottom: 1px solid var(--bi-border);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .02), 0 2px 8px -4px rgba(15, 23, 42, .08);
}
.topnav-inner { max-width: 1600px; margin: 0 auto; height: var(--bi-topbar-h); display: flex; align-items: center; gap: 1.5rem; padding: 0 1.75rem; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--bi-heading); font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { color: var(--bi-heading); }
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(135deg, #2563eb, #1e40af); color: #fff; font-size: 1.05rem;
    box-shadow: 0 6px 14px -6px rgba(37, 99, 235, .75);
}
.mainnav { display: flex; align-items: stretch; gap: .15rem; height: 100%; margin: 0; padding: 0; list-style: none; }
.mainnav > li { display: flex; align-items: center; position: relative; }
.mainnav .nav-item-link {
    display: flex; align-items: center; gap: .45rem; height: 38px; padding: 0 .8rem; border-radius: 8px;
    color: var(--bi-nav-text); font-weight: 500; font-size: .9rem; white-space: nowrap;
    background: none; border: 0; transition: background .15s, color .15s;
}
.mainnav .nav-item-link i { font-size: 1rem; opacity: .85; }
.mainnav .nav-item-link:hover, .mainnav .show > .nav-item-link { background: var(--bi-nav-hover-bg); color: var(--bi-heading); }
.mainnav .nav-item-link.active { color: var(--bi-primary-text); background: var(--bi-primary-soft); font-weight: 600; }
.mainnav .nav-item-link.active i { opacity: 1; }
.mainnav .dropdown-toggle::after { border: 0; content: "\F282"; font-family: "bootstrap-icons"; font-size: .65rem; margin-left: .15rem; vertical-align: 0; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
    font-weight: 600; font-size: .78rem; color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.avatar-sm { width: 30px; height: 30px; font-size: .7rem; }
.icon-btn {
    width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 9px;
    border: 1px solid var(--bi-border); background: var(--bi-surface); color: var(--bi-text-muted);
    transition: all .15s;
}
.icon-btn:hover { color: var(--bi-primary); border-color: rgba(var(--bi-primary-rgb), .4); }
.user-btn { display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .3rem; border-radius: 99px; border: 1px solid var(--bi-border); background: var(--bi-surface); color: var(--bi-heading); font-weight: 500; font-size: .875rem; }
.user-btn:hover { border-color: rgba(var(--bi-primary-rgb), .4); }
.user-btn .role { display: block; font-size: .7rem; color: var(--bi-text-muted); font-weight: 500; line-height: 1.1; }

.content { padding: 1.75rem; flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; }
.app-footer { padding: 1rem 1.75rem 1.5rem; font-size: .8rem; color: var(--bi-text-muted); max-width: 1600px; margin: 0 auto; width: 100%; }

/* Mobile nav */
.nav-toggle { display: none; }
@media (max-width: 1199.98px) {
    .topnav-inner { gap: .75rem; padding: 0 1rem; }
    .nav-toggle { display: inline-grid; }
    .mainnav {
        position: fixed; top: var(--bi-topbar-h); left: 0; right: 0; height: auto; max-height: calc(100vh - var(--bi-topbar-h));
        overflow-y: auto; flex-direction: column; align-items: stretch; gap: .15rem; padding: .75rem 1rem 1rem;
        background: var(--bi-nav-bg); border-bottom: 1px solid var(--bi-border); box-shadow: var(--bi-shadow-lg);
        transform: translateY(-8px); opacity: 0; visibility: hidden; transition: all .18s ease;
    }
    .mainnav.open { transform: none; opacity: 1; visibility: visible; }
    .mainnav > li { display: block; }
    .mainnav .nav-item-link { width: 100%; height: 44px; }
    .mainnav .dropdown-menu { position: static !important; transform: none !important; box-shadow: none; border: 0; padding: 0 0 0 1.75rem; background: transparent; }
    .content { padding: 1.25rem 1rem; }
    .app-footer { padding-left: 1rem; padding-right: 1rem; }
}
@media (max-width: 575.98px) { .brand-text { display: none; } }

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; margin: 0; }
.page-subtitle { color: var(--bi-text-muted); margin: .25rem 0 0; font-size: .875rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Cards ---------- */
.card {
    --bs-card-bg: var(--bi-surface);
    --bs-card-border-color: var(--bi-border);
    --bs-card-border-radius: var(--bi-radius);
    --bs-card-inner-border-radius: calc(var(--bi-radius) - 1px);
    --bs-card-cap-bg: transparent;
    box-shadow: var(--bi-shadow);
}
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--bi-border); display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card-title { font-size: .95rem; font-weight: 600; margin: 0; color: var(--bi-heading); }
.card-body { padding: 1.25rem; }
.card-narrow { max-width: 760px; }
.card-xs { max-width: 520px; }

/* Stat tiles */
.stat {
    background: var(--bi-surface); border: 1px solid var(--bi-border); border-radius: var(--bi-radius);
    padding: 1.15rem 1.25rem; box-shadow: var(--bi-shadow); height: 100%; position: relative; overflow: hidden;
}
.stat-label { font-size: .84rem; font-weight: 500; color: var(--bi-text-muted); margin-bottom: .35rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--bi-heading); letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-meta { font-size: .76rem; color: var(--bi-text-muted); margin-top: .35rem; }
.stat-icon {
    position: absolute; top: 1rem; right: 1rem; width: 40px; height: 40px; border-radius: 11px;
    display: grid; place-items: center; font-size: 1.15rem;
}
.tone-primary { background: var(--bi-primary-soft); color: var(--bi-primary-text); }
.tone-success { background: var(--bi-success-soft); color: var(--bi-success); }
.tone-warning { background: var(--bi-warning-soft); color: var(--bi-warning); }
.tone-danger  { background: var(--bi-danger-soft);  color: var(--bi-danger); }
.tone-info    { background: var(--bi-info-soft);    color: var(--bi-info); }
.tone-neutral { background: var(--bi-neutral-soft); color: var(--bi-neutral); }

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: 8px; font-size: .9rem; padding: .48rem .95rem; display: inline-flex; align-items: center; gap: .4rem; justify-content: center; }
.btn-sm { padding: .32rem .7rem; font-size: .8rem; border-radius: 8px; }
.btn-primary {
    --bs-btn-bg: var(--bi-primary); --bs-btn-border-color: var(--bi-primary);
    --bs-btn-hover-bg: var(--bi-primary-hover); --bs-btn-hover-border-color: var(--bi-primary-hover);
    --bs-btn-active-bg: var(--bi-primary-hover); --bs-btn-active-border-color: var(--bi-primary-hover);
    --bs-btn-disabled-bg: var(--bi-primary); --bs-btn-disabled-border-color: var(--bi-primary);
    box-shadow: 0 1px 2px rgba(var(--bi-primary-rgb), .3);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0b1020; --bs-btn-hover-color: #0b1020; --bs-btn-active-color: #0b1020; }
.btn-light, .btn-outline-secondary {
    --bs-btn-bg: var(--bi-surface); --bs-btn-color: var(--bi-text); --bs-btn-border-color: var(--bi-border);
    --bs-btn-hover-bg: var(--bi-surface-2); --bs-btn-hover-color: var(--bi-heading); --bs-btn-hover-border-color: #cbd5e1;
    --bs-btn-active-bg: var(--bi-surface-2); --bs-btn-active-color: var(--bi-heading); --bs-btn-active-border-color: #cbd5e1;
}
.btn-soft-danger { background: var(--bi-danger-soft); color: var(--bi-danger); border: 0; }
.btn-soft-danger:hover { background: var(--bi-danger); color: #fff; }
.btn-soft-success { background: var(--bi-success-soft); color: var(--bi-success); border: 0; }
.btn-soft-success:hover { background: var(--bi-success); color: #fff; }

/* Row action icon buttons */
.row-actions { display: inline-flex; gap: .25rem; align-items: center; justify-content: flex-end; }
.row-actions form { display: inline; margin: 0; }
.act {
    width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center;
    color: var(--bi-text-muted); background: transparent; border: 1px solid transparent; font-size: .95rem;
    transition: all .12s;
}
.act:hover { background: var(--bi-surface-2); border-color: var(--bi-border); color: var(--bi-heading); }
.act.act-primary:hover { color: var(--bi-primary); background: var(--bi-primary-soft); border-color: transparent; }
.act.act-success:hover { color: var(--bi-success); background: var(--bi-success-soft); border-color: transparent; }
.act.act-warning:hover { color: var(--bi-warning); background: var(--bi-warning-soft); border-color: transparent; }
.act.act-danger:hover  { color: var(--bi-danger);  background: var(--bi-danger-soft);  border-color: transparent; }
.act.act-info:hover    { color: var(--bi-info);    background: var(--bi-info-soft);    border-color: transparent; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .86rem; color: var(--bi-heading); margin-bottom: .35rem; }
.form-label .req { color: var(--bi-danger); }
.form-control, .form-select {
    border-radius: 9px; border-color: var(--bi-border); background-color: var(--bi-surface);
    color: var(--bi-text); font-size: .9375rem; padding: .55rem .8rem;
}
.form-control-sm, .form-select-sm { padding: .38rem .65rem; font-size: .82rem; border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--bi-primary-rgb), .6); box-shadow: 0 0 0 .22rem rgba(var(--bi-primary-rgb), .15); }
.form-control::placeholder { color: #94a3b8; }
.form-text { color: var(--bi-text-muted); font-size: .82rem; }
.form-section { padding-bottom: 1.25rem; margin-bottom: 1.25rem; border-bottom: 1px dashed var(--bi-border); }
.form-section:last-of-type { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.form-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--bi-text-muted); font-weight: 600; margin-bottom: .9rem; }
.form-footer { display: flex; gap: .5rem; justify-content: flex-end; padding: 1rem 1.25rem; border-top: 1px solid var(--bi-border); background: var(--bi-surface-2); border-radius: 0 0 var(--bi-radius) var(--bi-radius); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }
.input-icon > .form-control { padding-left: 2.3rem; }
.is-invalid { border-color: var(--bi-danger) !important; }

/* Filter bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; padding: 1rem 1.25rem; border-bottom: 1px solid var(--bi-border); }
.filter-bar .form-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bi-text-muted); font-weight: 600; margin-bottom: .25rem; }
.filter-bar .grow { flex: 1 1 200px; }
.filter-note { padding: .6rem 1.25rem; font-size: .84rem; color: var(--bi-text-muted); background: var(--bi-surface-2); border-bottom: 1px solid var(--bi-border); display: flex; gap: .5rem; align-items: center; }

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: transparent; --bs-table-color: var(--bi-text);
    --bs-table-hover-bg: var(--bi-surface-2); --bs-table-striped-bg: transparent;
    --bs-table-border-color: var(--bi-border);
    margin-bottom: 0; font-size: .9rem;
}
.table > thead th {
    background: var(--bi-surface-2); color: var(--bi-text-muted); font-weight: 600;
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
    padding: .7rem 1rem; border-bottom: 1px solid var(--bi-border);
}
.table > tbody td { padding: .75rem 1rem; vertical-align: middle; border-color: var(--bi-border); }
.table > tbody tr:last-child td { border-bottom: 0; }
.table > tfoot td { padding: .8rem 1rem; background: var(--bi-surface-2); font-weight: 600; border-top: 1px solid var(--bi-border); }
.table-wrap { overflow-x: auto; }
.cell-strong { font-weight: 600; color: var(--bi-heading); }
.cell-sub { display: block; font-size: .8rem; color: var(--bi-text-muted); }
.cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; color: var(--bi-text-muted); }
.row-today > td { background: var(--bi-success-soft) !important; }
.row-blocked > td { opacity: .55; }
td[contenteditable="true"] {
    cursor: text; border-radius: 6px; outline: 1px dashed rgba(var(--bi-primary-rgb), .45); outline-offset: -4px;
}
td[contenteditable="true"]:focus { outline: 2px solid var(--bi-primary); background: var(--bi-primary-soft); }
td.saved { background: var(--bi-success-soft) !important; transition: background .4s; }

/* Pagination */
.card-pager { padding: .85rem 1.25rem; border-top: 1px solid var(--bi-border); }
.card-pager .pagination { margin: 0; }
.card-pager nav > .d-sm-flex > .small.text-muted { display: none; }
.card-pager nav > .d-sm-flex { justify-content: flex-end !important; }
.pagination { --bs-pagination-color: var(--bi-text); --bs-pagination-bg: var(--bi-surface); --bs-pagination-border-color: var(--bi-border);
    --bs-pagination-hover-bg: var(--bi-surface-2); --bs-pagination-hover-color: var(--bi-heading); --bs-pagination-hover-border-color: var(--bi-border);
    --bs-pagination-active-bg: var(--bi-primary); --bs-pagination-active-border-color: var(--bi-primary);
    --bs-pagination-disabled-bg: var(--bi-surface); --bs-pagination-disabled-border-color: var(--bi-border);
    --bs-pagination-font-size: .82rem; --bs-pagination-border-radius: 8px; gap: .25rem; }
.pagination .page-link { border-radius: 8px !important; min-width: 34px; text-align: center; }

/* ---------- Badges ---------- */
.pill {
    display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .6rem; border-radius: 99px;
    font-size: .78rem; font-weight: 600; white-space: nowrap; line-height: 1.35;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.no-dot::before { display: none; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--bi-text-muted); }
.empty i { font-size: 2.2rem; display: block; margin-bottom: .6rem; color: #cbd5e1; }
.empty strong { display: block; color: var(--bi-heading); font-size: .95rem; margin-bottom: .2rem; }

/* ---------- Alerts / toasts ---------- */
.alert { border-radius: var(--bi-radius-sm); border: 1px solid transparent; font-size: .86rem; }
.alert-danger { background: var(--bi-danger-soft); color: var(--bi-danger); border-color: rgba(225, 29, 72, .15); }
.alert-warning { background: var(--bi-warning-soft); color: var(--bi-warning); border-color: rgba(217, 119, 6, .15); }
.alert-info { background: var(--bi-info-soft); color: var(--bi-info); border-color: rgba(2, 132, 199, .15); }
.alert-success { background: var(--bi-success-soft); color: var(--bi-success); border-color: rgba(5, 150, 105, .15); }
.toast-stack { position: fixed; top: calc(var(--bi-topbar-h) + .75rem); right: 1.25rem; z-index: 1090; display: flex; flex-direction: column; gap: .5rem; }
.app-toast {
    display: flex; gap: .75rem; align-items: flex-start; min-width: 300px; max-width: 420px;
    background: var(--bi-surface); border: 1px solid var(--bi-border); border-radius: 12px;
    padding: .85rem 1rem; box-shadow: var(--bi-shadow-lg); font-size: .86rem;
    animation: toast-in .25s ease;
}
.app-toast .toast-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.app-toast .btn-close { margin-left: auto; font-size: .65rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Dropdown / modal ---------- */
.dropdown-menu {
    --bs-dropdown-bg: var(--bi-surface); --bs-dropdown-border-color: var(--bi-border);
    --bs-dropdown-link-color: var(--bi-text); --bs-dropdown-link-hover-bg: var(--bi-surface-2);
    --bs-dropdown-link-active-bg: var(--bi-primary-soft); --bs-dropdown-link-active-color: var(--bi-primary-text);
    border-radius: 12px; box-shadow: var(--bi-shadow-lg); padding: .4rem; font-size: .86rem;
}
.dropdown-item { border-radius: 8px; padding: .45rem .7rem; display: flex; gap: .6rem; align-items: center; }
.modal-content { border-radius: 16px; border: 1px solid var(--bi-border); background: var(--bi-surface); box-shadow: var(--bi-shadow-lg); }
.modal-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; margin-bottom: .9rem; }

/* ---------- Detail list ---------- */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.1rem 1.5rem; margin: 0; }
.dl-grid dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bi-text-muted); font-weight: 600; margin-bottom: .2rem; }
.dl-grid dd { margin: 0; font-weight: 500; color: var(--bi-heading); }

/* ---------- Chart ---------- */
.chart-box { position: relative; height: 340px; }
.chart-box.lg { height: 420px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: middle; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--bi-surface); }
.auth-aside {
    position: relative; overflow: hidden; color: #e2e8f0; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
    background:
        radial-gradient(800px 400px at 0% 0%, rgba(37, 99, 235, .5), transparent 60%),
        radial-gradient(600px 400px at 100% 100%, rgba(14, 165, 233, .3), transparent 60%),
        #0f172a;
}
.auth-aside h2 { color: #fff; font-size: 2rem; line-height: 1.2; max-width: 440px; }
.auth-aside p { color: #94a3b8; max-width: 420px; }
.auth-feature { display: flex; gap: .8rem; align-items: center; margin-top: .9rem; color: #cbd5e1; font-size: .9rem; }
.auth-feature i { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: rgba(255, 255, 255, .08); color: #93c5fd; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--bi-bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .btn { padding: .7rem 1rem; }
@media (max-width: 991.98px) {
    .auth { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

/* ---------- Tom Select theming ---------- */
.ts-wrapper .ts-control { border-radius: 9px !important; border-color: var(--bi-border) !important; background: var(--bi-surface) !important; color: var(--bi-text); padding: .55rem .8rem; min-height: 44px; }
.ts-wrapper.focus .ts-control { border-color: rgba(var(--bi-primary-rgb), .6) !important; box-shadow: 0 0 0 .22rem rgba(var(--bi-primary-rgb), .15) !important; }
.ts-dropdown { border-radius: 10px; border-color: var(--bi-border); background: var(--bi-surface); color: var(--bi-text); box-shadow: var(--bi-shadow-lg); }
.ts-dropdown .active { background: var(--bi-primary-soft) !important; color: var(--bi-primary-text) !important; }
.ts-dropdown .option { padding: .55rem .8rem; }
.ts-opt-sub { display: block; font-size: .75rem; color: var(--bi-text-muted); }

/* Utilities */
.gap-row > * { margin-bottom: 1.25rem; }
.min-w-0 { min-width: 0; }
.fw-650 { font-weight: 650; }
kbd { background: var(--bi-surface-2); color: var(--bi-heading); border: 1px solid var(--bi-border); border-radius: 5px; font-size: .75rem; padding: .05rem .35rem; }

/* ---------- Navigation progress bar ---------- */
.nav-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 2000; background: linear-gradient(90deg, var(--bi-primary), #38bdf8); box-shadow: 0 0 8px rgba(var(--bi-primary-rgb), .6); opacity: 0; pointer-events: none; }
.nav-progress.run { opacity: 1; animation: nav-progress 8s cubic-bezier(.1, .7, .2, 1) forwards; }
.nav-progress.done { width: 0; opacity: 0; transition: opacity .2s; }
@keyframes nav-progress { 0% { width: 0; } 20% { width: 45%; } 60% { width: 75%; } 100% { width: 92%; } }

/* Smoother interactions */
.card, .stat { transition: box-shadow .2s, border-color .2s; }
a.stat:hover, .stat-link:hover .stat { border-color: rgba(var(--bi-primary-rgb), .35); box-shadow: var(--bi-shadow-lg); }
.content { animation: fade-in .25s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .content, .app-toast { animation: none; } .nav-progress.run { animation-duration: 0s; } }
.table > tbody tr { transition: background-color .12s; }
.recent-list { max-height: 360px; overflow-y: auto; }
.dup-warning { display: none; }
.dup-warning.show { display: flex; }
