:root {
    --primary-color: #4f46e5; /* Indigo 600 */
    --primary-hover: #4338ca; /* Indigo 700 */
    --primary-gradient: linear-gradient(to right, #4f46e5, #6366f1);
    --header-bg: #111827;
    --header-text: #9ca3af;
    --content-bg: #f9faff; /* Un azul muy claro y suave */
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border-color: #eef2ff; /* Indigo 100 */
    --card-bg: #ffffff;
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.07);
    --status-solvente: #22c55e; /* Green 500 */
    --status-mora: #f43f5e;    /* Rose 500 */
    --whatsapp-color: #25D366;
    --font-sans: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html {
     scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);    
    background-color: #eef2ff; /* Fondo general de la app */
    margin: 0;
    color: var(--text-dark);
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s;
}

/* Clase para evitar el scroll del body cuando un modal está abierto */
body.modal-open {
    overflow: hidden;
}

/* --- Layout Principal (Header + Content) --- */
.admin-layout { display: flex; flex-direction: column; min-height: 100%; position: relative; }
.header { background-image: linear-gradient(to right, #1f2937, #111827); color: var(--header-text); padding: 0.5rem 1.5rem; display: flex; flex-direction:column; align-items: center; justify-content: center; position: sticky; top: 0; z-index: 1000; flex-shrink: 0; }
.header-top { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.header-logo { font-size: 1.5rem; font-weight: 700; color: #fff; }
.header-nav { display: none; }
.main-content { flex-grow: 1; padding: 1rem; padding-bottom: 80px; }

/* Vistas públicas */
.public-layout.view.active { 
    display: flex; /* Ya no se necesita !important */
    justify-content: center; 
    align-items: center;
    background-color: #f4f7fe;
    background-image: radial-gradient(circle at 100% 0, rgba(79, 70, 229, 0.1) 0%, transparent 35%), radial-gradient(circle at 0 100%, rgba(79, 70, 229, 0.1) 0%, transparent 35%);
}

.public-container {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 480px;
}

/* ========================================
   PORTAL DE CLIENTES - ESTILOS MEJORADOS
   ======================================== */

/* Contenedor principal del portal de clientes */
.client-portal-result {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header del cliente con foto/avatar */
.client-portal-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.client-portal-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.client-portal-header .client-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    border: 3px solid rgba(255,255,255,0.3);
}

.client-portal-header .client-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.client-portal-header .client-id {
    opacity: 0.8;
    font-size: 0.85rem;
}

/* Tabs del portal mejorados */
.portal-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f3f4f6;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

.portal-tab-btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: transparent;
    color: #6b7280;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    box-shadow: none;
}

.portal-tab-btn:hover {
    background: #e5e7eb;
    transform: none;
    box-shadow: none;
}

.portal-tab-btn.active {
    background: white;
    color: #4f46e5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.portal-tab-btn svg {
    width: 20px;
    height: 20px;
}

/* Card de estado de cuenta */
.account-status-card {
    background: white;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
}

.account-status-card.solvente {
    border-left: 4px solid #22c55e;
    background: linear-gradient(90deg, #f0fdf4 0%, white 30%);
}

.account-status-card.mora {
    border-left: 4px solid #ef4444;
    background: linear-gradient(90deg, #fef2f2 0%, white 30%);
}

.account-status-card.favor {
    border-left: 4px solid #3b82f6;
    background: linear-gradient(90deg, #eff6ff 0%, white 30%);
}

.account-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.account-status-badge.solvente {
    background: #dcfce7;
    color: #15803d;
}

.account-status-badge.mora {
    background: #fee2e2;
    color: #dc2626;
}

.account-status-badge.favor {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Lista de pagos estilo cards para móvil */
.payment-cards-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.payment-card-item {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.payment-card-item:active {
    transform: scale(0.98);
    background: #f9fafb;
}

.payment-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.payment-card-icon svg {
    width: 20px;
    height: 20px;
    color: #15803d;
}

.payment-card-info {
    flex: 1;
    min-width: 0;
}

.payment-card-concept {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.payment-card-date {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.125rem;
}

.payment-card-amount {
    font-weight: 700;
    font-size: 1.1rem;
    color: #059669;
    text-align: right;
}

.payment-card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Botón de descarga rápida flotante */
.quick-download-fab {
    position: fixed;
    bottom: 100px;
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    transition: all 0.3s;
    z-index: 100;
    border: none;
}

.quick-download-fab:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.5);
}

.quick-download-fab svg {
    width: 24px;
    height: 24px;
}

/* Menú de descarga rápida */
.quick-download-menu {
    position: fixed;
    bottom: 170px;
    right: 1rem;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    padding: 0.5rem;
    z-index: 101;
    min-width: 220px;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    pointer-events: none;
    transition: all 0.2s ease-out;
}

.quick-download-menu.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.quick-download-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
    color: #374151;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.quick-download-menu-item:hover {
    background: #f3f4f6;
}

.quick-download-menu-item svg {
    width: 20px;
    height: 20px;
    color: #6366f1;
}

.quick-download-menu-header {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #9ca3af;
    letter-spacing: 0.05em;
}

/* Botón de soporte WhatsApp mejorado */
.whatsapp-support-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    padding: 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    width: 100%;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.whatsapp-support-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

.whatsapp-support-btn svg {
    width: 22px;
    height: 22px;
}

/* Alerta de pago pendiente mejorada */
.payment-alert {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border: 1px solid #fecaca;
    border-radius: 1rem;
    padding: 1.25rem;
    margin-top: 1rem;
}

.payment-alert-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fee2e2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.payment-alert-icon svg {
    width: 24px;
    height: 24px;
    color: #dc2626;
}

.payment-alert-title {
    font-weight: 700;
    color: #b91c1c;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.payment-alert-text {
    color: #7f1d1d;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Comunicado card mejorado */
.announcement-card {
    background: white;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    border-left: 4px solid #6366f1;
}

.announcement-card.general {
    border-left-color: #8b5cf6;
}

.announcement-card.personal {
    border-left-color: #ec4899;
}

.announcement-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.announcement-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eef2ff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.announcement-card-icon svg {
    width: 18px;
    height: 18px;
    color: #6366f1;
}

.announcement-card-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95rem;
}

.announcement-card-badge {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
    margin-left: auto;
}

.announcement-card-badge.general {
    background: #ede9fe;
    color: #6d28d9;
}

.announcement-card-badge.personal {
    background: #fce7f3;
    color: #be185d;
}

.announcement-card-message {
    color: #4b5563;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.announcement-card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #9ca3af;
}

/* ========================================
   PORTAL MÓVIL - ESTILOS RESPONSIVOS
   ======================================== */
@media (max-width: 480px) {
    .public-container {
        padding: 1rem;
        border-radius: 0;
        max-width: 100%;
        min-height: 100vh;
        box-shadow: none;
    }
    
    .public-layout.view.active {
        align-items: flex-start;
        padding: 0;
    }
    
    .client-portal-header {
        margin: -1rem -1rem 1rem -1rem;
        border-radius: 0;
        padding: 1.5rem 1rem 1.25rem;
    }
    
    .client-portal-header .client-avatar {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
    
    .client-portal-header .client-name {
        font-size: 1.25rem;
    }
    
    .portal-tabs {
        margin: 0 -0.5rem 1rem;
        border-radius: 0.5rem;
    }
    
    .portal-tab-btn {
        padding: 0.625rem 0.25rem;
        font-size: 0.7rem;
    }
    
    .portal-tab-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .account-status-card {
        padding: 1rem;
    }
    
    .payment-card-item {
        padding: 0.875rem;
    }
    
    .payment-card-icon {
        width: 40px;
        height: 40px;
    }
    
    .payment-card-concept {
        font-size: 0.85rem;
    }
    
    .payment-card-amount {
        font-size: 1rem;
    }
    
    .quick-download-fab {
        width: 52px;
        height: 52px;
        bottom: 90px;
    }
    
    .quick-download-menu {
        bottom: 155px;
        right: 0.75rem;
        left: 0.75rem;
        min-width: auto;
    }
    
    .announcement-card {
        padding: 1rem;
    }
    
    .announcement-card-header {
        flex-wrap: wrap;
    }
    
    .announcement-card-badge {
        margin-left: 0;
        margin-top: 0.5rem;
        flex-basis: 100%;
        text-align: center;
        display: none;
    }
}

/* Animación para el botón de descarga */
@keyframes pulse-download {
    0%, 100% { box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(79, 70, 229, 0.6); }
}

.quick-download-fab.has-invoices {
    animation: pulse-download 2s infinite;
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.4s ease-in-out; flex-grow: 1; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Componentes de UI rediseñados */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; background: linear-gradient(to right, var(--primary-color), var(--primary-hover)); color: white; padding: 1rem 1.5rem; margin: -1rem -1rem 1.5rem -1rem; border-radius: 0.5rem 0.5rem 0 0; box-shadow: var(--shadow-md); }
.widget { background: var(--card-bg); padding: 1.5rem; border-radius: 1rem; border: 1px solid var(--border-color); box-shadow: var(--shadow-md); transition: all 0.3s ease; }
.widget-title { font-size: 1.1rem; font-weight: 600; margin-top: 0; margin-bottom: 1.25rem; display: flex; align-items: center; gap: 0.5rem; color: var(--text-dark); border-bottom: 1px solid var(--border-color); padding-bottom: 0.75rem; }
h2 { font-size: 1.5rem; font-weight: 700; color: white; text-shadow: 1px 1px 2px rgba(0,0,0,0.2); }
input, select, textarea { width:100%; padding: 0.75rem; border-radius: 0.5rem; font-size: 0.9rem; transition: border-color 0.2s, box-shadow 0.2s; background-color: #f9fafb; border: 1px solid #d1d5db; box-sizing: border-box;}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); }

button, .button { background-image: var(--primary-gradient); color: white; border: none; border-radius: 0.5rem; cursor: pointer; font-size: 0.9rem; font-weight: 600; transition: all 0.2s ease-in-out; display: inline-flex; align-items: center; gap: 0.5rem; justify-content: center; padding: 0.75rem 1.25rem; box-shadow: 0 4px 6px rgba(67, 56, 202, 0.2); }
button:hover, .button:hover { transform: translateY(-2px); box-shadow: 0 7px 14px rgba(67, 56, 202, 0.25); }
.button.secondary { background: #6b7280; box-shadow: 0 4px 6px rgba(107, 114, 128, 0.2); } .button.secondary:hover { background: #4b5563; box-shadow: 0 7px 14px rgba(107, 114, 128, 0.25); }
.button.danger { background: #ef4444; box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2); } .button.danger:hover { background: #dc2626; box-shadow: 0 7px 14px rgba(239, 68, 68, 0.25); }
.button-sm { padding: 0.5rem 1rem; font-size: 0.8rem; } 
/* Icon-only buttons: ghost style to avoid big gradient circles */
.button-icon { 
    background: transparent; 
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 0.35rem; 
    width: 28px; height: 28px; 
    box-shadow: none; 
    display: inline-flex; align-items: center; justify-content: center; 
    line-height: 1; 
}
.button-icon:hover { background: #f3f4f6; transform: none; box-shadow: none; }
.button-icon.danger { color: #ef4444; border-color: #fecaca; background-color: #fef2f2; }
.button-icon.danger:hover { background-color: #fee2e2; }

/* Botón WhatsApp */
.button-icon.whatsapp { 
    color: #25D366; 
    border-color: #86efac; 
    background-color: #f0fdf4; 
}
.button-icon.whatsapp:hover { background-color: #dcfce7; }

/* Botón Ver/Info */
.button-icon.info { 
    color: #3b82f6; 
    border-color: #93c5fd; 
    background-color: #eff6ff; 
}
.button-icon.info:hover { background-color: #dbeafe; }

/* Botón Success/Check */
.button-icon.success { 
    color: #22c55e; 
    border-color: #86efac; 
    background-color: #f0fdf4; 
}
.button-icon.success:hover { background-color: #dcfce7; }

/* Botón Warning */
.button-icon.warning { 
    color: #f59e0b; 
    border-color: #fcd34d; 
    background-color: #fffbeb; 
}
.button-icon.warning:hover { background-color: #fef3c7; }

/* Botón Primary */
.button-icon.primary { 
    color: var(--primary-color); 
    border-color: #a5b4fc; 
    background-color: #eef2ff; 
}
.button-icon.primary:hover { background-color: #e0e7ff; }

/* Dark mode adjustments for icon buttons */
html.dark .button-icon { color: var(--text-dark); border-color: #4b5563; }
html.dark .button-icon:hover { background: #374151; }
html.dark .button-icon.whatsapp { color: #4ade80; background-color: #14532d; border-color: #166534; }
html.dark .button-icon.info { color: #60a5fa; background-color: #1e3a5f; border-color: #1e40af; }
html.dark .button-icon.danger { color: #f87171; background-color: #450a0a; border-color: #7f1d1d; }
html.dark .button-icon.success { color: #4ade80; background-color: #14532d; border-color: #166534; }
html.dark .button-icon.warning { color: #fbbf24; background-color: #451a03; border-color: #78350f; }
html.dark .button-icon.primary { color: #818cf8; background-color: #312e81; border-color: #3730a3; }

.status { padding: 0.25rem 0.75rem; border-radius: 9999px; color: #fff; font-weight: 600; font-size: 0.7rem; text-shadow: 1px 1px 1px rgba(0,0,0,0.1);}
.status.solvente { background-color: var(--status-solvente); box-shadow: 0 0 10px rgba(34, 197, 94, 0.5); }
.status.mora { background-color: var(--status-mora); box-shadow: 0 0 10px rgba(244, 63, 94, 0.5); }

.table-container { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 0.75rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border-color); text-align: left; vertical-align: middle; white-space: nowrap; }
th { background-color: #f9fafb; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.05em; border-top: 1px solid var(--border-color); }
tbody tr { transition: background-color 0.2s; }
tbody tr:hover { background-color: #eff6ff; box-shadow: 0 1px 3px rgba(0,0,0,0.05) inset; }
tbody tr:last-child td { border-bottom: none; }

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.dashboard-card { background: var(--card-bg); border-radius: 1rem; padding: 1.5rem; display: flex; align-items: flex-start; justify-content: space-between; box-shadow: var(--shadow-md); transition: all 0.3s ease; border: 1px solid var(--border-color); }
.dashboard-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.dashboard-card .icon { padding: 1rem; border-radius: 0.75rem; display: flex; align-items: center; justify-content: center; }
.dashboard-card .text-content { text-align: right; }
.dashboard-card .value { font-size: 2rem; font-weight: 700; color: var(--text-dark); line-height: 1; }
.dashboard-card .label { font-size: 0.85rem; color: var(--text-light); margin-top: 0.25rem; }

.tabs { display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 1.5rem; overflow-x: auto; }
.tab-link { padding: 0.75rem 1rem; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; font-size: 0.8rem; white-space: nowrap; color: var(--text-light); transition: all 0.2s; }
.tab-link:hover { color: var(--primary-color); }
.tab-link.active { border-bottom-color: var(--primary-color); color: var(--primary-color); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 0.5rem; margin-top: 1.5rem; }
.bottom-nav { display: flex; justify-content: space-around; align-items: center; position: fixed; bottom: 0; left: 0; right: 0; height: 65px; background-color: var(--card-bg); border-top: 1px solid var(--border-color); box-shadow: 0 -2px 10px rgba(0,0,0,0.05); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; flex-grow: 1; color: var(--text-light); text-decoration: none; font-size: 0.7rem; padding: 0.5rem 0; transition: color 0.2s; }
.bottom-nav a.active { color: var(--primary-color); font-weight: 600; }
.bottom-nav a svg { width: 1.25rem; height: 1.25rem; margin-bottom: 2px; }

/* Mobile-first: Bottom nav is default */
.header-top, .header-nav, .mobile-header-content { display: none; }

/* Estilos específicos para desktop */
@media (min-width: 768px) {
    body { font-size: 0.9rem; }
    .header-top { display: flex; }
    .header-nav { display: flex; gap: 0.5rem; width: 100%; justify-content: center; padding: 0.5rem 0; margin-top: 0.5rem; border-top: 1px solid #374151; }
    .header-nav a { padding: 0.75rem; border-radius: 0.5rem; transition: background-color 0.2s, color 0.2s; display: flex; align-items: center; justify-content: center; font-weight: 500; }
    .header-nav a span { display: inline; margin-left: 0.5rem; } /* Mostrar texto en escritorio */
    .header-nav a:hover { background-color: #374151; color: #fff; } 
    .header-nav a.active { background-color: var(--primary-color); color: #fff; }
    .bottom-nav { display: none; }

    .main-content { padding: 1.5rem 2rem; padding-bottom: 2rem; }
    h2 { font-size: 1.75rem; }
    th, td { padding: 0.75rem 1rem; }
    .tabs .tab-link { font-size: 0.875rem; padding: 0.75rem 1.5rem;}
}

/* --- ESTILOS MEJORADOS PARA MÓVIL --- */
@media (max-width: 767px) {
    /* SOLUCIÓN: Forzar la visibilidad del texto en los botones en pantallas pequeñas */
    .button span, button span {
        display: inline !important;
    }

    body { font-size: 15px; }
    
    /* Header móvil más compacto */
    .header {
        flex-direction: row;
        height: 56px;
        padding: 0 1rem;
    }
    .mobile-header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    .mobile-header-content .header-logo {
        display: none;
    }
    .mobile-header-content .header-page-title {
        position: absolute; left: 50%; transform: translateX(-50%);
    }
    .header-page-title { font-weight: 600; color: white; font-size: 1.1rem; }
    
    .admin-layout {
        padding-bottom: 65px;
    }

    /* Main content con menos padding */
    .main-content {
        padding: 0.75rem;
        padding-bottom: 80px;
    }

    /* Page header más compacto y responsive */
    .page-header {
        margin: -0.75rem -0.75rem 1rem -0.75rem;
        padding: 0.875rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        border-radius: 0;
    }
    .page-header h2 {
        font-size: 1.25rem;
        text-align: center;
    }
    .page-header > div,
    .page-header > .flex {
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Dashboard cards en 2 columnas */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .dashboard-card {
        padding: 1rem;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.5rem;
    }
    .dashboard-card .icon {
        padding: 0.75rem;
        margin-bottom: 0.25rem;
    }
    .dashboard-card .icon svg {
        width: 1.25rem;
        height: 1.25rem;
    }
    .dashboard-card .text-content {
        text-align: center;
    }
    .dashboard-card .value {
        font-size: 1.5rem;
    }
    .dashboard-card .label {
        font-size: 0.75rem;
    }

    /* Widgets más compactos */
    .widget {
        padding: 1rem;
        border-radius: 0.75rem;
    }
    .widget-title {
        font-size: 1rem;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }

    /* Tabs scrollables */
    .tabs {
        margin: 0 -0.75rem 1rem -0.75rem;
        padding: 0 0.75rem;
        gap: 0;
        -webkit-overflow-scrolling: touch;
    }
    .tab-link {
        padding: 0.625rem 0.875rem;
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    /* Tablas responsive */
    .table-container {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    table {
        font-size: 0.8rem;
    }
    th, td {
        padding: 0.625rem 0.75rem;
    }
    th {
        font-size: 0.7rem;
    }
    /* Ocultar columnas menos importantes en móvil */
    .hide-mobile {
        display: none !important;
    }

    /* Botones táctiles más grandes */
    .button { 
        padding: 0.875rem 1.25rem;
        min-height: 44px;
    }
    .button-sm { 
        padding: 0.625rem 1rem;
        min-height: 36px;
    }
    .button-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    /* Inputs más grandes para táctil */
    input, select, textarea {
        padding: 0.875rem;
        font-size: 16px; /* Evita zoom en iOS */
        min-height: 44px;
    }

    /* Formularios en una columna */
    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
    .md\\:grid-cols-2,
    .md\\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }

    /* Acciones de fila más táctiles */
    td .flex.gap-1,
    td .flex.gap-2 {
        gap: 0.5rem;
    }

    /* Barra de búsqueda full width */
    .search-bar,
    input[type="search"],
    input[placeholder*="Buscar"] {
        width: 100%;
    }

    /* Cards de cliente más compactas */
    .client-card {
        padding: 0.875rem;
    }

    /* Paginación más compacta */
    .pagination {
        gap: 0.25rem;
        margin-top: 1rem;
    }
    .pagination button {
        padding: 0.5rem 0.75rem;
        min-width: 36px;
    }

    /* Bottom nav mejorado */
    .bottom-nav {
        height: 60px;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .bottom-nav a {
        height: 100%;
        padding: 0.5rem 0;
    }
    .bottom-nav a span {
        display: none;
    }
    .bottom-nav a svg {
        width: 1.5rem;
        height: 1.5rem;
        margin-bottom: 0;
    }

    /* Filtros en columna */
    .filters-row,
    .flex.gap-2.flex-wrap {
        flex-direction: column;
    }
    .filters-row > *,
    .flex.gap-2.flex-wrap > * {
        width: 100%;
    }

    /* Espaciado entre secciones */
    .space-y-4 > * + * {
        margin-top: 0.875rem;
    }
    .space-y-6 > * + * {
        margin-top: 1.25rem;
    }

    /* FAB (Floating Action Button) para acciones principales */
    .fab {
        position: fixed;
        bottom: 80px;
        right: 1rem;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
        z-index: 100;
    }
    .fab svg {
        width: 1.5rem;
        height: 1.5rem;
    }

    /* Estadísticas en row scrollable si son muchas */
    .stats-row {
        display: flex;
        overflow-x: auto;
        gap: 0.75rem;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    .stats-row > * {
        flex-shrink: 0;
        min-width: 140px;
    }

    /* Notificaciones más compactas */
    .notification-item {
        padding: 0.75rem;
    }

    /* Ajuste para listas de clientes */
    .client-list-item {
        padding: 0.875rem;
    }
    .client-list-item .client-info {
        flex: 1;
        min-width: 0;
    }
    .client-list-item .client-name {
        font-size: 0.9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .client-list-item .client-details {
        font-size: 0.75rem;
    }

    /* Toast en móvil - más ancho y en la parte inferior */
    #toast-notification {
        top: auto;
        bottom: 80px;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }
}

/* --- ESTILOS PARA MODAL (VENTANA EMERGENTE) --- */
#modal-container {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 2000;
    background-color: rgba(17, 24, 39, 0.6);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}
#modal-container.active {
    opacity: 1;
    pointer-events: auto;
}
#modal-container > div {
    transform: scale(0.95);
    transition: transform 0.3s ease-in-out;
}
#modal-container.active > div {
    transform: scale(1);
}
/* 3. Estilo de modal "Bottom Sheet" para móvil */
@media (max-width: 767px) {
    #modal-container {
        align-items: flex-end;
        padding: 0;
    }
    #modal-container > div {
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
        border-radius: 1rem 1rem 0 0;
    }
    #modal-container.active > div {
        transform: translateY(0);
    }
    #modal-dialog {
        max-height: 80vh; /* Limitar altura en móvil */
    }
}

#toast-notification {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    color: white;
    font-size: 0.875rem;
    z-index: 9999;
    transform: translateX(calc(100% + 1.25rem));
    transition: transform 0.3s ease-in-out;
}

#toast-notification.active {
    transform: translateX(0);
}

/* --- Superposición de Carga --- */
#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.7); z-index: 9999; display: none; justify-content: center; align-items: center;
}
#loading-overlay.active { display: flex; }
.loader {
    border: 5px solid #f3f3f3; border-top: 5px solid var(--primary-color); border-radius: 50%;
    width: 50px; height: 50px; animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- TEMA OSCURO --- */
html.dark {
    --header-bg: #000000;
    --content-bg: #111827; /* Gray 900 */
    --card-bg: #1f2937;    /* Gray 800 */
    --text-dark: #f9fafb;  /* Gray 50 */
    --text-light: #9ca3af; /* Gray 400 */
    --border-color: #374151; /* Gray 700 */
}
html.dark .page-header { background: linear-gradient(to right, #1f2937, #111827); }
html.dark h2 { color: var(--text-dark); }
html.dark th { background-color: #1f2937; }
html.dark tbody tr:hover { background-color: #1e293b; }
html.dark body {
    background-color: #0d111c;
}
html.dark input, html.dark select, html.dark textarea {
    background-color: #374151;
    border-color: #4b5563;
}