/* Fuentes en la propia app, para que funcione sin conexión */
@font-face {
  font-family: 'Figtree';
  src: url('../fonts/figtree.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('../fonts/bricolage-grotesque-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --papel: #e6eff5;
  --papel-claro: #f8fbfd;
  --tinta: #1b2c38;
  --tinta-suave: #4a5e6c;
  --linea: #c6d6e1;
  --marino: #375971;
  --marino-oscuro: #26404f;
  --terracota: #cd6d28;
  --naranja-texto: #ab4e00;
  --naranja: #ec7005;
  --tinta-oscura: #14232e;
  --amarillo: #f9ce1e;
  --amarillo-tinta: #3d2f00;
  --cielo: #a3d3ea;
  --azul: #549ecd;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(27, 44, 56, .08), 0 6px 18px rgba(27, 44, 56, .07);
  --titulos: 'Bricolage Grotesque', 'Segoe UI', sans-serif;
  --texto: 'Figtree', 'Segoe UI', sans-serif;
  --alto-nav: 68px;
}

* { box-sizing: border-box; margin: 0; }

[hidden] { display: none !important; }

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

body {
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--texto);
  font-size: 1rem;
  line-height: 1.45;
  padding-bottom: calc(var(--alto-nav) + env(safe-area-inset-bottom) + 1rem);
}

a { color: inherit; }

:focus-visible { outline: 3px solid var(--marino); outline-offset: 2px; }

.saltar {
  position: absolute;
  left: .75rem;
  top: -4rem;
  z-index: 100;
  padding: .7rem 1rem;
  background: var(--marino);
  color: #fff;
  border-radius: 8px;
}
.saltar:focus { top: .75rem; }

.container { width: 100%; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 3rem); }

h1, h2 { font-family: var(--titulos); font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 7vw, 2.5rem); }
h2 { font-size: 1.3rem; }

/* Toque naranja bajo el título de cada pantalla */
.cabecera h1::after,
.ficha-cabecera h1::after {
  content: '';
  display: block;
  width: 2.75rem;
  height: 5px;
  margin-top: .55rem;
  border-radius: 3px;
  background: var(--naranja);
}

.cabecera { padding: 1.6rem 0 1.1rem; }
.cabecera p { margin-top: .4rem; color: var(--tinta-suave); }
.cabecera strong { color: var(--naranja-texto); }

.seccion { margin-top: 1.5rem; }
.seccion > h2 { margin-bottom: .8rem; }

/* Filtros */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .25rem 0 .5rem;
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 44px;
  padding: 0 1rem;
  border: 1.5px solid var(--linea);
  border-radius: 99px;
  background: var(--papel-claro);
  color: var(--tinta);
  font: 500 .95rem var(--texto);
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--persona, var(--marino)); border-color: var(--persona, var(--marino)); color: var(--persona-texto, #fff); }
.chips .chip[aria-pressed="true"]::before { background: var(--persona-texto, #fff); }

.busqueda {
  display: grid;
  grid-template-columns: 1fr;
  gap: .6rem;
  margin-bottom: .6rem;
}

/* Tarjetas con el resguardo de dias restantes */
.tarjetas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: .75rem;
  list-style: none;
  padding: 0;
}

.tarjeta {
  display: grid;
  grid-template-columns: 84px 1fr;
  min-height: 104px;
  background: var(--papel-claro);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  text-decoration: none;
  overflow: hidden;
  transition: transform .15s ease;
}
.tarjeta:active { transform: scale(.985); }

.resguardo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .5rem .25rem;
  border-right: 2px dashed rgba(255, 255, 255, .55);
  color: #fff;
  text-align: center;
}
.resguardo b { font: 600 2.1rem/1 var(--titulos); }
.resguardo span { font-size: .78rem; font-weight: 600; }

.urgente .resguardo { background: var(--naranja); color: var(--tinta-oscura); border-right-color: rgba(20, 35, 46, .35); }
.pronto .resguardo { background: var(--amarillo); color: var(--amarillo-tinta); border-right-color: rgba(61, 47, 0, .35); }
.al-dia .resguardo { background: var(--cielo); color: var(--tinta); border-right-color: rgba(27, 44, 56, .3); }

.tarjeta__cuerpo { padding: .8rem .9rem; min-width: 0; }
.tarjeta__titulo { font-weight: 700; font-size: 1.05rem; }
.tarjeta__dato { color: var(--tinta-suave); font-size: .92rem; }

/* Color de cada persona, siempre de la paleta: punto fuerte y fondo suave de la etiqueta */
[data-color] { --persona: var(--marino); --persona-suave: #d5e4ee; --persona-texto: #fff; }
[data-color="azul"] { --persona: var(--azul); --persona-suave: #dcebf6; --persona-texto: var(--tinta-oscura); }
[data-color="cielo"] { --persona: var(--cielo); --persona-suave: #d3eaf5; --persona-texto: var(--tinta-oscura); }
[data-color="amarillo"] { --persona: var(--amarillo); --persona-suave: #fcf0bf; --persona-texto: var(--tinta-oscura); }
[data-color="terracota"] { --persona: var(--terracota); --persona-suave: #f6e1d2; --persona-texto: #0b141b; }
[data-color="naranja"] { --persona: var(--naranja); --persona-suave: #fde3cc; --persona-texto: var(--tinta-oscura); }

.persona {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: .4rem;
  padding: .1rem .55rem;
  border-radius: 6px;
  background: var(--persona-suave);
  font-size: .82rem;
  font-weight: 600;
}
.persona::before,
.chip[data-color]::before,
.opciones [data-color] span::before,
.colores span::before {
  content: '';
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  background: var(--persona);
  box-shadow: inset 0 0 0 1px rgba(20, 35, 46, .3);
  flex: none;
}

.vacio {
  padding: 1.5rem 1rem;
  border: 1.5px dashed var(--linea);
  border-radius: var(--radio);
  color: var(--tinta-suave);
  text-align: center;
}

/* Formularios */
label, .etiqueta { display: block; margin-bottom: .35rem; font-weight: 600; font-size: .95rem; }

input[type="text"], input[type="search"], input[type="tel"], input[type="date"], input[type="password"],
select, textarea {
  width: 100%;
  min-height: 48px;
  padding: .6rem .8rem;
  border: 1.5px solid #7a8d9b;
  border-radius: 10px;
  background: var(--papel-claro);
  color: var(--tinta);
  font: 400 16px var(--texto);
}
textarea { min-height: 96px; resize: vertical; }

[aria-invalid="true"] { border-color: var(--naranja-texto); }

/* minmax(0, 1fr): sin esto, el ancho propio del campo de fecha y el de archivo ensanchan la pagina en movil */
.formulario { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.1rem; max-width: 640px; padding: 0; border: 0; }
.campo-doble { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.ayuda { margin-top: .3rem; color: var(--tinta-suave); font-size: .86rem; }

fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: .35rem; font-weight: 600; font-size: .95rem; }

.opciones { display: flex; flex-wrap: wrap; gap: .5rem; }
.opciones label { margin: 0; }
.opciones input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opciones span {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border: 1.5px solid #7a8d9b;
  border-radius: 99px;
  background: var(--papel-claro);
  font-weight: 500;
  cursor: pointer;
}
.opciones span { gap: .45rem; }
.opciones input:checked + span { background: var(--persona, var(--marino)); border-color: var(--persona, var(--marino)); color: var(--persona-texto, #fff); }
.opciones input:checked + span::before { background: var(--persona-texto, #fff); }
.opciones input:focus-visible + span { outline: 3px solid var(--marino); outline-offset: 2px; }

.casilla { display: flex; align-items: center; gap: .6rem; min-height: 44px; margin: 0; font-weight: 500; }
.casilla input { width: 22px; height: 22px; accent-color: var(--marino); }

.subida {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .5rem;
  padding: 1rem;
  border: 1.5px dashed #7a8d9b;
  border-radius: var(--radio);
  background: var(--papel-claro);
}
.subida input { font: 400 16px var(--texto); max-width: 100%; }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  min-height: 50px;
  padding: 0 1.2rem;
  border: 1.5px solid transparent;
  border-radius: 12px;
  font: 600 1rem var(--texto);
  text-decoration: none;
  cursor: pointer;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-principal { background: var(--marino); color: #fff; }
.btn-principal:hover { background: var(--marino-oscuro); }
.btn-secundario { background: transparent; border-color: var(--marino); color: var(--marino); }

.estado { min-height: 1.4em; font-weight: 600; }
.estado.error { color: var(--naranja-texto); }
.estado.ok { color: var(--marino); }

/* Ficha */
.volver {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  min-height: 44px;
  margin-top: .4rem;
  color: var(--naranja-texto);
  font-weight: 600;
  text-decoration: none;
}
.volver svg { width: 18px; height: 18px; }

.ficha-cabecera { padding-bottom: 1rem; }
.ficha-cabecera p { color: var(--tinta-suave); margin-top: .3rem; }

.cuenta-atras {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radio);
  color: var(--amarillo-tinta);
  background: var(--amarillo);
}
.cuenta-atras b { font: 600 3rem/1 var(--titulos); }
.cuenta-atras strong { display: block; }

.bloque {
  padding: .3rem 1rem;
  border-radius: var(--radio);
  background: var(--papel-claro);
  box-shadow: var(--sombra);
}

.datos > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--linea);
}
.datos > div:last-child { border-bottom: 0; }
.datos dt { color: var(--tinta-suave); }
.datos dd { margin: 0; font-weight: 600; text-align: right; }

.documentos { list-style: none; }
.documentos li { border-bottom: 1px solid var(--linea); }
.documentos li:last-child { border-bottom: 0; }

.cuenta-atras.urgente { background: var(--naranja); color: var(--tinta-oscura); }
.cuenta-atras.al-dia { background: var(--cielo); color: var(--tinta); }


.documentos li { display: flex; align-items: center; gap: .5rem; }

.borrar-doc {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--tinta-suave);
  cursor: pointer;
}
.borrar-doc svg { width: 20px; height: 20px; color: inherit; }

.subida--ficha { margin-top: .75rem; }

.btn-peligro { background: transparent; border-color: var(--naranja-texto); color: var(--naranja-texto); }

.aviso {
  padding-top: .75rem;
  padding-bottom: .75rem;
  background: var(--marino);
  color: #fff;
  font-weight: 600;
}

.enlace {
  min-height: 44px;
  padding: 0 1rem;
  border: 0;
  background: none;
  color: var(--tinta-suave);
  font: 600 .92rem var(--texto);
  text-decoration: underline;
  cursor: pointer;
}
.credito { margin-top: .5rem; }

.acciones { display: grid; gap: .6rem; margin-top: 1.5rem; }
.acciones-fila { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .6rem; }
.accion {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  min-height: 72px;
  padding: .5rem .25rem;
  border: 0;
  border-radius: 12px;
  background: var(--marino);
  color: #fff;
  font: 500 1.1rem var(--texto);
  text-decoration: none;
  cursor: pointer;
}
.accion svg { width: 26px; height: 26px; }
.accion--peligro { background: var(--naranja); }
.accion--azul { background: var(--azul); }
.accion:focus-visible { outline: 3px solid var(--tinta-oscura); outline-offset: 3px; }
.pantalla-ancha { max-width: 640px; }

/* Barra inferior */
.barra {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: center;
  height: calc(var(--alto-nav) + env(safe-area-inset-bottom));
  padding: 0 .5rem env(safe-area-inset-bottom);
  background: var(--marino-oscuro);
  color: #fff;
}
.barra a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  opacity: .78;
}
.barra a[aria-current="page"] { opacity: 1; color: var(--amarillo); }
.barra svg { width: 24px; height: 24px; }
.barra :focus-visible { outline-color: #fff; }
.barra .barra__nueva {
  width: 60px;
  height: 60px;
  margin-top: -22px;
  border: 4px solid var(--papel);
  border-radius: 50%;
  background: var(--amarillo);
  color: var(--amarillo-tinta);
  opacity: 1;
}
.barra .barra__nueva[aria-current="page"] { color: var(--amarillo-tinta); }
.barra .barra__nueva svg { width: 28px; height: 28px; }

.credito {
  margin-top: 2.5rem;
  color: var(--tinta-suave);
  font-size: .8rem;
  text-align: center;
}
.credito a { text-decoration: none; }

/* ---------- App en el móvil ---------- */
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cargando { padding: 2rem 0; color: var(--tinta-suave); }

/* Primera vez */
.pasos { display: grid; gap: .6rem; max-width: 640px; margin: .5rem 0 1rem; padding-left: 1.4rem; }
.pasos li::marker { color: var(--naranja-texto); font-weight: 700; }
.nota { max-width: 640px; margin-bottom: 1rem; color: var(--tinta-suave); font-size: .92rem; }
.pantalla-ancha + .pantalla-ancha { margin-top: .6rem; }

/* Recordatorio de copia de seguridad */
.recordatorio {
  display: block;
  max-width: 640px;
  margin-bottom: 1rem;
  padding: .8rem 1rem;
  border-radius: var(--radio);
  background: var(--papel-claro);
  box-shadow: var(--sombra);
  font-size: .92rem;
  text-decoration: none;
}
.recordatorio strong { display: block; }
.recordatorio__enlace { color: var(--marino); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Personas */
.lista-personas { list-style: none; max-width: 640px; }
.lista-personas li {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 60px;
  border-bottom: 1px solid var(--linea);
}
.lista-personas li:last-child { border-bottom: 0; }
.lista-personas .persona { margin: 0; font-size: .95rem; padding: .25rem .65rem; white-space: nowrap; }
.lista-personas small { flex: 1; color: var(--tinta-suave); font-size: .85rem; }
#zona-tipos { margin-top: 2.5rem; }
.intro { max-width: 640px; margin: .3rem 0 .9rem; color: var(--tinta-suave); }
.subseccion { margin-top: 1.4rem; }
h3 { margin-bottom: .7rem; font-size: 1.05rem; }
.nombre-tipo { font-weight: 600; }
.lista__texto { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lista__texto small { display: block; }
.lista-tipos li { min-height: 56px; }

.btn-pequeno {
  min-height: 44px;
  padding: 0 .9rem;
  border: 1.5px solid var(--marino);
  border-radius: 10px;
  background: transparent;
  color: var(--marino);
  font: 600 .9rem var(--texto);
  cursor: pointer;
}

.colores { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.colores label { margin: 0; }
.colores input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.colores span {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 48px;
  padding: 0 .9rem;
  border: 1.5px solid var(--linea);
  border-radius: 12px;
  background: var(--papel-claro);
  font-weight: 500;
  cursor: pointer;
}
.colores span::before { width: 1.2rem; height: 1.2rem; }
.colores input:checked + span { border: 3px solid var(--marino); padding: 0 calc(.9rem - 1.5px); font-weight: 700; }
.colores input:focus-visible + span { outline: 3px solid var(--marino); outline-offset: 2px; }

/* Ficha */
.ficha-cabecera .persona { margin-top: .5rem; }
.bloque--relleno { display: grid; gap: .75rem; padding: 1rem; }
.tipo-nuevo { margin-top: .9rem; }
.avisos { display: grid; gap: .6rem; padding: 1rem; }
.avisos .enlace { justify-self: start; padding: 0; }
/* Blanco sobre naranja solo llega al contraste mínimo con texto grande y en negrita (19px, 700) */
.btn-aviso { background: var(--naranja); color: #fff; font-size: 1.35rem; line-height: 1.25; font-weight: 700; padding: .6rem 1rem; text-align: center; }
.btn-aviso small { display: block; font-size: 1.2rem; font-weight: 700; }
.btn-aviso:focus-visible { outline: 3px solid var(--marino-oscuro); outline-offset: 3px; }
.datos__notas { flex-direction: column; gap: .2rem !important; }
.datos__notas dd { text-align: left !important; font-weight: 400 !important; }

.doc-abrir {
  display: flex;
  flex: 1;
  align-items: center;
  gap: .75rem;
  min-width: 0;
  min-height: 56px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: 600 1rem var(--texto);
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.doc-abrir svg { width: 24px; height: 24px; flex: none; color: var(--naranja); }
.doc-abrir small { display: block; color: var(--tinta-suave); font-weight: 400; font-size: .85rem; }

.acciones--juntas { margin-top: 0; }
label.btn { margin: 0; }

/* Selector de archivos en español (el input nativo está oculto) */
.elegir-archivo { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.elegir-archivo .btn { width: auto; }
.elegir-archivo span { min-width: 0; overflow-wrap: anywhere; color: var(--tinta-suave); font-size: .95rem; }
input.oculto:focus-visible + .elegir-archivo .btn { outline: 3px solid var(--marino); outline-offset: 2px; }

/* Visor de fotos */
.visor {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: .5rem;
  padding: calc(env(safe-area-inset-top) + .75rem) .75rem .75rem;
  background: rgba(20, 35, 46, .94);
}
.visor img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.visor__cerrar {
  justify-self: end;
  min-height: 44px;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 99px;
  background: var(--papel-claro);
  color: var(--tinta);
  font: 600 1rem var(--texto);
  cursor: pointer;
}

@media (min-width: 720px) {
  .busqueda { grid-template-columns: 2fr 1fr; }
  .acciones { grid-template-columns: repeat(auto-fit, minmax(200px, 300px)); }
  .acciones--juntas { grid-template-columns: 1fr; }
}

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