:root {
  color-scheme: light; /* el sitio público solo tiene modo claro */
  /* Los mismos colores que la portada (landing.css): tinta, verde y amarillo de la marca. */
  --bg: #f6f7f6;
  --surface: #ffffff;
  --text: #0b0f0d;
  --muted: #59615d;
  --border: #e6e8e7;
  --accent: #0b0f0d;
  --accent-hover: #1f2a25;
  --accent-soft: #f1f3f2;
  --link: #0b7a62;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* .btn y otras clases con display no deben mostrar elementos ocultos */
html, body { margin: 0; }
body {
  font-family: "Geist", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #ffffff; /* blanco, como la portada; las líneas del fondo las pone grid-pulse.js */
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.02em; }

/* ---------- Layout ---------- */
/* Encabezado igual al de la portada: mismo alto, logo y ancho máximo (1200 px con 32 px a los lados). */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 72px;
  padding: 0 max(clamp(16px, 3vw, 32px), calc((100% - 1136px) / 2));
  background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 26px; height: 26px; flex: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center; color: #fff; font-size: .8rem; font-weight: 800;
}
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.user-name { color: var(--muted); font-size: .9rem; }
.container { max-width: 1200px; margin: 0 auto; padding: 2rem clamp(16px, 3vw, 32px) 4rem; }

/* ---------- Controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=url], select {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: .95rem; background: var(--surface); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=color] {
  width: 100%; height: 42px; padding: 3px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer;
}
input[type=range] { width: 100%; accent-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .9rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.alert { padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1rem; display: none; }
.alert.show { display: block; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ---------- Landing / auth ---------- */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 3rem; align-items: center;
  max-width: 1120px; margin: 0 auto; padding: 4rem clamp(16px, 4vw, 40px);
}
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); }
.hero p.lead { font-size: 1.1rem; color: var(--muted); max-width: 34rem; }
.features { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .7rem; }
.features li { display: flex; gap: .6rem; align-items: flex-start; }
.features li::before {
  content: "✓"; flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: .75rem; font-weight: 800;
}
.auth-card { padding: 1.75rem; }
.tabs { display: flex; background: #f1f5f9; border-radius: 10px; padding: 4px; margin-bottom: 1.25rem; }
.tab {
  flex: 1; padding: .55rem; border: 0; background: transparent; border-radius: 8px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.auth-card form .btn { width: 100%; padding: .75rem; }

/* ---------- Dashboard ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.1rem; }
.qr-card { padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.qr-thumb {
  background: #f8fafc; border-radius: 10px; display: grid; place-items: center; aspect-ratio: 1;
  overflow: hidden; padding: .75rem;
}
.qr-thumb canvas, .qr-thumb svg, .qr-thumb img { width: 100%; height: auto; max-width: 200px; }
.qr-card h3 { font-size: 1rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-meta { font-size: .8rem; color: var(--muted); display: grid; gap: .15rem; }
.qr-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: .1rem .55rem; font-size: .75rem; font-weight: 700;
}
.qr-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; }
.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty h2 { color: var(--text); }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: 1fr 380px; gap: 1.5rem; align-items: start; }
.panel { padding: 1.5rem; }
.panel h2 { font-size: 1.05rem; margin-bottom: 1rem; }
.panel + .panel { margin-top: 1.25rem; }
.preview { position: sticky; top: 84px; padding: 1.5rem; text-align: center; }
.preview-box {
  background: #f8fafc; border-radius: 12px; padding: 1rem; display: grid; place-items: center; margin-bottom: 1rem;
}
.preview-box canvas, .preview-box svg { width: 100%; height: auto; max-width: 300px; }
.short-link {
  display: flex; gap: .4rem; align-items: center; background: #f1f5f9; border-radius: 10px;
  padding: .5rem .6rem; font-size: .82rem; margin-bottom: 1rem; text-align: left;
}
.short-link code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview .actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.preview .actions .btn-primary { grid-column: 1 / -1; }
.logo-row { display: flex; gap: .75rem; align-items: center; }
.logo-preview {
  width: 56px; height: 56px; border-radius: 10px; border: 1px dashed var(--border);
  display: grid; place-items: center; background: #f8fafc; overflow: hidden; flex: none; color: var(--muted); font-size: .7rem;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.swatches { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 2rem; gap: 2rem; }
  .editor { grid-template-columns: 1fr; }
  .preview { position: static; }
}

/* ---------- v2: formularios, panel con carpetas, editor ampliado ---------- */
input[type=tel], input[type=search], textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: .95rem; background: var(--surface); color: var(--text);
}
textarea { resize: vertical; }
textarea:focus, input[type=search]:focus, input[type=tel]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
select:disabled, input:disabled { opacity: .5; cursor: not-allowed; }
.muted { color: var(--muted); font-size: .9rem; }
.block { width: 100%; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 500; font-size: .88rem; margin: .25rem 0 1rem; cursor: pointer; }
.check input { margin-top: .2rem; accent-color: var(--accent); }
.self-end { align-self: end; margin-bottom: 1.4rem; }
.form-foot { text-align: center; font-size: .85rem; margin: 1rem 0 0; color: var(--muted); }
.captcha { margin-bottom: 1rem; min-height: 0; }
.code-input { font-size: 1.6rem !important; letter-spacing: .5em; text-align: center; font-weight: 700; }
.auth-card h2 { font-size: 1.2rem; }
.narrow { max-width: 460px; }
.alert-info { background: #e6f4ee; color: #0a5a48; border: 1px solid #b5e2cf; }
.badge-muted { background: #f1f5f9; color: var(--muted); }
.badge-off { background: #fef2f2; color: #991b1b; }
.footer { text-align: center; padding: 2rem 16px 2.5rem; font-size: .85rem; color: var(--muted); }
.footer a { color: var(--muted); }

.dash { display: grid; grid-template-columns: 220px 1fr; gap: 1.75rem; align-items: start; }
.sidebar { position: sticky; top: 84px; display: grid; gap: .75rem; }
.folder-nav { display: grid; gap: 2px; }
.folder-link {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem; width: 100%;
  padding: .5rem .7rem; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: .9rem;
  color: var(--text); cursor: pointer; text-align: left;
}
.folder-link span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-link:hover { background: #eef0f6; }
.folder-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder-link.trash { margin-top: .5rem; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.folder-link .count { font-size: .75rem; color: var(--muted); }
.head-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.head-actions input[type=search] { width: 260px; max-width: 100%; }
.qr-card .move { padding: .4rem .6rem; font-size: .82rem; }
.qr-card.in-trash .qr-thumb { opacity: .45; filter: grayscale(1); }
.span-all { grid-column: 1 / -1; }

/* En el celular cada QR es una fila: la miniatura a la izquierda y los datos a la derecha. */
@media (max-width: 640px) {
  .grid:has(.qr-card) { grid-template-columns: 1fr; gap: .75rem; }
  .qr-card {
    display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: .85rem; row-gap: .45rem;
    align-items: start; padding: .8rem;
  }
  .qr-card .qr-thumb { grid-row: 1 / span 3; padding: .4rem; border-radius: 8px; }
  .qr-card h3, .qr-card .qr-meta, .qr-card .move { grid-column: 2; }
  .qr-card .move { width: 100%; }
  .qr-card .qr-actions { grid-column: 1 / -1; gap: .35rem; }
  .qr-card .qr-actions .btn { flex: 1 1 calc(50% - .35rem); min-width: 0; padding: .4rem .5rem; font-size: .8rem; justify-content: center; text-align: center; }
}

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .6rem; }
.preset {
  display: grid; justify-items: center; gap: .35rem; padding: .6rem .3rem; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); font: inherit; font-size: .75rem; font-weight: 600; cursor: pointer;
}
.preset:hover { border-color: var(--accent); }
.preset-swatch { width: 34px; height: 34px; border-radius: 9px; }
.preview-box.checker {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e2e8f0 25%, transparent 25%), linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%), linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.downloads { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); text-align: left; }
.downloads h3 { font-size: .95rem; }
.row.tight { grid-template-columns: 1fr auto; gap: .75rem; }
.dl-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }

/* Textos legales */
.legal { max-width: 780px; }
.legal .card { padding: clamp(1.25rem, 4vw, 2.5rem); }
.legal h1 { font-size: 1.8rem; }
.legal h2 { font-size: 1.1rem; margin-top: 1.75rem; }
.legal p, .legal li { color: #334155; font-size: .95rem; }
.legal .updated { color: var(--muted); font-size: .85rem; }

@media (max-width: 860px) {
  .dash { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .folder-nav { display: flex; overflow-x: auto; gap: .35rem; padding-bottom: .25rem; }
  .folder-link { width: auto; flex: none; background: #eef0f6; }
  .folder-link.trash { margin-top: 0; border-top: 0; border-radius: 8px; }
  .head-actions input[type=search] { width: 100%; }
}

/* Selectores visuales del editor (puntos y esquinas) */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .5rem; }
.picker-opt {
  display: grid; justify-items: center; gap: .35rem; padding: .6rem .3rem; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); font: inherit; font-size: .74rem; font-weight: 600;
  color: var(--muted); cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.picker-opt:hover { border-color: #a5b4fc; }
.picker-opt.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--accent); }
.picker-opt svg {
  width: 44px; height: 44px; padding: 3px; border-radius: 8px;
  background: var(--qr-bg, #fff); box-shadow: 0 0 0 1px var(--border);
}
label .ico { display: inline-flex; vertical-align: -5px; margin-right: .4rem; }
label .ico svg { width: 20px; height: 20px; padding: 1px; border-radius: 5px; background: var(--qr-bg, #fff); box-shadow: 0 0 0 1px var(--border); }

/* Agregar QRs existentes a una carpeta */
.add-dialog { border: 1px solid var(--border); border-radius: 16px; padding: 1.2rem; width: min(440px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.add-dialog::backdrop { background: rgba(15, 23, 42, .35); }
.add-dialog h2 { margin: 0 0 .8rem; font-size: 1.15rem; }
.add-dialog input[type=search] { width: 100%; box-sizing: border-box; }
.add-list { display: grid; gap: .35rem; max-height: 50vh; overflow-y: auto; margin: .7rem 0; }
.add-item { display: flex; gap: .65rem; align-items: center; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.add-item:hover { border-color: var(--accent); }
.add-item span { display: grid; min-width: 0; }
.add-item small { color: var(--muted, #64748b); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-empty { color: var(--muted, #64748b); text-align: center; padding: 1rem 0; }
.add-row { display: flex; justify-content: flex-end; gap: .5rem; }

/* Pie de página siempre hasta abajo, aunque la página tenga poco contenido */
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; width: 100%; }
body > .footer { flex-shrink: 0; }

/* Descargar desde «Mis QRs» */
.dl-choices { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 11px; background: #f1f5f9; margin: .35rem 0 .9rem; }
.dl-choices button { min-height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; }
.dl-choices button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.dl-label { font-size: .82rem; font-weight: 600; }
.dl-hint { font-size: .82rem; color: var(--muted); margin: 0 0 .9rem; }

/* Editar enlace */
.link-fields { display: grid; gap: .35rem; margin-bottom: .9rem; }
.link-fields input, .link-fields textarea { width: 100%; }
#link-alert { margin-bottom: .8rem; }

/* Saldo de tokens en el encabezado */
.tokens-link b { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .user-name { display: none; } }

/* Soporte */
.support .muted { margin-bottom: 1.25rem; }
.support-grid { display: grid; gap: 0 1rem; }
@media (min-width: 640px) { .support-grid { grid-template-columns: 1fr 1fr; } }
.support textarea { min-height: 140px; }
.support .optional { font-weight: 400; color: var(--muted); }
.support .captcha { display: flex; justify-content: center; margin-bottom: 1rem; }
.support .captcha:empty { margin: 0; }
.support .btn-primary { width: 100%; padding: .75rem; }
.support-sent { text-align: center; padding: 1rem 0 .5rem; }
.support-sent h2 { margin-top: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Aviso del plan en «Mis QRs» */
.plan-note { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
  padding: .8rem 1rem; margin-bottom: 1rem; border-radius: 14px; background: #fff6d6; border: 1px solid #f3dc85; color: #4a3b00; font-size: .9rem; }
.plan-note.warn { background: #fdecea; border-color: #f5c2bc; color: #8f1d14; }
.plan-note[hidden] { display: none; }

/* Encabezado en celular: con el selector de moneda no cabe todo */
@media (max-width: 640px) {
  .topbar { gap: .5rem; }
  .topbar-right { gap: .4rem; }
}
@media (max-width: 440px) {
  .topbar .brand { font-size: 0; gap: 0; }
  .tokens-link .tk-word { display: none; }
}
