:root {
    --navy: #10213d;
    --ink: #19263b;
    --muted: #7e8a9e;
    --line: #e9edf3;
    --canvas: #f5f7fb
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    font-size: 14px
}

.app-shell {
    min-height: 100vh;
    display: flex
}

.sidebar {
    width: 258px;
    position: fixed;
    inset: 0 auto 0 0;
    background: var(--navy);
    color: #fff;
    padding: 27px 17px;
    display: flex;
    flex-direction: column
}

.brand, .login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    padding: 0 7px 32px
}

    .brand b, .login-brand b {
        font-size: 17px;
        letter-spacing: 1.2px;
        display: block
    }

    .brand small, .login-brand small {
        font-size: 9px;
        letter-spacing: 1.5px;
        color: #a9b6cc;
        display: block;
        margin-top: 4px
    }

.brand-mark {
    height: 42px;
    width: 42px;
    border-radius: 13px;
    background: #5279f4;
    display: grid;
    place-items: center;
    font-size: 15px;
    font-weight: 800;
    flex-shrink: 0
}

.nav-label, .eyebrow {
    font-size: 10px;
    letter-spacing: 1.4px;
    color: #8d9cb4;
    font-weight: 800
}

.nav-label {
    padding: 0 12px 12px
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 13px;
    color: #aebbd0;
    padding: 13px 14px;
    margin: 3px 0;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600
}

    .nav-link span {
        width: 20px;
        font-size: 18px;
        text-align: center
    }

    .nav-link.active {
        color: #fff;
        background: #2a4167;
        box-shadow: inset 3px 0 #6486ff
    }

.sidebar-bottom {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: auto;
    padding: 15px 8px;
    border-top: 1px solid #ffffff19;
    font-size: 11px
}

    .sidebar-bottom i {
        height: 8px;
        width: 8px;
        background: #36d49d;
        border-radius: 50%
    }

    .sidebar-bottom small {
        display: block;
        color: #93a4bd;
        margin-top: 4px
    }

.main-panel {
    margin-left: 258px;
    width: calc(100% - 258px);
    padding: 0 32px 20px
}

.topbar {
    height: 98px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e8ecf3;
    margin-bottom: 25px
}

    .topbar .eyebrow {
        color: #8a96aa
    }

    .topbar h1 {
        font-size: 23px;
        font-weight: 750;
        margin: 5px 0 0
    }

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px
}

    .user-menu b {
        font-size: 12px
    }

.avatar {
    height: 37px;
    width: 37px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e4eaff;
    color: #4265d8;
    font-weight: 800
}

.dashboard-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px
}

    .dashboard-intro h2 {
        font-size: 18px;
        font-weight: 750;
        margin: 0 0 5px
    }

    .dashboard-intro p, .card-heading p {
        margin: 0;
        color: var(--muted);
        font-size: 12px
    }

.date-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 13px
}

.date-icon {
    height: 32px;
    width: 32px;
    border-radius: 9px;
    background: #eef2ff;
    color: #5572d8;
    display: grid;
    place-items: center;
    font-size: 19px
}

.date-chip small {
    display: block;
    font-size: 8px;
    letter-spacing: 1px;
    color: var(--muted);
    font-weight: 800
}

.date-chip b {
    font-size: 11px;
    display: block;
    margin-top: 3px
}

.metric-card, .content-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: 0 4px 16px #24385a05
}

.metric-card {
    padding: 19px 20px;
    min-height: 169px
}

.metric-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px
}

.metric-icon {
    height: 39px;
    width: 39px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    font-size: 21px;
    font-weight: 700
}

    .metric-icon.blue {
        color: #4268dc;
        background: #edf1ff
    }

    .metric-icon.green {
        color: #139b70;
        background: #e5f8f0
    }

    .metric-icon.violet {
        color: #8068db;
        background: #f0ecff
    }

    .metric-icon.orange {
        color: #c77c19;
        background: #fff2df
    }

.metric-tag {
    font-size: 8px;
    letter-spacing: .8px;
    color: #8a96a9;
    font-weight: 800;
    background: #f4f6f9;
    border-radius: 6px;
    padding: 5px 7px
}

.warning-tag {
    color: #ba7a22;
    background: #fff4e5
}

.metric-label {
    font-size: 12px;
    color: #6f7c91;
    font-weight: 600
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 4px 0 2px;
    color: #1c2b43
}

.metric-foot {
    font-size: 10px;
    color: #9aa4b4
}

.content-card {
    padding: 22px 22px 18px
}

.card-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px
}

    .card-heading h3 {
        font-size: 15px;
        font-weight: 750;
        margin: 0 0 5px
    }

.soft-pill {
    font-size: 10px;
    color: #66758d;
    background: #f2f5fa;
    border-radius: 7px;
    padding: 7px 10px;
    font-weight: 700
}

.payments-table {
    font-size: 11px;
    margin-bottom: 0;
    white-space: nowrap
}

    .payments-table thead th {
        color: #9aa5b5;
        font-size: 9px;
        letter-spacing: .7px;
        font-weight: 800;
        border-bottom-color: var(--line);
        padding: 11px 8px
    }

    .payments-table td {
        padding: 13px 8px;
        border-bottom-color: #f0f2f6;
        color: #536177
    }

    .payments-table tbody tr:last-child td {
        border-bottom: 0
    }

.customer-name {
    font-weight: 750;
    color: #24334b;
    font-size: 11px;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis
}

.muted {
    color: var(--muted) !important
}

.payments-table td small {
    font-size: 9px
}

.money {
    font-weight: 800;
    color: #24334b !important
}

.status-pill {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 6px;
    background: #eaf8f2;
    color: #17855f;
    font-size: 9px;
    font-weight: 700
}

.empty-state {
    text-align: center;
    padding: 30px !important;
    color: var(--muted) !important
}

.portfolio-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 17px;
    background: #f7f9fc;
    border-radius: 10px;
    margin-bottom: 24px;
    color: #758198;
    font-size: 12px
}

    .portfolio-total b {
        font-size: 22px;
        color: #1d2c43
    }

.progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #5e6b80;
    margin: 17px 0 9px
}

    .progress-label b {
        color: #25344b
    }

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px
}

.dot-blue {
    background: #5578eb
}

.dot-green {
    background: #23b785
}

.dot-gray {
    background: #b9c2d0
}

.progress {
    height: 7px;
    border-radius: 20px;
    background: #edf0f5
}

.progress-bar {
    border-radius: 20px
}

.bg-blue {
    background: #5578eb
}

.bg-green {
    background: #23b785
}

.bg-gray {
    background: #b9c2d0
}

.notice-box {
    display: flex;
    gap: 10px;
    background: #f6f8fc;
    padding: 13px;
    border-radius: 9px;
    margin-top: 26px;
    color: #7b879a
}

    .notice-box p {
        font-size: 10px;
        line-height: 1.6;
        margin: 0
    }

.footer {
    margin-top: 28px;
    border-top: 1px solid #e8ecf3;
    padding: 18px 2px 0;
    font-size: 9px;
    letter-spacing: .8px;
    font-weight: 800;
    color: #9ba5b4
}

    .footer span {
        float: right;
        letter-spacing: 0;
        font-weight: 500
    }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 10% 10%,#e7edff,transparent 35%),var(--canvas)
}

.login-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 20px 70px #182c5012;
    padding: 38px;
    width: min(100%,440px)
}

.login-brand {
    padding: 0;
    color: var(--ink)
}

    .login-brand small {
        color: #8a96aa
    }

.login-card h1 {
    font-size: 27px;
    font-weight: 800;
    margin: 5px 0 7px
}

.login-card .eyebrow {
    color: #5978e7
}

.login-card .muted {
    font-size: 12px
}

.login-card .form-control {
    border-color: #dfe5ee;
    font-size: 13px;
    border-radius: 10px
}

.login-card .form-label {
    font-size: 11px;
    font-weight: 700
}

.btn-primary {
    background: #4169e1;
    border-color: #4169e1;
    border-radius: 9px;
    font-weight: 700
}

/* ==========================================
   LAYOUT RESPONSIVO
   ========================================== */

html {
    width: 100%;
    overflow-x: clip;
}

body {
    min-width: 320px;
    width: 100%;
    overflow-x: clip;
}

.app-shell,
.main-panel,
.page-content,
.content-card,
.metric-card {
    min-width: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

    .sidebar-nav .nav-link {
        width: 100%;
    }

.nav-icon {
    flex: 0 0 20px;
    text-align: center;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.page-heading {
    min-width: 0;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    border: 1px solid #e3e8f0;
    border-radius: 11px;
    background: #fff;
    cursor: pointer;
}

    .menu-toggle span {
        width: 18px;
        height: 2px;
        border-radius: 2px;
        background: #10213d;
    }

.sidebar-overlay {
    display: none;
}

.logout-short {
    display: none;
}

.page-content > .row {
    --bs-gutter-x: 1rem;
}

.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.payments-table {
    width: 100%;
}

/* ==========================================
   LOGIN
   ========================================== */

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background: radial-gradient(circle at 10% 10%, rgba(82, 121, 244, .13), transparent 35%), radial-gradient(circle at 90% 90%, rgba(16, 33, 61, .08), transparent 35%), var(--canvas);
}

.login-card {
    width: min(100%, 440px);
    padding: 38px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 20px 70px rgba(24, 44, 80, .09);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    color: var(--ink);
    text-decoration: none;
}

    .login-brand .brand-mark {
        width: 46px;
        height: 46px;
        flex: 0 0 46px;
        display: grid;
        place-items: center;
        border-radius: 14px;
        background: #5279f4;
        color: #fff;
        font-size: 16px;
        font-weight: 800;
    }

    .login-brand b {
        display: block;
        font-size: 18px;
        letter-spacing: 1.2px;
    }

    .login-brand small {
        display: block;
        margin-top: 4px;
        color: #8a96aa;
        font-size: 10px;
        letter-spacing: 1.1px;
    }

.login-card .eyebrow {
    color: #5978e7;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.login-card h1 {
    margin: 6px 0 8px;
    color: #19263b;
    font-size: 29px;
    font-weight: 800;
    letter-spacing: -.7px;
}

.login-card > p.muted {
    margin-bottom: 25px;
    color: #7e8a9e;
    font-size: 13px;
    line-height: 1.6;
}

.login-card .form-label {
    display: block;
    margin-bottom: 8px;
    color: #334158;
    font-size: 12px;
    font-weight: 700;
}

.login-card .form-control {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid #dfe5ee;
    border-radius: 11px;
    background-color: #fff;
    color: #19263b;
    font-size: 15px;
    box-shadow: none;
    transition: border-color .2s, box-shadow .2s;
}

    .login-card .form-control:focus {
        border-color: #5279f4;
        box-shadow: 0 0 0 4px rgba(82, 121, 244, .12);
    }

.login-card .btn-primary {
    min-height: 49px;
    border: 1px solid #4169e1;
    border-radius: 11px;
    background: #4169e1;
    color: #fff;
    font-size: 14px;
    font-weight: 750;
    transition: background .2s, transform .2s;
}

    .login-card .btn-primary:hover {
        border-color: #3157ca;
        background: #3157ca;
    }

    .login-card .btn-primary:active {
        transform: scale(.99);
    }

.login-card .alert {
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
}

.login-card .text-danger {
    font-size: 12px;
}

.login-card > small.muted {
    color: #8a96aa;
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
}

/* Indicador de validación del login */
.login-status {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    padding: 13px;
    border: 1px solid #e3eaff;
    border-radius: 10px;
    background: #f5f7ff;
    color: #4265d8;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

#loginButton:disabled {
    opacity: .8;
    cursor: wait;
}

#loginButton .spinner-border {
    vertical-align: middle;
}

/* ==========================================
   TABLET Y CELULAR
   ========================================== */

@media (max-width: 1100px) {
    .sidebar {
        width: 220px;
        padding: 22px 12px;
    }

    .main-panel {
        margin-left: 220px;
        width: calc(100% - 220px);
        padding: 0 20px 24px;
    }

    .metric-card {
        padding: 16px;
    }

    .content-card {
        padding: 18px;
    }

    .topbar {
        gap: 16px;
    }
}

@media (max-width: 760px) {
    body.menu-open {
        overflow: hidden;
    }

    .app-shell {
        display: block;
        min-height: 100vh;
    }

    /* Menú lateral desplegable */
    .sidebar {
        position: fixed;
        z-index: 1051;
        inset: 0 auto 0 0;
        width: min(290px, 85vw);
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        overflow-y: auto;
        padding: 22px 16px;
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform .25s ease, visibility .25s ease;
        box-shadow: 12px 0 35px #0b173329;
    }

        .sidebar.sidebar-open {
            transform: translateX(0);
            visibility: visible;
        }

    .brand {
        padding: 0 4px 28px;
    }

        .brand > span:last-child {
            display: block;
        }

    .nav-label {
        display: block;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

        .sidebar-nav .nav-link,
        .sidebar-nav .nav-link:not(.active) {
            display: flex;
            justify-content: flex-start;
            width: 100%;
            padding: 13px 14px;
            margin: 0;
            font-size: 13px;
        }

            .sidebar-nav .nav-link span {
                font-size: 16px;
            }

            .sidebar-nav .nav-link.active {
                font-size: 13px;
                box-shadow: inset 3px 0 #6486ff;
            }

    .sidebar-bottom {
        display: flex;
        margin-top: 25px;
    }

        .sidebar-bottom > div {
            display: block;
        }

    .sidebar-overlay.overlay-visible {
        display: block;
        position: fixed;
        z-index: 1050;
        inset: 0;
        background: rgb(9 20 39 / 48%);
        backdrop-filter: blur(2px);
    }

    /* Encabezado */
    .main-panel {
        width: 100%;
        margin: 0;
        padding: 0 16px 20px;
    }

    .topbar {
        min-height: 76px;
        height: auto;
        padding: 12px 0;
        gap: 10px;
        margin-bottom: 20px;
    }

    .topbar-left {
        gap: 10px;
        flex: 1;
    }

    .menu-toggle {
        display: flex;
    }

    .topbar .eyebrow {
        font-size: 8px;
        letter-spacing: 1px;
    }

    .topbar h1 {
        font-size: clamp(17px, 4vw, 21px);
        line-height: 1.25;
        overflow-wrap: anywhere;
        margin-top: 4px;
    }

    .user-menu {
        gap: 7px;
        flex-shrink: 0;
    }

        .user-menu .user-name {
            display: none;
        }

    .avatar {
        width: 34px;
        height: 34px;
    }

    .logout-button {
        padding: 6px 9px;
    }

    .logout-full {
        display: none;
    }

    .logout-short {
        display: inline;
    }

    /* Filtros del Dashboard */
    .dashboard-intro {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 18px;
    }

        .dashboard-intro > .d-flex {
            width: 100%;
            align-items: stretch !important;
        }

        .dashboard-intro form {
            width: 100%;
            flex-wrap: wrap;
        }

            .dashboard-intro form > div {
                flex: 1 1 160px;
                min-width: 0;
            }

            .dashboard-intro form input {
                width: 100%;
            }

            .dashboard-intro form button {
                min-height: 38px;
            }

    .date-chip {
        width: 100%;
        min-width: 0;
    }

    /* Indicadores en dos columnas */
    .metric-grid {
        --bs-gutter-x: .75rem;
        --bs-gutter-y: .75rem;
    }

        .metric-grid > .col-12 {
            flex: 0 0 50%;
            width: 50%;
        }

    .metric-card {
        min-height: 145px;
        padding: 13px;
        border-radius: 13px;
    }

    .metric-top {
        gap: 6px;
        margin-bottom: 12px;
    }

    .metric-icon {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }

    .metric-tag {
        font-size: 7px;
        padding: 4px 5px;
        letter-spacing: .3px;
    }

    .metric-label {
        font-size: 11px;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .metric-value {
        font-size: clamp(19px, 5vw, 25px);
        letter-spacing: -.5px;
        overflow-wrap: anywhere;
    }

    .metric-foot {
        font-size: 9px;
        line-height: 1.4;
    }

    .content-card {
        padding: 16px 12px;
        border-radius: 13px;
    }

    .card-heading {
        gap: 10px;
        flex-wrap: wrap;
    }

    .payments-table {
        min-width: 580px;
        font-size: 11px;
    }

    .portfolio-total {
        gap: 10px;
        flex-wrap: wrap;
    }

    .footer {
        line-height: 1.6;
    }

        .footer span {
            display: block;
            float: none;
            margin-top: 5px;
        }

    /* Login en móvil */
    .login-page {
        padding: 24px 18px;
    }

    .login-card {
        width: 100%;
        max-width: 420px;
        padding: 32px 28px;
        border-radius: 20px;
    }

        .login-card h1 {
            font-size: 27px;
        }
}

@media (max-width: 420px) {
    .main-panel {
        padding-right: 10px;
        padding-left: 10px;
    }

    .topbar {
        min-height: 64px;
        margin-bottom: 16px;
    }

    .topbar-left {
        gap: 7px;
    }

    .menu-toggle {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .topbar .eyebrow {
        font-size: 7px;
    }

    .topbar h1 {
        font-size: 16px;
    }

    .metric-card {
        padding: 10px;
    }

    .metric-tag {
        font-size: 6px;
    }

    .metric-value {
        font-size: 19px;
    }

    .content-card {
        padding: 14px 10px;
    }

    .soft-pill {
        white-space: normal;
        text-align: center;
    }

    .login-page {
        padding: 16px;
        align-items: center;
    }

    .login-card {
        padding: 27px 21px;
        border-radius: 17px;
    }

    .login-brand .brand-mark {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
    }

    .login-brand b {
        font-size: 16px;
    }

    .login-brand small {
        font-size: 9px;
        letter-spacing: .7px;
    }

    .login-card h1 {
        font-size: 25px;
    }

    .login-card > p.muted {
        font-size: 12px;
    }

    .login-card .form-control {
        min-height: 46px;
        font-size: 16px;
    }

    .login-card .btn-primary {
        min-height: 48px;
    }
}

@media (max-width: 380px) {
    .metric-card {
        padding: 9px;
    }

    .metric-value {
        font-size: 18px;
    }

    .metric-tag {
        letter-spacing: 0;
    }
}

@media (max-height: 520px) and (max-width: 760px) {
    .login-page {
        align-items: flex-start;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .login-card {
        padding-top: 22px;
        padding-bottom: 22px;
    }

        .login-card .mt-4 {
            margin-top: 16px !important;
        }
}
