/* MiEscáner — hoja de estilos única. Paleta y estilo según docs/design/mockup.png */

:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF6FF;
  --primary-soft-2: #DBEAFE;
  --dark: #0F172A;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-2: #64748B;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --success: #16A34A;
  --success-soft: #F0FDF4;
  --error: #DC2626;
  --error-soft: #FEF2F2;
  --warning: #B45309;
  --warning-soft: #FFFBEB;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .08);
  --focus: 0 0 0 3px rgba(37, 99, 235, .35);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 268px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
.icon { flex-shrink: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.625rem; font-weight: 700; }
h2 { font-size: 1.125rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  background: var(--dark); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 16px; }

.muted { color: var(--text-2); }
.small { font-size: .875rem; }
.xsmall { font-size: .8125rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.text-center { text-align: center; }
.hidden, [hidden] { display: none !important; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-name { display: block; font-weight: 700; font-size: 1.25rem; letter-spacing: -.02em; line-height: 1.1; }
.brand-tagline { display: block; font-size: .75rem; color: var(--text-2); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  font: inherit; font-weight: 600; font-size: .9375rem; line-height: 1;
  border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { box-shadow: var(--focus); border-radius: 10px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--border-strong); }
.btn-danger { background: var(--surface); color: var(--error); border-color: #FCA5A5; }
.btn-danger:hover { background: var(--error-soft); }
.btn-danger-solid { background: var(--error); color: #fff; }
.btn-danger-solid:hover { background: #B91C1C; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .875rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; border-radius: 8px; }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed; pointer-events: none;
}
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: block; }
.btn.is-loading { pointer-events: none; opacity: .85; }

.spinner { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 18px; }
/* align-items/align-content: start evita que un campo sin ayuda ni error se estire
   para igualar la altura del de al lado (eso desplazaba sus iconos fuera del recuadro). */
.form-grid-2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 560px) { .form-grid-2 { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 6px; align-content: start; }
.label { font-size: .875rem; font-weight: 600; color: var(--text); }
.label .optional { font-weight: 400; color: var(--text-2); }
/* El contenedor mide exactamente lo que el input: los iconos se centran respecto a él. */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .input { display: block; flex: 1 1 auto; min-width: 0; }
.input-wrap > .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-2); pointer-events: none;
}
.input, .select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap > .icon ~ .input { padding-left: 40px; }
.input-wrap.has-toggle .input { padding-right: 46px; }
/* Edge agrega su propio botón de "mostrar contraseña"; ya tenemos uno. */
.input::-ms-reveal, .input::-ms-clear { display: none; }
.input::placeholder { color: #94A3B8; }
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: var(--focus); }
.input[readonly] { background: var(--bg); color: var(--text-2); }
.select {
  appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field.is-invalid .input, .field.is-invalid .select, .input[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--error);
}
.field.is-invalid .input:focus, .field.is-invalid .select:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .25); }
.field-error { display: flex; align-items: flex-start; gap: 6px; color: var(--error); font-size: .8125rem; }
.field-error .icon { margin-top: 1px; }
.field-hint { color: var(--text-2); font-size: .8125rem; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px; color: var(--text-2); cursor: pointer;
}
.pw-toggle:hover { color: var(--text); background: var(--bg); }
.pw-toggle .icon-hide { display: none; }
.pw-toggle[aria-pressed="true"] .icon-show { display: none; }
.pw-toggle[aria-pressed="true"] .icon-hide { display: block; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: .875rem; cursor: pointer; }
.check input {
  appearance: none; flex-shrink: 0; width: 18px; height: 18px; margin: 1px 0 0;
  border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after {
  content: ""; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}
.check input:focus-visible { box-shadow: var(--focus); }
.field.is-invalid .check input { border-color: var(--error); }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 420px) { .choice-grid { grid-template-columns: 1fr; } }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; font-size: .875rem; background: var(--surface);
  transition: border-color .15s, background-color .15s;
}
.choice input:hover + span { border-color: var(--border-strong); }
.choice input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.choice input:focus-visible + span { box-shadow: var(--focus); }
.field.is-invalid .choice span { border-color: #FCA5A5; }

/* ---------- Alertas ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; border: 1px solid; font-size: .875rem;
}
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--error-soft); border-color: #FECACA; color: #991B1B; }
.alert-success { background: var(--success-soft); border-color: #BBF7D0; color: #166534; }
.alert-info { background: var(--primary-soft); border-color: var(--primary-soft-2); color: #1E40AF; }
.alert-warning { background: var(--warning-soft); border-color: #FDE68A; color: var(--warning); }

/* ---------- Insignias ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.4;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft-2); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: #BBF7D0; }
.badge-error { background: var(--error-soft); color: var(--error); border-color: #FECACA; }
.badge-soon { background: #F1F5F9; color: var(--text-2); border-color: var(--border); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 24px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-sub { color: var(--text-2); font-size: .875rem; margin-top: 4px; }
@media (max-width: 560px) { .card { padding: 18px; } }

/* ---------- Layout de autenticación ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.auth-aside {
  background: var(--dark); color: #E2E8F0; padding: 48px; display: flex; flex-direction: column;
  justify-content: space-between; gap: 40px; position: relative; overflow: hidden;
}
.auth-aside .brand { color: #fff; }
.auth-aside .brand-tagline { color: #94A3B8; }
.auth-aside h2 { font-size: 2rem; font-weight: 700; color: #fff; max-width: 420px; letter-spacing: -.02em; }
.auth-aside p { color: #94A3B8; max-width: 420px; margin-top: 12px; }
.auth-features { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.auth-features li { display: flex; gap: 12px; align-items: center; color: #CBD5E1; font-size: .9375rem; }
.auth-features .feat-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(37, 99, 235, .18); color: #93C5FD;
}
.auth-aside-foot { color: #64748B; font-size: .8125rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .brand { margin-bottom: 28px; }
.auth-title { font-size: 1.625rem; }
.auth-sub { color: var(--text-2); margin-top: 6px; margin-bottom: 24px; }
.auth-foot { margin-top: 24px; text-align: center; color: var(--text-2); font-size: .9375rem; }
.auth-card .brand-mobile { display: none; }
.auth-wide .auth-card { max-width: 520px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-card .brand-mobile { display: flex; }
  .auth-main { align-items: flex-start; padding: 32px 16px 48px; }
}

/* ---------- Layout de la app ---------- */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 0 8px; }
.nav { display: grid; gap: 4px; }
.nav-link, .nav-button {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #334155; font-weight: 500; font-size: .9375rem; text-decoration: none;
  background: transparent; border: 0; width: 100%; font: inherit; cursor: pointer; text-align: left;
}
.nav-link:hover, .nav-button:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-link .badge { margin-left: auto; font-size: .625rem; padding: 1px 7px; letter-spacing: .01em; }
.nav-link.is-soon { color: #94A3B8; }
.nav-foot { margin-top: auto; display: grid; gap: 4px; border-top: 1px solid var(--border); padding-top: 16px; }
.nav-user { padding: 4px 12px 10px; min-width: 0; }
.nav-user strong { display: block; font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user span { display: block; font-size: .8125rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar { display: none; }
.app-main { padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--text-2); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.container { max-width: 1120px; }

.sidebar-backdrop { display: none; }
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
  }
  .topbar .brand-mark { width: 34px; height: 34px; }
  .topbar .brand-name { font-size: 1.125rem; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop.is-open { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 40; }
  .app-main { padding: 20px 16px 40px; }
}

/* ---------- Dashboard ---------- */
.grid { display: grid; gap: 20px; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.stat { display: flex; align-items: center; gap: 14px; }
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); flex-shrink: 0;
}
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.purple { background: #F5F3FF; color: #7C3AED; }
.stat-value { font-size: 1.375rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--text-2); font-size: .875rem; }

.hero-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; padding: 0; overflow: hidden; }
.hero-card > div { padding: 28px; }
.hero-steps { background: #F1F5FD; display: grid; gap: 18px; align-content: center; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft-2); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.step strong { display: block; font-weight: 600; }
.step span { color: var(--text-2); font-size: .875rem; }
@media (max-width: 860px) { .hero-card { grid-template-columns: 1fr; } }

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border);
}
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }
.list-icon {
  width: 40px; height: 40px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text-2); flex-shrink: 0;
}
.list-body { flex: 1; min-width: 0; }
.list-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { color: var(--text-2); font-size: .8125rem; }
.list-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 560px) {
  .list-item { flex-wrap: wrap; }
  .list-actions { width: 100%; justify-content: flex-end; }
}

.empty {
  text-align: center; padding: 28px 16px; color: var(--text-2); display: grid; justify-items: center; gap: 10px;
}
.empty .empty-icon {
  width: 48px; height: 48px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border);
  display: grid; place-items: center; color: #94A3B8;
}
.empty strong { color: var(--text); }

.soon-card { position: relative; }
.soon-card .soon-body { color: var(--text-2); font-size: .875rem; }

/* ---------- Planes ---------- */
.plans { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); max-width: 1100px; }
.plan { display: flex; flex-direction: column; gap: 16px; }
.plan.is-current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow); }
.plan-price { font-size: 2.25rem; font-weight: 700; letter-spacing: -.02em; }
.plan-price small { font-size: .8125rem; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.plan-features { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: .9375rem; }
.plan-features li { display: flex; gap: 10px; align-items: flex-start; }
.plan-features .icon { color: var(--success); margin-top: 2px; }
.plan-features li.off { color: var(--text-2); }
.plan-features li.off .icon { color: #94A3B8; }
.plan .btn { margin-top: auto; }

/* ---------- Tabla de definición ---------- */
.kv { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 10px 16px; font-size: .9375rem; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 10px; } }

/* ---------- Vinculación ---------- */
.pair-box { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; }
.qr {
  width: 220px; height: 220px; padding: 10px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); display: grid; place-items: center;
}
.qr svg { width: 100%; height: 100%; }
.qr.is-expired svg { opacity: .15; }
.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-size: .875rem; }
.pair-status { display: flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--text-2); }
.pair-status.ok { color: var(--success); font-weight: 600; }
.pair-status.bad { color: var(--error); }
@media (max-width: 680px) {
  .pair-box { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .qr { width: 200px; height: 200px; }
  .copy-field { width: 100%; }
}

/* ---------- Diálogo ---------- */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px;
  width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--text);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Móvil (/m y /vincular) ---------- */
.mobile-page { min-height: 100vh; display: flex; flex-direction: column; }
.mobile-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.mobile-main { flex: 1; padding: 20px 16px 40px; width: 100%; max-width: 520px; margin: 0 auto; }
.big-icon {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 16px;
  background: var(--primary-soft); color: var(--primary);
}
.big-icon.green { background: var(--success-soft); color: var(--success); }
.big-icon.red { background: var(--error-soft); color: var(--error); }

/* ---------- Páginas legales y error ---------- */
.doc-page { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }
.doc-page h1 { margin: 20px 0 8px; }
.doc-page h2 { margin: 28px 0 8px; }
.doc-page p, .doc-page li { color: #334155; }
.doc-page p + p { margin-top: 10px; }
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.error-page .card { max-width: 440px; width: 100%; text-align: center; }
.error-code { font-size: 3rem; font-weight: 700; color: var(--primary); line-height: 1; }
.row-center { justify-content: center; }
.fieldset-reset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset-reset legend { padding: 0; margin-bottom: 6px; }
.draft-banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px;
  background: var(--warning-soft); border: 1px solid #FDE68A; color: var(--warning); font-size: .875rem; margin-top: 20px;
}
.back-link { gap: 6px; width: fit-content; }
.mb-4 { margin-bottom: 24px; }
.form-narrow { max-width: 480px; }
.hero-card h2 { font-size: 1.25rem; }
.inline-form { display: inline-flex; }
.rename { margin-top: 6px; }
.rename summary { cursor: pointer; color: var(--primary); width: fit-content; list-style: none; }
.rename summary::-webkit-details-marker { display: none; }
.rename summary:focus-visible { box-shadow: var(--focus); border-radius: 4px; }
.rename-form { margin-top: 8px; max-width: 420px; }
.list-item.device-item { align-items: flex-start; }
.pair-status .spinner { display: block; }
.pair-status.ok .spinner, .pair-status.bad .spinner { display: none; }
.owner-name { font-size: 1.25rem; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.text-dark { color: var(--text); }
.device-chip {
  display: inline-flex; align-items: center; gap: 8px; margin: 4px auto 0; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg); font-weight: 600; max-width: 100%;
}
.device-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps-list { margin: 0; padding-left: 22px; display: grid; gap: 8px; color: #334155; }
.btn.is-copied { color: var(--success); border-color: #BBF7D0; }
.hero-card.pair-card { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 860px) { .hero-card.pair-card { grid-template-columns: 1fr; } }

/* ---------- Fase 2: sesiones de escaneo (PC) ---------- */
.stat-icon.orange { background: #FFF7ED; color: #C2410C; }
.stat-value-sm { font-size: 1.0625rem; }
.grid-4 { display: grid; gap: 20px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr; } }
.narrow-card { max-width: 620px; }
.list-link { color: var(--text); text-decoration: none; }
.list-link:hover { color: var(--primary); text-decoration: underline; }
.history-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

.session-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 20px; }
.session-title { min-width: 0; flex: 1 1 280px; }
.eyebrow { display: block; font-size: .8125rem; color: var(--text-2); font-weight: 500; }
.session-name-row { gap: 4px; flex-wrap: nowrap; }
.session-name-row h1 { font-size: 1.5rem; overflow-wrap: anywhere; }
.rename-session { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.rename-session .input { flex: 1 1 240px; min-height: 40px; }
.rename-session .field-error { flex-basis: 100%; }
.session-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.session-head .page-actions { margin-left: auto; }

.conn { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 600; padding: 3px 10px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); }
.conn[data-state="online"] { color: var(--success); border-color: #BBF7D0; background: var(--success-soft); }
.conn[data-state="reconnecting"] { color: var(--warning); border-color: #FDE68A; background: var(--warning-soft); }

.limit-banner { display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin-bottom: 20px;
  border: 1px solid var(--primary-soft-2); background: var(--primary-soft); border-radius: var(--radius-lg); }
.limit-banner[hidden] { display: none; }
.limit-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--primary-soft-2); color: var(--primary); }
.limit-body { flex: 1; min-width: 0; }
.limit-body p { color: #334155; font-size: .9375rem; margin-top: 2px; }
@media (max-width: 620px) { .limit-banner { flex-direction: column; align-items: flex-start; } }

.connect-card[hidden] { display: none; }
.qr-sm { width: 150px; }
.qr-sm svg { width: 150px; height: 150px; }

.table-card { padding: 0; overflow: hidden; }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); }
.table-toolbar .search { flex: 0 1 380px; min-width: 200px; }
/* En pantallas angostas la tabla se desplaza dentro de la tarjeta (la página no) y el código no se parte letra por letra. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: .9375rem; }
.table .code { min-width: 200px; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8125rem; font-weight: 600; color: var(--text-2); background: var(--bg); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFCFF; }
.table .num { color: var(--text-2); width: 48px; }
.table .qty { text-align: right; width: 96px; font-variant-numeric: tabular-nums; }
.table th.qty { text-align: right; }
.table .time { white-space: nowrap; font-variant-numeric: tabular-nums; color: #334155; }
.table .code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .875rem;
  overflow-wrap: anywhere; word-break: break-word; max-width: 420px; }
.table .actions { width: 72px; text-align: center; }
.table tr.is-new { animation: flash-row 1.6s ease-out; }
@keyframes flash-row { from { background: #DCFCE7; } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .table tr.is-new { animation: none; } }
.fmt { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; white-space: nowrap;
  background: var(--success-soft); color: #15803D; }
.fmt-code { background: var(--primary-soft); color: var(--primary); }
.fmt-2d { background: #F5F3FF; color: #7C3AED; }
.fmt-manual { background: #F1F5F9; color: #475569; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9375rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--border-strong);
  transition: background .15s; flex-shrink: 0; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
.switch input:disabled + .switch-track { opacity: .5; }

/* ---------- Fase 2: escáner en el celular (/m) ---------- */
.mobile-main-scanner { padding-top: 12px; }
.scanner { display: grid; gap: 14px; }
.scanner [hidden] { display: none !important; }
.scan-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scan-top-text { min-width: 0; }
.scan-session { display: block; font-size: 1.0625rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wait-line { display: flex; justify-content: center; align-items: center; gap: 8px; }

.camera { position: relative; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%; border-radius: var(--radius-lg);
  overflow: hidden; background: #0B1220; }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-frame { position: absolute; inset: 22% 14%; pointer-events: none; transition: transform .15s; }
.camera-frame span { position: absolute; width: 34px; height: 34px; border: 4px solid #22C55E; }
.camera-frame span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.camera-frame span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.camera-frame span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.camera-frame span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
.camera.is-flash .camera-frame { transform: scale(1.04); }
.camera.is-flash::after { content: ""; position: absolute; inset: 0; border: 6px solid #22C55E; border-radius: inherit;
  background: rgba(34, 197, 94, .18); pointer-events: none; }
.camera-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  padding: 24px; text-align: center; color: #E2E8F0; background: rgba(11, 18, 32, .82); }
.camera-overlay p { max-width: 300px; }
.camera-controls { position: absolute; left: 12px; right: 12px; bottom: 14px; display: flex; align-items: center;
  justify-content: center; gap: 12px; }
.zoom { display: inline-flex; padding: 4px; border-radius: 12px; background: rgba(15, 23, 42, .6); }
.zoom button { min-width: 52px; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; }
.zoom button[aria-pressed="true"] { background: #fff; color: var(--primary); }
.torch { position: absolute; right: 0; width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid;
  place-items: center; background: rgba(15, 23, 42, .6); color: #fff; cursor: pointer; }
.torch[aria-pressed="true"] { background: #FACC15; color: #0F172A; }
.zoom button:focus-visible, .torch:focus-visible { box-shadow: 0 0 0 3px #fff; outline: none; }

.scan-panel { display: grid; gap: 14px; }
.scan-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: var(--primary-soft); color: #1E3A8A; font-weight: 600; }
.scan-status[data-tone="warn"] { background: var(--warning-soft); color: var(--warning); }
.scan-status[data-tone="error"] { background: var(--error-soft); color: var(--error); }
.scan-status[data-tone="ok"] { background: var(--success-soft); color: #15803D; }
.last-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
.last-code { font-size: 1.5rem; font-weight: 700; overflow-wrap: anywhere; min-width: 0; line-height: 1.25; }
.scan-stats { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: 12px; }
.scan-stats > div { display: grid; padding: 12px 16px; }
.scan-stats > div + div { border-left: 1px solid var(--border); }
.scan-stats strong { font-size: 1.5rem; line-height: 1.2; }
.scan-stats span { color: var(--text-2); font-size: .875rem; }

.limit-card { display: grid; justify-items: center; gap: 6px; text-align: center; border-color: var(--primary-soft-2);
  background: var(--primary-soft); }
.limit-card p { color: #334155; font-size: .9375rem; }
.unsent { border-color: #FDE68A; background: var(--warning-soft); }
.unsent-list { margin: 8px 0 0; padding-left: 18px; max-height: 140px; overflow: auto; font-family: ui-monospace, Consolas, monospace;
  overflow-wrap: anywhere; }

dialog.sheet { width: min(480px, calc(100vw - 24px)); margin: auto auto 12px; border: 0; border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-lg); }
dialog.sheet::backdrop { background: rgba(15, 23, 42, .5); }

/* Exportar */
dialog.export-dialog { width: min(520px, calc(100vw - 24px)); border: 0; border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-lg); }
dialog.export-dialog::backdrop { background: rgba(15, 23, 42, .5); }
.file-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .file-choices { grid-template-columns: 1fr; } }
.file-choice { position: relative; cursor: pointer; }
.file-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-choice > span { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 12px; height: 100%; }
.file-choice > span > span { display: grid; }
.file-choice small { color: var(--text-2); font-size: .75rem; }
.file-choice input:checked + span { border-color: var(--success); background: var(--success-soft); }
.file-choice input:checked + span .icon { color: var(--success); }
.file-choice input:focus-visible + span { box-shadow: var(--focus); }
.export-options { display: grid; gap: 12px; }

/* Avisos de cobro */
.billing-alert { align-items: center; flex-wrap: wrap; gap: 12px; }
.billing-alert .row { gap: 10px; align-items: flex-start; flex: 1 1 280px; }
[data-auto-refresh] { gap: 8px; }

/* Botón con precio en segunda línea ("Contratar Pro" / "$99 MXN al mes, IVA incluido") */
.btn-two-lines { min-height: 52px; }
.btn-two-lines .btn-label { display: grid; line-height: 1.25; text-align: center; }
.btn-two-lines .btn-label small { font-size: .75rem; font-weight: 500; opacity: .9; }
