:root {
    --navy-950: #031126;
    --navy-900: #061B3A;
    --navy-800: #0B2E59;
    --navy-700: #155EAD;
    --white: #FFFFFF;
    --gray-50: #F4F7FB;
    --gray-100: #EAF0F7;
    --gray-600: #5E6B7A;
    --success: #16A34A;
    --danger: #DC2626;
    --sidebar-width: 288px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--gray-50);
    color: #122033;
}

a { text-decoration: none; }

.login-body {
    min-height: 100vh;
    background: radial-gradient(circle at top left, #155EAD 0, #061B3A 34%, #031126 100%);
}

.login-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 520px) 1fr;
}

.login-panel {
    background: var(--white);
    min-height: 100vh;
    padding: clamp(28px, 6vw, 72px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-brand,
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
    color: var(--white);
    font-weight: 800;
    letter-spacing: -0.05em;
    box-shadow: 0 16px 38px rgba(6, 27, 58, .24);
}

.login-brand h1 {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--navy-900);
}

.login-brand p {
    margin: 0;
    color: var(--gray-600);
}

.login-panel h2 {
    color: var(--navy-900);
    font-weight: 800;
}

.login-hero {
    color: var(--white);
    padding: clamp(40px, 8vw, 96px);
    align-items: center;
    background: linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
}

.login-hero h2 {
    max-width: 680px;
    font-size: clamp(2rem, 5vw, 4.6rem);
    line-height: 1;
    font-weight: 850;
    letter-spacing: -0.06em;
}

.login-hero p {
    max-width: 560px;
    color: rgba(255,255,255,.78);
    font-size: 1.1rem;
}

.login-note {
    background: var(--gray-50);
    border: 1px solid var(--gray-100);
    color: var(--gray-600);
    border-radius: 18px;
    padding: 14px 16px;
    font-size: .9rem;
}

.btn-primary {
    --bs-btn-bg: var(--navy-700);
    --bs-btn-border-color: var(--navy-700);
    --bs-btn-hover-bg: var(--navy-800);
    --bs-btn-hover-border-color: var(--navy-800);
    border-radius: 14px;
    font-weight: 700;
}

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

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
    color: var(--white);
    position: fixed;
    inset: 0 auto 0 0;
    padding: 22px;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .22s ease;
}

.sidebar-brand {
    padding: 6px 4px 22px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand span {
    display: block;
    color: rgba(255,255,255,.58);
    font-size: .84rem;
}

.sidebar-nav {
    padding-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.sidebar-link {
    color: rgba(255,255,255,.78);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    transition: .18s ease;
    font-weight: 600;
}

.sidebar-link:hover {
    color: var(--white);
    background: rgba(255,255,255,.09);
}

.sidebar-link i {
    font-size: 1.1rem;
}

.disabled-link {
    opacity: .68;
    cursor: default;
}

.sidebar-footer {
    margin-top: auto;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 18px;
    padding: 14px;
}

.app-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

.app-topbar {
    height: 82px;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--navy-900);
}

.page-subtitle {
    font-size: .86rem;
    color: var(--gray-600);
}

.user-menu {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--gray-100);
    background: var(--white);
    border-radius: 999px;
    padding: 6px 12px 6px 6px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--navy-900);
    color: var(--white);
    border-radius: 50%;
    font-weight: 800;
}

.app-content {
    padding: 28px;
}

.dashboard-header {
    background: linear-gradient(135deg, var(--white), #EDF5FF);
    border: 1px solid var(--gray-100);
    border-radius: 26px;
    padding: 26px;
    box-shadow: 0 18px 45px rgba(13, 43, 85, .06);
}

.dashboard-header h2 {
    color: var(--navy-900);
    font-weight: 850;
    margin: 0 0 8px;
}

.dashboard-header p {
    color: var(--gray-600);
    margin: 0;
}

.badge-soft-primary {
    background: #DDEEFF;
    color: var(--navy-700);
    border: 1px solid #C5E0FF;
}

.metric-card,
.panel-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 18px 45px rgba(13, 43, 85, .06);
}

.metric-label {
    color: var(--gray-600);
    font-size: .9rem;
    font-weight: 700;
}

.metric-value {
    color: var(--navy-900);
    font-size: 2rem;
    line-height: 1;
    font-weight: 850;
    margin: 12px 0 6px;
}

.metric-hint {
    color: var(--gray-600);
    font-size: .86rem;
}

.panel-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-card h5 {
    color: var(--navy-900);
    font-weight: 800;
    margin-bottom: 4px;
}

.panel-card p {
    color: var(--gray-600);
    margin-bottom: 0;
}

.navy-card {
    background: linear-gradient(145deg, var(--navy-900), var(--navy-800));
    color: var(--white);
    border: 0;
}

.navy-card h5,
.navy-card p {
    color: var(--white);
}

.navy-card p {
    opacity: .82;
}

.timeline-list {
    display: grid;
    gap: 16px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 14px;
}

.timeline-item > span {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gray-100);
    margin-top: 5px;
    border: 3px solid #D8E4F3;
}

.timeline-item.active > span {
    background: var(--success);
    border-color: #BBF7D0;
}

.timeline-item strong {
    color: var(--navy-900);
}

.timeline-item p {
    margin: 3px 0 0;
    color: var(--gray-600);
}

@media (max-width: 991.98px) {
    .login-wrapper {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
        width: 100%;
    }

    .app-topbar {
        padding: 0 16px;
    }

    .app-content {
        padding: 18px;
    }
}

/* Fase 3 - Administración de usuarios */
.sidebar-link.active {
    color: var(--white);
    background: rgba(255,255,255,.14);
}

.table-card {
    padding: 0;
    overflow: hidden;
}

.table-card .panel-card-header {
    padding: 22px 22px 0;
}

.people-table thead th {
    background: #F8FBFF;
    color: var(--navy-900);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--gray-100);
    padding: 14px 18px;
}

.people-table tbody td {
    padding: 16px 18px;
    border-color: var(--gray-100);
}

.text-navy {
    color: var(--navy-900);
}

.code-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    background: #EEF6FF;
    color: var(--navy-800);
    font-weight: 800;
    font-size: .78rem;
    border: 1px solid #D9EBFF;
}

.mini-metric .metric-value {
    font-size: 1.55rem;
}

.modal-content {
    border: 0;
    border-radius: 24px;
    box-shadow: 0 30px 90px rgba(3, 17, 38, .20);
}

.modal-header,
.modal-footer {
    border-color: var(--gray-100);
}

.form-label {
    color: var(--navy-900);
    font-weight: 700;
    font-size: .9rem;
}

.form-control,
.form-select {
    border-radius: 14px;
    border-color: #DDE7F3;
    padding: 10px 13px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--navy-700);
    box-shadow: 0 0 0 .2rem rgba(21, 94, 173, .12);
}
/* Fase 4 - Inventario Facil */
.inventory-tabs .nav-link {
    border-radius: 999px;
    color: var(--navy-900);
    font-weight: 800;
    padding: 10px 18px;
}

.inventory-tabs .nav-link.active {
    background: var(--navy-900);
    color: #fff;
}

.btn-dark {
    background: var(--navy-900);
    border-color: var(--navy-900);
}

.btn-dark:hover {
    background: var(--navy-800);
    border-color: var(--navy-800);
}

.badge.text-bg-dark {
    background-color: var(--navy-900) !important;
}

@media (max-width: 767px) {
    .dashboard-header .btn {
        width: 100%;
    }
}
/* Fase 5 - Tarjetas vinculadas */
.linked-card-privacy {
    border-radius: 20px;
    background: #EEF6FF;
    color: var(--navy-900);
}

.linked-card-privacy i {
    color: var(--navy-700);
    font-size: 1.2rem;
}

.form-check-input:checked {
    background-color: var(--navy-700);
    border-color: var(--navy-700);
}

.btn-outline-warning {
    color: #A16207;
    border-color: #FACC15;
    background: #FEFCE8;
}

.btn-outline-warning:hover {
    background: #FACC15;
    color: #422006;
    border-color: #FACC15;
}
/* Fase 6 - Recargas SPEI/CEP */
.detail-box {
    border: 1px solid #E2EAF5;
    background: #F8FBFF;
    border-radius: 18px;
    padding: 14px 16px;
    min-height: 92px;
}

.detail-box span {
    display: block;
    color: var(--gray-600);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 5px;
}

.detail-box strong {
    display: block;
    color: var(--navy-900);
    font-size: .98rem;
}

.detail-box small {
    color: var(--gray-600);
}

.btn-outline-success {
    background: #ECFDF5;
    border-color: #86EFAC;
    color: #166534;
}

.btn-outline-success:hover {
    background: #16A34A;
    border-color: #16A34A;
    color: #fff;
}

.btn-outline-danger {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #991B1B;
}

.btn-outline-danger:hover {
    background: #DC2626;
    border-color: #DC2626;
    color: #fff;
}
/* Fase 7 - Recargas cripto */
.text-break {
    word-break: break-all;
}

.badge.text-bg-info {
    background-color: #0EA5E9 !important;
}

.btn-outline-secondary {
    background: #F8FAFC;
    border-color: #CBD5E1;
    color: #334155;
}

.btn-outline-secondary:hover {
    background: #334155;
    border-color: #334155;
    color: #fff;
}
/* Fase 8 - Comisiones */
.commission-summary-box {
    border: 1px solid #E2EAF5;
    background: #F8FBFF;
    border-radius: 20px;
    padding: 16px;
    min-height: 120px;
}

.commission-summary-box strong {
    display: block;
    color: var(--navy-900);
    font-size: 1.05rem;
    margin-top: 10px;
}

.commission-summary-box span {
    display: block;
    color: var(--gray-600);
    font-size: .82rem;
    margin-top: 4px;
}
/* Fase 9 - Conversiones y dispersiones */
.dispersion-item {
    border: 1px solid #E2EAF5;
    background: #F8FBFF;
    border-radius: 18px;
    padding: 12px;
}

.btn-outline-primary.btn-sm,
.btn-outline-danger.btn-sm,
.btn-outline-success.btn-sm,
.btn-outline-secondary.btn-sm {
    border-radius: 12px;
}
/* Fase 10 - Compra y vinculación de tarjetas */
.card-checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #E2EAF5;
    background: #F8FBFF;
    border-radius: 16px;
    padding: 12px;
    cursor: pointer;
    font-weight: 700;
    color: var(--navy-900);
}

.card-checkbox-option input {
    width: 18px;
    height: 18px;
}

.card-checkbox-option:hover {
    border-color: var(--navy-700);
    background: #EEF6FF;
}
/* Modales: footer visible sin hacer zoom out */
.modal-dialog {
    max-height: calc(100vh - 1rem);
}

.modal-content {
    max-height: calc(100vh - 1rem);
    overflow: hidden;
}

.modal-body {
    overflow-y: auto;
    max-height: calc(100vh - 190px);
}

.modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: #fff;
    border-top: 1px solid #e5edf7;
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 6;
    background: #fff;
    border-bottom: 1px solid #e5edf7;
}

@media (max-height: 720px) {
    .modal-dialog {
        margin-top: .5rem;
        margin-bottom: .5rem;
    }

    .modal-body {
        max-height: calc(100vh - 150px);
    }
}

@media (max-width: 576px) {
    .modal-dialog {
        margin: .5rem;
    }

    .modal-content {
        max-height: calc(100vh - 1rem);
    }

    .modal-body {
        max-height: calc(100vh - 155px);
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }
}
.crypto-payment-box {
    border: 1px solid #e2eaf5;
    background: #f8fbff;
    border-radius: 16px;
    padding: 12px;
}

.crypto-qr {
    width: 160px;
    height: 160px;
    border-radius: 12px;
    border: 1px solid #e2eaf5;
    background: #fff;
    padding: 8px;
}

.polygon-logo {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #8247e5;
    color: #fff;
    font-weight: 800;
}
/* DataTables inventory */
.dataTables_wrapper .dataTables_filter input,
.dt-search input {
    border-radius: 12px;
    border: 1px solid #dbe7f3;
    padding: 8px 12px;
    margin-left: 8px;
}

.dataTables_wrapper .dataTables_length select,
.dt-length select {
    border-radius: 12px;
    border: 1px solid #dbe7f3;
    padding: 6px 10px;
}

.dt-info,
.dataTables_info {
    color: #64748b;
    font-size: 0.875rem;
}

.dt-paging .pagination {
    margin-bottom: 0;
}
/* ---- Selector de idioma (i18n) ---- */
.lang-switch .lang-flag { font-size: 1.1rem; line-height: 1; }
.lang-switch-menu { min-width: 190px; max-height: 70vh; overflow-y: auto; }
.lang-switch .dropdown-item.active { background-color: var(--bs-primary, #0d6efd); color: #fff; }

/* En páginas de login/registro: fijo arriba a la derecha, seguro en móvil */
.auth-lang {
    position: fixed;
    top: .75rem;
    right: .75rem;
    z-index: 1050;
}
@media (max-width: 575.98px) {
    .auth-lang { top: .5rem; right: .5rem; }
}
