:root {
  --brand: #6d5dfc; --brand2: #a78bfa; --soft: #efedff; --ink: #1f1b3a; --muted: #6b7280; --line: #e5e7eb;
  --bg: #f7f7fb; --card: #fff;
  --ok: #047857; --okbg: #ecfdf5; --no: #b91c1c; --nobg: #fef2f2; --warn: #9a3412; --warnbg: #fff7ed;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: #5b4bf0; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; word-break: break-all; }
.center { text-align: center; }

/* Encabezado */
.top { background: linear-gradient(90deg, var(--brand), var(--brand2)); color: #fff; }
.top-in { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 16px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 22px; letter-spacing: -.5px; }
.brand span { font-weight: 500; font-size: 14px; opacity: .9; margin-left: 6px; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: 14px; }
.top nav a:hover { background: rgba(255,255,255,.18); }
main.wrap { padding-top: 24px; padding-bottom: 24px; display: grid; gap: 20px; }
.foot { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; }

/* Tarjetas y elementos */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.card.narrow { max-width: 760px; width: 100%; margin: 0 auto; }
.card h1 { margin: 0 0 8px; font-size: 26px; }
.card h2 { margin: 0 0 6px; font-size: 19px; }
.card h3 { font-size: 15px; margin: 16px 0 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: 12px; font-weight: 700; color: var(--brand); margin: 0 0 4px; }
.btn { display: inline-block; border: 0; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; font-family: inherit; }
.btn.primary { background: linear-gradient(90deg, var(--brand), var(--brand2)); color: #fff; }
.btn.ghost { background: var(--soft); color: #5b4bf0; }
.btn.big { padding: 14px 26px; font-size: 16px; margin-top: 12px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:hover { filter: brightness(1.05); }
input[type=text], input[type=password], input[type=email] {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; font-family: inherit; width: 100%;
}
input:focus { outline: 2px solid var(--brand2); border-color: transparent; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: #f3f4f6; color: var(--muted); }
.tag.ok { background: var(--okbg); color: var(--ok); }
.tag.no { background: var(--nobg); color: var(--no); }
.tag.warn { background: var(--warnbg); color: var(--warn); }
.alert { background: var(--soft); border-radius: 10px; padding: 12px 16px; font-size: 14px; }
.alert.ok { background: var(--okbg); color: var(--ok); }
.alert.no { background: var(--nobg); color: var(--no); margin-bottom: 12px; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.stack { display: grid; gap: 12px; }
.stack label { font-size: 13px; font-weight: 600; color: var(--muted); display: grid; gap: 6px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafafa; }

/* Validador */
.hero-box { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border-radius: 16px; padding: 32px 24px; }
.hero-box h1 { margin: 0 0 6px; font-size: 28px; }
.hero-box p { margin: 0 0 18px; opacity: .95; max-width: 640px; }
.search { display: flex; gap: 8px; max-width: 640px; }
.search input { flex: 1; }
.search.sm { max-width: 360px; }
.verdict { display: flex; gap: 18px; align-items: flex-start; }
.verdict .icon { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 700; color: #fff; }
.verdict.ok { border-color: #a7f3d0; } .verdict.ok .icon { background: var(--ok); } .verdict.ok h2 { color: var(--ok); }
.verdict.no { border-color: #fecaca; } .verdict.no .icon { background: var(--no); } .verdict.no h2 { color: var(--no); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* Evaluación */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 18px 0; }
.facts div { background: var(--soft); border-radius: 12px; padding: 14px; text-align: center; }
.facts b { display: block; font-size: 22px; color: #5b4bf0; }
.facts span { font-size: 13px; color: var(--muted); }
.timer { position: sticky; top: 0; z-index: 5; max-width: 760px; width: 100%; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 18px; }
.timer b { font-size: 24px; font-variant-numeric: tabular-nums; }
.timer small { margin-left: auto; opacity: .7; }
.timer.low { background: var(--no); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .85; } }
.q { border: 0; border-top: 1px solid var(--line); padding: 16px 0; margin: 0; }
.q:first-of-type { border-top: 0; }
.q legend { font-weight: 600; font-size: 16px; padding: 0; margin-bottom: 8px; }
.q legend span { color: var(--brand); }
.opt { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); margin-top: 8px; cursor: pointer; }
.opt:hover { background: #fafafa; }
.opt:has(input:checked) { border-color: var(--brand2); background: var(--soft); }
.opt input { accent-color: var(--brand); width: 18px; height: 18px; }
.score { font-size: 64px; font-weight: 800; margin: 8px 0; }
.score.ok { color: var(--ok); } .score.no { color: var(--no); }

/* Admin */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpis div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.kpis b { display: block; font-size: 28px; }
.kpis span { color: var(--muted); font-size: 13px; }
.kpis .hl { border-color: var(--brand2); background: var(--soft); }
.resolve { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.resolve input { width: 160px; padding: 6px 10px; font-size: 13px; }
.mods { display: grid; gap: 8px; max-width: 520px; }
.mods > div { display: grid; grid-template-columns: 140px 1fr 48px; gap: 10px; align-items: center; font-size: 14px; }
.mods .bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.mods .bar i { display: block; height: 100%; background: var(--brand); }
input.copy { font-size: 12px; width: 260px; }
.login { max-width: 400px; }
.btn.danger { background: var(--nobg); color: var(--no); }
.btn.danger:hover { background: #fee2e2; }
td.actions { white-space: nowrap; }
td.actions > * { margin: 2px 4px 2px 0; vertical-align: middle; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
select, input[type=date] { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; font-family: inherit; background: #fff; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filters input[type=text] { width: 240px; }
.stack label.check { flex-direction: row; display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.stack select { width: 100%; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
input[type=number], textarea { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; font-family: inherit; width: 100%; }
textarea { resize: vertical; }
.filters .date { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* Ventanas emergentes (resumen de evaluación, revocar) */
dialog.modal { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 0; border-radius: 16px; padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.3); color: var(--ink); }
dialog.modal.small { width: min(520px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(17, 12, 46, .55); }
dialog.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin: -24px -24px 12px; padding: 14px 24px;
  position: sticky; top: -24px; z-index: 2; background: #fff; border-bottom: 1px solid var(--line); }
.modal-title { flex: 1; min-width: 0; }
.modal-title h2 { margin: 0; }
.modal-title .eyebrow { margin: 0 0 2px; }
.modal-x { flex: none; width: 36px; height: 36px; border: 0; border-radius: 8px; background: #f3f4f6; color: #374151; font-size: 18px; cursor: pointer; }
.modal-x:hover { background: #e5e7eb; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
table.audit tr.right td:last-child, table.audit tr.wrong td:last-child { text-align: center; }
table.audit tr.wrong { background: #fff7f7; }
@media print {
  body:has(dialog[open]) > *:not(main), body:has(dialog[open]) main > *:not(dialog[open]) { display: none !important; }
  dialog.modal[open] { position: static; box-shadow: none; max-height: none; width: 100%; padding: 0; }
  dialog.modal .btn { display: none; }
}

/* Certificado */
.cert-page { background: #e9e7f5; padding: 24px 16px; }
.cert-actions { max-width: 960px; margin: 0 auto 16px; display: flex; gap: 8px; justify-content: flex-end; }
.cert { position: relative; max-width: 960px; margin: 0 auto; background: #fff; padding: 56px 64px 40px; text-align: center;
  border: 10px solid transparent; border-radius: 6px;
  background-image: linear-gradient(#fff, #fff), linear-gradient(135deg, var(--brand), var(--brand2));
  background-origin: border-box; background-clip: padding-box, border-box; box-shadow: 0 20px 50px rgba(31,27,58,.15); }
.cert-brand { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.cert-brand span { font-size: 14px; vertical-align: super; color: var(--brand); }
.cert-eyebrow { text-transform: uppercase; letter-spacing: .25em; color: var(--brand); font-weight: 700; margin: 8px 0 28px; }
.cert h1 { font-size: 42px; margin: 6px 0; font-family: Georgia, "Times New Roman", serif; }
.cert-company { color: var(--muted); margin-top: 0; font-size: 18px; }
.cert-score { font-size: 56px; font-weight: 800; color: var(--brand); margin: 8px 0; }
.cert-foot { display: grid; grid-template-columns: 1fr 2fr 1.4fr; gap: 16px; text-align: left; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12px; }
.cert-foot span { display: block; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: 10px; }
.cert-foot b { word-break: break-all; font-weight: 600; }
.cert-invalid { position: absolute; inset: 0; display: grid; place-items: center; font-size: 48px; font-weight: 800; color: rgba(185,28,28,.35); transform: rotate(-18deg); pointer-events: none; }
.cert-tip { max-width: 960px; margin: -6px auto 12px; text-align: right; font-size: 13px; color: var(--muted); }
.cert-print-aviso { display: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
@media print {
  .cert-page { background: #fff; padding: 0; }
  .cert-actions, .cert-tip { display: none; }
  .cert { box-shadow: none; }
  @page { size: landscape; margin: 10mm; }
  /* Consulta pública: no se imprime ni se guarda en PDF el certificado, solo un aviso. */
  .cert-solo-consulta .cert { display: none; }
  .cert-solo-consulta .cert-print-aviso { display: block; text-align: center; padding: 80px 40px; font-size: 18px; }
  .cert-solo-consulta .cert-print-aviso b { font-size: 26px; }
}

@media (max-width: 640px) {
  .search { flex-direction: column; }
  .cert { padding: 32px 20px; }
  .cert h1 { font-size: 30px; }
  .cert-foot { grid-template-columns: 1fr; }
  .verdict { flex-direction: column; }
}
