:root {
  --rcp: #c8102e;
  --rcp-osc: #9e0c24;
  --rcp-claro: #fdecef;
  --fondo: #f4f6f9;
  --bs-primary: #c8102e;
  --bs-primary-rgb: 200, 16, 46;
  --bs-link-color: #b30e29;
  --bs-link-hover-color: #7d0a1d;
  --bs-border-radius: .6rem;
}
body { background: var(--fondo); font-feature-settings: "tnum"; }
body.con-menu { padding-bottom: 76px; }
@media (min-width: 992px) { body.con-menu { padding-bottom: 0; } }

.btn-primary { --bs-btn-bg: var(--rcp); --bs-btn-border-color: var(--rcp); --bs-btn-hover-bg: var(--rcp-osc); --bs-btn-hover-border-color: var(--rcp-osc); --bs-btn-active-bg: var(--rcp-osc); --bs-btn-disabled-bg: var(--rcp); --bs-btn-disabled-border-color: var(--rcp); }
.btn-outline-primary { --bs-btn-color: var(--rcp); --bs-btn-border-color: var(--rcp); --bs-btn-hover-bg: var(--rcp); --bs-btn-hover-border-color: var(--rcp); --bs-btn-active-bg: var(--rcp-osc); }
.text-rcp { color: var(--rcp) !important; }
.form-control:focus, .form-select:focus { border-color: #e88a99; box-shadow: 0 0 0 .2rem rgba(200,16,46,.15); }

.barra { background: linear-gradient(90deg, var(--rcp-osc), var(--rcp)); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.barra .nav-link { color: rgba(255,255,255,.85); border-radius: .5rem; }
.barra .nav-link:hover, .barra .nav-link.active { color: #fff; background: rgba(255,255,255,.14); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.25); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }

.tarjeta { background: #fff; border: 1px solid #e7eaef; border-radius: .9rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.tarjeta > .cab { padding: .85rem 1.1rem; border-bottom: 1px solid #eef0f3; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.tarjeta > .cab h2, .tarjeta > .cab h3 { font-size: 1rem; font-weight: 650; margin: 0; }
.tarjeta > .cuerpo { padding: 1.1rem; }
.titulo-pag { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.titulo-pag h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.titulo-pag .sub { color: #6c757d; font-size: .9rem; }

.kpi { display: block; text-decoration: none; color: inherit; padding: 1rem 1.1rem; border-radius: .9rem; background: #fff; border: 1px solid #e7eaef; height: 100%; transition: transform .12s, box-shadow .12s; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,24,40,.08); color: inherit; }
.kpi .num { font-size: 2rem; font-weight: 750; line-height: 1.1; }
.kpi .et { color: #6c757d; font-size: .85rem; }
.kpi .ico { font-size: 1.5rem; float: right; opacity: .85; }
.kpi.rojo .num, .kpi.rojo .ico { color: #c8102e; }
.kpi.ambar .num, .kpi.ambar .ico { color: #d98a00; }
.kpi.verde .num, .kpi.verde .ico { color: #198754; }
.kpi.azul .num, .kpi.azul .ico { color: #2563eb; }

.sem { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.sem::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.sem-verde { color: #146c43; background: #e8f5ee; }
.sem-ambar { color: #9a6200; background: #fff4dc; }
.sem-rojo { color: #b00d28; background: #fdecef; }
.sem-gris { color: #6c757d; background: #f1f3f5; }

.table > :not(caption) > * > * { padding: .6rem .7rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #6c757d; font-weight: 600; background: #fafbfc; }
.table-hover tbody tr { cursor: pointer; }
.fila-link { cursor: pointer; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.vacio { text-align: center; color: #8a939d; padding: 2.5rem 1rem; }
.vacio i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .5; }
.dato .et { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #8a939d; }
.dato .val { font-weight: 550; word-break: break-word; }

/* Tablas → tarjetas en móvil */
@media (max-width: 767.98px) {
  .tabla-tarjetas thead { display: none; }
  .tabla-tarjetas, .tabla-tarjetas tbody, .tabla-tarjetas tr, .tabla-tarjetas td { display: block; width: 100%; }
  .tabla-tarjetas tr { background: #fff; border: 1px solid #e7eaef; border-radius: .8rem; margin-bottom: .6rem; padding: .5rem .2rem; }
  .tabla-tarjetas td { border: 0 !important; padding: .2rem .8rem !important; }
  .tabla-tarjetas td[data-et]::before { content: attr(data-et); display: inline-block; min-width: 7.5rem; color: #8a939d; font-size: .78rem; }
  .tabla-tarjetas td.principal { font-weight: 650; font-size: 1.02rem; }
}

/* Barra inferior en móvil */
.barra-movil { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; background: #fff; border-top: 1px solid #e7eaef; display: flex; justify-content: space-around; align-items: center; padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.barra-movil a { flex: 1; text-align: center; color: #6c757d; text-decoration: none; font-size: .7rem; display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.barra-movil a i { font-size: 1.3rem; }
.barra-movil a.active { color: var(--rcp); }
.barra-movil a.nueva { flex: 0 0 auto; width: 56px; height: 56px; margin-top: -26px; border-radius: 50%; background: var(--rcp); color: #fff; justify-content: center; box-shadow: 0 6px 16px rgba(200,16,46,.4); }
.barra-movil a.nueva i { font-size: 1.7rem; }

/* Login */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(circle at 20% 10%, #ffe3e8 0, transparent 40%), radial-gradient(circle at 90% 90%, #ffe9ec 0, transparent 40%), var(--fondo); }
.acceso .caja { width: 100%; max-width: 410px; }
.acceso .logo { width: 64px; height: 64px; }
.latido { animation: latido 1.6s ease-in-out infinite; transform-origin: center; }
@keyframes latido { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.12); } 30% { transform: scale(1); } 45% { transform: scale(1.08); } }

/* Asistente de revisión */
.pasos { display: flex; gap: .35rem; margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.pasos button { flex: 1 0 auto; border: 0; background: #e9ecef; color: #6c757d; border-radius: 999px; padding: .4rem .8rem; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.pasos button.hecho { background: #e8f5ee; color: #146c43; }
.pasos button.actual { background: var(--rcp); color: #fff; }
.paso { margin-bottom: 1.5rem; scroll-margin-top: 70px; }
.seccion-rev { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: .55rem; margin: .5rem 0 .75rem; }
.seccion-rev span { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--rcp); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .9rem; }
.paso.con-error .seccion-rev { color: var(--rcp); }
.nav-pasos { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--fondo) 30%); padding: 1rem 0 .5rem; display: flex; gap: .6rem; z-index: 5; }
body.con-menu .nav-pasos { bottom: 72px; }
@media (min-width: 992px) { body.con-menu .nav-pasos { bottom: 0; } }
.nav-pasos .btn { flex: 1; padding: .75rem; font-weight: 650; }

.check-fila { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid #eef0f3; }
.check-fila:last-child { border-bottom: 0; }
.check-fila .txt { font-size: .95rem; }
.check-fila.falta .txt { color: var(--rcp); font-weight: 600; }
.tri { display: inline-flex; border-radius: .6rem; overflow: hidden; border: 1px solid #dee2e6; flex-shrink: 0; }
.tri input { display: none; }
.tri label { padding: .45rem .7rem; font-size: .82rem; font-weight: 650; cursor: pointer; color: #6c757d; background: #fff; user-select: none; min-width: 44px; text-align: center; }
.tri label + input + label, .tri label:not(:first-of-type) { border-left: 1px solid #dee2e6; }
.tri input.ok:checked + label { background: #198754; color: #fff; }
.tri input.defecto:checked + label { background: #c8102e; color: #fff; }
.tri input.na:checked + label { background: #6c757d; color: #fff; }

.resultado-caja { border-radius: .9rem; padding: 1rem 1.2rem; color: #fff; font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: .6rem; }
.resultado-caja.apto { background: #198754; }
.resultado-caja.apto_obs { background: #d98a00; }
.resultado-caja.no_apto { background: #c8102e; }

.firma-caja { border: 2px dashed #ced4da; border-radius: .8rem; background: #fff; position: relative; touch-action: none; }
.firma-caja canvas { width: 100%; height: 190px; display: block; border-radius: .8rem; }
.firma-caja .borrar { position: absolute; top: .4rem; right: .4rem; }
.firma-caja .pista { position: absolute; left: 0; right: 0; bottom: 2.2rem; text-align: center; color: #c2c8cf; pointer-events: none; font-size: .9rem; }
.firma-caja .linea { position: absolute; left: 10%; right: 10%; bottom: 2rem; border-bottom: 1px solid #dee2e6; pointer-events: none; }

.resultado-busqueda { max-height: 320px; overflow-y: auto; }
.resultado-busqueda .list-group-item { cursor: pointer; }
.borrador-aviso { background: #fff8e6; border: 1px solid #ffe0a3; border-radius: .7rem; }
.foto-mini { width: 84px; height: 84px; object-fit: cover; border-radius: .5rem; border: 1px solid #e7eaef; }
.estado-red { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 1050; }

@media print { .no-print { display: none !important; } body { background: #fff; padding: 0 !important; } }

/* ===== Formulario de revisión (mismo planteamiento que el de la v1) ===== */
.form-rev { max-width: 1000px; }
.titulo-form { text-align: center; color: var(--rcp); font-weight: 700; font-size: 1.9rem; margin: .5rem 0 1.25rem; }
.bloque { background: #fff; border-radius: 1rem; border-left: 5px solid var(--rcp); box-shadow: 0 2px 10px rgba(16,24,40,.07); padding: 1.1rem 1.25rem 1.25rem; margin-bottom: 1.25rem; }
.bloque h2 { color: var(--rcp); font-size: 1.35rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; margin: 0 0 .9rem; }
.bloque .form-label { font-size: .88rem; margin-bottom: .25rem; }
.rejilla-casillas { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem 1rem; }
.rejilla-casillas.cuatro { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 767.98px) { .rejilla-casillas, .rejilla-casillas.cuatro { grid-template-columns: 1fr 1fr; } }
.casilla { display: flex; align-items: center; gap: .5rem; padding-left: 0; margin: 0; min-height: 44px; }
.casilla .form-check-input { width: 1.45em; height: 1.45em; margin: 0; float: none; flex-shrink: 0; cursor: pointer; border: 2px solid #c9ced6; }
.casilla .form-check-input:checked { background-color: #198754; border-color: #198754; }
.casilla .form-check-label { font-weight: 600; font-size: .92rem; cursor: pointer; }
.fila-cad { padding: .35rem 0; border-bottom: 1px dashed #eef0f3; }
.fila-cad:last-child { border-bottom: 0; }
.sugerencias { position: absolute; left: calc(var(--bs-gutter-x) * .5); right: calc(var(--bs-gutter-x) * .5); top: 100%; z-index: 20; max-height: 340px; overflow-y: auto; }
.sugerencias .list-group-item { cursor: pointer; }
.estado-desa { border-radius: .7rem; padding: .7rem .9rem; font-size: .92rem; }
.estado-desa.existe { background: #e8f5ee; border: 1px solid #b7e1c8; color: #0f5132; }
.estado-desa.nuevo { background: #eef4ff; border: 1px solid #c7d8fb; color: #1e40af; }
.estado-desa.ajeno { background: #fdecef; border: 1px solid #f5c2cb; color: #9e0c24; }
.ultima-rev { border-radius: .7rem; padding: .7rem .9rem; font-size: .88rem; background: #f6f7f9; border: 1px solid #e1e4ea; color: #3a4150; }
.ultima-rev .tit { font-weight: 600; color: #212529; margin-bottom: .25rem; }
.ultima-rev .def { color: #9e0c24; }
.ultima-rev .lin { margin-top: .15rem; }
.caja-firma { border: 1px solid #dee2e6; border-radius: .7rem; padding: .6rem; background: #f8f9fa; }
.caja-firma .firma-caja { border: 1px solid #dee2e6; border-style: solid; background: #fff; }
.caja-firma .firma-caja canvas { height: 170px; }
.caja-firma .borrar { position: absolute; right: .5rem; bottom: .5rem; top: auto; }
.barra-enviar { position: sticky; bottom: 0; text-align: center; padding: .75rem 0 1rem; background: linear-gradient(transparent, var(--fondo) 35%); z-index: 5; }
body.con-menu .barra-enviar { bottom: 72px; }
@media (min-width: 992px) { body.con-menu .barra-enviar { bottom: 0; } }
.barra-enviar .btn { min-width: 260px; font-weight: 650; box-shadow: 0 6px 16px rgba(200,16,46,.3); }
.bloque.con-error { box-shadow: 0 0 0 2px rgba(200,16,46,.45), 0 2px 10px rgba(16,24,40,.07); }
.campo-error { border-color: #c8102e !important; box-shadow: 0 0 0 .2rem rgba(200,16,46,.15) !important; }

/* Cabeceras ordenables */
.th-orden a { color: inherit; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: .25rem; }
.th-orden a:hover { color: var(--rcp); }
.th-orden.activa, .th-orden.activa a { color: var(--rcp); }
.th-orden .bi { font-size: .7rem; }
