/* Blade Passport · hoja de estilos única.
   Móvil primero, tipografía del sistema, contraste AA, modo oscuro por
   prefers-color-scheme y hoja de impresión (pasaporte, página pública e informe). */

:root {
  color-scheme: light dark;
  --fondo: #f5f7f8;
  --superficie: #ffffff;
  --superficie-2: #eef2f4;
  --texto: #13202a;
  --texto-suave: #485864;
  --borde: #c9d3da;
  --primario: #0b5d7a;
  --primario-hover: #094d65;
  --primario-texto: #ffffff;
  --foco: #d9480f;
  --ok: #1d6f45;
  --ok-fondo: #e2f2e9;
  --aviso: #7f5200;
  --aviso-fondo: #fbefd9;
  --error: #b3261e;
  --error-fondo: #fbe3e1;
  --neutro: #3d4b55;
  --neutro-fondo: #e6ebef;
  --radio: 12px;
  --radio-peq: 8px;
  --sombra: 0 1px 2px rgba(10, 30, 45, 0.08), 0 4px 16px rgba(10, 30, 45, 0.06);
  --ancho: 60rem;
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fuente-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0d151b;
    --superficie: #15212a;
    --superficie-2: #1c2a34;
    --texto: #e5edf2;
    --texto-suave: #a8b7c2;
    --borde: #2e3e4a;
    --primario: #5bbfe4;
    --primario-hover: #7dcdeb;
    --primario-texto: #04202b;
    --foco: #ffa36b;
    --ok: #74d6a0;
    --ok-fondo: #11331f;
    --aviso: #f2c46f;
    --aviso-fondo: #3a2b0e;
    --error: #ff948b;
    --error-fondo: #3d1714;
    --neutro: #c3cfd8;
    --neutro-fondo: #24333e;
    --sombra: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

/* ------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente);
  font-size: 1rem;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--primario); text-underline-offset: 2px; }
a:hover { color: var(--primario-hover); }
img, svg { max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--foco);
  outline-offset: 2px;
  border-radius: 4px;
}

.visualmente-oculto {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.saltar {
  position: absolute;
  left: 0.5rem; top: -3rem;
  background: var(--primario);
  color: var(--primario-texto);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radio-peq);
  z-index: 10;
}
.saltar:focus { top: 0.5rem; }

main {
  display: block;
  max-width: var(--ancho);
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}
main:focus { outline: none; }

.intro { color: var(--texto-suave); max-width: 42rem; }
.suave { color: var(--texto-suave); }
.pequeno { font-size: 0.875rem; }
.mono { font-family: var(--fuente-mono); }

/* ------------------------------------------------------------ cabecera */

.cabecera {
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
}
.cabecera__fila {
  max-width: var(--ancho);
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.marca {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--texto);
  text-decoration: none;
  font-weight: 700;
  min-height: 44px;
}
.marca img { width: 32px; height: 32px; }
.cabecera__acciones { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.cabecera__usuario {
  display: none;
  color: var(--texto-suave);
  font-size: 0.875rem;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selector-idioma { width: auto; min-height: 40px; padding: 0.25rem 0.5rem; }
.cabecera__nav { max-width: var(--ancho); margin: 0 auto; padding: 0 0.5rem; }
.nav {
  list-style: none;
  margin: 0;
  padding: 0 0 0.25rem;
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: thin;
}
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: var(--radio-peq);
  color: var(--texto);
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { background: var(--superficie-2); }
.nav a[aria-current="page"] {
  background: var(--superficie-2);
  color: var(--primario);
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--primario);
}

/* ------------------------------------------------------------ bloques */

.panel, .seccion {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1rem;
  margin: 0 0 1rem;
  box-shadow: var(--sombra);
}
.panel--sesion { text-align: left; }
.panel--destacado { border-left: 4px solid var(--primario); }

fieldset.seccion { min-width: 0; }
.seccion > legend {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 0.25rem;
}

.cabecera-seccion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

/* ------------------------------------------------------------ botones */

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 2px solid var(--primario);
  border-radius: var(--radio-peq);
  background: var(--primario);
  color: var(--primario-texto);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.boton:hover { background: var(--primario-hover); border-color: var(--primario-hover); color: var(--primario-texto); }
.boton:disabled, .boton[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.boton--secundario { background: transparent; color: var(--primario); }
.boton--secundario:hover { background: var(--superficie-2); color: var(--primario); }
.boton--peligro { background: transparent; border-color: var(--error); color: var(--error); }
.boton--peligro:hover { background: var(--error-fondo); border-color: var(--error); color: var(--error); }
.boton--peq { min-height: 40px; padding: 0.25rem 0.75rem; font-size: 0.9rem; }
.boton--bloque { width: 100%; }
/* Botones de proveedor (Google y Apple): fondo blanco con el logotipo, también en modo oscuro. */
.boton--sso { background: #ffffff; border-color: #c9ced6; color: #1f2328; }
.boton--sso:hover { background: #f3f5f8; border-color: #9aa3b0; color: #1f2328; }
.boton--sso .logo-sso { width: 1.15rem; height: 1.15rem; flex: none; }
.botones--sso { flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 0.75rem; }
.botones--sso .separador-sso { width: 100%; margin: 0; }

.botones { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 0; }
.botones--grandes .boton { flex: 1 1 14rem; min-height: 56px; font-size: 1.05rem; }

/* ------------------------------------------------------------ formularios */

label, .etiqueta { display: block; font-weight: 600; margin: 0 0 0.25rem; }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--borde);
  border-radius: var(--radio-peq);
  background: var(--superficie);
  color: var(--texto);
  font: inherit;
}
textarea { min-height: 7rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] {
  width: 1.25rem; height: 1.25rem; min-height: 0;
  margin: 0; flex: none;
  accent-color: var(--primario);
}
input[type="file"] { padding: 0.4rem; }
[aria-invalid="true"] { border-color: var(--error); border-width: 2px; }

.campo { margin: 0 0 0.9rem; min-width: 0; }
.ayuda { display: block; color: var(--texto-suave); font-size: 0.875rem; margin-top: 0.25rem; font-weight: 400; }

.rejilla { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }

.casillas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.25rem 1rem;
  margin: 0 0 0.75rem;
  padding: 0;
  border: 0;
}
.casilla {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  font-weight: 400;
  margin: 0;
}

.opciones-origen { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; border: 0; padding: 0; margin: 0 0 1rem; }

.interruptor {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 400;
  margin: 0.25rem 0 0.75rem;
  min-height: 40px;
  cursor: pointer;
}
.interruptor input {
  appearance: none;
  -webkit-appearance: none;
  width: 2.75rem; height: 1.5rem;
  border-radius: 999px;
  background: var(--borde);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.interruptor input::after {
  content: "";
  position: absolute;
  top: 0.2rem; left: 0.2rem;
  width: 1.1rem; height: 1.1rem;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s;
}
.interruptor input:checked { background: var(--primario); }
.interruptor input:checked::after { transform: translateX(1.25rem); }

.fila-repetible {
  border: 1px dashed var(--borde);
  border-radius: var(--radio-peq);
  padding: 0.75rem;
  margin: 0 0 0.75rem;
}

details.plegable > summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
}

/* ------------------------------------------------------------ listas y tarjetas */

.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 0.9rem;
}
.tarjeta__cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; }
.tarjeta__titulo { margin: 0; font-size: 1.05rem; }
.tarjeta__acciones { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.datos { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: 0.25rem 1rem; margin: 0.5rem 0 0; }
.datos dt { color: var(--texto-suave); }
.datos dd { margin: 0; overflow-wrap: anywhere; }

.vacio { color: var(--texto-suave); font-style: italic; }

/* ------------------------------------------------------------ sellos y veredictos */

.sello {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.sello--declarado, .sello--pendiente, .sello--no_consta { color: var(--neutro); background: var(--neutro-fondo); }
.sello--documento, .sello--cumple_declarado, .sello--aviso, .sello--encaja_con_avisos { color: var(--aviso); background: var(--aviso-fondo); }
.sello--verificado, .sello--cumple, .sello--encaja, .sello--vigente, .sello--confirmada { color: var(--ok); background: var(--ok-fondo); }
.sello--caducado, .sello--no_declarado, .sello--no_encaja { color: var(--error); background: var(--error-fondo); }
.sellos { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.veredicto { font-size: 1.1rem; padding: 0.35rem 0.9rem; }

/* ------------------------------------------------------------ avisos */

.avisos { margin: 0 0 1rem; }
.avisos:empty { display: none; }
.aviso {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radio-peq);
  border-left: 4px solid var(--neutro);
  background: var(--neutro-fondo);
  color: var(--texto);
  margin: 0 0 0.75rem;
}
.aviso p { margin: 0; }
.aviso--ok { border-left-color: var(--ok); background: var(--ok-fondo); }
.aviso--error { border-left-color: var(--error); background: var(--error-fondo); }
.aviso--aviso { border-left-color: var(--aviso); background: var(--aviso-fondo); }
.aviso__cerrar {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
  min-width: 40px; min-height: 40px;
  cursor: pointer;
}

/* ------------------------------------------------------------ cifras */

.cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin: 0.75rem 0; }
.cifra {
  background: var(--superficie-2);
  border-radius: var(--radio-peq);
  padding: 0.75rem 0.5rem;
  text-align: center;
}
.cifra__valor { display: block; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cifra__nombre { display: block; font-size: 0.8rem; color: var(--texto-suave); }
.cifra--principal .cifra__valor { color: var(--primario); font-size: 1.5rem; }

.tabla-economica { width: 100%; border-collapse: collapse; margin: 0.5rem 0; }
.tabla-economica th, .tabla-economica td { padding: 0.45rem 0.25rem; border-bottom: 1px solid var(--borde); text-align: left; }
.tabla-economica td { text-align: right; font-variant-numeric: tabular-nums; }
.tabla-economica tr.total th, .tabla-economica tr.total td { font-weight: 700; }

.formulas { font-family: var(--fuente-mono); font-size: 0.85rem; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ chat */

.chat { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.75rem; }
.mensaje {
  max-width: 92%;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radio);
  background: var(--superficie);
  border: 1px solid var(--borde);
}
.mensaje--usuario { justify-self: end; background: var(--superficie-2); }
.mensaje--asistente { justify-self: start; }
.mensaje__autor { display: block; font-size: 0.8rem; font-weight: 700; color: var(--texto-suave); margin-bottom: 0.25rem; }
.mensaje__texto { white-space: pre-wrap; margin: 0; }
.fichas-citadas { margin: 0.5rem 0 0; padding-left: 1.25rem; font-size: 0.875rem; }

/* ------------------------------------------------------------ QR y público */

.qr-caja { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.qr {
  width: 200px;
  height: 200px;
  background: #ffffff;
  border-radius: var(--radio-peq);
}

.ficha-publica__cabecera { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; }

.solo-impresion { display: none; }

/* ------------------------------------------------------------ pantallas medianas */

@media (min-width: 40rem) {
  h1 { font-size: 1.9rem; }
  main { padding: 1.5rem 1.5rem 4rem; }
  .rejilla { grid-template-columns: 1fr 1fr; }
  .rejilla--tres { grid-template-columns: 1fr 1fr 1fr; }
  .cabecera__usuario { display: inline; }
  .panel, .seccion { padding: 1.25rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------ impresión */

@media print {
  :root {
    --fondo: #ffffff; --superficie: #ffffff; --superficie-2: #f1f1f1;
    --texto: #000000; --texto-suave: #333333; --borde: #999999;
    --primario: #000000; --ok: #000000; --aviso: #000000; --error: #000000; --neutro: #000000;
    --ok-fondo: #ffffff; --aviso-fondo: #ffffff; --error-fondo: #ffffff; --neutro-fondo: #ffffff;
    --sombra: none;
  }
  @page { margin: 15mm; }
  body { background: #ffffff; color: #000000; font-size: 11pt; }
  .cabecera, .saltar, .avisos, .no-imprimir, button, .boton, form, #aviso-sesion { display: none !important; }
  .solo-impresion { display: block !important; }
  main { max-width: none; padding: 0; }
  .panel, .seccion, .tarjeta { box-shadow: none; border-color: #999999; break-inside: avoid; }
  a { color: #000000; text-decoration: none; }
  .qr { width: 35mm; height: 35mm; }
  .sello { border: 1px solid #000000; }
}
/* ------------------------------------------------------------ páginas legales */
.legal-enlaces { text-align: center; margin: 2rem 0 1rem; }
.legal h2 { margin-top: 1.5rem; }
.legal h3 { margin-top: 1.25rem; font-size: 1.05rem; }
.legal p, .legal li { max-width: 70ch; }
.legal .idioma { border-top: 1px solid var(--linea, #d9dee5); margin-top: 2rem; padding-top: 1.5rem; }
