:root {
  --fondo: #f5f6f8;
  --superficie: #ffffff;
  --superficie-2: #eef0f4;
  --texto: #14182b;
  --texto-2: #5a6178;
  --borde: #dde1e8;
  --primario: #14213d;
  --primario-texto: #ffffff;
  --acento: #b8860b;
  --acento-suave: #fbf3dc;
  --ok: #1a7f4b;
  --ok-suave: #e3f4ea;
  --alerta: #b45309;
  --alerta-suave: #fdf0e1;
  --error: #b42318;
  --error-suave: #fdecea;
  --barra-fondo: #e6e9ef;
  --radio: 14px;
  --sombra: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0d111c;
    --superficie: #161b29;
    --superficie-2: #1e2435;
    --texto: #eef0f6;
    --texto-2: #a2a9bd;
    --borde: #2b3247;
    --primario: #e9c46a;
    --primario-texto: #14182b;
    --acento: #e9c46a;
    --acento-suave: #3a3220;
    --ok: #4ade80;
    --ok-suave: #163222;
    --alerta: #fbbf24;
    --alerta-suave: #3a2c12;
    --error: #f87171;
    --error-suave: #3b1a1a;
    --barra-fondo: #262d40;
    --sombra: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- Barra superior y navegación ---------- */
.barra {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #14213d;
  color: #fff;
  padding-top: env(safe-area-inset-top);
}

.barra-in {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
}

.marca {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
}

.logo {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #e9c46a;
  color: #14213d;
  font-weight: 800;
}

.quien {
  margin-left: auto;
  font-size: 0.85rem;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}

.nav-sup {
  display: none;
  gap: 4px;
}

.nav-sup a,
.nav-inf a {
  text-decoration: none;
  border-radius: 10px;
}

.nav-sup a {
  padding: 6px 12px;
  opacity: 0.8;
}

.nav-sup a[aria-current='page'] {
  background: rgb(255 255 255 / 14%);
  opacity: 1;
}

.nav-inf {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  background: var(--superficie);
  border-top: 1px solid var(--borde);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.nav-inf[hidden] {
  display: none;
}

.nav-inf a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 2px;
  font-size: 0.72rem;
  color: var(--texto-2);
}

.nav-inf a svg {
  width: 22px;
  height: 22px;
}

.nav-inf a[aria-current='page'] {
  color: var(--texto);
  font-weight: 600;
}

.nav-inf a[aria-current='page'] svg {
  color: var(--acento);
}

@media (min-width: 760px) {
  body {
    padding-bottom: 24px;
  }
  .nav-sup {
    display: flex;
  }
  .nav-inf {
    display: none;
  }
}

/* ---------- Contenido ---------- */
.contenido {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.cargando,
.vacio {
  color: var(--texto-2);
  text-align: center;
  padding: 32px 8px;
}

.encabezado {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sub {
  color: var(--texto-2);
  font-size: 0.875rem;
  margin-top: 4px;
}

.seccion {
  margin: 24px 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--texto-2);
}

.rejilla {
  display: grid;
  gap: 12px;
}

@media (min-width: 760px) {
  .rejilla {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 16px;
  min-width: 0;
}

.tarjeta + .tarjeta {
  margin-top: 12px;
}

.rejilla .tarjeta + .tarjeta {
  margin-top: 0;
}

/* ---------- Resumen de premios ---------- */
.resumen {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--primario);
  color: var(--primario-texto);
  border-radius: var(--radio);
  padding: 16px;
}

.resumen .etiqueta {
  font-size: 0.8rem;
  opacity: 0.85;
}

.resumen .monto {
  font-size: 1.6rem;
  font-weight: 800;
}

/* ---------- Tarjeta de meta ---------- */
.meta-cab {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.periodo {
  color: var(--texto-2);
  font-size: 0.82rem;
  margin-top: 2px;
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--superficie-2);
  color: var(--texto-2);
  white-space: nowrap;
}

.chip.ok {
  background: var(--ok-suave);
  color: var(--ok);
}

.chip.oro {
  background: var(--acento-suave);
  color: var(--acento);
}

.cifras {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 8px;
}

.pct {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.pct.ok {
  color: var(--ok);
}

.venta-cuota {
  text-align: right;
  font-size: 0.85rem;
  color: var(--texto-2);
}

.venta-cuota strong {
  display: block;
  font-size: 1.05rem;
  color: var(--texto);
}

.barra-avance {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: var(--barra-fondo);
  margin: 6px 0 12px;
}

.barra-avance .lleno {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: var(--primario);
  transition: width 0.4s ease;
}

.barra-avance .lleno.ok {
  background: var(--ok);
}

.barra-avance .marca-tramo {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--texto);
  opacity: 0.55;
}


.mensaje {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-top: 8px;
}

.mensaje.ganado {
  background: var(--ok-suave);
  color: var(--ok);
}

.mensaje.falta {
  background: var(--alerta-suave);
  color: var(--alerta);
}

.mensaje.info {
  background: var(--superficie-2);
  color: var(--texto-2);
}

.mensaje strong {
  font-weight: 700;
}

.tramos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tramo {
  font-size: 0.78rem;
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: 3px 8px;
  color: var(--texto-2);
}

.tramo.alcanzado {
  border-color: var(--ok);
  color: var(--ok);
  font-weight: 600;
}

details.dias {
  margin-top: 12px;
  font-size: 0.85rem;
}

details.dias summary {
  cursor: pointer;
  color: var(--texto-2);
}

.dias-lista {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.dia {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 8px;
}

.dia .mini {
  height: 8px;
  border-radius: 4px;
  background: var(--acento);
  opacity: 0.8;
}

/* ---------- Listas compactas ---------- */
.fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--borde);
}

.fila:last-child {
  border-bottom: 0;
}

.fila .der {
  text-align: right;
  white-space: nowrap;
}

.persona {
  display: block;
  text-decoration: none;
}

.persona:hover {
  border-color: var(--acento);
}

.persona-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 64px;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.85rem;
}

.persona-meta .barra-avance {
  margin: 0;
  height: 8px;
}

.persona-meta .nombre-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Formularios ---------- */
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--texto-2);
  margin-bottom: 4px;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--borde);
  border-radius: 10px;
  background: var(--superficie);
  color: var(--texto);
}

textarea {
  min-height: 120px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--acento);
  outline-offset: 2px;
}

.campos {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.campo-ancho {
  grid-column: 1 / -1;
}

.acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.boton {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--primario);
  color: var(--primario-texto);
  font-weight: 600;
  cursor: pointer;
}

.boton.sec {
  background: transparent;
  color: var(--texto);
  border-color: var(--borde);
}

.boton.peligro {
  background: transparent;
  color: var(--error);
  border-color: var(--borde);
}

.boton.chico {
  min-height: 36px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.boton:disabled {
  opacity: 0.5;
  cursor: default;
}

.tramo-fila {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 8px;
}

.errores {
  background: var(--error-suave);
  color: var(--error);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-top: 12px;
}

.errores ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.ayuda {
  font-size: 0.82rem;
  color: var(--texto-2);
  margin: 6px 0 0;
}

code {
  background: var(--superficie-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.85em;
}

/* ---------- Tablas ---------- */
.tabla-scroll {
  overflow-x: auto;
  margin: 0 -16px;
  padding: 0 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--borde);
  white-space: nowrap;
}

th {
  font-size: 0.75rem;
  color: var(--texto-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td.n,
th.n {
  text-align: right;
}

/* ---------- Aviso flotante ---------- */
.aviso {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100vw - 32px);
  background: var(--texto);
  color: var(--fondo);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / 20%);
}

.aviso.error {
  background: var(--error);
  color: #fff;
}

@media (min-width: 760px) {
  .aviso {
    bottom: 24px;
  }
}
