/* Diagnóstico IA — marca Winapsis (tokens de ~/logo-personal/web/winapsis-tokens.css).
   Sin recursos de terceros: Sora va autoalojada en /static/brand y la CSP solo permite 'self'. */
@font-face {
  font-family: "Sora";
  src: url("/static/brand/Sora.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
:root {
  --wn-bg: #05070D;
  --wn-surface: #0E1126;
  --wn-ink: #F2F8FF;
  --wn-blue: #1F4BFF;
  --wn-cyan: #22B8F0;
  --wn-petrol: #1A7FB0;
  --wn-light-bg: #F7F8FC;
  --wn-light-ink: #1B2140;

  --bg: var(--wn-light-bg);
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --ink: var(--wn-light-ink);
  --muted: #5a6280;
  --line: #d6daea;
  --accent: var(--wn-blue);
  --accent-ink: #ffffff;
  --accent-soft: #e3e9ff;
  --ok: #2e7d4f;
  --ok-soft: #dff0e5;
  --warn: #9a6400;
  --warn-soft: #f7ecd6;
  --bad: #b3261e;
  --bad-soft: #f8dedb;
  --q-quick: #e3f1e7;
  --q-strategic: #e3e9ff;
  --q-minor: #f3f1e4;
  --q-later: #f1e9e9;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Sora", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--wn-bg);
    --surface: var(--wn-surface);
    --surface-2: #161a36;
    --ink: var(--wn-ink);
    --muted: #9aa5c4;
    --line: #262c52;
    --accent: var(--wn-cyan);
    --accent-ink: var(--wn-bg);
    --accent-soft: #10284a;
    --ok: #6cc28c;
    --ok-soft: #13291f;
    --warn: #e0ac4c;
    --warn-soft: #33290f;
    --bad: #f08a80;
    --bad-soft: #3a1c1f;
    --q-quick: #12281f;
    --q-strategic: #10284a;
    --q-minor: #29261a;
    --q-later: #2c1c22;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0 0 .4em; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .8em; }
code { font-family: var(--mono); font-size: .88em; }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
main.wrap { padding-block: 24px 64px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 600; color: var(--accent); margin: 0 0 .3em; }
.empty { padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.alert { padding: 10px 14px; border-radius: var(--radius); background: var(--bad-soft); color: var(--bad); }
.warn-text { color: var(--warn); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Barra superior */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; flex: none; display: block; }
.brand-name { font-family: var(--display); font-weight: 600; }
.topnav { display: flex; gap: 16px; align-items: center; }
.topnav a { color: var(--ink); text-decoration: none; }
.linklike { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }

/* Controles */
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 2.6em; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
label { font-weight: 500; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
progress { appearance: none; width: 100%; height: 6px; border: 0; border-radius: 3px; background: var(--surface-2); overflow: hidden; vertical-align: middle; }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-block: 24px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 140px; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.grid-form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 500; margin-bottom: 6px; }
.check { display: flex; gap: 8px; align-items: baseline; font-weight: 400; padding: 3px 0; }
.check input { width: auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* Login */
.login { max-width: 400px; margin: 6vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.login-logo img { display: block; width: 212px; height: auto; margin: 0 0 20px -6px; }
.site-foot { display: flex; align-items: center; gap: 8px; justify-content: center; padding-block: 0 28px; color: var(--muted); font: 600 .8rem/1 var(--display); letter-spacing: .02em; }
.site-foot img { display: block; }

/* Lista de empresas */
.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list th, .list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
.list tr:last-child td { border-bottom: 0; }
.list td progress { width: 120px; margin-right: 8px; }
.list .num { text-align: right; }

/* Cabecera de empresa */
.company-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.company-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.linkbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius); }
.linkbox-label { font-size: .8rem; color: var(--muted); }
.linkbox code { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; user-select: all; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* Cuestionario */
.intro { max-width: 72ch; margin-bottom: 24px; }
.q-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; }
.q-nav { position: sticky; top: 72px; font-size: .9rem; }
.q-nav ol { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 2px; }
.q-nav li { display: flex; justify-content: space-between; gap: 8px; }
.q-nav li a { color: var(--ink); text-decoration: none; padding: 3px 0; }
.q-nav li a:hover { color: var(--accent); }
.progress-box { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: baseline; }
.progress-box progress { grid-column: 1 / -1; }
.save-state { color: var(--muted); }
.save-state.ok { color: var(--ok); }
.save-state.bad { color: var(--bad); }
.q-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; scroll-margin-top: 72px; }
.q-section > header { margin-bottom: 8px; }
.q-section > header p { max-width: 72ch; }
.question { padding: 14px 0; border-top: 1px solid var(--line); }
.q-section > header + .question { border-top: 0; }
.q-label { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.q-label label { max-width: 72ch; }
.q-state { margin-left: auto; font-size: .75rem; color: var(--muted); }
.q-help { font-size: .85rem; color: var(--muted); margin: -2px 0 8px; max-width: 72ch; }
.question.answered .q-label label::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: middle; }
.question.error input, .question.error textarea, .question.error select { border-color: var(--bad); }
.question.admin-only { background: linear-gradient(90deg, var(--accent-soft), transparent 40%); margin-inline: -24px; padding-inline: 24px; }
.question input[type=text], .question select { max-width: 520px; }
.with-unit { display: flex; align-items: center; gap: 8px; max-width: 280px; }
.unit { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.options, .scale { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { position: relative; font-weight: 400; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; background: var(--surface); }
.chip.num span { min-width: 38px; text-align: center; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.scale-end { font-size: .8rem; color: var(--muted); }
.finish { border-color: var(--accent); }

/* Oportunidades */
.matrix-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.matrix-layout .card { margin: 0; }
.matrix { position: relative; padding: 0 0 26px 26px; }
.axis { position: absolute; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.axis-x { bottom: 4px; right: 0; }
.axis-y { left: 0; top: 0; writing-mode: vertical-rl; transform: rotate(180deg); }
.cells { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; aspect-ratio: 5 / 4; max-width: 100%; }
.cell { position: relative; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 4px; padding: 4px; border-radius: 3px; min-height: 48px; }
.cell.quad-quick { background: var(--q-quick); }
.cell.quad-strategic { background: var(--q-strategic); }
.cell.quad-minor { background: var(--q-minor); }
.cell.quad-later { background: var(--q-later); }
.corner { position: absolute; top: 4px; left: 6px; right: 6px; font-size: .68rem; font-weight: 600; color: var(--muted); line-height: 1.15; pointer-events: none; }
.dot { position: relative; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .78rem; font-weight: 700; text-decoration: none; font-variant-numeric: tabular-nums; }
.dot:hover { transform: scale(1.1); }
.opp-list { display: flex; flex-direction: column; gap: 12px; }
.opp { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 72px; }
.opp:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.opp.discarded { opacity: .6; }
.opp-head { display: flex; gap: 10px; align-items: center; }
.opp-n { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; }
.opp-title { font-weight: 600; border-color: transparent; background: transparent; padding-inline: 4px; }
.opp-title:hover { border-color: var(--line); }
.opp-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 10px; }
.opp-grid label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--muted); font-weight: 500; }
.opp-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pill.quad-quick { background: var(--q-quick); color: var(--ok); }
.pill.quad-strategic { background: var(--q-strategic); color: var(--accent); }
.pill.quad-minor { background: var(--q-minor); color: var(--warn); }
.pill.quad-later { background: var(--q-later); color: var(--bad); }
.suggest-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.suggest { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.suggest p { margin: 4px 0 0; color: var(--muted); }

/* Propuesta */
.provider-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.provider { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); width: 100%; }
.provider input { width: auto; margin-top: 4px; }
.running { color: var(--warn); }
.running::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); margin-right: 8px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .running::before { animation: none; } .dot:hover { transform: none; } }
.proposal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 24px; margin-bottom: 18px; }
.proposal-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.prose { max-width: 80ch; }
.prose h1 { font-size: 1.6rem; margin-top: .4em; }
.prose h2 { font-size: 1.25rem; margin-top: 1.4em; }
.prose h3 { font-size: 1.05rem; margin-top: 1.2em; }
.prose table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: .9rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.prose li { margin-bottom: .25em; }
.danger-zone { border-color: var(--bad-soft); }

/* Informe imprimible */
.print-page { background: var(--surface); }
.print-bar { display: flex; gap: 8px; justify-content: space-between; padding: 12px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); }
.print-body { margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-left)) 64px; }
@media print {
  :root { color-scheme: light; --ink: #000; --muted: #444; --line: #bbb; --surface: #fff; --surface-2: #eee; --accent: #1F4BFF; }
  .site-foot, .topbar { display: none; }
  .no-print { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .print-body { padding: 0; max-width: none; }
  .prose table { display: table; }
  h2, h3 { break-after: avoid; }
  tr, li { break-inside: avoid; }
}

/* Móvil */
@media (max-width: 860px) {
  .q-layout, .matrix-layout { grid-template-columns: minmax(0, 1fr); }
  .q-nav { position: static; }
  .q-nav ol { display: none; }
  .grid-form { grid-template-columns: minmax(0, 1fr); }
  .opp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list thead { display: none; }
  .list, .list tbody, .list tr, .list td { display: block; }
  .list tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .list td { border: 0; padding: 4px 12px; }
  .list .num { text-align: left; }
  .q-section { padding: 18px 16px; }
  .question.admin-only { margin-inline: -16px; padding-inline: 16px; }
  .cells { aspect-ratio: auto; }
}

/* PIN */
.pin-input { font-family: var(--mono); font-size: 1.6rem; letter-spacing: .5em; text-align: center; max-width: 240px; }
.linkbox code.pin-code { flex: none; } .pin-code { font-size: 1rem; font-weight: 700; letter-spacing: .15em; }

/* Seguridad / doble factor */
.narrow { max-width: 420px; }
.steps { padding-left: 1.2em; margin: 0 0 12px; }
.qr-block { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin: 8px 0 20px; }
.qr { background: #fff; padding: 8px; border-radius: var(--radius); border: 1px solid var(--line); line-height: 0; }
.qr svg { max-width: 100%; height: auto; }
.secret { display: inline-block; font-size: 1rem; letter-spacing: .08em; overflow-wrap: anywhere; margin-right: 8px; }
.codes { font-family: var(--mono); font-size: 1rem; background: var(--surface-2); padding: 12px 16px; border-radius: var(--radius); columns: 2; max-width: 420px; }
