:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --surface: #fcfcfb;
  --page: #f5f7fa;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --border: #e5e7eb;
  --gridline: #e1e0d9;

  /* Paleta categórica validada (dataviz skill) — orden fijo, no ciclar */
  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */

  /* Paleta de estado (fija, nunca para series) */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}

button, input, select { font-family: inherit; font-size: inherit; }

/* ---- Login ---- */

#pantalla-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 1px 3px rgba(11,11,11,0.08), 0 8px 24px rgba(11,11,11,0.06);
}

.login-card h1 {
  font-size: 19px;
  margin: 0 0 4px;
}

.login-card p.subtitulo {
  color: var(--text-secondary);
  margin: 0 0 24px;
  font-size: 13px;
}

.campo { margin-bottom: 14px; }
.campo label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.campo input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.campo input:focus { border-color: var(--brand); }

.btn-primario {
  width: 100%;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}
.btn-primario:hover { background: var(--brand-dark); }
.btn-primario:disabled { opacity: 0.6; cursor: default; }

.error-texto {
  color: var(--status-critical);
  font-size: 13px;
  margin-top: 10px;
  min-height: 16px;
}

/* ---- Layout general ---- */

#pantalla-app { display: none; min-height: 100vh; }
#pantalla-app.visible { display: flex; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.sidebar .marca {
  font-weight: 800;
  font-size: 16px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.tab-btn {
  text-align: left;
  padding: 11px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 13px;
}
.tab-btn:hover { background: var(--page); }
.tab-btn.activo { background: #eff6ff; color: var(--brand); border-right: 3px solid var(--brand); }

.btn-salir {
  margin: 12px 20px 0;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.contenido { flex: 1; padding: 28px 32px; overflow-y: auto; max-height: 100vh; }

.seccion { display: none; }
.seccion.activa { display: block; }

.seccion-header { margin-bottom: 20px; }
.seccion-header h2 { margin: 0 0 4px; font-size: 20px; }
.seccion-header p { margin: 0; color: var(--text-secondary); font-size: 13px; }

/* ---- Filtros ---- */

.filtros-fila {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.filtro-campo { display: flex; flex-direction: column; gap: 4px; }
.filtro-campo label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.filtro-campo select, .filtro-campo input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 140px;
}

/* ---- Cards / grillas ---- */

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.stat-tile .valor { font-size: 24px; font-weight: 800; }
.stat-tile .label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}
.panel h3 { margin: 0 0 14px; font-size: 14px; }

.chart-wrap { position: relative; height: 280px; }

/* ---- Tablas ---- */

table.tabla-datos { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tabla-datos th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
}
table.tabla-datos td { padding: 9px 10px; border-bottom: 1px solid var(--gridline); }
table.tabla-datos tr:last-child td { border-bottom: none; }
.tabla-scroll { overflow-x: auto; }

.chip-estado {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.chip-good { background: #e6f7e6; color: #0a5a0a; }
.chip-warning { background: #fff4de; color: #92600a; }
.chip-critical { background: #fbe2e2; color: #9c2a2a; }
.chip-neutral { background: var(--page); color: var(--text-secondary); }

.pestanas { display: flex; gap: 8px; margin-bottom: 16px; }
.pestana-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 20px;
  padding: 7px 16px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
}
.pestana-btn.activa { background: var(--brand); border-color: var(--brand); color: #fff; }

.sin-datos { color: var(--text-muted); font-style: italic; padding: 20px 0; text-align: center; }
.cargando { color: var(--text-muted); padding: 20px 0; text-align: center; }

/* ---- Fotos ---- */

.fotos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.foto-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}
.foto-card img { width: 100%; height: 130px; object-fit: cover; display: block; background: var(--page); }
.foto-card .foto-info { padding: 8px 10px; }
.foto-card .foto-tipo { font-size: 11px; font-weight: 700; color: var(--text-primary); }
.foto-card .foto-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.foto-card .foto-pct { font-size: 12px; font-weight: 800; color: var(--brand); margin-top: 4px; }

.lightbox {
  position: fixed; inset: 0; background: rgba(11,11,11,0.85);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.lightbox.visible { display: flex; }
.lightbox img { max-width: 90vw; max-height: 85vh; border-radius: 8px; }
.lightbox-cerrar {
  position: absolute; top: 20px; right: 24px; color: #fff; font-size: 15px;
  background: rgba(255,255,255,0.15); border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer;
}

@media (max-width: 860px) {
  #pantalla-app.visible { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; }
  .sidebar .marca { display: none; }
  .sidebar nav { flex-direction: row; }
  .btn-salir { margin: 0 0 0 auto; }
  .contenido { max-height: none; padding: 18px; }
}
