:root {
  --bg: #f6f5f1; --surface: #ffffff; --text: #1d1f23; --muted: #646b76; --line: #dcd9d1;
  --accent: #1f5f4a; --accent-text: #ffffff; --accent-soft: #e4efe9;
  --warn: #9a5b00; --warn-soft: #fbf1dc; --bad: #a12d2d; --bad-soft: #f8e4e2; --ok: #1f6b3a;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b; --surface: #1f2226; --text: #e8e6e1; --muted: #9aa1ab; --line: #343941;
    --accent: #6fc3a3; --accent-text: #10201a; --accent-soft: #23352e;
    --warn: #e5b45a; --warn-soft: #3a2f18; --bad: #ef8f88; --bad-soft: #3d2221; --ok: #7fd09a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.topbar { display: flex; align-items: baseline; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { font-size: 20px; font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -0.01em; }
.tagline { color: var(--muted); font-size: 13px; }
.conn-link { margin-left: auto; font-size: 13px; text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; color: var(--text); white-space: nowrap; }
.conn-link:hover { border-color: var(--accent); }
.provider { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.provider.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.provider-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.provider-head label { font-weight: 600; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.notice.ok { background: var(--accent-soft); color: var(--text); }
.banner { padding: 10px 20px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); font-size: 14px; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

button, .btn { font: inherit; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--bad); }
input[type=text], input[type=email], input[type=number], input[type=password], textarea, select { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }
textarea { min-height: 84px; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }

.project-list { list-style: none; padding: 0; margin: 0; }
.project-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.project-list li:first-child { border-top: 0; }
.project-list a { font-weight: 600; text-decoration: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0 18px; overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .wide { grid-column: 1 / -1; }
.field label.title { display: block; font-weight: 600; margin-bottom: 4px; }
.field .help { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.req { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; user-select: none; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.chips label:has(input:focus-visible) { outline: 2px solid var(--accent); }

.workspace { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
.steps-nav { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; padding: 10px; }
.steps-nav h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 12px 6px 4px; }
.steps-nav h3:first-child { margin-top: 2px; }
.steps-nav button { display: flex; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 5px 6px; border-radius: 6px; font-size: 14px; align-items: baseline; }
.steps-nav button:hover { background: var(--accent-soft); }
.steps-nav button.current { background: var(--accent-soft); font-weight: 600; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); transform: translateY(1px); }
.dot.draft { background: var(--warn); border-color: var(--warn); }
.dot.approved { background: var(--ok); border-color: var(--ok); }
.dot.review { background: var(--bad); border-color: var(--bad); }
.progress { font-size: 13px; color: var(--muted); padding: 4px 6px 8px; }

.step-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.status { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.status.draft { color: var(--warn); border-color: var(--warn); }
.status.approved { color: var(--ok); border-color: var(--ok); }
.status.review { color: var(--bad); border-color: var(--bad); }
.hallazgos { margin: 6px 0 0; padding-left: 20px; }
.notice { padding: 9px 12px; border-radius: var(--radius); font-size: 14px; }
.notice.error { background: var(--bad-soft); color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.empty-state { color: var(--muted); padding: 26px 0; text-align: center; }

.prose { overflow-wrap: anywhere; }
.prose h3 { font-size: 16px; margin: 18px 0 6px; }
.prose h4 { font-size: 15px; margin: 14px 0 4px; }
.prose p, .prose ul, .prose ol { margin: 8px 0; }
.prose .table-wrap { overflow-x: auto; margin: 10px 0; }
.prose table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.prose th { background: var(--accent-soft); }
.prose pre { white-space: pre-wrap; }
.editor { min-height: 420px; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }

.score { font-size: 40px; font-weight: 700; line-height: 1; }
.axes { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.axis { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.axis b { font-size: 20px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.criterion { border-top: 1px solid var(--line); padding: 12px 0; }
.criterion summary { cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.criterion .pts { font-weight: 700; white-space: nowrap; }
.pts.low { color: var(--bad); } .pts.mid { color: var(--warn); } .pts.high { color: var(--ok); }

@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
  .steps-nav { position: static; max-height: 260px; }
  .form-grid { grid-template-columns: 1fr; }
  .tagline { display: none; }
}
@media print {
  .topbar, .tabs, .banner, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; }
}

/* Base de conocimiento y fuentes citadas */
table.docs { width: 100%; border-collapse: collapse; font-size: 14px; }
table.docs th, table.docs td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.docs th { font-size: 12px; color: var(--muted); font-weight: 600; }
.fuentes { border-top: 1px solid var(--line); padding-top: 10px; font-size: 14px; }
.fuentes ul { margin: 6px 0 0; padding-left: 20px; }
.fuentes li { margin-bottom: 4px; }
.topbar .conn-link + .conn-link { margin-left: 14px; }

.help.cita { font-style: italic; }
.candidato { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.candidato a { word-break: break-all; }
ul.dominios { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
ul.dominios li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
details > summary { cursor: pointer; font-weight: 600; }
/* Fase 6: menú por rol, ingreso y contraseñas temporales */
.menu { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.menu .conn-link { margin-left: 0; }
.quien { color: var(--muted); text-decoration: none; }
.quien:hover { color: var(--text); text-decoration: underline; }
button.link { border: 0; background: none; padding: 3px 6px; color: var(--accent); font-size: 13px; }
.login { max-width: 420px; margin: 40px auto; }
code.temporal { font-size: 17px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); user-select: all; }
ul.admins { list-style: none; margin: 0; padding: 0; }
ul.admins li { padding: 2px 0; }
@media (max-width: 640px) { .topbar { flex-wrap: wrap; } .tagline { display: none; } }
/* Etapa D: selector del plan en la tabla de empresas */
table.docs td select { min-width: 150px; }

/* Respaldo, en la pantalla del operador */
.datos-respaldo { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.datos-respaldo dt { color: var(--muted, #666); }
.datos-respaldo dd { margin: 0; }
@media (max-width: 600px) { .datos-respaldo { grid-template-columns: 1fr; } .datos-respaldo dd { margin-bottom: 6px; } }

/* Posición en la cola de las operaciones largas */
.aviso-cola { position: fixed; right: 16px; bottom: 16px; max-width: min(360px, calc(100vw - 32px)); z-index: 50; box-shadow: 0 2px 10px rgba(0,0,0,.15); }

/* Segundo factor del operador */
.clave-2f { font-size: 1.1em; letter-spacing: .08em; padding: 6px 10px; word-break: break-all; }
.pasos { padding-left: 1.3em; display: grid; gap: 8px; margin: 0; }
.codigos-recuperacion { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 24px; }
.codigos-recuperacion code { font-size: 1.05em; }

/* Modo soporte del operador */
.barra-soporte { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 8px 16px; background: #fff4d6; color: #5a4300; border-bottom: 1px solid #e8cf86; }
@media (prefers-color-scheme: dark) { .barra-soporte { background: #3a3014; color: #f3dc9a; border-color: #5a4a1c; } }

/* Guía de uso */
.guia { max-width: 820px; }
.guia h1 { margin-top: 0; }
.guia h2 { margin-top: 2em; padding-top: .6em; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
.guia li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.3em; }
.guia input[type="checkbox"] { margin-right: .5em; }

/* Ventanas de confirmación propias */
dialog.ventana { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(480px, calc(100vw - 32px)); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
dialog.ventana::backdrop { background: rgba(0,0,0,.35); }

/* Código QR del segundo factor: fondo blanco siempre, para que el teléfono lo lea también en modo oscuro */
img.qr-2f { display: block; margin: 8px 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; }

/* Estado del servicio (operador) */
table.tabla-cola { width: 100%; border-collapse: collapse; font-size: .95em; }
table.tabla-cola th, table.tabla-cola td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
