:root {
    --ocaso-blue: #2563eb;
    --brand-primary: #2563eb;
    --ocaso-blue-dark: #0b1739;
    --ocaso-blue-light: #3b82f6;
    --ocaso-blue-050: #eaf0f6;
    --ocaso-blue-100: #d4e0ec;
    --ocaso-blue-200: #97b9d8;
    --ocaso-gold: #f39c12;
    --ocaso-gold-hover: #e67e22;
    --ocaso-white: #ffffff;
    --ocaso-bg: #f5f7fb;
    --ocaso-gray-50: #f8f9fa;
    --ocaso-gray-100: #ecf0f4;
    --ocaso-gray-200: #dbe0eb;
    --ocaso-gray-300: #c3ccdc;
    --ocaso-gray-400: #aab5c9;
    --ocaso-gray-500: #7f8c9a;
    --ocaso-gray-600: #636f82;
    --ocaso-gray-900: #2c3e50;
    --ocaso-green: #27ae60;
    --ocaso-red: #e74c3c;
    --ocaso-red-light: #fdecea;
    --sidebar-width: 276px;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text-strong: #15213b;
    --text-body: #35425d;
    --text-muted: #748198;
    --border-subtle: #e7ebf2;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px rgba(15, 23, 42, .04);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, .08);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

/* ========== BASE ========== */
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--ocaso-bg);
    color: var(--ocaso-gray-900);
    overflow-x: hidden;
}

[data-bs-theme="dark"] body {
    background-color: #1a1a2e;
    color: #e0e0e0;
}


.sidebar-heading {
    border-bottom: 1px solid rgba(255,255,255,0.15) !important;
}

/* Desktop: sidebar always visible */
@media (min-width: 992px) {
    #sidebar-wrapper { transform: translateX(0) !important; }
    #sidebar-backdrop { display: none !important; }
    #page-content-wrapper { margin-left: var(--sidebar-width) !important; }
    #sidebarToggle { display: none !important; }
}

.sidebar-heading h5 {
    color: white !important;
    font-weight: 700;
    letter-spacing: 1px;
}

.sidebar-heading small {
    color: rgba(255,255,255,0.6) !important;
}

/* Sidebar links */
#sidebar-wrapper .list-group-item {
    border-left: 3px solid transparent;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    background: transparent !important;
    color: rgba(255,255,255,0.85) !important;
    padding: 12px 16px;
    transition: all 0.2s ease;
}

#sidebar-wrapper .list-group-item:hover {
    border-left-color: var(--ocaso-gold);
    background: rgba(255,255,255,0.08) !important;
    color: white !important;
}

#sidebar-wrapper .list-group-item.active {
    border-left-color: var(--ocaso-gold);
    background: rgba(255,255,255,0.12) !important;
    color: white !important;
}

#sidebar-wrapper .list-group-item i {
    color: rgba(255,255,255,0.6);
    font-size: 1.1rem;
}

#sidebar-wrapper .list-group-item:hover i,
#sidebar-wrapper .list-group-item.active i {
    color: var(--ocaso-gold);
}

#sidebar-wrapper .position-absolute {
    background: rgba(0,0,0,0.2) !important;
    color: rgba(255,255,255,0.7) !important;
}

#sidebar-wrapper .btn-outline-secondary {
    color: rgba(255,255,255,0.7);
    border-color: rgba(255,255,255,0.3);
}

#sidebar-wrapper .btn-outline-secondary:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* Bottom mobile nav */
#bottomNav {
    display: none;
}

#bottomNav .nav-item {
    text-align: center;
    color: var(--ocaso-gray-500);
    padding: 4px 2px;
    font-size: 10px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    font-weight: 500;
}

#bottomNav .nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

#bottomNav .nav-item.active {
    color: var(--ocaso-blue);
}

#bottomNav .nav-scroll-btn { display: none; }
#bottomNav .nav-scroll-area { display: flex; }

/* ========== TOP BAR ========== */
.navbar-top {
    background: var(--ocaso-white) !important;
    position: sticky;
    top: 0;
    z-index: 1020;
    border-bottom: 1px solid var(--ocaso-gray-200) !important;
}

.navbar-top .form-control {
    font-size: 16px;
    border-radius: 24px;
    border: 2px solid var(--ocaso-gray-200);
    padding: 8px 40px 8px 16px;
    transition: border-color 0.2s;
}

.navbar-top .form-control:focus {
    border-color: var(--ocaso-blue);
    box-shadow: 0 0 0 3px rgba(0,51,150,0.1);
}

.navbar-top .btn {
    border-radius: 8px;
}

#resultadosBusqueda {
    z-index: 1050 !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12) !important;
    border: 1px solid var(--ocaso-gray-200) !important;
    margin-top: 6px !important;
}

.search-result-item {
    transition: background 0.15s;
    border-bottom: 1px solid var(--ocaso-gray-100) !important;
}

.search-result-item:hover {
    background-color: var(--ocaso-blue-050) !important;
}

.search-result-item:last-child {
    border-bottom: none !important;
}

/* ========== BUTTONS ========== */
.btn-primary,
.btn-danger {
    background-color: var(--ocaso-blue) !important;
    border-color: var(--ocaso-blue) !important;
}

.btn-primary:hover,
.btn-danger:hover {
    background-color: var(--ocaso-blue-light) !important;
    border-color: var(--ocaso-blue-light) !important;
}

.btn-outline-secondary {
    color: var(--ocaso-gray-600);
    border-color: var(--ocaso-gray-300);
}

.btn-outline-secondary:hover {
    background-color: var(--ocaso-gray-100);
    color: var(--ocaso-gray-900);
}

.btn-outline-danger {
    color: var(--ocaso-red);
    border-color: var(--ocaso-red);
}

.btn-outline-danger:hover {
    background-color: var(--ocaso-red);
    border-color: var(--ocaso-red);
    color: white;
}

.btn {
    border-radius: 8px;
    font-weight: 500;
}

/* ========== CARDS ========== */
.card {
    border-radius: 12px;
    border: 1px solid var(--ocaso-gray-200);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    overflow: hidden;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    background: var(--ocaso-gray-50) !important;
    border-bottom: 1px solid var(--ocaso-gray-200);
    font-weight: 600;
}

.card-header.bg-white {
    background: white !important;
}

/* ========== BADGES ========== */
.badge.bg-danger {
    background-color: var(--ocaso-red) !important;
}

.badge.bg-success {
    background-color: var(--ocaso-green) !important;
}

.badge.bg-warning {
    background-color: var(--ocaso-gold) !important;
    color: #4a3800 !important;
}

.badge.bg-info {
    background-color: var(--ocaso-blue-100) !important;
    color: var(--ocaso-blue-dark) !important;
}

.badge.bg-secondary {
    background-color: var(--ocaso-gray-200) !important;
    color: var(--ocaso-gray-600) !important;
}

.badge.bg-primary {
    background-color: var(--ocaso-blue) !important;
    color: white !important;
}

/* ========== TABLES ========== */
.table > thead {
    border-bottom: 2px solid var(--ocaso-blue-100);
}

.table thead th {
    color: var(--ocaso-gray-600);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-hover tbody tr:hover {
    background-color: var(--ocaso-blue-050);
}

.table th {
    white-space: nowrap;
}

.table td code {
    color: var(--ocaso-blue);
    background: var(--ocaso-blue-050);
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ========== PAGINATION ========== */
.page-link {
    color: var(--ocaso-blue);
    border-radius: 8px !important;
    margin: 0 2px;
    border: 1px solid var(--ocaso-gray-200);
}

.page-item.active .page-link {
    background-color: var(--ocaso-blue);
    border-color: var(--ocaso-blue);
    color: white;
}

/* ========== FORMS ========== */
.form-control, .form-select {
    font-size: 16px;
    border-radius: 8px;
    border: 1px solid var(--ocaso-gray-300);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--ocaso-blue);
    box-shadow: 0 0 0 3px rgba(0,51,150,0.15);
}

@media (min-width: 768px) {
    .form-control-sm, .form-select-sm {
        font-size: 14px;
    }
}

.form-label {
    font-weight: 500;
    color: var(--ocaso-gray-600);
    font-size: 0.85rem;
}

/* ========== LOGIN ========== */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ocaso-blue-dark) 0%, var(--ocaso-blue) 40%, #0045cc 100%);
    padding: 20px;
}

.login-card {
    width: 400px;
    max-width: 100%;
}

/* ========== NAV TABS ========== */
.nav-tabs .nav-link {
    color: var(--ocaso-gray-600);
    font-weight: 500;
    border: none;
    padding: 10px 16px;
    border-bottom: 3px solid transparent;
}

.nav-tabs .nav-link:hover {
    border-bottom-color: var(--ocaso-gray-300);
}

.nav-tabs .nav-link.active {
    color: var(--ocaso-blue);
    border-bottom-color: var(--ocaso-blue);
    background: transparent;
}

/* ========== ALERTS ========== */
.alert {
    border-radius: 8px;
    border: none;
}

.alert-success {
    background: #e6f7f0;
    color: #005b3f;
}

.alert-danger {
    background: var(--ocaso-red-light);
    color: #8f0019;
}

.alert-warning {
    background: #fff4e0;
    color: #4a3800;
}

/* ========== MODALS ========== */
.modal-content {
    border-radius: 12px;
    border: none;
}

.modal-header {
    border-bottom: 1px solid var(--ocaso-gray-200);
}

.modal-footer {
    border-top: 1px solid var(--ocaso-gray-200);
}

/* ========== PROGRESS ========== */
.progress {
    background: var(--ocaso-gray-200);
    border-radius: 10px;
}

.progress-bar {
    border-radius: 10px;
}

.progress-bar.bg-info {
    background-color: var(--ocaso-blue) !important;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--ocaso-gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--ocaso-gray-400);
    border-radius: 3px;
}

/* ========== DARK MODE ========== */
[data-bs-theme="dark"] {
    --bs-body-bg: #0d1b2a;
    --bs-body-color: #e0e6ed;
    --bs-border-color: #1e3a5f;
}

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .navbar-top,
[data-bs-theme="dark"] #bottomNav,
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light {
    background-color: #112240 !important;
    color: #e0e6ed;
    border-color: #1e3a5f;
}

[data-bs-theme="dark"] .card-header {
    background-color: #0a1929 !important;
    border-color: #1e3a5f;
}

[data-bs-theme="dark"] .card-header.bg-white {
    background-color: #112240 !important;
}

[data-bs-theme="dark"] .table > thead {
    border-color: #1e3a5f;
}

[data-bs-theme="dark"] .table-light {
    background-color: #0a1929 !important;
}

[data-bs-theme="dark"] .text-dark {
    color: #e0e6ed !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #7b8ba3 !important;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #112240;
    border-color: #1e3a5f;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e0e6ed;
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: #1a365d;
}

[data-bs-theme="dark"] #resultadosBusqueda {
    background-color: #112240 !important;
    border-color: #1e3a5f !important;
}

[data-bs-theme="dark"] .search-result-item {
    color: #e0e6ed;
    border-color: #1e3a5f !important;
}

[data-bs-theme="dark"] .search-result-item:hover {
    background-color: #1a365d !important;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: transparent;
    color: #e0e6ed;
}

[data-bs-theme="dark"] .alert-success {
    background: rgba(0,166,106,0.15);
    color: #33b984;
}

[data-bs-theme="dark"] .alert-danger {
    background: rgba(224,0,43,0.15);
    color: #e63352;
}

[data-bs-theme="dark"] .alert-warning {
    background: rgba(251,190,33,0.15);
    color: #fbbe21;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0a1929;
    border-color: #1e3a5f;
    color: #e0e6ed;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #0a1929;
    border-color: var(--ocaso-blue);
}

[data-bs-theme="dark"] table td code {
    background: rgba(0,51,150,0.2);
    color: #659aff;
}

[data-bs-theme="dark"] #bottomNav {
    background: #0a1929;
    border-color: #1e3a5f;
}

/* ========== HTMX ========== */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

/* ========== PRINT ========== */
@media print {
    #sidebar-wrapper, #bottomNav, #sidebar-backdrop,
    .navbar-top, .btn, form { display: none !important; }
    #page-content-wrapper { margin-left: 0 !important; width: 100% !important; }
}

/* ========== LAYOUT ========== */

#sidebar-wrapper {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    transition: transform 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1030;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, var(--ocaso-blue) 0%, var(--ocaso-blue-dark) 100%) !important;
    color: white !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
    display: flex;
    flex-direction: column;
}

#sidebar-wrapper::-webkit-scrollbar {
    width: 4px;
}

#sidebar-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

#sidebar-wrapper .list-group-flush {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
}

#sidebar-wrapper .list-group-flush::-webkit-scrollbar {
    display: none;
}

#sidebar-wrapper.collapsed {
    transform: translateX(-100%);
}

#sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1029;
    transition: opacity 0.2s;
}

#sidebar-backdrop.show {
    display: block;
}

#page-content-wrapper {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
}

#sidebar-wrapper.collapsed ~ #page-content-wrapper {
    margin-left: 0;
}

#bottomNav { display: none !important; }


/* ========== UTILITY ========== */

@media (max-width: 767.98px) {
    .hide-mobile { display: none; }
    h4 { font-size: 1.25rem; }
    .card .display-6, .card h2, .card h3 { font-size: 1.4rem; }
    .table { font-size: 0.85rem; }
    .table th, .table td { padding: 6px 8px; }
    .btn-sm { padding: 6px 12px; font-size: 0.85rem; }
    .modal-dialog { margin: 8px; }
    .navbar-top .position-relative { max-width: calc(100vw - 100px); }
    .table-responsive { margin: 0 -12px; width: calc(100% + 24px); }
}

@media (min-width: 768px) {
    .form-control-sm, .form-select-sm { font-size: 14px; }
}

/* ========================================================================== */
/* MODERN WORKSPACE THEME                                                     */
/* ========================================================================== */

html { scroll-behavior: smooth; }

body {
    color: var(--text-body);
    background:
        radial-gradient(circle at 100% 0, rgba(37, 99, 235, .035), transparent 28rem),
        var(--ocaso-bg);
    font-size: .9375rem;
    line-height: 1.55;
}

h1, h2, h3, h4, h5, h6,
.navbar-brand {
    font-family: 'Manrope', 'DM Sans', sans-serif;
    color: var(--text-strong);
    letter-spacing: -.025em;
}

a { color: var(--brand-primary); }
a:hover { color: var(--ocaso-blue-light); }

::selection { color: #fff; background: var(--brand-primary); }

.app-container {
    width: min(100% - 48px, 1540px);
    margin-inline: auto;
}

.app-main { padding-block: 28px 48px; }

/* Brand */
.brand-lockup {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.brand-mark {
    position: relative;
    display: inline-flex;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(145deg, #4f8cff, var(--brand-primary));
    box-shadow: 0 8px 22px rgba(37, 99, 235, .34), inset 0 1px rgba(255, 255, 255, .25);
    font: 800 1.15rem/1 'Manrope', sans-serif;
}

.brand-mark::after {
    content: '';
    position: absolute;
    top: 7px;
    right: 7px;
    width: 5px;
    height: 5px;
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 50%;
}

.brand-copy { display: grid; line-height: 1.05; min-width: 0; }
.brand-copy strong { color: #fff; font: 800 1rem/1.2 'Manrope', sans-serif; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; }
.brand-copy small { color: rgba(255, 255, 255, .48); font-size: .68rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }

/* Sidebar */
#sidebar-wrapper {
    padding: 14px;
    border: 0 !important;
    background:
        radial-gradient(circle at 20% 0, rgba(58, 104, 255, .22), transparent 22rem),
        linear-gradient(180deg, #0c1835 0%, #081126 100%) !important;
    box-shadow: 14px 0 44px rgba(8, 17, 38, .08);
}

.sidebar-heading {
    padding: 9px 8px 16px;
    border: 0 !important;
    text-align: left !important;
}

.tenant-logo { display: block; max-width: 170px; max-height: 46px; object-fit: contain; }

.tenant-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    max-width: 100%;
    margin-top: 17px;
    padding: 6px 9px;
    color: rgba(255, 255, 255, .72);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 9px;
    font-size: .7rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-pill > span {
    flex: 0 0 6px;
    width: 6px;
    height: 6px;
    background: #34d399;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, .12);
}

.sidebar-user {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 26px 26px;
    align-items: center;
    gap: 7px;
    margin: 0 0 17px;
    padding: 10px;
    background: rgba(255, 255, 255, .055);
    border: 1px solid rgba(255, 255, 255, .065);
    border-radius: 13px;
}

.user-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: #dbeafe;
    background: linear-gradient(145deg, rgba(75, 132, 255, .42), rgba(37, 99, 235, .2));
    border: 1px solid rgba(147, 197, 253, .24);
    border-radius: 10px;
    font: 700 .82rem/1 'Manrope', sans-serif;
}

.user-copy { display: grid; min-width: 0; line-height: 1.2; }
.user-copy strong { color: rgba(255, 255, 255, .9); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { color: rgba(255, 255, 255, .4); font-size: .62rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-icon-link {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    color: rgba(255, 255, 255, .42);
    border-radius: 7px;
    text-decoration: none;
    transition: .2s ease;
}
.sidebar-icon-link:hover { color: #fff; background: rgba(255, 255, 255, .09); }

.sidebar-section-label {
    padding: 0 11px 7px;
    color: rgba(255, 255, 255, .3);
    font-size: .61rem;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}

#sidebar-wrapper .sidebar-nav { gap: 2px; margin: 0; padding-right: 2px; }

#sidebar-wrapper .list-group-item {
    display: flex;
    min-height: 40px;
    align-items: center;
    margin: 0;
    padding: 8px 10px;
    color: rgba(226, 232, 240, .68) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 10px !important;
    font-size: .79rem;
    font-weight: 600;
    letter-spacing: -.005em;
}

#sidebar-wrapper .list-group-item::after {
    content: '';
    width: 4px;
    height: 4px;
    margin-left: auto;
    background: transparent;
    border-radius: 50%;
}

#sidebar-wrapper .list-group-item i {
    display: grid;
    flex: 0 0 27px;
    width: 27px;
    height: 27px;
    margin-right: 8px !important;
    place-items: center;
    color: rgba(191, 219, 254, .55);
    background: rgba(255, 255, 255, .035);
    border-radius: 8px;
    font-size: .91rem;
}

#sidebar-wrapper .list-group-item:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, .055) !important;
    transform: translateX(2px);
}

#sidebar-wrapper .list-group-item.active {
    color: #fff !important;
    background: linear-gradient(90deg, rgba(52, 112, 255, .26), rgba(52, 112, 255, .09)) !important;
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .12);
}

#sidebar-wrapper .list-group-item.active i {
    color: #fff;
    background: var(--brand-primary);
    box-shadow: 0 5px 14px rgba(37, 99, 235, .3);
}
#sidebar-wrapper .list-group-item.active::after { background: #60a5fa; box-shadow: 0 0 0 3px rgba(96, 165, 250, .12); }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 12px;
    padding: 11px;
    color: rgba(255, 255, 255, .48);
    background: rgba(255, 255, 255, .035);
    border-radius: 11px;
    font-size: .66rem;
    line-height: 1.25;
}
.sidebar-footer > i { color: #34d399; font-size: .95rem; }
.sidebar-footer small { color: rgba(255, 255, 255, .28); }

#sidebarClose { margin: 0 !important; border: 0 !important; background: rgba(255,255,255,.07); }

/* Top bar */
.navbar-top {
    min-height: 72px;
    padding: 11px 24px;
    gap: 12px;
    background: rgba(255, 255, 255, .82) !important;
    border-bottom: 1px solid rgba(226, 232, 240, .82) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .8);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.topbar-context { display: grid; min-width: 180px; flex-direction: column; justify-content: center; line-height: 1.1; }
.topbar-context .context-eyebrow { color: var(--text-muted); font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.topbar-context strong { color: var(--text-strong); font: 700 .8rem/1.4 'Manrope', sans-serif; }

.global-search { max-width: 620px; margin: 0 auto; min-width: 0; }
.search-leading-icon { position: absolute; z-index: 2; left: 15px; top: 50%; color: #94a3b8; transform: translateY(-50%); pointer-events: none; }

.navbar-top .global-search .form-control {
    height: 44px;
    padding: 8px 42px 8px 43px;
    color: var(--text-strong);
    background: #f4f6fa;
    border: 1px solid transparent;
    border-radius: 13px;
    font-size: .83rem;
}
.navbar-top .global-search .form-control::placeholder { color: #98a4b7; }
.navbar-top .global-search .form-control:focus { background: var(--surface); border-color: rgba(37, 99, 235, .32); box-shadow: 0 0 0 4px rgba(37, 99, 235, .07), var(--shadow-sm); }

.tenant-switcher { height: 40px; padding-inline: 13px; border-radius: 11px !important; }

.theme-control { flex: 0 0 auto; }
.theme-toggle {
    display: grid;
    width: 40px;
    height: 40px;
    margin: 0;
    place-items: center;
    color: var(--text-muted);
    background: var(--surface-soft);
    border: 1px solid var(--border-subtle);
    border-radius: 11px;
    cursor: pointer;
    transition: .2s ease;
}
.theme-toggle:hover { color: var(--brand-primary); background: #fff; transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.sidebar-toggle {
    position: fixed;
    z-index: 1050;
    top: 14px;
    left: 12px;
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
    color: white;
    background: #0c1835;
    border: 0;
    border-radius: 11px;
    box-shadow: var(--shadow-md);
}

#resultadosBusqueda {
    top: calc(100% + 4px);
    padding: 6px;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 14px !important;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .14) !important;
}
.search-result-item { padding: 10px 12px !important; border: 0 !important; border-radius: 9px; }

/* Shared components */
.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--brand-primary);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
}
.page-header h1 { margin: 0; font-size: clamp(1.55rem, 2vw, 2rem); font-weight: 800; }
.page-header p { margin: 5px 0 0; color: var(--text-muted); }
.page-header-meta > span,
.period-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    font-size: .72rem;
    font-weight: 600;
}
.month-picker-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
}
.month-picker-toggle:hover { color: var(--brand-primary); border-color: var(--brand-primary); }
.month-picker-toggle i:first-child { color: var(--brand-primary); }
.month-picker-menu { min-width: 220px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.card:hover { border-color: #dde3ed; }
.card-header {
    padding: 16px 18px;
    color: var(--text-strong);
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
}
.card-body { padding: 18px; }

.surface-card { overflow: hidden; }
.surface-card-header { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 16px; }
.surface-card-header h2 { margin: 0; font-size: 1rem; font-weight: 750; }
.header-icon { display: grid; width: 36px; height: 36px; place-items: center; color: var(--brand-primary); background: rgba(37, 99, 235, .08); border-radius: 10px; }

.btn {
    min-height: 38px;
    padding: 7px 14px;
    border-radius: 10px;
    font-size: .82rem;
    font-weight: 650;
    transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary, .btn-danger {
    background: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    box-shadow: 0 5px 14px rgba(37, 99, 235, .18);
}
.btn-primary:hover, .btn-danger:hover { filter: brightness(1.07); box-shadow: 0 8px 20px rgba(37, 99, 235, .23); }
.btn-light, .btn-outline-secondary, .btn-outline-primary { border-color: var(--border-subtle); }

.form-control, .form-select {
    min-height: 42px;
    color: var(--text-strong);
    background-color: var(--surface);
    border: 1px solid #dce2ec;
    border-radius: 10px;
    font-size: .875rem;
}
.form-control::placeholder { color: #a1abba; }
.form-control:hover, .form-select:hover { border-color: #c6cfdd; }
.form-control:focus, .form-select:focus { border-color: rgba(37, 99, 235, .55); box-shadow: 0 0 0 4px rgba(37, 99, 235, .08); }
.form-label { margin-bottom: 6px; color: #526078; font-size: .76rem; font-weight: 650; }

.table { --bs-table-bg: transparent; color: var(--text-body); }
.table > thead { border: 0; }
.table thead th {
    padding: 11px 14px;
    color: #8490a4;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border-subtle);
    font-size: .65rem;
    letter-spacing: .08em;
}
.table tbody td { padding: 12px 14px; border-color: var(--border-subtle); vertical-align: middle; }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: rgba(248, 250, 252, .75); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(37, 99, 235, .035); }
.table-responsive { border-radius: inherit; }

.badge { padding: .42em .68em; border-radius: 7px; font-size: .68rem; font-weight: 650; }
.alert { border: 1px solid transparent; border-radius: 11px; box-shadow: var(--shadow-sm); }
.alert-success { border-color: rgba(16, 185, 129, .16); }
.alert-danger { border-color: rgba(239, 68, 68, .14); }
.alert-warning { border-color: rgba(245, 158, 11, .16); }
.modal-content { border: 1px solid var(--border-subtle); border-radius: 18px; box-shadow: 0 24px 70px rgba(15, 23, 42, .18); }
.dropdown-menu { padding: 6px; border: 1px solid var(--border-subtle); border-radius: 12px; box-shadow: var(--shadow-md); }
.dropdown-item { padding: 8px 10px; border-radius: 8px; font-size: .82rem; }
.nav-tabs { gap: 5px; border-bottom-color: var(--border-subtle); }
.nav-tabs .nav-link { padding: 9px 12px; border: 0; border-radius: 9px 9px 0 0; font-size: .8rem; }

/* Dashboard */
.metric-card {
    position: relative;
    height: 100%;
    min-height: 164px;
    padding: 17px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.metric-card::before { content: ''; position: absolute; right: -28px; bottom: -38px; width: 100px; height: 100px; background: var(--metric-soft); border-radius: 50%; opacity: .65; }
.metric-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--metric-color) 25%, var(--border-subtle)); box-shadow: var(--shadow-md); }
.metric-primary { --metric-color: var(--brand-primary); --metric-soft: rgba(37, 99, 235, .1); }
.metric-violet { --metric-color: #8b5cf6; --metric-soft: rgba(139, 92, 246, .1); }
.metric-success { --metric-color: #0f9f83; --metric-soft: rgba(15, 159, 131, .1); }
.metric-danger { --metric-color: #ef5b67; --metric-soft: rgba(239, 91, 103, .1); }
.metric-top { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 15px; }
.metric-icon { display: grid; width: 38px; height: 38px; place-items: center; color: var(--metric-color); background: var(--metric-soft); border-radius: 11px; font-size: 1rem; }
.metric-trend { color: var(--text-muted); font-size: .64rem; font-weight: 600; white-space: nowrap; }
.metric-trend i { color: var(--metric-color); }
.metric-value { position: relative; z-index: 1; display: block; color: var(--text-strong); font: 800 clamp(1.5rem, 2.5vw, 2rem)/1.1 'Manrope', sans-serif; letter-spacing: -.04em; }
.metric-value small { margin-left: 2px; color: var(--text-muted); font-size: .8rem; font-weight: 700; }
.metric-label { position: relative; z-index: 1; display: block; margin-top: 6px; color: var(--text-muted); font-size: .72rem; font-weight: 500; }
.chart-body { position: relative; height: 330px; padding: 18px 20px 14px; }
.branch-list { display: grid; max-height: 330px; overflow-y: auto; }
.branch-list::-webkit-scrollbar { width: 6px; }
.branch-list::-webkit-scrollbar-track { background: transparent; }
.branch-list::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }
.branch-row { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 13px 18px; border-bottom: 1px solid var(--border-subtle); }
.branch-row:last-child { border-bottom: 0; }
.branch-dot { width: 8px; height: 8px; background: var(--brand-primary); border-radius: 3px; }
.branch-row:nth-child(4n+2) .branch-dot { background: #8b5cf6; }
.branch-row:nth-child(4n+3) .branch-dot { background: #14b8a6; }
.branch-row:nth-child(4n+4) .branch-dot { background: #f59e0b; }
.branch-copy { display: grid; line-height: 1.25; }
.branch-copy strong { color: var(--text-strong); font-size: .78rem; }
.branch-copy small { color: var(--text-muted); font-size: .65rem; }
.branch-value { color: var(--text-strong); font: 700 .78rem/1 'Manrope', sans-serif; }
.client-avatar { display: inline-grid; width: 30px; height: 30px; margin-right: 10px; place-items: center; color: var(--brand-primary); background: rgba(37, 99, 235, .08); border-radius: 9px; font-size: .7rem; font-weight: 700; }
.modern-table tbody strong { color: var(--text-strong); font-size: .78rem; }
.amount-value { color: var(--text-strong); font: 700 .78rem/1 'Manrope', sans-serif; }
.empty-state { display: grid; place-items: center; color: var(--text-muted); text-align: center; }
.empty-state.compact { min-height: 125px; padding: 24px; }
.empty-state i { margin-bottom: 7px; color: #b0bac9; font-size: 1.5rem; }
.empty-state p { margin: 0; font-size: .75rem; }

/* Authentication */
.login-page {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 28px;
    overflow: hidden;
    background: #edf2f9;
}
.login-ambient { position: absolute; border-radius: 50%; filter: blur(4px); pointer-events: none; }
.login-ambient-one { top: -18rem; left: -16rem; width: 38rem; height: 38rem; background: rgba(37, 99, 235, .09); }
.login-ambient-two { right: -12rem; bottom: -16rem; width: 32rem; height: 32rem; background: rgba(20, 184, 166, .07); }
.login-shell {
    position: relative;
    display: grid;
    grid-template-columns: minmax(400px, .92fr) minmax(450px, 1.08fr);
    width: min(1120px, 100%);
    min-height: min(720px, calc(100dvh - 56px));
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 26px;
    box-shadow: 0 32px 90px rgba(42, 58, 90, .16);
}
.login-story {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 38px 40px 30px;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(circle at 90% 10%, rgba(63, 128, 255, .38), transparent 20rem),
        radial-gradient(circle at 0 90%, rgba(20, 184, 166, .14), transparent 20rem),
        linear-gradient(155deg, #0e204a 0%, #09142f 62%, #071126 100%);
}
.login-story::after { content: ''; position: absolute; right: -75px; bottom: -100px; width: 300px; height: 300px; border: 1px solid rgba(255,255,255,.07); border-radius: 50%; box-shadow: 0 0 0 42px rgba(255,255,255,.025), 0 0 0 86px rgba(255,255,255,.018); }
.login-story > * { position: relative; z-index: 1; }
.login-story-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login-edition { padding: 6px 9px; color: rgba(219, 234, 254, .72); background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 8px; font-size: .62rem; font-weight: 650; }
.eyebrow-light { display: block; margin-bottom: 14px; color: #85abff; font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.login-story-content { max-width: 410px; margin-top: 30px; }
.login-story-content h1 { margin: 0; color: #fff; font-size: clamp(2.3rem, 4.3vw, 4rem); font-weight: 800; line-height: 1.04; letter-spacing: -.06em; }
.login-story-content h1 span { color: #74a2ff; }
.login-story-content > p { max-width: 390px; margin: 21px 0 30px; color: rgba(226, 232, 240, .62); font-size: .92rem; line-height: 1.65; }
.login-benefits { display: grid; gap: 13px; }
.login-benefits > div { display: flex; align-items: center; gap: 12px; }
.login-benefits > div > i { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; color: #8eb2ff; background: rgba(96, 165, 250, .1); border: 1px solid rgba(147, 197, 253, .1); border-radius: 10px; }
.login-benefits span { display: grid; line-height: 1.35; }
.login-benefits strong { color: rgba(255,255,255,.88); font-size: .76rem; }
.login-benefits small { color: rgba(255,255,255,.39); font-size: .67rem; }
.login-story-footer { display: flex; justify-content: space-between; color: rgba(255,255,255,.3); font-size: .62rem; }
.login-story-footer span:first-child { display: flex; align-items: center; gap: 6px; }
.login-story-footer i { color: #34d399; }
.login-form-panel { position: relative; display: grid; grid-template-rows: 1fr auto; place-items: center; padding: 50px clamp(35px, 5vw, 76px) 22px; background: #fff; }
.login-form-wrap { width: 100%; max-width: 430px; }
.login-mobile-brand { display: none; }
.login-heading { display: flex; align-items: center; gap: 13px; }
.login-office-icon { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; color: var(--brand-primary); background: rgba(37, 99, 235, .08); border-radius: 13px; font-size: 1.05rem; }
.login-heading .eyebrow { margin-bottom: 1px; }
.login-heading h2 { margin: 0; font-size: 1.55rem; font-weight: 800; }
.login-subtitle { margin: 14px 0 28px; color: var(--text-muted); font-size: .83rem; }
.login-subtitle strong { color: var(--text-body); }
.login-form { display: grid; gap: 18px; }
.form-field { display: grid; }
.input-icon-wrap { position: relative; }
.input-icon-wrap > i { position: absolute; z-index: 1; top: 50%; left: 14px; color: #9aa6b9; transform: translateY(-50%); }
.input-icon-wrap .form-control { height: 48px; padding-left: 42px; border-radius: 12px; }
.form-hint { margin-top: 5px; color: #9aa6b9; font-size: .64rem; }
.login-help-link { margin-bottom: 6px; font-size: .68rem; font-weight: 650; text-decoration: none; }
.login-submit { display: flex; height: 49px; align-items: center; justify-content: space-between; margin-top: 3px; padding-inline: 18px; border-radius: 12px; }
.login-submit i { transition: transform .2s ease; }
.login-submit:hover i { transform: translateX(3px); }
.login-change-office { display: flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; color: var(--text-muted); border: 1px dashed var(--border-subtle); border-radius: 12px; font-size: .74rem; font-weight: 650; text-decoration: none; }
.login-change-office:hover { color: var(--brand-primary); border-color: var(--brand-primary); background: rgba(37, 99, 235, .04); }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0 15px; color: #98a4b6; font-size: .64rem; }
.login-divider::before, .login-divider::after { content: ''; height: 1px; flex: 1; background: var(--border-subtle); }
.btn-portal-access { display: flex; min-height: 58px; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; color: var(--text-body); background: #f8fafc; border: 1px solid var(--border-subtle); text-align: left; }
.btn-portal-access:hover { color: var(--text-strong); background: #fff; border-color: #d4dce8; box-shadow: var(--shadow-sm); }
.portal-access-icon { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; color: #0f9f83; background: rgba(15, 159, 131, .08); border-radius: 10px; }
.btn-portal-access > span:nth-child(2) { display: grid; line-height: 1.3; }
.btn-portal-access strong { font-size: .73rem; }
.btn-portal-access small { color: var(--text-muted); font-size: .62rem; }
.btn-portal-access > i { color: #a0aabd; font-size: .72rem; }
.login-legal { align-self: end; margin-top: 28px; color: #a1abba; font-size: .59rem; text-align: center; }

/* Dark theme */
[data-bs-theme="dark"] {
    --ocaso-bg: #09111f;
    --surface: #101b2e;
    --surface-soft: #0c1728;
    --text-strong: #edf3ff;
    --text-body: #c2ccdc;
    --text-muted: #8190a8;
    --border-subtle: #1d2b42;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.16), 0 5px 18px rgba(0,0,0,.1);
    --shadow-md: 0 15px 38px rgba(0,0,0,.22);
}
[data-bs-theme="dark"] body { background: radial-gradient(circle at 100% 0, rgba(37,99,235,.08), transparent 30rem), var(--ocaso-bg); color: var(--text-body); }
[data-bs-theme="dark"] .navbar-top { background: rgba(16, 27, 46, .84) !important; border-color: var(--border-subtle) !important; box-shadow: none; }
[data-bs-theme="dark"] .navbar-top .global-search .form-control,
[data-bs-theme="dark"] .theme-toggle { background: var(--surface-soft); border-color: var(--border-subtle); }
[data-bs-theme="dark"] .navbar-top .global-search .form-control:focus { background: var(--surface); }
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .metric-card,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] #resultadosBusqueda { background: var(--surface) !important; border-color: var(--border-subtle) !important; color: var(--text-body); }
[data-bs-theme="dark"] .table thead th { background: var(--surface-soft); }
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select { color: var(--text-strong); background: var(--surface-soft); border-color: var(--border-subtle); }
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus { background: var(--surface-soft); }
[data-bs-theme="dark"] .btn-portal-access { color: var(--text-body); background: var(--surface-soft); border-color: var(--border-subtle); }
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: rgba(255,255,255,.012); }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(96,165,250,.045); }

/* Responsive */
@media (max-width: 1100px) {
    .login-shell { grid-template-columns: minmax(350px, .85fr) minmax(420px, 1.15fr); }
    .login-story { padding-inline: 32px; }
    .login-story-content h1 { font-size: 2.7rem; }
}

@media (max-width: 991.98px) {
    #sidebar-wrapper { width: min(292px, 88vw); }
    #page-content-wrapper { margin-left: 0 !important; }
    .navbar-top { padding-left: 62px; }
    .sidebar-toggle { display: grid; place-items: center; }
    .login-page { padding: 18px; }
    .login-shell { grid-template-columns: 1fr; width: min(570px, 100%); min-height: 0; }
    .login-story { display: none; }
    .login-form-panel { min-height: calc(100dvh - 36px); padding: 42px clamp(28px, 8vw, 60px) 20px; }
    .login-mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 42px; }
    .login-mobile-brand strong { color: var(--text-strong); font: 800 1rem/1 'Manrope', sans-serif; }
}

@media (max-width: 767.98px) {
    .app-container { width: min(100% - 28px, 1540px); }
    .app-main { padding-block: 22px 34px; }
    .navbar-top { min-height: 66px; padding-top: 9px; padding-right: 14px; padding-bottom: 9px; gap: 8px; }
    .tenant-switcher { width: 40px; padding: 0; overflow: hidden; color: transparent !important; }
    .tenant-switcher i { display: grid; width: 100%; color: var(--text-muted); place-items: center; }
    .global-search { max-width: none; }
    .navbar-top .global-search .form-control { height: 40px; }
    .theme-toggle { width: 38px; height: 38px; }
    .page-header { align-items: flex-start; margin-bottom: 20px; }
    .page-header-meta { display: none; }
    .page-header h1 { font-size: 1.45rem; }
    .page-header p { font-size: .78rem; }
    .metric-card { min-height: 142px; padding: 14px; }
    .metric-top { margin-bottom: 12px; }
    .metric-icon { width: 34px; height: 34px; }
    .metric-trend { max-width: 68px; overflow: hidden; text-overflow: ellipsis; }
    .chart-body { height: 280px; padding-inline: 12px; }
    .branch-list { max-height: 280px; }
    .surface-card-header { min-height: 66px; padding: 14px; }
    .table-responsive { margin: 0; width: 100%; }
}

@media (max-width: 520px) {
    .login-page { padding: 0; background: #fff; }
    .login-shell { min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
    .login-form-panel { min-height: 100dvh; padding: 32px 22px 18px; }
    .login-mobile-brand { margin-bottom: 34px; }
    .login-heading h2 { font-size: 1.35rem; }
    .login-legal { font-size: .55rem; }
    .metric-trend { display: none; }
    .metric-card { min-height: 132px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
