:root {
  --fondo: #f1f5f9;
  --superficie: #ffffff;
  --texto: #0f172a;
  --suave: #64748b;
  --borde: #e2e8f0;
  --primario: #1d4ed8;
  --primario-texto: #ffffff;
  --ok: #047857;
  --mal: #b91c1c;
  --aviso-fondo: #fef3c7;
  --aviso-texto: #78350f;
  --barra: #0f172a;
  --barra-texto: #f8fafc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0b1220;
    --superficie: #162032;
    --texto: #f1f5f9;
    --suave: #94a3b8;
    --borde: #27364d;
    --primario: #3b82f6;
    --ok: #34d399;
    --mal: #f87171;
    --aviso-fondo: #422006;
    --aviso-texto: #fde68a;
    --barra: #0b1220;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Comportamiento de app: sin zoom por doble toque ni rebote al llegar al borde */
html { touch-action: manipulation; overscroll-behavior: none; }
body { overscroll-behavior: none; }
/* Sin selección de texto ni menú al mantener pulsado, salvo donde hace falta copiar */
#app {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
#app input, #app .aviso p {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}
body {
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primario); }
.cargando { text-align: center; padding: 3rem 1rem; color: var(--suave); }

.cabecera {
  background: var(--barra);
  color: var(--barra-texto);
  padding: calc(env(safe-area-inset-top) + .75rem) 1rem .75rem;
  font-weight: 600;
  position: sticky; top: 0; z-index: 5;
}
.contenido {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem calc(env(safe-area-inset-bottom) + 5rem);
}
.contenido.sin-nav { padding-bottom: 2rem; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex;
  background: var(--superficie);
  border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; text-align: center; padding: .7rem .25rem;
  color: var(--suave); text-decoration: none; font-size: .85rem; font-weight: 500;
  position: relative;
}
.nav a.activa { color: var(--primario); font-weight: 700; }
.globo {
  display: inline-block; min-width: 1.25rem; padding: 0 .3rem; margin-left: .25rem;
  border-radius: 1rem; background: var(--mal); color: #fff; font-size: .72rem; line-height: 1.25rem;
}

.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: .85rem;
}
.marca { text-align: center; padding: 1.5rem 0 1rem; }
/* El logo tiene texto negro: necesita fondo blanco también en modo oscuro */
.placa-logo { display: inline-block; background: #fff; border-radius: 12px; padding: .75rem 1rem; }
.marca img { display: block; width: 241px; max-width: 100%; height: auto; }
.marca h1 { margin: 0 0 .6rem; }
.suave { color: var(--suave); font-size: .9rem; }
.pie { text-align: center; margin-top: 1rem; font-size: .9rem; }
.pie a { display: inline-block; padding: .35rem .5rem; }

label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .75rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date] {
  display: block; width: 100%; margin-top: .25rem;
  padding: .65rem .7rem;
  font: inherit; font-weight: 400;
  font-size: 16px; /* con menos, iOS amplía la pantalla al tocar el campo */
  color: var(--texto); background: var(--fondo);
  border: 1px solid var(--borde); border-radius: 8px;
  min-height: 44px;
}
input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible {
  outline: 2px solid var(--primario); outline-offset: 2px;
}
.casilla { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.casilla input { margin-top: .3rem; width: 1.15rem; height: 1.15rem; flex: none; }
.opcion {
  display: flex; gap: .6rem; align-items: center; font-weight: 500;
  border: 1px solid var(--borde); border-radius: 8px; padding: .7rem; margin-bottom: .5rem; min-height: 44px;
}
.opcion input { width: 1.15rem; height: 1.15rem; flex: none; }
fieldset { border: 0; margin: 0 0 .75rem; padding: 0; }
legend { font-size: .9rem; font-weight: 600; margin-bottom: .4rem; padding: 0; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  min-height: 44px; padding: .6rem 1rem;
  border-radius: 8px; border: 1px solid transparent;
  background: var(--primario); color: var(--primario-texto);
}
button:disabled { opacity: .6; cursor: default; }
button.ancho { width: 100%; }
button.secundario { background: transparent; color: var(--primario); border-color: var(--borde); }
button.peligro { background: transparent; color: var(--mal); border-color: var(--mal); }
.botones { display: flex; flex-wrap: wrap; gap: .5rem; }

.error, .ok-msg, .nota {
  border-radius: 8px; padding: .6rem .75rem; margin-bottom: .75rem; font-size: .92rem;
}
.error { background: color-mix(in srgb, var(--mal) 14%, transparent); color: var(--mal); }
.ok-msg { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.nota { background: var(--aviso-fondo); color: var(--aviso-texto); }

.etiqueta {
  display: inline-block; font-size: .75rem; font-weight: 600;
  padding: .1rem .5rem; border-radius: 1rem; border: 1px solid var(--borde); color: var(--suave);
}
.etiqueta.espera { background: var(--aviso-fondo); color: var(--aviso-texto); border-color: transparent; }
.fila { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.dias { display: flex; gap: .25rem; margin: .5rem 0; }
.dia {
  width: 1.9rem; height: 1.9rem; line-height: 1.9rem; text-align: center; border-radius: 50%;
  font-size: .75rem; font-weight: 600; background: var(--fondo); color: var(--suave);
}
.dia.si { background: var(--primario); color: var(--primario-texto); }
.importes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: center; margin: .6rem 0; }
.importes small { display: block; color: var(--suave); font-size: .75rem; }
.importes strong { font-variant-numeric: tabular-nums; }
.pendiente { color: var(--mal); }
.al-dia { color: var(--ok); }
details { margin-top: .5rem; font-size: .9rem; }
summary { cursor: pointer; color: var(--suave); padding: .25rem 0; }
.movimiento { display: flex; justify-content: space-between; padding: .3rem 0; border-top: 1px solid var(--borde); font-variant-numeric: tabular-nums; }

/* Colores fijos: el texto blanco debe leerse igual en modo claro y oscuro */
.circuito { border-radius: 12px; padding: 1rem; margin-bottom: .85rem; color: #fff; }
.circuito.abierto { background: #15803d; }
.circuito.cerrado { background: #b91c1c; }
.circuito strong { display: block; font-size: 1.25rem; line-height: 1.25; }
.circuito small { display: block; margin-top: .25rem; font-size: .8rem; }
.apartado { margin: 1.25rem 0 .6rem; }
.evento h3 { margin-bottom: .15rem; overflow-wrap: anywhere; }
.evento p { white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 0; }
.evento .etiqueta { flex: none; }
.evento.caducado { background: transparent; color: var(--suave); }
.etiqueta.en-curso { background: var(--primario); color: var(--primario-texto); border-color: transparent; }

.aviso h3 { margin-bottom: .15rem; }
.aviso.nuevo { border-left: 4px solid var(--primario); }
.aviso p { white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 0; }
ol.pasos { margin: .25rem 0 .75rem; padding-left: 1.25rem; }
ol.pasos li { margin-bottom: .25rem; }
.hijo { border: 1px solid var(--borde); border-radius: 8px; padding: .75rem; margin-bottom: .6rem; }
.oculto { display: none; }
.tirar {
  position: fixed; left: 0; right: 0; z-index: 4;
  top: calc(env(safe-area-inset-top) + 3.6rem);
  text-align: center; font-size: .85rem; color: var(--suave);
  opacity: 0; pointer-events: none;
}
.tirar.visible { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  button { transition: opacity .15s; }
}
