/* ============================================
   TESORERO PRO - Estilos (sistema de diseño v12)
   Diseño: Sidebar + Tabs + Dashboard + Login
   ============================================ */

/* ============================================================================
   v12 · SISTEMA DE DISEÑO — TOKENS SEMÁNTICOS (TEMA CLARO)
   Única fuente de verdad del color. Ningún componente debe declarar un color
   literal: todos consumen estas variables, de modo que el cambio de tema se
   propaga SIEMPRE al sidebar, la cabecera, el contenido y los componentes.
   ============================================================================ */
:root {
    color-scheme: light;

    /* ── Marca y acento ─────────────────────────────────────────────── */
    --primary-color: #2563eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, .10);
    --accent-soft-strong: rgba(37, 99, 235, .18);
    --accent-contrast: #ffffff;
    --secondary-color: #0f2444;
    --brand-teal: #0d9488;
    --brand-gold: #d97706;
    /* Colores sólidos de botón: constantes en ambos temas (texto blanco encima) */
    --success-solid: #059669;
    --warning-solid: #d97706;
    --danger-solid: #dc2626;
    --info-solid: #0284c7;

    /* ── Fondos y superficies ───────────────────────────────────────── */
    --bg: #f5f7fb;
    --app-background: #f5f7fb;
    --surface: #ffffff;
    --surface-background: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --surface-raised: #ffffff;
    --input-background: #ffffff;
    --hover-background: #f1f5f9;
    --active-background: #e8f0fe;
    --disabled-background: #f1f5f9;
    --disabled-text: #a3aebd;

    /* ── Menú lateral ───────────────────────────────────────────────── */
    --sidebar-bg: #ffffff;
    --sidebar-bg-2: #ffffff;
    --sidebar-border: #e7ecf3;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #2563eb;
    --sidebar-active-bg: #e8f0fe;
    --sidebar-active-text: #1d4ed8;
    --sidebar-text: #5b6b82;
    --sidebar-text-strong: #0f172a;
    --sidebar-section: #94a3b8;
    --sidebar-icon-bg: #f1f5f9;
    --sidebar-icon-bg-hover: #e6ecf5;
    --sidebar-icon-bg-active: #dbe8fd;
    --sidebar-soft: rgba(15, 23, 42, .05);
    --sidebar-soft-strong: rgba(15, 23, 42, .11);
    --sidebar-solid: #0f2444;
    --sidebar-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    --sidebar-width: 272px;
    --sidebar-collapsed: 80px;
    --sidebar-drawer: min(300px, 86vw);

    /* ── Cabecera y patrón de puntos ────────────────────────────────── */
    --header-background: #ffffff;
    --pattern-dot: rgba(15, 23, 42, .17);
    --pattern-gap: 18px;
    --pattern-size: 1.1px;
    /* v8.1 · alto de la franja de título (sustituye a la antigua barra superior) */
    --page-head-height: 40px;

    /* ── Texto ──────────────────────────────────────────────────────── */
    --text-primary: #0f172a;
    --text-secondary: #5b6b82;
    --text-muted: #8a97a8;
    --text-inverse: #ffffff;

    /* ── Bordes y separadores ───────────────────────────────────────── */
    --border: #e2e8f0;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --border-light: #f1f5f9;
    --divider: #edf1f7;

    /* ── Estados ────────────────────────────────────────────────────── */
    --success: #059669;
    --success-soft: #ecfdf5;
    --success-border: #a7f3d0;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --warning-border: #fde68a;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --danger-border: #fecaca;
    --info: #0284c7;
    --info-soft: #f0f9ff;
    --info-border: #bae6fd;
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, .18);

    /* ── Tablas ─────────────────────────────────────────────────────── */
    --table-header: #f8fafc;
    --table-even: #ffffff;
    --table-odd: #fbfcfe;
    --table-selected: #eaf2fe;
    --table-border: #edf1f7;
    --status-pagado: #fffbeb;
    --status-falta: #fef2f2;
    --status-favor: #ecfdf5;

    /* ── Formas, sombras y movimiento ───────────────────────────────── */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --shadow-color: 15, 23, 42;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, .13);
    --transition: .18s ease;
    --transition-slow: .28s cubic-bezier(.4, 0, .2, 1);

    /* ── Tipografía ─────────────────────────────────────────────────── */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    --fs-page-title: 19px;
    --fs-section: 15px;
    --fs-body: 13.5px;
    --fs-small: 12px;
    --fs-label: 11.5px;
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
}

/* ============================================================================
   v12 · SISTEMA DE DISEÑO — TOKENS SEMÁNTICOS (TEMA OSCURO)
   Mismo juego de variables que :root. Al vivir en el <html> (data-theme),
   el cambio alcanza a TODO el árbol: sidebar, cabecera, tarjetas, tablas,
   formularios, modales y patrón de puntos. Una sola fuente de verdad.
   ============================================================================ */
:root[data-theme="dark"],
[data-theme="dark"] {
    color-scheme: dark;

    /* ── Marca y acento ─────────────────────────────────────────────── */
    --primary-color: #3b82f6;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, .16);
    --accent-soft-strong: rgba(59, 130, 246, .26);
    --accent-contrast: #ffffff;
    --secondary-color: #93c5fd;
    --brand-teal: #2dd4bf;
    --brand-gold: #fbbf24;
    --success-solid: #047857;
    --warning-solid: #b45309;
    --danger-solid: #b91c1c;
    --info-solid: #0369a1;

    /* ── Fondos y superficies ───────────────────────────────────────── */
    --bg: #0b1220;
    --app-background: #0b1220;
    --surface: #151f31;
    --surface-background: #151f31;
    --surface-2: #1a2438;
    --surface-3: #1f2b42;
    --surface-raised: #1a2438;
    --input-background: #0f1a2c;
    --hover-background: #1e2a41;
    --active-background: #1e3a5f;
    --disabled-background: #1a2438;
    --disabled-text: #55637a;

    /* ── Menú lateral ───────────────────────────────────────────────── */
    --sidebar-bg: #0d1728;
    --sidebar-bg-2: #111d31;
    --sidebar-border: #1e2b45;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-active: #3b82f6;
    --sidebar-active-bg: rgba(59, 130, 246, .20);
    --sidebar-active-text: #bfdbfe;
    --sidebar-text: #9fb0c9;
    --sidebar-text-strong: #f1f5f9;
    --sidebar-section: #64748b;
    --sidebar-icon-bg: rgba(255, 255, 255, .06);
    --sidebar-icon-bg-hover: rgba(255, 255, 255, .12);
    --sidebar-icon-bg-active: rgba(255, 255, 255, .16);
    --sidebar-soft: rgba(255, 255, 255, .06);
    --sidebar-soft-strong: rgba(255, 255, 255, .14);
    --sidebar-solid: #081a33;
    --sidebar-shadow: none;

    /* ── Cabecera y patrón de puntos ────────────────────────────────── */
    --header-background: #101a2c;
    --pattern-dot: rgba(148, 163, 184, .30);

    /* ── Texto ──────────────────────────────────────────────────────── */
    --text-primary: #f1f5f9;
    --text-secondary: #9aa8bd;
    --text-muted: #6b7a90;
    --text-inverse: #0b1220;

    /* ── Bordes y separadores ───────────────────────────────────────── */
    --border: #26334a;
    --border-color: #26334a;
    --border-strong: #33425c;
    --border-light: #1c2941;
    --divider: #1c2941;

    /* ── Estados ────────────────────────────────────────────────────── */
    --success: #34d399;
    --success-soft: rgba(16, 185, 129, .14);
    --success-border: rgba(16, 185, 129, .34);
    --warning: #fbbf24;
    --warning-soft: rgba(245, 158, 11, .14);
    --warning-border: rgba(245, 158, 11, .34);
    --danger: #f87171;
    --danger-soft: rgba(239, 68, 68, .14);
    --danger-border: rgba(239, 68, 68, .34);
    --info: #38bdf8;
    --info-soft: rgba(14, 165, 233, .14);
    --info-border: rgba(14, 165, 233, .34);
    --focus-ring: 0 0 0 3px rgba(96, 165, 250, .30);

    /* ── Tablas ─────────────────────────────────────────────────────── */
    --table-header: #1a2438;
    --table-even: #151f31;
    --table-odd: #172133;
    --table-selected: #1e3a5f;
    --table-border: #23304a;
    --status-pagado: #3a2b0b;
    --status-falta: #3d1414;
    --status-favor: #06301f;

    /* ── Formas, sombras y movimiento ───────────────────────────────── */
    --shadow-color: 0, 0, 0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .40);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
}

[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 img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}
.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;
}
/* El emblema es azul oscuro: necesita fondo claro sobre la cabecera en degradado */
.login-icon-logo {
    background: #fff;
    padding: 6px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .18);
}
.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;
}
/* El logo ya incluye el wordmark "Tesorería": sustituye al texto de la marca */
.login-brand-logo {
    display: block;
    width: auto;
    height: 112px;
    max-width: 100%;
    margin: 0 auto;
}
@media (max-width: 420px) {
    .login-brand-logo { height: 92px; }
}
.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 (v8.1 · al pie del menú lateral) ===== */
.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    background: transparent;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    min-width: 0;
}
.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 .topbar-user-meta { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding-left: 10px; padding-right: 10px; }
.sidebar.collapsed .sidebar-footer { padding: 8px; align-items: center; }
.sidebar.collapsed .sidebar-account { flex-direction: column; width: 100%; }
.sidebar.collapsed .sidebar-account .user-badge { border-color: transparent; background: transparent; justify-content: center; padding: 2px; }
.sidebar.collapsed .sidebar-actions { flex-direction: column; width: 100%; }
.sidebar.collapsed .sidebar-actions .btn { width: 100%; flex: none; }
.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);
}

/* ── PIE DEL MENÚ (v8.1): perfil + acciones del sistema + ÚNICO control de
   contracción. Antes estas acciones vivían en la barra superior; ahora están
   junto a la cuenta, al final del sidebar. ─────────────────────────────── */
.sidebar-footer {
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(255,255,255,.09);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: var(--sidebar-text);
}
.sidebar-account {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.sidebar-account .user-badge {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(255,255,255,.06);
    border-radius: 10px;
}
.topbar-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
}
.user-name {
    color: #fff;
    font-weight: 600;
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-account .user-avatar {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: none;
}
.sidebar-account .user-rol-badge { align-self: flex-start; margin-top: 1px; }
.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar-actions .btn {
    flex: 1;
    height: 32px;
    padding: 0;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border-radius: 9px;
    color: var(--sidebar-text);
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.10);
}
.sidebar-actions .btn:hover {
    background: rgba(255,255,255,.16);
    color: #fff;
    filter: none;
    transform: none;
    box-shadow: none;
}
.sidebar-actions .btn .btn-text-hide { display: none; }
.sidebar-collapse {
    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);
    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;
}

/* ===== PAGE HEAD (v8.1 · sin barra superior) =====
   La barra horizontal se eliminó para ganar espacio vertical. Esta franja es
   mínima y SIN fondo, borde ni sombra: se lee como la primera línea del
   contenido, no como un encabezado fijo. Conserva el título de la sección y el
   contexto de la sesión (institución / Plataforma). */
.page-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 14px 22px 0;
    flex-shrink: 0;
    flex-wrap: wrap;
    min-width: 0;
}
.page-head h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    min-width: 0;
}
/* Disparador del drawer móvil: SOLO existe en pantallas ≤768px. En escritorio el
   único control de menú es el del pie del sidebar (#sidebarCollapseBtn), así que
   nunca hay dos controles de menú visibles al mismo tiempo. */
.sidebar-mobile-toggle {
    display: none;
    align-self: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.sidebar-mobile-toggle:hover { background: var(--bg); 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); }
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    /* v8.1 · menos aire arriba: el contenido arranca más alto al no haber barra */
    padding: 14px 22px 22px;
    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;
}
/* FIX causa raíz (v7.5.4): varias tablas pintan las acciones directamente en la
   celda (<td class="row-actions">). Un <td> con display:flex DEJA de estirarse a
   la altura de su fila en Chrome: su fondo y su border-bottom se recortan unos
   px por encima de la línea de la fila y aparece una "barra" flotante bajo los
   botones, incluso en reposo (Instituciones, Usuarios, Renovaciones…).
   Devolvemos el display de celda y replicamos el layout flex con márgenes y
   alineación de texto, sin tocar el marcado de ninguna pantalla. */
td.row-actions,
th.row-actions {
    display: table-cell;
    vertical-align: middle;
    text-align: right;
}
td.row-actions > * + *,
th.row-actions > * + * { margin-left: 4px; }
.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; }

/* (v7.5.3) Barras .dist-bar-* y listas .top-* antiguas: retiradas junto con el
   renderizador anterior del Dashboard. Sus equivalentes actuales son
   .cartera-* (distribución) y .rank-* (top de deudores), al final del archivo. */

/* ===== 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 eliminado: reemplazado por .bk-row-actions en rediseño v2 */

/* ===== 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, .page-head, .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 .topbar-user-meta,
    .sidebar.collapsed .context-chip { display: flex; }
    .sidebar.collapsed .nav-label,
    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .brand-subtitle { 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; }
    /* El drawer móvil siempre se ve expandido: el pie recupera su maquetación */
    .sidebar.collapsed .sidebar-footer { flex-direction: column; align-items: stretch; padding: 10px 12px 12px; width: auto; }
    .sidebar.collapsed .sidebar-account { flex-direction: row; width: auto; }
    .sidebar.collapsed .sidebar-account .user-badge { flex: 1; justify-content: flex-start; padding: 4px 6px; border-color: rgba(255,255,255,.10); background: rgba(255,255,255,.06); }
    .sidebar.collapsed .sidebar-actions { flex-direction: row; width: auto; }
    .sidebar.collapsed .sidebar-actions .btn { width: auto; flex: 1; }
    .sidebar.collapsed .nav-item::after { display: none; } /* sin tooltips en drawer */
    .sidebar-collapse { display: none; }
    .sidebar-drawer-close { display: inline-flex; }

    /* Franja de título compacta (ya no hay barra superior) */
    .page-head { padding: 10px 12px 0; gap: 8px; }
    .sidebar-mobile-toggle { display: inline-flex; }
    .page-head h2 { font-size: 15px; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .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: 10px 12px 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; }
    /* Las celdas de acciones ya no son flex: permiten saltos de línea naturales */
    td.row-actions, th.row-actions { white-space: normal; }

    /* 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 */
    .page-head { padding: 8px 8px 0; }
    .page-head h2 { max-width: 120px; 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; }

    /* Acciones del pie del menú mínimas */
    .sidebar-actions .btn { height: 30px; font-size: 14px; }

    /* 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/badge-datos eliminados: reemplazados por .bk-type--* en rediseño v2 */
.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 (estilos legacy eliminados: reemplazados por .bk-* en rediseño v2) ===== */

/* ===== 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 (compacto) ===== */
#tab-mi-suscripcion .card-body { padding: 12px 14px; }
#tab-mi-suscripcion .card-header { padding: 10px 14px; }
#tab-mi-suscripcion .card-header h3 { font-size: 14px; }
.mi-sub-container { display: flex; flex-direction: column; gap: 12px; }
.mi-sub-info { display: flex; gap: 14px; flex-wrap: wrap; align-items: stretch; }
.mi-sub-plan-card {
    flex: 0 0 180px;
    background: linear-gradient(135deg, var(--accent), #6d28d9);
    color: #fff;
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.mi-sub-plan-name { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.mi-sub-plan-price { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.mi-sub-plan-desc { font-size: 11px; opacity: .85; line-height: 1.35; }
.mi-sub-details { flex: 1; min-width: 200px; }
.mi-sub-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.mi-sub-detail-row:last-child { border-bottom: none; }
.mi-sub-label { font-weight: 600; color: var(--text-muted); }
.mi-sub-value { font-weight: 500; }

/* v11.3 · Tabla de consumo REAL frente a los límites del plan (Administrar → Uso) */
.tabla-uso { width: 100%; border-collapse: collapse; margin: 4px 0 10px; font-size: 13px; }
.tabla-uso th { text-align: left; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--texto-2, #64748b); padding: 6px 8px; border-bottom: 1.5px solid var(--border, #e2e8f0); white-space: nowrap; }
.tabla-uso td { padding: 9px 8px; border-bottom: 1px dashed var(--border, #e2e8f0); color: var(--texto, #1e293b); }
.tabla-uso td:first-child { font-weight: 700; }
.tabla-uso td.uso-excedido { color: #dc2626; font-weight: 800; }
.tabla-uso tr:last-child td { border-bottom: none; }
@media (max-width: 640px) {
    .tabla-uso thead { display: none; }
    .tabla-uso tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border, #e2e8f0); }
    .tabla-uso td { border: none; padding: 2px 0; display: flex; justify-content: space-between; }
    .tabla-uso td::before { content: attr(data-label); font-weight: 600; color: var(--texto-2, #64748b); font-size: 11.5px; }
}
/* Usage meters */
.uso-meters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.uso-meter-item { display: flex; align-items: center; gap: 10px; }
.uso-meter-label { flex: 0 0 80px; font-weight: 600; font-size: 12px; color: var(--text-secondary, #64748b); }
.uso-meter-bar {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.uso-meter-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width .5s ease;
}
.uso-meter-fill.meter-warning { background: #f59e0b; }
.uso-meter-fill.meter-danger { background: #ef4444; }
.uso-meter-text { flex: 0 0 70px; text-align: right; font-size: 12px; font-weight: 600; }

/* Feature badges */
.mi-sub-features { display: flex; gap: 8px; flex-wrap: wrap; }
.feature-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    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: 8px;
    padding: 8px 12px;
    margin-top: 6px;
    max-width: 420px;
}
.descuento-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 12.5px;
}
.descuento-row.descuento-total {
    border-top: 1px solid var(--primary, #3b82f6);
    margin-top: 4px;
    padding-top: 5px;
    font-size: 13.5px;
}
.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(190px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.plan-card {
    border: 1.5px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 12px 14px;
    text-align: center;
    transition: all 0.2s;
    background: var(--surface, #fff);
}
.plan-card:hover { border-color: var(--primary, #3b82f6); transform: translateY(-1px); }
.plan-card.plan-actual { border-color: var(--primary, #3b82f6); background: rgba(59,130,246,0.05); }
.plan-card-nombre { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.plan-card-precio { font-size: 19px; font-weight: 800; color: var(--primary, #3b82f6); }
.plan-card-precio small { font-size: 11.5px; font-weight: 400; color: var(--text-secondary, #64748b); }
.plan-card-features { list-style: none; padding: 0; margin: 8px 0; font-size: 12px; text-align: left; }
.plan-card-features li { padding: 2px 0; }
.plan-card-features li::before { content: '✓ '; color: #16a34a; font-weight: 700; }
.plan-card-descuento { font-size: 11px; color: var(--primary, #3b82f6); font-weight: 600; margin-top: 6px; }
[data-theme="dark"] .plan-card { background: var(--surface, #1e293b); }
[data-theme="dark"] .plan-card.plan-actual { background: rgba(59,130,246,0.1); }

/* ============================================
   Distribuidores y Comisiones (v7.6)
   ============================================ */
.user-rol-badge.rol-dist { background: #fef3c7; color: #92400e; }
.dist-codigo {
    background: var(--border-light, #f1f5f9);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .4px;
}
.dist-code-grid { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 10px; }
.dist-code-box {
    background: var(--table-header, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 10px 12px;
}
.dist-code-box > small {
    color: var(--text-muted, #64748b);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.dist-code-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.dist-code-row strong { font-size: 17px; letter-spacing: 1px; color: var(--text-primary); }
.dist-code-row input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    padding: 7px 9px;
    font-size: 12.5px;
    background: var(--surface, #fff);
    color: var(--text-primary, #0f172a);
}
.dist-hint { margin: 8px 0 0; font-size: 12px; color: var(--text-secondary, #64748b); line-height: 1.45; }
.form-hint { display: block; font-size: 11px; color: var(--text-muted, #64748b); margin-top: 4px; }
[data-theme="dark"] .dist-code-box { background: var(--surface, #1e293b); border-color: var(--border, #334155); }
[data-theme="dark"] .dist-codigo { background: rgba(148,163,184,.12); }
@media (max-width: 768px) {
    .dist-code-grid { grid-template-columns: 1fr; }
}

/* ── Modal «Nuevo distribuidor» (v7.6.1): centrado real + compacto ──
   · margin:auto sobre el flex-child = centrado exacto horizontal y vertical,
     seguro incluso si el contenido llegara a desbordar (nunca recorta arriba).
   · La altura se acota al viewport real (dvh con fallback vh) y el scroll
     ocurre DENTRO del .modal-body: el modal jamás se sale de la vista.
   · Espaciados compactos sin eliminar ningún campo del formulario. */
#modalDistribuidor {
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}
#modalDistribuidor .modal-content {
    margin: auto; /* centrado verdadero (anula el clipping de align-items:center) */
    width: min(460px, 100%);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
}
#modalDistribuidor .modal-header { padding: 11px 16px; flex: 0 0 auto; }
#modalDistribuidor .modal-header h3 { font-size: 15px; }
#modalDistribuidor .modal-body {
    padding: 12px 16px;
    flex: 1 1 auto;
    min-height: 0;              /* permite que el body encoja y haga scroll interno */
    overflow-y: auto;
    overscroll-behavior: contain;
}
#modalDistribuidor .modal-footer { padding: 10px 16px; flex: 0 0 auto; }
#modalDistribuidor .form-grid { gap: 10px; margin-bottom: 4px; }
#modalDistribuidor .form-group label { margin-bottom: 3px; }
#modalDistribuidor input[type="text"],
#modalDistribuidor input[type="number"],
#modalDistribuidor input[type="password"],
#modalDistribuidor select { padding: 7px 10px; font-size: 12.5px; }
#modalDistribuidor .form-hint { margin-top: 3px; }
#modalDistribuidor .context-hint {
    margin-bottom: 2px;
    padding: 8px 10px;
    font-size: 11.5px;
    line-height: 1.45;
    border-radius: 10px;
}
#modalDistribuidor .context-hint-icon { font-size: 13px; }
@media (max-width: 480px) {
    #modalDistribuidor { padding: 8px; }
    #modalDistribuidor .modal-content {
        width: 100%;
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }
    #modalDistribuidor .modal-body { padding: 10px 12px; }
}

/* ============================================
   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;
}
/* Alcance limitado a la barra del recibo. Antes esta regla era GLOBAL y, al
   ir después de .btn-ghost en la hoja, le pisaba «color» y «border»: cualquier
   «btn btn-ghost btn-sm» quedaba con texto blanco sin borde (invisible sobre
   fondo claro). Ese era el motivo de que Recurrencias y Eventos globales se
   vieran como simples iconos. */
.modal-recibo-toolbar .btn-sm {
    padding: 6px 9px;
    font-size: 11px;
    border-radius: 6px;
}
.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) ===== */
/* v8.0 · la barra de deuda global vive DENTRO del grid (fila propia), de modo
   que el alto total sigue siendo el del viewport sin scroll añadido. */
.pm-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    /* v9.6 · UNA sola fila: la lista de personas y el detalle arrancan arriba y
       aprovechan TODA la altura disponible (la barra superior se retiró). */
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
    height: calc(100vh - var(--page-head-height) - 36px);
    min-height: 420px;
}
/* Panel de personas retráctil: al ocultarlo, el detalle gana todo el ancho. */
.pm-layout.izq-oculto { grid-template-columns: minmax(0, 1fr); }
.pm-layout.izq-oculto .pm-left { display: none; }
.pm-toolbar-label { display: inline-block; }

/* v9.11 · MENÚ desplegable «Deuda global»: agrupa deuda global, recurrencias y
   eventos globales. Usa EXCLUSIVAMENTE tokens del tema (sin colores fijos) y
   sin sombras fuertes: borde + superficie, nativo y limpio en cualquier tema. */
.pm-menu { position: relative; display: inline-flex; }
.pm-menu-caret { font-size: 10px; line-height: 1; opacity: .75; }
.pm-menu-lista {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 50;
    min-width: 210px; max-width: 260px; padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.pm-menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 6px;
    background: transparent; color: var(--text-primary);
    font-family: inherit; font-size: 12.5px; font-weight: 600;
    text-align: left; white-space: nowrap; cursor: pointer;
}
.pm-menu-item:hover { background: var(--bg); color: var(--accent); }
.pm-menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pm-menu-ico { font-size: 14px; line-height: 1; flex: none; }

/* ===== DEUDA GLOBAL POR EVENTO (v8.0) ===== */
.dg-intro { margin: 0 0 14px; }
.dg-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.dg-aplicar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 14px 0 10px;
}
.dg-radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}
.dg-radio input { width: auto; margin: 0; }
.dg-sel-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.dg-sel-tools #dgBuscar { flex: 1 1 200px; margin: 0; }
.dg-sel-count { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.dg-sel-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    background: var(--bg);
}
.dg-sel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13.5px;
}
.dg-sel-item:hover { background: var(--surface); }
.dg-sel-item input { width: auto; margin: 0; }
.dg-sel-item .dg-sel-ced { margin-left: auto; font-size: 11.5px; color: var(--text-muted); }
.dg-sel-vacio { padding: 14px; text-align: center; font-size: 13px; color: var(--text-muted); }
.dg-resumen {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--bg);
}
.dg-res-titulo { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.dg-res-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 13.5px;
}
.dg-res-row:last-child { border-bottom: 0; }
.dg-res-row b { font-size: 14.5px; }
.dg-res-total b { color: var(--danger); font-size: 17px; }
.dg-res-aviso {
    margin-top: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    background: rgba(59, 130, 246, .08);
    border: 1px solid rgba(59, 130, 246, .35);
}
.dg-res-lista { max-height: 180px; overflow-y: auto; margin-top: 10px; font-size: 12.5px; color: var(--text-muted); }
.dg-evento-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.dg-evento-tabla th, .dg-evento-tabla td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.dg-evento-tabla td.num, .dg-evento-tabla th.num { text-align: right; }
.dg-evento-estado { font-weight: 700; }
.dg-evento-estado.pagada { color: var(--success); }
.dg-evento-estado.pendiente { color: var(--danger); }
/* ===== DEUDAS GLOBALES RECURRENTES (v8.6) ===== */
.dg-tipo {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
}
.dg-radio-tipo {
    flex: 1 1 240px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    background: var(--bg);
}
.dg-radio-tipo input { width: auto; margin: 0; }
.dg-radio-tipo span { display: flex; flex-direction: column; gap: 2px; font-weight: 700; }
.dg-radio-tipo span small { font-weight: 500; font-size: 11.5px; color: var(--text-muted); }
.dg-grid-rec { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 4px; }
.hint-inline { font-weight: 500; color: var(--text-muted); font-size: 11.5px; }
.dg-nota-rec {
    margin: 12px 0;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    line-height: 1.5;
    background: rgba(245, 158, 11, .10);
    border: 1px solid rgba(245, 158, 11, .45);
}
.dg-preview {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    padding: 12px 14px;
}
.dg-prev-titulo { font-size: 13px; font-weight: 700; margin: 0 0 8px; }
.dg-prev-lista {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.dg-prev-cuota {
    display: grid;
    grid-template-columns: minmax(80px, 1fr) minmax(110px, 1.2fr) minmax(80px, 1fr);
    gap: 8px;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}
.dg-prev-cuota:last-child { border-bottom: 0; }
.dg-prev-n { font-weight: 700; color: var(--text-muted); }
.dg-prev-f { font-variant-numeric: tabular-nums; }
.dg-prev-m { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.dg-prev-mas { padding: 8px 10px; font-size: 12px; color: var(--text-muted); text-align: center; }
.dg-prev-total { margin-top: 10px; font-size: 13px; }
.dg-prev-total b { color: var(--danger); font-size: 15px; }
.dg-prev-personas { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); }

/* ── v9.13 · Deuda global recurrente: separar SIEMPRE el valor individual
   (por persona) de los totales estimados del grupo. La presentación nunca
   muestra un importe global como si fuera el de una persona. ── */
.dg-res-persona {
    margin: 2px 0 12px;
    padding: 12px 14px;
    border: 1px solid rgba(59, 130, 246, .38);
    border-radius: var(--radius);
    background: rgba(59, 130, 246, .08);
}
.dg-res-persona-titulo {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
}
.dg-res-persona-nota {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
}
.dg-res-persona-nota b { color: var(--text-primary); }
.dg-kpis { display: flex; flex-wrap: wrap; gap: 10px; }
.dg-kpi {
    flex: 1 1 132px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.dg-kpi-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--text-muted); }
.dg-kpi-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dg-kpi--persona { border-color: rgba(59, 130, 246, .5); }
.dg-kpi--persona .dg-kpi-value { color: var(--accent); }
.dg-kpi--total .dg-kpi-value { color: var(--danger); }

/* Bloque de totales del GRUPO: siempre rotulado como estimado. */
.dg-grupo {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.dg-grupo-titulo {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.dg-grupo .dg-res-row { font-size: 12.5px; color: var(--text-secondary); }
.dg-grupo .dg-res-row b { font-size: 13.5px; color: var(--text-primary); }
.dg-grupo-nota {
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--text-muted);
}
.dg-grupo-nota b { color: var(--text-secondary); }
.pop-grupo { color: var(--text-secondary); }

/* Calendario de cuotas: columna «Por persona» + columna «≈ Total estimado». */
.dg-prev-cuota--rec {
    grid-template-columns: minmax(74px, .9fr) minmax(96px, 1fr) minmax(88px, 1fr) minmax(96px, 1fr);
}
.dg-prev-cuota--head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--table-header);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.dg-prev-tag {
    display: block;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.dg-prev-m--per { color: var(--text-primary); }
.dg-prev-m--est { color: var(--text-muted); font-weight: 500; }
.dg-prev-m--est .dg-prev-tag { opacity: .85; }

@media (max-width: 640px) {
    .dg-prev-cuota--rec { grid-template-columns: minmax(60px, .8fr) minmax(84px, 1fr) minmax(80px, 1fr); }
    .dg-prev-cuota--rec .dg-prev-m--est { grid-column: 1 / -1; }
    .dg-prev-cuota--rec.dg-prev-cuota--head span:last-child { display: none; }
}
.dg-prev-aviso {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    background: rgba(59, 130, 246, .08);
    border: 1px solid rgba(59, 130, 246, .35);
}
.rec-estado {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
}
.rec-ok { background: rgba(16, 185, 129, .15); color: var(--success); }
.rec-warn { background: rgba(245, 158, 11, .18); color: #b45309; }
.rec-off { background: rgba(239, 68, 68, .15); color: var(--danger); }
.rec-done { background: rgba(148, 163, 184, .20); color: var(--text-muted); }
.rec-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.rec-acciones { white-space: nowrap; }
.rec-acciones .btn-link { font-size: 12px; }
.btn-link-danger { color: var(--danger); }
@media (max-width: 640px) {
    .dg-grid-rec { grid-template-columns: minmax(0, 1fr); }
    .dg-radio-tipo { flex: 1 1 100%; }
}

/* Etiqueta del evento en la tarjeta de la deuda individual */
.pm-deuda-evento {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}
@media (max-width: 640px) {
    .dg-grid { grid-template-columns: minmax(0, 1fr); }
}
.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; }
.pm-left-title-actions { display: flex; align-items: center; gap: 6px; }
/* v9.9 · Tres acciones compactas (30 px) y alineadas en la línea «Personas». */
.pm-left-title-actions .btn-round { width: 30px; height: 30px; font-size: 14px; }
.pm-head-btn {
    display: inline-flex; align-items: center; gap: 5px; height: 30px;
    padding: 0 10px; font-size: 12px; line-height: 1; white-space: nowrap;
    border-radius: var(--radius-sm); color: var(--text-secondary);
}
.pm-head-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Botón para recuperar la lista cuando está retraída (siempre accesible). */
.pm-mostrar-lista {
    display: none; align-self: flex-start; align-items: center; gap: 6px;
    margin-bottom: 8px; padding: 6px 12px;
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer;
}
.pm-mostrar-lista:hover { border-color: var(--accent); color: var(--accent); }
.pm-layout.izq-oculto .pm-mostrar-lista { display: inline-flex; }

/* v9.8 · Barra del panel oculto: botón «Mostrar lista» + buscador compacto con
   desplegable de coincidencias (permite cambiar de persona sin desplegar nada). */
.pm-lista-oculta-barra { display: none; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pm-layout.izq-oculto .pm-lista-oculta-barra { display: flex; }
.pm-lista-oculta-barra .pm-mostrar-lista { margin-bottom: 0; }
.pm-mini-buscar {
    position: relative; display: flex; align-items: center; gap: 6px;
    height: 34px; padding: 0 10px; min-width: 250px; max-width: 340px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.pm-mini-buscar:focus-within { border-color: var(--accent); }
.pm-mini-ico { font-size: 13px; opacity: .7; }
.pm-mini-buscar input {
    flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
    font-size: 12.5px; color: var(--text-primary);
}
.pm-mini-limpiar { border: 0; background: transparent; cursor: pointer; padding: 0 2px; font-size: 12px; color: var(--text-muted); }
.pm-mini-limpiar:hover { color: var(--danger); }
.pm-mini-resultados {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
    max-height: 260px; overflow-y: auto; padding: 4px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.pm-mini-item {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    width: 100%; padding: 6px 8px; border: 0; border-radius: 6px;
    background: transparent; cursor: pointer; text-align: left;
}
.pm-mini-item:hover, .pm-mini-item.active { background: var(--bg); }
.pm-mini-nombre { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.pm-mini-sub { font-size: 11px; color: var(--text-muted); }
.pm-mini-vacio { padding: 8px; font-size: 12px; color: var(--text-muted); }
/* 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; }

/* v9.10 · «Agregar persona»: botón rectangular a todo el ancho, bajo el buscador.
   Usa EXCLUSIVAMENTE tokens del tema (sin colores fijos), sin sombras ni aspecto
   flotante, para adaptarse a cualquier tema con contraste y legibilidad. */
.pm-btn-agregar {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; height: 36px;
    margin-top: 8px; padding: 0 12px;
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.pm-btn-agregar:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.pm-btn-agregar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pm-btn-agregar-mas { font-size: 17px; font-weight: 700; line-height: 1; }
.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; }
/* Saldo a favor sin aplicar en la tarjeta lateral (concepto aparte) */
.pm-pcard-favor { font-size: 10px; font-weight: 700; color: var(--success); 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 RESUMEN de persona (v9.5): UNA sola fila horizontal.
   Identidad (foto + nombre + contacto) 35% · Deudas 21% · Pagos 21% ·
   Estado 23% · acciones. Todo verticalmente centrado salvo las acciones, que
   quedan en la esquina superior derecha sin aumentar la altura. */
.pm-persona-card {
    position: relative;
    display: grid;
    /* Identidad ~35% · bloque de tarjetas ~65% (3 tarjetas de IGUAL ancho) · acciones */
    grid-template-columns: minmax(0, 35fr) minmax(0, 65fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.pm-persona-ident { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pm-persona-foto {
    width: 48px; height: 48px; border-radius: 10px; overflow: hidden; flex: none;
    background: var(--table-header); display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.pm-persona-foto img { width: 100%; height: 100%; object-fit: cover; }
.pm-persona-info { min-width: 0; }
.pm-persona-nombre { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.pm-persona-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2px; font-size: 12px; color: var(--text-secondary); }
.pm-meta-item { white-space: nowrap; }
/* v8.3 · La cabecera de la persona muestra DOS conceptos independientes:
   pendiente por pagar y saldo a favor (nunca se restan automáticamente). */
.pm-saldo-favor {
    display: flex; align-items: baseline; gap: 5px;
    margin-top: 1px; font-size: 10.5px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
}
.pm-favor-num { font-size: 13px; font-weight: 800; color: var(--success); text-transform: none; letter-spacing: 0; }
.pm-saldo-favor.pm-favor-cero .pm-favor-num { color: var(--text-muted); }
.pm-saldo-favor.pm-favor-cero .pm-favor-lbl { opacity: .75; }
.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: 16px; font-weight: 800; line-height: 1.1; }
.pm-saldo-valor.debe { color: var(--danger); }
.pm-saldo-valor.pagado { color: var(--success); }
/* Acciones en la esquina superior derecha, sin aportar altura a la fila. */
.pm-persona-actions { display: flex; gap: 6px; align-self: start; }

/* Bloque de resumen (v9.5): sub-rejilla HORIZONTAL de 3 tarjetas de ancho
   idéntico y altura idéntica; vive en la misma fila que la identidad. */
.pm-saldo-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; min-width: 0; }
.pm-saldo-chip {
    display: flex; flex-direction: column; justify-content: center; gap: 2px;
    /* align-self: stretch → las TRES tarjetas comparten exactamente la misma
       altura (la de la más alta), sin desalinearse. */
    align-self: stretch;
    min-height: 56px; padding: 8px 10px; min-width: 0;
    background: var(--table-header);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
/* La etiqueta puede ocupar dos líneas: se lee completa (nunca se recorta con
   puntos suspensivos) y las tres tarjetas conservan la misma altura. */
.pm-chip-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .2px; line-height: 1.2; }
.pm-chip-value { font-size: 16px; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.pm-chip-red { color: var(--danger); }
.pm-chip-green { color: var(--success); }
/* Tarjeta de estado: acento institucional + saldo a favor como dato secundario */
.pm-saldo-chip-estado { border-left: 3px solid var(--accent); }
.pm-saldo-chip-estado .pm-saldo-favor { justify-content: flex-start; }

/* 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; }
/* Descripción: admite varias líneas. Mismo aspecto que los inputs del sistema
   y crecimiento automático con el contenido (ver autoGrowDescripcion en app.js). */
.pm-input-desc {
    flex: 1; min-width: 170px;
    padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit; line-height: 1.35; color: var(--text-primary);
    background: var(--surface); outline: none; transition: all var(--transition);
    resize: vertical; min-height: 36px; max-height: 140px; overflow-y: auto;
}
.pm-input-desc::placeholder { color: var(--text-muted); }
.pm-input-desc:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.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; vertical-align: middle; }
.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); }
/* WhatsApp: acción al final de la fila, con ícono y texto siempre visibles */
.btn-wa-row {
    display: inline-flex; align-items: center; gap: 4px;
    border-color: #16a34a; color: #16a34a; margin-left: 6px;
    font-weight: 600; padding: 3px 8px;
}
.btn-wa-row .wa-lbl { font-size: 11px; white-space: nowrap; }
.btn-wa-row:hover { background: #16a34a; border-color: #16a34a; color: #fff; }

/* La tabla de movimientos tiene 7 columnas: con el relleno por defecto (14px por
   lado) la descripción quedaba aplastada. Se compacta el relleno horizontal de
   ESTA tabla para que la descripción conserve un ancho legible. */
#tablaMovimientos th, #tablaMovimientos td { padding-left: 6px; padding-right: 6px; }

/* ── Comp. / Doc. / Acciones: encabezados alineados con su contenido ──
   El comprobante y el documento se leen de izquierda a derecha; el grupo de
   botones se alinea a la derecha, que es donde termina la tabla. */
#tablaMovimientos thead th:nth-child(5),
#tablaMovimientos thead th:nth-child(6) { text-align: left; }

/* La columna de Acciones toma EXACTAMENTE el ancho de sus botones (width:1%
   con nowrap) y se pega al borde derecho: el ancho sobrante se lo queda la
   descripción, así el grupo no queda flotando en el centro de la celda.
   La tabla siempre llena el panel; el único ancho que no cuenta es la barra de
   scroll vertical, así que el margen real de WhatsApp es el del borde útil. */
#tablaMovimientos thead th:last-child,
#tablaMovimientos tbody td.td-acciones {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

/* En paneles angostos la tabla no cabe completa: la columna de Acciones queda
   fija a la derecha para que editar / recibo / eliminar / WhatsApp estén siempre
   a la vista y una descripción larga NUNCA desplace los botones.
   z-index: el encabezado (1) tapa la celda fija (0) al desplazar verticalmente;
   la esquina del encabezado de Acciones (2) tapa a ambos. */
#tablaMovimientos thead th:last-child {
    position: sticky; top: 0; right: 0; z-index: 2;
    background: var(--table-header);
}
#tablaMovimientos tbody td.td-acciones {
    position: sticky; right: 0; z-index: 0;
    background: inherit;
    box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .28);
    padding-left: 4px;
    padding-right: 6px;      /* margen visual pequeño y uniforme en el borde derecho */
    font-size: 0;            /* elimina los huecos que dejan los espacios en blanco */
    vertical-align: middle;
}
/* v9.6 · La acción "Gestionar deuda" YA NO es un botón en esta columna: se
   trasladó al BLOQUE DE MONTO de la fila (ver td.td-monto .mov-deuda-montos).
   Así la columna Acciones muestra las MISMAS acciones en todas las filas. */

/* Los botones recuperan su tipografía y se separan siempre lo mismo (4px) */
#tablaMovimientos tbody td.td-acciones > button { font-size: 12px; vertical-align: middle; }
#tablaMovimientos tbody td.td-acciones > button + button { margin-left: 4px; }
#tablaMovimientos tbody td.td-acciones .btn-recibo { padding: 3px 5px; }
#tablaMovimientos tbody td.td-acciones .btn-wa-row { padding: 3px 7px; }

/* Paneles angostos: con las 7 columnas la etiqueta larga obligaba a desplazar
   la tabla y la columna Doc quedaba bajo el riel de acciones. Se usa la misma
   acción con etiqueta corta ("WhatsApp", mismo ícono y mismo title) para que
   Comp., Doc. y Acciones quepan completas y sin scroll horizontal. */
@media (max-width: 1500px) {
    #tablaMovimientos tbody td.td-acciones .btn-wa-row .wa-lbl { display: none; }
    #tablaMovimientos tbody td.td-acciones .btn-wa-row::after { content: 'WhatsApp'; font-size: 11px; font-weight: 600; }
    #tablaMovimientos tbody td.td-acciones .btn-recibo { padding: 3px 4px; }
}

/* Descripción con saltos de línea: la celda crece hacia abajo, conserva un
   ancho mínimo legible y su texto queda acotado para no comprimir el monto. */
/* v8.3 · Fila de DEUDA: la columna MONTO muestra sus tres cifras reales
   (original / pagado / pendiente) de forma compacta, sin ensanchar la tabla. */
#tablaMovimientos td.td-monto .mov-deuda-montos {
    display: flex; flex-direction: column; gap: 0;
    font-size: 10px; line-height: 1.2; white-space: nowrap;
    /* v9.6 · El bloque de cifras ES la acción de gestionar la deuda: se
       indica con cursor y un hover suave. El relleno, compensado con márgenes
       negativos, amplía el área de clic sin mover ninguna cifra de su sitio. */
    cursor: pointer;
    padding: 4px 6px; margin: -4px -6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition), box-shadow var(--transition);
}
/* El hover de la FILA ya tiñe toda la fila: el bloque se marca como una
   "tarjeta" con fondo propio y un anillo de acento, así se distingue de la
   fila sin gritar. */
#tablaMovimientos td.td-monto .mov-deuda-montos:hover {
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--accent);
}
#tablaMovimientos td.td-monto .mov-deuda-montos:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 1px;
}
#tablaMovimientos td.td-monto .mov-deuda-montos span { color: var(--text-secondary); }
#tablaMovimientos td.td-monto .mov-deuda-montos b { color: var(--text-primary); font-size: 11px; }
#tablaMovimientos td.td-monto .mov-deuda-montos .debe b { color: var(--danger); }
#tablaMovimientos td.td-monto .mov-deuda-montos .ok b { color: var(--success); }

/* ── Columna DESCRIPCIÓN: estructura uniforme (título · meta · extra) ─────
   Todas las filas comparten el MISMO bloque vertical .mov-desc de tres
   niveles:
     1) .mov-desc__title  texto principal (mayor jerarquía visual)
     2) .mov-desc__meta   detalle secundario de la operación
     3) .mov-desc__extra  dato adicional (evento)
   El título arranca siempre en el mismo punto y las líneas secundarias usan
   una rejilla común icono + texto (icono de ancho fijo), de modo que el texto
   queda alineado en TODAS las filas, tengan una, dos o tres líneas, sin
   huecos ni líneas flotantes. El selector se acota a #tablaMovimientos para
   no alterar el .mov-desc del panel "Movimientos recientes" del dashboard. */
#tablaMovimientos td.td-desc {
    white-space: pre-wrap; overflow-wrap: anywhere;
    vertical-align: top; min-width: 200px;
}
/* align-items: stretch mantiene el ancho del bloque (la descripción envuelve
   igual que antes) y fija la x de arranque de todas las líneas. */
#tablaMovimientos td.td-desc .mov-desc {
    display: flex; flex-direction: column; align-items: stretch; gap: 3px;
    max-width: 320px; min-width: 0; padding: 1px 0;
    font-size: 12.5px; line-height: 1.35; color: var(--text-primary);
    white-space: normal; overflow: visible; text-overflow: clip;
}
/* .desc-txt se conserva como alias del título (compatibilidad) */
#tablaMovimientos td.td-desc .mov-desc__title,
#tablaMovimientos td.td-desc .desc-txt {
    display: block; max-width: 100%;
    font-size: 13px; font-weight: 700; line-height: 1.35;
    color: var(--text-primary);
    white-space: pre-wrap; overflow-wrap: anywhere;
}
#tablaMovimientos td.td-desc .mov-desc__meta,
#tablaMovimientos td.td-desc .mov-desc__extra {
    display: flex; align-items: flex-start; gap: 0;
    max-width: 100%; margin: 0;
    font-size: 11px; font-weight: 600; line-height: 1.3;
    white-space: normal; overflow-wrap: anywhere;
}
/* Rejilla común: el icono ocupa SIEMPRE el mismo ancho, así el texto de todas
   las líneas secundarias empieza exactamente en la misma x. */
#tablaMovimientos td.td-desc .mov-desc__ico {
    display: inline-block; flex: 0 0 auto;
    width: 14px; margin-right: 5px;
    text-align: center; vertical-align: middle; line-height: inherit;
}
#tablaMovimientos td.td-desc .mov-desc__txt { min-width: 0; overflow-wrap: anywhere; }

/* ===== DEUDAS POR CONCEPTO (integradas en Movimientos, v7.9) ===== */
.pm-form-deuda-row { margin-top: 8px; }
.pm-form-deuda-row input, .pm-form-deuda-row select { flex: 1; min-width: 180px; }

/* ===== DEUDAS EN MODAL (v8.1) =====
   Toda la información de deudas vive en #modalDeudas: la vista principal solo
   ofrece la acción "Ver deudas", sin duplicar datos. */
.pm-deudas-vacio { font-size: 12.5px; color: var(--text-muted); padding: 10px 2px; }

/* ===== MODAL DE UNA DEUDA (v8.1) ===== */
/* v9.6 · Modal más amplio: aprovecha la pantalla para leer las cifras, las
   acciones y el historial con holgura. El contenido y la lógica NO cambian.
   El ancho es fluido —min(880px, 94vw)— y en móvil (≤768px) hereda el 92vw
   del modal base; nunca desborda. El alto se reparte entre cabecera, cuerpo
   con scroll propio y pie, así que el documento sigue cabiendo en pantalla. */
#modalDeuda .modal-content { width: min(880px, 94vw); max-width: 94vw; max-height: 88vh; }
#modalDeuda .modal-header { padding: 16px 26px; }
#modalDeuda .modal-body { padding: 20px 26px; }
#modalDeuda .modal-footer { padding: 14px 26px; }
#modalDeudaBody { max-height: 72vh; overflow: auto; }
/* Con más ancho, las cifras y el título respiran: misma información, mejor
   jerarquía visual. */
#modalDeudaBody .md-concepto { font-size: 22px; }
#modalDeudaBody .md-datos { gap: 10px; padding: 12px 14px; }
#modalDeudaBody .md-dato b { font-size: 17px; }
/* Pantallas pequeñas: relleno más ajustado para no comer ancho útil. */
@media (max-width: 768px) {
    #modalDeuda .modal-header { padding: 13px 16px; }
    #modalDeuda .modal-body { padding: 14px 16px; }
    #modalDeuda .modal-footer { padding: 12px 16px; }
    #modalDeudaBody { max-height: 68vh; }
}
.md-concepto { font-size: 20px; font-weight: 800; color: var(--text-primary); line-height: 1.2; overflow-wrap: anywhere; }
.md-estado { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; }
.md-datos {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px; padding: 10px 12px; background: var(--table-header);
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
}
.md-dato { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.md-dato span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; }
.md-dato b { font-size: 16px; font-weight: 800; color: var(--text-primary); overflow-wrap: anywhere; }
.md-dato.debe b { color: var(--danger); }
.md-dato.ok b { color: var(--success); }
.md-acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.md-favor {
    margin-top: 10px; padding: 8px 10px; font-size: 12.5px; color: var(--text-secondary);
    background: var(--table-header); border: 1px dashed var(--success); border-radius: var(--radius-sm);
}
.md-favor b { font-size: 14px; color: var(--success); font-weight: 800; }
.md-favor-nota { color: var(--text-muted); font-size: 11.5px; }
.md-hist { margin-top: 14px; }
.md-hist h4 {
    margin: 0 0 6px; font-size: 12px; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: .4px;
    border-bottom: 1px solid var(--border-light); padding-bottom: 4px;
}

.pm-deuda { border: 1px solid var(--border-light); border-radius: var(--radius-sm); margin-bottom: 8px; overflow: hidden; }
.pm-deuda:last-child { margin-bottom: 0; }
.pm-deuda.pagada { opacity: .9; }
.pm-deuda-inicial { border-style: dashed; }
.pm-deuda-top {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 7px 9px; background: var(--table-header);
}
.pm-deuda-inicial .pm-deuda-top { background: transparent; }
.pm-deuda-concepto {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere;
}
.pm-deuda-estado { font-size: 10.5px; font-weight: 700; letter-spacing: .3px; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.pm-deuda-fecha { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.pm-deuda-acciones { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pm-deuda-cifras {
    display: flex; gap: 8px 16px; flex-wrap: wrap;
    padding: 8px 10px 0; font-size: 11.5px; color: var(--text-secondary);
}
.pm-deuda-pagos { padding: 4px 10px 9px; }
.pm-deuda-cifra { white-space: nowrap; }
.pm-deuda-cifra b { color: var(--text-primary); font-size: 12.5px; }
.pm-deuda-cifra.debe b { color: var(--danger); }
.pm-deuda-cifra.ok b { color: var(--success); }
.pm-deuda-hist-item {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline;
    font-size: 11.5px; color: var(--text-secondary); padding: 2px 0;
    border-bottom: 1px dashed var(--border-light);
}
.pm-deuda-hist-item:last-child { border-bottom: none; }
.pm-deuda-hist-fecha { color: var(--text-muted); white-space: nowrap; }
.pm-deuda-hist-tipo { font-weight: 600; }
.pm-deuda-hist-monto { font-weight: 700; color: var(--text-primary); }
.pm-deuda-hist-extra { color: var(--text-muted); }
.pm-deuda-hist-vacio { font-style: italic; color: var(--text-muted); }

/* Etiqueta de trazabilidad en la fila del movimiento: distingue de un vistazo
   un pago aplicado a una deuda de un abono general (saldo a favor). */
.pm-deuda-tag {
    display: block; margin-top: 2px; font-size: 10.5px; font-weight: 600;
    white-space: normal; overflow-wrap: anywhere;
}
.pm-deuda-tag.tag-deuda { color: var(--accent); }
.pm-deuda-tag.tag-favor { color: var(--success); }
/* v8.5 · Aplicación de saldo a favor: pago visible que NO es dinero nuevo. */
.pm-deuda-tag.tag-aplicacion { color: var(--warning); }
.ap-hint { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.4; }
#modalAplicarSaldo .form-label { display: block; margin: 8px 0 4px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
#modalAplicarSaldo select, #modalAplicarSaldo input { width: 100%; }
#modalAplicarSaldo #apMaxHint { margin-top: 4px; }

/* ===== 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) ===== */
/* ── Mi Institución: la altura la manda el contenido ───────────────
   .tab-content es un flex column con overflow-y:auto, y sus hijos .card
   heredan flex-shrink:1. Cuando el contenido no cabía en la ventana, las
   tarjetas se comprimían y .card-body (overflow:auto, flex:1) abría un
   scroll interno que recortaba el final del contenido. Este tab es un
   flujo vertical de tarjetas: deben crecer con su contenido y dejar el
   scroll —uno solo— al contenedor del tab.
   Alcance limitado a #tab-mi-institucion para no afectar a los tabs que
   sí necesitan tarjetas que llenen el alto (.card-table { flex: 1 }). */
#tab-mi-institucion .card { flex-shrink: 0; }
#tab-mi-institucion .card-body { flex: none; overflow: visible; }

.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); }
/* El botón «↗ Abrir» es .btn-ghost.btn-sm. La hoja tiene un segundo bloque
   .btn-sm (~línea 2280) que impone color:#fff y border:none y, al ir después,
   gana a .btn-ghost por orden en la cascada: quedaba blanco sobre blanco e
   invisible. Se restituye el aspecto ghost solo dentro de esta tarjeta. */
.cp-config-card .btn-ghost.btn-sm {
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.cp-config-card .btn-ghost.btn-sm:hover { background: var(--bg); color: var(--text-primary); }

/* ===== 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); }
}
/* v9.11 · El menú desplegable no se sale del panel en pantallas estrechas. */
@media (max-width: 560px) {
    .pm-menu-lista { right: auto; left: 0; min-width: 190px; }
}
@media (max-width: 1024px) {
    .pm-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
    /* En pantallas estrechas la lista siempre se muestra (el retraído no aplica). */
    .pm-layout.izq-oculto .pm-left { display: flex; }
    .pm-mostrar-lista { display: none !important; }
    .pm-lista-oculta-barra { display: none !important; }
    .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; }
    /* v9.5 · En móvil: identidad + acciones en la primera fila y las tres
       tarjetas apiladas a todo el ancho debajo (misma información, sin recortes). */
    .pm-persona-card { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
    .pm-persona-ident { grid-column: 1; grid-row: 1; }
    .pm-persona-foto { width: 44px; height: 44px; font-size: 20px; }
    .pm-persona-actions { grid-column: 2; grid-row: 1; justify-content: flex-end; }
    .pm-saldo-row { grid-column: 1 / -1; grid-template-columns: 1fr; }
    .pm-saldo-chip { min-height: 0; }
    .pm-saldo-valor { font-size: 16px; }
    .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; }
    /* Deudas compactas en móvil: nada se sale del ancho disponible */
    .pm-deuda-top { gap: 6px 8px; }
    .pm-deuda-concepto { flex: 1 1 100%; font-size: 12.5px; }
    .pm-deuda-acciones { width: 100%; justify-content: flex-end; gap: 6px; }
    .pm-deuda-cifras { gap: 6px 12px; }
    .pm-deuda-cifra { white-space: normal; }
    .pm-deuda-detalle { padding: 8px; }
    .pm-deuda-hist-item { gap: 2px 8px; }
    .pm-deuda-hist-extra, .pm-deuda-hist-tipo { overflow-wrap: anywhere; }
    /* Modal de una deuda en móvil: cifras en una columna y acciones a lo ancho */
    .md-datos { grid-template-columns: 1fr; }
    .md-concepto { font-size: 17px; }
    .md-acciones { flex-direction: column; }
    .md-acciones .btn { width: 100%; justify-content: center; }
    .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 · v8.1 · Franja de título (la barra superior ya no existe) */
body[data-contexto="institucion"] .page-head { gap: 8px; }
body[data-contexto="institucion"] .page-head 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 al pie del menú lateral */
body[data-contexto="institucion"] .sidebar-account .user-badge {
    gap: 6px; padding: 4px 6px; background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.10); border-radius: 10px; font-size: 12.5px;
}
body[data-contexto="institucion"] .sidebar-account .user-avatar { width: 26px; height: 26px; font-size: 11px; }
body[data-contexto="institucion"] .sidebar-account .user-name {
    max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body[data-contexto="institucion"] .user-rol-badge { font-size: 9px; padding: 1px 6px; }

/* 3 · Acciones del sistema como botones de símbolo (Actualizar / tema / Salir) */
body[data-contexto="institucion"] .sidebar-actions { gap: 6px; }
body[data-contexto="institucion"] .sidebar-actions .btn {
    height: 34px; padding: 0; font-size: 15px; border-radius: 9px;
}
body[data-contexto="institucion"] .sidebar-actions .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"] .sidebar-account .user-name { display: none; }
    body[data-contexto="institucion"] .topbar-contexto { max-width: 20ch; }
}
/* 6 · Móvil: franja de título compacta y mismos símbolos */
@media (max-width: 768px) {
    body[data-contexto="institucion"] .page-head { padding: 10px 10px 0; gap: 6px; }
    body[data-contexto="institucion"] .topbar-contexto { display: none; }
    body[data-contexto="institucion"] .topbar-tipo-tesoreria::before { content: ''; }
    body[data-contexto="institucion"] .sidebar-actions .btn { height: 32px; font-size: 14px; }
    body[data-contexto="institucion"] .sidebar-brand { min-height: 52px; }
}

/* ════════════════════════════════════════════════════════════════
   CABECERA DEL SIDEBAR · PLATAFORMA SaaS
   Solo la marca del servicio: el logo oficial del proyecto junto a
   «Plataforma SaaS». Se retiraron el bloque «CONTEXTO: PLATAFORMA /
   Solo administración del servicio» y el subtítulo «Gestión global ·
   sin institución»: eran redundantes, no aportaban información útil
   y no cumplían ninguna función en la interfaz.
   Solo presentación: no altera rutas, permisos, menús ni datos.
   ════════════════════════════════════════════════════════════════ */
body[data-contexto="plataforma"] .sidebar-brand {
    min-height: 68px;
    padding: 12px 16px;
    gap: 12px;
}
/* El emblema es azul oscuro: sobre el sidebar necesita fondo claro, como en el acceso */
body[data-contexto="plataforma"] .sidebar-brand .brand-logo {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    background: #fff;
    object-fit: contain;
    box-shadow: 0 4px 14px rgba(2,8,23,.35);
}
body[data-contexto="plataforma"] .brand-text {
    font-size: 16.5px;
    font-weight: 700;
    letter-spacing: .2px;
    color: #fff;
    line-height: 1.15;
}
body[data-contexto="plataforma"] .sidebar-nav { padding-top: 10px; }

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

/* ═══════════════════════════════════════════════════════════════════════
   v7.5.3 · MENÚ LATERAL REORGANIZADO + DASHBOARD COMPACTO (portal institución)
   Solo presentación: ninguna regla de aquí altera permisos, rutas ni datos.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 1 · Familia única de iconos (SVG en línea) ───────────────────────── */
.ico-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico,
.nav-ico {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ico { width: 18px; height: 18px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.ico-inline { width: 17px; height: 17px; vertical-align: -3px; margin-right: 7px; }
.ico-lg { width: 42px; height: 42px; stroke-width: 1.6; }
.nav-ico { width: 19px; height: 19px; display: block; }
.nav-icon .nav-ico { opacity: .92; }
.nav-item.active .nav-icon .nav-ico { opacity: 1; }

/* ── 2 · Bloque «Cuenta» al final del menú, visualmente secundario ────── */
.nav-section-cuenta {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,.07);
}
.nav-item-cuenta { color: rgba(168,188,216,.75); font-weight: 500; }
.nav-item-cuenta .nav-icon { background: transparent; }
.nav-item-cuenta:hover { color: #fff; }
.nav-item-cuenta.active { color: #fff; font-weight: 600; }
.sidebar.collapsed .nav-section-cuenta { margin-top: auto; padding-top: 12px; }

/* ── 3 · Indicadores del Dashboard (tarjetas compactas) ─────────────────
   v8.1 · TRES tarjetas principales: Total Personas, Por Cobrar y Recaudado.
   «Saldo a favor de personas» no es dinero disponible: vive aparte, en el
   bloque «Resumen financiero» (.fin-favor). */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.kpi-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.kpi-ico {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.kpi-ico .ico { width: 21px; height: 21px; stroke-width: 1.9; }
.kpi-total    .kpi-ico { background: rgba(59,130,246,.12);  color: var(--accent); }
.kpi-falta    .kpi-ico { background: rgba(239,68,68,.12);   color: var(--danger); }
.kpi-recaudado .kpi-ico { background: rgba(16,185,129,.12); color: var(--success); }
.kpi-favor    .kpi-ico { background: rgba(245,158,11,.12);  color: var(--warning); }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.kpi-value {
    font-size: 21px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-foot {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-foot b { font-weight: 700; color: var(--text-secondary); }

/* ── 4 · Resumen financiero con jerarquía y balance neto destacado ────── */
.fin-rows { display: flex; flex-direction: column; }
.fin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-light);
    font-size: 13px;
}
.fin-row:last-child { border-bottom: none; }
.fin-label { color: var(--text-secondary); }
.fin-value { font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.fin-value.is-danger  { color: var(--danger); }
.fin-value.is-success { color: var(--success); }
.fin-balance {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--border);
    background: var(--table-odd);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.fin-balance-label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.fin-balance-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.fin-balance.is-danger  { background: var(--status-falta); border-left-color: var(--danger); }
.fin-balance.is-danger  .fin-balance-value { color: var(--danger); }
.fin-balance.is-success { background: var(--status-favor); border-left-color: var(--success); }
.fin-balance.is-success .fin-balance-value { color: var(--success); }

/* ── v8.1 · «Saldo a favor de personas» (bloque secundario y separado) ──────
   No es dinero disponible para gastos: por eso NO comparte fila de tarjetas con
   los indicadores principales y aquí se pinta con un tono neutro/ámbar, nunca
   con el verde de «recaudado». Deja explícito que no se resta de la deuda. */
.fin-favor {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px dashed var(--border);
    border-left: 4px solid var(--warning);
    border-radius: var(--radius-sm);
    background: rgba(245, 158, 11, .07);
}
.fin-favor-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.fin-favor-label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #b45309;
}
.fin-favor-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    color: #b45309;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.fin-favor-note {
    margin: 6px 0 0;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--text-secondary);
}
.fin-favor-note b { color: #b45309; }
[data-theme="dark"] .fin-favor-label,
[data-theme="dark"] .fin-favor-value,
[data-theme="dark"] .fin-favor-note b { color: #fbbf24; }

/* ── 5 · Distribución de cartera (dona proporcional + leyenda) ────────── */
.cartera-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.cartera-donut {
    position: relative;
    width: 132px;
    height: 132px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cartera-hole {
    position: absolute;
    inset: 26px;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.cartera-hole strong { font-size: 22px; font-weight: 700; line-height: 1; color: var(--text-primary); }
.cartera-hole small {
    margin-top: 3px;
    font-size: 10.5px;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.cartera-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cartera-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.cartera-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.cartera-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cartera-val { font-weight: 700; color: var(--text-primary); white-space: nowrap; }

/* ── 6 · Movimientos recientes ────────────────────────────────────────── */
.dash-meta { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
/* v9.7 · «Movimientos recientes» ocupa todo el ancho del Dashboard. */
.dash-mov-card { margin-top: 20px; }

.mov-list { display: flex; flex-direction: column; }
.mov-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border-light);
}
.mov-row:last-child { border-bottom: none; }
.mov-main { display: flex; flex-direction: column; min-width: 0; }
.mov-persona {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* v9.7 · Solo el NOMBRE es clicable: abre esa persona en Personas y Movimientos. */
.mov-persona-link {
    appearance: none; background: none; border: 0; padding: 0; margin: 0;
    font: inherit; color: inherit; cursor: pointer; text-align: left;
    border-radius: 4px; transition: color .15s ease;
}
.mov-persona-link:hover { color: var(--accent); text-decoration: underline; }
.mov-persona-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mov-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mov-tipo {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
}
.mov-tipo.is-cargo { background: rgba(239,68,68,.12);   color: var(--danger); }
.mov-tipo.is-pago  { background: rgba(16,185,129,.12); color: var(--success); }
.mov-monto { font-size: 13px; font-weight: 700; white-space: nowrap; }
.mov-monto.is-cargo { color: var(--danger); }
.mov-monto.is-pago  { color: var(--success); }
.mov-fecha { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

/* ── 7 · Top deudores (ranking compacto, importe siempre positivo) ────── */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border-light);
}
.rank-item:last-child { border-bottom: none; }
.rank-pos {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.rank-item:first-child .rank-pos { background: var(--danger); color: #fff; }
.rank-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rank-debt { font-size: 13px; font-weight: 700; color: var(--danger); white-space: nowrap; }

/* ── 8 · Acciones rápidas: RETIRADAS ───────────────────────────────────
   Las tres tarjetas del pie del dashboard («Gestionar Personas», «Exportar
   Saldos» y «Crear Respaldo») se eliminaron por decisión del propietario.
   Sus funciones siguen intactas y accesibles desde sus secciones:
   Personas y Movimientos, Reportes (exportación) y Respaldos. Se retiran
   también .quick-actions-row / .qa-card / .qa-ico / .qa-text, que ya no usa
   ningún otro componente. */

/* ── 9 · Adaptación a pantallas medianas y móvil ──────────────────────── */
@media (max-width: 1280px) {
    .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .kpi-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .kpi-row { grid-template-columns: 1fr; }
    .kpi-card { padding: 12px 14px; }
    .kpi-value { font-size: 19px; }
    .cartera-wrap { gap: 16px; justify-content: center; }
    .cartera-legend { min-width: 100%; }
    .mov-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
    .mov-fecha { grid-column: 1 / -1; }
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPALDOS — Rediseño v2 (tarjeta única, banner, métricas, responsive)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Banner informativo compacto ─────────────────────────────────────── */
.bk-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 16px;
    position: relative;
}
[data-theme="dark"] .bk-banner { background: #172554; border-color: #1e3a8a; color: #93c5fd; }
.bk-banner-ico { width: 18px; height: 18px; flex-shrink: 0; color: #3b82f6; }
[data-theme="dark"] .bk-banner-ico { color: #60a5fa; }
.bk-banner span { flex: 1; min-width: 0; }
.bk-banner-close {
    width: 28px; height: 28px; flex-shrink: 0;
    border: none; background: transparent; color: inherit;
    font-size: 18px; cursor: pointer; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    opacity: .5; transition: all var(--transition);
}
.bk-banner-close:hover { opacity: 1; background: rgba(59,130,246,.12); }

/* ── Cabecera: subtítulo + acciones ──────────────────────────────────── */
.bk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.bk-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 450;
    margin: 0;
}
.bk-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.bk-btn-create {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(59,130,246,.25);
}
.bk-btn-create:hover { box-shadow: 0 4px 12px rgba(59,130,246,.3); }
.bk-btn-limpiar { color: var(--danger); border-color: var(--danger); }
.bk-btn-limpiar:hover { background: #fef2f2; color: var(--danger); }
[data-theme="dark"] .bk-btn-limpiar:hover { background: #450a0a; }

/* ── Métricas compactas (3 stats) ────────────────────────────────────── */
.bk-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.bk-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}
.bk-stat-ico {
    width: 38px; height: 38px; flex-shrink: 0;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
}
.bk-stat-ico .ico { width: 19px; height: 19px; stroke-width: 1.9; }
.bk-stat-ico--blue  { background: rgba(59,130,246,.12); color: var(--accent); }
.bk-stat-ico--green { background: rgba(16,185,129,.12); color: var(--success); }
.bk-stat-ico--amber { background: rgba(245,158,11,.12); color: var(--warning); }
.bk-stat-body { display: flex; flex-direction: column; min-width: 0; }
.bk-stat-value {
    font-size: 18px; font-weight: 800; color: var(--text-primary);
    line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-stat-label {
    font-size: 11px; font-weight: 600; letter-spacing: .4px;
    text-transform: uppercase; color: var(--text-muted);
}

/* ── Contador badge en header de tarjeta ─────────────────────────────── */
.bk-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; background: var(--accent); color: #fff;
    font-size: 11px; font-weight: 700; vertical-align: middle; margin-left: 4px;
}

/* ── Tarjeta principal ───────────────────────────────────────────────── */
.bk-card { overflow: visible; }
.bk-table-wrap { padding: 0 !important; overflow: visible; }

/* ── Tabla sin scroll horizontal ─────────────────────────────────────── */
.bk-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 13px;
}
.bk-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    background: var(--table-header);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: default;
}
.bk-col-name    { width: 36%; }
.bk-col-type    { width: 14%; }
.bk-col-date    { width: 20%; }
.bk-col-size    { width: 12%; }
.bk-col-inst    { width: 16%; }
.bk-col-actions { width: 16%; text-align: right; }
.bk-inst-name { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 140px; }
.bk-inst-id { font-size: 10px; color: var(--text-muted); }

.bk-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background .1s;
    cursor: default;
}
.bk-table tbody tr:last-child { border-bottom: none; }
.bk-table tbody tr:nth-child(even) { background: var(--table-even); }
.bk-table tbody tr:nth-child(odd)  { background: var(--table-odd); }
.bk-table tbody tr:hover { background: var(--table-selected); }

.bk-table td {
    padding: 10px 14px;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* FIX causa raíz (v7.5.4): el overflow:hidden del td (necesario para el
   ellipsis de nombres largos) RECORTABA geométricamente el tooltip CSS
   (.bk-act::after, position:absolute) que asoma por encima de la celda: al
   hacer hover solo se veía un fragmento oscuro del tooltip pegado bajo la
   línea de fila/encabezado de ACCIONES, y ese fragmento persistía durante el
   fade-out. La celda de acciones no contiene texto con ellipsis (sus bloques
   de texto ya lo gestionan aparte), así que se libera el recorte solo ahí. */
.bk-table td:has(.bk-row-actions),
.bk-table td:last-child {
    overflow: visible;
}

/* Celda nombre de archivo */
.bk-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.bk-file-ico {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
}
.bk-file-ico .ico { width: 16px; height: 16px; }
.bk-file-ico--zip { background: rgba(59,130,246,.1); color: var(--accent); }
.bk-file-ico--sql { background: rgba(245,158,11,.1); color: var(--warning); }
.bk-file-info { min-width: 0; }
.bk-file-name {
    font-weight: 600; font-size: 13px; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}
.bk-file-sub {
    font-size: 11px; color: var(--text-muted); font-weight: 400;
}

/* Badge tipo */
.bk-type {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 20px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
}
.bk-type--completo { background: rgba(59,130,246,.1); color: #2563eb; }
.bk-type--datos    { background: rgba(245,158,11,.1); color: #ca8a04; }
[data-theme="dark"] .bk-type--completo { background: rgba(59,130,246,.18); color: #93c5fd; }
[data-theme="dark"] .bk-type--datos    { background: rgba(245,158,11,.18); color: #fbbf24; }

/* Fecha */
.bk-date { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.bk-date-time { font-size: 11px; color: var(--text-muted); display: block; font-weight: 400; }

/* Tamaño */
.bk-size { font-size: 13px; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Acciones en fila */
.bk-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}
.bk-act {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; border-radius: 8px;
    color: var(--text-muted); cursor: pointer;
    transition: all var(--transition);
    position: relative;
    padding: 0;
}
.bk-act .ico { width: 16px; height: 16px; }
.bk-act:hover { background: var(--border-light); color: var(--text-primary); }
.bk-act--info:hover     { color: #3b82f6; background: rgba(59,130,246,.08); }
.bk-act--download:hover { color: #10b981; background: rgba(16,185,129,.08); }
.bk-act--restore:hover  { color: #f59e0b; background: rgba(245,158,11,.08); }
.bk-act--delete:hover   { color: #ef4444; background: rgba(239,68,68,.08); }
.bk-act--recover        { color: var(--text-muted); }
.bk-act--recover:hover  { color: #8b5cf6; background: rgba(139,92,246,.08); }

/* Tooltips CSS puros */
.bk-act::after {
    content: attr(data-tip);
    position: absolute; bottom: calc(100% + 4px); left: 50%;
    transform: translateX(-50%);
    padding: 3px 8px; border-radius: 4px;
    background: var(--text-primary); color: var(--surface);
    font-size: 10px; font-weight: 600; white-space: nowrap;
    opacity: 0; pointer-events: none;
    transition: opacity .12s ease;
    z-index: 9999;
}
.bk-act:hover::after { opacity: 1; }
/* FIX tooltips (v7.5.4): el tooltip centrado con translateX(-50%) se salía del
   contenedor recortado (.bk-table-wrap con overflow:hidden) en la última
   columna y quedaba "parcialmente visible/recortado" junto al encabezado de
   ACCIONES. En la columna de acciones se alinea al borde del botón para que
   siempre quede dentro del contenedor, en reposo sigue invisible (opacity 0)
   y solo aparece con :hover / :focus-visible. */
.bk-col-actions .bk-act::after,
td.row-actions .bk-act::after,
.bk-row-actions .bk-act:last-child::after,
.bk-mcard-actions .bk-act:last-child::after {
    left: auto;
    right: 0;
    transform: none;
}
.bk-act:focus-visible::after { opacity: 1; }
/* FIX tooltips: modal-body con tabla de respaldos permite desbordamiento */
.modal-body .bk-table-wrap { overflow: visible; }
.bk-table-wrap .bk-row-actions { position: relative; z-index: 2; }

/* ── Estado vacío rediseñado ─────────────────────────────────────────── */
.bk-empty {
    text-align: center;
    padding: 40px 20px;
}
.bk-empty-ico {
    width: 64px; height: 64px; margin: 0 auto 14px;
    border-radius: 16px;
    background: rgba(59,130,246,.08);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
}
.bk-empty-ico .ico-lg { width: 32px; height: 32px; }
.bk-empty-title {
    font-size: 15px; font-weight: 700; color: var(--text-primary);
    margin: 0 0 4px;
}
.bk-empty-desc {
    font-size: 13px; color: var(--text-muted);
    max-width: 300px; margin: 0 auto 16px; line-height: 1.5;
}

/* ── Vista móvil: tarjetas apiladas (oculta por defecto) ─────────────── */
.bk-mobile-list { display: none; }

.bk-mcard {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
}
.bk-mcard:last-child { border-bottom: none; }
.bk-mcard-top {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 8px; margin-bottom: 8px;
}
.bk-mcard-name {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    word-break: break-all; line-height: 1.35;
}
.bk-mcard-meta {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 10px;
}
.bk-mcard-meta-item {
    font-size: 12px; color: var(--text-muted);
    display: inline-flex; align-items: center; gap: 3px;
}
.bk-mcard-meta-item .ico { width: 13px; height: 13px; }
.bk-mcard-actions {
    display: flex; gap: 6px;
    border-top: 1px solid var(--border-light);
    padding-top: 10px;
}
.bk-mcard-btn {
    flex: 1;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 8px 0; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-secondary); font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
    font-family: inherit; min-height: 36px;
}
.bk-mcard-btn:hover { border-color: var(--accent); color: var(--accent); }
.bk-mcard-btn .ico { width: 14px; height: 14px; }
.bk-mcard-btn--danger:hover { border-color: var(--danger); color: var(--danger); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .bk-stats { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}

@media (max-width: 768px) {
    .bk-header { flex-direction: column; align-items: stretch; }
    .bk-header-actions { width: 100%; }
    .bk-btn-create { flex: 1; justify-content: center; padding: 10px 16px; }
    .bk-stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
    .bk-stat { padding: 10px 12px; gap: 10px; }
    .bk-stat-ico { width: 32px; height: 32px; }
    .bk-stat-ico .ico { width: 16px; height: 16px; }
    .bk-stat-value { font-size: 16px; }

    /* Cambiar a tarjetas apiladas en móvil */
    .bk-table { display: none; }
    .bk-mobile-list { display: block; }
}

@media (max-width: 480px) {
    .bk-stats { grid-template-columns: 1fr; gap: 6px; }
    .bk-stat { padding: 10px 12px; }
    .bk-banner { font-size: 12px; padding: 8px 12px; }
    .bk-mcard-actions { flex-wrap: wrap; }
    .bk-mcard-btn { min-width: calc(50% - 3px); flex: none; width: calc(50% - 3px); }
}

/* ====================================================================== */
/* ===== USUARIOS · REDISEÑO UX: toolbar compacta + modal + tabla ======= */
/* ====================================================================== */

/* --- Encabezado: título + contador + única acción primaria --- */
.usuarios-header { gap: 12px; flex-wrap: wrap; }
.usuarios-titulo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.badge-count {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 10px;
    font-variant-numeric: tabular-nums;
}

/* --- Toolbar: búsqueda + filtros en una fila bajo el encabezado --- */
.usuarios-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    flex-shrink: 0;
}
.usuarios-toolbar .search-box { flex: 1 1 220px; max-width: 340px; }
.usuarios-toolbar .search-box input { width: 100%; }
.usuarios-toolbar .filtro-select { flex: 0 0 auto; }

/* --- Celda de identidad: avatar con iniciales + nombre bajo el usuario ---
   (.usuario-avatar, NO .user-avatar que pertenece al topbar) */
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.usuario-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; letter-spacing: .3px;
    flex-shrink: 0; user-select: none;
}
.usuario-avatar-off { background: var(--text-muted); }
.user-name { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-name strong { font-size: 13px; color: var(--text-primary); }
.user-name small {
    color: var(--text-muted);
    font-size: 11.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 240px;
}

/* --- Estado: píldora con punto (sustituye a los emojis 🟢/🔴) --- */
.status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill-on  { background: #f0fdf4; color: #15803d; }
.pill-off { background: #fef2f2; color: #b91c1c; }
[data-theme="dark"] .pill-on  { background: rgba(34,197,94,.15); color: #4ade80; }
[data-theme="dark"] .pill-off { background: rgba(239,68,68,.15); color: #f87171; }

/* --- Tabla: sin puntero de orden falso; acciones alineadas a la derecha --- */
#tablaUsuarios thead th { cursor: default; }
#tablaUsuarios thead th:hover { background: var(--table-header); }
#tablaUsuarios tbody tr { cursor: default; }
#tablaUsuarios th.col-acciones { text-align: right; }
/* td.row-actions ya es table-cell (ver FIX causa raíz): la alineación derecha
   viene de la regla compartida td.row-actions { text-align: right; } */
#tablaUsuarios .btn-action { padding: 5px 9px; }

/* --- Formulario dentro del modal: 2 columnas (1 en móvil, ver media 768) --- */
.form-grid-modal { grid-template-columns: 1fr 1fr; }

/* --- Responsividad de la pantalla de usuarios --- */
@media (max-width: 768px) {
    .usuarios-header { padding: 12px 14px; }
    .usuarios-toolbar { padding: 10px 14px; }
    .usuarios-toolbar .search-box { flex-basis: 100%; max-width: none; }
    .usuarios-toolbar .filtro-select { flex: 1 1 0; min-width: 0; }
    /* En móvil se oculta "Último acceso": la tabla prioriza identidad y acciones */
    #tablaUsuarios th.col-acceso,
    #tablaUsuarios td.col-acceso { display: none; }
    .user-name small { max-width: 150px; }
}
@media (max-width: 480px) {
    .usuarios-header .btn-label { display: none; }
    .usuarios-header #btnNuevoUsuario { padding: 8px 12px; }
    .usuario-avatar { width: 30px; height: 30px; font-size: 11px; }
}

/* ====================================================================== */
/* == INSTITUCIONES · REDISEÑO UX: lista limpia + modal + menú de fila === */
/* ====================================================================== */
/* Misma anatomía que la pantalla de Usuarios: encabezado (título + contador
   + única acción primaria), toolbar (búsqueda + filtros) y tabla simplificada.
   Reutiliza .badge-count, .status-pill y .form-grid-modal ya definidos.     */

/* --- Encabezado: título + contador + única acción primaria --- */
.inst-header { gap: 12px; flex-wrap: wrap; }
.inst-titulo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }

/* --- Toolbar: búsqueda + filtros en una fila bajo el encabezado --- */
.inst-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    flex-shrink: 0;
}
.inst-toolbar .search-box { flex: 1 1 220px; max-width: 340px; }
.inst-toolbar .search-box input { width: 100%; }
.inst-toolbar .filtro-select { flex: 0 0 auto; }

/* --- Celda de identidad: avatar con iniciales + nombre sobre ID/RUC --- */
.inst-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.inst-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; letter-spacing: .3px;
    flex-shrink: 0; user-select: none;
}
.inst-avatar-off { background: var(--text-muted); }
.inst-name { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.inst-name strong { font-size: 13px; color: var(--text-primary); }
.inst-name small {
    color: var(--text-muted);
    font-size: 11.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 260px;
}

/* --- Tabla: acciones alineadas a la derecha --- */
#tablaInstituciones thead th { cursor: default; }
#tablaInstituciones thead th:hover { background: var(--table-header); }
#tablaInstituciones tbody tr { cursor: default; }
#tablaInstituciones th.col-acciones { text-align: right; }
/* td.row-actions ya es table-cell (ver FIX causa raíz): la alineación derecha
   viene de la regla compartida td.row-actions { text-align: right; } */
#tablaInstituciones .btn-action { padding: 5px 9px; }

/* --- Menú de fila «⋯»: acciones secundarias agrupadas (popover fijo) --- */
.cell-menu { position: relative; text-align: right; width: 1%; }
.btn-more { padding: 4px 10px; font-size: 14px; line-height: 1.2; letter-spacing: 1px; }
.row-menu {
    position: fixed;              /* el JS fija top/left al abrir */
    z-index: 1100;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: none;
    text-align: left;
}
.row-menu.open { display: block; animation: modalIn .15s ease; }
.row-menu-item {
    display: flex; width: 100%; align-items: center; gap: 8px;
    background: none; border: 0; padding: 8px 10px; border-radius: 8px;
    font-size: 13px; font-family: inherit; color: var(--text-primary);
    cursor: pointer; text-align: left; white-space: nowrap;
}
.row-menu-item:hover { background: var(--bg); }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { background: #fef2f2; }
[data-theme="dark"] .row-menu-item.danger:hover { background: rgba(239,68,68,.12); }

/* --- Modal contractual: un poco más ancho que el de usuario --- */
.modal-inst { width: 560px; }

/* --- Responsividad de la pantalla de instituciones --- */
@media (max-width: 768px) {
    .inst-header { padding: 12px 14px; }
    .inst-toolbar { padding: 10px 14px; }
    .inst-toolbar .search-box { flex-basis: 100%; max-width: none; }
    .inst-toolbar .filtro-select { flex: 1 1 0; min-width: 0; }
    /* En móvil se ocultan Tipo y Contacto: prioridad a identidad, plan y acciones */
    #tablaInstituciones th.col-tipo,
    #tablaInstituciones td.col-tipo,
    #tablaInstituciones th.col-contacto,
    #tablaInstituciones td.col-contacto { display: none; }
    .inst-name small { max-width: 150px; }
    .modal-inst { width: 92vw !important; max-width: 560px; }
}
@media (max-width: 480px) {
    .inst-header .btn-label { display: none; }
    .inst-header #btnNuevaInstitucion { padding: 8px 12px; }
    .inst-avatar { width: 30px; height: 30px; font-size: 11px; }
}

/* ===== AUDITORÍA POR USUARIO (v7.7) ===== 
   ESTRUCTURA BASE: un ÚNICO contenedor con scroll.
   El modal es una columna flex de altura acotada: cabecera, filtros, barra de
   acciones y paginación quedan fijos, y TODO el desplazamiento vertical vive
   en .auditoria-scroll. Se eliminaron los overflow anidados que provocaban
   dos y tres barras de scroll dentro del mismo modal. */
.modal-auditoria {
    width: min(1180px, 96vw);
    max-width: 96vw;
    height: min(88vh, 940px);
    max-height: 92vh;
    overflow: hidden;
}
.modal-auditoria .modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 16px 20px;
    gap: 12px;
}
/* Cabecera de filtros fija; el contenedor de la tabla absorbe el espacio
   restante y es el ÚNICO que scrollea. (Una regla comodín > * quitaba el
   flex:1 al scroller y la lista larga quedaba recortada sin scroll.) */
.modal-auditoria .modal-body > .auditoria-intro,
.modal-auditoria .modal-body > .auditoria-filtros,
.modal-auditoria .modal-body > .auditoria-acciones-filtro,
.modal-auditoria .modal-body > .auditoria-paginacion { flex: 0 0 auto; }
.modal-auditoria .modal-body > .auditoria-scroll { flex: 1 1 auto; }

.auditoria-intro {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* Filtros: rejilla fluida que se reordena sin desbordar */
.auditoria-filtros {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}
.auditoria-filtros .form-group { margin: 0; min-width: 0; }
.auditoria-filtros label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 3px;
}
.auditoria-filtros input,
.auditoria-filtros select { width: 100%; min-width: 0; }
.auditoria-acciones-filtro {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.auditoria-contador {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ── ÚNICO contenedor con scroll vertical ── */
.auditoria-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

/* Tabla: 100% del ancho, sin desbordes y legible */
.auditoria-tabla {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12.5px;
}
.auditoria-tabla col.col-fecha   { width: 96px; }
.auditoria-tabla col.col-usuario { width: 164px; }
.auditoria-tabla col.col-datos   { width: 104px; }
/* El estilo global de la app (tbody td { white-space: nowrap }) impedía que
   la acción humana partiese en varias líneas: por eso el texto se salía del
   ancho y se recortaba en móvil. Aquí se revierte de forma explícita. */
.auditoria-tabla th,
.auditoria-tabla td {
    padding: 9px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
    white-space: normal;
}
.auditoria-tabla tbody tr { cursor: default; }
.auditoria-tabla thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    white-space: nowrap;
}
.auditoria-tabla tbody tr:hover { background: var(--bg); }
.auditoria-tabla tbody tr:last-child td { border-bottom: none; }
.aud-col-fecha {
    color: var(--text-secondary);
    white-space: normal;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
}
.aud-fecha-dia { display: block; }
.aud-fecha-hora { display: block; font-size: 11px; color: var(--text-muted); }
.aud-usuario { display: block; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.aud-usuario-id { display: block; font-size: 10.5px; color: var(--text-muted); }

/* Acción legible para humanos */
.aud-col-accion .aud-frase { display: block; color: var(--text-primary); line-height: 1.45; }
.aud-ref { display: block; margin-top: 2px; font-size: 11px; color: var(--text-muted); }

/* Chip del tipo de acción */
.aud-chip {
    display: inline-block;
    margin: 0 6px 2px 0;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: 1px;
}
.aud-chip-crear      { background: rgba(16, 185, 129, .16);  color: #047857; }
.aud-chip-actualizar { background: rgba(59, 130, 246, .16);  color: #1d4ed8; }
.aud-chip-eliminar   { background: rgba(239, 68, 68, .16);   color: #b91c1c; }
.aud-chip-acceso     { background: rgba(139, 92, 246, .16);  color: #6d28d9; }
.aud-chip-seguridad  { background: rgba(245, 158, 11, .18);  color: #b45309; }
.aud-chip-otro       { background: rgba(100, 116, 139, .16); color: #475569; }

/* La celda de datos apila botón y marca: nunca ensancha la tabla */
.aud-col-datos { white-space: normal; }
.aud-col-datos > * { display: block; }
.aud-col-datos .btn-action { width: fit-content; margin: 0 0 4px; }
.aud-col-datos .badge-snapshot { width: fit-content; margin-left: 0; }

.badge-snapshot {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    padding: 2px 8px;
    background: rgba(239, 68, 68, .15);
    color: var(--danger);
    border-radius: 10px;
    font-weight: 700;
    vertical-align: middle;
}

.auditoria-paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.auditoria-pagina { font-size: 12px; color: var(--text-muted); }

/* El detalle también usa un solo scroll (el de su propio modal-body) */
.modal-auditoria-detalle {
    width: min(860px, 94vw);
    max-height: 90vh;
}

/* Detalle antes/después */
.aud-detalle-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 16px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.aud-meta-item { display: flex; gap: 8px; font-size: 12px; }
.aud-meta-k { color: var(--text-muted); font-weight: 600; min-width: 84px; }
.aud-meta-v { color: var(--text-primary); word-break: break-word; }

.aud-detalle-nota {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.5;
}
.aud-detalle-sub { font-size: 13px; font-weight: 600; margin: 10px 0; }

.aud-diff {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}
.aud-diff th,
.aud-diff td {
    border: 1px solid var(--border);
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}
.aud-diff thead th { background: var(--bg); font-weight: 600; }
.aud-diff-cambio { background: rgba(245, 158, 11, .14); }
.aud-diff-cambio td:last-child { font-weight: 600; }

/* Sin scroll propio: el JSON fluye dentro del scroll del modal */
.aud-json {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

@media (max-width: 1100px) {
    .auditoria-filtros { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .auditoria-filtros { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Tabla → tarjetas apiladas: sin scroll horizontal, todo legible */
/* Cada fila se convierte en una tarjeta con rejilla: anchos controlados por
   minmax(0, 1fr) (nunca desbordan) y sin scroll horizontal. */
@media (max-width: 700px) {
    .modal-auditoria { width: 96vw; height: 90vh; }
    .auditoria-tabla colgroup { display: none; }
    .auditoria-tabla thead { display: none; }
    .auditoria-tabla,
    .auditoria-tabla tbody { display: block; width: 100%; }
    .auditoria-tabla tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "fecha datos"
            "usuario usuario"
            "accion accion";
        gap: 4px 10px;
        width: 100%;
        box-sizing: border-box;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }
    .auditoria-tabla td {
        display: block;
        width: auto;
        min-width: 0;
        border: none;
        padding: 0;
    }
    .auditoria-tabla td::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--text-muted);
    }
    .aud-col-fecha { grid-area: fecha; }
    .aud-col-usuario { grid-area: usuario; }
    .aud-col-accion { grid-area: accion; }
    .aud-col-datos {
        grid-area: datos;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 6px;
    }
    .aud-col-datos > * { display: inline-block; margin: 0; }
    .aud-col-datos::before { display: none; }
    .aud-detalle-meta { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .auditoria-filtros { grid-template-columns: 1fr; }
}

/* ======================================================================
   v7.9 · GASTOS ADMINISTRATIVOS / CAJA GLOBAL
   Módulo SEPARADO del dinero individual de las personas: controla solo el
   efectivo real de la institución (recaudado − gastos administrativos).
   Se integra con las tarjetas, tablas y filtros ya existentes.
   ====================================================================== */

/* Indicadores de caja: recaudado / saldo a favor / gastos / disponible */
.kpi-disponible .kpi-ico { background: rgba(59,130,246,.12); color: var(--accent); }
.gastos-kpi-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* --- Encabezado de la sección --- */
.gastos-card { display: flex; flex-direction: column; min-width: 0; }
.gastos-header { gap: 12px; flex-wrap: wrap; }
.gastos-titulo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.badge-deuda-indep {
    background: rgba(245,158,11,.14);
    border: 1px solid rgba(245,158,11,.4);
    color: #b45309;
    font-size: 11px;
    padding: 2px 10px;
    font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .badge-deuda-indep { color: #fbbf24; }

/* --- Formulario inline (nuevo / editar). Nunca modal dentro de modal --- */
.gasto-form-panel {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.gasto-form-titulo { font-size: 13px; font-weight: 700; color: var(--text-primary); margin: 0 0 12px; }
.gasto-form-panel .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gasto-form-panel .form-group.span-full { grid-column: 1 / -1; }
.gasto-form-panel textarea { width: 100%; resize: vertical; font-family: inherit; }
.gasto-form-panel input[type="file"] { width: 100%; font-size: 12px; }
.file-hint { display: block; margin-top: 4px; font-size: 11.5px; color: var(--text-muted); }
.gasto-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* --- Filtros: fecha, categoría, usuario y texto --- */
.gastos-toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.6fr) auto;
    align-items: end;
    gap: 10px 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.gastos-toolbar .form-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; }
.gastos-toolbar label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.gastos-toolbar input[type="date"],
.gastos-toolbar .filtro-select { width: 100%; }
.gastos-buscar .search-box { width: 100%; }
.gastos-buscar .search-box input { width: 100%; }
.gastos-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gastos-suma { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

/* --- Tabla del historial: 100% del ancho útil, sin desbordes --- */
.gastos-table-wrap { padding: 0; }
.gastos-tabla { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.gastos-tabla col.col-fecha    { width: 92px; }
.gastos-tabla col.col-cat      { width: 128px; }
.gastos-tabla col.col-monto    { width: 108px; }
.gastos-tabla col.col-usuario  { width: 138px; }
.gastos-tabla col.col-doc      { width: 96px; }
.gastos-tabla col.col-acciones { width: 92px; }
.gastos-tabla th,
.gastos-tabla td {
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
    white-space: normal;
}
.gastos-tabla thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    white-space: nowrap;
}
.gastos-tabla tbody tr:hover { background: var(--bg); }
.gastos-tabla tbody tr:last-child td { border-bottom: none; }
.gastos-tabla .col-monto, .gasto-monto { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.gasto-fecha { color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: normal; }
.gasto-cat {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 999px;
    background: rgba(59,130,246,.12);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.gasto-concepto { color: var(--text-primary); }
.gasto-obs { display: block; margin-top: 2px; font-size: 11px; color: var(--text-muted); }
.gasto-usuario { color: var(--text-secondary); }
.gasto-acciones { display: flex; gap: 6px; justify-content: flex-end; }
.gasto-sin-doc { color: var(--text-muted); }
.gasto-doc { white-space: nowrap; }

/* --- Paginación --- */
.gastos-paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}
.gastos-pagina { font-size: 12px; color: var(--text-muted); }

/* --- Dashboard: tarjeta de CAJA GLOBAL --- */
.caja-card { margin-bottom: 16px; }
.caja-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.caja-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}
.caja-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.caja-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.caja-item.is-recaudado .caja-value { color: var(--success); }
.caja-item.is-favor .caja-value { color: var(--warning); }
.caja-item.is-gasto .caja-value { color: var(--danger); }
.caja-item.is-disponible { border-color: var(--accent); }
.caja-item.is-disponible .caja-value { color: var(--accent); }
.caja-note { font-size: 11.5px; color: var(--text-muted); }
.caja-deuda-indep {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}
.caja-deuda-chip {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 999px;
    background: rgba(245,158,11,.14);
    color: #b45309;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .caja-deuda-chip { color: #fbbf24; }
.caja-deuda-indep small { color: var(--text-muted); font-size: 11.5px; }

/* --- Responsive: tablet y móvil --------------------------------------- */
@media (max-width: 1100px) {
    .gastos-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .gastos-toolbar-actions { grid-column: 1 / -1; justify-content: flex-end; }
    .caja-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .gastos-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .gastos-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .gasto-form-panel .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .caja-grid { grid-template-columns: 1fr; }
}
/* Tabla → tarjetas apiladas: sin scroll horizontal, todo legible en móvil */
@media (max-width: 700px) {
    .gastos-kpi-row { grid-template-columns: 1fr; }
    .gastos-toolbar { grid-template-columns: 1fr; }
    .gasto-form-panel .form-grid { grid-template-columns: 1fr; }
    .gastos-tabla colgroup,
    .gastos-tabla thead { display: none; }
    .gastos-tabla,
    .gastos-tabla tbody { display: block; width: 100%; }
    .gastos-tabla tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 4px 10px;
        width: 100%;
        box-sizing: border-box;
        padding: 12px;
        border-bottom: 1px solid var(--border);
    }
    .gastos-tabla td { display: block; width: auto; min-width: 0; border: none; padding: 0; }
    .gastos-tabla td::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--text-muted);
    }
    .gastos-tabla .col-monto, .gasto-monto { text-align: left; }
    .gasto-acciones { justify-content: flex-start; }
    .gastos-header .header-actions { width: 100%; }
    .gastos-header .header-actions .btn { width: 100%; justify-content: center; }
}

/* ── Mismas reglas anti-compresión que #tab-mi-institucion ──────────────
   #tab-dashboard y #tab-gastos son flex column: sin esto, la tarjeta de caja
   y la sección de gastos se comprimían y su .card-body (overflow:auto,
   flex:1) recortaba el contenido con un scroll interno. El scroll —uno
   solo— queda en el contenedor del tab. */
#tab-dashboard .caja-card,
#tab-gastos .gastos-card { flex-shrink: 0; }
#tab-dashboard .caja-card .card-body,
#tab-gastos .gastos-card .card-body { flex: none; overflow: visible; }
#tab-gastos .gastos-table-wrap { overflow: visible; }




/* ============================================================
   v9.0 · REPORTES PROFESIONALES (motor A4 reutilizable)
   Panel de selección + filtros + vista previa del PDF real.
   ============================================================ */
.rep-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.rep-lado { display: flex; flex-direction: column; gap: 14px; }
.rep-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rep-card .card-body { padding: 12px 14px; }
/* Selector compacto de formato, en fila sobre el visor (sustituye a la antigua
   tarjeta «Reportes disponibles» del lateral). Solo presentación: el JS sigue
   pintando los mismos .rep-item dentro de #repListaReportes. */
.rep-selector { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: var(--shadow); }
.rep-selector-label { flex-shrink: 0; font-size: 10.5px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-secondary); }
.rep-lista { display: flex; flex-wrap: wrap; gap: 6px; }
.rep-item { display: inline-flex; align-items: center; max-width: 100%; min-width: 0;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-primary);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 12.4px;
  font-weight: 600; line-height: 1.2; white-space: nowrap; transition: var(--transition); }
.rep-item:hover { border-color: var(--accent); background: var(--border-light); }
.rep-item.activo { border-color: var(--accent); background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.28); }
[data-theme="dark"] .rep-item.activo { background: #2563eb; }
.rep-item strong { min-width: 0; font-size: 12.4px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; }
.rep-item small { display: none; }
.rep-filtros { display: grid; grid-template-columns: 1fr; gap: 9px; }
.rep-campo label { display: block; margin-bottom: 3px; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); }
.rep-campo input, .rep-campo select { width: 100%; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary); font-size: 12.8px; }
.rep-campo input:focus, .rep-campo select:focus { outline: none; border-color: var(--accent); }
.rep-botones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.rep-btn { font-size: 12.4px; padding: 8px 11px; }
.rep-cargando { font-size: 12.5px; color: var(--text-secondary); }
.rep-visor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.rep-visor-head h3 { margin: 0; font-size: 16px; }
.rep-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-secondary); max-width: 760px; }
.rep-meta { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.rep-chip { background: var(--border-light); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; }
.rep-visor { position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-height: 620px; overflow: hidden; }
.rep-frame { display: block; width: 100%; height: min(82vh, 1120px); border: 0; background: #fff; }
.rep-vacio { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; padding: 24px; text-align: center; color: var(--text-secondary); }
.rep-vacio p { margin: 0; font-size: 13px; max-width: 460px; }
.rep-vacio .ico { color: var(--accent); }
@media (max-width: 1024px) {
  .rep-layout { grid-template-columns: 1fr; }
  .rep-frame { height: min(72vh, 900px); }
  .rep-visor { min-height: 460px; }
}


/* v9.2 · casilla «solo deuda vencida» del listado de recaudación manual */
.rep-campo-check label { display: flex; align-items: center; gap: 8px; font-size: 12.6px; font-weight: 600;
  color: var(--text-primary); cursor: pointer; padding: 6px 0; }
.rep-campo-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* =====================================================================
   v9.3 · VISOR GLOBAL DE IMÁGENES Y COMPROBANTES (vista previa interna)
   Un ÚNICO lightbox reutilizable para TODO el sistema: fondo oscuro,
   imagen centrada, zoom, rotar, pantalla completa, responsive y accesible.
   ===================================================================== */
.visor-img {
    position: fixed; inset: 0; z-index: 2000;
    display: none; align-items: stretch; justify-content: stretch;
}
.visor-img-overlay {
    position: absolute; inset: 0;
    background: rgba(2, 6, 23, .82);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    cursor: zoom-out;
}
.visor-img-panel {
    position: relative; z-index: 1; margin: auto;
    width: min(96vw, 1500px); height: min(94vh, 1000px);
    display: flex; flex-direction: column;
    background: #0b1220;
    border: 1px solid rgba(148, 163, 184, .25);
    border-radius: 12px; overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
    animation: modalIn .18s ease;
}
.visor-img-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 10px; background: #0f172a;
    border-bottom: 1px solid rgba(148, 163, 184, .2); flex: 0 0 auto;
}
.visor-img-title { min-width: 0; display: flex; flex-direction: column; }
.visor-img-name {
    color: #e2e8f0; font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw;
}
.visor-img-sub { color: #94a3b8; font-size: 11px; }
.visor-img-tools { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.visor-img-btn {
    background: rgba(148, 163, 184, .12); color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, .25); border-radius: 6px;
    min-width: 34px; height: 32px; padding: 0 8px;
    font-size: 15px; line-height: 1; cursor: pointer;
}
.visor-img-btn:hover { background: rgba(148, 163, 184, .28); }
.visor-img-btn:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
.visor-img-btn-txt { font-size: 11.5px; font-weight: 600; }
.visor-img-zoom {
    color: #cbd5e1; font-size: 11.5px; min-width: 48px; text-align: center;
    font-variant-numeric: tabular-nums;
}
.visor-img-close { background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .4); }
.visor-img-close:hover { background: rgba(239, 68, 68, .35); }
.visor-img-stage {
    position: relative; flex: 1 1 auto; overflow: auto; background: #060b16;
    display: grid; align-content: safe center; justify-content: safe center;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.visor-img-lienzo {
    padding: 20px; display: flex; align-items: center; justify-content: center;
}
.visor-img-media {
    display: block; max-width: 100%; max-height: 100%; object-fit: contain;
    background: #fff; border-radius: 4px; box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
    transform-origin: center center;
}
.visor-img.visor-pdf .visor-img-stage { display: block; }
.visor-img.visor-pdf .visor-img-lienzo { width: 100%; height: 100%; padding: 8px; box-sizing: border-box; }
.visor-img-frame {
    display: block; width: 100%; height: 100%; min-height: calc(94vh - 56px);
    border: 0; background: #fff; border-radius: 4px;
}
.visor-img-estado {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    color: #cbd5e1; font-size: 13px; text-align: center; padding: 20px;
    pointer-events: none;
}
.visor-img-spinner {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid rgba(148, 163, 184, .3); border-top-color: #60a5fa;
    animation: visorSpin .8s linear infinite;
}
.visor-img-error .visor-img-estado-txt { color: #fca5a5; }
@keyframes visorSpin { to { transform: rotate(360deg); } }
html.visor-img-abierto, html.visor-img-abierto body { overflow: hidden !important; }

/* ── Miniaturas y elementos previsualizables (cursor + hover marcados) ── */
[data-preview], [data-preview-url], [data-preview-image], [data-preview-file], [data-preview-src] {
    cursor: pointer;
}
img[data-preview]:hover, img[data-preview-url]:hover,
img[data-preview-image]:hover, img[data-preview-src]:hover {
    opacity: .88; transition: opacity .15s ease;
}
a.doc-link:hover, a.gasto-doc:hover { opacity: .85; }
.doc-mini {
    width: 28px; height: 28px; object-fit: cover; border-radius: 4px;
    border: 1px solid var(--border); display: inline-block;
    vertical-align: middle; background: #fff;
}
.gasto-doc-mini {
    width: 30px; height: 30px; object-fit: cover; border-radius: 4px;
    border: 1px solid var(--border); margin-right: 6px;
    vertical-align: middle; background: #fff;
}
.doc-mini-lbl { margin-left: 6px; vertical-align: middle; }

/* ── Responsive (móvil: visor prácticamente a pantalla completa) ── */
@media (max-width: 720px) {
    /* Objetivo táctil cómodo para las miniaturas de comprobante */
    .doc-mini { width: 36px; height: 36px; }
    #tablaMovimientos .doc-link, .pm-deuda-hist-extra .doc-link {
        display: inline-flex; align-items: center; justify-content: center;
        min-width: 40px; min-height: 40px;
    }
    .visor-img-panel { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
    .visor-img-name { max-width: 38vw; font-size: 12px; }
    .visor-img-bar { padding: 6px 8px; gap: 6px; }
    .visor-img-btn { min-width: 32px; height: 32px; padding: 0 6px; font-size: 14px; }
    .visor-img-zoom { min-width: 42px; }
    .visor-img-frame { min-height: calc(100dvh - 50px); }
}


/* ══════════════════════════════════════════════════════════════════════
   v10 · SaaS: CICLO DE VIDA DE SUSCRIPCIONES Y ADMINISTRACIÓN CENTRALIZADA
   Reutiliza variables, tarjetas, píldoras y modales existentes.
   ══════════════════════════════════════════════════════════════════════ */

/* --- Panel: 6 indicadores (3×2 en escritorio, 2×3 en tableta y móvil) --- */
.saas-kpis { grid-template-columns: repeat(3, 1fr); }
button.stat-card.kpi-link {
    font: inherit; text-align: left; cursor: pointer; width: 100%;
    border-top: 0; border-right: 0; border-bottom: 0; color: inherit;
    transition: transform .15s ease, box-shadow .15s ease;
}
button.stat-card.kpi-link:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
button.stat-card.kpi-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.saas-kpis .stat-card { display: flex; flex-direction: column; gap: 2px; }
.saas-kpis .stat-label, .saas-kpis .stat-value { display: block; }
@media (max-width: 1024px) { .saas-kpis { grid-template-columns: repeat(2, 1fr); } }

/* --- Chip de estado unificado de la suscripción --- */
.estado-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 20px; white-space: nowrap;
    font-size: 11.5px; font-weight: 600;
    background: var(--border-light); color: var(--text-secondary);
}
.est-vigente, .est-gratuita       { background: #f0fdf4; color: #15803d; }
.est-por_vencer, .est-sin_vencimiento { background: #fffbeb; color: #b45309; }
.est-gracia                        { background: #fff7ed; color: #c2410c; }
.est-vencida, .est-cancelada, .est-sin_suscripcion { background: #fef2f2; color: #b91c1c; }
.est-suspendida, .est-servicio_suspendido { background: #f1f5f9; color: #475569; }
.est-archivada                     { background: #f1f5f9; color: #64748b; font-style: italic; }
[data-theme="dark"] .est-vigente, [data-theme="dark"] .est-gratuita { background: rgba(34,197,94,.15); color: #4ade80; }
[data-theme="dark"] .est-por_vencer, [data-theme="dark"] .est-sin_vencimiento { background: rgba(245,158,11,.15); color: #fbbf24; }
[data-theme="dark"] .est-gracia { background: rgba(249,115,22,.15); color: #fb923c; }
[data-theme="dark"] .est-vencida, [data-theme="dark"] .est-cancelada, [data-theme="dark"] .est-sin_suscripcion { background: rgba(239,68,68,.15); color: #f87171; }
[data-theme="dark"] .est-suspendida, [data-theme="dark"] .est-servicio_suspendido,
[data-theme="dark"] .est-archivada { background: rgba(148,163,184,.15); color: #cbd5e1; }

/* --- Tabla de instituciones: columnas compactas --- */
#tablaInstituciones td small { color: var(--text-muted); font-size: 11.5px; }
#tablaInstituciones .uso-excedido { color: var(--danger); font-weight: 600; }
#tablaInstituciones .badge-warning { margin-left: 4px; font-size: 11px; padding: 2px 7px; }

/* --- Panel lateral «Administrar» --- */
.modal.modal-drawer { justify-content: flex-end; align-items: stretch; }
.modal-drawer .modal-content.modal-admin-inst {
    width: min(760px, 100vw); max-height: 100vh; height: 100vh;
    border-radius: 0; animation: drawerIn .2s ease;
}
@keyframes drawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.admin-inst-cab { display: flex; flex-direction: column; min-width: 0; }
.admin-inst-cab small { color: var(--text-muted); font-size: 12px; }
.admin-tabs {
    display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--border);
    overflow-x: auto; flex-shrink: 0; scrollbar-width: thin;
}
.admin-tab {
    background: none; border: 0; border-bottom: 2px solid transparent;
    padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 600;
    color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.admin-tab:hover { color: var(--text-primary); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-tab .badge { font-size: 10.5px; padding: 1px 6px; margin-left: 4px; }
.admin-bloque { padding: 4px 0 14px; border-bottom: 1px solid var(--border-light); margin-bottom: 12px; }
.admin-bloque:last-child { border-bottom: 0; }
.admin-bloque h4 { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--text-primary); }
.admin-bloque .cartera-row strong { text-align: right; overflow-wrap: anywhere; }
.admin-acciones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.admin-estado { margin-bottom: 6px; }
.admin-estado .estado-chip { font-size: 13px; padding: 5px 12px; }
.admin-aviso {
    margin: 6px 0; padding: 9px 12px; border-radius: 8px; font-size: 13px;
    background: var(--status-pagado); color: var(--text-primary); border-left: 4px solid var(--warning);
}
.admin-aviso.aviso-danger { background: var(--status-falta); border-left-color: var(--danger); }
.admin-aviso.aviso-info { background: var(--border-light); border-left-color: var(--accent); }
.admin-nota { margin: 8px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.solicitud-card {
    border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
}
.solicitud-card .solicitud-info { flex: 1 1 260px; font-size: 13px; }
.solicitud-card .solicitud-info small { color: var(--text-muted); }
.solicitud-card .admin-acciones { margin-top: 0; flex-basis: 100%; }
.tabla-compacta { width: 100%; font-size: 12.5px; }
.tabla-compacta th, .tabla-compacta td { padding: 6px 8px; vertical-align: top; }
.tabla-compacta small { color: var(--text-muted); }
.check-inline { display: flex; align-items: center; gap: 6px; font-weight: 500; margin: 4px 0; cursor: pointer; }

/* --- Bitácora --- */
.bitacora-filtros input[type="date"] { min-width: 130px; }
.bitacora-paginacion {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 10px 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-secondary);
}
.detalle-titulo { margin: 14px 0 6px; font-size: 13px; }

/* --- Portal del cliente: aviso persistente y pantalla de vencida --- */
.aviso-suscripcion {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin: 10px 24px 0; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
    background: var(--border-light); border-left: 4px solid var(--accent); color: var(--text-primary);
}
.aviso-suscripcion.aviso-warning { background: var(--status-pagado); border-left-color: var(--warning); }
.aviso-suscripcion.aviso-danger { background: var(--status-falta); border-left-color: var(--danger); }
.modal-content.modal-vencida { width: 560px; }
.vencida-mensaje { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.vencida-datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.vencida-datos > div { background: var(--border-light); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.vencida-datos small { color: var(--text-muted); font-size: 11.5px; }
.vencida-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; font-size: 13px; }
.vencida-columnas ul { margin: 6px 0 0; padding-left: 18px; color: var(--text-secondary); line-height: 1.5; }
.vencida-nota { margin: 12px 0 0; font-size: 12.5px; color: var(--text-muted); }

/* --- Registro: estado de la validación del código de distribuidor --- */
.registro-hint.codigo-ok { color: #15803d; font-weight: 600; }
.registro-hint.codigo-aviso { color: #b45309; font-weight: 600; }
.registro-hint.codigo-error { color: #b91c1c; font-weight: 600; }
.registro-hint.codigo-validando { color: var(--text-muted); font-style: italic; }

/* --- Responsive --- */
@media (max-width: 1024px) {
    #tablaInstituciones .col-uso, #tablaBitacora .col-uso, #tablaPlanes .col-uso { display: none; }
}
@media (max-width: 768px) {
    .aviso-suscripcion { margin: 8px 12px 0; }
    .vencida-columnas, .vencida-datos { grid-template-columns: 1fr; }
    .modal-content.modal-vencida { width: 92vw !important; max-width: 560px; }
    .modal-drawer .modal-content.modal-admin-inst { width: 100vw !important; max-width: 100vw; }
    #tablaBitacora .col-plan { display: none; }
    .bitacora-paginacion { padding: 10px 14px; flex-wrap: wrap; }
}
/* Móvil: cada institución es una tarjeta (nombre, estado y vencimiento) */
@media (max-width: 640px) {
    #tablaInstituciones thead { display: none; }
    #tablaInstituciones, #tablaInstituciones tbody { display: block; width: 100%; }
    #tablaInstituciones tr {
        display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center;
        padding: 10px 12px; border-bottom: 1px solid var(--border);
    }
    #tablaInstituciones td { display: block; padding: 0 !important; border: 0 !important; }
    #tablaInstituciones td:first-child { grid-column: 1 / -1; }
    #tablaInstituciones .col-plan { display: none; }
    #tablaInstituciones td.col-vence { text-align: right; }
    #tablaInstituciones td.cell-acceso { grid-column: 1; text-align: left; }
    #tablaInstituciones td.cell-menu { grid-column: 2; width: auto; }
    .admin-tabs { padding: 6px 10px 0; }
    /* Filtros en dos filas legibles (sin textos recortados) */
    #tab-instituciones .inst-toolbar .filtro-select { flex: 1 1 calc(50% - 4px); }
}

/* ============================================================
   v11 · MI SUSCRIPCIÓN COMPACTA Y RENOVACIÓN EN 3 PASOS
   ============================================================ */

/* --- Sección «Mi plan»: ancho completo y distribución en columnas --- */
.sub-page {
    display: flex; flex-direction: column; gap: 18px;
    width: 100%; max-width: none; min-width: 0;
}
.sub-plan { overflow: hidden; }
.sub-plan-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
}
.sub-plan-head-txt { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; min-width: 0; }
.sub-plan-kicker { margin: 0; font-size: 12px; color: var(--text-muted); }
.sub-plan-body { display: flex; flex-direction: column; gap: 16px; overflow: visible; }
.sub-plan-overview {
    display: grid;
    grid-template-columns: minmax(240px, .85fr) minmax(0, 2fr);
    gap: 18px; align-items: stretch;
}
.sub-plan-ident {
    display: flex; flex-direction: column; gap: 4px; justify-content: center;
    min-width: 0; padding: 2px 0;
}
.sub-hero-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted); font-weight: 700;
}
.sub-plan-ident h4 {
    margin: 0; font-size: clamp(23px, 2.1vw, 30px); line-height: 1.15;
    font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere;
}
.sub-hero-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; overflow-wrap: anywhere; }
.sub-plan-priceline {
    display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
    margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border);
}
.sub-plan-priceline strong {
    font-size: 17px; font-weight: 800; color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.sub-plan-priceline small { font-size: 11.5px; color: var(--text-muted); }
.sub-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}
.sub-kpi {
    display: flex; flex-direction: column; gap: 6px; min-width: 0;
    background: var(--border-light); border: 1px solid var(--border);
    border-radius: 12px; padding: 12px 14px;
}
.sub-kpi-k {
    display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .045em; color: var(--text-muted);
}
.sub-kpi-k em {
    font-style: normal; font-weight: 500; text-transform: none;
    letter-spacing: 0; font-size: 10.5px; color: var(--text-muted);
}
.sub-kpi strong {
    font-size: 18px; font-weight: 800; line-height: 1.2;
    overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}
.sub-kpi strong.limite-alcanzado { color: var(--danger); }
.sub-kpi-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.sub-kpi-fill {
    height: 100%; width: 0; border-radius: inherit;
    background: var(--success); transition: width .35s ease, background .2s;
}
.sub-kpi-fill.is-warning { background: var(--warning); }
.sub-kpi-fill.is-danger { background: var(--danger); }
.sub-kpi-note { font-size: 11.5px; line-height: 1.3; color: var(--text-muted); }
.sub-plan-benefits { display: flex; flex-direction: column; gap: 7px; }
.sub-plan-subtitle {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .045em; color: var(--text-muted);
}
.sub-hero-beneficios { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-plan-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap;
    border-top: 1px solid var(--border); padding-top: 12px;
}
.sub-plan-foot-note { margin: 0; flex: 1 1 320px; font-size: 11.5px; color: var(--text-muted); }
.sub-plan-foot .btn { flex: 0 0 auto; }

/* --- Estado discreto de la última solicitud (misma tarjeta) --- */
.sub-solicitud {
    display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
    margin-top: 14px; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--border-light); font-size: 13px;
}
.sub-solicitud > div { flex: 1 1 240px; display: flex; flex-direction: column; gap: 2px; }
.sub-solicitud-ico { font-size: 18px; line-height: 1; }
.sub-solicitud small { color: var(--text-secondary); font-size: 12px; }
.sub-solicitud.estado-pendiente { background: var(--status-pagado); border-color: var(--warning); }
.sub-solicitud.estado-aprobada { background: var(--status-favor); border-color: var(--success); }
.sub-solicitud.estado-rechazada { background: var(--status-falta); border-color: var(--danger); }
.sub-solicitud-nota { flex: 1 1 100%; font-size: 12px; color: var(--text-muted); }
.sub-solicitud-btn { align-self: flex-start; margin-top: 4px; }

/* --- Detalles e historial dentro de la sección «Mi plan» --- */
.sub-detalles { border-top: 1px solid var(--border); background: var(--surface-2); }
.sub-detalles-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.sub-detalles-title { margin: 0; font-size: 14px; }
.sub-detalle-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 18px; }
.sub-detalle-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.sub-detalle-row span { color: var(--text-muted); }
.sub-subtitle { margin: 8px 0 2px; font-size: 13px; font-weight: 700; }
.sub-aviso-pendiente, .sub-aviso-error {
    border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 500; margin-bottom: 12px;
}
.sub-aviso-pendiente { background: var(--status-pagado); border-left: 4px solid var(--warning); }
.sub-aviso-error { background: var(--status-falta); border-left: 4px solid var(--danger); }

/* --- Modal amplio del asistente --- */
.modal-content.modal-sub-wizard { width: min(1000px, 94vw); max-width: 94vw; max-height: 90vh; }
.sub-steps {
    display: flex; gap: 6px; padding: 12px 22px 0; flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}
.sub-step {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    border: none; background: transparent; padding: 8px 10px 12px;
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    border-bottom: 2px solid transparent; transition: color var(--transition);
}
.sub-step span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%; font-size: 12px;
    background: var(--border); color: var(--text-secondary);
}
.sub-step em { font-style: normal; }
.sub-step.active { color: var(--accent); border-bottom-color: var(--accent); }
.sub-step.active span { background: var(--accent); color: #fff; }
.sub-step.done span { background: var(--success); color: #fff; }
.sub-step.done { color: var(--success); }
.modal-sub-body { padding: 16px 22px; overflow-y: auto; flex: 1 1 auto; }
.modal-sub-wizard .modal-footer { padding: 12px 22px; gap: 10px; flex-wrap: wrap; }

/* --- Paso 1: revisión del pedido (el catálogo ya no se repite aquí) --- */
.ren-hint { margin: 0 0 12px; font-size: 12.5px; color: var(--text-secondary); }
.ren-duracion { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.ren-sub-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.ren-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.ren-chip {
    border: 1.5px solid var(--border); background: var(--surface); color: var(--text-primary);
    border-radius: 20px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all var(--transition);
}
.ren-chip:hover { border-color: var(--accent); }
.ren-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- Paso 2: método de pago y cuentas --- */
.ren-metodos { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.ren-metodo {
    display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer;
    border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px;
    background: var(--surface); color: var(--text-primary); transition: all var(--transition);
}
.ren-metodo:hover:not(.disabled) { border-color: var(--accent); }
.ren-metodo.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.ren-metodo.disabled { opacity: .55; cursor: not-allowed; }
.ren-metodo-ico { font-size: 22px; }
.ren-metodo span { display: flex; flex-direction: column; gap: 1px; }
.ren-metodo strong { font-size: 14px; }
.ren-metodo small { font-size: 11.5px; color: var(--text-muted); }
.ren-cuentas { display: grid; gap: 10px; margin-bottom: 12px; }
.ren-cuenta {
    border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px;
    cursor: pointer; background: var(--surface); transition: all var(--transition);
}
.ren-cuenta:hover { border-color: var(--accent); }
.ren-cuenta.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.ren-cuenta-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.ren-cuenta-grid { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; font-size: 12.5px; }
.ren-cuenta-grid span { color: var(--text-muted); }
.ren-cuenta-grid strong { overflow-wrap: anywhere; }
.ren-cuenta-num { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-copiar {
    border: 1px solid var(--border); background: var(--border-light); color: var(--text-secondary);
    border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.btn-copiar:hover { border-color: var(--accent); color: var(--accent); }

/* --- Paso 3: registrar transferencia --- */
.ren-form { margin-bottom: 4px; }
.ren-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.ren-form-grid .span-full { grid-column: 1 / -1; }
.ren-preview { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.ren-preview-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 12px; background: var(--border-light); border-bottom: 1px solid var(--border);
    font-size: 12.5px; flex-wrap: wrap;
}
.ren-preview-head > span { color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: 11px; }
.ren-preview-head strong { overflow-wrap: anywhere; }
.ren-preview-body { display: flex; justify-content: center; align-items: center; background: var(--bg); padding: 10px; }
.ren-preview-body img { max-width: 100%; max-height: 320px; border-radius: 6px; }
.ren-preview-body iframe { width: 100%; height: 340px; border: none; border-radius: 6px; background: #fff; }

/* --- Ficha completa de la solicitud (administrador) --- */
.solicitud-card-full { flex-direction: column; align-items: stretch; }
.solicitud-datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 16px; width: 100%; }
.solicitud-dato { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.solicitud-dato span { color: var(--text-muted); }
.solicitud-dato strong { text-align: right; overflow-wrap: anywhere; }
.solicitud-card-full .solicitud-comp { margin-top: 4px; }

/* --- Ajustes responsive --- */
@media (max-width: 768px) {
    .modal-content.modal-sub-wizard { width: 96vw !important; max-width: 96vw; max-height: 94vh; }
    .sub-steps { padding: 10px 14px 0; gap: 2px; }
    .sub-step { font-size: 11.5px; padding: 6px 4px 10px; }
    .modal-sub-body { padding: 14px; }
    .modal-sub-wizard .modal-footer { padding: 12px 14px; }
    .ren-cuenta-grid { grid-template-columns: 1fr; gap: 1px 0; }
    .ren-cuenta-grid span { margin-top: 4px; }
}
@media (max-width: 420px) {
    .sub-step span { width: 20px; height: 20px; font-size: 11px; }
    .sub-step em { display: none; }
    .ren-preview-body iframe { height: 260px; }
}
[data-theme="dark"] .sub-kpi,
[data-theme="dark"] .ren-pedido,
[data-theme="dark"] .btn-copiar,
[data-theme="dark"] .ren-preview-head { background: var(--border-light); }

/* ============================================================
   v12 · MI SUSCRIPCIÓN: RESUMEN + CATÁLOGO DINÁMICO DE PLANES
   ============================================================ */

/* --- Sección «Mi plan»: distintivos y beneficios --- */
.sub-hero-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub-hero-extra { font-size: 11.5px; color: var(--text-muted); }
.sub-hero-beneficios .benef-vacio { font-size: 12px; color: var(--text-muted); }
.badge-neutral { background: var(--border-strong); color: var(--text-primary); }

/* --- Catálogo dinámico de planes --- */
.sub-catalogo { overflow: hidden; }
.sub-catalogo-head { gap: 12px; flex-wrap: wrap; }
.sub-catalogo-head-txt { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; min-width: 0; flex: 1 1 380px; }
.sub-catalogo-sub { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.sub-catalogo-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sub-catalogo-count {
    font-size: 11.5px; font-weight: 700; color: var(--accent);
    background: var(--accent-soft); border: 1px solid var(--accent-soft-strong);
    border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}
.sub-catalogo-meta { font-size: 11.5px; color: var(--text-muted); }
.sub-catalogo-body { padding: 18px 20px 20px; }
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    justify-content: center;
    gap: 14px;
    align-items: stretch;
}
.cat-grid > .resumen-loading, .cat-grid > .cat-vacio { grid-column: 1 / -1; }
.cat-vacio {
    margin: 0; padding: 18px; text-align: center;
    font-size: 13px; color: var(--text-secondary);
    background: var(--border-light); border: 1px dashed var(--border-strong); border-radius: 12px;
}
.cat-plan {
    position: relative;
    display: flex; flex-direction: column; gap: 11px;
    border: 1px solid var(--border);
    border-top: 3px solid var(--border-strong);
    border-radius: 14px;
    padding: 14px 15px;
    background: var(--surface);
    min-width: 0; width: 100%; max-width: 600px;
    justify-self: center; height: 100%;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.cat-plan:hover {
    border-color: var(--accent);
    border-top-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.cat-plan.es-actual {
    border-color: var(--accent);
    border-top-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft-strong);
    background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 34%);
}
.cat-plan.no-contratable { opacity: .86; }
.cat-plan.no-contratable:hover {
    transform: none; box-shadow: none;
    border-color: var(--border); border-top-color: var(--border-strong);
}
.cat-plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cat-plan-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cat-plan-title strong { font-size: 15.5px; line-height: 1.25; overflow-wrap: anywhere; }
.cat-plan-title small {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; font-size: 11.5px; line-height: 1.35; color: var(--text-secondary);
}
.cat-plan-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.cat-plan-badges .badge { white-space: nowrap; }
.cat-plan-price {
    display: flex; flex-direction: column; gap: 3px;
    min-height: 62px; justify-content: flex-end;
}
.cat-plan-amount { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.cat-plan-amount strong {
    font-size: 25px; font-weight: 800; letter-spacing: -.02em;
    color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.cat-plan-amount small { font-size: 11.5px; color: var(--text-muted); }
.cat-plan-antes { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.cat-plan-ahorro {
    align-self: flex-start; font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
    color: var(--success-text); background: var(--success-soft);
    border: 1px solid var(--success-border); border-radius: 999px; padding: 2px 8px;
}
.cat-plan-durs { display: flex; flex-direction: column; gap: 5px; }
.cat-plan-lbl {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-muted);
}
.cat-durs { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 5px; }
.cat-dur {
    display: flex; flex-direction: column; gap: 1px; align-items: flex-start;
    min-width: 0; border: 1px solid var(--border); background: var(--surface);
    color: var(--text-primary); border-radius: 8px; padding: 5px 7px;
    cursor: pointer; font-size: 11.5px; font-weight: 700; line-height: 1.2;
    text-align: left;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.cat-dur span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-dur small { font-size: 10.5px; font-weight: 500; color: var(--text-muted); }
.cat-dur:hover { border-color: var(--accent); background: var(--accent-soft); }
.cat-dur.active {
    border-color: var(--accent); background: var(--accent);
    color: var(--accent-contrast); box-shadow: var(--focus-ring);
}
.cat-dur.active small { color: var(--accent-contrast); opacity: .9; }
.cat-dur.active s { color: var(--accent-contrast); opacity: .75; }
.cat-plan-feats {
    list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column;
    gap: 4px; font-size: 12px; color: var(--text-secondary);
}
.cat-plan-feats li { display: flex; gap: 6px; align-items: baseline; overflow-wrap: anywhere; }
.cat-plan-feats li::before { content: '✓'; color: var(--success-solid); font-weight: 800; flex: 0 0 auto; }
.cat-plan-feats li.cat-feat-personas::before { content: '👥'; }
.cat-plan-feats li.cat-feat-usuarios::before { content: '🔑'; }
.cat-plan-feats li.cat-plan-vence { color: var(--text-muted); font-size: 11px; }
.cat-plan-feats li.cat-plan-vence::before { content: '📅'; }
.cat-plan-foot {
    margin-top: auto; display: flex; flex-direction: column; gap: 7px;
    border-top: 1px solid var(--border); padding-top: 10px;
}
.cat-plan-nota { font-size: 11px; color: var(--text-muted); min-height: 1px; line-height: 1.3; }
.cat-plan-foot .btn { width: 100%; }
.sub-condiciones-nota, .sub-historial-nota { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); }

/* --- Revisión del pedido en el modal unificado --- */
.ren-pedido {
    display: flex; flex-direction: column; gap: 4px;
    padding: 12px 14px; margin-bottom: 8px;
    border: 1px solid var(--border); border-left: 4px solid var(--accent);
    border-radius: 10px; background: var(--border-light);
}
.ren-pedido-kicker {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-muted);
}
.ren-pedido-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ren-pedido-meta strong { font-size: 17px; font-weight: 800; overflow-wrap: anywhere; }
.ren-hint-mini { margin: 0; font-size: 11.5px; }
.ren-resumen { width: 100%; max-width: none; margin: 10px 0 0; }

/* --- Adaptación de la sección a tabletas y teléfonos --- */
@media (max-width: 1100px) {
    .sub-plan-overview { grid-template-columns: 1fr; gap: 14px; }
    .sub-plan-ident { padding: 0; }
    .sub-kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}
@media (max-width: 768px) {
    .sub-plan-head, .sub-catalogo-head { padding: 13px 15px; }
    .sub-plan-body { padding: 15px; }
    .sub-catalogo-body { padding: 15px; }
    .sub-detalles-body { padding: 14px 15px 16px; }
    .sub-catalogo-actions { width: 100%; justify-content: flex-start; }
    .sub-plan-foot-note { flex-basis: 100%; }
    .cat-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
}
@media (max-width: 620px) {
    .sub-page { gap: 14px; }
    .sub-plan-ident h4 { font-size: 23px; }
    .sub-kpis { grid-template-columns: 1fr 1fr; }
    .sub-kpi:first-child { grid-column: 1 / -1; }
    .sub-plan-foot { flex-direction: column; align-items: stretch; }
    .sub-plan-foot .btn { width: 100%; }
    .sub-catalogo-count { font-size: 11px; }
    .sub-catalogo-meta { font-size: 11px; }
    .cat-grid { grid-template-columns: 1fr; }
    .cat-plan { padding: 14px; }
    .cat-plan-amount strong { font-size: 23px; }
    .cat-plan-price { min-height: 0; }
}
@media (max-width: 420px) {
    .sub-kpis { grid-template-columns: 1fr; }
    .sub-kpi:first-child { grid-column: auto; }
}

/* --- Editor de duraciones del plan (Plataforma) --- */
.plan-dur-editor { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 8px; }
.plan-dur-head, .plan-dur-row {
    display: grid;
    grid-template-columns: 130px 90px minmax(120px, 1fr) 120px 34px;
    gap: 6px;
    align-items: center;
}
.plan-dur-head span { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.plan-dur-row input, .plan-dur-row select { width: 100%; padding: 6px 8px; font-size: 12.5px; }
.plan-dur-row input:disabled { background: var(--disabled-background); color: var(--disabled-text); }
.plan-dur-cell { font-size: 11.5px; line-height: 1.5; }
.ren-hint-mini { margin: 6px 0 0; font-size: 11.5px; }

@media (max-width: 900px) {
    .plan-dur-head { display: none; }
    .plan-dur-row { grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; }
    .plan-dur-row .plan-dur-etiq { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
    .cat-grid { grid-template-columns: 1fr; }
    .cat-plan { padding: 14px; }
    .cat-plan-price strong { font-size: 23px; }
    .cat-dur { flex: 1 1 auto; align-items: center; }
    .sub-hero-badges { width: 100%; justify-content: flex-start; }
}

/* ============================================================
   v11b · ADMINISTRACIÓN SaaS COMPACTA, MENÚ, MODALES Y LÍMITES
   ============================================================ */

/* --- Cabecera compacta de «Administrar institución» --- */
.admin-inst-header-actions { display: flex; align-items: center; gap: 8px; position: relative; }
.admin-inst-menu {
    position: absolute; top: calc(100% + 6px); right: 34px; z-index: 20;
    min-width: 250px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column;
}
.admin-menu-item {
    text-align: left; border: none; background: transparent; cursor: pointer;
    padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-primary);
}
.admin-menu-item:hover { background: var(--border-light); }
.admin-menu-item.peligro { color: var(--danger); }
/* Resumen superior de «Administrar institución».
   El número de columnas se FIJA al de tarjetas que pinta renderAdminInstHeader()
   (Servicio · Plan · Vencimiento · Estado · Responsable · Uso = 6). Con
   «auto-fit» solo cabían 5 columnas en el panel de 760 px: la sexta tarjeta
   caía a una segunda fila y las celdas vacías que quedaban a su lado mostraban
   el fondo gris de los separadores. Con las columnas explícitas no hay ninguna
   celda vacía: una sola fila en escritorio y filas siempre completas por debajo. */
.admin-inst-resumen {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px;
    background: var(--border); border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.air-item { background: var(--surface); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.air-item span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; }
.air-item strong { font-size: 13px; overflow-wrap: anywhere; }
/* Tableta y panel estrecho: 3 + 3 (ninguna celda vacía). */
@media (max-width: 899px) {
    .admin-inst-resumen { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Móvil: 2 + 2 + 2 (ninguna celda vacía). */
@media (max-width: 640px) {
    .admin-inst-resumen { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .air-item { padding: 9px 11px; }
}

/* --- Modal «Ver solicitud / pago» --- */
.modal-content.modal-ver-solicitud { width: min(720px, 94vw); max-width: 94vw; max-height: 88vh; }
.vs-grupo { margin-bottom: 14px; }
.vs-grupo h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 0 0 6px; }
.vs-fila { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.vs-fila span { color: var(--text-secondary); }
.vs-fila strong { text-align: right; overflow-wrap: anywhere; }
#modalVerSolicitud .admin-bloque { margin-top: 4px; }

/* --- Modal de instituciones de un distribuidor --- */
.modal-content.modal-dist-inst { width: min(760px, 94vw); }

/* --- Indicadores de uso --- */
.limite-alcanzado { color: var(--danger) !important; font-weight: 700; }
.uso-meter-text.limite-alcanzado { color: var(--danger); }

/* --- Tablas compactas sin desbordamiento horizontal --- */
.tabla-solicitudes { table-layout: auto; }
.tabla-solicitudes th, .tabla-solicitudes td { padding: 7px 8px; font-size: 12.5px; white-space: nowrap; }
.tabla-solicitudes .row-actions { text-align: right; }

@media (max-width: 768px) {
    .admin-inst-menu { right: 0; min-width: 220px; }
    .modal-content.modal-ver-solicitud { width: 96vw !important; max-width: 96vw; }
    .vs-fila { flex-direction: column; gap: 2px; }
    .vs-fila strong { text-align: left; }
}

/* v11.3 · Consulta pública por nombres: códigos de acceso (config institución) */
.cp-config-gestion { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border, #e2e8f0); }
.cp-config-gestion-head { margin-bottom: 8px; }
.cp-config-gestion-head strong { display: block; font-size: 13.5px; }
.cp-config-gestion-head small { display: block; font-size: 12px; color: var(--texto-2, #64748b); line-height: 1.45; margin-top: 2px; }
.cp-config-gestion-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cp-config-gestion-row input { flex: 1 1 200px; min-width: 160px; padding: 9px 12px; border: 1.5px solid var(--border, #dbe3ef); border-radius: 10px; font: 500 13.5px 'Inter', sans-serif; }
.cp-config-gestion-row select { flex: 1 1 240px; min-width: 180px; padding: 9px 12px; border: 1.5px solid var(--border, #dbe3ef); border-radius: 10px; font: 500 13.5px 'Inter', sans-serif; background: #fff; }
.cp-codigo-resultado { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: #ecfdf5; border: 1px solid #a7f3d0; }
.cp-codigo-resultado .cp-codigo { font: 800 26px 'Inter', monospace; letter-spacing: 6px; color: #065f46; margin: 4px 0; }
.cp-codigo-resultado small { color: #047857; font-size: 12px; }
.cp-solicitudes-lista { display: flex; flex-direction: column; gap: 6px; }
.cp-solicitud-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border, #e2e8f0); border-radius: 10px; background: #fff; }
.cp-solicitud-item .cp-sol-info { min-width: 0; }
.cp-solicitud-item .cp-sol-info strong { display: block; font-size: 13.5px; }
.cp-solicitud-item .cp-sol-info small { color: var(--texto-2, #64748b); font-size: 12px; }
.cp-solicitud-vacia { font-size: 12.5px; color: var(--texto-2, #64748b); padding: 6px 0; }
@media (max-width: 640px) { .cp-config-gestion-row { flex-direction: column; align-items: stretch; } .cp-config-gestion-row input, .cp-config-gestion-row select { flex: 1 1 auto; } }

/* ============================================================================
   v12 · SISTEMA DE DISEÑO — CAPA DE COMPONENTES
   ----------------------------------------------------------------------------
   Rediseño visual integral de TESORERO PRO. Todos los colores provienen de los
   tokens semánticos de :root / [data-theme="dark"], así que el cambio de tema
   alcanza SIEMPRE al menú lateral, la cabecera, las tarjetas, las tablas, los
   formularios y los modales. Solo presentación: no altera lógica, cálculos,
   rutas, permisos ni contratos de datos.
   ============================================================================ */

/* Tokens de texto sobre fondos de estado (contraste correcto en ambos temas)
   y alias de compatibilidad con los nombres heredados del proyecto
   (--primary, --texto, --texto-2) para que ninguna regla antigua quede con un
   color fijo que contradiga el tema activo. */
:root {
    --success-text: #047857;
    --warning-text: #92400e;
    --danger-text:  #b91c1c;
    --info-text:    #0369a1;
    --primary: #2563eb;
    --texto: #0f172a;
    --texto-2: #5b6b82;
    --accent-text: #1d4ed8;
}
[data-theme="dark"] {
    --success-text: #6ee7b7;
    --warning-text: #fcd34d;
    --danger-text:  #fca5a5;
    --info-text:    #7dd3fc;
    --primary: #3b82f6;
    --texto: #f1f5f9;
    --texto-2: #9aa8bd;
    --accent-text: #93c5fd;
}

/* ── 1 · Base tipográfica y de superficie ─────────────────────────────── */
body {
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    background: var(--app-background);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
#appContainer { background: var(--app-background); }

/* Foco visible homogéneo (navegación por teclado) */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Transición discreta al conmutar de tema; respeta «movimiento reducido» */
@media (prefers-reduced-motion: no-preference) {
    body, #appContainer, .main-wrapper, .page-head, .tab-content,
    .card, .stat-card, .login-card, .registro-card, .modal-content,
    table, thead th, tbody tr, input, select, textarea {
        transition: background-color .22s ease, border-color .22s ease, color .22s ease;
    }
    .sidebar {
        transition: width var(--transition), background-color .22s ease,
                    border-color .22s ease, color .22s ease;
    }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ── 2 · PATRÓN DE PUNTOS CON DESVANECIMIENTO PROGRESIVO ──────────────────
   Clase reutilizable. CSS puro (radial-gradient + mask-image): sin imágenes,
   sin peticiones extra y con coste nulo en móvil. El patrón se pinta en un
   pseudoelemento DETRÁS del contenido y nunca intercepta el puntero. */
.page-header-pattern {
    position: relative;
    isolation: isolate;
}
/* La pantalla de acceso YA es un lienzo fijo a pantalla completa: la utilidad
   no debe degradarla a «relative» (encogería el fondo al tamaño de la tarjeta). */
.login-screen.page-header-pattern { position: fixed; }
.page-header-pattern::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: radial-gradient(circle, var(--pattern-dot) var(--pattern-size), transparent var(--pattern-size));
    background-size: var(--pattern-gap) var(--pattern-gap);
    background-position: 7px 5px;
    background-repeat: repeat;
    -webkit-mask-image: linear-gradient(to bottom,
        rgba(0, 0, 0, 1) 0%,
        rgba(0, 0, 0, .50) var(--pattern-fade-mid, 45%),
        rgba(0, 0, 0, 0) var(--pattern-fade-end, 100%));
    mask-image: linear-gradient(to bottom,
        rgba(0, 0, 0, 1) 0%,
        rgba(0, 0, 0, .50) var(--pattern-fade-mid, 45%),
        rgba(0, 0, 0, 0) var(--pattern-fade-end, 100%));
    pointer-events: none;
}
.page-header-pattern > * { position: relative; z-index: 1; }

/* ── 3 · Cabecera de página ────────────────────────────────────────────── */
.page-head {
    align-items: center;
    gap: 12px;
    padding: 18px 24px 16px;
    background: var(--header-background);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}
.page-head h2,
.page-head #tituloSeccion {
    font-size: var(--fs-page-title);
    font-weight: var(--fw-semibold);
    letter-spacing: -.015em;
    color: var(--text-primary);
    line-height: 1.25;
}
.topbar-contexto {
    font-size: var(--fs-small);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
}
body[data-contexto="institucion"] .page-head { gap: 10px; }
body[data-contexto="institucion"] .topbar-contexto { color: var(--text-secondary); font-weight: 600; }

.tab-content { padding: 20px 24px 28px; }
.tab-content.active { gap: 18px; }

/* ── 4 · MENÚ LATERAL (completamente temático: claro ⇄ oscuro) ─────────── */
.sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 62%);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: var(--sidebar-shadow);
}
.sidebar-brand { border-bottom: 1px solid var(--sidebar-border); }
.brand-text { color: var(--sidebar-text-strong); font-weight: var(--fw-bold); letter-spacing: -.01em; }
.brand-subtitle { color: var(--sidebar-text); }
.brand-logo { object-fit: contain; }

.sidebar-drawer-close {
    border: 1px solid var(--sidebar-soft-strong);
    background: var(--sidebar-soft);
    color: var(--sidebar-text);
}
.sidebar-drawer-close:hover { background: var(--sidebar-soft-strong); color: var(--sidebar-text-strong); }

.nav-section-title { color: var(--sidebar-section); letter-spacing: 1.1px; }
.nav-item { color: var(--sidebar-text); border-radius: var(--radius-sm); }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: var(--fw-semibold);
    box-shadow: none;
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    border-radius: 0 3px 3px 0;
    background: var(--sidebar-active);
}
.nav-icon { background: var(--sidebar-icon-bg); border-radius: var(--radius-sm); }
.nav-item:hover .nav-icon { background: var(--sidebar-icon-bg-hover); }
.nav-item.active .nav-icon { background: var(--sidebar-icon-bg-active); }

.sidebar-footer { border-top: 1px solid var(--sidebar-border); color: var(--sidebar-text); }
.sidebar-account .user-badge { border: 1px solid var(--sidebar-soft-strong); background: var(--sidebar-soft); }
.user-name { color: var(--sidebar-text-strong); }
.sidebar-actions .btn {
    color: var(--sidebar-text);
    background: var(--sidebar-soft);
    border: 1px solid var(--sidebar-soft-strong);
}
.sidebar-actions .btn:hover { background: var(--sidebar-soft-strong); color: var(--sidebar-text-strong); }
.sidebar-collapse {
    border: 1px solid var(--sidebar-soft-strong);
    background: var(--sidebar-soft);
    color: var(--sidebar-text);
}
.sidebar-collapse:hover { background: var(--sidebar-soft-strong); color: var(--sidebar-text-strong); }

.nav-section-cuenta { border-top: 1px solid var(--sidebar-border); }
.nav-item-cuenta { color: var(--sidebar-section); }
.nav-item-cuenta:hover, .nav-item-cuenta.active { color: var(--sidebar-text-strong); }
.sidebar.collapsed .nav-item::after {
    background: var(--sidebar-solid);
    color: #fff;
    border: 1px solid var(--sidebar-soft-strong);
    box-shadow: var(--shadow-lg);
}

/* Marca del servicio en el menú (contexto Plataforma SaaS) */
body[data-contexto="plataforma"] .brand-text { color: var(--sidebar-text-strong); }
body[data-contexto="plataforma"] .sidebar-brand .brand-logo {
    background: transparent;
    box-shadow: none;
    object-fit: contain;
}
body[data-contexto="institucion"] .brand-subtitle { color: var(--sidebar-text); }

/* ── 5 · Tarjetas, paneles y superficies ───────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.card-header h3 { font-size: var(--fs-section); font-weight: var(--fw-semibold); letter-spacing: -.01em; }
.card-body { padding: 20px; }

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.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-value, .info-saldo-value, .fin-value, .fin-favor-value,
table, .sub-kpi strong, .sub-plan-priceline strong { font-variant-numeric: tabular-nums; }

.info-item { background: var(--surface-2); border: 1px solid var(--border-light); border-radius: var(--radius-sm); }

/* ── 6 · Tablas y listados financieros ─────────────────────────────────── */
table { font-size: 13px; }
thead th {
    background: var(--table-header);
    color: var(--text-secondary);
    font-size: var(--fs-label);
    font-weight: var(--fw-bold);
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
}
thead th:hover { background: var(--surface-3); }
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 { border-bottom: 1px solid var(--table-border); color: var(--text-primary); }

.btn-action {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}
.btn-action.action-info:hover   { background: var(--success-soft); }
.btn-action.action-edit:hover   { background: var(--warning-soft); }
.btn-action.action-delete:hover { background: var(--danger-soft); }

/* ── 7 · Formularios y controles ───────────────────────────────────────── */
input[type="text"], input[type="email"], input[type="number"], input[type="password"],
input[type="date"], input[type="search"], input[type="tel"], input[type="url"],
select, textarea {
    background: var(--input-background);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
    outline: none;
}
input:disabled, select:disabled, textarea:disabled {
    background: var(--disabled-background);
    color: var(--disabled-text);
    cursor: not-allowed;
}
label { color: var(--text-secondary); font-weight: var(--fw-semibold); }
.input-deuda { background: var(--warning-soft); border-color: var(--warning); }
.input-monto { background: var(--danger-soft); border-color: var(--danger); }
.tipo-tesoreria-select { background: var(--warning-soft); border-color: var(--warning); }
.search-box { background: var(--input-background); border-color: var(--border); }
.filtro-select { background: var(--input-background); color: var(--text-primary); border-color: var(--border); }

/* ── 8 · Botones ───────────────────────────────────────────────────────── */
.btn { border-radius: var(--radius-sm); font-weight: var(--fw-semibold); }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success-solid); color: #fff; }
.btn-warning { background: var(--warning-solid); color: #fff; }
.btn-danger  { background: var(--danger-solid);  color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--hover-background); color: var(--text-primary); }

/* ── 9 · Modales, menús y ventanas emergentes ──────────────────────────── */
.modal-overlay {
    background: rgba(15, 23, 42, .45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border); }
.modal-header h3 { font-weight: var(--fw-semibold); letter-spacing: -.01em; }
.modal-footer { border-top: 1px solid var(--border); }
.modal-close { border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--hover-background); color: var(--text-primary); }
[data-theme="dark"] .modal-overlay { background: rgba(2, 6, 16, .68); }

/* ── 10 · Mensajes de estado ───────────────────────────────────────────── */
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-left-color: var(--warning); }
.alert-success { background: var(--success-soft); color: var(--success-text); border-left-color: var(--success); }
.alert-danger, .alert-error { background: var(--danger-soft); color: var(--danger-text); border-left-color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info-text); border-left-color: var(--info); }

/* ── 11 · Chips de estado de suscripción ───────────────────────────────── */
.estado-chip { border: 1px solid var(--border); }
.est-vigente, .est-gratuita                 { background: var(--success-soft); color: var(--success-text); }
.est-por_vencer, .est-sin_vencimiento       { background: var(--warning-soft); color: var(--warning-text); }
.est-gracia                                 { background: var(--warning-soft); color: var(--warning-text); }
.est-vencida, .est-cancelada, .est-sin_suscripcion { background: var(--danger-soft); color: var(--danger-text); }
.est-suspendida, .est-servicio_suspendido, .est-archivada { background: var(--surface-3); color: var(--text-secondary); }

/* ── 12 · Registro de institución ──────────────────────────────────────── */
.registro-card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.registro-header { background: var(--header-background); color: var(--text-primary); border-bottom: 1px solid var(--border); }
.registro-header p { color: var(--text-secondary); }
.registro-header-icon { background: var(--accent-soft); }
.registro-input-wrap { background: var(--input-background); border-color: var(--border); }
.registro-input-wrap:focus-within { background: var(--input-background); border-color: var(--accent); box-shadow: var(--focus-ring); }
.registro-input-wrap input, .registro-input-wrap select { background: transparent; color: var(--text-primary); }
.registro-btn-back { background: var(--surface-3); color: var(--text-secondary); }
.registro-footer { border-top: 1px solid var(--border); }
.registro-plan-badge { background: var(--warning-soft); color: var(--warning-text); }
.registro-back-link { color: var(--accent); }
.registro-open-link { color: var(--success-text); border-color: var(--success-border); }

/* ── 13 · Pantallas de acceso (login) ──────────────────────────────────── */
.login-screen {
    background: var(--app-background);
    overflow: hidden;
    padding: 24px;
    --pattern-fade-mid: 28%;
    --pattern-fade-end: 70%;
}
.login-screen.login-minimal { background: var(--app-background); }
.login-screen.pantalla-plataforma { background: var(--app-background); }
.login-screen.pantalla-plataforma::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--brand-teal));
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}
.login-header {
    background: transparent;
    color: var(--text-primary);
    padding: 32px 32px 6px;
}
.login-card.plataforma .login-header { background: transparent; }
.login-header h1 { font-size: 22px; font-weight: var(--fw-bold); letter-spacing: -.02em; color: var(--text-primary); }
.login-header p { color: var(--text-secondary); opacity: 1; }
.login-icon { background: var(--surface-2); }
.login-icon-logo { background: var(--surface-2); border: 1px solid var(--border); box-shadow: none; }
.login-card.plataforma .login-btn { background: var(--accent) !important; color: var(--accent-contrast) !important; }
.login-card.plataforma .login-cross a { color: var(--accent); }
.login-error { background: var(--danger-soft); color: var(--danger-text); border: 1px solid var(--danger-border); }
.login-field input { background: var(--input-background); color: var(--text-primary); border-color: var(--border); }
.login-field input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.login-footer { border-top: 1px solid var(--border); color: var(--text-muted); }
.login-minimal-brand { margin-bottom: 22px; }

/* Variantes oficiales del logotipo según el fondo */
.logo-para-tema-oscuro { display: none !important; }
[data-theme="dark"] .logo-para-tema-claro { display: none !important; }
[data-theme="dark"] .logo-para-tema-oscuro { display: block !important; }

/* ── 14 · Desplazamiento ───────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
    border: 3px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* ── 15 · Adaptación a tabletas y teléfonos ────────────────────────────── */
@media (max-width: 1024px) {
    .tab-content { padding: 18px 18px 22px; }
    .card-body { padding: 16px; }
}
@media (max-width: 768px) {
    .page-head { padding: 12px 12px; gap: 8px; }
    body[data-contexto="institucion"] .page-head { padding: 12px 12px; gap: 8px; }
    .page-head h2, .page-head #tituloSeccion { font-size: 16px; }
    .tab-content { padding: 14px 12px 18px; }
    .tab-content.active { gap: 14px; }
    .modal-content, .modal-content.modal-lg { width: 96vw; max-width: 96vw; max-height: 92vh; }
    .modal-body { padding: 16px; }
    .modal-header, .modal-footer { padding: 14px 16px; }
    .sidebar { box-shadow: 12px 0 40px rgba(2, 8, 23, .45); }
    .sidebar.collapsed .sidebar-account .user-badge {
        border-color: var(--sidebar-soft-strong);
        background: var(--sidebar-soft);
    }
    .login-card { border-radius: var(--radius); }
    thead th, tbody td { padding: 8px 10px; }
    table { font-size: 12.5px; }
    :root { --pattern-gap: 15px; --pattern-size: 1px; }
}
@media (max-width: 480px) {
    .page-head { padding: 10px 10px; }
    body[data-contexto="institucion"] .page-head { padding: 10px 10px; gap: 8px; }
    .page-head h2, .page-head #tituloSeccion { font-size: 15px; }
    .tab-content { padding: 12px 10px 16px; }
    .card-header { padding: 12px 14px; }
    .card-body { padding: 14px; }
    .login-screen { padding: 14px; }
}

/* ── 16 · Correcciones puntuales de contraste en ambos temas ───────────── */
/* El contador del menú se pintaba con blanco translúcido (solo válido sobre
   un sidebar oscuro): ahora es sólido y legible en los dos temas. */
.nav-badge { background: var(--accent); color: #fff; }

/* Aviso de suscripción: los colores de estado se toman de los tokens
   semánticos, que ya cambian con el tema. */
.aviso-suscripcion { background: var(--surface-2); color: var(--text-primary); }
.aviso-suscripcion.aviso-warning { background: var(--warning-soft); color: var(--warning-text); border-left-color: var(--warning); }
.aviso-suscripcion.aviso-danger  { background: var(--danger-soft);  color: var(--danger-text);  border-left-color: var(--danger); }
[data-theme="dark"] .aviso-suscripcion.aviso-warning { background: var(--warning-soft); }
[data-theme="dark"] .aviso-suscripcion.aviso-danger  { background: var(--danger-soft); }

/* Validación del código de distribuidor en el registro */
.registro-hint.codigo-ok       { color: var(--success-text); }
.registro-hint.codigo-aviso    { color: var(--warning-text); }
.registro-hint.codigo-error    { color: var(--danger-text); }

/* Enlaces y cifras de apoyo */
.registro-input-icon { color: var(--text-secondary); }

/* ── 17 · Superficies y chips con color claro: variantes temáticas ───────
   Cierre de la auditoría de contraste: todo selector que declaraba un fondo
   claro literal pasa a consumir los tokens semánticos, de modo que ningún
   componente conserva colores del tema anterior. */
.registro-section-title { color: var(--text-primary); border-bottom-color: var(--border); }
.registro-alert-error   { background: var(--danger-soft);  color: var(--danger-text);  border-color: var(--danger-border); }
.registro-alert-success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.registro-footer { background: var(--surface-2); border-top-color: var(--border); }

.topbar-contexto.ctx-plataforma-text {
    color: var(--accent-text);
    background: var(--accent-soft);
    border-color: var(--accent-soft-strong);
}
.topbar-contexto.ctx-institucion-text {
    color: var(--success-text);
    background: var(--success-soft);
    border-color: var(--success-border);
}
.badge-plataforma { background: var(--accent-soft);  color: var(--accent-text);  border: 1px solid var(--accent-soft-strong); }
.badge-institucion { background: var(--success-soft); color: var(--success-text); border: 1px solid var(--success-border); }

.rol-admin  { background: var(--warning-soft); color: var(--warning-text); }
.rol-user   { background: var(--accent-soft);  color: var(--accent-text); }
.user-rol-badge.rol-dist { background: var(--warning-soft); color: var(--warning-text); }

.action-item.action-danger:hover { background: var(--danger-soft); border-color: var(--danger-border); }
.feature-ok { background: var(--success-soft); color: var(--success-text); }
.feature-no { background: var(--danger-soft);  color: var(--danger-text); }
.bg-green  { background: var(--success-soft); }
.bg-blue   { background: var(--accent-soft); }
.bg-red    { background: var(--danger-soft); }
.bg-yellow { background: var(--warning-soft); }

.cp-codigo-resultado { background: var(--success-soft); border-color: var(--success-border); }
.cp-codigo-resultado .cp-codigo { color: var(--success-text); }
.cp-codigo-resultado small { color: var(--success-text); }
.cp-solicitud-item { background: var(--surface); border-color: var(--border); }
.cp-config-gestion-row input, .cp-config-gestion-row select { background: var(--input-background); color: var(--text-primary); border-color: var(--border); }

/* ============================================================
   v13 · DESCUENTOS POR PLAN Y DURACIÓN
   ============================================================ */

/* --- Catálogo del cliente: precio original, ahorro y distintivos --- */
.cat-plan-antes {
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
    margin-right: 2px;
}
.cat-plan-ahorro {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--success-soft);
    border: 1px solid var(--success-border);
    color: var(--success);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .02em;
    white-space: nowrap;
}
.cat-dur s { color: var(--text-muted); font-weight: 500; margin-right: 3px; }
.cat-dur-badge {
    font-style: normal;
    font-size: 10px;
    font-weight: 800;
    color: var(--success);
    background: var(--success-soft);
    border-radius: 999px;
    padding: 0 6px;
    margin-top: 1px;
}
.cat-dur.active .cat-dur-badge { background: var(--success); color: #fff; }
.monto-antes { color: var(--text-muted); font-weight: 500; margin-right: 3px; }
.monto-desc {
    font-style: normal; font-size: 10.5px; font-weight: 800;
    color: var(--success); background: var(--success-soft);
    border-radius: 999px; padding: 1px 6px; margin-left: 3px;
}

/* --- Editor de duraciones: base, final y descuento --- */
.plan-dur-head, .plan-dur-row {
    grid-template-columns: 104px 74px minmax(90px, 1fr) 98px 98px 58px 30px;
}
.plan-dur-desc {
    font-size: 11.5px;
    font-weight: 800;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
}
.plan-dur-desc.con-desc { color: var(--success); }
.plan-dur-row input:disabled { opacity: .9; }

/* --- Editor de reglas de descuento --- */
.plan-desc-editor { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.plan-desc-head, .plan-desc-row {
    display: grid;
    grid-template-columns: 110px 100px 90px 110px 64px 30px;
    gap: 6px;
    align-items: center;
}
.plan-desc-head span {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .03em;
}
.plan-desc-row input, .plan-desc-row select { width: 100%; padding: 6px 8px; font-size: 12.5px; }
.plan-desc-row input[type="checkbox"] { width: 18px; height: 18px; justify-self: center; }
.plan-desc-preview {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.desc-preview-item {
    font-size: 11.5px;
    background: var(--border-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 8px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.desc-preview-off { font-size: 11.5px; color: var(--text-muted); }

@media (max-width: 900px) {
    .plan-dur-head, .plan-desc-head { display: none; }
    .plan-dur-row, .plan-desc-row {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 8px;
        border: 1px solid var(--border);
        border-radius: 10px;
    }
    .plan-dur-row .plan-dur-etiq { grid-column: 1 / -1; }
    .plan-desc-row .plan-desc-pct { grid-column: 1 / 2; }
    .desc-preview-item { width: 100%; }
}
@media (max-width: 620px) {
    .plan-dur-row, .plan-desc-row { grid-template-columns: 1fr 1fr; }
    .cat-plan-ahorro { font-size: 10px; }
}

/* ============================================================
   v14 · MI SUSCRIPCIÓN REDISEÑADA — AJUSTES FINALES
   ============================================================ */
.cat-plan-mes {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.ren-resumen .descuento-row { gap: 14px; align-items: baseline; }
.ren-resumen .descuento-row span:last-child { text-align: right; overflow-wrap: anywhere; }
.ren-resumen .descuento-row span:first-child { flex: 0 0 auto; }
.cat-plan-antes {
    font-size: 12px;
    margin-right: 0;
    text-decoration-thickness: 1px;
}
.cat-plan-ahorro {
    margin-left: 0;
    display: inline-flex;
    align-items: center;
    color: var(--success-text);
}
.cat-dur.active .cat-dur-badge {
    background: var(--accent-contrast);
    color: var(--accent);
}
.sub-catalogo.is-destacado {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft-strong), var(--shadow-md);
}
.sub-catalogo.is-destacado .card-header h3 { color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
    .sub-catalogo { transition: box-shadow .3s ease, border-color .3s ease; }
}

/* ============================================================
   v12.2 · ALMACENAMIENTO EN LA NUBE (Cloudflare R2) · solo Plataforma
   Todo consume los tokens del tema (claro/oscuro): no se introduce
   ningún color nuevo ni se alteran componentes existentes.
   ============================================================ */
.nube-stack { display: flex; flex-direction: column; gap: 16px; }

/* ── Panel de estado ─────────────────────────────────────────── */
.nube-estado {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.nube-estado-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.nube-estado-item--full { grid-column: 1 / -1; }
.nube-estado-k {
    font-size: var(--fs-label);
    font-weight: var(--fw-bold);
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.nube-estado-v {
    font-size: var(--fs-small);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    overflow-wrap: anywhere;
}
.nube-mono { font-family: var(--font-mono); font-size: 11.5px; }

/* ── Auxiliares ──────────────────────────────────────────────── */
.nube-sub { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.nube-inline-msg { align-self: center; font-size: var(--fs-small); color: var(--text-secondary); }
.nube-inline-ok { color: var(--success); font-weight: var(--fw-semibold); }
.nube-inline-error { color: var(--danger); font-weight: var(--fw-semibold); }

.nube-tipo {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: var(--fw-semibold);
    white-space: nowrap;
    background: var(--accent-soft);
    color: var(--accent);
}
.nube-tipo--diario { background: var(--success-soft); color: var(--success); }
.nube-tipo--manual { background: var(--info-soft); color: var(--info); }
.nube-tipo--pre_restauracion { background: var(--warning-soft); color: var(--warning); }
.nube-tipo--eliminacion,
.nube-tipo--especial { background: var(--danger-soft); color: var(--danger); }

/* ── Generar respaldo manual ─────────────────────────────────── */
.nube-generar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.nube-generar .form-group { flex: 1 1 320px; margin: 0; }

/* ── Tablas de R2: acciones en línea ─────────────────────────── */
#tablaNubeRespaldos td.cell-acciones,
#tablaNubeInstituciones td.cell-acciones { text-align: right; white-space: nowrap; }
#tablaNubeRespaldos td.cell-acciones .btn,
#tablaNubeInstituciones td.cell-acciones .btn { margin-left: 4px; }
#tablaNubeRespaldos td,
#tablaNubeInstituciones td { vertical-align: middle; }

/* ── Asistente de restauración integral ──────────────────────── */
.modal-content.modal-wizard-nube {
    width: min(860px, 94vw);
    max-width: 94vw;
    max-height: 90vh;
}
.nube-pasos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.nube-paso {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg);
    color: var(--text-muted);
    font-size: var(--fs-label);
    font-weight: var(--fw-semibold);
    white-space: nowrap;
}
.nube-paso.done { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.nube-paso.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.nube-panel-intro {
    margin: 0 0 10px;
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}

.nube-detalle {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.nube-detalle-fila {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--fs-small);
}
.nube-detalle-fila:last-child { border-bottom: none; }
.nube-detalle-fila span { color: var(--text-secondary); }

.nube-elegido {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-small);
}
.nube-elegido-ico { font-size: 20px; }

.nube-resumen {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 8px;
}
.nube-resumen-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.nube-resumen-k {
    font-size: var(--fs-label);
    font-weight: var(--fw-bold);
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.nube-resumen-v {
    font-size: var(--fs-small);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.nube-plan-box {
    margin-top: 14px;
    padding: 14px;
    background: var(--warning-soft);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-sm);
}
.nube-plan-box .form-group { margin-bottom: 10px; }


