:root {
    --mac-bg: #f5f5f7; --mac-surface: #ffffff; --mac-text-main: #1d1d1f;
    --mac-text-secondary: #86868b; --mac-border: #d2d2d7; --mac-blue: #007aff;
    --mac-blue-hover: #006ae6; --mac-red: #ff3b30; --mac-green: #34c759;
    --mac-orange: #ff9500; --mac-gray: #e5e5ea; --mac-table-hover: #f9f9f9;
    --mac-dropdown-bg: rgba(255, 255, 255, 0.95);
}
body.dark-mode {
    --mac-bg: #000000; --mac-surface: #1c1c1e; --mac-text-main: #f5f5f7;
    --mac-text-secondary: #ebebf599; --mac-border: #38383a; --mac-blue: #0a84ff;
    --mac-blue-hover: #0070e0; --mac-red: #ff453a; --mac-green: #30d158;
    --mac-orange: #ff9f0a; --mac-gray: #2c2c2e; --mac-table-hover: #2c2c2e;
    --mac-dropdown-bg: rgba(28, 28, 30, 0.95);
}
body { font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif; background-color: var(--mac-bg); color: var(--mac-text-main); margin: 0; padding: 20px 10px; transition: background-color 0.3s, color 0.3s; }
.container { max-width: 1200px; margin: auto; background: var(--mac-surface); padding: 25px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); border: 1px solid var(--mac-border); }
.login-container { max-width: 400px; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 15px; margin-top: 20px; }
.auth-link { color: var(--mac-blue); cursor: pointer; font-size: 14px; margin-top: 10px; }
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.mac-controls { display: flex; gap: 8px; }
.mac-dot { width: 12px; height: 12px; border-radius: 50%; cursor: pointer; transition: transform 0.2s;}
.mac-dot.close { background-color: #ff5f56; } .mac-dot.minimize { background-color: #ffbd2e; } .mac-dot.maximize { background-color: #27c93f; }
.theme-toggle, .btn-logout { background: var(--mac-gray); border: none; padding: 6px 12px; border-radius: 15px; cursor: pointer; color: var(--mac-text-main); }
h1 { text-align: center; font-size: 24px; margin-bottom: 5px; }
h3 { text-align: center; color: var(--mac-text-secondary); font-size: 14px; margin-top: 0; margin-bottom: 20px; }
.stats-panel { display: none; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 25px; }
.stat-card { background: var(--mac-gray); padding: 15px; border-radius: 10px; text-align: center; border: 1px solid var(--mac-border); }
.stat-card h4 { margin: 0 0 5px 0; font-size: 12px; color: var(--mac-text-secondary); }
.stat-card p { margin: 0; font-size: 24px; font-weight: bold; color: var(--mac-text-main); }
.stat-active p { color: var(--mac-green); } .stat-warning p { color: var(--mac-orange); } .stat-expired p { color: var(--mac-red); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 25px; }
input, select, .select-box { padding: 10px 12px; border: 1px solid var(--mac-border); border-radius: 8px; font-size: 14px; width: 100%; box-sizing: border-box; background-color: transparent; color: var(--mac-text-main); }
.custom-select { position: relative; width: 100%; }
.select-box { cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--mac-text-secondary); }
.checkbox-dropdown { display: none; position: absolute; top: 100%; left: 0; width: 100%; background: var(--mac-dropdown-bg); backdrop-filter: blur(10px); border: 1px solid var(--mac-border); border-radius: 8px; max-height: 200px; overflow-y: auto; z-index: 100; padding: 5px; box-sizing: border-box;}
.checkbox-dropdown.show { display: block; }
/* --- CORRECCIÓN DEFINITIVA DE ALINEACIÓN (CUADRÍCULA ESTRICTA) --- */
.checkbox-dropdown label { 
    display: grid !important; 
    grid-template-columns: 20px 1fr !important; /* Columna 1 fija para el check, Columna 2 para el texto */
    align-items: center !important; 
    gap: 12px !important; 
    padding: 10px 15px !important; 
    cursor: pointer; 
    font-size: 14px; 
    text-align: left !important; /* Prohíbe terminantemente el centrado */
    white-space: nowrap !important; /* Evita que el texto se parta en dos líneas */
}
.checkbox-dropdown label input[type="checkbox"] {
    margin: 0 !important; 
    width: 16px !important;
    height: 16px !important;
    justify-self: center !important; /* Centra el cuadrito perfectamente en su columna de 20px */
}
button { padding: 10px; border: none; border-radius: 8px; font-size: 14px; font-weight: bold; cursor: pointer; width: 100%; }
.btn-primary { background-color: var(--mac-blue); color: white; } .btn-secondary { background-color: var(--mac-gray); color: var(--mac-text-main); }
.toolbar { display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; background: var(--mac-gray); padding: 10px; border-radius: 8px; }
.search-bar { flex-grow: 1; } .filter-select { width: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px; border-bottom: 1px solid var(--mac-gray); text-align: left; }
th { color: var(--mac-text-secondary); border-bottom: 2px solid var(--mac-border); }
.client-profile { display: flex; align-items: center; gap: 8px; }
.avatar { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.platform-container { display: flex; flex-wrap: wrap; gap: 5px; } .platform-logo { height: 18px; border-radius: 2px;} .platform-fallback { background: var(--mac-gray); padding: 2px 4px; border-radius: 4px; font-size: 11px; }
.actions-cell { display: flex; gap: 5px; flex-wrap: wrap; }
.action-btn { padding: 6px 8px; border-radius: 6px; font-size: 12px; background: var(--mac-gray); width: auto;}
.btn-wa { background: rgba(52,199,89,0.15); color: var(--mac-green); } .btn-renew { background: rgba(0,122,255,0.15); color: var(--mac-blue); } .btn-del { background: rgba(255,59,48,0.15); color: var(--mac-red); }
.status { padding: 4px 8px; border-radius: 12px; font-size: 11px; font-weight: bold; }
.active { background: rgba(52,199,89,0.15); color: var(--mac-green); } .warning { background: rgba(255,149,0,0.15); color: var(--mac-orange); } .expired { background: rgba(255,59,48,0.15); color: var(--mac-red); }
#toast { position: fixed; bottom: 20px; right: 20px; background: var(--mac-text-main); color: var(--mac-bg); padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 1000; opacity: 0; transform: translateY(20px); transition: 0.3s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateY(0); }

/* --- MAGIA RESPONSIVA: TABLAS A TARJETAS EN CELULARES --- */
@media (max-width: 768px) {
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { display: none; /* Ocultamos las cabeceras */ }
    tr { border: 1px solid var(--mac-border); border-radius: 10px; margin-bottom: 15px; padding: 15px; background: var(--mac-surface); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
    td { display: flex; justify-content: space-between; align-items: center; border: none; padding: 8px 0; border-bottom: 1px solid var(--mac-gray); }
    td:last-child { border-bottom: none; justify-content: center; gap: 10px; margin-top: 10px; padding-top: 15px; }
    td::before { content: attr(data-label); font-weight: 600; color: var(--mac-text-secondary); font-size: 12px; text-transform: uppercase; }
    .client-profile { justify-content: flex-end; width: 60%; text-align: right; }
    .actions-cell .action-btn { flex-grow: 1; padding: 10px; font-size: 14px; } /* Botones gordos para tocar */
}

/* --- ESTILOS PARA LAS TARJETAS FLOTANTES (MODALES) --- */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh; 
    background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); 
    z-index: 10000; display: flex; align-items: center; justify-content: center; 
}
.modal-card { 
    background: var(--mac-surface); padding: 25px; border-radius: 12px; 
    width: 90%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,0.3); 
    border: 1px solid var(--mac-border); display: flex; flex-direction: column; 
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* --- CORRECCIÓN FORZADA PARA EL MENÚ DESPLEGABLE --- */

/* 1. MODO CLARO (Por defecto): Fondo blanco, letras negras */
select {
    background-color: #ffffff !important;
    color: #000000 !important;
}
select option {
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* 2. MODO OSCURO: Fondo oscuro, letras blancas */
body.dark-mode select {
    background-color: #1c1c1e !important;
    color: #ffffff !important;
}
body.dark-mode select option {
    background-color: #1c1c1e !important;
    color: #ffffff !important;
}

/* --- ESTILOS DEL OJITO PARA CONTRASEÑAS --- */
.pwd-wrapper { position: relative; display: block; width: 100%; }
.pwd-wrapper input { width: 100%; padding-right: 40px; }
.pwd-toggle { 
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%); 
    background: none; border: none; cursor: pointer; color: var(--mac-text-main); 
    width: auto; padding: 0; font-size: 16px;
}

/* --- ANIMACIÓN DE CARGA DE TABLA --- */
#tableLoader { 
    text-align: center; padding: 40px 20px; font-size: 14px; 
    color: var(--mac-text-secondary); font-weight: bold; 
}

/* --- DESGLOSE FINANCIERO (TOOLTIP) --- */
.profit-card { position: relative; cursor: help; }
.profit-breakdown { 
    display: none; position: absolute; top: calc(100% + 5px); left: 50%; 
    transform: translateX(-50%); background: var(--mac-dropdown-bg); 
    border: 1px solid var(--mac-border); padding: 12px; border-radius: 8px; 
    z-index: 100; font-size: 13px; text-align: left; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); backdrop-filter: blur(10px); 
    min-width: 150px;
}
.profit-card:hover .profit-breakdown { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -5px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* --- ESTILOS GOOGLE LOGIN --- */
.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background-color: var(--mac-surface); color: var(--mac-text-main);
    border: 1px solid var(--mac-border); border-radius: 8px; padding: 12px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s; width: 100%;
}
.btn-google:hover { background-color: var(--mac-gray); }
.btn-google img { width: 18px; height: 18px; }
.divider { display: flex; align-items: center; text-align: center; color: var(--mac-text-secondary); font-size: 12px; margin: 10px 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--mac-border); }
.divider span { padding: 0 10px; }

/* --- ESTILOS FORZADOS DEL BOTÓN DE TEMA (UNA SOLA LÍNEA) --- */
button.theme-toggle {
    width: max-content !important;
    min-width: unset !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    display: flex !important;
    flex-direction: row !important; /* Fuerza dirección horizontal */
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important; /* Separación entre emoji y texto */
    margin-left: auto !important;
    background: var(--mac-surface) !important;
    border: 1px solid var(--mac-border) !important;
    color: var(--mac-text-main) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    white-space: nowrap !important; /* Prohíbe que el texto baje a otra línea */
}

button.theme-toggle:hover {
    background: var(--mac-gray) !important;
}
