:root {
  --bg: #F6F6F4;
  --surface: #FFFFFF;
  --ink: #17181C;
  --ink-soft: #6B6D76;
  --accent: #5850EC;
  --accent-soft: #EEECFE;
  --border: #E4E4E0;
  --success: #0E9F6E;
  --success-soft: #E8F9F1;
  --danger: #E02424;
  --danger-soft: #FDE8E8;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select {
  font-family: inherit;
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.only-mobile { display: none; }

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand { padding: 0 8px 20px; }
.brand-title { font-size: 19px; font-weight: 800; }
.badge-pro {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 700;
}
.nav-item:hover { background: var(--bg); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); }
.nav-item--external {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  color: var(--accent);
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 16px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; flex-shrink: 0;
}
.account-name { font-size: 13px; font-weight: 700; }
.account-plan { font-size: 11.5px; color: var(--ink-soft); }

.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 20;
}

/* Main */

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 32px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}

.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  max-width: 420px;
  color: var(--ink-soft);
}
.search-field input {
  border: none;
  padding: 10px 0;
  background: transparent;
}
.search-field input:focus { box-shadow: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn--block { width: 100%; justify-content: center; margin-top: 6px; }

.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.view-header h1 { font-size: 22px; font-weight: 800; margin: 0; }
.view-subtitle { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }

.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 700;
}
.chip.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

.content-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.history-table { width: 100%; border-collapse: collapse; }
.history-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.history-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.history-table tr:last-child td { border-bottom: none; }

.cell-content { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cell-text { min-width: 0; }
.cell-label {
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 320px;
}
.cell-raw { font-size: 11.5px; color: var(--ink-soft); }

.origin-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg);
  color: var(--ink-soft);
}

.row-delete {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.row-delete:hover { background: var(--danger-soft); color: var(--danger); }

.empty-state { padding: 48px 24px; text-align: center; }
.empty-state p { margin: 0 0 6px; }
.muted { color: var(--ink-soft); font-size: 12.5px; }

.side-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.side-card-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.side-card-inner h2 { font-size: 13.5px; font-weight: 800; margin: 0 0 12px; }
.side-card-inner label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 10px 0 6px;
}
.side-card-inner label:first-of-type { margin-top: 0; }

.reader-link {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  color: var(--accent);
}
.reader-link span { font-size: 12px; font-weight: 600; line-height: 1.5; }

.sync-card p { margin: 0 0 4px; }

.placeholder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  color: var(--ink-soft);
  font-size: 13.5px;
}
.placeholder-card strong { color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
  z-index: 15;
}

/* ---------- Responsive: mobile ---------- */

@media (max-width: 860px) {
  .only-mobile { display: flex; }

  .sidebar {
    position: fixed;
    z-index: 30;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 transparent;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,0.12); }
  .scrim.is-open { display: block; }

  .main { padding: 16px 16px 96px; }

  .content-grid { grid-template-columns: 1fr; }

  .bottom-nav {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 0;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    font-size: 10.5px;
    font-weight: 700;
  }
  .bottom-nav-item.is-active { color: var(--accent); }

  .history-table thead { display: none; }
  .history-table, .history-table tbody, .history-table tr, .history-table td {
    display: block;
    width: 100%;
  }
  .history-table tr {
    padding: 4px 0;
  }
  .history-table td { border-bottom: none; padding: 6px 16px; }
  .history-table td:first-child { padding-top: 12px; }
  .history-table td:last-child { padding-bottom: 12px; }
  .row-actions-cell { display: flex; justify-content: flex-end; }
}

/* ======================================================================
   Crear QR (index.html) — the free, no-login page
   ====================================================================== */

.creator-shell { min-height: 100vh; display: flex; flex-direction: column; }

.creator-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.creator-brand { display: flex; align-items: center; gap: 12px; }
.creator-brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.creator-brand-title { font-size: 15px; font-weight: 800; }
.creator-brand-subtitle { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }

.login-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.login-pill:hover { background: var(--bg); }

.creator-main { flex: 1; padding: 32px; max-width: 1040px; width: 100%; margin: 0 auto; }

.creator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.creator-form-card, .creator-preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
}

.creator-heading { font-size: 20px; font-weight: 800; margin: 0 0 6px; }
.creator-subheading { font-size: 13px; color: var(--ink-soft); margin: 0 0 18px; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

#creator-fields label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 12px 0 6px;
}
#creator-fields label:first-child { margin-top: 0; }
#creator-fields textarea {
  font-family: inherit;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  resize: vertical;
}
#creator-fields textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.qr-preview-box {
  aspect-ratio: 1;
  border: 1px dashed var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.qr-preview-box svg { width: 100%; height: 100%; }

.creator-preview-actions { display: flex; gap: 10px; margin-top: 16px; }
.creator-preview-actions .btn { flex: 1; justify-content: center; }

.creator-footnote {
  text-align: center;
  color: var(--ink-soft);
  font-size: 12px;
  margin: 24px 0 0;
}

@media (max-width: 860px) {
  .creator-topbar { padding: 16px 16px; }
  .creator-main { padding: 16px; }
  .creator-grid { grid-template-columns: 1fr; }
  .qr-preview-box { max-width: 280px; margin: 0 auto; }
}

/* ======================================================================
   Login gate (pro/index.html, shown until "Simular inicio de sesión")
   ====================================================================== */

.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-gate-card {
  max-width: 360px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
}

.login-gate-mark {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

.login-gate-card h1 { font-size: 18px; font-weight: 800; margin: 0 0 8px; }
.login-gate-card .muted { margin: 0 0 20px; }

.login-gate-note {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin: 12px 0 0;
}

.login-gate-back {
  display: inline-block;
  margin-top: 18px;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
}

.brand-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 15px;
  flex-shrink: 0;
  margin-right: 2px;
}
.brand-back:hover { background: var(--bg); }
.sidebar-brand { display: flex; align-items: flex-start; gap: 4px; }
