/* ===== DobleFactor — Sesame Design System (DS v3) =====
   Tokens de @sesamehr/react-design-system (paleta v3, la misma que usan las
   apps internas): neutros zinc · primario accent-custom #415BFF · insight
   violeta #6C63FF · semántica fija (verde = bien, ámbar = atención, rojo = mal).
   Tipografía: Inter Tight. Pesos moderados: 700 como máximo.
   Marca    : escudo con candado (ver <symbol id="i-mark"> en index.html)       */

:root {
  /* --- Marca / primario (accent-custom) --- */
  --primary: #415bff;        /* accent-custom-500 */
  --primary-600: #3449cc;    /* accent-custom-600 */
  --primary-soft: #ecefff;   /* accent-custom-50 */
  --primary-ink: #273799;    /* accent-custom-700 */
  --ring: #8d9dff;           /* accent-custom-300 */
  --insight: #6c63ff;        /* indigo-500 */

  /* --- Neutros (zinc) --- */
  --bg: #fafafa;             /* zinc-50 */
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-hover: #f4f4f5;     /* zinc-100 */
  --muted-bg: #f4f4f5;       /* zinc-100 */
  --line: #e4e4e7;           /* zinc-200 */
  --text: #18181b;           /* zinc-900 */
  --text-dim: #71717b;       /* zinc-500 */
  --slate: #a1a1aa;          /* zinc-400 */

  /* --- Semántica fija --- */
  --success: #22c55e;        /* grass-500 */
  --success-ink: #15803d;    /* texto verde legible sobre blanco */
  --warning: #f59e0b;        /* amber-500 */
  --warning-ink: #b45309;    /* texto ámbar legible sobre blanco (AA) */
  --danger: #fb2c36;         /* red-500 */
  --danger-ink: #dc2626;

  /* --- Tipografía --- */
  --font-brand: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-h1: clamp(32px, 7vw, 42px);
  --fs-h2: clamp(22px, 5vw, 28px);
  --fs-body: 17px;
  --fs-ui: 15px;

  --radius: 12px;            /* radio de tarjeta del DS */
  --ease-organic: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 3px rgba(2, 6, 23, .06);
  --shadow-md: 0 4px 12px rgba(2, 6, 23, .08);
  --shadow: 0 12px 32px rgba(2, 6, 23, .14);
  font-family: var(--font-brand);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  /* Ambiente del DS: manchas muy diluidas del primario sobre zinc-50. */
  background:
    radial-gradient(540px 540px at 82% 14%, color-mix(in oklab, var(--primary) 7%, transparent), transparent 62%),
    radial-gradient(580px 580px at 13% 84%, color-mix(in oklab, var(--primary) 6%, transparent), transparent 64%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-brand);
  -webkit-font-smoothing: antialiased;
  font-size: var(--fs-ui);
  /* En un móvil, 100vh es la altura CON las barras del navegador ocultas, que
     es mayor que la visible: la página acababa midiendo más que la pantalla y
     se podía desplazar sin que hubiera nada debajo. 100dvh es lo que se ve de
     verdad. El vh queda como reserva para navegadores sin dvh. */
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
/* El atributo `hidden` del navegador lo aplica la hoja de estilos del agente
   de usuario con `display: none`, así que cualquier clase que declare `display`
   lo anula sin avisar: es lo que dejaba visible el círculo vacío de la inicial
   junto a la foto de perfil. Con esto, `hidden` vuelve a significar oculto. */
[hidden] { display: none !important; }
.muted { color: var(--text-dim); font-size: 14px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 1px; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .92em; color: var(--primary-ink);
  background: var(--primary-soft); padding: 1px 5px; border-radius: 5px;
}

.screen { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }

/* hoja de símbolos SVG: fuera del flujo, sin estilo en línea */
.svg-defs { position: absolute; width: 0; height: 0; }

/* ---------- Pantallas de acceso (SSO + contraseña maestra) ---------- */
.auth-screen {
  display: flex; align-items: center; justify-content: center;
  /* viewport-fit=cover deja el contenido pasar por debajo del indicador de
     inicio en los iPhone con muesca; env() lo devuelve a zona visible. */
  padding: 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-top: max(24px, env(safe-area-inset-top));
}
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow);
}
.brand-logo { display: flex; justify-content: center; margin-bottom: 14px; }

/* Móviles de pantalla corta (y cualquiera con el teclado abierto): se aprieta
   el acceso para que quepa sin desplazar, que es lo que se espera de una
   pantalla de login. El eje que importa aquí es el alto, no el ancho. */
@media (max-height: 720px) {
  .auth-screen { padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .auth-card { padding: 26px 22px; border-radius: 14px; }
  .brand-logo { margin-bottom: 8px; }
  .brand-logo svg { width: 42px; height: 42px; }
  .auth-subtitle { margin: 8px 0 16px; }
  .steps { margin-bottom: 16px; }
  .legal { margin-top: 16px; padding-top: 14px; }
  .user-chip-lg { margin-bottom: 14px; }
}
.brand-title {
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.05;
}
.brand-title span { color: var(--primary); }
.auth-subtitle {
  color: var(--text-dim);
  font-size: clamp(15px, 3.6vw, 17px);
  line-height: 1.5;
  margin: 10px 0 22px;
}
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.legal {
  color: var(--slate); font-size: 12px; line-height: 1.5;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line);
}
.hint { margin-top: 8px; font-size: 13px; }

/* pasos 1 → 2 */
.steps {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  list-style: none; margin: 0 0 22px; flex-wrap: wrap;
}
.step {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  background: var(--bg); border: 1px solid var(--line);
  padding: 6px 12px 6px 6px; border-radius: 999px;
}
.step-num {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--line); color: var(--text-dim);
  font-size: 11px; font-weight: 700;
}
.step.active { color: var(--text); border-color: var(--primary); }
.step.active .step-num { background: var(--primary); color: #fff; }
.step.done .step-num { background: var(--success); color: #fff; }


.code-block {
  display: block; text-align: left; margin: 4px 0 12px;
  padding: 9px 12px; border-radius: 8px; line-height: 1.5;
  /* wrap rather than clip: these blocks hold commands the user must copy */
  white-space: pre-wrap; word-break: break-word; overflow-x: auto;
}

/* ---------- Chip de usuario ---------- */
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px 4px 4px;
  max-width: 100%; overflow: hidden;
}
.user-chip-lg {
  display: flex; margin: 0 auto 20px; padding: 6px 16px 6px 6px;
  text-align: left; width: fit-content; max-width: 100%;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; background: var(--primary);
}
.user-avatar-fallback {
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
}

/* Colores de avatar como clases en lugar de estilo en línea: es lo que permite
   que la CSP no necesite 'unsafe-inline' en style-src. */
.avatar-c0 { background: #415bff; }   /* accent-custom-500 */
.avatar-c1 { background: #6c63ff; }   /* indigo-500 */
.avatar-c2 { background: #273799; }   /* accent-custom-700 */
.avatar-c3 { background: #3449cc; }   /* accent-custom-600 */
.avatar-c4 { background: #15803d; }   /* grass-700 */
.avatar-c5 { background: #52525c; }   /* zinc-600 */
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-meta strong { font-size: 14px; font-weight: 600; }
.user-meta small { color: var(--text-dim); font-size: 12px; }
.user-email {
  font-size: 13px; color: var(--text-dim); max-width: 150px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}


/* ---------- Inputs & botones ---------- */
.text-input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: var(--fs-ui);
  transition: border-color .15s, box-shadow .15s;
}
.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 45%, transparent);
}
select.text-input { appearance: none; cursor: pointer; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-family: inherit;
  font-size: var(--fs-ui);
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s, background .15s, opacity .15s;
  color: #fff;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn-primary { background: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-ghost { background: var(--bg-elev); border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; display: inline-flex; align-items: center; justify-content: center; }
/* los botones que en realidad son enlaces no deben salir subrayados */
a.btn { text-decoration: none; }

.lock-links { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.link-btn {
  background: none; border: none; color: var(--text-dim);
  font-family: inherit; font-size: 13px; cursor: pointer; text-decoration: underline;
}
.link-btn:hover { color: var(--primary); }
#reset-vault:hover { color: var(--danger-ink); }
.error-text { color: var(--danger-ink); font-size: 13px; min-height: 16px; text-align: left; }
.error-text.center { text-align: center; }

.btn-danger { background: var(--bg-elev); border: 1px solid color-mix(in oklab, var(--danger) 45%, transparent); color: var(--danger-ink); }
.btn-danger:hover { background: color-mix(in oklab, var(--danger) 8%, transparent); border-color: var(--danger); }
.spaced { margin-top: 10px; }

/* enlace al manual en la pantalla de acceso */
.guide-link {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 14px;
  color: var(--text-dim); font-size: 13px; font-weight: 600; text-decoration: none;
}
.guide-link:hover { color: var(--primary); }

/* lista de dispositivos */
.devices-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.device-row {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.device-row.is-current { border-color: var(--primary); }
.device-info { flex: 1; min-width: 0; }
.device-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.device-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  background: var(--primary); color: #fff; padding: 2px 6px; border-radius: 999px;
}
.device-seen { color: var(--text-dim); font-size: 12px; }
.btn-revoke {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 9px; cursor: pointer; flex-shrink: 0;
}
.btn-revoke:hover { border-color: var(--danger); color: var(--danger-ink); }

/* reordenar */
.order-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.token.dragging { opacity: .45; }
.token.drag-over { border-color: var(--primary); border-style: dashed; }
.token-actions { display: flex; flex-direction: column; gap: 2px; }
.token-edit {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 4px; border-radius: 8px; opacity: 0; transition: opacity .15s, color .15s;
}
.token:hover .token-edit { opacity: 1; }
.token-edit:hover { color: var(--primary); }
@media (hover: none) { .token-edit { opacity: 1; } }

/* aviso de riesgo (export CSV en claro) */
.warn-box {
  display: block; text-align: left;
  background: color-mix(in oklab, var(--warning) 9%, var(--bg-elev));
  border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent);
  border-left: 3px solid var(--warning);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.5; color: var(--text);
}
.warn-box strong { display: block; margin-bottom: 3px; color: var(--warning-ink); }

/* Igual que .warn-box pero sin alarma: aquí solo se aclara una confusión. */
.note-box {
  display: block; text-align: left;
  background: var(--primary-soft);
  border: 1px solid color-mix(in oklab, var(--primary) 25%, transparent);
  border-left: 3px solid var(--primary);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.5; color: var(--text);
}
.note-box strong { display: block; margin-bottom: 3px; color: var(--primary-ink); }

/* Códigos de respaldo del servicio: se teclean, se copian y se tachan. */
.svc-codes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.svc-codes:empty { display: none; }
.svc-code {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 6px 6px 11px;
}
.svc-code .svc-code-text {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px; letter-spacing: 1px; color: var(--text);
  background: none; border: none; padding: 0; cursor: pointer;
}
.svc-code .svc-code-text:hover { color: var(--primary); }
/* Un código gastado sigue a la vista: saber cuáles ya no sirven es la mitad
   del valor de tenerlos guardados. */
.svc-code.used .svc-code-text { text-decoration: line-through; color: var(--text-dim); }
.svc-code .svc-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 3px; border-radius: 6px; display: flex;
}
.svc-code .svc-btn:hover { color: var(--primary); }
.svc-code .svc-del:hover { color: var(--danger-ink); }

/* Recuento en la tarjeta de la cuenta. */
.token-svc-codes {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--text-dim);
}
.token-svc-codes.spent { color: var(--warning-ink); }

textarea.text-input { resize: vertical; min-height: 96px; line-height: 1.6; }

/* ---------- Cabecera de la app ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 18px 18px 12px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 70%, transparent);
}
/* La marca es lo único que cede espacio: así los botones nunca acaban fuera
   de la pantalla, que es lo que pasaba en móviles estrechos. */
.header-brand {
  display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 600;
  min-width: 0; overflow: hidden; flex-shrink: 1;
}
.header-brand svg { flex-shrink: 0; }
.header-brand > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-brand strong { color: var(--primary); font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.icon-btn {
  background: transparent; border: none; color: var(--text-dim);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--muted-bg); color: var(--text); }

/* --- Cabecera en pantallas estrechas -------------------------------------
   Medido con la cabecera completa (chip de sincronización, chip de usuario y
   cuatro botones): sin estos ajustes necesita 440 px, así que en un móvil de
   320-412 px había que desplazar la pantalla para alcanzar los últimos
   iconos. Los umbrales salen de ese cálculo, no de valores redondos. */
@media (max-width: 560px) {
  #sync-label { display: none; }             /* basta el punto de color */
  .user-email { display: none; }             /* la cuenta está en Ajustes */
}
@media (max-width: 480px) {
  .header-brand > span { display: none; }    /* se queda el isotipo */
}
@media (max-width: 400px) {
  .app-header { padding: 14px 12px 10px; }
  .icon-btn { width: 36px; height: 36px; }
  .search-bar { margin-left: 12px; margin-right: 12px; }
  .tokens { padding-left: 10px; padding-right: 10px; }
}

/* indicador de sincronización */
.sync-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text-dim);
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px; cursor: pointer; flex-shrink: 0;
  transition: border-color .15s, color .15s;
}
.sync-chip:hover { border-color: var(--primary); color: var(--text); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--slate); flex-shrink: 0; }
.sync-chip[data-state="synced"] .sync-dot { background: var(--success); }
.sync-chip[data-state="syncing"] .sync-dot { background: var(--primary); animation: pulse 1s ease-in-out infinite; }
.sync-chip[data-state="offline"] .sync-dot,
.sync-chip[data-state="error"] .sync-dot { background: var(--danger); }
.sync-chip[data-state="reauth"] .sync-dot { background: var(--warning); }
.sync-chip[data-state="reauth"] { border-color: color-mix(in oklab, var(--warning) 50%, transparent); color: var(--warning-ink); }
@keyframes pulse { 50% { opacity: .3; } }


/* ---------- Buscador ---------- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 18px 14px; padding: 0 12px;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text-dim);
}
.search-input {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-family: inherit; padding: 11px 0; font-size: var(--fs-ui); outline: none;
}

/* ---------- Tarjetas de código ---------- */
.tokens { padding: 0 14px 120px; display: flex; flex-direction: column; gap: 10px; }
.token {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
  cursor: pointer; transition: background .15s, transform .05s, border-color .15s, box-shadow .32s var(--ease-organic);
  position: relative; overflow: hidden;
}
.token:hover { border-color: var(--ring); box-shadow: var(--shadow-md); }
.token:active { transform: scale(.995); }
.token.copied { border-color: var(--success); }

.token-avatar {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 18px; color: #fff;
}
.token-info { flex: 1; min-width: 0; }
.token-issuer { font-weight: 600; font-size: var(--fs-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.token-account { color: var(--text-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.token-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 26px; font-weight: 700; letter-spacing: 3px; color: var(--primary);
  margin-top: 3px;
  white-space: nowrap;   /* un código partido en dos líneas es ilegible */
}
/* A 320 px el código no cabe con el tracking amplio y se partía en dos. */
@media (max-width: 400px) {
  .token-code { font-size: 22px; letter-spacing: 1.5px; }
  .token { gap: 11px; padding: 13px 13px; }
  .token-avatar { width: 40px; height: 40px; border-radius: 11px; font-size: 16px; }
}
.token-right { display: flex; align-items: center; gap: 10px; }

/* cuenta atrás circular */
.countdown { position: relative; width: 38px; height: 38px; flex-shrink: 0; }
.countdown svg { transform: rotate(-90deg); }
.countdown .track { stroke: var(--line); }
.countdown .progress { stroke: var(--primary); transition: stroke-dashoffset 1s linear, stroke .3s; }
.countdown.warn .progress { stroke: var(--danger); }
.countdown-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text-dim);
}

.token-del {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 4px; border-radius: 8px; opacity: 0; transition: opacity .15s, color .15s;
}
.token:hover .token-del { opacity: 1; }
.token-del:hover { color: var(--danger-ink); }
@media (hover: none) { .token-del { opacity: 1; } }

/* ---------- Estado vacío / FAB ---------- */
.empty-state { text-align: center; padding: 80px 24px; color: var(--text-dim); }
.empty-state svg { opacity: .25; margin-bottom: 16px; }
.empty-state p { margin: 6px 0; }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 14px));
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px color-mix(in oklab, var(--primary) 40%, transparent); transition: background .15s, transform .1s;
}
.fab:hover { background: var(--primary-600); }
.fab:active { transform: translateX(-50%) scale(.94); }

/* ---------- Modales ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(24, 24, 27, .4); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 560px) { .modal { align-items: center; } }
.modal-content {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 16px 16px 0 0; width: 100%; max-width: 480px;
  padding: 22px; box-shadow: var(--shadow);
  max-height: 92vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
@media (min-width: 560px) { .modal-content { border-radius: 16px; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h2 { font-size: 22px; font-weight: 600; letter-spacing: -.4px; }

/* pestañas */
.tabs { display: flex; gap: 6px; background: var(--muted-bg); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tab {
  flex: 1; background: none; border: none; color: var(--text-dim);
  font-family: inherit; padding: 9px; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: background .15s, color .15s;
}
.tab.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* escáner */
.scanner-frame {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 16px;
  overflow: hidden; background: #000; margin-bottom: 12px;
}
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-overlay {
  position: absolute; inset: 18%; border: 3px solid var(--primary);
  border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}

/* subida de imagen */
.upload-drop {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  border: 2px dashed var(--line); border-radius: 16px; padding: 40px 20px;
  color: var(--text-dim); cursor: pointer; transition: border-color .15s, color .15s; text-align: center;
}
.upload-drop:hover { border-color: var(--primary); color: var(--text); }

/* formularios */
#manual-form, #lock-form { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--text-dim); margin: 8px 0 2px; display: block; text-align: left; }
.field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
/* Tres selects en fila no caben: "SHA256" necesita más de un tercio del ancho
   disponible en un móvil estrecho, y el modal se desbordaba. */
@media (max-width: 380px) {
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row > div:last-child { grid-column: 1 / -1; }
}
.field-row .field-label { margin-top: 4px; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--text-dim); margin: 16px 0; font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* toast */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--text); border: none;
  color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); text-align: center;
  z-index: 100; box-shadow: var(--shadow); animation: toastIn .2s ease;
  /* Flota sobre el centro inferior, justo donde caen los botones de los
     diálogos: sin esto se traga el clic durante los 2,6 s que está visible y
     el botón parece no responder. No hay nada que pulsar en el aviso. */
  pointer-events: none;
}
@keyframes toastIn { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Recovery codes ---------- */
.codes-account { font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.codes-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin: 16px 0;
}
.code-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; color: var(--primary-ink);
  padding: 6px 4px; letter-spacing: .5px;
}
.code-chip i { color: var(--text-dim); font-style: normal; font-size: 12px; min-width: 16px; }
.codes-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.codes-actions .btn { flex: 1; padding: 11px 8px; font-size: 14px; }
#codes-modal .warn-box { margin-bottom: 16px; }

.recovery-list { display: flex; flex-direction: column; gap: 10px; }
.recovery-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px;
}
.recovery-item-head { display: flex; align-items: center; gap: 12px; }
.recovery-item-head .token-avatar { width: 36px; height: 36px; border-radius: 10px; font-size: 15px; }
.recovery-item-info { flex: 1; min-width: 0; }
.recovery-item-issuer { font-weight: 600; font-size: 15px; }
.recovery-item-meta { color: var(--text-dim); font-size: 12.5px; }
.recovery-item .btn { padding: 9px 14px; font-size: 14px; white-space: nowrap; }
.recover-form { display: flex; gap: 8px; margin-top: 11px; }
.recover-form .text-input { flex: 1; text-transform: uppercase; padding: 10px 12px; }
.recovery-item .error-text { margin-top: 6px; min-height: 0; }

@media (max-width: 420px) {
  .codes-grid { grid-template-columns: 1fr; }
  .codes-actions { flex-wrap: wrap; }
}

/* Printing the sheet is the safest way to store it, so give it a clean page. */
@media print {
  body > *:not(#codes-modal) { display: none !important; }
  #codes-modal { position: static; background: none; backdrop-filter: none; }
  #codes-modal .modal-content {
    border: none; box-shadow: none; max-height: none; animation: none; max-width: none;
  }
  .codes-actions, #codes-done { display: none !important; }
  body, #codes-modal .modal-content, .code-chip, .codes-account, .muted, .warn-box {
    color: #000 !important; background: #fff !important;
  }
}
