/* =========================================================
   BinariaOS QR Platform — Design System v2.0
   Paleta: Slate neutro + Azul corporativo como acento único
   Filosofía: limpio, serio, funcional, sin decoración innecesaria
   ========================================================= */

/* ── GOOGLE FONTS ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── VARIABLES ── */
:root {
  /* Superficies */
  --bg:          #f8fafc;
  --surface:     #ffffff;
  --surface-2:   #f1f5f9;
  --surface-3:   #e8eef5;

  /* Bordes */
  --border:      #e2e8f0;
  --border-2:    #cbd5e1;

  /* Texto */
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --text-4:      #cbd5e1;

  /* Acento principal */
  --accent:      #2563eb;
  --accent-dark: #1d4ed8;
  --accent-dim:  #eff6ff;
  --accent-mid:  #bfdbfe;

  /* Estados */
  --ok:          #16a34a;
  --ok-bg:       #f0fdf4;
  --ok-border:   #bbf7d0;
  --err:         #dc2626;
  --err-bg:      #fef2f2;
  --err-border:  #fecaca;
  --warn:        #d97706;
  --warn-bg:     #fffbeb;
  --warn-border: #fde68a;

  /* Sidebar */
  --sb-bg:       #0f172a;
  --sb-hover:    #1e293b;
  --sb-active:   #1e40af;
  --sb-text:     #94a3b8;
  --sb-text-on:  #ffffff;
  --sb-border:   rgba(255,255,255,0.06);

  /* Dimensiones */
  --sidebar-w:   248px;
  --topbar-h:    60px;

  /* Radios */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl:20px;

  /* Sombras */
  --sh-xs: 0 1px 2px rgba(0,0,0,0.05);
  --sh-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --sh:    0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --sh-md: 0 8px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --sh-lg: 0 20px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);

  /* Tipografía */
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* Ocultar scrollbar vertical del documento sin deshabilitar el scroll */
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE / Edge legacy */
}
html::-webkit-scrollbar { display: none; } /* Chrome / Safari / Opera */

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul { list-style: none; }

/* ── TIPOGRAFÍA ── */
h1 { font-size: 1.75rem;  font-weight: 800; line-height: 1.2; color: var(--text); }
h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.3; color: var(--text); }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; color: var(--text); }
h4 { font-size: 0.9375rem;font-weight: 600; color: var(--text); }
p  { color: var(--text-2); line-height: 1.65; }

/* ══════════════════════════════════════════════════════════
   LAYOUT PÚBLICO
   ══════════════════════════════════════════════════════════ */
.layout-public { display: flex; flex-direction: column; min-height: 100vh; }

/* Header público */
.public-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--sh-xs);
}
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

.public-nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 1.5rem;
}
.nav-brand {
  display: flex; align-items: center; gap: 0.625rem;
  font-weight: 700; font-size: 0.9375rem; color: var(--text);
  text-decoration: none; flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; color: var(--text); }
.nav-logo { width: 30px; height: 30px; object-fit: contain; border-radius: var(--r-sm); }
.nav-links { display: flex; align-items: center; gap: 0.75rem; }
.nav-link {
  color: var(--text-2); font-size: 0.875rem; font-weight: 500;
  padding: 0.4rem 0.6rem; border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.mobile-menu-btn { display: none; background: none; border: none; color: var(--text-2); padding: 0.25rem; }

/* Footer público */
.public-main { flex: 1; }
.public-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  background: var(--surface);
}
.footer-content {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem;
}
.footer-copy { font-size: 0.8125rem; color: var(--text-3); }
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a { font-size: 0.8125rem; color: var(--text-3); }
.footer-links a:hover { color: var(--text-2); }

/* ══════════════════════════════════════════════════════════
   LAYOUT APP (AUTENTICADO)
   ══════════════════════════════════════════════════════════ */
.layout-app { overflow: hidden; }
.app-shell  { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sb-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.125rem;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.625rem;
  text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-logo { width: 28px; height: 28px; object-fit: contain; border-radius: var(--r-sm); }
.sidebar-brand-name { color: var(--sb-text-on); font-weight: 700; font-size: 0.875rem; line-height: 1.2; }
.sidebar-close { display: none; background: none; border: none; color: var(--sb-text); padding: 0.25rem; border-radius: var(--r-sm); }
.sidebar-close:hover { color: var(--sb-text-on); background: var(--sb-hover); }

.sidebar-section { padding: 1rem 0.875rem 0.5rem; }
.sidebar-section-label {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--sb-text);
  padding: 0 0.5rem; margin-bottom: 0.375rem;
}

.sidebar-nav { flex: 1; padding: 0.75rem 0.875rem; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5625rem 0.75rem;
  border-radius: var(--r);
  color: var(--sb-text);
  font-size: 0.875rem; font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--sb-hover); color: var(--sb-text-on); text-decoration: none; }
.nav-item.active { background: var(--sb-active); color: var(--sb-text-on); }
.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.6875rem; font-weight: 700;
  padding: 0.125rem 0.4rem;
  border-radius: 999px;
  line-height: 1.4;
}

.sidebar-divider { height: 1px; background: var(--sb-border); margin: 0.5rem 0.875rem; }

.sidebar-footer {
  padding: 0.875rem;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.625rem 0.5rem;
  margin-bottom: 0.375rem;
}
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--sb-active);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.8125rem; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name {
  color: var(--sb-text-on); font-size: 0.8125rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  color: var(--sb-text); font-size: 0.6875rem;
  text-transform: capitalize;
}
.nav-item-logout { color: #f87171 !important; }
.nav-item-logout:hover { background: rgba(248,113,113,0.1) !important; color: #fca5a5 !important; }

/* Overlay móvil */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 199;
  backdrop-filter: blur(2px);
}

/* ── Main content ── */
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}

.app-topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  box-shadow: var(--sh-xs);
  flex-shrink: 0;
}
.topbar-menu-btn { display: none; background: none; border: none; color: var(--text-2); padding: 0.25rem; }
.topbar-breadcrumb {
  flex: 1; display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem;
}
.topbar-breadcrumb-home { color: var(--text-3); }
.topbar-breadcrumb-sep  { color: var(--text-4); }
.topbar-breadcrumb-current { color: var(--text); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.app-content {
  flex: 1; padding: 1.75rem 1.75rem;
  max-width: 1040px; width: 100%;
}

/* ══════════════════════════════════════════════════════════
   BOTONES
   ══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--r);
  font-size: 0.875rem; font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer; transition: all 0.15s ease;
  text-decoration: none; white-space: nowrap; line-height: 1.4;
  font-family: var(--font);
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.btn-secondary {
  background: var(--surface-2); color: var(--text-2); border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-2); }

.btn-outline {
  background: transparent; color: var(--text-2); border-color: var(--border-2);
}
.btn-outline:hover { background: var(--surface-2); color: var(--text); }

.btn-ghost {
  background: transparent; color: var(--text-2); border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: transparent; color: var(--err); border-color: var(--err-border);
}
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }

.btn-danger-solid {
  background: var(--err); color: #fff; border-color: var(--err);
}
.btn-danger-solid:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-xs  { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
.btn-sm  { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg  { padding: 0.6875rem 1.375rem; font-size: 1rem; }
.btn-xl  { padding: 0.875rem 1.75rem; font-size: 1.0625rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.5rem; }
.btn-icon.btn-sm { padding: 0.375rem; }

/* ══════════════════════════════════════════════════════════
   FORMULARIOS
   ══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 1.125rem; }
.form-label {
  display: block; font-size: 0.875rem; font-weight: 500;
  color: var(--text); margin-bottom: 0.375rem;
}
.form-label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.375rem;
}
.form-label-optional { font-size: 0.75rem; color: var(--text-3); font-weight: 400; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon {
  position: absolute; left: 0.75rem;
  color: var(--text-3); pointer-events: none;
  display: flex; align-items: center; z-index: 1;
}
.input-suffix {
  position: absolute; right: 0.75rem;
  display: flex; align-items: center; gap: 0.25rem;
}
.btn-pass-toggle {
  background: none; border: none; color: var(--text-3); padding: 0;
  display: flex; align-items: center; cursor: pointer;
  transition: color 0.15s;
}
.btn-pass-toggle:hover { color: var(--text-2); }

.form-control {
  width: 100%;
  padding: 0.5625rem 0.875rem 0.5625rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 0.9rem; font-family: var(--font);
  color: var(--text); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-control::placeholder { color: var(--text-4); }
.form-control.no-icon { padding-left: 0.875rem; }
.form-control.has-suffix { padding-right: 2.75rem; }
.form-control:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }

.form-control-color {
  padding: 0.25rem 0.375rem;
  height: 42px; width: 72px;
  cursor: pointer; border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.form-control-color:focus { outline: none; border-color: var(--accent); }

.form-hint { font-size: 0.8rem; color: var(--text-3); margin-top: 0.3rem; line-height: 1.5; }
.form-error-msg { font-size: 0.8rem; color: var(--err); margin-top: 0.3rem; }
.form-legal {
  font-size: 0.8rem; color: var(--text-3); text-align: center;
  margin-top: 1rem; line-height: 1.6;
}
.form-legal a { color: var(--text-2); }
.form-legal a:hover { color: var(--text); }

/* Select */
select.form-control { padding-left: 0.875rem; }

/* ══════════════════════════════════════════════════════════
   ALERTAS
   ══════════════════════════════════════════════════════════ */
.alert {
  display: flex; align-items: flex-start; gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--r);
  font-size: 0.875rem; line-height: 1.5;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-error   { background: var(--err-bg);  color: var(--err);  border-color: var(--err-border); }
.alert-success { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-border); }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.alert-info    { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-mid); }

/* ══════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xs);
  overflow: hidden;
}
.card-header {
  padding: 1.125rem 1.375rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface);
}
.card-title { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 0.8125rem; color: var(--text-3); margin-top: 0.125rem; }
.card-body { padding: 1.375rem; }
.card-footer {
  padding: 1rem 1.375rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.card + .card { margin-top: 1.25rem; }

/* ══════════════════════════════════════════════════════════
   STATS / MÉTRICAS
   ══════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem 1.375rem;
  box-shadow: var(--sh-xs);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
  opacity: 0.6;
}
.stat-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem;
}
.stat-value { font-size: 1.875rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 0.8rem; color: var(--text-3); margin-top: 0.375rem; }
.stat-icon  {
  position: absolute; right: 1.125rem; top: 1.125rem;
  color: var(--border-2);
}

/* ══════════════════════════════════════════════════════════
   TABLA DE QR
   ══════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.qr-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.875rem;
}
.qr-table thead tr {
  border-bottom: 2px solid var(--border);
}
.qr-table th {
  padding: 0.75rem 1rem; text-align: left;
  font-size: 0.6875rem; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.07em;
  white-space: nowrap; background: var(--surface-2);
}
.qr-table th:first-child { border-radius: var(--r-sm) 0 0 0; }
.qr-table th:last-child  { border-radius: 0 var(--r-sm) 0 0; }
.qr-table td {
  padding: 0.875rem 1rem; vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.qr-table tbody tr:last-child td { border-bottom: none; }
.qr-table tbody tr { transition: background 0.1s; }
.qr-table tbody tr:hover { background: var(--surface-2); }

.qr-thumb {
  width: 44px; height: 44px; border-radius: var(--r);
  background: var(--surface-2); padding: 3px;
  border: 1px solid var(--border);
  object-fit: contain;
}
.qr-name-cell {}
.qr-name { font-weight: 600; color: var(--text); font-size: 0.875rem; }
.qr-dest {
  font-size: 0.75rem; color: var(--text-3);
  max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px;
}
.qr-slug-link {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem; color: var(--accent);
  background: var(--accent-dim);
  padding: 0.2rem 0.5rem; border-radius: var(--r-xs);
  white-space: nowrap;
}
.qr-slug-link:hover { text-decoration: none; background: var(--accent-mid); }
.qr-date { color: var(--text-3); font-size: 0.8125rem; white-space: nowrap; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase;
  white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-active  { background: #dcfce7; color: #15803d; }
.badge-expired { background: #fef9c3; color: #92400e; }
.badge-deleted { background: #fee2e2; color: #b91c1c; }
.badge-admin   { background: var(--accent-dim); color: var(--accent); }

.actions-cell { display: flex; gap: 0.375rem; justify-content: flex-end; align-items: center; }

/* ══════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 3.5rem 1.5rem;
}
.empty-state-icon {
  width: 72px; height: 72px;
  background: var(--surface-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.25rem;
  color: var(--text-4);
}
.empty-state h3 { color: var(--text-2); font-size: 1rem; margin-bottom: 0.5rem; }
.empty-state p  { font-size: 0.875rem; max-width: 320px; margin: 0 auto 1.5rem; }

/* ══════════════════════════════════════════════════════════
   FORMULARIO CREACIÓN QR (layout 2 columnas)
   ══════════════════════════════════════════════════════════ */
.create-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}
.create-form-col { display: flex; flex-direction: column; gap: 1.25rem; }

.qr-preview-panel {
  position: sticky; top: calc(var(--topbar-h) + 1.5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.5rem;
  box-shadow: var(--sh-xs);
  text-align: center;
}
.qr-preview-label {
  font-size: 0.6875rem; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 1rem;
}
.qr-preview-frame {
  width: 200px; height: 200px; margin: 0 auto;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.qr-preview-frame img { width: 100%; height: 100%; object-fit: contain; }
.qr-preview-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  padding: 1rem; color: var(--text-4);
}
.qr-preview-placeholder p { font-size: 0.8rem; color: var(--text-3); }
.qr-preview-spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.qr-preview-note { font-size: 0.75rem; color: var(--text-3); margin-top: 1rem; line-height: 1.5; }

/* Tipo de QR selector */
.qr-type-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.625rem;
}
.qr-type-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 0.875rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  cursor: pointer; transition: all 0.15s;
  font-size: 0.75rem; font-weight: 600; color: var(--text-2);
  text-align: center;
}
.qr-type-btn svg { color: var(--text-3); transition: color 0.15s; }
.qr-type-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.qr-type-btn:hover svg { color: var(--accent); }
.qr-type-btn.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.qr-type-btn.selected svg { color: var(--accent); }

/* ══════════════════════════════════════════════════════════
   AUTENTICACIÓN
   ══════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* Panel izquierdo (branding) */
.auth-brand-panel {
  background: var(--sb-bg);
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem;
  position: relative; overflow: hidden;
}
.auth-brand-panel::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(37,99,235,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.auth-brand-logo {
  display: flex; align-items: center; gap: 0.625rem;
  text-decoration: none; position: relative; z-index: 1;
}
.auth-brand-logo img { width: 32px; height: 32px; border-radius: var(--r-sm); }
.auth-brand-logo span { color: #fff; font-weight: 700; font-size: 1rem; }
.auth-brand-content { position: relative; z-index: 1; }
.auth-brand-content h2 {
  color: #fff; font-size: 1.75rem; font-weight: 800;
  line-height: 1.25; margin-bottom: 1rem;
}
.auth-brand-content p { color: var(--sb-text); font-size: 0.9375rem; line-height: 1.65; }
.auth-brand-features { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.75rem; }
.auth-brand-feature {
  display: flex; align-items: center; gap: 0.625rem;
  color: var(--sb-text); font-size: 0.875rem;
}
.auth-brand-feature svg { color: var(--accent); flex-shrink: 0; }
.auth-brand-footer { color: var(--sb-text); font-size: 0.8rem; position: relative; z-index: 1; margin-top: auto; }

/* Ilustración decorativa QR en el panel de marca */
.auth-brand-illustration {
  position: relative; z-index: 1;
  display: block;
  margin: 1.5rem 0 0;
  width: 100%;
  max-width: 320px;
  height: 320px;
  overflow: hidden;
  border-radius: var(--r-lg);
  flex-shrink: 0;
}
.auth-brand-illustration img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: var(--r-lg);
  opacity: 0.88;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

/* Panel derecho (formulario) */
.auth-form-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem 2rem;
  background: var(--bg);
  overflow-y: auto;
}
.auth-form-inner { width: 100%; max-width: 400px; }
.auth-form-header { margin-bottom: 2rem; }
.auth-form-header h1 { font-size: 1.5rem; margin-bottom: 0.375rem; }
.auth-form-header p  { font-size: 0.9rem; color: var(--text-3); }

.auth-form-footer {
  text-align: center; margin-top: 1.5rem;
  font-size: 0.875rem; color: var(--text-3);
}
.auth-form-footer a { color: var(--accent); font-weight: 600; }

.link-forgot { font-size: 0.8125rem; color: var(--text-3); }
.link-forgot:hover { color: var(--text-2); }

/* Requisitos de contraseña */
.pass-reqs {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.75rem 1rem;
  margin-bottom: 1.125rem;
}
.pass-reqs-title { font-size: 0.75rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.5rem; }
.pass-reqs ul { display: flex; flex-direction: column; gap: 0.3rem; }
.req-item {
  font-size: 0.8rem; color: var(--text-3);
  display: flex; align-items: center; gap: 0.4rem;
}
.req-item::before {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--border-2); flex-shrink: 0;
  transition: all 0.2s;
}
.req-item.valid { color: var(--ok); }
.req-item.valid::before { background: var(--ok); border-color: var(--ok); }
.req-item.invalid { color: var(--err); }
.req-item.invalid::before { background: var(--err); border-color: var(--err); }

/* ══════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--sh-lg);
  width: 100%; max-width: 480px;
  animation: modalIn 0.2s ease;
  overflow: hidden;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-3);
  display: flex; align-items: center; padding: 0.25rem;
  border-radius: var(--r-sm); transition: all 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; gap: 0.75rem; justify-content: flex-end;
  background: var(--surface-2);
}

/* ══════════════════════════════════════════════════════════
   TOASTS
   ══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: 0.625rem;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  background: var(--sb-bg);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  font-size: 0.875rem; color: #fff;
  max-width: 360px; pointer-events: all;
  animation: toastIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
  border-left: 3px solid transparent;
}
.toast-success { border-left-color: #4ade80; }
.toast-error   { border-left-color: #f87171; }
.toast-info    { border-left-color: #60a5fa; }
.toast svg { flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  background: none; border: none; color: rgba(255,255,255,0.5);
  cursor: pointer; padding: 0; display: flex; align-items: center;
  transition: color 0.15s;
}
.toast-close:hover { color: #fff; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ══════════════════════════════════════════════════════════
   PÁGINAS DE ERROR
   ══════════════════════════════════════════════════════════ */
.error-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.error-container { text-align: center; padding: 2rem; max-width: 440px; }
.error-code {
  font-size: 7rem; font-weight: 900; line-height: 1;
  color: var(--border); margin-bottom: 0.5rem;
  letter-spacing: -0.04em;
}
.error-title { font-size: 1.5rem; margin-bottom: 0.75rem; }
.error-message { color: var(--text-3); margin-bottom: 2rem; font-size: 0.9375rem; }
.error-icon-lg {
  color: var(--text-4); margin-bottom: 1.5rem;
  display: flex; justify-content: center;
}

/* ══════════════════════════════════════════════════════════
   PERFIL
   ══════════════════════════════════════════════════════════ */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.plan-detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.plan-detail-row:last-child { border-bottom: none; }
.plan-detail-label { color: var(--text-3); }
.plan-detail-value { font-weight: 600; color: var(--text); }

/* ══════════════════════════════════════════════════════════
   LANDING PÚBLICA
   ══════════════════════════════════════════════════════════ */
.hero {
  padding: 5rem 0 4rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.hero-inner { max-width: 680px; margin: 0 auto; text-align: center; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--accent-dim); color: var(--accent);
  font-size: 0.8125rem; font-weight: 600; padding: 0.3rem 0.75rem;
  border-radius: 999px; margin-bottom: 1.25rem;
  border: 1px solid var(--accent-mid);
}
.hero h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 900; line-height: 1.15;
  margin-bottom: 1.125rem;
  letter-spacing: -0.02em;
}
.hero h1 span { color: var(--accent); }
.hero p { font-size: 1.0625rem; color: var(--text-2); max-width: 520px; margin: 0 auto 2.5rem; line-height: 1.7; }
.hero-cta { display: flex; gap: 0.875rem; justify-content: center; flex-wrap: wrap; }

.features-section { padding: 4rem 0; }
.section-header { text-align: center; max-width: 560px; margin: 0 auto 3rem; }
.section-label {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.75rem;
}
.section-header h2 { font-size: 1.875rem; margin-bottom: 0.75rem; }

.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.75rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.feature-card:hover { box-shadow: var(--sh-md); border-color: var(--border-2); }
.feature-icon {
  width: 44px; height: 44px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
}
.feature-card h3 { margin-bottom: 0.5rem; font-size: 1rem; }
.feature-card p  { font-size: 0.875rem; }

.cta-section {
  padding: 4rem 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}
.cta-section h2 { font-size: 1.75rem; margin-bottom: 0.75rem; }
.cta-section p  { color: var(--text-2); margin-bottom: 2rem; }

/* Pricing */
.pricing-section { padding: 4rem 0; }
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem; max-width: 900px; margin: 0 auto;
}
.pricing-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-2xl);
  padding: 2rem;
  position: relative;
  transition: box-shadow 0.2s;
}
.pricing-card:hover { box-shadow: var(--sh-md); }
.pricing-card.featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.08), var(--sh-md);
}
.pricing-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  font-size: 0.6875rem; font-weight: 700; padding: 0.25rem 0.75rem;
  border-radius: 999px; white-space: nowrap;
}
.pricing-name { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.25rem; }
.pricing-desc { font-size: 0.8125rem; color: var(--text-3); margin-bottom: 1.25rem; }
.pricing-price {
  font-size: 2.5rem; font-weight: 900; color: var(--text);
  line-height: 1; margin-bottom: 1.5rem; letter-spacing: -0.03em;
}
.pricing-price sup { font-size: 1.25rem; vertical-align: top; margin-top: 0.5rem; font-weight: 600; }
.pricing-price span { font-size: 0.9rem; font-weight: 400; color: var(--text-3); }
.pricing-features { display: flex; flex-direction: column; gap: 0.625rem; margin-bottom: 1.75rem; }
.pricing-feature {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem; color: var(--text-2);
}
.pricing-feature svg { color: var(--ok); flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════
   UTILIDADES
   ══════════════════════════════════════════════════════════ */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-3) !important; }
.text-sm  { font-size: 0.875rem; }
.text-xs  { font-size: 0.75rem; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Separador */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: 2rem 1.5rem; }
  .auth-form-inner { max-width: 100%; }
}

@media (max-width: 768px) {
  /* Sidebar */
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay.visible { display: block; }
  .topbar-menu-btn { display: flex; }
  .app-main { margin-left: 0; }

  /* Layouts */
  .create-layout { grid-template-columns: 1fr; }
  .qr-preview-panel { position: static; }
  .profile-grid { grid-template-columns: 1fr; }

  /* Nav pública */
  .nav-links { display: none; }
  .mobile-menu-btn { display: flex; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Tabla */
  .qr-table th:nth-child(5),
  .qr-table td:nth-child(5) { display: none; }

  /* App content */
  .app-content { padding: 1.25rem 1rem; }
  .app-topbar { padding: 0 1rem; }
}

@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 1.75rem; }
  .hero-cta { flex-direction: column; align-items: center; }
  .qr-type-grid { grid-template-columns: repeat(2, 1fr); }
  .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { max-width: 100%; }
}

/* ═══════════════════════════════════════════════════════
   FASE FINAL — Componentes: Admin, Stats, Gráficos
   ═══════════════════════════════════════════════════════ */

/* ── Gráficos ─────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
}
.chart-wrap-sm {
  max-width: 220px;
  margin: 0 auto 1rem;
}

/* ── Leyenda de gráficos de dona ─────────────────────── */
.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-label {
  flex: 1;
  color: var(--text-2);
  text-transform: capitalize;
}
.legend-value {
  font-weight: 600;
  color: var(--text);
  font-size: 0.8rem;
}

/* ── Layout de dos columnas para gráficos de stats ────── */
.stats-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ── Paginación ───────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
.pagination-info {
  font-size: 0.875rem;
  color: var(--text-3);
}

/* ── Acciones en tabla ────────────────────────────────── */
.actions-cell {
  display: flex;
  gap: 0.375rem;
  justify-content: flex-end;
  align-items: center;
}
.btn-icon {
  padding: 0.375rem;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fecaca;
  border-color: #f87171;
  color: #b91c1c;
}

/* ── Badges adicionales ───────────────────────────────── */
.badge-neutral  { background: var(--surface-2); color: var(--text-2); }
.badge-info     { background: #dbeafe; color: #1d4ed8; }
.badge-deleted  { background: #f3f4f6; color: #9ca3af; }

/* ── Sidebar: sección admin ───────────────────────────── */
.sidebar-nav-admin .sidebar-nav-item {
  border-left: 2px solid transparent;
}
.sidebar-nav-admin .sidebar-nav-item.active,
.sidebar-nav-admin .sidebar-nav-item:hover {
  border-left-color: var(--accent);
}

/* ── Topbar: badge de rol admin ───────────────────────── */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Destino del QR en tabla ──────────────────────────── */
.qr-dest {
  font-size: 0.75rem;
  color: var(--text-3);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

/* ── Helpers de texto ─────────────────────────────────── */
.text-xs   { font-size: 0.75rem; }
.text-sm   { font-size: 0.8125rem; }
.text-muted { color: var(--text-3); }
.mb-3 { margin-bottom: 1.25rem; }

/* ── Responsive: stats y admin ────────────────────────── */
@media (max-width: 900px) {
  .stats-charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .actions-cell { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr; }
  .pagination { flex-direction: column; gap: 0.5rem; }
}
