:root {
    --font-size-base: 13px; 
    --bg-body: #0b0e11; --bg-sidebar: #15191e; --bg-card: #1c2127;
    --bg-input: #2b3139; --accent: #3b82f6; --text-main: #ffffff;
    --text-gray: #94a3b8; --danger: #ff3d00; --success: #00c853;
    --warning: #ffa000; --border: #2d343c;
    --sidebar-width: 250px;
    --dot-empty: #ffffff;
}
body.light-mode {
    --bg-body: #f0f2f5; --bg-sidebar: #ffffff; --bg-card: #ffffff;
    --bg-input: #e4e6eb; --accent: #2563eb; --text-main: #1c1e21;
    --text-gray: #65676b; --border: #ced0d4;
    --dot-empty: #000000;
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg-body); color: var(--text-main); margin: 0; display: flex; height: 100vh; overflow: hidden; transition: 0.3s; font-size: var(--font-size-base); }

#login-screen { position: fixed; inset: 0; background: var(--bg-body); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--bg-card); padding: 40px; border-radius: 20px; border: 1px solid var(--border); width: 320px; text-align: center; }

.sidebar { width: var(--sidebar-width); background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: 0.3s ease; position: absolute; height: 100%; z-index: 2000; transform: translateX(-100%); }
.sidebar.active { transform: translateX(0); position: relative; }
.logo { padding: 30px 25px; font-size: 1.5rem; font-weight: 900; color: var(--accent); text-transform: uppercase; }
.nav-item { padding: 15px 25px; color: var(--text-gray); cursor: pointer; display: flex; align-items: center; gap: 12px; }
.nav-item.active { background: rgba(59, 130, 246, 0.1); color: var(--accent); border-left: 4px solid var(--accent); }

.main { flex: 1; padding: 15px; overflow-y: auto; width: 100%; box-sizing: border-box; padding-bottom: 140px; }

.copyable { cursor: pointer; position: relative; transition: color 0.2s; }
.copyable:active { color: var(--accent); }
.copy-toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--success); color: black; padding: 8px 16px; border-radius: 20px; font-weight: bold; z-index: 10001; display: none; }

/* ESTILOS DEL PANEL DE PERÍODOS Y KPIS */
.btn-periodo { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-gray); cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: all 0.2s ease; }
.btn-periodo:hover { color: var(--text-main); border-color: var(--accent); }
.btn-periodo.active { background: var(--accent); color: #ffffff; border-color: var(--accent); box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4); }

.stat-card-kpi { padding: 14px; background: var(--bg-card); border-radius: 12px; border: 1px solid var(--border); flex: 1; min-width: 140px; box-shadow: 0 2px 6px rgba(0,0,0,0.15); transition: transform 0.15s; }
.stat-card-kpi:hover { transform: translateY(-2px); }

.badge-ingreso { background: rgba(0, 200, 83, 0.15); color: var(--success); border: 1px solid var(--success); }
.badge-gasto { background: rgba(255, 61, 0, 0.15); color: var(--danger); border: 1px solid var(--danger); }
.badge-costo { background: rgba(255, 160, 0, 0.15); color: var(--warning); border: 1px solid var(--warning); }
.badge-revendedor { background: rgba(59, 130, 246, 0.2); color: var(--accent); border: 1px solid var(--accent); font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: bold; }

.filter-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 15px; }
table { width: 100%; border-collapse: collapse; min-width: 600px; font-size: var(--font-size-base); }
th { text-align: left; padding: 10px; color: var(--text-gray); font-size: 0.75rem; text-transform: uppercase; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }

.btn { padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; }
.btn-sm { padding: 4px 8px; font-size: 11px; border: none; border-radius: 6px; cursor: pointer; color: white; margin-right: 4px; }
.btn-wa { background: #25D366; color: white; font-weight: bold; }
.btn-danger { background: var(--danger); color: white; }

.semaforo-box { font-size: 11px; font-weight: bold; padding: 2px 8px; border-radius: 12px; display: inline-block; }
.bg-ok { background: rgba(0, 200, 83, 0.2); color: var(--success); }
.bg-warn { background: rgba(255, 160, 0, 0.2); color: var(--warning); }
.bg-danger { background: rgba(255, 61, 0, 0.2); color: var(--danger); }

.toggle-btn { position: fixed; bottom: 25px; left: 25px; width: 50px; height: 50px; background: var(--accent); color: white; border-radius: 50%; border: none; font-size: 1.5rem; cursor: pointer; z-index: 3000; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }

/* AJUSTE MÓVIL: Scroll completo para que el último perfil nunca se tape */
.modal { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); overflow-y: auto; -webkit-overflow-scrolling: touch; align-items: flex-start; justify-content: center; padding: 15px 10px 60px 10px; box-sizing: border-box; }
.modal-content { background: var(--bg-card); padding: 20px; border-radius: 20px; width: 100%; max-width: 650px; max-height: 88vh; overflow-y: auto; position: relative; border: 1px solid var(--border); margin: 10px auto; box-sizing: border-box; padding-bottom: 35px; }

input, select, textarea { width: 100%; padding: 10px; margin: 8px 0; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-main); border-radius: 8px; box-sizing: border-box; font-size: var(--font-size-base); }
.close-x { position: absolute; right: 20px; top: 15px; font-size: 24px; cursor: pointer; color: var(--text-gray); }

.table-container { background: var(--bg-card); border-radius: 15px; border: 1px solid var(--border); padding: 5px; overflow-x: auto; margin-top: 15px; width: calc(100% - 10px); -webkit-overflow-scrolling: touch; }
.profile-dots { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; gap: 7px; align-items: center; padding: 5px 0; }
.circle-dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(128,128,128,0.4); flex-shrink: 0; cursor: pointer; transition: transform 0.15s; }
.circle-dot:hover { transform: scale(1.18); }
.dot-danger { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.dot-warning { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.dot-safe { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-free { background: var(--dot-empty); }

/* AJUSTE MÓVIL PANTALLAS: Permite 2 filas visibles sin recortar el perfil 5 */
.ojo-grid { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; justify-content: center !important; align-items: flex-start !important; gap: 12px !important; padding: 15px 5px 35px 5px !important; width: 100% !important; box-sizing: border-box !important; }
.ojo-item { display: flex !important; flex-direction: column !important; align-items: center !important; width: 90px !important; min-width: 85px !important; text-align: center !important; margin-bottom: 10px !important; }
.ojo-circle { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--border); margin-bottom: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); font-weight: bold; }
.ojo-circle .pantalla-name { font-size: 0.8rem; font-weight: 900; text-transform: uppercase; line-height: 1.1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.search-results { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; max-height: 180px; overflow-y: auto; position: absolute; width: 90%; z-index: 100; display: none; margin-top: 5px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
.search-item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.search-close-row { text-align: right; padding: 5px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.btn-close-search { background: var(--danger); color: white; border: none; padding: 2px 8px; border-radius: 4px; font-size: 10px; cursor: pointer; font-weight: bold; }

@media (max-width: 768px) {
    .main { padding: 10px !important; margin-left: 0 !important; }
    .filter-section, .stats-bar, #radarCobros, #barraEcuacion { margin-left: 0 !important; }
    div[style*="margin-left: 55px"], div[style*="padding-left:55px"] { margin-left: 0 !important; padding-left: 0 !important; }
    .table-container { width: 100% !important; margin-left: 0 !important; }
}

@media print {
    body * { visibility: hidden; }
    #modalFactura, #modalFactura * { visibility: visible; }
    #modalFactura { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: white !important; color: black !important; }
    .no-print { display: none !important; }
    .factura-box { border: none !important; box-shadow: none !important; background: white !important; color: black !important; width: 100% !important; max-width: 100% !important; }
}

.factura-box { background: #ffffff; color: #111827; padding: 25px; border-radius: 12px; max-width: 500px; margin: auto; font-family: 'Helvetica Neue', Arial, sans-serif; }
.factura-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #e5e7eb; padding-bottom: 15px; margin-bottom: 15px; }
.factura-title { font-size: 20px; font-weight: 900; color: #2563eb; }
.factura-stamp { display: inline-block; padding: 4px 10px; border: 2px solid #16a34a; color: #16a34a; font-weight: 900; border-radius: 6px; text-transform: uppercase; font-size: 11px; transform: rotate(-5deg); margin-top: 5px; }

.hidden { display: none; }
@media (min-width: 900px) { .sidebar { transform: translateX(0); position: relative; } }