/* ==========================================================================
   1. VARIABLES GLOBALES (Figma Design Tokens)
   ========================================================================== */
:root {
    --bg-app: #f4f6f8;
    --bg-sidebar: #0f2e2a; /* Verde oscuro elegante */
    --bg-card: #ffffff;
    --primary: #1e3a34;
    --primary-light: #2c4e46;
    --accent: #d4af37;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    
    /* Estados y Frecuencias */
    --color-pendiente: #d97706;
    --bg-pendiente: #fef3c7;
    --color-aldia: #16a34a;
    --bg-aldia: #dcfce7;
    --color-vencido: #dc2626;
    --bg-vencido: #fee2e2;
    --color-diario: #2563eb;
    --bg-diario: #dbeafe;
    --color-semanal: #7c3aed;
    --bg-semanal: #ede9fe;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
}

/* ==========================================================================
   2. INTERFAZ ESTRUCTURAL (Sidebar Fijo en PC)
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: #ffffff;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.sidebar-brand span {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 1px;
    display: block;
    margin-top: 0.25rem;
}

.sidebar-nav-container {
    flex: 1; 
    margin-top: 1.5rem;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #a7f3d0;
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background-color: var(--primary-light);
    color: #ffffff;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--primary-light);
    font-size: 0.85rem;
    font-weight: 600;
    color: #a7f3d0;
    letter-spacing: 0.5px;
    text-align: center;
    width: 100%;
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card { max-width: 400px; width: 100%; padding: 2.5rem; }
.auth-heading { margin-bottom: 2rem; text-align: center; }
.auth-heading h2 { color: var(--primary); margin-bottom: 0.35rem; }
.auth-heading p, .auth-recovery-link { color: var(--text-muted); font-size: 0.9rem; text-align: center; }
.auth-recovery-link { margin-top: 1.2rem; }
.auth-recovery-link a { color: var(--primary-light); font-weight: 700; text-decoration: none; }
.auth-recovery-link a:hover { text-decoration: underline; }
.auth-actions { margin-top: 1.5rem; padding-top: 0; }
.auth-actions .btn-guardar { width: 100%; }

.password-field { position: relative; }
.password-field .form-control { padding-right: 3.15rem; }
.password-toggle { position: absolute; top: 50%; right: 0.45rem; display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; border: 1px solid transparent; border-radius: 50%; color: #718096; background: transparent; cursor: pointer; transform: translateY(-50%); transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease; }
.password-toggle-icon { width: 1.12rem; height: 1.12rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.password-toggle::after { content: ''; position: absolute; width: 1.2rem; height: 2px; border-radius: 2px; background: currentColor; opacity: 0; transform: rotate(-45deg) scaleX(.4); transition: opacity .18s ease, transform .18s ease; }
.password-toggle:hover, .password-toggle.is-visible { color: var(--primary); border-color: #cfe1db; background: #eef5f2; transform: translateY(-50%) scale(1.05); }
.password-toggle.is-visible::after { opacity: 1; transform: rotate(-45deg) scaleX(1); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.user-create-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; margin: 1.25rem 0; padding: 1.2rem; border: 1px solid #dce9e6; border-radius: 0.85rem; background: linear-gradient(135deg, #f8fcfb 0%, #f4f8fb 100%); box-shadow: 0 7px 18px rgba(15, 118, 110, 0.05); }
.user-create-action { display: flex; flex-direction: column; justify-content: flex-end; }
.user-list-wrap { overflow-x: auto; border: 1px solid #dce9e6; border-radius: 0.85rem; box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05); }
.user-list-table { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
.user-list-table th, .user-list-table td { padding: 0.9rem 0.85rem; border-bottom: 1px solid #e7eef0; text-align: left; vertical-align: middle; }
.user-list-table th { color: #64748b; background: #f5faf9; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.035em; text-transform: uppercase; }
.user-list-table tbody tr { transition: background-color 0.18s ease, transform 0.18s ease; }
.user-list-table tbody tr:hover { background: #f4fbf9; }
.user-list-table tbody tr:last-child td { border-bottom: 0; }
.role-badge, .user-state { display: inline-block; border-radius: 999px; padding: 0.3rem 0.62rem; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.015em; }
.role-badge { color: #5b21b6; background: #ede9fe; border: 1px solid #ddd6fe; }
.user-state.is-active { color: #166534; background: #dcfce7; }
.user-state.is-inactive { color: #991b1b; background: #fee2e2; }
.user-actions { display: flex; flex-wrap: wrap; gap: 0.42rem; min-width: 188px; }
.btn-user-state, .btn-user-resend, .btn-user-edit { border: 1px solid var(--border); border-radius: 0.5rem; background: #fff; color: var(--primary); cursor: pointer; font: inherit; font-size: 0.76rem; font-weight: 750; line-height: 1.15; padding: 0.44rem 0.65rem; transition: background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.btn-user-state:hover, .btn-user-resend:hover, .btn-user-edit:hover { box-shadow: 0 5px 10px rgba(15, 23, 42, 0.11); transform: translateY(-1px); }
.btn-user-state:focus-visible, .btn-user-resend:focus-visible, .btn-user-edit:focus-visible { outline: 3px solid rgba(20, 184, 166, 0.25); outline-offset: 2px; }
.btn-user-edit { color: #0f766e; border-color: #5eead4; background: #f0fdfa; }
.btn-user-edit:hover { color: #fff; background: #0f766e; }
.swal-user-popup { width: min(92vw, 510px) !important; padding: 1.6rem 1.8rem 1.35rem !important; border: 1px solid #dbe5e8 !important; border-radius: 1rem !important; box-shadow: 0 20px 55px rgba(15, 46, 42, 0.22) !important; }
.swal-user-title { margin: 0.1rem 0 0.25rem !important; color: #123d39 !important; font-size: 1.45rem !important; }
.swal-user-intro { margin: 0 0 1.1rem; color: #64748b; font-size: 0.85rem; line-height: 1.45; text-align: left; }
.swal-user-form { display: grid; gap: 0.9rem; text-align: left; }
.swal-user-field label { display: block; margin-bottom: 0.38rem; color: #334155; font-size: 0.8rem; font-weight: 800; }
.swal-user-field label em { color: #c2410c; font-size: 0.72rem; font-style: normal; font-weight: 700; }
.swal-user-popup .user-edit-control, .swal-user-reason { box-sizing: border-box !important; display: block !important; width: 100% !important; height: 2.65rem; margin: 0 !important; padding: 0.6rem 0.72rem !important; border: 1px solid #cbd5e1 !important; border-radius: 0.55rem !important; color: #334155; background: #fff; box-shadow: none !important; font: inherit !important; font-size: 0.92rem !important; }
.swal-user-reason { min-height: 5.3rem; line-height: 1.4; outline: 0; resize: vertical; }
.swal-user-popup .user-edit-control:focus, .swal-user-reason:focus { border-color: #0f766e !important; box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14) !important; }
.swal-user-note { margin: 1rem 0 0; padding: 0.7rem 0.8rem; border-left: 3px solid #0f766e; border-radius: 0.35rem; color: #496579; background: #f0fdfa; font-size: 0.79rem; line-height: 1.45; text-align: left; }
.swal-user-note strong { display: block; margin-bottom: 0.25rem; color: #0f5f58; }
.swal-user-note ul { margin: 0; padding-left: 1.05rem; }
.swal-user-note li + li { margin-top: 0.2rem; }
.swal-user-popup .swal2-actions { margin: 1.25rem 0 0 !important; }
.swal-user-confirm, .swal-user-cancel { border-radius: 0.55rem !important; font-weight: 800 !important; padding: 0.62rem 1rem !important; }
.swal-user-cancel { background: #e2e8f0 !important; color: #475569 !important; }
.btn-user-state:hover { background: var(--primary); color: #fff; }
.btn-user-resend { color: #1d4ed8; border-color: #93c5fd; background: #eff6ff; }
.btn-user-resend:hover { color: #fff; background: #1d4ed8; }

/* Acciones de administración del menú lateral */
.sidebar-admin-area {
    margin-top: 2rem;
    padding: 0 0.5rem;
}

.sidebar-admin-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--primary-light);
    border-radius: 0.5rem;
    color: var(--accent);
    background: transparent;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar-admin-link:hover {
    color: #ffffff;
    background-color: var(--primary-light);
    transform: translateY(-1px);
}

.sidebar-admin-link--active {
    color: #ffffff;
    border-color: var(--accent);
    background-color: var(--primary-light);
    box-shadow: none;
}

.sidebar-session-warning {
    margin-top: 0.75rem;
    padding: 0.7rem;
    border: 1px solid rgba(251, 191, 36, 0.75);
    border-radius: 0.5rem;
    color: #fef3c7;
    background: linear-gradient(135deg, rgba(146, 64, 14, 0.65), rgba(120, 53, 15, 0.78));
    font-size: 0.72rem;
    line-height: 1.4;
    text-align: center;
}

.sidebar-user-session {
    margin-top: 0.75rem;
    padding: 0.7rem;
    border: 1px solid rgba(167, 243, 208, 0.28);
    border-radius: 0.5rem;
    color: #d1fae5;
    background: rgba(255, 255, 255, 0.06);
    text-align: center;
}

.sidebar-user-session strong, .sidebar-user-session span { display: block; }
.sidebar-user-session strong { font-size: 0.8rem; }
.sidebar-user-session span { margin-top: 0.2rem; color: var(--accent); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; }

.sidebar-logout-form {
    margin-top: 0.65rem;
}

.btn-sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.65rem 0.9rem;
    border: 1px solid rgba(248, 113, 113, 0.65);
    border-radius: 0.5rem;
    color: #fee2e2;
    background: linear-gradient(135deg, #b91c1c, #7f1d1d);
    box-shadow: 0 5px 12px rgba(127, 29, 29, 0.3);
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-sidebar-logout::before {
    content: '↪';
    margin-right: 0.45rem;
    font-size: 1rem;
}

.btn-sidebar-logout:hover {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    box-shadow: 0 8px 18px rgba(127, 29, 29, 0.42);
    transform: translateY(-2px);
}

.btn-sidebar-logout:focus-visible,
.sidebar-admin-link:focus-visible {
    outline: 3px solid #fcd34d;
    outline-offset: 3px;
}

/* Área de Contenido Principal */
.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 2.5rem;
    width: auto;
    max-width: none;
    transition: all 0.3s ease;
}

/* Control de la barra lateral en pantallas de escritorio. */
.desktop-sidebar-toggle {
    position: fixed;
    top: 50%;
    left: calc(var(--sidebar-width) - 1.1rem);
    z-index: 201;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 3.4rem;
    border: 1px solid rgba(212, 175, 55, 0.75);
    border-radius: 0 0.7rem 0.7rem 0;
    color: #ffffff;
    background: var(--primary-light);
    box-shadow: 4px 5px 12px rgba(15, 46, 42, 0.2);
    cursor: pointer;
    font-size: 2rem;
    line-height: 1;
    transform: translateY(-50%);
    transition: left 0.3s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.desktop-sidebar-toggle:hover {
    background: var(--primary);
    box-shadow: 5px 7px 16px rgba(15, 46, 42, 0.3);
}

.desktop-sidebar-toggle:focus-visible {
    outline: 3px solid #fcd34d;
    outline-offset: 3px;
}

body.sidebar-oculto .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

body.sidebar-oculto .main-content {
    margin-left: 0;
}

body.sidebar-oculto .desktop-sidebar-toggle {
    left: 0;
    border-radius: 0 0.7rem 0.7rem 0;
}

/* ==========================================================================
   3. COMPONENTES VISTAS GENERÁLICAS (Header, Cards y Tablas)
   ========================================================================== */
.header {
    margin-bottom: 2.5rem;
    width: 100%;
}

.header h2 { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.sub-cartera { color: var(--text-muted); font-size: 0.95rem; margin-top: 0.25rem; }

.resumen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
    width: 100%;
}

.card-resumen {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-resumen .card-title { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.card-resumen .card-value { font-size: 1.4rem; font-weight: 700; margin-top: 0.5rem; color: var(--primary); }

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input, .filter-select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    background-color: #fff;
    outline: none;
}
.search-input { flex: 2; min-width: 260px; }
.filter-select { flex: 1; min-width: 160px; }

.table-container {
    background: var(--bg-card);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    /* El desplazamiento ocurre dentro de la tabla para conservar sus encabezados visibles. */
    max-height: min(68vh, 720px);
    overflow: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    width: 100%;
}

.data-table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
.data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #f8fafc;
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 3px rgba(15, 46, 42, 0.08);
    text-transform: uppercase;
}
.data-table td { padding: 1rem; border-bottom: 1px solid var(--border); font-size: 0.95rem; }

/* Componentes internos de las celdas */
.client-name { font-weight: 600; color: var(--text-main); }
.client-id { font-size: 0.8rem; color: var(--text-muted); }
.client-address-line { margin-top: 0.22rem; max-width: 250px; color: var(--text-muted); font-size: 0.76rem; line-height: 1.25; white-space: normal; }
.cuota-price { font-weight: 600; }

/* Badges de estados */
.badge { display: inline-flex; padding: 0.25rem 0.75rem; border-radius: 50px; font-size: 0.8rem; font-weight: 600; }
.badge-diario { color: var(--color-diario); background-color: var(--bg-diario); }
.badge-semanal { color: var(--color-semanal); background-color: var(--bg-semanal); }
.loan-frequency { display: inline-flex; flex-direction: column; align-items: center; gap: 0.18rem; }
.loan-frequency-day { color: var(--text-muted); font-size: 0.72rem; font-weight: 600; line-height: 1.1; }
.badge-quincenal { color: #7c3aed; background-color: #f3e8ff; }
.badge-mensual { color: #db2777; background-color: #fce7f3; }
.badge-pendiente { color: var(--color-pendiente); background-color: var(--bg-pendiente); }
.badge-aldia { color: var(--color-aldia); background-color: var(--bg-aldia); }
.badge-vencido { color: var(--color-vencido); background-color: var(--bg-vencido); }
.badge-pagado { color: #166534; background-color: #dcfce7; }
.badge-anulado { color: #9f1239; background-color: #ffe4e6; }

.btn-table-action, .btn-header-action {
    background-color: #e2e8f0;
    color: var(--text-main);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
}
.btn-header-action { background-color: var(--primary); color: white; }
.btn-header-action:hover { background-color: var(--primary-light); }
.btn-table-action:hover { background-color: #cbd5e1; }

/* ==========================================================================
   4. COMPONENTES DE FORMULARIO ESPECTACULARES Y CENTRADOS
   ========================================================================== */
.form-container {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    max-width: 680px;
    width: 100%;
    margin: 0 auto; /* Centrado estricto del bloque de formulario */
}

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 0.85rem 1.1rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.6rem;
    font-size: 0.95rem;
    outline: none;
    background-color: #ffffff;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(44, 78, 70, 0.15);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.btn-guardar, .btn-cancelar {
    padding: 0.85rem 2rem;
    border-radius: 0.6rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-guardar {
    background-color: var(--bg-sidebar);
    color: white;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(15, 46, 42, 0.2);
}

.btn-guardar:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
}

.btn-cancelar {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.btn-cancelar:hover {
    background-color: #e2e8f0;
    color: #1e293b;
}

.schedule-preview {
    display: none;
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    border-left: 4px solid var(--color-diario);
    border-radius: 0.5rem;
    color: #1e3a34;
    background-color: #eff6ff;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.5;
}

.schedule-preview.is-visible {
    display: block;
}

.config-rule-description {
    margin: -0.5rem 0 0.85rem;
    padding: 0.7rem 0.85rem;
    border-left: 3px solid var(--accent);
    border-radius: 0.35rem;
    color: var(--text-muted);
    background-color: #fffbeb;
    font-size: 0.83rem;
    line-height: 1.45;
}

.btn-logout-secondary {
    color: #b91c1c;
    border-color: #fecaca;
    background-color: #fff1f2;
}

.btn-logout-secondary:hover {
    color: #ffffff;
    border-color: #b91c1c;
    background-color: #b91c1c;
}

/* ==========================================================================
   5. INTERFAZ RESPONSIVA Y DESPLEGABLE HAMBURGUESA MÓVIL
   ========================================================================== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 200;
    background-color: var(--bg-sidebar);
    color: white;
    border: 1px solid var(--primary-light);
    border-radius: 8px;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .menu-toggle { display: flex; }
    .desktop-sidebar-toggle { display: none; }
    body { flex-direction: column; }

    .sidebar {
        position: fixed;
        width: 280px;
        height: 100vh;
        height: 100dvh;
        left: -280px;
        top: 0;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
        z-index: 999;
        padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom)) 1.25rem;
    }

    .sidebar.menu-abierto { transform: translateX(280px); }
    .sidebar-menu { flex-direction: column; }
    .sidebar-nav-container { margin-top: 0.5rem; }

    .sidebar-footer {
        margin-top: auto;
        padding-top: 1rem;
        padding-bottom: 0.5rem;
        background-color: var(--bg-sidebar);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 4.5rem 1.25rem 1.25rem 1.25rem;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .user-create-grid { grid-template-columns: 1fr; gap: 0; }
}
/* ==========================================================================
   6. IMPRESIÓN PROFESIONAL
   ========================================================================== */
@media print {
    .no-print, 
    .menu-toggle, 
    .sidebar, 
    .filters-row, 
    .btn-header-action, 
    .btn-table-action, 
    td:last-child, 
    th:last-child {
        display: none !important;
    }

    body { 
        background-color: white !important; 
        color: #000000 !important; 
        display: block !important; 
        margin: 0 !important; 
        padding: 0 !important; 
    }

    .main-content { 
        margin-left: 0 !important; 
        width: 100% !important; 
        padding: 0 !important; 
    }

    .table-container { 
        border: none !important; 
        box-shadow: none !important; 
        overflow: visible !important; 
    }

    .data-table { 
        width: 100% !important; 
        border-collapse: collapse !important; 
    }

    .data-table tr { 
        page-break-inside: avoid !important; 
    }

    .data-table th { 
        background-color: #f1f5f9 !important; 
        border-bottom: 2px solid #000000 !important; 
        padding: 8px !important; 
    }

    .data-table td { 
        border-bottom: 1px solid #cbd5e1 !important; 
        padding: 8px !important; 
        white-space: normal !important; 
    }
}

/* ==========================================================================
   7. OPTIMIZACIÓN DE ADAPTABILIDAD MÓVIL PARA INDEX.PHP
   ========================================================================== */
.header-tabla-index {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    margin-top: 1rem;
    width: 100%;
}

.header-tabla-index h3 {
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 700;
}

.btn-ver-completo {
    background-color: #e2e8f0;
    color: var(--text-main);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background-color 0.2s;
}

.btn-ver-completo:hover {
    background-color: #cbd5e1;
}

@media (max-width: 600px) {
    .header-tabla-index {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .btn-ver-completo {
        width: 100%;
        text-align: center;
    }

    .table-container .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
}
/* ==========================================================================
   8. DISEÑO ESPECTACULAR PARA VENTANA MODAL (Registrar Cobro)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 46, 42, 0.4); /* Capa verde oscura traslúcida */
    backdrop-filter: blur(4px); /* Suave desenfoque de fondo */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000; /* Por encima de cualquier menú o tabla */
}

/* Las alertas del sistema deben mostrarse sobre cualquier ventana modal. */
.swal2-container {
    z-index: 3000 !important;
}

/* Confirmaciones y avisos del módulo de préstamos. */
.loan-swal-popup {
    border-radius: 18px !important;
    padding: 1.65rem !important;
    box-shadow: 0 22px 55px rgba(10, 44, 58, 0.22) !important;
}
.loan-swal-title { color: #073b4c !important; font-size: 1.45rem !important; }
.loan-swal-text { color: #496579 !important; line-height: 1.5 !important; }
.loan-swal-confirm, .loan-swal-cancel {
    border: 0 !important;
    border-radius: 9px !important;
    padding: 0.68rem 1.15rem !important;
    font-weight: 700 !important;
    margin: 0.25rem !important;
    cursor: pointer !important;
}
.loan-swal-confirm { background: #0f766e !important; color: #fff !important; }
.loan-swal-confirm:hover { background: #115e59 !important; }
.loan-swal-cancel { background: #e8eef3 !important; color: #27485c !important; }

.modal-box {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 440px; /* Tamaño exacto compacto de tu captura */
    padding: 2.2rem;
    border-radius: 1.2rem;
    border: 1px solid var(--border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.modal-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 0.25rem;
}

/* Cabecera del historial: resume el crédito antes del detalle de pagos. */
#modal-historial-pagos .modal-header {
    margin-bottom: .8rem;
    padding: 1.15rem 1.25rem;
    border: 1px solid #d9e5ed;
    border-radius: .85rem;
    background: linear-gradient(135deg, #f9fcfe 0%, #f0f7fa 100%);
    box-shadow: 0 3px 10px rgba(21, 62, 82, .05);
}
#modal-historial-pagos .modal-header h2 {
    margin: 0;
    color: #123b4b;
    font-size: 1.35rem;
    letter-spacing: -.015em;
}
.historial-resumen {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: .9rem;
    padding-top: .85rem;
    border-top: 1px solid #dce8ef;
}
.historial-cliente { min-width: 0; padding-left: .7rem; border-left: 3px solid #179366; }
.historial-etiqueta { display: block; margin-bottom: .2rem; color: #708397; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.historial-cliente .modal-subtitle { margin: 0; color: #294c60; font-size: .93rem; }
.historial-fecha-credito {
    min-width: 160px;
    padding: .55rem .85rem;
    border: 1px solid #c9dce8;
    border-radius: .65rem;
    background: #fff;
    box-shadow: 0 2px 5px rgba(19, 62, 82, .06);
    text-align: center;
}
.historial-fecha-credito span { display: block; margin-bottom: .15rem; color: #668098; font-size: .67rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.historial-fecha-credito strong { color: #0d526a; font-size: 1rem; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
    #modal-historial-pagos .modal-header { padding: 1rem; }
    .historial-resumen { align-items: stretch; flex-direction: column; gap: .65rem; }
    .historial-fecha-credito { text-align: left; }
}

/* Tarjeta interna de datos técnicos */
.modal-info-card {
    background-color: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.info-label {
    color: var(--text-muted);
    font-weight: 500;
}

.info-value {
    color: var(--text-main);
}

.info-value.text-bold {
    font-weight: 700;
    color: #475569;
}

/* Pequeños Badges internos del Modal */
.badge-frecuencia {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
}
.badge-frecuencia.frecuencia-semanal { color: #7c3aed; background-color: #f3e8ff; }
.badge-frecuencia.frecuencia-diario { color: var(--color-diario); background-color: var(--bg-diario); }
.badge-frecuencia.frecuencia-quincenal { color: #b45309; background-color: #fef3c7; }

/* Estilos integrados para validaciones visuales en tiempo real */
        .form-group {
            position: relative;
            margin-bottom: 1.25rem;
        }
        .error-feedback {
            display: none;
            color: #dc3545;
            font-size: 0.85rem;
            margin-top: 0.25rem;
            font-weight: 500;
        }
        .form-control.is-invalid {
            border-color: #dc3545 !important;
            background-color: #fff8f8 !important;
        }
.form-control.is-valid {
            border-color: #28a745 !important;
            background-color: #f8fff9 !important;
        }

/* ========================================================================== 
   9. GESTIÓN DE PRÉSTAMOS: ACCIONES Y EDICIÓN
   ========================================================================== */
.modal-overlay.is-hidden {
    display: none;
}

/* Decisión de pago en el modal de cobro */
.modal-cobro-box { max-width: 510px; }
#modal-cobro-contenedor {
    align-items: flex-start;
    overflow-y: auto;
    padding: 1rem;
    box-sizing: border-box;
}
#modal-cobro-contenedor .modal-cobro-box {
    margin: 0 auto;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-sizing: border-box;
}
.payment-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin: 1rem 0;
}
.payment-breakdown > div {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    padding: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}
.payment-breakdown span { color: var(--text-muted); font-size: 0.76rem; }
.payment-breakdown strong { color: var(--text-main); font-size: 1.05rem; }
.payment-breakdown .payment-breakdown-total { grid-column: 1 / -1; background: #ecfdf5; border-color: #86efac; }
.payment-breakdown-total strong { color: #15803d; }
.payment-choice { border: 0; padding: 0; margin: 1rem 0; }
.payment-choice legend { color: var(--text-main); font-size: 0.9rem; font-weight: 700; margin-bottom: 0.55rem; }
.payment-choice-option {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.72rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}
.payment-choice-option input { margin-top: 0.22rem; accent-color: var(--primary); }
.payment-choice-option span { display: flex; flex-direction: column; gap: 0.12rem; }
.payment-choice-option small { color: var(--text-muted); font-size: 0.75rem; }
.payment-choice-option.is-selected { border-color: var(--primary); background: #effcf6; }
.payment-choice-option.is-disabled { opacity: .55; cursor: not-allowed; background: #f8fafc; }
/* Las tarjetas del modal usan display:flex; sin esta regla pueden ignorar hidden. */
#modal-semanal-contenedor [hidden] { display: none !important; }
.cobros-hoy-page #opcion-abono-cuota { display: none !important; }
.payment-choice-no-payment.is-selected { border-color: #94a3b8; background: #f8fafc; }
.daily-delay-message { margin: -0.35rem 0 0.9rem; padding: 0.65rem 0.8rem; border-radius: 0.5rem; color: #1e40af; background: #eff6ff; font-size: 0.82rem; font-weight: 600; }
.modal-payment-amount input[readonly] { background: #f8fafc; color: var(--text-main); font-weight: 700; }
.modal-payment-actions { display: flex; gap: 0.75rem; border-top: 0; padding-top: 0; margin-top: 1.25rem; }
.modal-payment-actions button { flex: 1; }

.loan-edit-modal {
    max-width: 470px;
}

.loan-modal-actions,
.loan-action-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.loan-modal-actions {
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.btn-modal-cancel {
    border: 1px solid #b9c8d8;
    border-radius: 0.5rem;
    background: #f5f8fb;
    color: #29445d;
    padding: 0.7rem 1.1rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-modal-cancel:hover { background: #e7eef5; }
.historial-acciones { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* Un pago eliminado sigue visible para auditoría, pero se diferencia de un
   movimiento vigente sin afectar la lectura de las columnas. */
.history-row-deleted td { background: #fff1f2 !important; color: #8a1c2c; }
.history-row-deleted:hover td { background: #ffe4e6 !important; }

.session-timeout-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 1rem; background: #102a4388; }
.session-timeout-card { width: min(420px, 100%); padding: 1.5rem; border-radius: .9rem; background: #fff; box-shadow: 0 18px 50px #102a4355; text-align: center; }
.session-timeout-card h3 { margin: 0 0 .65rem; color: #9a3412; }
.session-timeout-card p { margin: 0 0 1rem; color: #43566a; line-height: 1.5; }
.session-timeout-card button { border: 0; border-radius: .55rem; padding: .7rem 1rem; background: #0b4037; color: #fff; font-weight: 700; cursor: pointer; }

.btn-loan-action {
    border: 0;
    border-radius: 0.45rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-loan-action:hover {
    transform: translateY(-1px);
    filter: brightness(0.95);
}

.btn-loan-edit { background: #dbeafe; color: #1d4ed8; }
.btn-loan-collect { background: linear-gradient(135deg, #047857, #065f46); color: #fff; box-shadow: 0 3px 8px rgba(6, 95, 70, .22); }
.route-row-paid { background: #f0fdf4; }
.btn-client-edit { background: #dcfce7; color: #166534; }
.btn-loan-delete { background: #fee2e2; color: #b91c1c; }
.btn-loan-annul { background: #fef3c7; color: #92400e; }
.loan-no-actions { color: var(--text-muted); }
.loan-code, .loan-date { color: #475569; font-size: 0.82rem; }
.table-empty { text-align: center; padding: 30px; color: #6B7B72; font-style: italic; }
.table-error { text-align: center; padding: 20px; color: #dc2626; }

.loan-header-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.btn-loan-print {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 5px 12px rgba(37, 99, 235, 0.22);
}

.btn-loan-print:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.loan-report-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.loan-report-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border-top: 4px solid #64748b;
}

.loan-report-card span,
.loan-report-card small { color: var(--text-muted); font-size: 0.78rem; }
.loan-report-card strong { color: var(--text-main); font-size: 1.35rem; }
.loan-report-card--warning { border-top-color: #d97706; background: #fffbeb; }
.loan-report-card--primary { border-top-color: #2563eb; background: #eff6ff; }
.loan-report-card--success { border-top-color: #16a34a; background: #f0fdf4; }

.loan-report-quantity { color: #334155; font-size: 0.84rem; }
.loan-total-due { color: #b45309; font-weight: 800; }
.loan-mora { display: flex; flex-direction: column; gap: 0.15rem; white-space: nowrap; }
.loan-mora small { color: var(--text-muted); font-size: 0.72rem; }
.loan-mora--cobrada b { color: #15803d; }
.loan-mora--pendiente b { color: #b45309; }

/* Hoja de ruta del cobrador */
.route-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.route-summary-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-left: 4px solid #475569;
    border-radius: 0.85rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.route-summary-card span, .route-summary-card small { color: var(--text-muted); font-size: 0.78rem; }
.route-summary-card strong { color: var(--text-main); font-size: 1.35rem; }
.route-summary-card--mora { border-left-color: #d97706; background: #fffbeb; }
.route-summary-card--total { border-left-color: #15803d; background: #f0fdf4; }
.route-summary-card--cobrado { border-left-color: #2563eb; background: #eff6ff; }
.route-current-date { margin-top: 0.35rem; color: #475569; font-size: 0.82rem; }
.route-current-date strong { color: var(--primary); }
.route-address { max-width: 220px; white-space: normal; color: #475569; font-size: 0.8rem; line-height: 1.35; }
.loan-credit { text-align: center; }
.route-capital { display: block; margin-top: 0.22rem; color: #1d4ed8; font-size: 0.76rem; font-weight: 800; text-align: center; }
#tabla-ruta-cobros th:nth-child(5),
#tabla-ruta-cobros th:nth-child(10),
#tabla-ruta-cobros th:nth-child(11) { text-align: center; }
.route-total { color: #15803d; font-weight: 800; white-space: nowrap; }
.route-status-cell { min-width: 132px; text-align: center; vertical-align: middle; }
.route-actions-cell { min-width: 110px; text-align: center; vertical-align: middle; }
.route-paid-action small { color: #15803d; font-weight: 700; font-size: 0.8rem; }
.route-recargo-info { display: flex; flex-direction: column; align-items: center; gap: 0.24rem; min-width: 132px; }
.route-actions-cell > .btn-table-action { margin: 0; }
.route-mora { display: flex; flex-direction: column; gap: 0.12rem; white-space: nowrap; }
.route-mora b { color: #b45309; }
.route-mora small, .route-no-mora { color: var(--text-muted); font-size: 0.72rem; }
.route-daily-delay { display: block; margin-top: 0.3rem; color: #b45309; font-size: 0.72rem; font-weight: 700; }
.route-daily-current { display: block; margin-top: 0.3rem; color: #15803d; font-size: 0.72rem; font-weight: 700; }
.is-daily-route .mora-column, .is-daily-route td.mora-column { display: none; }

/* Panel principal con datos reales */
.card-resumen--vencido { border-left: 4px solid var(--color-vencido); }
.card-resumen--vencido .card-title, .card-resumen--vencido .card-value { color: var(--color-vencido); }
.resumen-link-card { text-decoration: none; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.resumen-link-card:hover, .resumen-link-card:focus-visible { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(220, 38, 38, .16); outline: 2px solid #fca5a5; outline-offset: 2px; }
.inicio-total { color: #15803d; font-weight: 800; }
.inicio-mora { color: #b45309; font-weight: 700; }
.inicio-cartera-card { border-top: 4px solid #64748b; }
.inicio-cartera-diario { border-top-color: var(--color-diario); }
.inicio-cartera-semanal { border-top-color: var(--color-semanal); }
.inicio-cartera-quincenal { border-top-color: #7c3aed; }
.inicio-cartera-mensual { border-top-color: #db2777; }
.inicio-cartera-saldo { font-weight: 700; color: #475569; margin-top: 0.35rem; }

/* Pestañas de configuración */
.config-container { max-width: 850px; }
.config-tabs { display: flex; gap: .5rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.config-tab { border: 0; background: transparent; padding: .7rem .9rem; color: var(--text-muted); font-weight: 700; white-space: nowrap; cursor: pointer; border-bottom: 3px solid transparent; }
.config-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.config-tab-panel { display: none; }
.config-tab-panel.is-active { display: block; }
.config-section-title { font-size: 1.2rem; color: var(--primary); margin: .5rem 0 1rem; font-weight: 700; border-bottom: 2px solid var(--border); padding-bottom: .5rem; }
.config-modalidad-title { color: var(--primary-light); margin: 1rem 0 .4rem; font-size: .95rem; text-transform: uppercase; }
.payment-method-list { display: grid; gap: .65rem; margin: 1rem 0; }
.payment-method-row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: center; padding: .7rem; border: 1px solid var(--border); border-radius: .65rem; background: #f8fafc; }
.method-switch { display: flex; gap: .35rem; align-items: center; color: var(--text-main); font-size: .85rem; font-weight: 600; }
.method-new { color: #15803d; font-size: .8rem; font-weight: 700; }
.btn-add-method { border: 1px dashed var(--primary); color: var(--primary); background: #f0fdf4; border-radius: .55rem; padding: .65rem .9rem; font-weight: 700; cursor: pointer; }
.client-list-wrap { overflow-x: auto; margin-top: 1rem; border: 1px solid var(--border); border-radius: .7rem; }
.client-list-table { width: 100%; min-width: 780px; border-collapse: collapse; font-size: .86rem; }
.client-list-table th, .client-list-table td { padding: .75rem; border-bottom: 1px solid var(--border); text-align: left; }
.client-list-table th { color: var(--text-muted); background: #f8fafc; font-size: .74rem; text-transform: uppercase; }
.client-address { max-width: 250px; white-space: normal; }
.btn-client-config-edit { border: 1px solid #86efac; border-radius: .45rem; padding: .42rem .6rem; background: #f0fdf4; color: #166534; font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn-client-config-edit:hover { color: #fff; background: #15803d; }
.client-actions { min-width: 105px; }
.btn-client-config-manage { border: 1px solid #0f766e; border-radius: .45rem; padding: .42rem .72rem; background: #f0fdfa; color: #115e59; font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn-client-config-manage:hover { background: #0f766e; color: #fff; }
.btn-client-config-correct, .btn-client-config-delete { border-radius: .45rem; padding: .42rem .6rem; font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn-client-config-correct { border: 1px solid #fcd34d; background: #fffbeb; color: #92400e; }
.btn-client-config-correct:hover { background: #d97706; color: #fff; }
.btn-client-config-delete { border: 1px solid #fca5a5; background: #fff1f2; color: #b91c1c; }
.btn-client-config-delete:hover { background: #dc2626; color: #fff; }
.client-history-lock { color: #64748b; font-size: .74rem; font-weight: 600; align-self: center; }
.form-control:disabled#config-cliente-cedula {
    border-color: #cbd5e1;
    background: #e9eef5;
    color: #64748b;
    cursor: not-allowed;
    opacity: 1;
}
.client-manager-options { display: grid; gap: .65rem; margin-top: .8rem; text-align: left; }
.client-manager-option { width: 100%; border: 1px solid #cbd5e1; border-radius: .65rem; padding: .8rem .9rem; background: #fff; color: #173c37; text-align: left; cursor: pointer; font: inherit; }
.client-manager-option strong, .client-manager-option span { display: block; }
.client-manager-option strong { font-size: .9rem; margin-bottom: .15rem; }
.client-manager-option span { color: #64748b; font-size: .78rem; line-height: 1.35; }
.client-manager-option:hover { border-color: #0f766e; background: #f0fdfa; }
.client-manager-option--danger:hover { border-color: #dc2626; background: #fff1f2; }
.client-manager-option--danger strong { color: #b91c1c; }
.client-manager-locked { margin: .2rem 0 0; padding: .7rem; border-radius: .55rem; background: #f8fafc; color: #64748b; font-size: .8rem; }
.backup-info-card { display: grid; gap: .38rem; padding: 1rem; margin: 1rem 0; border: 1px solid #bbf7d0; border-left: 4px solid #16a34a; border-radius: .7rem; background: #f0fdf4; color: #14532d; }
.backup-info-card code { padding: .35rem .5rem; overflow-wrap: anywhere; border-radius: .35rem; background: #dcfce7; color: #166534; font-size: .78rem; }
.backup-info-card span { color: #3f6212; font-size: .84rem; }
.backup-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.btn-backup-restore, .btn-backup-download, .btn-backup-email { display: inline-flex; justify-content: center; align-items: center; border: 1px solid #b45309; border-radius: .55rem; padding: .68rem .95rem; color: #92400e; background: #fffbeb; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn-backup-email { border-color: #1d4ed8; color: #1e40af; background: #eff6ff; }
.backup-warning { margin: .7rem 0 1rem; color: #9a3412; font-size: .86rem; font-weight: 600; }
.backup-list-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: .7rem; }
.backup-list-table { width: 100%; min-width: 650px; border-collapse: collapse; font-size: .86rem; }
.backup-list-table th, .backup-list-table td { padding: .75rem; border-bottom: 1px solid var(--border); text-align: left; }
.backup-list-table th { color: var(--text-muted); background: #f8fafc; font-size: .74rem; text-transform: uppercase; }
.backup-list-table td:first-child { font-family: Consolas, monospace; font-size: .78rem; }
.backup-loading { text-align: center; color: var(--text-muted); padding: 1.2rem !important; }
.backup-loading--error { color: #b91c1c; }
.backup-type { display: inline-block; padding: .22rem .48rem; border-radius: 999px; font-weight: 700; font-size: .74rem; }
.backup-type--auto { color: #1d4ed8; background: #dbeafe; }
.backup-type--manual { color: #166534; background: #dcfce7; }

@media (max-width: 600px) {
    .loan-action-group { flex-direction: column; align-items: stretch; }
    .btn-loan-action { width: 100%; }
    .loan-modal-actions { flex-direction: column-reverse; }
    .loan-modal-actions button { width: 100%; }
    .loan-header-actions { width: 100%; flex-direction: column-reverse; align-items: stretch; }
    .loan-header-actions .btn-header-action { text-align: center; }
    .loan-report-summary { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
    .loan-report-card { padding: 0.75rem; }
    .loan-report-card strong { font-size: 1.05rem; }
    .route-summary { grid-template-columns: 1fr; gap: 0.65rem; }
    .route-summary-card { padding: 0.75rem; }
    #modal-cobro-contenedor { padding: 0.6rem; }
    #modal-cobro-contenedor .modal-cobro-box { max-height: calc(100vh - 1.2rem); padding: 1.25rem; }
}

@media print {
    @page { size: landscape; margin: 10mm; }
    .table-container { max-height: none !important; overflow: visible !important; }
    .data-table th { position: static !important; box-shadow: none !important; }
    .loan-report-summary { grid-template-columns: repeat(4, 1fr); margin: 0 0 0.75rem; }
    .loan-report-card { padding: 0.55rem; border-width: 1px 1px 3px; }
    .loan-report-card strong { font-size: 1rem; }
    .data-table th, .data-table td { padding: 0.38rem !important; font-size: 0.66rem !important; }
    .loan-mora small { font-size: 0.58rem; }
    .route-summary { grid-template-columns: repeat(3, 1fr); margin: 0 0 0.75rem; }
    .route-summary-card { padding: 0.55rem; }
    .route-summary-card strong { font-size: 1rem; }
    .route-address { max-width: 180px; font-size: 0.62rem; }
    .route-current-date { font-size: 0.72rem; }
}

/* Selección exclusiva del cobro semanal administrativo. */
.weekly-installments { margin: 1rem 0; }
.weekly-installments h3 { margin: 0 0 0.25rem; font-size: 0.9rem; color: #0f2f2a; }
.weekly-installments p { margin: 0 0 0.65rem; font-size: 0.77rem; color: #52708d; }
.weekly-installments-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
.weekly-installment { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.65rem; padding: 0.65rem 0.75rem; border: 1px solid #cbd9ea; border-radius: 0.6rem; cursor: pointer; }
.weekly-installment:has(input:checked) { border-color: #0f766e; background: #edfdf7; }
.weekly-installment span { display: grid; gap: 0.12rem; }
.weekly-installment small { color: #59718e; font-size: 0.72rem; }
.weekly-installment strong { color: #073f38; font-size: 0.86rem; }
.weekly-installment.is-paid { opacity: 0.62; cursor: default; background: #f4f7fa; }
.weekly-installment.is-paid strong { color: #16803a; }
.weekly-action-guide { margin: 0.7rem 0; padding: 0.65rem 0.75rem; border-radius: 0.55rem; background: #eef6ff; color: #174ea6; font-size: 0.78rem; font-weight: 600; }
#semanal-abono-cuota-grupo[hidden] { display: none !important; }
#semanal-abono-mora-grupo[hidden] { display: none !important; }
#semanal-lista-cuotas[hidden] { display: none !important; }
#modal-semanal-contenedor.is-mensual #semanal-opcion-mora { display: none !important; }
#modal-semanal-contenedor {
    align-items: flex-start;
    overflow-y: auto;
    padding: 1rem;
    box-sizing: border-box;
}
#modal-semanal-contenedor .modal-cobro-box {
    max-width: 560px;
    margin: 0 auto;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-sizing: border-box;
}
@media (max-width: 560px) {
    .weekly-installments-list { grid-template-columns: 1fr; }
}
.client-email-note {
    display: block;
    margin-top: 0.45rem;
    padding: 0.55rem 0.7rem;
    color: #1d4ed8;
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    border-radius: 0.3rem;
    font-weight: 600;
}
