:root {
  --navy: #09194E; --ink-muted: #4A5578; --surface: #FFFFFF; --muted: #F4F6FA;
  --border: #D5DAE5; --border-strong: #6B7699; --danger: #B3261E; --photo: #DCE3F0;
  --lime: #A3CD39; --amber: #FFCC00; --orange: #CF4800;
  --r-md: 10px; --r-card: 14px; --r-lg: 16px;
  --sombra: 0 1px 2px rgba(9,25,78,.12); --sombra-hoja: 0 -4px 16px rgba(9,25,78,.16);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--muted); color: var(--navy);
  font: 16px/24px Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
main { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(160px + env(safe-area-inset-bottom)); background: var(--muted); }
h1 { margin: 0; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.titulo-grande { font-size: 28px; line-height: 34px; }

/* Cabeceras (como las maquetas: fondo claro, título grande) */
.cab-lista { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px; }
.cab-sub { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.cab-form { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top)) 16px 8px; }
.cab-form-centro { text-align: center; }
.cab-form-centro h1 { font-size: 18px; line-height: 24px; font-weight: 600; }
.cab-form-centro p { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.cab-espacio { width: 44px; height: 44px; }
.btn-icono { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--sombra); border: 0; color: var(--navy); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.contenido { padding: 8px 16px 0; }
.seccion-tit { font-size: 18px; line-height: 24px; font-weight: 700; margin: 0; padding: 20px 16px 8px; }
.contenido .seccion-tit { padding-left: 0; padding-right: 0; }
#form-hallazgo { padding: 0 16px; }
#form-hallazgo .seccion-tit { padding-left: 0; padding-right: 0; }
.conteo { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ink-muted); padding: 4px 0 8px; }

/* Estado de sincronización */
.chip { padding: 6px 12px; border-radius: 999px; font-size: 13px; line-height: 18px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; background: #E6E9F0; color: var(--ink-muted); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.ok { background: #E8F3C8; color: #35560A; }
.chip.pend { background: #FFF3C2; color: #6B5200; }
.chip.off { background: #E6E9F0; color: var(--ink-muted); }

/* Tarjetas y campos */
.grupo-tarjetas { display: flex; flex-direction: column; gap: 12px; }
.tarjeta { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--sombra); padding: 12px 14px; }
.campo-etq-fijo { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-muted); margin-bottom: 8px; }
.ayuda-leg { font-weight: 400; margin-left: 4px; }
.campo { position: relative; background: var(--surface); border-radius: var(--r-card); box-shadow: var(--sombra); min-height: 60px; }
.campo-etq { position: absolute; top: 8px; left: 14px; right: 44px; z-index: 1; pointer-events: none; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-muted); margin: 0; }
.campo select, .fila-campo select {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--r-card); background-color: transparent;
  padding: 26px 44px 6px 14px; font: inherit; font-size: 16px; color: var(--navy); appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%234A5578' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; text-overflow: ellipsis;
}
.campo select:focus-visible, .fila-campo select:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.campo-texto { position: relative; padding: 26px 14px 10px; min-height: 60px; }
.campo-texto .campo-etq { position: absolute; }
.campo-texto input, .campo-texto textarea { width: 100%; border: 0; padding: 0; background: transparent; font: inherit; font-size: 16px; color: var(--navy); margin: 0; }
.campo-texto input:focus-visible, .campo-texto textarea:focus-visible { outline: none; }
.campo-texto:focus-within { outline: 2px solid var(--navy); outline-offset: 2px; }
.campo-texto textarea { min-height: 80px; resize: vertical; display: block; }
#txt-lugar, #txt-elemento { width: 100%; min-height: 52px; border: 1.5px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); padding: 10px 14px; font: inherit; font-size: 16px; color: var(--navy); }
::placeholder { color: #7a84a3; }

/* Botones */
button { font: inherit; }
button.primario, .boton-archivo.primario { background: var(--navy); color: #fff; border: 2px solid var(--navy); }
button.secundario, .boton-archivo.secundario { background: var(--surface); color: var(--navy); border: 2px solid var(--navy); }
button.grande, .boton-archivo { min-height: 52px; border-radius: 12px; font-weight: 600; font-size: 16px; line-height: 20px; padding: 0 20px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; transition: transform .08s ease; }
button:active, .boton-archivo:active { transform: scale(.985); }
button:disabled { opacity: .55; }
.error { color: var(--danger); font-weight: 600; font-size: 14px; line-height: 20px; }
.error:empty { display: none; }
.aviso-error { background: #F9DEDC; color: #8C1D18; border-radius: 12px; padding: 10px 12px; margin: 12px 0 0; font-weight: 400; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.grupo { margin: 0 0 14px; }
.grupo:last-child { margin-bottom: 0; }
.grupo-titulo { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-muted); margin: 0 0 8px; }
.chips button, .grupo button {
  width: auto; min-height: 44px; padding: 8px 16px; border-radius: 999px; font-size: 15px; font-weight: 600; line-height: 20px;
  background: var(--surface); color: var(--ink-muted); border: 1.5px solid var(--border); cursor: pointer;
}
.chips button[aria-pressed=true], .grupo button[aria-pressed=true] { background: var(--navy); color: #fff; border-color: var(--navy); }
.chips button[aria-pressed=true]::before, .grupo button[aria-pressed=true]::before { content: "\2713\00a0"; font-weight: 700; }

/* Prioridad (segmentos, como la maqueta) */
.prioridades { display: flex; gap: 8px; }
.prioridades button { flex: 1; min-height: 48px; padding: 10px 0; border-radius: 12px; font-size: 15px; font-weight: 600; background: var(--surface); color: var(--ink-muted); border: 1.5px solid var(--border); cursor: pointer; }
.prioridades button[aria-pressed=true] { background: var(--navy); color: #fff; border-color: var(--navy); }
.prioridades button[aria-pressed=true]::before { content: "\2713\00a0"; }

/* Fotos */
.fila-fotos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.boton-archivo { position: relative; }
.oculto-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; margin: 0; }
.miniaturas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.miniaturas:empty { display: none; }
.miniatura { position: relative; width: 104px; height: 104px; }
.miniatura img { width: 104px; height: 104px; object-fit: cover; border-radius: var(--r-card); background: var(--photo); }
.miniatura button { position: absolute; top: -8px; right: -8px; width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; background: var(--navy); color: #fff; border: 2px solid #fff; font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.nota { font-size: 13px; line-height: 18px; color: var(--ink-muted); padding: 8px 0 0; }

/* Barra de acción fija */
.barra-fija {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-width: 640px; margin: 0 auto; background: var(--surface); box-shadow: var(--sombra-hoja);
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 8px;
}
.barra-form .error { text-align: center; }

/* Lista: tarjetas como Pendientes */
.items { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.item { display: flex; gap: 12px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sombra); padding: 12px; }
.item .foto { flex: none; width: 76px; height: 76px; border-radius: var(--r-md); object-fit: cover; background: var(--photo); display: flex; align-items: center; justify-content: center; color: var(--ink-muted); }
.item .cuerpo { flex: 1; min-width: 0; }
.item .titulo { font-size: 15px; line-height: 20px; font-weight: 600; margin: 0; }
.item .meta { font-size: 13px; line-height: 18px; color: var(--ink-muted); margin: 0; }
.item .texto { font-size: 15px; line-height: 21px; margin: 2px 0 6px; }
.item .fila-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .pie-item { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; line-height: 18px; color: var(--ink-muted); margin-top: 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 8px; border-radius: 6px; font-size: 13px; line-height: 20px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.Alta { background: #FBE6DA; color: #8F3000; }
.badge.Media { background: #FFF3C2; color: #6B5200; }
.badge.Baja { background: #E6E9F0; color: var(--ink-muted); }
.badge.pend { background: #E6E9F0; color: var(--ink-muted); }
.badge.pend::before { content: none; }
.vacio { text-align: center; color: var(--ink-muted); padding: 28px 16px; background: var(--surface); border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); }
.vacio svg { color: var(--navy); }
.vacio p { margin-top: 6px; font-weight: 600; color: var(--navy); }
.vacio .vacio-ayuda { font-weight: 400; color: var(--ink-muted); font-size: 14px; }
.exportar-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.enlace-boton { display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 8px 12px; background: var(--surface); border: 2px solid var(--navy); border-radius: 12px; color: var(--navy); font-weight: 600; text-decoration: none; text-align: center; font-size: 15px; line-height: 20px; }

/* Acceso (logo blanco sobre navy, como el Design System) */
.pantalla-login { background: var(--navy); color: #fff; display: flex; align-items: center; padding: 32px 24px 96px; }
.login-cuerpo { width: 100%; max-width: 420px; margin: 0 auto; }
.login-logo { display: block; margin: 0 0 28px; height: auto; max-width: 62%; }
.pantalla-login .titulo-grande { color: #fff; }
.login-sub { color: #C9D1EC; margin: 6px 0 28px; font-size: 15px; line-height: 22px; }
.pantalla-login .campo-texto { background: #fff; box-shadow: none; }
.pantalla-login button.primario { background: var(--lime); color: var(--navy); border-color: var(--lime); font-weight: 700; }
.pantalla-login .grande { margin-top: 16px; }
.pantalla-login :focus-visible { outline-color: var(--amber); }
.pantalla-login .campo-texto:focus-within { outline-color: var(--amber); }

/* Informe imprimible */
body.informe { background: #fff; max-width: 900px; margin: 0 auto; padding: 0 20px 40px; }
body.informe .portada { background: var(--navy); margin: 0 -20px; padding: 26px 20px 4px; }
body.informe .portada img { display: block; }
body.informe h1 { background: var(--navy); color: #fff; margin: 0 -20px 0; padding: 14px 20px 8px; font-size: 26px; line-height: 32px; }
body.informe .sub { background: var(--navy); color: #C9D1EC; margin: 0 -20px 20px; padding: 0 20px 22px; }
body.informe h2 { color: var(--navy); border-bottom: 3px solid var(--lime); font-size: 20px; margin: 30px 0 8px; padding: 0 0 6px; }
.hallazgo { break-inside: avoid; border: 1px solid var(--border); border-left: 6px solid var(--navy); border-radius: 10px; padding: 12px 16px; margin: 14px 0; background: #fff; }
.hallazgo h3 { margin: 0 0 6px; font-size: 17px; }
.hallazgo p { margin: 4px 0; color: #22305e; }
.hallazgo .badge { margin-right: 6px; }
.fotos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fotos img { width: 220px; height: 165px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.barra-informe { margin: 16px 0; }
.barra-informe button { width: auto; min-height: 44px; padding: 0 18px; background: var(--navy); color: #fff; border: 2px solid var(--navy); border-radius: 12px; font-weight: 600; cursor: pointer; }
@media print { .barra-informe { display: none; } body.informe { padding: 0; } body.informe h1, body.informe .sub, body.informe .portada { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
@media (min-width: 768px) { main { box-shadow: 0 0 0 1px var(--border); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===== Layout por paneles (v3) ===== */
.panel { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sombra); overflow: hidden; }
.panel > * + * { border-top: 1px solid var(--border); }
.fila { padding: 14px 16px; }
.fila .campo-etq-fijo { margin-bottom: 10px; }
.fila-campo { position: relative; min-height: 64px; }
.fila-campo .campo-etq { top: 10px; left: 16px; }
.fila-campo select { padding: 28px 44px 8px 16px; border-radius: 0; }
.fila-campo select:focus-visible { outline-offset: -2px; }
.fila-texto { position: relative; padding: 30px 16px 12px; }
.fila-texto .campo-etq { position: absolute; top: 10px; left: 16px; }
.fila-texto textarea { width: 100%; border: 0; padding: 0; margin: 0; background: transparent; font: inherit; font-size: 16px; color: var(--navy); min-height: 72px; resize: vertical; display: block; }
.fila-texto textarea:focus-visible { outline: none; }
.fila-texto:focus-within { box-shadow: inset 0 0 0 2px var(--navy); }
#txt-lugar, #txt-elemento { display: block; border: 0; border-radius: 0; min-height: 56px; padding: 14px 16px; background: #FBFCFE; }
#txt-lugar:focus-visible, #txt-elemento:focus-visible { outline: 2px solid var(--navy); outline-offset: -2px; }
.seccion-tit { padding-top: 28px; display: flex; align-items: center; gap: 10px; }
.seccion-tit::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--navy); }
.contenido .seccion-tit::before { display: none; }

/* Pisos en cuadrícula pareja */
.rejilla { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rejilla button { width: 100%; min-height: 48px; border-radius: 12px; padding: 6px 8px; font-size: 15px; line-height: 18px; }

/* Observaciones plegables */
.fila-obs { padding-bottom: 12px; }
.fila-obs .campo-etq-fijo { margin-bottom: 0; }
.obs-resumen { margin-top: 8px; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--navy); background: #E6E9F0; border-radius: 8px; padding: 6px 10px; }
.acordeon { border-top: 1px solid var(--border); }
.acordeon summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; cursor: pointer; font-weight: 600; }
.acordeon summary::-webkit-details-marker { display: none; }
.acordeon summary::after {
  content: ""; margin-left: auto; width: 22px; height: 22px; flex: none; transition: transform .15s ease;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%234A5578' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
}
.acordeon[open] summary::after { transform: rotate(180deg); }
.acordeon summary:focus-visible { outline: 2px solid var(--navy); outline-offset: -2px; }
.cuenta { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 13px; line-height: 24px; text-align: center; font-weight: 700; }
.acordeon-cuerpo { padding: 2px 16px 16px; }
.acordeon-cuerpo button { min-height: 42px; font-size: 14px; padding: 6px 14px; }
.panel .prioridades button { min-height: 48px; }

/* ===== Hoja inferior «¿qué sigue?» ===== */
.hoja-fondo { position: fixed; inset: 0; z-index: 30; background: rgba(9,25,78,.5); display: flex; align-items: flex-end; justify-content: center; }
.hoja { width: 100%; max-width: 640px; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--sombra-hoja); padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
.hoja-cab { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.hoja-cab h2 { margin: 0; font-size: 20px; line-height: 26px; font-weight: 700; padding: 0; text-transform: none; letter-spacing: 0; color: var(--navy); }
.hoja-cab h2::before { display: none; }
.hoja-cab p { font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.hoja-ok { flex: none; width: 40px; height: 40px; border-radius: 50%; background: #E8F3C8; color: #35560A; display: inline-flex; align-items: center; justify-content: center; }
.hoja-opciones { display: flex; flex-direction: column; gap: 10px; }
.op { width: 100%; min-height: 64px; border-radius: 12px; padding: 10px 16px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; cursor: pointer; font: inherit; }
.op-tit { font-size: 16px; line-height: 22px; font-weight: 700; }
.op-sub { font-size: 13px; line-height: 18px; opacity: .85; }
.op-primaria { background: var(--navy); color: #fff; border: 2px solid var(--navy); }
.op-sec { background: var(--surface); color: var(--navy); border: 2px solid var(--navy); }
.op-texto { background: transparent; color: var(--ink-muted); border: 0; min-height: 52px; align-items: center; text-align: center; }
.op-texto .op-tit { font-weight: 600; }
.op:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* Campo obligatorio faltante */
.panel .invalido { background: #FDECEA; box-shadow: inset 0 0 0 2px var(--danger); }
.panel .invalido .campo-etq, .panel .invalido .campo-etq-fijo { color: var(--danger); }
#txt-lugar.invalido, #txt-elemento.invalido { background: #FDECEA; }
.panel .invalido select { background-color: transparent; }

/* Barra de marca (lista): logo blanco sobre navy + usuario */
.barra-marca { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.barra-logo { display: block; height: 48px; width: auto; }
.barra-usuario { display: flex; align-items: center; gap: 10px; font-size: 15px; line-height: 20px; font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--lime); color: var(--navy); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
