/* Portal RAT LOPDP — estilos base sin dependencias externas */
:root {
  --brand: #1F4E79;
  --brand-ink: #fff;
  --ink: #1d2433;
  --muted: #5b6577;
  --line: #dde2ea;
  --bg: #f5f7fa;
  --card: #fff;
  --ok: #1e7b4b;
  --warn: #9a6700;
  --bad: #b42318;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; font-size: 16px; }
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Barra superior */
.topbar { background: var(--brand); color: var(--brand-ink); }
.topbar .wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .75rem 1rem; }
.topbar a { color: var(--brand-ink); text-decoration: none; }
.brand { font-weight: 700; font-size: 1.05rem; margin-right: auto; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a { padding: .35rem .7rem; border-radius: 6px; opacity: .9; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.15); opacity: 1; }
.userbox { display: flex; gap: .75rem; align-items: center; font-size: .9rem; }
.userbox form { margin: 0; }
.linkbtn { background: none; border: 1px solid rgba(255,255,255,.5); color: inherit; padding: .3rem .7rem; border-radius: 6px; cursor: pointer; font: inherit; }

.wrap { max-width: 1100px; margin: 0 auto; }
main.wrap { padding: 1.5rem 1rem 3rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

/* Tarjetas y grillas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tile { display: block; text-decoration: none; color: inherit; }
.tile:hover { border-color: var(--brand); }
.tile.disabled { opacity: .65; }

/* Formularios */
label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=url], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid #c4ccd8; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 140px; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--brand) 30%, transparent); border-color: var(--brand); }
input[type=color] { width: 64px; height: 40px; padding: 2px; border: 1px solid #c4ccd8; border-radius: 8px; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .3rem; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; flex: 1 1 180px; }
.code-input { font-size: 1.4rem; letter-spacing: .3em; text-align: center; max-width: 240px; }

/* Botones */
.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); padding: .6rem 1.1rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn-secondary { background: #fff; color: var(--brand); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; font-weight: 500; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }

/* Mensajes */
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert-ok { background: #ecf8f1; border-color: #b5e2c8; color: var(--ok); }
.alert-bad { background: #fdf0ef; border-color: #f3c4bf; color: var(--bad); }
.alert-warn { background: #fff8e6; border-color: #f0d28c; color: var(--warn); }
.alert ul { margin: 0; padding-left: 1.2rem; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eef1f6; color: var(--muted); }
.badge-ok { background: #e4f5ec; color: var(--ok); }
.badge-warn { background: #fff3d6; color: var(--warn); }
.badge-bad { background: #fde7e5; color: var(--bad); }
.badge-brand { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); }

/* Pantallas de acceso */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth .card { width: 100%; max-width: 440px; }
.auth-brand { text-align: center; color: var(--brand); font-weight: 700; font-size: 1.2rem; margin-bottom: 1rem; }
.qr { display: flex; justify-content: center; margin: 1rem 0; }
.qr svg { width: 220px; height: 220px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f1f3f7; padding: .4rem .6rem; border-radius: 6px; word-break: break-all; }
.codes { columns: 2; font-family: ui-monospace, Menlo, Consolas, monospace; padding-left: 1.2rem; }
.prose { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line); padding: 1rem; border-radius: 8px; max-height: 50vh; overflow: auto; }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem; }

@media (max-width: 640px) {
  .topbar .wrap { gap: .5rem; }
  .brand { width: 100%; }
  h1 { font-size: 1.35rem; }
  .card { padding: 1rem; }
}
@media print {
  .topbar, .footer, .actions, .btn { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
}
.mt { margin-top: 1.25rem; }
.row-between { justify-content: space-between; margin-bottom: .5rem; }

/* ───────────── Fase 2: diagnóstico pregunta por pregunta ───────────── */
.hidden { display: none !important; }
.center { text-align: center; }
.actions.center { justify-content: center; }
.mt-s { margin-top: .5rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.linkish { background: none; border: none; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.btn-lg { padding: .85rem 1.5rem; font-size: 1.05rem; border-radius: 12px; }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.chip { display: inline-block; background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); border-radius: 99px; padding: .25rem .8rem; font-size: .85rem; font-weight: 600; }

body.diag { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, #fff) 0%, var(--bg) 320px); }
.diag-top { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.2rem; max-width: 820px; margin: 0 auto; }
.diag-brand { font-weight: 800; color: var(--brand); text-decoration: none; margin-right: auto; }
.diag-link { color: var(--muted); font-size: .9rem; }
.diag-main { max-width: 820px; margin: 0 auto; padding: .5rem 1rem 2rem; }
.save-pill { font-size: .8rem; color: var(--ok); opacity: 0; transition: opacity .3s; }
.save-pill.show { opacity: 1; }
.save-pill.err { color: var(--bad); }

.progress { height: 8px; background: #e3e8ef; border-radius: 99px; overflow: hidden; margin: .25rem 0 .9rem; }
.progress-bar { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #3fd0a3)); border-radius: 99px; transition: width .6s ease; }
.w-0 { width: 0%; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }
.q-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; gap: .5rem; flex-wrap: wrap; }

@keyframes slideIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
.q-card { background: #fff; border-radius: 20px; padding: 1.75rem; box-shadow: 0 10px 30px rgba(20, 40, 80, .08); animation: slideIn .35s ease both; }
.q-intro { text-align: center; padding: 2.5rem 1.75rem; }
.intro-icon { font-size: 3.2rem; animation: pop .5s ease both; }
.q-title { font-size: 1.55rem; line-height: 1.25; margin-bottom: .5rem; }
.q-help { color: var(--muted); }
.q-example { color: var(--muted); font-size: .9rem; font-style: italic; }
.animo { color: var(--ok); font-weight: 600; margin-bottom: .4rem; animation: pop .5s ease both; }
.input-lg { font-size: 1.15rem; padding: .85rem 1rem; }

.options { display: grid; gap: .6rem; margin: 1rem 0; }
.options-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.opt { position: relative; cursor: pointer; font-weight: 500; margin: 0; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt-box { display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; border: 2px solid var(--line); border-radius: 14px; background: #fff; transition: border-color .15s, background .15s, transform .1s; }
.opt:hover .opt-box { border-color: color-mix(in srgb, var(--brand) 45%, #fff); }
.opt input:checked + .opt-box { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, #fff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent); }
.opt input:checked + .opt-box::after { content: "✓"; margin-left: auto; color: var(--brand); font-weight: 800; }
.opt input:focus-visible + .opt-box { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); }
.opt:active .opt-box { transform: scale(.98); }
.opt-icon { font-size: 1.35rem; }
.other-field { animation: slideIn .25s ease both; }
.form-grid { display: grid; gap: .25rem 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-top: 1rem; }

.matrix { display: grid; gap: .8rem; margin-top: 1rem; }
.matrix-row { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; margin: 0; }
.matrix-row legend { font-weight: 600; padding: 0 .3rem; }
.pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill { margin: 0; font-weight: 500; cursor: pointer; }
.pill input { position: absolute; opacity: 0; }
.pill span { display: inline-block; padding: .35rem .75rem; border: 1.5px solid var(--line); border-radius: 99px; font-size: .88rem; }
.pill input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.pill input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); }

.q-actions { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: 1.5rem; }
.q-actions-right { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

.tip { display: flex; gap: .9rem; background: #fffbea; border: 1px solid #f3e1a0; border-radius: 16px; padding: 1rem 1.2rem; margin: 1.1rem 0; animation: slideIn .5s .15s ease both; }
.tip-icon { font-size: 1.6rem; }
.tip p { margin: .2rem 0 .3rem; }
.tip-src { font-size: .78rem; color: var(--muted); }

.hero { text-align: center; padding: 2.2rem 0 1.5rem; }
.hero h1 { font-size: 2.1rem; line-height: 1.15; margin: .8rem auto; max-width: 680px; }
.hero-sub { color: var(--muted); font-size: 1.1rem; max-width: 620px; margin: 0 auto 1.4rem; }
.start-form { max-width: 520px; margin: 0 auto; display: grid; gap: 1rem; justify-items: center; text-align: left; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 2rem 0; }
.how-step { background: #fff; border-radius: 16px; padding: 1.2rem; box-shadow: 0 6px 20px rgba(20, 40, 80, .06); }
.how-n { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; margin-bottom: .5rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin: 1.5rem 0 .6rem; }
.fact { background: var(--brand); color: #fff; border-radius: 16px; padding: 1rem; }
.fact strong { display: block; font-size: 1.5rem; }
.fact span { font-size: .85rem; opacity: .92; }

.summary-wrap { max-width: 820px; margin: 0 auto; }
.celebrate { font-size: 3.4rem; text-align: center; animation: pop .6s ease both; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin: 1.2rem 0; }
.stat { background: #fff; border-radius: 16px; padding: 1rem; text-align: center; box-shadow: 0 6px 20px rgba(20, 40, 80, .06); }
.stat strong { display: block; font-size: 1.9rem; color: var(--brand); }
.stat span { font-size: .85rem; color: var(--muted); }
.points { list-style: none; padding: 0; margin: 0; }
.points li { display: flex; gap: .6rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.cta { border: 2px solid var(--brand); }
.answers td { vertical-align: top; }
.answers-q { width: 42%; color: var(--muted); }
.answers-edit { width: 60px; text-align: right; }
.obs { background: #fff8e6; border-left: 3px solid var(--warn); padding: .45rem .6rem; margin-top: .45rem; border-radius: 6px; font-size: .92rem; }
.review-row { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.review-row.changed { background: #fffdf3; }
.review-q { color: var(--muted); font-size: .92rem; }
.review-a { font-weight: 500; margin: .2rem 0; }
.obs-form { margin-top: .4rem; }

@media (max-width: 640px) {
  .q-card { padding: 1.2rem; border-radius: 16px; }
  .q-title { font-size: 1.3rem; }
  .hero h1 { font-size: 1.6rem; }
  .stats { grid-template-columns: 1fr; }
  .q-actions { position: sticky; bottom: 0; background: #fff; padding: .7rem 0; margin-bottom: -.5rem; }
  .q-actions .btn-lg { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
details.obs-toggle summary { cursor: pointer; color: var(--brand); font-size: .88rem; margin-top: .3rem; }
details.obs-toggle[open] summary { margin-bottom: .3rem; }
@media (max-width: 640px) {
  table.answers, table.answers tbody, table.answers tr, table.answers td { display: block; width: 100%; }
  table.answers tr { padding: .6rem 0; border-bottom: 1px solid var(--line); }
  table.answers td { border: none; padding: .15rem 0; }
  .answers-q { width: 100%; font-size: .9rem; }
  .answers-edit { text-align: left; }
}
.req { color: var(--bad); }
/* Fase 3: RAT */
.rat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.rat-side { position: sticky; top: 1rem; }
.suggestion { margin-top: .35rem; font-size: .88rem; color: var(--muted); background: #f4f7fb; border-left: 3px solid var(--brand); padding: .35rem .6rem; border-radius: 6px; white-space: pre-line; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .8rem 0; }
.pre { white-space: pre-line; }
td.del { background: #fdf0ef; }
td.ins { background: #ecf8f1; }
@media (max-width: 900px) { .rat-layout { grid-template-columns: 1fr; } .rat-side { position: static; } }
/* Fase 4: expediente */
.big-action { text-align: center; }
.big-icon { font-size: 2.4rem; margin-bottom: .4rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.meter { height: 10px; background: #e3e8ef; border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ok); }
tr.muted td { color: var(--muted); }
.pending-sec { border-left: 4px solid var(--warn); }
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid var(--line); border-radius: 10px; padding: .6rem; margin-bottom: .6rem; }
  table.stack td { border: none; padding: .15rem 0; }
}
.field-error { color: var(--bad); font-size: .85rem; margin-top: .25rem; }
