/* ============================================
   Tesorería Pro - Estilos v5.0
   Diseño: Sidebar + Tabs + Dashboard + Login
   ============================================ */

:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --sidebar-bg: #0f2444;
    --sidebar-bg-2: #16356b;
    --sidebar-hover: rgba(255,255,255,.07);
    --sidebar-active: #2563eb;
    --sidebar-text: #a8bcd8;
    --sidebar-solid: #16356b;
    --topbar-bg: #ffffff;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --table-header: #f8fafc;
    --table-even: #ffffff;
    --table-odd: #f8fafc;
    --table-selected: #dbeafe;
    --status-pagado: #fef9c3;
    --status-falta: #fee2e2;
    --status-favor: #dcfce7;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.03);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
    --sidebar-width: 272px;
    --sidebar-collapsed: 80px;
    --sidebar-drawer: min(300px, 86vw);
    --topbar-height: 56px;
    --transition: .2s ease;
}

/* ===== TEMA OSCURO ===== */
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --sidebar-bg: #081a33;
    --sidebar-bg-2: #0f2a52;
    --sidebar-hover: rgba(255,255,255,.06);
    --sidebar-active: #2563eb;
    --sidebar-solid: #0f2a52;
    --topbar-bg: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-light: #1e293b;
    --table-header: #1e293b;
    --table-even: #1e293b;
    --table-odd: #172033;
    --table-selected: #1e3a5f;
    --status-pagado: #422006;
    --status-falta: #450a0a;
    --status-favor: #052e16;
    --shadow: 0 1px 3px rgba(0,0,0,.2), 0 1px 2px rgba(0,0,0,.15);
    --shadow-md: 0 4px 6px rgba(0,0,0,.2), 0 2px 4px rgba(0,0,0,.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.3);
}

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #0f172a;
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="dark"] .login-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .registro-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .registro-input-wrap input,
[data-theme="dark"] .registro-input-wrap select {
    background: #0f172a;
    color: var(--text-primary);
}

[data-theme="dark"] .btn-ghost {
    color: var(--text-secondary);
}
[data-theme="dark"] .btn-ghost:hover {
    background: rgba(255,255,255,.08);
    color: var(--text-primary);
}

[data-theme="dark"] table th {
    background: var(--table-header);
    color: var(--text-secondary);
}
[data-theme="dark"] table td {
    border-color: var(--border);
}

[data-theme="dark"] .modal-content {
    background: var(--surface);
    border-color: var(--border);
}

.theme-toggle {
    font-size: 18px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.theme-toggle:hover {
    transform: scale(1.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(140deg, #0f2444 0%, #1d4ed8 55%, #3b82f6 100%);
}
.login-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    width: 400px;
    max-width: 90vw;
    overflow: hidden;
    animation: modalIn .3s ease;
}
.login-header {
    text-align: center;
    padding: 36px 32px 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
}
.login-icon {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,.2);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}
.login-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}
.login-header p {
    font-size: 13px;
    opacity: .85;
}
#formLogin {
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.login-field {
    display: flex;
    flex-direction: column;
}
.login-field label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.login-field input {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}
.login-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.login-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}
.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    justify-content: center;
}
.login-footer {
    text-align: center;
    padding: 12px;
    border-top: 1px solid var(--border-light);
    color: var(--text-muted);
}
/* ===== Variante de acceso alternativo (clases .plataforma) ===== */
.login-screen.pantalla-plataforma {
    background: linear-gradient(135deg, #0f0a2e 0%, #2a1e5f 50%, #0f0a2e 100%);
}
.login-card.plataforma .login-header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed 60%, #9333ea);
}
.login-card.plataforma .login-btn {
    background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
    border: none !important;
    color: #fff !important;
}
.login-cross {
    text-align: center;
    padding: 4px 24px 16px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.login-cross a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.login-cross a:hover { text-decoration: underline; }
.login-card.plataforma .login-cross a { color: #7c3aed; }

/* ===== LOGIN PÚBLICO DE INSTITUCIONES: minimalista ===== */
.login-screen.login-minimal {
    background: var(--bg);
}
.login-card.login-card-minimal {
    width: 380px;
    padding: 42px 34px 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}
.login-minimal-brand {
    text-align: center;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text-primary);
    margin-bottom: 26px;
}
.login-card-minimal #formLogin {
    padding: 0 0 6px;
}
.login-card-minimal .login-field input {
    padding: 12px 14px;
}
.login-minimal-alt {
    text-align: center;
    padding-top: 2px;
}
.login-minimal-reg {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
}
.login-minimal-reg:hover {
    color: var(--accent);
    text-decoration: underline;
}
/* ===== Banner de operación asistida (soporte dentro de una institución) ===== */
.acting-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 14px;
    padding: 10px 16px;
    background: linear-gradient(90deg, #312e81, #6d28d9);
    color: #fff;
    border-radius: 10px;
    font-size: 13px;
}
.acting-banner .acting-exit {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}
.acting-banner .acting-exit:hover { background: rgba(255,255,255,.28); }



/* ===== REGISTRO DE INSTITUCIÓN ===== */
.registro-card {
    background: var(--surface);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0,0,0,.35);
    width: 560px;
    max-width: 95vw;
    max-height: 95vh;
    overflow-y: auto;
    animation: modalIn .4s ease;
}
.registro-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 28px 32px 20px;
    background: linear-gradient(135deg, #3b82f6, #2563eb, #1d4ed8);
    color: #fff;
    border-radius: 20px 20px 0 0;
}
.registro-header-icon {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,.2);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    backdrop-filter: blur(4px);
}
.registro-header h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
}
.registro-header p {
    font-size: 13px;
    opacity: .85;
    margin: 0;
}
.registro-form {
    padding: 24px 32px;
}

/* Steps indicator */
.registro-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 28px;
    padding: 0 20px;
}
.registro-step {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: .4;
    transition: all .3s ease;
}
.registro-step.active {
    opacity: 1;
}
.registro-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    transition: all .3s ease;
}
.registro-step.active .registro-step-num {
    background: #3b82f6;
    color: #fff;
    box-shadow: 0 4px 12px rgba(59,130,246,.35);
}
.registro-step-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}
.registro-step.active .registro-step-label {
    color: #1e293b;
}
.registro-step-line {
    flex: 1;
    height: 2px;
    background: #e2e8f0;
    margin: 0 16px;
    min-width: 40px;
}

/* Section titles */
.registro-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}
.registro-section-icon {
    font-size: 22px;
}

/* Fields */
.registro-field {
    margin-bottom: 16px;
}
.registro-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}
.reg-required {
    color: #ef4444;
}
.registro-input-wrap {
    display: flex;
    align-items: center;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    transition: all .2s ease;
    overflow: hidden;
}
.registro-input-wrap:focus-within {
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(59,130,246,.1);
}
.registro-input-icon {
    padding: 0 4px 0 14px;
    font-size: 16px;
    flex-shrink: 0;
}
.registro-input-wrap input,
.registro-input-wrap select {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 14px 12px 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    color: #1e293b;
    min-width: 0;
}
.registro-input-wrap select {
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.registro-hint {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding-left: 2px;
}

/* Row layout */
.registro-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Buttons */
.registro-btn-next {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all .2s ease;
    letter-spacing: .3px;
}
.registro-btn-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59,130,246,.35);
}
.registro-btn-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}
.registro-btn-back {
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all .2s ease;
}
.registro-btn-back:hover {
    background: #e2e8f0;
}
.registro-btn-submit {
    flex: 1;
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all .2s ease;
    letter-spacing: .3px;
}
.registro-btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16,185,129,.35);
}
.registro-btn-submit:disabled {
    opacity: .6;
    transform: none;
    box-shadow: none;
}

/* Alerts */
.registro-alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
}
.registro-alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.registro-alert-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* Footer */
.registro-footer {
    padding: 16px 32px 20px;
    text-align: center;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.registro-plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.registro-back-link {
    color: #3b82f6;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color .2s;
}
.registro-back-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* Paso animations */
.registro-paso {
    animation: regFadeIn .3s ease;
}
@keyframes regFadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 600px) {
    .registro-card { border-radius: 0; max-height: 100vh; }
    .registro-header { border-radius: 0; padding: 20px; }
    .registro-form { padding: 20px; }
    .registro-row { grid-template-columns: 1fr; }
    .registro-footer { padding: 12px 20px 16px; }
    .registro-header h1 { font-size: 17px; }
    .registro-btn-group { flex-direction: column; }
    .registro-step-label { display: none; }
}

/* ===== APP CONTAINER ===== */
#appContainer {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* ===== USER BADGE (topbar) ===== */
.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    background: var(--bg);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}
.user-avatar {
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}
.user-rol-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.rol-admin {
    background: #fef3c7;
    color: #92400e;
}
.rol-user {
    background: #dbeafe;
    color: #1e40af;
}

/* Badges for user table */
.badge-admin {
    background: #fef3c7;
    color: #92400e;
}
.badge-user {
    background: #dbeafe;
    color: #1e40af;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 62%);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    transition: width var(--transition);
    border-right: 1px solid rgba(255,255,255,.06);
}
/* ── Estado colapsado: solo iconos (tooltip al pasar el cursor) ── */
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .brand-text-wrap,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .context-chip,
.sidebar.collapsed .sidebar-user { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding-left: 10px; padding-right: 10px; }
.sidebar.collapsed .sidebar-footer { justify-content: center; }
.sidebar.collapsed .sidebar-collapse { margin-left: 0; }
.sidebar.collapsed .sidebar-collapse .chev { transform: rotate(180deg); }
.sidebar.collapsed .nav-item { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .brand-logo { margin-right: 0; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 70px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,.09);
}
.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(37,99,235,.4);
}
.sidebar-drawer-close {
    display: none;
    margin-left: auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.06);
    color: var(--sidebar-text);
    font-size: 14px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-drawer-close:hover { background: rgba(255,255,255,.14); color: #fff; }
.brand-text {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-text-wrap {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.brand-subtitle {
    font-size: 12px;
    font-weight: 600;
    color: #fbbf24;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin-top: 2px;
}
.brand-tipo-tesoreria {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    padding: 2px 8px;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-top: 3px;
    display: inline-block;
    max-width: 100%;
    letter-spacing: 0.3px;
}
/* Colores por tipo de tesorería */
.tipo-tes-estudiantes {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}
.tipo-tes-padres {
    background: linear-gradient(135deg, #10b981, #059669);
}
.tipo-tes-profesores {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}
.tipo-tes-comite {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}
.tipo-tes-default {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}
.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: rgba(168,188,216,.45);
    padding: 14px 12px 6px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-nav > .nav-section-title:first-child { padding-top: 2px; }
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px 6px 6px;
    border-radius: 11px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sidebar-text);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    line-height: 1.4;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item:focus-visible { outline: 2px solid #60a5fa; outline-offset: -2px; }
.nav-item.active {
    background: linear-gradient(90deg, var(--sidebar-active), #3b82f6);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
}
.nav-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: rgba(255,255,255,.06);
    transition: background var(--transition);
}
.nav-item:hover .nav-icon { background: rgba(255,255,255,.12); }
.nav-item.active .nav-icon { background: rgba(255,255,255,.18); }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* Tooltip solo en modo colapsado (iconos) */
.sidebar.collapsed .nav-item::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: var(--sidebar-solid);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 8px 22px rgba(2,10,28,.45);
    border: 1px solid rgba(255,255,255,.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
    z-index: 400;
}
.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .nav-item:focus-visible::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.09);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--sidebar-text);
    min-height: 54px;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.sidebar-user .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-collapse {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.06);
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}
.sidebar-collapse:hover { background: rgba(255,255,255,.14); color: #fff; }
.sidebar-collapse .chev { display: inline-block; transition: transform .25s ease; }
.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(16,185,129,.18);
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar-left h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}
.topbar-tipo-tesoreria {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    padding: 4px 14px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
    animation: pulseGlow 2s ease-in-out infinite;
}
@keyframes pulseGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
}
.sidebar-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--bg); color: var(--text-primary); }
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;
}
.tab-content.active { display: flex; flex-direction: column; gap: 20px; }

/* ===== STAT CARDS ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}
.stat-card.stat-total  { border-left-color: var(--accent); }
.stat-card.stat-falta  { border-left-color: var(--danger); }
.stat-card.stat-favor  { border-left-color: var(--success); }
.stat-card.stat-pagado { border-left-color: var(--warning); }

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== CONTENT GRID ===== */
.content-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    min-height: 0;
}
.reportes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.card-form { flex-shrink: 0; }
.card-table { flex: 1; min-height: 200px; }

.form-grid-compact {
    grid-template-columns: repeat(3, 1fr) !important;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
    min-height: 0;
}
.table-wrapper { padding: 0; }

/* ===== FORMS ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group.span-full { grid-column: 1 / -1; }

label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-secondary);
}
.label-deuda { color: var(--danger) !important; }
.required { color: var(--danger); }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
    background: var(--surface);
    color: var(--text-primary);
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.input-deuda {
    background: #fffbeb;
    border-color: var(--warning);
}
.input-deuda:focus { border-color: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,.12); }
.input-monto {
    font-size: 16px;
    font-weight: 700;
    background: #fef2f2;
    border: 2px solid var(--danger);
}
.input-monto:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.12); }
.input-password {
    width: 100%;
    padding: 12px;
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    color: #fff;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); }
.btn-warning { background: var(--warning); }
.btn-danger  { background: var(--danger); }
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

/* ===== SEARCH BOX ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 6px 2px 10px;
}
.search-icon { font-size: 14px; }
.search-box input {
    border: none;
    background: none;
    padding: 6px 8px;
    width: 200px;
    max-width: 100%;
    min-width: 0;
    font-size: 13px;
    outline: none;
}
.search-box input:focus { box-shadow: none; }
.btn-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    font-size: 14px;
    border-radius: 4px;
}
.btn-clear:hover { background: var(--border); color: var(--text-primary); }

/* ===== FILTER SELECT ===== */
.filtro-select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    min-width: 120px;
}
.filtro-select:focus { border-color: var(--accent); }

/* ===== TABLES ===== */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    background: var(--table-header);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .4px;
    position: sticky;
    top: 0;
    z-index: 1;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    transition: background var(--transition);
}
thead th:hover { background: var(--border); }

tbody tr {
    cursor: pointer;
    transition: background .1s;
}
tbody tr:nth-child(even) { background: var(--table-even); }
tbody tr:nth-child(odd)  { background: var(--table-odd); }
tbody tr:hover { background: var(--table-selected); }
tbody tr.selected {
    background: var(--table-selected) !important;
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

/* Status colors */
tr.mov-cobro td { color: var(--danger); font-weight: 600; }
tr.mov-pago  td { color: var(--success); font-weight: 600; }

/* ===== ROW ACTION BUTTONS ===== */
.row-actions {
    display: flex;
    gap: 4px;
    white-space: nowrap;
}
.btn-action {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--text-secondary);
}
.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-action.action-info {
    color: var(--success);
    border-color: var(--success);
}
.btn-action.action-info:hover { background: #f0fdf4; }
.btn-action.action-edit {
    color: var(--warning);
    border-color: var(--warning);
}
.btn-action.action-edit:hover { background: #fffbeb; }
.btn-action.action-delete {
    color: var(--danger);
    border-color: var(--danger);
}
.btn-action.action-delete:hover { background: #fef2f2; }

/* ===== DISTRIBUTION BARS ===== */
.dist-bar-container {
    margin-bottom: 14px;
}
.dist-bar-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
}
.dist-bar-label span:first-child { color: var(--text-secondary); }
.dist-bar-label span:last-child  { font-weight: 700; }
.dist-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}
.dist-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .5s ease;
}

/* ===== TOP DEUDORES LIST ===== */
.top-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.top-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
}
.top-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.top-info { flex: 1; }
.top-info strong { display: block; font-size: 13px; color: var(--text-primary); }
.top-info small { color: var(--text-secondary); font-size: 12px; }
.top-amount { font-weight: 700; color: var(--danger); font-size: 14px; }

/* ===== INFO GRID (modal) ===== */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.info-item {
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.info-item label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.info-item .info-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.info-item.span-full { grid-column: 1 / -1; }
.info-saldo-box {
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
    margin-top: 8px;
}
.info-saldo-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
    font-weight: 500;
}
.info-saldo-value {
    font-size: 28px;
    font-weight: 700;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 15px; font-weight: 500; margin-bottom: 4px; color: var(--text-secondary); }
.empty-state small { font-size: 13px; }

/* ===== ACTION LIST (Reportes/Respaldos) ===== */
.action-list { display: flex; flex-direction: column; gap: 6px; }
.action-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border-light);
}
.action-item:hover {
    background: var(--bg);
    border-color: var(--border);
    transform: translateX(4px);
}
.action-item.action-danger:hover { background: #fef2f2; border-color: #fecaca; }

.action-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.bg-green  { background: #dcfce7; }
.bg-blue   { background: #dbeafe; }
.bg-red    { background: #fee2e2; }
.bg-yellow { background: #fef9c3; }

.action-info { flex: 1; }
.action-info strong { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.action-info small { color: var(--text-secondary); font-size: 12px; }
.action-arrow { color: var(--text-muted); font-size: 18px; font-weight: 300; }

/* Select Respaldo (modal) */
.select-respaldo {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
}
.select-respaldo:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.acciones-respaldo {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ===== RESUMEN ===== */
.resumen-loading {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}
.resumen-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.resumen-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.resumen-row:last-child { border-bottom: none; }
.resumen-row-label { font-weight: 500; color: var(--text-secondary); }
.resumen-row-value { font-weight: 700; font-size: 16px; }

/* ===== ALERT ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}
.alert-icon { font-size: 20px; }

/* ===== BADGE ===== */
.badge {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    z-index: 1;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 440px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalIn .2s ease;
}
.modal-content.modal-lg { width: 700px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }

.modal-body {
    padding: 24px;
    overflow: auto;
    flex: 1;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== PRINT ===== */
@media print {
    body { overflow: visible; height: auto; }
    .sidebar, .topbar, .form-actions, .search-box, .btn,
    .stats-row, .modal-footer, .modal-overlay, .tab-content:not(.print-active) {
        display: none !important;
    }
    .main-wrapper { overflow: visible; }
    .tab-content { overflow: visible; padding: 10px; }
    .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
    table { font-size: 11px; }
    #modalImprimir { position: static; }
    #modalImprimir .modal-content { width: 100%; box-shadow: none; max-height: none; }
    #modalImprimir .modal-overlay { display: none; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    /* El auto-colapso del sidebar en tablet lo aplica JS con la clase .collapsed
       (mismos estilos + tooltips); aquí solo maquetamos el contenido. */
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .reportes-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .tab-content { padding: 16px; }
}

/* ===== MOBILE OVERLAY ===== */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 99;
    -webkit-tap-highlight-color: transparent;
}
.mobile-overlay.active { display: block; }

@media (max-width: 768px) {
    /* Drawer fuera de pantalla: entra deslizándose sobre overlay */
    .sidebar,
    .sidebar.collapsed {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: var(--sidebar-drawer);
        z-index: 100;
        transform: translateX(-105%);
        transition: transform 0.28s ease;
        box-shadow: 12px 0 40px rgba(2,8,23,.55);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    /* En drawer el menú SIEMPRE se muestra expandido (ignora .collapsed) */
    .sidebar.collapsed .brand-text-wrap,
    .sidebar.collapsed .sidebar-user,
    .sidebar.collapsed .context-chip { display: flex; }
    .sidebar.collapsed .nav-label,
    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .brand-subtitle,
    .sidebar.collapsed .sidebar-footer .nav-label { display: inline; }
    .sidebar.collapsed .nav-section-title { display: block; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; gap: 12px; padding: 6px 10px 6px 6px; }
    .sidebar.collapsed .sidebar-brand { justify-content: flex-start; padding-left: 18px; padding-right: 18px; }
    .sidebar.collapsed .sidebar-footer { justify-content: flex-start; }
    .sidebar.collapsed .nav-item::after { display: none; } /* sin tooltips en drawer */
    .sidebar-collapse { display: none; }
    .sidebar-drawer-close { display: inline-flex; }

    /* Topbar compacto */
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar-left h2 { font-size: 14px; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-right { gap: 4px; }
    .topbar-right .btn { padding: 6px 8px; font-size: 12px; }
    .topbar-right .btn .btn-text-hide { display: none; }
    .user-badge { padding: 2px 8px 2px 2px; font-size: 11px; }
    .user-badge #topbarUserName { display: none; }
    .user-rol-badge { font-size: 9px !important; padding: 1px 5px !important; }
    .topbar-tipo-tesoreria { font-size: 9px; padding: 2px 8px; }

    /* Contenido */
    .tab-content { padding: 12px; gap: 12px; }
    .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 11px; }

    /* Formularios */
    .form-grid, .form-grid-compact { grid-template-columns: 1fr !important; }
    .form-group.span-full { grid-column: 1; }
    .row-actions { flex-wrap: wrap; }

    /* Dashboard */
    .dashboard-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }

    /* Cards */
    .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .card-header h3 { font-size: 14px; }
    .card-body { padding: 12px 14px; }
    .header-actions { flex-wrap: wrap; gap: 6px; width: 100%; }
    .header-actions .search-box { flex: 1; min-width: 0; }
    .header-actions .search-box input { width: 100%; }
    .header-actions .filtro-select { flex: 1; min-width: 100px; }

    /* Tablas */
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { font-size: 12px; }
    table th, table td { padding: 8px 6px; }

    /* Modales */
    .modal-content { width: 92vw !important; max-width: 440px; }
    .modal-content.modal-lg { width: 95vw !important; max-width: 700px; }
    .modal-header { padding: 12px 14px; }
    .modal-body { padding: 12px 14px; }

    /* Chip de contexto compacto en móvil */
    .context-chip { padding: 7px 9px; gap: 7px; }
    .context-chip-note { font-size: 10.5px; }
    .th-acceso { min-width: 0; }

    /* Suscripción */
    .mi-sub-info { flex-direction: column; }
    .plan-card { flex: none; width: 100%; }
}

@media (max-width: 480px) {
    /* Ultra-compact para teléfonos pequeños */
    .topbar-left h2 { max-width: 90px; font-size: 13px; }
    .tab-content { padding: 8px; gap: 8px; }
    .stats-row { grid-template-columns: 1fr; gap: 6px; }

    /* Login */
    .login-card { max-width: 95vw; }
    #formLogin { padding: 20px 16px; }
    .login-header { padding: 20px 16px; }

    /* Botones topbar mínimos */
    .topbar-right .btn { padding: 5px 6px; font-size: 11px; }
    .sidebar-toggle { padding: 4px 8px; font-size: 16px; }

    /* Recibo */
    .modal-recibo-container { width: 100%; }
    .recibo-paper { width: 100%; }
}

/* ============================================================
   CONTEXTO DE SESIÓN (Plataforma · Institución) — v7.4
   El contexto NO se elige en la interfaz: lo fija el servidor.
   Estos estilos solo informatizan en pantalla ese contexto.
   ============================================================ */
.context-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 12px 4px;
    padding: 9px 11px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.05);
    color: #fff;
}
.context-chip-icon { font-size: 17px; line-height: 1; flex-shrink: 0; }
.context-chip-body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.context-chip-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .6px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.context-chip-note {
    font-size: 11px;
    line-height: 1.3;
    color: rgba(226,238,255,.72);
}
.context-chip-exit {
    margin-left: auto;
    flex-shrink: 0;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.34);
    color: #fff;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 9px;
    border-radius: 8px;
    cursor: pointer;
}
.context-chip-exit:hover { background: rgba(255,255,255,.26); }
.ctx-plataforma { border-color: rgba(129,140,248,.55); background: linear-gradient(135deg, rgba(49,46,129,.75), rgba(79,70,229,.45)); }
.ctx-institucion { border-color: rgba(16,185,129,.45); background: linear-gradient(135deg, rgba(6,78,59,.6), rgba(16,185,129,.28)); }
.ctx-plataforma-text { color: #c7d2fe; }
.ctx-institucion-text { color: #065f46; }

/* Chip equivalente en la barra superior (legible sobre fondo claro) */
.topbar-contexto {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid currentColor;
    white-space: nowrap;
}
.topbar-contexto.ctx-plataforma-text { background: rgba(99,102,241,.12); }
.topbar-contexto.ctx-institucion-text { background: rgba(16,185,129,.12); color: #047857; }

/* Pista dentro de un módulo: qué contexto rige aquí */
.context-hint {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 14px;
    padding: 11px 13px;
    border-radius: 12px;
    border-left: 4px solid var(--accent);
    background: rgba(59,130,246,.08);
    color: var(--text-secondary);
    font-size: 12.5px;
    line-height: 1.5;
}
.context-hint-icon { font-size: 15px; line-height: 1.3; }
.context-hint code { background: rgba(15,23,42,.08); padding: 1px 5px; border-radius: 5px; font-size: 11.5px; }

/* Navegación rápida del Panel SaaS (orden Panel SaaS → Instituciones → Configuración) */

/* (v7.5) estilos del acceso a institución eliminados con la función */
.nav-badge {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
    color: #fff;
}

/* Badges de contexto en formularios/tablas */
.badge-contexto { font-size: 10px; letter-spacing: .4px; text-transform: uppercase; }
.badge-plataforma { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.badge-institucion { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.form-hint { display: block; margin-top: 4px; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

/* Modal de acceso a institución */
.modal-acceso { max-width: 560px; }
.acceso-inst-nombre { margin: 0 0 10px; font-size: 14px; color: var(--text-primary); }
.acceso-reglas {
    margin: 0 0 14px;
    padding-left: 18px;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-secondary);
}
.acceso-reglas li { margin-bottom: 4px; }

/* ===== MULTI-INSTITUCIÓN ===== */
.tipo-tesoreria-select {
    border: 2px solid #f59e0b;
    background: #fffbeb;
}

/* Mi Institución */
.mi-inst-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.mi-inst-logo {
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 2px solid var(--border);
}
.mi-inst-logo-placeholder {
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    border: 2px solid var(--border);
}
.mi-inst-info h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

/* ===== UPLOAD DE ARCHIVOS ===== */
.file-upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--table-header);
    overflow: hidden;
}
.file-upload-area:hover {
    border-color: var(--accent);
    background: #f0f7ff;
}
.file-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-upload-label {
    font-size: 13px;
    color: var(--text-secondary);
}
.file-upload-sm {
    padding: 12px;
}
.file-preview-img {
    max-width: 120px;
    max-height: 120px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    margin: 0 auto;
    display: block;
}
.inst-thumb {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}
.inst-thumb-placeholder {
    display: inline-block;
    width: 32px;
    height: 32px;
    text-align: center;
    line-height: 32px;
    font-size: 18px;
}
.doc-link {
    text-decoration: none;
    font-size: 16px;
}
.doc-link:hover { opacity: .7; }

/* ===== INFO PERSONA FOTO ===== */
.info-persona-top {
    text-align: center;
    margin-bottom: 16px;
}
.info-persona-foto {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
}
.info-persona-foto-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    border: 3px solid var(--border);
}

/* ===== BADGES ===== */
.badge-super {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
    font-weight: 600;
}
.badge-admin {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}
.badge-user {
    background: var(--text-muted);
    color: #fff;
}
.badge-completo {
    background: #dbeafe;
    color: #2563eb;
}
.badge-datos {
    background: #fef9c3;
    color: #ca8a04;
}
.user-rol-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    margin-left: 4px;
}
.user-rol-badge.rol-super {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
}
.user-rol-badge.rol-admin {
    background: var(--accent);
    color: #fff;
}
.user-rol-badge.rol-user {
    background: var(--text-muted);
    color: #fff;
}

/* ===== RESPALDOS ===== */
.select-respaldo {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
}
.acciones-respaldo {
    display: flex;
    gap: 4px;
}
.acciones-respaldo .btn {
    padding: 4px 8px;
    font-size: 12px;
}

/* ===== PANEL DE GESTIÓN GLOBAL ===== */
.saas-stats { margin-bottom: 20px; }
.saas-panels { display: flex; flex-direction: column; gap: 20px; }
.btn-xs {
    padding: 2px 6px !important;
    font-size: 12px !important;
    min-width: auto !important;
}
.badge-success { background: #22c55e; color: #fff; }
.badge-warning { background: #f59e0b; color: #fff; }
.badge-danger { background: #ef4444; color: #fff; }
.badge-info { background: #3b82f6; color: #fff; }
.text-danger { color: #ef4444; }

/* ===== MI SUSCRIPCIÓN ===== */
.mi-sub-container { display: flex; flex-direction: column; gap: 20px; }
.mi-sub-info { display: flex; gap: 24px; flex-wrap: wrap; }
.mi-sub-plan-card {
    flex: 0 0 220px;
    background: linear-gradient(135deg, var(--accent), #6d28d9);
    color: #fff;
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}
.mi-sub-plan-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.mi-sub-plan-price { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.mi-sub-plan-desc { font-size: 12px; opacity: .85; }
.mi-sub-details { flex: 1; min-width: 200px; }
.mi-sub-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.mi-sub-label { font-weight: 600; color: var(--text-muted); }
.mi-sub-value { font-weight: 500; }

/* Usage meters */
.uso-meters { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.uso-meter-item { display: flex; align-items: center; gap: 12px; }
.uso-meter-label { flex: 0 0 140px; font-weight: 600; font-size: 13px; }
.uso-meter-bar {
    flex: 1;
    height: 20px;
    background: var(--bg);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.uso-meter-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 10px;
    transition: width .5s ease;
}
.uso-meter-fill.meter-warning { background: #f59e0b; }
.uso-meter-fill.meter-danger { background: #ef4444; }
.uso-meter-text { flex: 0 0 100px; text-align: right; font-size: 13px; font-weight: 500; }

/* Feature badges */
.mi-sub-features { display: flex; gap: 12px; flex-wrap: wrap; }
.feature-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}
.feature-ok { background: #dcfce7; color: #166534; }
.feature-no { background: #fee2e2; color: #991b1b; }

/* Descuento Renovación */
.descuento-resumen {
    background: var(--surface, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}
.descuento-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}
.descuento-row.descuento-total {
    border-top: 2px solid var(--primary, #3b82f6);
    margin-top: 8px;
    padding-top: 10px;
    font-size: 16px;
}
.text-success { color: #16a34a; }
[data-theme="dark"] .descuento-resumen {
    background: var(--surface, #1e293b);
    border-color: var(--border, #334155);
}

/* Planes disponibles cards */
.planes-disponibles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.plan-card {
    border: 2px solid var(--border, #e2e8f0);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.2s;
    background: var(--surface, #fff);
}
.plan-card:hover { border-color: var(--primary, #3b82f6); transform: translateY(-2px); }
.plan-card.plan-actual { border-color: var(--primary, #3b82f6); background: rgba(59,130,246,0.05); }
.plan-card-nombre { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.plan-card-precio { font-size: 28px; font-weight: 800; color: var(--primary, #3b82f6); }
.plan-card-precio small { font-size: 14px; font-weight: 400; color: var(--text-secondary, #64748b); }
.plan-card-features { list-style: none; padding: 0; margin: 12px 0; font-size: 13px; text-align: left; }
.plan-card-features li { padding: 4px 0; }
.plan-card-features li::before { content: '✓ '; color: #16a34a; font-weight: 700; }
.plan-card-descuento { font-size: 12px; color: var(--primary, #3b82f6); font-weight: 600; margin-top: 8px; }
[data-theme="dark"] .plan-card { background: var(--surface, #1e293b); }
[data-theme="dark"] .plan-card.plan-actual { background: rgba(59,130,246,0.1); }

/* ============================================
   Recibo Térmico 80mm
   ============================================ */

#modalRecibo {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}
.modal-recibo-container {
    background: #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 302px; /* ~80mm at 96dpi */
    max-height: 92vh;
    overflow-y: auto;
    animation: modalIn .25s ease;
}
.modal-recibo-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 6px;
    flex-wrap: wrap;
    justify-content: center;
    position: sticky;
    top: 0;
    background: #e8e8e8;
    z-index: 2;
    border-radius: 8px 8px 0 0;
}
.btn-sm {
    padding: 6px 9px;
    font-size: 11px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    color: #fff;
    transition: all .2s;
}
.btn-whatsapp { background: #25d366; }
.btn-whatsapp:hover { background: #1da851; }
.btn-info { background: #06b6d4; }
.btn-info:hover { background: #0891b2; }

/* Thermal paper style */
.recibo-paper {
    width: 302px;
    padding: 12px 10px 16px;
    background: #ffffff;
    font-family: 'Courier New', Courier, monospace;
    color: #000;
    font-size: 11px;
    line-height: 1.35;
}

/* Header */
.recibo-header {
    text-align: center;
    padding-bottom: 6px;
    border-bottom: 1px dashed #000;
    margin-bottom: 6px;
}
.recibo-inst-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.recibo-logo {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}
.recibo-logo-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
}
.recibo-inst-nombre {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}
.recibo-inst-sub {
    font-size: 10px;
    color: #333;
}
.recibo-inst-tipo {
    font-size: 10px;
    color: #555;
}

/* Tipo badge */
.recibo-tipo-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 3px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 5px;
}

/* Separador punteado */
.recibo-sep {
    border: none;
    border-top: 1px dashed #000;
    margin: 6px 0;
}
/* ═════ v7.5 · dashboard ejecutivo del servicio ═════ */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.dash-title { margin: 0; font-size: 17px; font-weight: 700; color: var(--text-primary); }
.dash-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.stat-foot { display: block; margin-top: 4px; font-size: 11px; color: var(--text-muted); }
.dash-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
.dash-grid > .card:last-child { grid-column: 1 / -1; }
.alert-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 9px 12px; margin-bottom: 8px; border-radius: 10px;
    border-left: 4px solid var(--border); background: var(--table-odd); font-size: 13px;
}
.alert-item.sev-alta { border-left-color: var(--danger); background: var(--status-falta); }
.alert-item.sev-media { border-left-color: var(--warning); background: var(--status-pagado); }
.alert-item.sev-baja { border-left-color: var(--accent); }
.alert-item-text { min-width: 0; }
.alert-item-action { flex-shrink: 0; }
.cartera-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border-light); font-size: 13px; }
.cartera-row:last-of-type { border-bottom: none; }
.cartera-nota { display: block; margin-top: 8px; font-size: 11.5px; color: var(--text-muted); }
.inst-contacto { white-space: normal; font-size: 12.5px; color: var(--text-secondary); }
.th-acceso { min-width: 150px; }
.cell-acceso { gap: 4px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
/* ═══════════════════════════════════════════════════════════════
   RESTAURACIÓN v7.5.1 · tail truncado de la hoja de estilos
   (Personas + Movimientos, tarjetas de persona, botones, switch,
   consulta pública, acciones de tabla, animación shake y recibo)
   ═══════════════════════════════════════════════════════════════ */

/* ===== PERSONAS + MOVIMIENTOS (vista unificada) ===== */
.pm-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 16px;
    height: calc(100vh - var(--topbar-height) - 48px);
    min-height: 420px;
}
.pm-left {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.pm-left-header { padding: 14px 14px 10px; border-bottom: 1px solid var(--border-light); }
.pm-left-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pm-left-title h3 { margin: 0; font-size: 15px; }
/* el buscador de la lista maestra reutiliza el patrón de .search-box */
.pm-search {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 6px 2px 10px;
}
.pm-search .search-icon { font-size: 14px; color: var(--text-muted); }
.pm-search input {
    flex: 1; min-width: 0; border: none; background: none; outline: none;
    padding: 6px 8px; font-size: 13px; font-family: inherit; color: var(--text-primary);
}
.pm-search input:focus { box-shadow: none; }
.pm-search .btn-clear { flex-shrink: 0; }
.pm-persona-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Tarjetas de persona (lista maestra) */
.pm-pcard {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.pm-pcard:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.pm-pcard.active {
    border-color: var(--accent);
    background: var(--table-selected);
    box-shadow: 0 0 0 1px var(--accent) inset;
}
.pm-pcard-foto {
    width: 44px; height: 44px; border-radius: 10px; overflow: hidden;
    background: var(--table-header); display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.pm-pcard-foto img { width: 100%; height: 100%; object-fit: cover; }
.pm-pcard-info { min-width: 0; }
.pm-pcard-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-pcard-cedula { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-pcard-saldo { text-align: right; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.pm-pcard-saldo-val { font-size: 13px; font-weight: 700; white-space: nowrap; }
.pm-pcard-badge { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; padding: 2px 7px; border-radius: 999px; }
.badge-debe { background: var(--status-falta); color: #b91c1c; }
.badge-pagado { background: var(--status-favor); color: #15803d; }
[data-theme="dark"] .badge-debe { color: #fca5a5; }
[data-theme="dark"] .badge-pagado { color: #86efac; }
.debe { color: var(--danger); }
.pagado { color: var(--success); }

/* Panel derecho */
.pm-right { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pm-empty {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; text-align: center; padding: 40px 20px;
    border: 2px dashed var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text-secondary);
}
.pm-empty-icon { font-size: 40px; line-height: 1; }
.pm-empty h3 { margin: 6px 0 0; font-size: 16px; color: var(--text-primary); }
.pm-empty p { margin: 0; font-size: 13px; }
.pm-detail { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }

/* Cabecera de persona */
.pm-persona-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.pm-persona-foto {
    width: 56px; height: 56px; border-radius: 12px; overflow: hidden;
    background: var(--table-header); display: flex; align-items: center; justify-content: center;
    font-size: 26px;
}
.pm-persona-foto img { width: 100%; height: 100%; object-fit: cover; }
.pm-persona-info { min-width: 0; }
.pm-persona-nombre { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.pm-persona-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 3px; font-size: 12.5px; color: var(--text-secondary); }
.pm-meta-item { white-space: nowrap; }
.pm-persona-saldo { text-align: right; }
.pm-saldo-label { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); }
.pm-saldo-valor { font-size: 20px; font-weight: 800; }
.pm-persona-actions { display: flex; gap: 6px; }

/* Chips de resumen */
.pm-saldo-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pm-saldo-chip {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 12px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.pm-chip-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.pm-chip-value { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.pm-chip-red { color: var(--danger); }
.pm-chip-green { color: var(--success); }

/* Formulario rápido de movimiento */
.pm-mov-form {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px;
}
.pm-form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pm-tipo-btns { display: flex; gap: 6px; }
.pm-tipo-btn { position: relative; display: inline-flex; }
.pm-tipo-btn input { position: absolute; opacity: 0; width: 0; height: 0; }
.pm-tipo-btn span {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
    border: 1.5px solid var(--border); color: var(--text-secondary); background: var(--surface);
    cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.pm-tipo-btn:hover span { border-color: var(--text-muted); }
.pm-tipo-deuda input:checked + span { background: var(--status-falta); border-color: var(--danger); color: #b91c1c; }
.pm-tipo-pago input:checked + span { background: var(--status-favor); border-color: var(--success); color: #15803d; }
[data-theme="dark"] .pm-tipo-deuda input:checked + span { color: #fecaca; }
[data-theme="dark"] .pm-tipo-pago input:checked + span { color: #bbf7d0; }
.pm-input-monto { width: 130px; font-weight: 700; }
.pm-input-desc { flex: 1; min-width: 170px; }
.pm-form-extra { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.pm-form-extra input[type="text"], .pm-form-extra select { flex: 1; min-width: 140px; }
.pm-doc-upload { position: relative; flex: 1; min-width: 160px; }
.pm-doc-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-upload-label {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 12px; border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
    font-size: 12.5px; color: var(--text-secondary); background: var(--table-header);
    transition: all var(--transition); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pm-doc-upload:hover .file-upload-label, .file-upload-area:hover .file-upload-label { border-color: var(--accent); color: var(--accent); }
.pm-form-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pm-form-edit-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* Historial de movimientos */
.pm-historial {
    display: flex; flex-direction: column; min-height: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.pm-historial-header {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 14px; border-bottom: 1px solid var(--border-light); flex-wrap: wrap;
}
.pm-historial-header h4 { margin: 0; font-size: 14px; }
.pm-historial-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.pm-filter-input { width: 180px; }
.pm-filter-select { min-width: 110px; }
.pm-mov-list { flex: 1; min-height: 0; overflow: auto; }
.pm-mov-list table { width: 100%; }
.pm-mov-list .empty-state { padding: 28px 12px; }

/* Modal de persona */
.pm-modal-persona {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 24px 12px; overflow-y: auto;
}
.pm-modal-persona-inner {
    width: 720px; max-width: 100%; background: var(--surface);
    border-radius: 14px; box-shadow: var(--shadow-lg); animation: modalIn .25s ease;
}
.pm-modal-persona-header {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.pm-modal-persona-header h3 { margin: 0; font-size: 16px; }
.pm-modal-persona form { padding: 18px; }
.pm-form-persona-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.pm-form-persona-grid .span-full { grid-column: 1 / -1; }

/* ===== BOTONES AUXILIARES ===== */
.btn-accent {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff; border: none;
}
.btn-accent:hover { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.btn-round { width: 34px; height: 34px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }
.btn-link {
    background: none; border: none; color: var(--accent); font-family: inherit;
    font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 2px;
}
.btn-link:hover { text-decoration: underline; }
.btn-icon {
    width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
    color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: all var(--transition);
}
.btn-icon:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-icon-danger { color: var(--danger); border-color: var(--danger); }
.btn-icon-danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.td-acciones { white-space: nowrap; text-align: center; }
.btn-recibo {
    border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
    border-radius: 7px; padding: 3px 7px; font-size: 12px; cursor: pointer; transition: all var(--transition);
}
.btn-recibo:hover { border-color: var(--accent); color: var(--accent); }
.btn-wa-row { border-color: #16a34a; color: #16a34a; margin-left: 4px; }
.btn-wa-row:hover { background: #16a34a; border-color: #16a34a; color: #fff; }

/* ===== SWITCH (interruptor de consulta pública) ===== */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0; cursor: pointer;
    background: var(--border); border-radius: 999px; transition: var(--transition);
}
.slider:before {
    content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.slider.round, .slider.round:before { border-radius: 999px; }

/* ===== CONSULTA PÚBLICA (tarjeta de configuración del cliente) ===== */
.cp-config-card { margin-top: 18px; }
.cp-config-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cp-config-info { display: flex; flex-direction: column; gap: 4px; min-width: 240px; flex: 1; }
.cp-config-info strong { font-size: 14px; color: var(--text-primary); }
.cp-config-info small { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.cp-config-actions { display: flex; align-items: center; gap: 12px; }
.cp-config-badge {
    font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
    background: var(--status-favor); color: #15803d; white-space: nowrap;
}
.cp-config-badge.off { background: var(--status-falta); color: #b91c1c; }
[data-theme="dark"] .cp-config-badge { color: #bbf7d0; }
[data-theme="dark"] .cp-config-badge.off { color: #fecaca; }
.cp-config-link { margin-top: 14px; }
.cp-config-link label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.cp-config-link-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cp-config-link input[type="text"] { flex: 1; min-width: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.cp-config-link small { display: block; margin-top: 6px; font-size: 12px; color: var(--text-muted); }

/* ===== ANIMACIÓN DE VALIDACIÓN ===== */
@keyframes pmShake { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-6px) } 40% { transform: translateX(6px) } 60% { transform: translateX(-4px) } 80% { transform: translateX(4px) } }
.shake { animation: pmShake .45s ease; border-color: var(--danger) !important; }

/* ===== UTILIDADES SaaS (usadas por el panel de la Plataforma) ===== */
.inst-uso { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.contexto-plataforma-hint { border-left-color: #6366f1; background: rgba(99,102,241,.08); }

/* ===== RECIBO TÉRMICO (resto de reglas) ===== */
.recibo-numero { font-size: 10px; text-align: center; letter-spacing: .5px; margin-top: 2px; }
.recibo-fecha { font-size: 10px; text-align: center; color: #333; }
.recibo-destinatario { margin: 4px 0 6px; }
.recibo-label { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .4px; color: #555; }
.recibo-valor { font-size: 11px; font-weight: 700; color: #000; }
.recibo-valor-grande { font-size: 13px; font-weight: 700; word-break: break-word; }
.recibo-detalles { margin: 4px 0; }
.recibo-fila { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; padding: 2px 0; }
.recibo-fila span:first-child { color: #333; }
.recibo-fila span:last-child { font-weight: 700; text-align: right; word-break: break-word; }
.recibo-fila-monto { border-top: 1px dashed #000; border-bottom: 1px dashed #000; margin: 5px 0; padding: 6px 0; }
.recibo-monto { font-size: 16px; font-weight: 800; letter-spacing: .5px; }
.recibo-footer { margin-top: 6px; text-align: center; }
.recibo-registrado { font-size: 9px; color: #555; margin-top: 4px; }
.recibo-mensaje { font-size: 10px; margin-top: 5px; line-height: 1.4; }
.recibo-brand { font-size: 9px; letter-spacing: .6px; text-transform: uppercase; color: #444; margin-top: 6px; }

/* ===== RESPONSIVE de la vista Personas + Movimientos ===== */
@media (max-width: 1200px) {
    .pm-layout { grid-template-columns: 290px minmax(0, 1fr); }
}
@media (max-width: 1024px) {
    .pm-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
    .pm-left { max-height: 420px; }
    .pm-detail { overflow: visible; }
    .pm-mov-list { max-height: 60vh; }
}
@media (max-width: 768px) {
    .pm-layout { gap: 12px; }
    .pm-left-header { padding: 10px; }
    .pm-persona-card { grid-template-columns: 44px minmax(0, 1fr); gap: 10px; }
    .pm-persona-foto { width: 44px; height: 44px; font-size: 20px; }
    .pm-persona-saldo { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 8px; }
    .pm-saldo-valor { font-size: 17px; }
    .pm-persona-actions { grid-column: 1 / -1; }
    .pm-saldo-row { grid-template-columns: 1fr; }
    .pm-form-row { flex-direction: column; align-items: stretch; }
    .pm-input-monto, .pm-input-desc, .pm-tipo-btns { width: 100%; }
    .pm-tipo-btns { justify-content: center; }
    .pm-form-extra { flex-direction: column; align-items: stretch; }
    .pm-form-extra input[type="text"], .pm-form-extra select, .pm-doc-upload { min-width: 0; width: 100%; }
    .pm-form-toggle-row { flex-direction: column; align-items: stretch; }
    .pm-form-edit-btns { justify-content: flex-end; }
    .pm-historial-header { flex-direction: column; align-items: stretch; }
    .pm-filter-input { width: 100%; }
    .pm-form-persona-grid { grid-template-columns: 1fr; }
    .pm-modal-persona form { padding: 14px; }
    .cp-config-actions { justify-content: space-between; width: 100%; }
}
@media (max-width: 480px) {
    .pm-pcard { grid-template-columns: 38px minmax(0, 1fr); }
    .pm-pcard-foto { width: 38px; height: 38px; font-size: 17px; }
    .pm-pcard-saldo { grid-column: 2; align-items: flex-start; text-align: left; flex-direction: row; gap: 8px; }
}

/* ════════════════════════════════════════════════════════════════
   v7.5.2 · LIMPIEZA VISUAL DEL PORTAL DE INSTITUCIÓN
   Solo presentación: ningún selector nuevo de JS, ningún cambio de
   comportamiento. Todo va apuntado con body[data-contexto="institucion"]
   (lo fija el servidor en index.php y lo reafirma aplicarRol), de modo que
   el portal de la Plataforma SaaS conserva exactamente su aspecto actual.
   ════════════════════════════════════════════════════════════════ */

/* 1 · Barra superior: título + una línea secundaria compacta (sin píldoras) */
body[data-contexto="institucion"] .topbar-left { gap: 8px; min-width: 0; }
body[data-contexto="institucion"] .topbar-left h2 { flex: 0 1 auto; min-width: 0; }
body[data-contexto="institucion"] .topbar-contexto,
body[data-contexto="institucion"] .topbar-tipo-tesoreria {
    border: none; border-radius: 0; background: none; box-shadow: none;
    animation: none; padding: 0; letter-spacing: 0; white-space: nowrap;
    font-size: 12px; font-weight: 500; color: var(--text-muted);
    max-width: 30ch; overflow: hidden; text-overflow: ellipsis;
}
body[data-contexto="institucion"] .topbar-contexto { color: var(--text-secondary); font-weight: 600; }
/* el separador pertenece al segundo tramo: si no hay tipo de tesorería, no se pinta */
body[data-contexto="institucion"] .topbar-tipo-tesoreria::before { content: '· '; font-weight: 400; }

/* 2 · Usuario en un único control compacto */
body[data-contexto="institucion"] .user-badge {
    gap: 6px; padding: 3px 9px 3px 3px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 999px; font-size: 12.5px;
}
body[data-contexto="institucion"] .user-avatar { width: 24px; height: 24px; font-size: 11px; }
body[data-contexto="institucion"] .user-badge #topbarUserName {
    max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body[data-contexto="institucion"] .user-rol-badge { font-size: 9px; padding: 1px 6px; }

/* 3 · Acciones como botones de símbolo cuadrados (Actualizar / tema / Salir) */
body[data-contexto="institucion"] .topbar-right { gap: 6px; }
body[data-contexto="institucion"] .topbar-right .btn {
    width: 34px; height: 34px; padding: 0; font-size: 15px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px; flex-shrink: 0;
}
body[data-contexto="institucion"] .topbar-right .btn .btn-text-hide { display: none; }

/* 4 · Cabecera del sidebar más baja, sin duplicar el tipo de tesorería */
body[data-contexto="institucion"] .sidebar-brand { min-height: 54px; padding: 9px 14px; gap: 10px; }
body[data-contexto="institucion"] .brand-icon {
    width: 34px; height: 34px; border-radius: 10px; font-size: 16px; box-shadow: none;
}
body[data-contexto="institucion"] .brand-logo { width: 36px; height: 36px; border-radius: 9px; }
body[data-contexto="institucion"] .brand-text { font-size: 14.5px; }
body[data-contexto="institucion"] .brand-subtitle { font-size: 11px; margin-top: 1px; color: #a9bdd9; }
body[data-contexto="institucion"] .sidebar-nav { padding-top: 6px; }
/* el tipo de tesorería ya se lee en la barra superior: se retira del sidebar */
body[data-contexto="institucion"] .brand-tipo-tesoreria { display: none !important; }

/* 5 · En pantallas medianas el nombre del usuario cede antes que el título */
@media (max-width: 1180px) {
    body[data-contexto="institucion"] .user-badge #topbarUserName { display: none; }
    body[data-contexto="institucion"] .topbar-contexto { max-width: 20ch; }
}
/* 6 · Móvil: se mantiene una sola fila y los mismos símbolos */
@media (max-width: 768px) {
    body[data-contexto="institucion"] .topbar { padding: 0 10px; }
    body[data-contexto="institucion"] .topbar-left { gap: 6px; }
    body[data-contexto="institucion"] .topbar-contexto { display: none; }
    body[data-contexto="institucion"] .topbar-tipo-tesoreria::before { content: ''; }
    body[data-contexto="institucion"] .topbar-right { gap: 4px; }
    body[data-contexto="institucion"] .topbar-right .btn { width: 32px; height: 32px; font-size: 14px; }
    body[data-contexto="institucion"] .sidebar-brand { min-height: 52px; }
}

/* aviso de plan/aviso genérico */
.alert-warning { background: var(--status-pagado); color: #92400e; border-left: 4px solid var(--warning); }