@font-face {
  font-family: "Play";
  src: url("../fonts/Play-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "Play";
  src: url("../fonts/Play-bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}

:root {
  --tinta: #1c2430;
  --navy: #0e3348;
  --teal: #1b6b64;
  --papel: #f3f0e8;
  --blanco: #fffcf8;
  --linea: #d5d0c6;
  --suave: #5c6770;
  --intolerable: #8e1d2c;
  --importante: #9a4310;
  --moderado: #7a5b0d;
  --tolerable: #1c6b3a;
  --sombra: 0 10px 28px rgba(14, 51, 72, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--tinta);
  background: #e7eef0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.barra {
  background: var(--navy);
  color: white;
}

.barra-interior {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.marca {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.marca img {
  height: 48px;
  width: auto;
  background: white;
  border-radius: 4px;
  padding: 2px 6px;
}

.marca strong { display: block; font-size: 18px; }
.marca small { display: block; opacity: 0.85; }

.barra .boton { margin-left: auto; background: #f4efe4; color: var(--navy); }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 48px;
}

.estado, .vacio { color: var(--suave); }

.aviso, .alerta {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 14px;
}

.aviso { background: #e5f4ef; color: #145443; }
.alerta { background: #fde8eb; color: var(--intolerable); }

.resumen {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.chip {
  text-align: left;
  background: var(--blanco);
  border: 1px solid var(--linea);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--tinta);
}

.chip strong { display: block; font-size: 22px; line-height: 1.1; }
.chip span { color: var(--suave); font-size: 13px; }
.chip.activo { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }

.herramientas {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.herramientas input {
  width: min(420px, 100%);
  background: white;
}

.tabla-marco {
  background: var(--blanco);
  border: 1px solid var(--linea);
  border-radius: 12px;
  overflow: auto;
  box-shadow: var(--sombra);
}

table.listado { width: 100%; border-collapse: collapse; min-width: 760px; }

.listado th, .listado td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--linea);
  vertical-align: top;
}

.listado th { font-size: 13px; color: var(--suave); font-weight: 650; background: #faf8f4; }
.listado tr:last-child td { border-bottom: 0; }
.listado small { display: block; color: var(--suave); margin-top: 3px; }
.listado a { color: var(--navy); font-weight: 650; }

.fila-intolerable { box-shadow: inset 3px 0 0 var(--intolerable); }
.fila-importante { box-shadow: inset 3px 0 0 var(--importante); }
.fila-moderado { box-shadow: inset 3px 0 0 var(--moderado); }
.fila-tolerable { box-shadow: inset 3px 0 0 var(--tolerable); }

.acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.acciones a, .acciones button { white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge.grande { font-size: 16px; padding: 6px 12px; }

.nivel-intolerable { background: #f8d6db; color: var(--intolerable); }
.nivel-importante { background: #fde4d4; color: var(--importante); }
.nivel-moderado { background: #f8efc8; color: var(--moderado); }
.nivel-tolerable { background: #d9f0e2; color: var(--tolerable); }
.nivel-sin-evaluar { background: #e6eaee; color: #4d5963; }

.vencida { color: var(--intolerable); font-weight: 700; }

.boton, button.boton, button.primario {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--navy);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

button.secundario, a.secundario {
  background: transparent;
  color: var(--navy);
  border: 1px solid #b7c3c8;
}

button.peligro {
  background: transparent;
  color: var(--intolerable);
  border: 0;
  padding: 8px 4px;
  cursor: pointer;
}

button:disabled { opacity: 0.6; cursor: wait; }

.panel {
  background: var(--blanco);
  border: 1px solid var(--linea);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--sombra);
  margin-bottom: 14px;
}

.panel h2 { margin: 0 0 12px; font-size: 18px; }

.grilla {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 16px;
}

.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.campo.ancho-2 { grid-column: span 2; }
.campo.ancho-4 { grid-column: span 4; }
.campo label { font-size: 14px; font-weight: 650; }
.campo .ayuda, .ayuda { color: var(--suave); font-size: 13px; margin: 6px 0 0; }

.requerido::after { content: " *"; color: var(--intolerable); }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--linea);
  border-radius: 8px;
  background: white;
}

textarea { min-height: 150px; resize: vertical; }

.evaluacion {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

.matriz { width: 100%; border-collapse: collapse; font-size: 13px; }
.matriz caption { text-align: left; font-weight: 700; margin-bottom: 6px; }
.matriz th, .matriz td { border: 1px solid var(--linea); padding: 6px 8px; text-align: center; }
.matriz td.activa { outline: 2px solid var(--navy); outline-offset: -2px; font-weight: 700; }

.zona-fotos {
  border: 1px dashed #9aaba8;
  border-radius: 10px;
  padding: 16px;
  background: #f7faf9;
  text-align: center;
}

.zona-fotos input { margin-top: 8px; }

.miniaturas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.miniaturas figure { margin: 0; width: 140px; }
.miniaturas img { width: 140px; height: 100px; object-fit: cover; border-radius: 6px; border: 1px solid var(--linea); background: white; }
.miniaturas figcaption { font-size: 12px; color: var(--suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pie-form { display: flex; gap: 10px; align-items: center; }

.marco-hoja { overflow: auto; }

.hoja {
  background: white;
  color: #161616;
  max-width: 980px;
  min-width: 760px;
  margin: 0 auto;
  padding: 28px 32px 40px;
  box-shadow: var(--sombra);
  font-family: Play, "Segoe UI", sans-serif;
}

.hoja-encabezado img { width: 100%; height: auto; }
.hoja h1 {
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.03em;
  margin: 14px 0 6px;
}
.fecha-lugar { text-align: right; margin: 0 0 12px; }

.hoja table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.hoja th, .hoja td {
  border: 1px solid #222;
  padding: 6px 8px;
  vertical-align: top;
  font-size: 13px;
  font-weight: 400;
}
.hoja .etiqueta { font-weight: 700; white-space: nowrap; background: #f6f6f6; width: 1%; }
.hoja .desarrollo th { text-align: center; font-weight: 700; background: #f6f6f6; }
.hoja .desarrollo td { width: 33.33%; }
.hoja .texto { white-space: pre-wrap; }
.hoja .fotos img { display: block; width: 100%; height: auto; margin-bottom: 8px; }
.barra-hoja { display: flex; gap: 8px; max-width: 980px; margin: 0 auto 12px; }

.nota-pie { color: var(--suave); font-size: 13px; margin-top: 18px; }

@media (max-width: 900px) {
  .resumen { grid-template-columns: repeat(3, 1fr); }
  .grilla { grid-template-columns: 1fr 1fr; }
  .campo.ancho-4 { grid-column: span 2; }
  .evaluacion { grid-template-columns: 1fr; }
  .marco-hoja { overflow: visible; }
  .hoja { min-width: 0; width: 100%; padding: 16px; }
  .hoja table, .hoja thead, .hoja tbody, .hoja tr { display: block; width: 100%; }
  .hoja th, .hoja td, .hoja .etiqueta, .hoja .desarrollo td {
    display: block;
    width: 100%;
    white-space: normal;
  }
  .hoja .desarrollo thead { display: none; }
  .hoja .desarrollo td::before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
  }
}

@media (max-width: 640px) {
  .barra-interior, .herramientas, .pie-form { flex-direction: column; align-items: stretch; }
  .barra .boton { margin-left: 0; }
  .resumen, .grilla { grid-template-columns: 1fr; }
  .campo.ancho-2, .campo.ancho-4 { grid-column: auto; }
  .marca strong { font-size: 16px; }
  table.listado { min-width: 0; }
  .listado thead { display: none; }
  .listado tr { display: block; border-bottom: 1px solid var(--linea); padding: 6px 0; }
  .listado td { display: block; border: 0; padding: 4px 12px; }
  .listado td::before {
    content: attr(data-label);
    display: block;
    color: var(--suave);
    font-size: 12px;
    font-weight: 700;
  }
  .listado td.vacio::before { content: none; }
}

@media print {
  .no-imprimir, .barra { display: none !important; }
  body { background: white; }
  main { max-width: none; padding: 0; }
  .marco-hoja { overflow: visible; }
  .hoja { box-shadow: none; max-width: none; min-width: 0; padding: 0; }
  .hoja table { display: table; width: 100%; }
  .hoja thead, .hoja .desarrollo thead { display: table-header-group; }
  .hoja tbody { display: table-row-group; }
  .hoja tr { display: table-row; }
  .hoja th, .hoja td, .hoja .desarrollo td { display: table-cell; width: auto; }
  .hoja .etiqueta { display: table-cell; width: 1%; white-space: nowrap; }
  .hoja .desarrollo td::before { content: none; }
  .hoja th, .hoja td, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4 landscape; margin: 10mm; }
}
