:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --texto: #1d2330;
  --suave: #5d6678;
  --linea: #dfe3ea;
  --cab: #eef1f6;
  --acento: #1f5fbf;
  --acento-suave: #e6eefb;
  --ok: #1d7a46;
  --ok-suave: #e3f4ea;
  --aviso: #9a5b00;
  --aviso-suave: #fdf1dc;
  --error: #b3261e;
  --error-suave: #fbe9e7;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--acento); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.2rem; }
small, .suave { color: var(--suave); }
button, .boton {
  font: inherit; cursor: pointer; border: 1px solid var(--linea); background: var(--panel);
  color: var(--texto); padding: .5rem .9rem; border-radius: 8px; text-decoration: none;
  display: inline-flex; align-items: center; gap: .4rem; line-height: 1.2;
}
button:hover, .boton:hover { border-color: #b7c0cf; }
.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.primario:hover { background: #194f9f; }
.peligro { color: var(--error); }
button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Encabezado público ---------- */
.cabecera-publica {
  background: var(--panel); border-bottom: 1px solid var(--linea); position: sticky; top: 0; z-index: 10;
}
.cabecera-publica .dentro { max-width: 980px; margin: 0 auto; padding: .75rem 1rem; display: flex;
  align-items: center; gap: 1rem; flex-wrap: wrap; }
.cabecera-publica .marca { font-weight: 700; }
.barra { flex: 1; min-width: 160px; height: 8px; background: var(--cab); border-radius: 99px; overflow: hidden; }
.barra > span { display: block; height: 100%; background: var(--acento); width: 0; transition: width .3s; }
.estado-guardado { font-size: .85rem; color: var(--suave); min-width: 9rem; text-align: right; }
.contenido { max-width: 980px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.tarjeta { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 1.25rem; box-shadow: var(--sombra); margin-bottom: 1rem; }
.leyenda { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: 0; margin: .75rem 0 0; list-style: none; }
.aviso { background: var(--aviso-suave); border: 1px solid #f1d29a; padding: .75rem 1rem; border-radius: 8px; }
.exito { background: var(--ok-suave); border: 1px solid #a9dcbc; padding: .75rem 1rem; border-radius: 8px; }
.indice { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .75rem; }
.indice a { text-decoration: none; border: 1px solid var(--linea); border-radius: 6px; padding: .2rem .55rem;
  font-size: .85rem; color: var(--texto); background: var(--panel); }
.indice a.completo { background: var(--ok-suave); border-color: #a9dcbc; }

/* ---------- Cuestionario ---------- */
.bloque { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--sombra); scroll-margin-top: 80px; }
.bloque h2 { display: flex; align-items: center; gap: .6rem; margin: 0 0 1rem; }
.bloque h2 .letra { background: var(--acento); color: #fff; width: 2rem; height: 2rem; border-radius: 8px;
  display: inline-grid; place-items: center; font-size: 1rem; flex: none; }
.bloque h2 .estrella { color: #d39b00; font-size: 1rem; }
.bloque h3 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.bloque .intro { margin-top: -.5rem; color: var(--suave); }

.preg { border: 1px solid var(--linea); border-radius: 8px; padding: 0; margin: 0 0 1rem; overflow: hidden; min-width: 0; }
.preg-tit { width: 100%; background: var(--cab); padding: .6rem .9rem; font-weight: 600; display: flex;
  justify-content: space-between; gap: 1rem; float: left; }
.preg-tit .pista { font-weight: 400; white-space: nowrap; }
.opts { clear: both; display: grid; gap: .5rem; padding: .75rem; }
.opts.rejilla { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opts.fila { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.opt { display: flex; align-items: center; gap: .55rem; padding: .6rem .7rem; border: 1px solid var(--linea);
  border-radius: 8px; cursor: pointer; min-height: 2.75rem; background: var(--panel); }
.opt:hover { border-color: #9fb3d6; }
.opt.on { border-color: var(--acento); background: var(--acento-suave); }
.opt input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--acento); flex: none; }
.det { clear: both; display: flex; gap: .6rem; align-items: center; padding: 0 .75rem .75rem; flex-wrap: wrap; }
.det span { font-size: .9rem; color: var(--suave); }
.det input { flex: 1; min-width: 10rem; }
input[type=text], input[type=email], input[type=password], textarea, select {
  font: inherit; padding: .5rem .65rem; border: 1px solid var(--linea); border-radius: 8px; background: #fff; width: 100%;
}
input:focus-visible, textarea:focus-visible, button:focus-visible, .opt:focus-within {
  outline: 2px solid var(--acento); outline-offset: 1px;
}

.textos { display: grid; gap: .75rem; margin-bottom: 1rem; }
.campo { display: grid; gap: .25rem; }
.campo span { font-weight: 600; font-size: .95rem; }

.matriz-wrap { margin-bottom: 1rem; border: 1px solid var(--linea); border-radius: 8px; overflow: hidden; }
.matriz { width: 100%; border-collapse: collapse; }
.matriz th { background: var(--cab); text-align: left; padding: .6rem .9rem; font-size: .95rem; }
.matriz th.col-op, .matriz td.col-op { text-align: center; width: 7.5rem; }
.matriz td { border-top: 1px solid var(--linea); padding: .5rem .9rem; vertical-align: middle; }
.matriz td.col-op { padding: 0; }
.matriz td.col-op.on { background: var(--acento-suave); }
.matriz .celda { display: grid; place-items: center; min-height: 2.9rem; cursor: pointer; }
.matriz .celda input { width: 1.2rem; height: 1.2rem; accent-color: var(--acento); margin: 0; }
.matriz .det { padding: .4rem 0 0; }
.matriz.proyectos td.cuando { width: 14rem; }

.envio { display: grid; gap: 1rem; }
.envio label.consent { display: flex; gap: .6rem; align-items: flex-start; }
.envio label.consent input { width: 1.2rem; height: 1.2rem; margin-top: .15rem; flex: none; }

.cuestionario.ro .opt, .cuestionario.ro .celda { cursor: default; }
.cuestionario.ro .opt:not(.on) { opacity: .55; }
.cuestionario.ro input[type=text], .cuestionario.ro textarea { background: var(--bg); }

@media (max-width: 720px) {
  .opts.fila { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .matriz thead { display: none; }
  .matriz, .matriz tbody, .matriz tr, .matriz td { display: block; width: 100%; }
  .matriz tr { border-top: 1px solid var(--linea); padding: .6rem .75rem; display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: .4rem; }
  .matriz tr:first-child { border-top: 0; }
  .matriz td { border: 0; padding: 0; }
  .matriz td.mt-texto { grid-column: 1 / -1; font-weight: 600; }
  .matriz th.col-op, .matriz td.col-op { width: auto; }
  .matriz td.col-op { border: 1px solid var(--linea); border-radius: 8px; }
  .matriz td.col-op .celda { grid-template-columns: auto auto; gap: .4rem; }
  .matriz td.col-op .celda::after { content: attr(data-l); font-size: .9rem; }
  .matriz.proyectos td.cuando { grid-column: 1 / -1; width: 100%; }
}
@media (max-width: 460px) {
  .opts.rejilla { grid-template-columns: 1fr; }
  .preg-tit { flex-direction: column; gap: .1rem; }
}

/* ---------- Zona privada ---------- */
.top { background: #14213d; color: #fff; }
.top .dentro { max-width: 1200px; margin: 0 auto; padding: .7rem 1rem; display: flex; gap: 1.25rem;
  align-items: center; flex-wrap: wrap; }
.top a { color: #fff; text-decoration: none; opacity: .85; }
.top a:hover, .top a.activo { opacity: 1; text-decoration: underline; }
.top small { color: inherit; }
.top .marca { font-weight: 700; opacity: 1; margin-right: auto; }
.top form { margin: 0; }
.top button { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); padding: .3rem .7rem; }
.pagina { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.fila-tit { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.acciones form { margin: 0; }
.mensajes { list-style: none; padding: 0; margin: 0 0 1rem; }
.mensajes li { background: var(--ok-suave); border: 1px solid #a9dcbc; padding: .6rem .9rem; border-radius: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); padding: .8rem 1rem; }
.kpi b { display: block; font-size: 1.6rem; }
.filtros { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filtros input[type=search] { max-width: 280px; }
.filtros select { width: auto; }
table.lista { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--linea);
  border-radius: var(--radio); overflow: hidden; }
table.lista th, table.lista td { padding: .6rem .8rem; text-align: left; border-top: 1px solid var(--linea); vertical-align: middle; }
table.lista th { background: var(--cab); border-top: 0; font-size: .9rem; }
table.lista tr:hover td { background: #fafbfd; }
.chip { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 600;
  background: var(--cab); white-space: nowrap; }
.chip.pendiente { background: #eceff3; color: #475166; }
.chip.en_curso { background: var(--aviso-suave); color: var(--aviso); }
.chip.enviada { background: var(--ok-suave); color: var(--ok); }
.chip.revocada { background: var(--error-suave); color: var(--error); }
.talla { display: inline-grid; place-items: center; min-width: 2.2rem; height: 2.2rem; border-radius: 8px;
  background: var(--acento); color: #fff; font-weight: 700; }
.mini-barra { width: 90px; height: 6px; background: var(--cab); border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-barra span { display: block; height: 100%; background: var(--acento); }
.dos-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .dos-col { grid-template-columns: 1fr; } }
dl.datos { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.datos dt { color: var(--suave); }
dl.datos dd { margin: 0; }
.enlace { display: flex; gap: .5rem; }
.enlace input { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.resultado { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.resultado .talla { min-width: 3.5rem; height: 3.5rem; font-size: 1.6rem; }
table.puntos { width: 100%; border-collapse: collapse; }
table.puntos td, table.puntos th { padding: .45rem .5rem; border-top: 1px solid var(--linea); text-align: left; }
table.puntos td.n { text-align: center; font-weight: 700; width: 3rem; }
.dudoso { color: var(--aviso); font-size: .85rem; }
ul.modulos { padding-left: 1.1rem; margin: .25rem 0; }
ul.modulos li { margin-bottom: .35rem; }
.form-cliente { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-cliente .ancho { grid-column: 1 / -1; }
.form-cliente label { display: grid; gap: .25rem; font-weight: 600; font-size: .95rem; }
.form-cliente .errorlist { color: var(--error); margin: 0; padding: 0; list-style: none; font-weight: 400; }
@media (max-width: 640px) { .form-cliente { grid-template-columns: 1fr; } }
.login { max-width: 380px; margin: 8vh auto; }
.login form { display: grid; gap: .9rem; }
.login label { display: grid; gap: .25rem; font-weight: 600; }
.calc-factor { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem 1rem; align-items: center;
  padding: .6rem 0; border-top: 1px solid var(--linea); }
.calc-factor select { width: 16rem; max-width: 100%; }
@media (max-width: 640px) { .calc-factor { grid-template-columns: 1fr; } }

@media print {
  .cabecera-publica, .top, .no-imprimir, .indice { display: none !important; }
  body { background: #fff; }
  .bloque, .tarjeta { box-shadow: none; break-inside: avoid-page; }
}
