/* Dashboard de analítica — identidad "Aureo" (oscuro + acento dorado).
   Sin dependencias externas: tipografía del sistema y gráficos SVG a mano,
   así corre igual offline en la Raspberry Pi. */

:root {
  --bg: #0e1116;
  --bg-2: #0b0e12;
  --panel: #161b22;
  --panel-2: #1b222c;
  --line: #26313f;
  --text: #e9eef6;
  --muted: #93a1b3;
  --gold: #e8b64a;
  --gold-2: #f2cd77;
  --gold-soft: rgba(232, 182, 74, 0.14);
  --green: #4ad991;
  --red: #ef7a7a;
  --blue: #62a8ea;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(232, 182, 74, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(98, 168, 234, 0.08), transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.brand .dot {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(145deg, var(--gold-2), var(--gold));
  display: grid; place-items: center;
  color: #2a2110; font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 16px rgba(232, 182, 74, 0.35);
}
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }
.brand small { color: var(--muted); }
.login-card p.sub { color: var(--muted); margin: 4px 0 22px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.08em;
}
.field input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  font-size: 15px; outline: none; transition: border-color 0.15s;
}
.field input:focus { border-color: var(--gold); }
.btn {
  width: 100%; padding: 12px 16px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--gold-2), var(--gold));
  color: #2a2110; font-weight: 700; font-size: 15px; cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.error {
  background: rgba(239, 122, 122, 0.12); border: 1px solid rgba(239, 122, 122, 0.4);
  color: var(--red); padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
}

/* ---------- Layout dashboard ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 22px;
  background: rgba(14, 17, 22, 0.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { margin: 0; }
.topbar .spacer { flex: 1; }
.control {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 8px;
}
.control label { font-size: 12px; color: var(--muted); padding-left: 6px; }
select, .seg button {
  background: transparent; color: var(--text); border: none;
  font-size: 14px; padding: 6px 10px; border-radius: 999px; cursor: pointer;
  font-family: var(--font);
}
select:focus { outline: none; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px; }
.seg button.activo { background: var(--gold-soft); color: var(--gold-2); font-weight: 600; }
.link-logout { color: var(--muted); text-decoration: none; font-size: 13px; padding: 8px 12px; }
.link-logout:hover { color: var(--text); }

main { max-width: 1200px; margin: 0 auto; padding: 24px 22px 60px; }
.seccion-titulo { font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin: 28px 4px 12px; }

/* KPIs */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(5, 1fr); }
.kpi {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  position: relative; overflow: hidden;
}
.kpi .etq { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .valor { font-size: 34px; font-weight: 750; letter-spacing: -0.03em; margin-top: 8px; line-height: 1; }
.kpi .valor small { font-size: 15px; color: var(--muted); font-weight: 500; }
.kpi.vivo { border-color: rgba(232, 182, 74, 0.5); }
.kpi.vivo .valor { color: var(--gold-2); }
.badge-vivo {
  position: absolute; top: 16px; right: 16px; font-size: 11px; color: var(--gold-2);
  display: inline-flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: 0.08em;
}
.badge-vivo::before { content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 0 rgba(232,182,74,0.6); animation: pulso 1.8s infinite; }
@keyframes pulso { 0% { box-shadow: 0 0 0 0 rgba(232,182,74,0.5);} 70% { box-shadow: 0 0 0 8px rgba(232,182,74,0);} 100% { box-shadow: 0 0 0 0 rgba(232,182,74,0);} }

/* Grillas de paneles */
.grid { display: grid; gap: 16px; }
.grid.dos { grid-template-columns: 1.4fr 1fr; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 12px;
}
.card h3 { margin: 0 0 2px; font-size: 15px; letter-spacing: -0.01em; }
.card .hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }

/* Horas pico */
.ranking { list-style: none; margin: 4px 0 8px; padding: 0; }
.ranking li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.ranking li:last-child { border-bottom: none; }
.ranking .pos { width: 24px; height: 24px; border-radius: 7px; background: var(--gold-soft);
  color: var(--gold-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.ranking .hh { font-weight: 600; }
.ranking .barra { flex: 1; height: 8px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.ranking .barra > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.ranking .n { color: var(--muted); font-size: 13px; min-width: 64px; text-align: right; }

/* Tabla de personas */
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }
.persona-nombre { display: inline-flex; align-items: center; gap: 8px; }
.persona-nombre .n-num { width: 26px; height: 26px; border-radius: 8px; background: var(--gold-soft);
  color: var(--gold-2); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.edit { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.edit:hover { color: var(--gold-2); background: var(--gold-soft); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; color: var(--muted); }
.chip b { color: var(--text); font-weight: 600; }
.vacio { color: var(--muted); text-align: center; padding: 30px; }

.nota-privacidad {
  margin-top: 28px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: rgba(98, 168, 234, 0.07); border: 1px solid rgba(98, 168, 234, 0.25);
  color: var(--muted); font-size: 12.5px; line-height: 1.5;
}

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid.dos { grid-template-columns: 1fr; }
  .cam-card { flex-direction: column; }
  .cam-thumb { width: 100%; height: auto; aspect-ratio: 4/3; }
}

/* ---------- Ajustes ---------- */
.form-camara { display: grid; gap: 12px; max-width: 520px; }
.cam-card { display: flex; gap: 16px; align-items: flex-start; }
.cam-thumb { width: 180px; height: 135px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2); flex-shrink: 0; }
.cam-thumb.sin-foto { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.cam-info { flex: 1; min-width: 0; }
.cam-info h3 { margin: 0 0 4px; }
.cam-acciones { display: flex; gap: 14px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.btn-sec { background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer; font-family: var(--font); }
.btn-sec:hover { border-color: var(--gold); color: var(--gold-2); }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--gold); width: 16px; height: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.svg-cal { width: 100%; max-width: 760px; height: auto; display: block; border: 1px solid var(--line);
  border-radius: 12px; cursor: crosshair; background: var(--bg-2); }
#editor-wrap { margin: 8px 0 14px; }
code { background: var(--bg-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
