/* ==================================================================
   Metas Cúcuta: tokens
   Navy de patio logístico + amarillo montacargas como señal.
   Verde/ámbar/rojo se reservan al semáforo de cumplimiento.
=================================================================== */
:root {
  --ink: #13213C;
  --ink-2: #1F3157;
  --ink-3: #3B5280;
  --signal: #FFB020;
  --signal-2: #FFE3A3;
  --bg: #EEF1F6;
  --surface: #FFFFFF;
  --line: #DFE4EC;
  --text: #18233B;
  --muted: #66728A;
  --ok: #129A68;
  --ok-bg: #E3F5EE;
  --warn: #E2851B;
  --warn-bg: #FDF0DF;
  --bad: #D63F48;
  --bad-bg: #FBE6E7;
  --none: #CDD4E0;
  --none-bg: #F1F3F7;

  --radio-s: 8px;
  --radio: 14px;
  --sombra: 0 1px 2px rgb(19 33 60 / 6%), 0 8px 24px -12px rgb(19 33 60 / 18%);
  --t: 180ms cubic-bezier(.2, .7, .2, 1);
  --lateral: 264px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/1.55 Poppins, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; line-height: 1.35; }
h3 { font-size: 14px; font-weight: 600; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex: none; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background var(--t), border-color var(--t), transform var(--t), box-shadow var(--t);
}
.btn:hover { border-color: #C3CBD8; }
.btn:active { transform: translateY(1px); }
.btn-primario { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primario:hover { background: var(--ink-2); border-color: var(--ink-2); box-shadow: 0 6px 16px -8px var(--ink); }
.btn-primario svg { color: var(--signal); }
.btn-peligro-suave { color: var(--bad); }
.btn-peligro-suave:hover { background: var(--bad-bg); border-color: #F2C3C6; }
.btn-bloque { width: 100%; height: 48px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.cargando svg { animation: girar 1s linear infinite; }
.icono-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); transition: background var(--t), color var(--t);
}
.icono-btn:hover:not(:disabled) { background: var(--none-bg); color: var(--text); }
.icono-btn:disabled { opacity: .35; cursor: default; }

/* ---------- Campos ---------- */
.campo { display: grid; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.campo > span, .campo > legend { font-size: 13px; font-weight: 500; color: var(--text); padding: 0; }
.campo small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.campo input, .selector-periodo select {
  height: 44px; width: 100%; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  transition: border-color var(--t), box-shadow var(--t);
}
.campo input:focus, .selector-periodo select:focus {
  outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 4px rgb(59 82 128 / 14%);
}
.input-icono { position: relative; }
.input-icono > svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.input-icono input { padding-left: 44px; height: 50px; font-size: 15px; }
.ver-clave { position: absolute; right: 6px; top: 50%; translate: 0 -50%; }
.ver-clave { display: grid; place-items: center; width: 38px; height: 38px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; }

/* ==================================================================
   Login
=================================================================== */
body.login { background: var(--surface); transition: opacity .35s; }
body.login.saliendo { opacity: 0; }
.login-grid { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.login-mapa {
  position: relative; overflow: hidden; background: var(--ink); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px;
}
.login-mapa .marca, .lateral .marca { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 17px; position: relative; z-index: 1; }
.rutas { position: absolute; inset: 0; width: 100%; height: 100%; }
.rutas .calles path { stroke: #22355D; stroke-width: 10; fill: none; stroke-linecap: round; }
.rutas .ruta path {
  stroke: var(--signal); stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: trazar 1.6s cubic-bezier(.6, .1, .2, 1) .25s forwards;
}
.rutas .ruta path:nth-child(2) { animation-delay: .4s; }
.rutas .ruta path:nth-child(3) { animation-delay: .55s; }
.rutas .ruta path:nth-child(4) { animation-delay: .7s; }
.rutas .ruta path:nth-child(5) { animation-delay: .85s; }
.rutas .paradas circle { fill: var(--ink); stroke: var(--signal); stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; animation: aparecer .4s ease-out var(--d) forwards; }
.rutas .cd circle:first-child { fill: rgb(255 176 32 / 16%); transform-box: fill-box; transform-origin: center; animation: latido 2.6s ease-out 1.9s infinite; }
.rutas .cd circle:last-child { fill: var(--signal); }
.login-lema { position: relative; z-index: 1; max-width: 30ch; }
.login-lema h1 { font-size: clamp(26px, 3vw, 38px); font-weight: 600; line-height: 1.15; letter-spacing: -.02em; margin-bottom: 14px; text-wrap: balance; }
.login-lema p { color: #B7C3DB; font-size: 15px; max-width: 42ch; }
.login-lema::before {
  content: ""; position: absolute; inset: -32px -40px -32px -48px; z-index: -1;
  background: linear-gradient(0deg, var(--ink) 55%, transparent);
}
.login-panel { display: grid; place-items: center; padding: 40px 24px; }
.login-form { width: min(380px, 100%); display: grid; gap: 18px; }
.login-form h2 { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.login-form .sub { color: var(--muted); margin-top: -12px; }
.login-logo-movil { display: none; }
.error-login, .error-form {
  display: flex; gap: 8px; padding: 10px 12px; border-radius: 10px;
  background: var(--bad-bg); color: #A62B33; font-size: 13px; font-weight: 500;
}
.ayuda { color: var(--muted); font-size: 13px; text-align: center; }
.sacudir { animation: sacudir .4s; }

/* ==================================================================
   Estructura de la app
=================================================================== */
.lateral {
  position: fixed; inset: 0 auto 0 0; width: var(--lateral); z-index: 30;
  display: flex; flex-direction: column; gap: 8px; padding: 22px 14px 14px;
  background: var(--ink); color: #D5DDEC;
}
.lateral .marca { color: #fff; padding: 0 8px 14px; }
#nav { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 18px; padding-right: 2px; scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent; }
.nav-bloque { display: grid; gap: 2px; }
.nav-titulo { font-size: 12px; color: #8494B3; padding: 0 10px 4px; font-weight: 500; }
#nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  border-radius: 10px; font-size: 13.5px; transition: background var(--t), color var(--t);
}
#nav a > span:not(.punto):not(.foto) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nav a svg { color: #8494B3; transition: color var(--t); }
#nav a:hover { background: var(--ink-2); color: #fff; }
#nav a.activo { background: var(--ink-2); color: #fff; font-weight: 500; }
#nav a.activo::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--signal); }
#nav a.activo svg { color: var(--signal); }
.punto { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--none); display: inline-block; }
.punto-ok { background: var(--ok); } .punto-warn { background: var(--warn); } .punto-bad { background: var(--bad); }
.perfil { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--ink-2); }
.perfil > div { flex: 1; min-width: 0; display: grid; }
.perfil strong { color: #fff; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perfil small { color: #8494B3; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perfil .icono-btn { color: #8494B3; }
.perfil .icono-btn:hover { background: var(--ink-2); color: #fff; }

/* ---------- Fotos de perfil ----------
   El ícono va debajo de la imagen: si no hay foto o falla, se ve el ícono. */
.foto {
  --tam: 38px;
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--tam); height: var(--tam); border-radius: 50%; overflow: hidden;
  background: #DCE6F7; color: var(--ink-3);
}
.foto svg { width: 55%; height: 55%; stroke-width: 1.75; }
.foto img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foto-gerente { background: var(--signal-2); color: #8A5A00; }
.foto-contratista { background: #E4E9F1; color: var(--muted); }
.foto-xs { --tam: 24px; }
.foto-sm { --tam: 40px; }
.foto-md { --tam: 44px; }
.foto-lg { --tam: 112px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--signal); }
#nav .foto-xs { box-shadow: 0 0 0 1.5px var(--ink-3); }
#nav a.activo .foto-xs { box-shadow: 0 0 0 2px var(--signal); }
#nav .foto-xs svg { color: var(--ink-3); }
#barra-foto:empty { display: none; }
#barra-foto .foto { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--line); }
.perfil-grande {
  position: relative; display: grid; justify-items: center; gap: 2px; text-align: center;
  padding-right: 24px; margin-right: 4px; border-right: 1px solid var(--line); min-width: 150px;
}
.perfil-grande .foto { margin-bottom: 10px; }
.perfil-grande strong { font-weight: 600; font-size: 14px; line-height: 1.3; }
.perfil-grande small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.foto-cambiar {
  position: absolute; top: 78px; left: calc(50% + 26px); width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 50%; border: 3px solid var(--surface);
  background: var(--ink); color: var(--signal); cursor: pointer; transition: transform var(--t), background var(--t);
}
.foto-cambiar svg { width: 16px; height: 16px; }
.foto-cambiar:hover { background: var(--ink-2); transform: scale(1.08); }
.subiendo-foto .perfil-grande .foto { opacity: .5; }
.subiendo-foto .foto-cambiar svg { animation: girar 1s linear infinite; }
.enlace-suave { border: 0; background: none; padding: 4px 0 0; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.enlace-suave:hover { color: var(--bad); }
.sentido {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 6px;
  background: var(--none-bg); color: var(--ink-2); font-weight: 600; font-size: 13px; line-height: 1;
}
.segmentos .sentido { background: transparent; }
.segmentos input:checked + span .sentido { color: var(--ink); background: var(--signal-2); }

.avatar {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--signal); color: var(--ink); font-weight: 600; font-size: 13px;
}
.avatar-gerente { background: var(--ink); color: var(--signal); }
.avatar-abi { background: #DCE6F7; color: var(--ink-2); }
.avatar-contratista { background: var(--signal-2); color: #7A4D00; }

.principal { margin-left: var(--lateral); min-height: 100vh; }
.barra {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 18px 32px; background: rgb(238 241 246 / 86%); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.barra-titulo { flex: 1; min-width: 0; }
.barra-titulo p { color: var(--muted); font-size: 13px; }
.barra-acciones { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.menu-movil { display: none; }
.selector-periodo { display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 2px; }
.selector-periodo select { height: 36px; border: 0; width: auto; min-width: 128px; padding: 0 8px; font-weight: 500; background: transparent; cursor: pointer; text-align: center; }
.vista { padding: 8px 32px 48px; display: grid; gap: 20px; outline: none; max-width: 1480px; }

.tarjeta { background: var(--surface); border-radius: var(--radio); box-shadow: var(--sombra); padding: 20px; min-width: 0; }
.tarjeta-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.nota { color: var(--muted); font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Anillo de cumplimiento ---------- */
.anillo { position: relative; width: var(--tam); height: var(--tam); flex: none; }
.anillo svg { width: 100%; height: 100%; rotate: -90deg; }
.anillo circle { fill: none; stroke-width: 11; }
.anillo-pista { stroke: var(--none-bg); }
.anillo-valor { stroke: var(--none); stroke-linecap: round; animation: llenar 1s cubic-bezier(.3, .7, .2, 1) both; }
.anillo-ok .anillo-valor { stroke: var(--ok); }
.anillo-warn .anillo-valor { stroke: var(--warn); }
.anillo-bad .anillo-valor { stroke: var(--bad); }
.anillo-texto { position: absolute; inset: 0; display: grid; place-items: center; }
.anillo-texto strong { font-size: calc(var(--tam) * .22); font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* ---------- Tira semáforo ---------- */
.tira { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; min-width: 156px; }
.tira.semanal { gap: 1.5px; min-width: 260px; }
.celda {
  position: relative; height: 22px; border-radius: 4px; background: var(--none-bg);
  box-shadow: inset 0 0 0 1px rgb(19 33 60 / 4%);
  transform-origin: bottom; animation: crecer .45s cubic-bezier(.3, .8, .3, 1) both;
  animation-delay: calc(var(--i) * 22ms + var(--fila, 0) * 30ms);
}
.semanal .celda { border-radius: 2px; animation-delay: calc(var(--i) * 6ms + var(--fila, 0) * 30ms); }
.celda.c-ok { background: var(--ok); }
.celda.c-warn { background: var(--warn); }
.celda.c-bad { background: var(--bad); }
.celda.actual { outline: 2px solid var(--ink); outline-offset: 1px; z-index: 1; }
.sin-entrada .celda, .sin-entrada .anillo-valor, .sin-entrada tbody tr { animation: none; }

/* ---------- Leyendas y estados ---------- */
.c-ok { --c: var(--ok); } .c-warn { --c: var(--warn); } .c-bad { --c: var(--bad); } .c-none { --c: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.chip svg { width: 15px; height: 15px; }
.chip-ok { background: var(--ok-bg); color: #0B7A51; }
.chip-warn { background: var(--warn-bg); color: #A65A05; }
.chip-bad { background: var(--bad-bg); color: #B42D36; }
.chip-none { background: var(--none-bg); color: var(--muted); }
.leyenda { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12.5px; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.cuadro { width: 12px; height: 12px; border-radius: 3px; background: var(--none); display: inline-block; }
.cuadro.c-ok { background: var(--ok); } .cuadro.c-warn { background: var(--warn); } .cuadro.c-bad { background: var(--bad); }

.aviso {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--signal-2); color: #6B4500; font-weight: 500; font-size: 13px;
}

/* ==================================================================
   Resumen
=================================================================== */
.resumen-cab {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 28px;
  background: var(--ink); color: #fff; border-radius: var(--radio); padding: 26px 30px;
}
.resumen-cab .anillo-pista { stroke: var(--ink-2); }
.resumen-datos h2 { font-size: 20px; }
.resumen-datos p { color: #A9B6CF; font-size: 13px; margin-top: 2px; }
.cifras { display: flex; gap: 28px; margin: 16px 0 0; flex-wrap: wrap; }
.cifras div { display: grid; }
.cifras dt { font-size: 12.5px; color: #A9B6CF; }
.cifras dd { margin: 0; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cifras .c-bad dd { color: #FF8A90; }
.cifras .c-warn dd { color: var(--signal); }
.resumen-cab .leyenda { flex-direction: column; color: #A9B6CF; align-self: end; }

.grupo { display: grid; gap: 10px; }
.grupo-titulo { display: flex; align-items: center; gap: 10px; font-size: 16px; padding: 6px 4px 0; }
.grupo-titulo svg { color: var(--ink-3); }
.grupo-titulo span { font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 1px 9px; font-weight: 500; }
.personas { display: grid; gap: 8px; }
.persona {
  display: grid; grid-template-columns: auto minmax(160px, 1.1fr) 92px minmax(200px, 2fr) auto;
  align-items: center; gap: 18px; padding: 14px 18px; background: var(--surface);
  border-radius: var(--radio); box-shadow: var(--sombra); border: 1px solid transparent;
  transition: border-color var(--t), transform var(--t);
}
.persona:hover { border-color: #C9D2E1; }
.persona:hover .persona-info strong { text-decoration: underline; text-decoration-color: var(--signal); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.persona-info { display: grid; min-width: 0; }
.persona-info strong { font-weight: 600; }
.persona-info small, .persona-valor small { color: var(--muted); font-size: 12px; }
.persona-valor { display: grid; text-align: right; }
.persona-valor strong { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.v-ok strong { color: var(--ok); } .v-warn strong { color: var(--warn); } .v-bad strong { color: var(--bad); } .v-none strong { color: var(--muted); }
.persona-conteo { display: flex; gap: 6px; }
.persona-conteo span {
  min-width: 28px; height: 26px; display: grid; place-items: center; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
}

/* ==================================================================
   Tablero
=================================================================== */
.tablero-cab { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; }
.puntaje { display: flex; align-items: center; gap: 24px; }
.puntaje h2 { font-size: 17px; }
.puntaje p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.conteo { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(2, auto); gap: 6px 20px; font-size: 13px; color: var(--muted); }
.conteo li { display: flex; align-items: baseline; gap: 6px; }
.conteo strong { color: var(--c); font-size: 18px; font-weight: 600; min-width: 1.4ch; font-variant-numeric: tabular-nums; }
.tendencia .lienzo { height: 170px; position: relative; }

.tabla-kpis { padding: 20px 0 8px; }
.tabla-kpis .tarjeta-cab { padding: 0 20px; }
.tabla-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted); padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.tabla-kpis th:first-child, .tabla-kpis td:first-child { padding-left: 20px; }
.tabla-kpis tbody tr { cursor: pointer; transition: background var(--t); animation: entrar .4s ease-out both; animation-delay: calc(var(--fila) * 35ms); }
.tabla-kpis tbody tr:hover, .tabla-kpis tbody tr:focus-visible { background: #F7F9FC; outline: none; }
.tabla-kpis tbody tr:focus-visible td:first-child { box-shadow: inset 4px 0 0 var(--signal); }
.kpi-nombre { min-width: 200px; }
.kpi-nombre strong { display: block; font-weight: 600; font-size: 13.5px; }
.kpi-nombre small { display: block; color: var(--muted); font-size: 12px; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }
.meta svg { width: 15px; height: 15px; color: var(--ink-3); }
.fuerte { font-weight: 600; font-size: 14px; }
.tenue { color: var(--muted); }
.col-tira { width: 30%; min-width: 180px; }
.acciones { width: 36px; color: var(--muted); }
.acciones svg { transition: translate var(--t); }
tbody tr:hover .acciones svg { translate: 3px 0; color: var(--ink); }

.vacio { display: grid; justify-items: center; gap: 14px; padding: 56px 20px; text-align: center; color: var(--muted); background: var(--surface); border-radius: var(--radio); }
.vacio > svg { width: 36px; height: 36px; color: var(--ink-3); }

/* ---------- Cajón lateral ---------- */
.velo { position: fixed; inset: 0; z-index: 40; background: rgb(19 33 60 / 38%); backdrop-filter: blur(2px); animation: aparecer-opacidad .2s; }
.cajon {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(520px, 100%);
  background: var(--surface); box-shadow: -24px 0 48px -24px rgb(19 33 60 / 35%);
  display: flex; flex-direction: column; translate: 100% 0; visibility: hidden;
  transition: translate .32s cubic-bezier(.3, .8, .2, 1), visibility 0s .32s;
}
.cajon.abierto { translate: 0 0; visibility: visible; transition: translate .32s cubic-bezier(.3, .8, .2, 1); }
.cajon-cab { display: flex; justify-content: space-between; gap: 12px; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.cajon-cab h2 { font-size: 19px; }
.cajon-cab p { color: var(--muted); font-size: 13px; }
.cajon-cuerpo { flex: 1; overflow-y: auto; padding: 18px 24px 0; display: grid; align-content: start; gap: 18px; }
.ficha { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin: 0; }
.ficha div { min-width: 0; }
.ficha dt { font-size: 12px; color: var(--muted); }
.ficha dd { margin: 0; font-weight: 500; font-size: 13.5px; overflow-wrap: anywhere; }
.lienzo-cajon { height: 210px; position: relative; }
#form-valores .tarjeta-cab { margin-bottom: 8px; }
.tabla-valores th, .tabla-valores td { padding: 4px 6px; border: 0; }
.tabla-valores thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; padding-bottom: 8px; }
.tabla-valores tbody th { color: var(--text); font-weight: 500; font-size: 13px; display: flex; align-items: center; gap: 8px; padding: 12px 6px; }
.tabla-valores tr.actual th { color: var(--ink); font-weight: 600; }
.tabla-valores tr.actual { background: var(--signal-2); }
.tabla-valores input {
  width: 100%; height: 36px; padding: 0 10px; text-align: right; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.tabla-valores input:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px rgb(59 82 128 / 14%); }
.tabla-valores input[readonly] { border-color: transparent; background: transparent; }
.cajon-pie {
  position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding: 14px 0 20px; margin-top: 8px; background: linear-gradient(transparent, var(--surface) 30%);
}
.cajon-pie .btn-peligro-suave { margin-right: auto; }
.solo-lectura { padding: 16px 0 24px; }

/* ---------- Modal ---------- */
.modal { border: 0; padding: 0; border-radius: 18px; width: min(620px, calc(100% - 32px)); max-height: calc(100vh - 32px); overflow: hidden; box-shadow: 0 30px 80px -20px rgb(19 33 60 / 45%); color: var(--text); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal[open] { animation: modal-in .25s cubic-bezier(.3, .8, .2, 1); }
.modal::backdrop { background: rgb(19 33 60 / 45%); backdrop-filter: blur(3px); }
.modal-cab { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px 6px; }
.modal-cab h2 { font-size: 19px; }
.modal-cuerpo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; padding: 14px 24px; flex: 1; min-height: 0; overflow-y: auto; }
.ancho { grid-column: 1 / -1; }
.modal-pie { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; border-top: 1px solid var(--line); }
.segmentos { display: flex; gap: 6px; padding: 4px; background: var(--none-bg); border-radius: 12px; }
.segmentos label { flex: 1; }
.segmentos input { position: absolute; opacity: 0; }
.segmentos span {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 38px; border-radius: 9px;
  font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background var(--t), color var(--t), box-shadow var(--t);
}
.segmentos input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(19 33 60 / 14%); }
.segmentos input:checked + span svg { color: var(--signal); }
.segmentos input:focus-visible + span { outline: 3px solid var(--signal); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; translate: -50% 0; z-index: 90; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 12px 30px -10px rgb(19 33 60 / 60%);
  animation: toast-in .3s cubic-bezier(.3, .8, .2, 1);
  transition: opacity .3s, translate .3s;
}
.toast svg { color: var(--signal); }
.toast-error svg { color: #FF8A90; }
.toast.fuera { opacity: 0; translate: 0 8px; }

/* ==================================================================
   Animaciones
=================================================================== */
@keyframes trazar { to { stroke-dashoffset: 0; } }
@keyframes aparecer { from { opacity: 0; scale: .2; } to { opacity: 1; scale: 1; } }
@keyframes latido { 0% { scale: 1; opacity: 1; } 100% { scale: 2.2; opacity: 0; } }
@keyframes llenar { from { stroke-dashoffset: var(--desde); } to { stroke-dashoffset: var(--hasta); } }
@keyframes crecer { from { transform: scaleY(.15); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes entrar { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }
@keyframes aparecer-opacidad { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; scale: .96; translate: 0 10px; } }
@keyframes toast-in { from { opacity: 0; translate: 0 12px; } }
@keyframes sacudir { 20%, 60% { translate: -6px 0; } 40%, 80% { translate: 6px 0; } }
@keyframes girar { to { rotate: 360deg; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .rutas .ruta path { stroke-dashoffset: 0; }
}

/* ==================================================================
   Responsive
=================================================================== */
@media (max-width: 1180px) {
  .persona { grid-template-columns: auto minmax(0, 1fr) auto; }
  .persona-tira { grid-column: 1 / -1; }
  .persona-conteo { display: none; }
  .tablero-cab { grid-template-columns: 1fr; }
  .resumen-cab { grid-template-columns: auto 1fr; }
  .resumen-cab .leyenda { grid-column: 1 / -1; flex-direction: row; }
}
@media (max-width: 900px) {
  .login-grid { grid-template-columns: 1fr; }
  .login-mapa { display: none; }
  .login-logo-movil { display: block; }
  .lateral { translate: -100% 0; transition: translate .28s cubic-bezier(.3, .8, .2, 1); z-index: 45; }
  .menu-abierto .lateral { translate: 0 0; }
  .principal { margin-left: 0; }
  .menu-movil { display: inline-grid; }
  .barra { padding: 12px 16px; flex-wrap: wrap; }
  .barra-acciones { width: 100%; justify-content: space-between; }
  .vista { padding: 4px 16px 40px; }
}
@media (max-width: 600px) {
  h1 { font-size: 19px; }
  .resumen-cab { grid-template-columns: 1fr; justify-items: start; padding: 22px; }
  .puntaje { flex-direction: column; align-items: center; text-align: center; }
  .puntaje .conteo { justify-content: center; }
  .perfil-grande { border-right: 0; padding: 0 0 18px; margin: 0; border-bottom: 1px solid var(--line); width: 100%; }
  .modal-cuerpo { grid-template-columns: 1fr; }
  .barra-acciones .btn span { display: none; }
  .selector-periodo select { min-width: 0; }
  .ficha { grid-template-columns: 1fr 1fr; }
  .cajon-cuerpo { padding: 16px 16px 0; }
  .cajon-cab { padding: 18px 16px 12px; }
}
