/* Páginas de cuenta servidas por Django (U7). Mismos tokens que la SPA (frontend/src/styles/tokens.css);
 * tema: <html data-theme> lo pone web/auth.js con la elección de la aplicación, si no, sigue al sistema. */
:root {
  --accent: #2f5bd3; --accent-hover: #2549b3; --accent-soft: #e8eefc; --accent-ink: #fff;
  --bg: #f3f4f7; --surface: #fff; --surface-2: #f8f9fb; --text: #1b2130; --muted: #5b6475;
  --border: #dde1e8; --border-strong: #c3c9d4; --ok: #1a7a4c; --ok-soft: #e3f4ea;
  --danger: #b42318; --danger-soft: #fde7e5; --focus: 0 0 0 3px rgb(47 91 211 / 0.35);
  --aside-from: #2f5bd3; --aside-to: #1d3a8f; --aside-ink: #fff;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light; font-family: var(--font); color: var(--text); background: var(--bg);
}
:root[data-theme="dark"] {
  --accent: #7b9bff; --accent-hover: #9bb3ff; --accent-soft: #1e2a4a; --accent-ink: #0b1020;
  --bg: #0f1218; --surface: #171b23; --surface-2: #1c212b; --text: #e6e9ef; --muted: #a3acbb;
  --border: #2a313e; --border-strong: #3a4352; --ok: #5fd39a; --ok-soft: #12291e;
  --danger: #ff8a7e; --danger-soft: #34171a; --focus: 0 0 0 3px rgb(123 155 255 / 0.45);
  --aside-from: #1b2a55; --aside-to: #10182f; --aside-ink: #e6e9ef;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #7b9bff; --accent-hover: #9bb3ff; --accent-soft: #1e2a4a; --accent-ink: #0b1020;
    --bg: #0f1218; --surface: #171b23; --surface-2: #1c212b; --text: #e6e9ef; --muted: #a3acbb;
    --border: #2a313e; --border-strong: #3a4352; --ok: #5fd39a; --ok-soft: #12291e;
    --danger: #ff8a7e; --danger-soft: #34171a; --focus: 0 0 0 3px rgb(123 155 255 / 0.45);
    --aside-from: #1b2a55; --aside-to: #10182f; --aside-ink: #e6e9ef;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* Disposición: presentación a la izquierda (sólo en acceso y pantallas anchas) y tarjeta centrada. */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth-entrance { grid-template-columns: minmax(320px, 5fr) 7fr; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; box-shadow: 0 16px 40px rgb(16 24 40 / 0.08); }
.auth-aside { background: linear-gradient(160deg, var(--aside-from), var(--aside-to)); color: var(--aside-ink);
  padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.aside-kicker { margin: 0; font-weight: 700; letter-spacing: 0.08em; font-size: 0.8rem; opacity: 0.85; color: inherit; }
.aside-title { margin: 0; font-size: 1.8rem; line-height: 1.25; max-width: 22ch; }
.aside-points { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 16px; max-width: 46ch; }
.aside-points li { padding-left: 30px; position: relative; line-height: 1.5; opacity: 0.95; }
.aside-points li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%;
  background: rgb(255 255 255 / 0.18); display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; }
.aside-points strong { display: block; }
@media (max-width: 860px) {
  .auth-entrance { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
@media (max-width: 480px) {
  .auth-main { padding: 0; place-items: stretch; }
  .auth-card { max-width: none; min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; padding: 28px 20px; }
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; margin-bottom: 28px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 0.9rem; }
h1 { font-size: 1.5rem; margin: 0 0 8px; line-height: 1.25; }
.lead { color: var(--muted); line-height: 1.55; margin: 0 0 22px; }
p { line-height: 1.5; }
.alt { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: 0.92rem; }
.notice { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 0.92rem; }
.steps { color: var(--muted); padding-left: 20px; margin: 0 0 8px; line-height: 1.6; font-size: 0.92rem; }

.state-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 1.4rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 16px; }
.state-ok { background: var(--ok-soft); color: var(--ok); }
.state-bad { background: var(--danger-soft); color: var(--danger); }

/* Formularios */
.auth-form { display: grid; gap: 16px; margin: 0; }
.field { display: grid; gap: 6px; }
.field label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.field input[type="email"], .field input[type="password"], .field input[type="text"] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; transition: border-color 120ms, box-shadow 120ms; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field input::placeholder { color: var(--muted); opacity: 0.8; }
.field.has-error input { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.86rem; margin: 0; }
.field-help { color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.field-help ul { margin: 4px 0 0; padding-left: 18px; }
.field-help a { font-weight: 600; }
.field-check { grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.field-check label { font-weight: 400; color: var(--muted); }
.field-check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 84px !important; }
.reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent;
  color: var(--accent); font: inherit; font-size: 0.85rem; font-weight: 600; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.reveal:hover { background: var(--accent-soft); }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 0.92rem; }
.form-error p { margin: 0; }

.btn-primary { display: block; width: 100%; padding: 12px; border: 0; border-radius: 8px; background: var(--accent);
  color: var(--accent-ink); font: inherit; font-weight: 600; font-size: 1rem; text-align: center; text-decoration: none; cursor: pointer;
  transition: background 120ms; }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-primary[aria-busy="true"] { opacity: 0.75; cursor: progress; }
.btn-link { display: block; width: 100%; background: none; border: 0; padding: 8px; color: var(--accent); font: inherit;
  text-align: center; cursor: pointer; text-decoration: none; }

/* Mensajes de Django y páginas genéricas de allauth que no se reescriben (gestión de correos). */
.messages { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.msg { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--text); font-size: 0.92rem; }
.msg-error { background: var(--danger-soft); color: var(--danger); }
.msg-success { background: var(--ok-soft); color: var(--ok); }
.auth-card form:not(.auth-form) { display: grid; gap: 12px; margin-bottom: 16px; }
.auth-card form:not(.auth-form) button { padding: 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; }
.auth-card form:not(.auth-form) button[type="submit"]:first-of-type { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.auth-card form:not(.auth-form) input[type="email"] { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.auth-nav { display: flex; gap: 6px 16px; flex-wrap: wrap; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 0.9rem; }
.auth-nav a[aria-current="page"] { color: var(--text); font-weight: 600; text-decoration: none; }

/* Aviso de privacidad y términos de uso */
.auth-legal .auth-card { max-width: 760px; }
.legal h1 { font-size: 1.6rem; margin-bottom: 16px; }
.legal h2 { font-size: 1.05rem; margin: 26px 0 8px; }
.legal p, .legal li { line-height: 1.6; color: var(--text); }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal-pending { margin-bottom: 18px; border-color: var(--danger); background: var(--danger-soft); color: var(--text); }
.legal-meta { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--muted); }
.legal-links { margin: 18px 0 0; text-align: center; font-size: 0.82rem; color: var(--muted); }
.legal-links a { color: var(--muted); }

/* Verificación en dos pasos */
.btn-secondary { display: inline-block; padding: 10px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  color: var(--text); font: inherit; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary.btn-danger { background: var(--danger); color: var(--surface); }  /* blanco en claro, oscuro en oscuro: contraste AA */
.btn-primary.btn-danger:hover { background: var(--danger); filter: brightness(0.92); color: var(--surface); }
.btn-secondary.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn-row .btn-primary { width: auto; display: inline-block; padding: 10px 16px; }
.mfa-panel { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 16px 0; }
.mfa-panel h2 { font-size: 1.05rem; margin: 0 0 8px; }
.mfa-panel p { margin: 0 0 12px; color: var(--muted); }
.mfa-panel .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mfa-panel .panel-head .badge { margin-right: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.8rem; font-weight: 600; margin-right: 6px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
/* El QR necesita fondo blanco también en el tema oscuro para que lo lean las cámaras. */
.qr { background: #fff; border-radius: 10px; padding: 12px; width: max-content; margin: 8px auto 16px; }
.qr img { display: block; width: 200px; height: 200px; }
.secret { margin: 0 0 16px; font-size: 0.92rem; }
.secret code, .codes code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.05em; word-break: break-all; }
.codes { list-style: none; padding: 12px; margin: 0 0 12px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px;
  background: var(--surface-2); border-radius: 8px; font-size: 1.05rem; }

/* Llaves de seguridad y passkeys (WebAuthn, ADR-046) */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; color: var(--muted); font-size: 0.9rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-block { display: block; width: 100%; text-align: center; }
.field-help.center { text-align: center; }
.keys { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.key { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.key-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.key-meta { margin: 6px 0 10px; color: var(--muted); font-size: 0.9rem; }
.webauthn-error { margin: 12px 0; }

/* Ayuda (/ayuda/): la guía de uso con el estilo de los documentos legales */
.help-back { margin: 0 0 8px; font-size: 0.92rem; }
.guide h2 { scroll-margin-top: 16px; }
.guide h3 { font-size: 0.98rem; margin: 18px 0 6px; }
.guide hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.guide code { font-size: 0.88em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); }
.guide table { width: 100%; border-collapse: collapse; margin: 12px 0 16px; font-size: 0.92rem; }
.guide th, .guide td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.guide th { color: var(--muted); font-weight: 600; }
.guide .table-wrap { overflow-x: auto; }

/* Planes y precios (ADR-047) */
.auth-pricing .auth-card { max-width: 1040px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 8px 0 20px; }
.plan { border: 1px solid var(--border); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.plan-featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan h2 { font-size: 1.15rem; margin: 0; }
.plan .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-tagline, .plan-alt { color: var(--muted); margin: 0; font-size: .9rem; line-height: 1.45; }
.plan-price { margin: 10px 0 0; font-size: 1rem; }
.plan-price strong { font-size: 1.6rem; }
.plan-features { margin: 12px 0 16px; padding-left: 18px; line-height: 1.6; flex: 1; }
.plan-buy { display: grid; gap: 8px; }
.pay-with { border: 1px solid var(--border, #ccc); border-radius: 8px; margin: 0; padding: 6px 10px 8px; display: grid; gap: 4px; }
.pay-with legend { font-size: .85rem; color: var(--muted); padding: 0 4px; }
.pay-with label { display: flex; align-items: center; gap: 6px; font-size: .9rem; cursor: pointer; }
.cancel-sub { margin: 4px 0; }
.cancel-sub summary { cursor: pointer; color: var(--muted); }
.cancel-sub p { margin: 8px 0; }
.plan-notes p { color: var(--muted); font-size: .9rem; line-height: 1.55; margin: 0 0 10px; }
.badge-warn { background: #fff4d6; color: #7a4b00; border-color: transparent; }
.usage { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px; }
.usage-row { display: grid; gap: 6px; }
.usage-row progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--border); }
.usage-row progress::-webkit-progress-bar { background: var(--border); }
.usage-row progress::-webkit-progress-value { background: var(--accent); }
.usage-row progress::-moz-progress-bar { background: var(--accent); }
.usage-warn progress::-webkit-progress-value { background: #b7791f; }
.usage-warn progress::-moz-progress-bar { background: #b7791f; }
.usage-full progress::-webkit-progress-value { background: var(--danger); }
.usage-full progress::-moz-progress-bar { background: var(--danger); }
.usage-full strong { color: var(--danger); }
