/* Sistema de diseño «mapa narrativo» (ver DESIGN-ghibli-app.md): crema, verde pasto, esquinas redondeadas, solo modo claro.
   Modo híbrido: 640 px en login, formularios y errores; las pantallas con tablas y el visor usan más ancho. */

@font-face { font-family: "Quicksand"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/quicksand-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Quicksand"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/quicksand-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Quicksand"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/quicksand-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Quicksand"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/quicksand-latin-700-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #faf8f2; --card: #ffffff; --text: #2b2b2b; --muted: #6a675f;
  --primary: #212635; --primary-text: #faf8f2;
  --bar: #2f5d18; --bar-text: #faf8f2;
  --accent: #0b6fa4; --pink: #b0305f;
  --ok: #2f6b12; --warn: #9a4a06; --bad: #b42318;
  --line: #e4dfd2; --campo: #cfc9b8; --punteada: #d6d0bd; --borde-sec: #b9b39f;
  --sky-soft: #e3f3fb; --grass-soft: #eaf3df; --pink-soft: #fcebf2; --neutro: #eceae1;
  --r-sm: 15px; --r-md: 30px; --r-lg: 45px;
  --shadow: 0 2px 12px rgba(43, 43, 43, .06);
}

* { box-sizing: border-box; }
body { margin: 0; font: 400 16px/1.6 "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); padding-bottom: env(safe-area-inset-bottom); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* --- cabecera ------------------------------------------------------------------------------------- */
.barra { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  background: var(--bar); color: var(--bar-text); border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: 0 6px 18px rgba(47, 93, 24, .18); padding: calc(12px + env(safe-area-inset-top)) 18px 18px; }
.barra :focus-visible { outline-color: var(--bar-text); }
.marca { font-size: 20px; font-weight: 700; line-height: 1.25; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; margin-right: auto; margin-left: 1rem; }
.barra .enlace { display: inline-flex; align-items: center; min-height: 38px; padding: 0 12px; border-radius: var(--r-sm);
  color: var(--bar-text); font-weight: 600; text-decoration: none; }
.barra .enlace:hover { background: rgba(250, 248, 242, .14); text-decoration: none; }
.salir { display: flex; align-items: center; gap: .75rem; margin: 0; font-size: .9rem; font-weight: 500; }
.salir .boton, .salir .boton.secundario { min-height: 38px; background: transparent; color: var(--bar-text);
  border: 1.5px solid rgba(250, 248, 242, .55); }
.salir .boton:hover { background: rgba(250, 248, 242, .14); filter: none; box-shadow: none; }

/* --- estructura ----------------------------------------------------------------------------------- */
.contenido { max-width: 640px; margin: 0 auto; padding: 18px 16px 24px; }
.contenido:has(.tabla-contenedor), .contenido:has(.filtros) { max-width: 1100px; }
.contenido:has(.formulario.ancho) { max-width: 800px; }
.contenido:has(.visor) { max-width: 1200px; }

.contenido h1 { margin: .4rem 0 1rem; font-size: 2.25rem; font-weight: 700; line-height: 1.2; color: var(--bar); }
.contenido:not(:has(.tabla-contenedor, .filtros, .visor)) > h1 { text-align: center; }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.25; }
.encabezado-pagina { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.sub, .resumen, .vacio, .descargas, .nota, #estado { color: var(--muted); }
.sub { font-size: .92rem; font-weight: 500; }
.resumen, .vacio { margin: .5rem 0; }
.descargas, .nota { font-size: .88rem; margin: .6rem 0 0; }
#estado { font-size: .88rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }

/* --- tarjetas y formularios ------------------------------------------------------------------------ */
.tarjeta, .formulario, .filtros, .ficha, .vista { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-sm); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.tarjeta, .formulario, .filtros, .ficha, .vista { animation: rise .42s ease-out both; }
.contenido > :nth-child(2) { animation-delay: 80ms; }
.contenido > :nth-child(3) { animation-delay: 160ms; }

.formulario { display: grid; gap: 1rem; padding: 1.25rem; max-width: 640px; }
.formulario.ancho { max-width: none; }
.formulario > * { min-width: 0; }
label { font-size: 14px; font-weight: 500; letter-spacing: .01em; color: var(--muted); }
.formulario label { display: grid; gap: .3rem; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea {
  font: inherit; font-size: 16px; font-weight: 400; color: var(--text); background: var(--bg);
  padding: 12px 14px; border: 1px solid var(--campo); border-radius: var(--r-sm); }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select { height: 48px; }
.formulario input:not([type=hidden]):not([type=checkbox]):not([type=radio]), .formulario select, .formulario textarea { width: 100%; max-width: 100%; }
.formulario textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
.formulario small { font-weight: 400; color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--bar); width: 20px; height: 20px; }
.datos { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0 0 1rem; }
.datos dt { color: var(--muted); }
.datos dd { margin: 0; }

.filtros { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; }
.filtros label { display: flex; flex-direction: column; gap: .25rem; }
.filtros input, .filtros select { min-width: 9rem; }
.filtros .boton { min-height: 48px; }
@media (max-width: 600px) { .filtros label, .filtros input, .filtros select, .filtros .acciones, .filtros .boton { width: 100%; } }
.acciones { display: flex; align-items: center; gap: .75rem; }
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; font-size: .85rem; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* --- botones y enlaces ---------------------------------------------------------------------------- */
.boton { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px;
  border: 0; border-radius: var(--r-sm); background: var(--primary); color: var(--primary-text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .2s ease-out, box-shadow .2s ease-out, filter .2s ease-out; }
.boton:hover { filter: brightness(1.08); box-shadow: 0 4px 12px rgba(33, 38, 53, .18); }
.boton:active { transform: translateY(1px); box-shadow: none; }
.boton:disabled { opacity: .5; cursor: progress; }
.boton.secundario { background: transparent; color: var(--bar); border: 1.5px solid var(--borde-sec); }
.boton.secundario:hover { background: var(--grass-soft); filter: none; box-shadow: none; }
.boton.peligro { background: var(--bad); }
.enlace { color: var(--accent); text-decoration: none; }
.enlace:hover { text-decoration: underline; }

/* --- mensajes ------------------------------------------------------------------------------------- */
.aviso, .errores { padding: 10px 14px; border-radius: var(--r-sm); font-size: 14px; font-weight: 500; margin-bottom: 1rem; }
.aviso { background: color-mix(in srgb, var(--warn) 12%, #fff); color: var(--warn); }
.aviso.ok { background: var(--grass-soft); color: var(--ok); }
.aviso.error, .errores { background: color-mix(in srgb, var(--bad) 12%, #fff); color: var(--bad); }
.aviso.info { background: var(--sky-soft); color: #0a4f76; }
.aviso ul, .errores ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.aviso p { margin: .3rem 0; }

/* --- tablas --------------------------------------------------------------------------------------- */
.tabla-contenedor { overflow-x: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-sm); box-shadow: var(--shadow); }
.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th, .tabla td { text-align: left; padding: .6rem .75rem; border-bottom: 1px dashed var(--punteada); white-space: nowrap; }
.tabla th { background: var(--bg); font-weight: 700; border-bottom: 1px solid var(--line); }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover { background: color-mix(in srgb, var(--grass-soft) 55%, #fff); }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla tr.mas td { text-align: center; }
.etiqueta { display: inline-block; padding: .05rem .6rem; border-radius: 999px; background: var(--bg);
  border: 1px solid var(--line); font-size: 12px; font-weight: 600; }

/* --- visor ---------------------------------------------------------------------------------------- */
.visor { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; align-items: start; }
.visor > * { margin-bottom: 0; }
.ficha h1 { font-size: 1.25rem; margin: 0 0 .75rem; color: var(--text); text-align: left; }
.ficha dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem .75rem; margin: 0; font-size: .9rem; }
.ficha dt { color: var(--muted); }
.ficha dd { margin: 0; overflow-wrap: anywhere; }
.acciones-visor { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--neutro); }
.marco-impresion { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }
@media (max-width: 800px) { .visor { grid-template-columns: 1fr; } }

/* --- estado de cajas ------------------------------------------------------------------------------ */
.chip { display: inline-block; padding: .1rem .7rem; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--neutro); color: var(--text); margin-right: .4rem; }
.chip.e-reportando { background: var(--grass-soft); color: var(--ok); }
.chip.e-sin_reportar { background: color-mix(in srgb, var(--bad) 12%, #fff); color: var(--bad); }
.chip.e-con_errores { background: color-mix(in srgb, var(--warn) 12%, #fff); color: var(--warn); }
.resumen-estado { margin: .5rem 0 1rem; }
.error-corto { max-width: 22rem; white-space: normal !important; font-size: .85rem; color: var(--muted); }

/* --- movimiento ----------------------------------------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tarjeta, .formulario, .filtros, .ficha, .vista { animation: none; }
  .boton { transition: none; }
}
