:root {
    --color-income: #10B981;
    --color-expense: #EF4444;
    --color-warning: #F59E0B;
    --color-primary: #3B82F6;
}

* { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
body { background-color: #F8FAFC; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.fade-in   { animation: fadeIn .45s ease-out forwards; }
.fade-d1   { animation: fadeIn .45s ease-out .08s  forwards; opacity: 0; }
.fade-d2   { animation: fadeIn .45s ease-out .16s  forwards; opacity: 0; }
.fade-d3   { animation: fadeIn .45s ease-out .24s  forwards; opacity: 0; }
.fade-d4   { animation: fadeIn .45s ease-out .32s  forwards; opacity: 0; }

/* Loader */
.loader {
    width: 36px; height: 36px;
    border: 3px solid #E2E8F0;
    border-top-color: #3B82F6;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.loader-sm { width: 18px; height: 18px; border-width: 2px; }

/* Progress bar */
.progress-track {
    height: 7px; border-radius: 4px;
    background: #E2E8F0; overflow: hidden;
}
.progress-fill {
    height: 100%; border-radius: 4px;
    transition: width 1s ease-out;
}

/* Card hover */
.card-hover {
    transition: transform .2s, box-shadow .2s;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -4px rgb(0 0 0 / .08);
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ApexCharts tweaks */
.apexcharts-tooltip { font-family: 'Inter', sans-serif !important; }

/* ============================================================
   AUTH — Login page styles
   ============================================================ */

/* Left panel gradient (cyan → blue → deep navy) */
.auth-brand-bg {
    background: linear-gradient(160deg, #0e3a6b 0%, #0a1c3b 50%, #10173a 100%);
}

/* Fade-in for login card */
@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.auth-fade-in {
    animation: authFadeIn 0.5s ease-out forwards;
}

/* Input focus states */
.auth-input:focus {
    background-color: #ffffff;
    border-color: #0b6bcb;
    box-shadow: 0 0 0 3px rgba(11, 107, 203, 0.1);
}

/* Primary button (gradient matching logo) */
.auth-btn-primary {
    background: linear-gradient(135deg, #0b6bcb 0%, #0a56a8 60%, #3b2e8a 100%);
    box-shadow: 0 2px 12px rgba(11, 107, 203, 0.25);
}
.auth-btn-primary:hover {
    background: linear-gradient(135deg, #0a5eb4 0%, #094a94 60%, #332778 100%);
    box-shadow: 0 4px 16px rgba(11, 107, 203, 0.35);
    transform: translateY(-1px);
}
.auth-btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 6px rgba(11, 107, 203, 0.2);
}
.auth-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   SIDEBAR LAYOUT SYSTEM
   ============================================================ */

/* ── Body push ─────────────────────────────────────── */
.ls-app {
    padding-left: 240px;
    transition: padding-left 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
.ls-app.sidebar-collapsed {
    padding-left: 64px;
}
@media (max-width: 1023px) {
    .ls-app, .ls-app.sidebar-collapsed { padding-left: 0 !important; }
}

/* ── Sidebar container ─────────────────────────────── */
#sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    background: #ffffff;
    border-right: 1px solid #E2E8F0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar.collapsed { width: 64px; }

@media (max-width: 1023px) {
    #sidebar {
        width: 240px !important;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }
    #sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
    }
}

/* ── Header ────────────────────────────────────────── */
.sb-header {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid #F1F5F9;
    flex-shrink: 0;
    overflow: hidden;
    transition: padding 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar.collapsed .sb-header { padding: 0; justify-content: center; }

.sb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
    transition: gap 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar.collapsed .sb-brand { gap: 0; justify-content: center; }

.sb-logo {
    width: 32px; height: 32px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
}
.sb-brand-text { display: flex; flex-direction: column; min-width: 0; }
.sb-title { font-size: 14px; font-weight: 700; color: #1E293B; line-height: 1.3; white-space: nowrap; }
.sb-subtitle { font-size: 10px; color: #94A3B8; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Toggle button (floating circle) ───────────────── */
.sb-toggle {
    position: absolute;
    right: -12px; top: 68px;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #E2E8F0;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50;
    color: #94A3B8;
    padding: 0;
    transition: color 200ms, background-color 200ms, box-shadow 200ms;
}
.sb-toggle:hover { color: #334155; background: #F8FAFC; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
@media (min-width: 1024px) { .sb-toggle { display: flex; } }

.sb-toggle-arrow {
    width: 14px; height: 14px;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar.collapsed .sb-toggle-arrow { transform: rotate(180deg); }

/* ── Navigation ────────────────────────────────────── */
.sb-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: padding 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar.collapsed .sb-nav { padding: 16px 8px; }

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #64748B;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    transition: all 200ms ease;
}
.nav-link:hover { color: #1E293B; background: #F8FAFC; }
.nav-link.active { color: #2563EB; background: #EFF6FF; }
.nav-link.active .nav-icon { color: #2563EB; }

#sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
}

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ── Labels (collapse animation) ───────────────────── */
.nav-label {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 250ms ease 60ms, max-width 300ms cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    max-width: 180px;
}
#sidebar.collapsed .nav-label {
    opacity: 0;
    max-width: 0;
    transition: opacity 80ms ease, max-width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Tooltips ──────────────────────────────────────── */
.nav-tooltip {
    position: absolute;
    left: calc(100% + 16px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    background: #1E293B;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 150ms ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.nav-tooltip::before {
    content: '';
    position: absolute;
    top: 50%; right: 100%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #1E293B;
}
#sidebar:not(.collapsed) .nav-tooltip { display: none; }
#sidebar.collapsed .nav-link:hover .nav-tooltip { opacity: 1; }
@media (max-width: 1023px) { .nav-tooltip { display: none !important; } }

/* ── Footer (user section) ─────────────────────────── */
.sb-footer {
    border-top: 1px solid #F1F5F9;
    padding: 12px;
    flex-shrink: 0;
    overflow: hidden;
    transition: padding 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar.collapsed .sb-footer { padding: 12px 8px; }

.sb-user-link { gap: 10px !important; }
#sidebar.collapsed .sb-user-link { justify-content: center; padding: 10px 0; gap: 0 !important; }

.sb-user-info { display: flex; flex-direction: column; min-width: 0; }
.sb-user-name { font-size: 13px; font-weight: 600; color: #1E293B; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.sb-user-email { font-size: 10px; color: #94A3B8; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }

/* ── Mobile overlay ────────────────────────────────── */
#sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
}
#sidebar-overlay.active { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) { #sidebar-overlay { display: none; } }

/* ── Topbar ────────────────────────────────────────── */
#topbar {
    position: sticky;
    top: 0; z-index: 30;
    height: 56px;
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 8px;
}
.tb-hamburger {
    display: none;
    padding: 8px;
    border-radius: 8px;
    color: #64748B;
    cursor: pointer;
    background: none;
    border: none;
    transition: background-color 150ms, color 150ms;
}
.tb-hamburger:hover { background: #F1F5F9; color: #1E293B; }
@media (max-width: 1023px) { .tb-hamburger { display: flex; } }

.tb-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 12px;
    background: none;
    border: none;
    cursor: pointer;
    transition: background-color 150ms;
}
.tb-user-btn:hover { background: #F8FAFC; }

.tb-user-name-text {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tb-chevron { width: 16px; height: 16px; color: #94A3B8; transition: transform 200ms ease; }
@media (max-width: 640px) { .tb-user-name-text, .tb-chevron { display: none; } }

/* ── Topbar dropdown ───────────────────────────────── */
.tb-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 224px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px -4px rgba(0,0,0,.12), 0 4px 12px -2px rgba(0,0,0,.06);
    border: 1px solid #E2E8F0;
    padding: 4px 0;
    z-index: 60;
    transition: all 150ms ease;
}
.tb-dd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 13px;
    color: #475569;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    transition: background-color 100ms, color 100ms;
}
.tb-dd-item:hover { background: #F8FAFC; color: #1E293B; }
.tb-dd-logout { color: #DC2626; }
.tb-dd-logout:hover { background: #FEF2F2; color: #DC2626; }

/* ============================================================
   TRANSACTIONS PAGE
   ============================================================ */

.ls-transactions-layout {
    width: 100%;
    max-width: 100%;
}

.transactions-toolbar {
    row-gap: 0.5rem;
}

.transactions-table-shell {
    width: 100%;
}

.transactions-table-scroll {
    overflow-x: auto;
}

.transactions-table {
    width: 100%;
    min-width: 1120px;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
}

.transactions-table th,
.transactions-table td {
    vertical-align: top;
}

.transactions-description,
.transactions-subtext {
    max-width: 30rem;
    white-space: normal;
    word-break: break-word;
    line-height: 1.45;
}

.transactions-actions-cell {
    min-width: 15rem;
    white-space: nowrap;
    vertical-align: middle;
}

.acciones {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: nowrap;
    width: max-content;
    margin-left: auto;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #555;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
    background: #FFFFFF;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: #f1f3f5;
    color: #007bff;
    transform: scale(1.1);
}

.icon-btn:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

.icon-btn i {
    pointer-events: none;
}

.icon-btn.ver {
    color: #475569;
}

.icon-btn.descargar {
    color: #047857;
}

.icon-btn.adjuntar {
    color: #0F766E;
}

.icon-btn.editar {
    color: #2563EB;
}

.icon-btn.eliminar {
    color: #DC2626;
}

.input-file-hidden,
.input-file-hidden[type="file"] {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
    overflow: hidden !important;
    pointer-events: none !important;
    clip-path: inset(100%) !important;
}

@media (max-width: 767px) {
    .transactions-description,
    .transactions-subtext {
        max-width: 18rem;
    }

    .transactions-actions-cell {
        min-width: 15rem;
    }
}
