:root {
  --fondo: #e8eef6;
  --panel: #ffffff;
  --texto: #1b2838;
  --linea: #d7e0ea;
  --acento: #0e7c66;
  --acento-oscuro: #0b5e4d;
  --sombra: 0 8px 24px rgba(22, 42, 68, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #dfe8f3 0, var(--fondo) 220px);
  color: var(--texto);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: linear-gradient(110deg, #12324d 0%, #0e7c66 100%);
  color: #fff;
}

.app-header h1 { margin: 0; font-size: 22px; }
.app-header p { margin: 4px 0 0; opacity: 0.85; }

.marca-sia {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #12324d;
  border-radius: 10px;
  padding: 4px 14px 4px 6px;
  flex-shrink: 0;
}

.logo-sia { height: 46px; width: auto; display: block; }
.marca-sia span { font-weight: 700; font-size: 18px; }

main { padding: 16px 24px 32px; max-width: 1280px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--sombra);
}

.login-caja { max-width: 420px; margin: 28px auto; }

h2 { margin: 0 0 12px; font-size: 18px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
input, button { font: inherit; }
input {
  border: 1px solid var(--linea);
  border-radius: 6px;
  padding: 8px;
  min-width: 180px;
  background: #fff;
  color: var(--texto);
}

button {
  background: var(--acento);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover { background: var(--acento-oscuro); }
button.secundario { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.55); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.filtros, .sesion { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.dos { display: flex; flex-wrap: wrap; gap: 12px; }
.dos > .panel { flex: 1 1 360px; margin-bottom: 0; }

.kpi {
  border: 1px solid var(--linea);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 150px;
  background: #fff;
  border-top: 4px solid #1d5f8a;
}

.kpi:nth-child(2) { border-top-color: #0e7c66; }
.kpi:nth-child(3) { border-top-color: #7a4ea3; }
.kpi:nth-child(4) { border-top-color: #c2410c; }
.kpi:nth-child(5) { border-top-color: #b45309; }
.kpi:nth-child(6) { border-top-color: #0f766e; }
.kpi strong { display: block; font-size: 22px; }
.kpi span { color: #526173; font-size: 13px; }

.pista { margin: 0 0 8px; color: #5b6b7c; font-size: 13px; }
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid var(--linea); text-align: left; padding: 8px; }
th { background: #eef3f7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mensaje { color: #8d2f2f; min-height: 1.2em; }

.grafico { max-height: 420px; overflow: auto; }
.encabezado-panel { display: flex; justify-content: space-between; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.encabezado-panel h2 { margin: 0; }
.barra-fila { display: grid; grid-template-columns: 72px 1fr 64px; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.barra-fila.clic { cursor: pointer; border-radius: 8px; padding: 3px 4px; }
.barra-fila.clic:hover, #tabla tr.clic:hover { background: #f3f7fb; }
.barra-fila.activa, #tabla tr.activa { background: #e7f0f8; }
#tabla tr.clic { cursor: pointer; }

.donut-caja { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.donut-marco { position: relative; width: 190px; height: 190px; flex: 0 0 190px; }
.donut-anillo { width: 190px; height: 190px; border-radius: 50%; background: #e7eef3; }
.donut-centro {
  position: absolute;
  inset: 46px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.donut-centro strong { font-size: 22px; }
.donut-centro span { color: #526173; font-size: 12px; }
.leyenda { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 240px; }
.leyenda li { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.leyenda i { width: 14px; height: 14px; border-radius: 4px; display: block; }
.paginas { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
button.secundario-panel { background: #fff; color: #12324d; border: 1px solid #12324d; }
button.secundario-panel:hover { background: #eef3f7; }
.barra-fila.persona { grid-template-columns: minmax(140px, 46%) 1fr 64px; }
.barra-fila.persona span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-pista { background: #e7eef3; border-radius: 999px; height: 12px; overflow: hidden; }
.barra-valor { display: block; height: 100%; background: #0e7c66; min-width: 2px; border-radius: 999px; }
.barra-valor.usuario { background: #1d5f8a; }

.cargando {
  position: fixed;
  inset: 0;
  background: rgba(18, 50, 77, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.cargando[hidden] { display: none; }
.cargando-caja {
  background: #fff;
  border-radius: 12px;
  padding: 18px 22px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--sombra);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #d7e0ea;
  border-top-color: #0e7c66;
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.pie {
  color: #5b6b7c;
  font-size: 12px;
  text-align: right;
  margin-top: 8px;
}
