/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #14151a;
  --muted: #666b78;
  --border: #e6e7eb;
  --accent: #14532d;
  --accent-ink: #ffffff;
  --accent-soft: #dcfce7;
  --ok: #1f9d55;
  --warn: #b5790a;
  --danger: #d33a3a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(20, 21, 26, 0.06);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Manrope", var(--sans);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1013;
    --surface: #17181d;
    --ink: #eef0f5;
    --muted: #9aa0ae;
    --border: #262832;
    --accent: #4ade80;
    --accent-ink: #0f1013;
    --accent-soft: #132a1c;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1013; --surface: #17181d; --ink: #eef0f5; --muted: #9aa0ae;
  --border: #262832; --accent: #4ade80; --accent-ink: #0f1013;
  --accent-soft: #132a1c; --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font-size: 1rem; cursor: pointer; line-height: 1;
}
.theme-toggle:hover { border-color: var(--accent); }

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { font-family: var(--display); text-wrap: balance; line-height: 1.12; letter-spacing: -0.02em; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--ink);
  color: var(--bg); z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-s { gap: .5rem; } .gap-m { gap: 1rem; } .gap-l { gap: 2rem; }

/* =============================================================
   4. Typography
   ============================================================= */
.eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 60ch; }
.muted { color: var(--muted); }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.5rem; border-radius: 999px; font-weight: 700; font-size: .95rem;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), opacity .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgba(20,83,45,.3); }
.btn-primary:hover { box-shadow: 0 10px 26px rgba(20,83,45,.4); }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-sm { padding: .5rem .95rem; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-block { width: 100%; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.75rem; box-shadow: var(--shadow);
}

.badge {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 700;
  padding: .3rem .7rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.badge-demo { background: #fff3d6; color: #8a5a00; border: 1px solid #f0d28f; }
@media (prefers-color-scheme: dark) { .badge-demo { background: #3a2c05; color: #f0c65f; border-color: #55420c; } }
.badge-activo { background: var(--accent-soft); color: var(--accent); }
.badge-pausado { background: #fff3d6; color: #8a5a00; }
@media (prefers-color-scheme: dark) { .badge-pausado { background: #3a2c05; color: #f0c65f; } }

.input, .textarea, select.input {
  width: 100%; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg); color: var(--ink); font: inherit;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field .hint { font-size: .78rem; color: var(--muted); }

.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: .8rem 1.2rem; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow); animation: toast-in .25s var(--ease-out); }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10,10,14,.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 1000; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); max-width: 460px; width: 100%; padding: 1.75rem; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; position: relative; }
.modal-wide { max-width: 640px; }
.modal-close { position: absolute; top: 1rem; right: 1rem; }

/* =============================================================
   6. Sections — shared shell
   ============================================================= */
.topbar { position: sticky; top: 0; z-index: 100; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .container { display: flex; align-items: center; justify-content: space-between; padding-block: .9rem; }
.logo { font-family: var(--display); font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; gap: .5rem; }
.logo-mark { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: .8rem; }
.nav-links { display: flex; align-items: center; gap: 1.2rem; }
.nav-links a { font-weight: 600; font-size: .92rem; color: var(--muted); }
.nav-links a:hover { color: var(--ink); }

.scans-pill { display: inline-flex; align-items: center; gap: .4rem; background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: .5rem 1rem; border-radius: 999px; font-size: .85rem; }

.footer { border-top: 1px solid var(--border); padding-block: 2.5rem; margin-top: 4rem; color: var(--muted); font-size: .9rem; }
.footer .container { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--ink); }

/* Landing hero */
.hero { padding-block: 3rem 2rem; }
.hero-grid { display: grid; gap: 2.5rem; align-items: start; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); margin-block: .8rem 1rem; }
.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.2rem; }
.trust-row { display: flex; flex-wrap: wrap; gap: .6rem 1.6rem; margin-top: 1.6rem; color: var(--muted); font-size: .85rem; }

.section { padding-block: 3.5rem; }
.section-head { max-width: 640px; margin-bottom: 2.2rem; }

/* How it works */
.steps-grid { display: grid; gap: 1rem; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; background: var(--surface); }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; margin-bottom: .8rem; }

/* Pricing */
.pricing-grid { display: grid; gap: 1.2rem; }
@media (min-width: 860px) { .pricing-grid { grid-template-columns: repeat(3, 1fr); } }
.plan-card { display: flex; flex-direction: column; gap: 1rem; position: relative; }
.plan-card.featured { border-color: var(--accent); box-shadow: 0 10px 34px rgba(20,83,45,.18); }
.plan-tag { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 800; padding: .3rem .8rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.plan-price { font-family: var(--display); font-size: 2.2rem; font-weight: 800; }
.plan-price span { font-size: 1rem; font-weight: 600; color: var(--muted); }
.plan-annual { font-size: .8rem; color: var(--muted); }
.plan-features { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .55rem; font-size: .9rem; color: var(--muted); }
.plan-features li::before { content: "✓ "; color: var(--ok); font-weight: 800; }
.demo-banner { display: flex; align-items: center; justify-content: center; gap: .5rem; text-align: center; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); padding: .7rem 1rem; font-size: .85rem; font-weight: 600; margin-bottom: 1.5rem; }

/* FAQ */
.faq { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .7rem; overflow: hidden; background: var(--surface); }
.faq summary { padding: 1rem 1.2rem; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; color: var(--muted); }
.faq[open] summary::after { content: "–"; }
.faq p { padding: 0 1.2rem 1.1rem; color: var(--muted); }

/* =============================================================
   7. App shell
   ============================================================= */
.app-body { min-height: 100vh; display: flex; flex-direction: column; }
.app-main { flex: 1; padding-block: 2rem 3rem; }

.state-idle, .state-working, .state-error { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.history-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.history-table th, .history-table td { text-align: left; padding: .6rem .4rem; border-bottom: 1px solid var(--border); }
.history-table th { color: var(--muted); font-weight: 600; }

/* -------- Free static QR generator (landing) -------- */
.gen-grid { display: grid; gap: 1.5rem; }
@media (min-width: 900px) { .gen-grid { grid-template-columns: 1fr 340px; align-items: start; } }
.type-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.2rem; }
.type-tab { border: 1.5px solid var(--border); border-radius: 999px; padding: .55rem 1rem; font-size: .85rem; font-weight: 700; background: var(--surface); }
.type-tab.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.type-fields { display: none; }
.type-fields.active { display: block; }

.design-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.swatch-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.swatch-btn { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--border); position: relative; }
.swatch-btn.selected::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--accent); }
.shape-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.shape-opt { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .4rem; text-align: center; font-size: .72rem; font-weight: 600; }
.shape-opt.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.color-input-row { display: flex; align-items: center; gap: .6rem; }
.color-input-row input[type=color] { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); padding: 0; background: none; }

.qr-preview-wrap { position: sticky; top: 90px; text-align: center; }
.qr-preview-box { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1.5rem; display: grid; place-items: center; min-height: 280px; }
.qr-preview-box canvas, .qr-preview-box svg { max-width: 100%; }
.qr-download-row { display: flex; gap: .6rem; margin-top: 1rem; }

/* -------- Dashboard "Mis QR" -------- */
.dash-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.6rem; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.1rem; }
.qr-card { display: flex; flex-direction: column; gap: .6rem; }
.qr-card-top { display: flex; gap: 1rem; align-items: center; }
.qr-card-thumb { width: 64px; height: 64px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.qr-card-thumb canvas { width: 100%; height: 100%; }
.qr-card-name { font-weight: 700; }
.qr-card-meta { font-size: .8rem; color: var(--muted); }
.qr-card-stats { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); }
.qr-card-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: auto; }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state p:first-child { font-size: 2.4rem; }

/* -------- Editor -------- */
.editor-grid { display: grid; gap: 1.5rem; }
@media (min-width: 960px) { .editor-grid { grid-template-columns: 1fr 340px; align-items: start; } }
.logo-upload { border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 1rem; text-align: center; cursor: pointer; }
.logo-upload:hover { border-color: var(--accent); background: var(--accent-soft); }
.logo-upload img { max-height: 60px; margin-inline: auto; }

/* -------- Analytics -------- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; background: var(--surface); }
.stat-tile .n { font-family: var(--display); font-size: 1.7rem; font-weight: 800; }
.stat-tile .l { font-size: .78rem; color: var(--muted); }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 1rem; }
.bar-chart .bar { flex: 1; background: var(--accent-soft); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bar-chart .bar.hoy { background: var(--accent); }
.bar-labels { display: flex; gap: 4px; font-size: .65rem; color: var(--muted); margin-top: .4rem; }
.bar-labels span { flex: 1; text-align: center; }
.breakdown-list { display: flex; flex-direction: column; gap: .5rem; }
.breakdown-row { display: flex; justify-content: space-between; align-items: center; font-size: .88rem; }
.breakdown-bar-bg { flex: 1; height: 6px; background: var(--border); border-radius: 999px; margin: 0 .7rem; overflow: hidden; }
.breakdown-bar-fill { height: 100%; background: var(--accent); }
.locked-panel { text-align: center; padding: 2rem 1rem; color: var(--muted); }

/* -------- Team -------- */
.team-row { display: flex; justify-content: space-between; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.team-row:last-child { border-bottom: none; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 720px) { .hero-grid { grid-template-columns: 1.05fr 1fr; } }

/* =============================================================
   9. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
