/* =============================================================
   Tachón — hoja de estilos única
   1. Tokens   2. Reset   3. Utilidades   4. Tipografía
   5. Componentes   6. Secciones (landing)   7. App   8. Responsive
   ============================================================= */

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg:        #f5f6f8;
  --superficie:#ffffff;
  --superficie-2:#eef0f4;
  --borde:     #dfe3ea;
  --borde-2:   #cbd2de;
  --tinta:     #14213d;
  --tinta-2:   #46506a;
  --tinta-3:   #6b7488;
  --acento:    #1f52e0;
  --acento-tinta:#173fb0;
  --acento-suave:#e7edfd;
  --ok:        #1a7f4b;
  --ok-suave:  #e2f3ea;
  --aviso:     #a15c00;
  --aviso-suave:#fbefdb;
  --error:     #b3261e;
  --error-suave:#fbe9e8;
  --negro-censura:#0a0a0a;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radio: 12px;
  --radio-s: 8px;
  --sombra: 0 1px 2px rgba(20,33,61,.06), 0 8px 24px rgba(20,33,61,.06);
  --sombra-fuerte: 0 12px 40px rgba(20,33,61,.16);
  --ancho: 1120px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0e131c;
    --superficie:#161d29;
    --superficie-2:#1e2735;
    --borde:     #2a3446;
    --borde-2:   #384356;
    --tinta:     #eef1f6;
    --tinta-2:   #b3bccc;
    --tinta-3:   #8c96a8;
    --acento:    #6c93ff;
    --acento-tinta:#8aa9ff;
    --acento-suave:#1a2540;
    --ok:        #4cc98a;
    --ok-suave:  #12291f;
    --aviso:     #e6ad57;
    --aviso-suave:#2c2412;
    --error:     #ef6f68;
    --error-suave:#2c1614;
    --sombra: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
    --sombra-fuerte: 0 12px 40px rgba(0,0,0,.45);
  }
}

/* =============================================================
   2. Reset
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--tinta);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.02em; color: var(--tinta); }
::selection { background: var(--acento); color: #fff; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 3px; border-radius: 4px; }

/* =============================================================
   3. Utilidades
   ============================================================= */
.contenedor { width: min(100% - 2.4rem, var(--ancho)); margin-inline: auto; }
.estrecho { width: min(100% - 2.4rem, 560px); margin-inline: auto; }
.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: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--tinta); color: var(--bg);
  border-radius: var(--radio-s); font-weight: 600;
}
.skip-link:focus { top: 1rem; }
.oculto { display: none !important; }

/* Revelado al hacer scroll (solo mejora, el contenido ya está en el HTML) */
.rev { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.rev.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .rev { opacity: 1; transform: none; transition: none; } }

/* =============================================================
   4. Tipografía
   ============================================================= */
h1 { font-size: clamp(2rem, 5vw, 3.1rem); }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); }
h3 { font-size: 1.15rem; }
.plomo { color: var(--tinta-2); font-size: clamp(1rem, 1.6vw, 1.18rem); }
.etiqueta {
  display: inline-block; font-size: .8rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--acento);
}

/* =============================================================
   5. Componentes
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .72rem 1.3rem; border-radius: var(--radio-s); font-weight: 600;
  background: var(--acento); color: #fff; transition: background .2s var(--ease), transform .2s var(--ease);
  text-align: center; line-height: 1.2;
}
.btn:hover { background: var(--acento-tinta); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.grande { padding: .9rem 1.7rem; font-size: 1.05rem; }
.btn.fantasma { background: transparent; color: var(--tinta); border: 1px solid var(--borde-2); }
.btn.fantasma:hover { background: var(--superficie-2); }
.btn.bloque { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.tarjeta {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra);
}

.campo { margin-bottom: 1rem; }
.campo label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .35rem; }
.campo input, .campo textarea {
  width: 100%; padding: .7rem .85rem; border-radius: var(--radio-s);
  border: 1px solid var(--borde-2); background: var(--superficie); color: var(--tinta);
}
.campo input:focus, .campo textarea:focus { outline: 2px solid var(--acento); outline-offset: 0; border-color: transparent; }

/* Avisos */
.aviso {
  padding: .8rem 1rem; border-radius: var(--radio-s); font-size: .95rem;
  border: 1px solid var(--borde-2); background: var(--superficie-2); color: var(--tinta-2);
}
.aviso.ok    { background: var(--ok-suave);    border-color: var(--ok);    color: var(--ok); }
.aviso.error { background: var(--error-suave); border-color: var(--error); color: var(--error); }
.aviso.atencion { background: var(--aviso-suave); border-color: var(--aviso); color: var(--aviso); }

/* Cinta MODO DEMO */
.cinta-demo {
  background: repeating-linear-gradient(45deg, var(--aviso-suave), var(--aviso-suave) 12px, #f5e6c8 12px, #f5e6c8 24px);
  color: var(--aviso); font-weight: 600; font-size: .85rem; text-align: center;
  padding: .45rem 1rem; border-bottom: 1px solid var(--aviso);
}
@media (prefers-color-scheme: dark) {
  .cinta-demo { background: var(--aviso-suave); }
}

/* Toast */
.toast-zona {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  z-index: 10000; display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 420px);
}
.toast {
  background: var(--tinta); color: var(--bg); padding: .8rem 1rem; border-radius: var(--radio-s);
  box-shadow: var(--sombra-fuerte); font-size: .93rem; animation: toast-in .3s var(--ease);
}
.toast.error { background: var(--error); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* Modal */
dialog {
  border: 0; border-radius: var(--radio); padding: 0;
  width: min(440px, calc(100% - 2rem));
  margin: auto;                       /* el reset quita el auto por defecto → centrar */
  background: var(--superficie); color: var(--tinta); box-shadow: var(--sombra-fuerte);
}
dialog::backdrop { background: rgba(10,15,25,.55); backdrop-filter: blur(2px); }
.modal-cuerpo { padding: 1.75rem; }
.modal-cuerpo h3 { margin-bottom: .5rem; }
.modal-cuerpo .modal-acciones { display: grid; gap: .55rem; margin-top: 1.4rem; }
.modal-nota-demo {
  display: flex; align-items: center; gap: .5rem; margin: 0 0 1.1rem;
  padding: .6rem .8rem; border-radius: var(--radio-s); font-size: .82rem; font-weight: 600;
  background: var(--aviso-suave); color: var(--aviso); border: 1px solid var(--aviso);
}

/* =============================================================
   6. Cabecera / pie
   ============================================================= */
.cabecera {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--borde);
}
.cabecera-fila { display: flex; align-items: center; gap: 1rem; height: 64px; }
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; color: var(--tinta); letter-spacing: -0.02em; }
.logo:hover { text-decoration: none; }
.logo-marca {
  width: 26px; height: 26px; border-radius: 6px; background: var(--tinta);
  display: grid; place-items: center; flex: none;
}
.logo-marca::after { content: ""; width: 14px; height: 5px; background: var(--negro-censura); border: 1px solid #fff; border-radius: 1px; }
.nav-princ { margin-left: auto; display: flex; align-items: center; gap: 1.5rem; }
.nav-princ a:not(.btn) { color: var(--tinta-2); font-weight: 500; font-size: .95rem; }
.nav-princ a:not(.btn):hover { color: var(--tinta); text-decoration: none; }
.nav-toggle { display: none; }

.pastilla-creditos {
  display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem;
  background: var(--acento-suave); color: var(--acento-tinta); border-radius: 999px;
  font-weight: 600; font-size: .9rem;
}
.menu-cuenta { position: relative; }
.menu-cuenta > button {
  display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .6rem;
  border-radius: var(--radio-s); border: 1px solid var(--borde-2); font-weight: 600; font-size: .9rem;
}
.menu-cuenta-lista {
  position: absolute; right: 0; top: calc(100% + .4rem); min-width: 180px;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio-s);
  box-shadow: var(--sombra-fuerte); padding: .4rem; display: none;
}
.menu-cuenta-lista.abierto { display: block; }
.menu-cuenta-lista a, .menu-cuenta-lista button {
  display: block; width: 100%; text-align: left; padding: .5rem .6rem; border-radius: 6px;
  color: var(--tinta-2); font-size: .92rem; font-weight: 500;
}
.menu-cuenta-lista a:hover, .menu-cuenta-lista button:hover { background: var(--superficie-2); text-decoration: none; color: var(--tinta); }

.pie {
  border-top: 1px solid var(--borde); margin-top: 5rem; padding: 3rem 0 2rem;
  color: var(--tinta-3); font-size: .9rem;
}
.pie-cols { display: flex; flex-wrap: wrap; gap: 2.5rem; justify-content: space-between; margin-bottom: 2rem; }
.pie a { color: var(--tinta-2); }
.pie h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--tinta-3); margin-bottom: .8rem; }
.pie ul { list-style: none; display: grid; gap: .5rem; }

/* =============================================================
   6b. Secciones landing
   ============================================================= */
.hero { padding: clamp(3rem, 8vw, 6rem) 0 clamp(2.5rem, 6vw, 4rem); }
.hero h1 { margin-bottom: 1rem; }
.hero .plomo { max-width: 44ch; margin-bottom: 1.8rem; }
.hero-acciones { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }
.hero-nota { color: var(--tinta-3); font-size: .88rem; margin-top: 1rem; }

/* Comparador antes/después */
.comparador {
  position: relative; border-radius: var(--radio); overflow: hidden; border: 1px solid var(--borde);
  box-shadow: var(--sombra-fuerte); background: #fff; aspect-ratio: 16 / 10; user-select: none;
  touch-action: pan-y;
}
.comparador img, .comparador svg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.comparador .despues { clip-path: inset(0 0 0 var(--pos, 50%)); }
.comparador-linea {
  position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 2px; background: var(--acento);
  transform: translateX(-1px);
}
.comparador-tirador {
  position: absolute; top: 50%; left: var(--pos, 50%); width: 40px; height: 40px; border-radius: 50%;
  background: var(--acento); transform: translate(-50%, -50%); display: grid; place-items: center;
  box-shadow: var(--sombra-fuerte); cursor: ew-resize;
}
.comparador-tirador::before { content: "◂ ▸"; color: #fff; font-size: .7rem; letter-spacing: -2px; }
.comparador-tag {
  position: absolute; top: .7rem; padding: .2rem .6rem; background: rgba(10,15,25,.7); color: #fff;
  font-size: .75rem; font-weight: 600; border-radius: 4px;
}
.comparador-tag.izq { left: .7rem; }
.comparador-tag.der { right: .7rem; }

.seccion { padding: clamp(2.5rem, 7vw, 4.5rem) 0; }
.seccion-cabeza { max-width: 52ch; margin-bottom: 2.5rem; }
.seccion-cabeza.centro { margin-inline: auto; text-align: center; }

.rejilla-detecta { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.detecta-item { padding: 1.3rem; }
.detecta-item .ico { width: 34px; height: 34px; color: var(--acento); margin-bottom: .7rem; }
.detecta-item h3 { margin-bottom: .3rem; }
.detecta-item p { color: var(--tinta-2); font-size: .95rem; }

.pasos { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; counter-reset: paso; }
.paso { position: relative; padding-top: 3rem; }
.paso::before {
  counter-increment: paso; content: counter(paso);
  position: absolute; top: 0; left: 0; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: var(--tinta); color: var(--bg); display: grid; place-items: center; font-weight: 700;
}
.paso h3 { margin-bottom: .4rem; }
.paso p { color: var(--tinta-2); font-size: .95rem; }

/* Precios */
.toggle-precio { display: inline-flex; gap: .3rem; padding: .3rem; background: var(--superficie-2); border-radius: 999px; margin: 0 auto 2rem; }
.toggle-precio button { padding: .4rem 1rem; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--tinta-2); }
.toggle-precio button[aria-pressed="true"] { background: var(--superficie); color: var(--tinta); box-shadow: var(--sombra); }
.toggle-precio .ahorro { color: var(--ok); font-weight: 600; }

.rejilla-precios { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1.2rem; align-items: start; }
.plan { padding: 1.6rem; display: flex; flex-direction: column; gap: 1rem; position: relative; }
.plan.destacado { border-color: var(--acento); box-shadow: 0 0 0 1px var(--acento), var(--sombra-fuerte); }
.plan-badge {
  position: absolute; top: -.7rem; left: 1.6rem; background: var(--acento); color: #fff;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; padding: .2rem .6rem; border-radius: 4px; text-transform: uppercase;
}
.plan h3 { font-size: 1.3rem; }
.plan-precio { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; }
.plan-precio span { font-size: .95rem; font-weight: 500; color: var(--tinta-3); }
.plan-resumen { color: var(--tinta-2); font-size: .93rem; min-height: 2.4em; }
.plan ul { list-style: none; display: grid; gap: .55rem; font-size: .93rem; color: var(--tinta-2); }
.plan li { display: flex; gap: .5rem; }
.plan li::before { content: "✓"; color: var(--ok); font-weight: 700; flex: none; }

.faq-item { border-bottom: 1px solid var(--borde); }
.faq-item summary { padding: 1.1rem 0; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--acento); font-size: 1.3rem; line-height: 1; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { padding-bottom: 1.1rem; color: var(--tinta-2); }

.cta-final { text-align: center; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: clamp(2rem, 6vw, 3.5rem); }
.cta-final h2 { margin-bottom: .6rem; }
.cta-final .plomo { margin-bottom: 1.5rem; }

/* Páginas legales */
.legal { padding: 3rem 0; }
.legal h1 { margin-bottom: 1.5rem; }
.legal h2 { font-size: 1.25rem; margin: 2rem 0 .6rem; }
.legal p, .legal li { color: var(--tinta-2); margin-bottom: .8rem; }
.legal ul { padding-left: 1.4rem; }

/* Autenticación */
.auth-envoltura { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 2rem 1rem; }
.auth-caja { width: min(100%, 420px); padding: 2rem; }
.auth-tabs { display: flex; gap: .3rem; margin-bottom: 1.5rem; background: var(--superficie-2); border-radius: var(--radio-s); padding: .3rem; }
.auth-tabs button { flex: 1; padding: .5rem; border-radius: 6px; font-weight: 600; font-size: .92rem; color: var(--tinta-2); }
.auth-tabs button[aria-pressed="true"] { background: var(--superficie); color: var(--tinta); box-shadow: var(--sombra); }

/* =============================================================
   7. App (herramienta)
   ============================================================= */
.app-body { background: var(--superficie-2); }
.app-main { padding: 1.5rem 0 4rem; }
.app-grid { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }
@media (min-width: 960px) { .app-grid.con-panel { grid-template-columns: 1fr 340px; } }

.zona-soltar {
  border: 2px dashed var(--borde-2); border-radius: var(--radio); background: var(--superficie);
  padding: clamp(2rem, 8vw, 4rem) 1.5rem; text-align: center; transition: border-color .2s, background .2s;
}
.zona-soltar.encima { border-color: var(--acento); background: var(--acento-suave); }
.zona-soltar .ico-subir { width: 42px; height: 42px; color: var(--acento); margin: 0 auto .8rem; }
.zona-soltar h2 { font-size: 1.2rem; margin-bottom: .4rem; }
.zona-soltar p { color: var(--tinta-3); font-size: .92rem; margin-bottom: 1rem; }

.barra-estado {
  display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; padding: .9rem 1.1rem;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); margin-bottom: 1rem;
}
.barra-estado .nombre-doc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.barra-estado .coste { color: var(--tinta-2); font-size: .9rem; }
.barra-estado .acciones { margin-left: auto; display: flex; gap: .6rem; flex-wrap: wrap; }

.progreso { height: 6px; background: var(--superficie-2); border-radius: 999px; overflow: hidden; }
.progreso i { display: block; height: 100%; background: var(--acento); width: 0; transition: width .3s var(--ease); }

.paginas-visor { display: grid; gap: 1.2rem; }
.pagina-lienzo {
  position: relative; margin: 0 auto; background: #fff; box-shadow: var(--sombra); border: 1px solid var(--borde);
  max-width: 100%;
}
.pagina-lienzo canvas { display: block; width: 100%; height: auto; }
.capa-recuadros { position: absolute; inset: 0; }
.recuadro {
  position: absolute; background: var(--negro-censura); outline: 1px solid rgba(255,255,255,.25);
  cursor: pointer;
}
.recuadro.inactivo { background: transparent; outline: 2px dashed var(--acento); }
.recuadro.manual { outline-color: var(--ok); }
.pagina-lienzo.dibujando { cursor: crosshair; }
.rect-dibujo { position: absolute; background: rgba(10,10,10,.35); outline: 2px solid var(--negro-censura); pointer-events: none; }

/* Panel de detecciones */
.panel-detec { position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
.panel-detec-cabeza { padding: 1rem 1.1rem; border-bottom: 1px solid var(--borde); }
.panel-detec-cabeza h2 { font-size: 1.05rem; }
.panel-detec-cabeza .mini { color: var(--tinta-3); font-size: .85rem; }
.panel-acciones-masa { display: flex; gap: .5rem; margin-top: .7rem; }
.panel-acciones-masa button { font-size: .82rem; font-weight: 600; color: var(--acento); }
.lista-detec { overflow-y: auto; padding: .5rem; flex: 1; }
.detec {
  display: flex; gap: .6rem; align-items: flex-start; padding: .6rem; border-radius: var(--radio-s);
}
.detec:hover { background: var(--superficie-2); }
.detec input[type="checkbox"] { margin-top: .2rem; width: 16px; height: 16px; flex: none; accent-color: var(--acento); }
.detec-cuerpo { min-width: 0; flex: 1; }
.detec-tipo { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--tinta-3); }
.detec-texto { font-size: .9rem; word-break: break-word; }
.detec-meta { font-size: .78rem; color: var(--tinta-3); }
.detec.no-localizada .detec-tipo { color: var(--aviso); }
.detec-borrar { color: var(--tinta-3); font-size: 1rem; padding: 0 .2rem; }
.detec-borrar:hover { color: var(--error); }

.panel-detec-pie { padding: 1rem 1.1rem; border-top: 1px solid var(--borde); display: grid; gap: .6rem; }

.estado-vacio { text-align: center; color: var(--tinta-3); padding: 3rem 1rem; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (max-width: 860px) {
  .nav-princ { position: fixed; inset: 64px 0 auto 0; flex-direction: column; align-items: stretch;
    background: var(--superficie); border-bottom: 1px solid var(--borde); padding: 1rem 1.2rem; gap: 1rem;
    transform: translateY(-120%); transition: transform .3s var(--ease); }
  .nav-princ.abierto { transform: none; }
  .nav-toggle { display: inline-grid; place-items: center; margin-left: auto; width: 40px; height: 40px; border-radius: var(--radio-s); border: 1px solid var(--borde-2); }
  .nav-princ .btn { text-align: center; }
  .menu-cuenta { margin-left: auto; }
}
@media (min-width: 720px) {
  .hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 3rem; align-items: center; }
}
