:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 10px;
}

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

body { background-color: var(--bg-body); color: var(--text-main); line-height: 1.4; min-height: 100vh; padding-bottom: 2rem; }

/* Utilidades */
.hidden { display: none !important; }
.container { max-width: 1400px; margin: 0 auto; padding: 0 1rem; }

/* Login */
#login-view { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #f3f4f6 0%, #e0e7ff 100%); }
.login-card { background: var(--bg-card); padding: 2rem; border-radius: var(--radius); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { color: var(--primary); font-size: 1.8rem; font-weight: 800; margin-bottom: 0.5rem; }
.login-card p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* Logo en el Login */
.login-logo {
    height: 60px; /* Ajusta este tamaño según tu logo */
    width: auto;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Ajuste opcional para el título del login si lo dejaste */
.login-card h1 {
    color: var(--primary);
    font-size: 1.5rem; /* Un poco más pequeño si hay logo arriba */
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Asegurar que los headers de las tarjetas se vean limpios */
.card-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap; /* Evita saltos de línea raros */
}

input { width: 100%; padding: 0.7rem; margin-bottom: 0.8rem; border: 1px solid var(--border); border-radius: 6px; outline: none; font-size: 0.9rem; background: #f9fafb; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.btn-primary { width: 100%; padding: 0.75rem; background: var(--primary); color: white; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 0.95rem; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-text { background: none; border: none; color: var(--primary); cursor: pointer; text-decoration: underline; margin-top: 1.2rem; font-size: 0.85rem; }
.guest-link { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1.2rem; }
.error-msg { color: var(--danger); margin-top: 0.8rem; font-size: 0.85rem; background: #fef2f2; padding: 0.4rem; border-radius: 4px; }

/* Header */
/* === NUEVO ENCABEZADO PROFESIONAL === */
/* === NUEVO ENCABEZADO PROFESIONAL === */

.main-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0;
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Centrado vertical */
    height: 70px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.brand-area {
    display: flex;
    flex-direction: column; /* Elementos uno encima del otro: Logo arriba, texto abajo */
    align-items: flex-start; /* Alinear a la izquierda */
    gap: 4px; /* Poco espacio entre logo y texto */
    text-decoration: none;
    justify-content: center;
}

/* Estilo del Logo */
.brand-logo {
    height: 45px; /* Un poco más grande para que se vea bien solo */
    width: auto;
    object-fit: contain;
    display: block;
}

/* Nuevo estilo para la etiqueta debajo del logo */
.brand-subtitle {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    line-height: 1.2;
    /* Los colores los maneja la clase .badge que ya tiene */
}

/* Badge genérico (mantenemos por si acaso) */
.badge {
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.badge.admin { 
    background: var(--danger); 
}

/* Botón de Logout Moderno */
.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background-color: #fef2f2;
    border-color: var(--danger);
    color: var(--danger);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
}

.btn-logout svg {
    width: 18px;
    height: 18px;
}

/* Responsive para móviles */
@media (max-width: 640px) {
    .header-content {
        padding: 0 1rem;
        height: auto; /* Altura automática para permitir que el texto baje */
        padding-top: 0.8rem;
        padding-bottom: 0.8rem;
        flex-direction: row; /* Mantener fila pero con ajustes */
        align-items: center;
    }
    
    .brand-area {
        align-items: center; /* Centrar logo y texto en móvil */
        text-align: center;
    }

    .brand-logo {
        height: 40px;
    }
    
    .brand-subtitle {
        font-size: 0.6rem;
        margin-top: 2px;
    }

    .btn-logout span {
        display: none;
    }
    
    .btn-logout {
        padding: 0.5rem;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        justify-content: center;
    }
}
.brand-area h1 { font-size: 1.4rem; font-weight: 800; color: var(--text-main); }
.badge { background: var(--primary); color: white; padding: 3px 8px; border-radius: 12px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; }
.badge.admin { background: var(--danger); }
.btn-outline { background: white; border: 1px solid var(--border); padding: 0.4rem 0.8rem; border-radius: 6px; cursor: pointer; color: var(--text-main); font-size: 0.85rem; }

/* Cards */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: 0 2px 4px rgba(0,0,0,0.05); margin-bottom: 1.5rem; overflow: hidden; border: 1px solid var(--border); }
.card-header { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); background: #f9fafb; display: flex; justify-content: space-between; align-items: center; }
.card-header h2 { font-size: 0.9rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 6px; }
.card-body { padding: 1rem; }

/* Formularios Admin */
.inline-form { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; }
.input-group { flex: 1; min-width: 200px; }
.input-group label { display: block; font-size: 0.75rem; font-weight: 600; margin-bottom: 0.3rem; }
.input-group input { margin-bottom: 0; padding: 0.6rem; font-size: 0.85rem; }

/* Grid Layouts */
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.client-view-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }

@media(min-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .client-view-grid { grid-template-columns: 1fr 1fr; }
}

/* === TABLAS CON SCROLL INTELIGENTE === */

.table-wrapper-scroll { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    position: relative;
    border-radius: var(--radius);
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
}

.table-wrapper-scroll::-webkit-scrollbar { height: 6px; } /* Scrollbar más delgada */
.table-wrapper-scroll::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.table-wrapper-scroll::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
.table-wrapper-scroll::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

.table-wrapper-fit {
    overflow-x: hidden;
    border-radius: var(--radius);
}

.modern-table { 
    width: 100%; 
    border-collapse: separate;
    border-spacing: 0;
    min-width: 100%;
}

/* Ancho mínimo reducido para generar scroll antes pero permitir ver más columnas */
#table-copies-parent {
    min-width: 750px; /* Reducido de 900px a 750px */
}

.modern-table th {
    background: #f9fafb;
    text-align: center;
    padding: 0.6rem 0.3rem; /* Padding ligeramente reducido */
    font-size: 0.65rem; /* Fuente reducida (antes 0.7rem) */
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid #f3f4f6;
    white-space: nowrap;
    letter-spacing: 0.5px;
    width: 45px; /* Columnas de meses más angostas */
    min-width: 45px;
}

.modern-table td {
    padding: 0.7rem 0.3rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid #f3f4f6;
    text-align: center;
    vertical-align: middle;
    font-size: 0.75rem; /* Fuente reducida (antes 0.85rem) */
    white-space: nowrap;
    background-color: var(--bg-card);
}

.modern-table tbody tr:last-child td { border-bottom: none; }
.modern-table tbody tr:hover td { background-color: #f9fafb; }

/* === COLUMNA STICKY (NOMBRES) === */
.modern-table td:first-child, 
.modern-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 20;
    text-align: left;
    background-color: var(--bg-card);
    box-shadow: 2px 0 5px -2px rgba(0,0,0,0.15);
    min-width: 140px; /* REDUCIDO de 200px a 140px para ganar espacio */
    max-width: 140px;
    padding-right: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    border-right: 1px solid var(--border);
    font-size: 0.75rem; /* Fuente nombre reducida */
}

.modern-table th:first-child {
    z-index: 30;
    background-color: #f9fafb;
    text-transform: uppercase;
    font-size: 0.65rem;
}

.modern-table tbody tr:hover td:first-child {
    background-color: #f9fafb;
}

/* Toggles Compactos */
.toggle-switch { position: relative; display: inline-block; width: 32px; height: 16px; margin: 0 auto; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .2s; border-radius: 16px; }
.slider:before { position: absolute; content: ""; height: 10px; width: 10px; left: 3px; bottom: 3px; background-color: white; transition: .2s; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(16px); }

/* Vista Cliente: Checks */
.client-view-grid .status-paid { color: var(--success); font-weight: 900; font-size: 1.2rem; display: block; line-height: 1; }
.client-view-grid .status-pending { color: #e5e7eb; font-weight: 900; font-size: 1.2rem; display: block; line-height: 1; }
.client-view-grid td:has(.status-paid) { background-color: var(--success-bg); }

/* === AJUSTES ESPECÍFICOS PARA MÓVILES === */
@media (max-width: 480px) {
    .container { padding: 0 0.5rem; }
    
    /* En móviles muy pequeños, reducimos aún más la columna de nombres */
    .modern-table td:first-child, 
    .modern-table th:first-child {
        min-width: 110px; /* Muy compacto */
        max-width: 135px;
        font-size: 0.7rem;
        padding-right: 0.5rem;
    }

    /* Meses aún más angostos */
    .modern-table th:not(:first-child),
    .modern-table td:not(:first-child) {
        width: 38px;
        min-width: 38px;
        padding: 0.5rem 0.1rem;
    }

    /* Ajuste mínimo de tabla para forzar scroll pero mostrar ~3 meses */
    #table-copies-parent {
        min-width: 600px; 
    }
    
    .card-header h2 { font-size: 0.85rem; }
}