[hidden] { display: none !important; }
:root {
  --p: #6d28d9;          /* se sobrescribe desde config.js */
  --a: #f59e0b;
  --bg: #f6f5fb;
  --card: #ffffff;
  --tx: #17151f;
  --tx2: #5f5b6e;
  --line: #e6e3ef;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --r: 18px;
  --sh: 0 1px 2px rgb(20 10 50 / .05), 0 8px 24px rgb(20 10 50 / .06);
  color-scheme: light;
}
:root[data-tema="oscuro"] {
  --bg: #0f0d16;
  --card: #1a1724;
  --tx: #f1eff7;
  --tx2: #a6a1b8;
  --line: #2b2738;
  --sh: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--tx);
  min-height: 100dvh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
a { color: var(--p); }
button { font: inherit; cursor: pointer; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--card); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--p) 55%, transparent); outline-offset: 2px; }

/* ---------- barra superior / inferior ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--tx); font-weight: 800; font-size: 18px; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: var(--p) url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2216%22%20fill%3D%22%236d28d9%22/%3E%3Cpath%20d%3D%22M25%2020v24l20-12z%22%20fill%3D%22%23fff%22/%3E%3C/svg%3E") center/cover; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  text-decoration: none; color: var(--tx2); font-size: 14px; font-weight: 600;
}
.tabs a svg { width: 18px; height: 18px; }
.tabs a[aria-current="page"] { background: color-mix(in srgb, var(--p) 12%, transparent); color: var(--p); }
.tabs a:hover { color: var(--tx); }

@media (max-width: 720px) {
  /* backdrop-filter haría que la barra fija quede dentro del encabezado */
  .topbar { backdrop-filter: none; background: var(--bg); }
  .chat { height: calc(100dvh - 210px - env(safe-area-inset-bottom)); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--line);
  }
  .tabs a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 8px; border-radius: 12px; }
  .tabs a svg { width: 22px; height: 22px; }
}

/* ---------- layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 20px 16px; outline: none; animation: in .25s ease; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
h1 { font-size: clamp(26px, 5vw, 34px); line-height: 1.15; margin: 4px 0 4px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 28px 0 12px; letter-spacing: -.01em; }
h3 { font-size: 17px; margin: 0 0 4px; }
.sub { color: var(--tx2); margin: 0 0 20px; }
.muted { color: var(--tx2); font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--sh); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--p); color: #fff; font-weight: 700; text-decoration: none;
  transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn.sec { background: transparent; color: var(--tx); border-color: var(--line); }
.btn.wa { background: #25d366; color: #073b1e; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- inicio ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: 26px 22px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--a) 70%, transparent), transparent 55%),
              linear-gradient(135deg, var(--p), color-mix(in srgb, var(--p) 55%, #000));
}
.hero h1 { color: #fff; }
.hero p { opacity: .9; margin: 0 0 18px; }
.hero .btn { background: #fff; color: var(--p); }
.hero .btn.sec { background: rgb(255 255 255 / .14); color: #fff; border-color: rgb(255 255 255 / .3); }
.tile { display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: var(--tx); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--p) 40%, var(--line)); }
.ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: color-mix(in srgb, var(--p) 12%, transparent); color: var(--p); flex: none; }
.aviso { border-left: 4px solid var(--warn); }
.pasos { counter-reset: p; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.pasos .card::before { counter-increment: p; content: counter(p); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--p); color: #fff; font-weight: 800; font-size: 14px; margin-bottom: 8px; }

/* ---------- planes ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.chip { white-space: nowrap; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--tx); font-weight: 600; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--tx); color: var(--bg); border-color: var(--tx); }
.buscar { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--tx); font: inherit; margin-bottom: 12px; }
[data-lista] { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.plan { display: flex; flex-direction: column; gap: 10px; position: relative; }
.plan .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--bg); color: var(--tx2); border: 1px solid var(--line); }
.badge { position: absolute; top: -10px; right: 14px; background: var(--a); color: #1a1200; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.badge.agotado { background: var(--tx2); color: var(--bg); }
.opciones { display: grid; gap: 6px; }
.opcion { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.opcion:has(input:checked) { border-color: var(--p); background: color-mix(in srgb, var(--p) 7%, transparent); }
.opcion input { accent-color: var(--p); }
.precio { font-weight: 800; font-size: 18px; }
.precio small { font-size: 12px; font-weight: 500; color: var(--tx2); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100dvh - 190px); min-height: 380px; padding: 0; overflow: hidden; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.bot { background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.yo { background: var(--p); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg time { display: block; font-size: 11px; opacity: .6; margin-top: 2px; text-align: right; }
.sugerencias { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; }
.chat form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat input { flex: 1; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--tx); font: inherit; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%; background: var(--tx2); animation: b 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes b { 50% { transform: translateY(-4px); opacity: .5; } }

/* ---------- cuentas ---------- */
.cuenta { display: grid; gap: 10px; }
.barra { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.estado { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.estado.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.estado.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.estado.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.cred { display: flex; align-items: center; gap: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 14px; background: var(--bg); padding: 8px 10px; border-radius: 10px; }
.vacio { text-align: center; padding: 36px 18px; }

/* ---------- formularios / ajustes ---------- */
label.campo { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.campo input, .campo select { padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--tx); font: inherit; font-weight: 400; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch input { width: 44px; height: 26px; appearance: none; background: var(--line); border-radius: 99px; position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
.switch input:checked { background: var(--p); }
.switch input:checked::after { transform: translateX(18px); }

details.faq { border-bottom: 1px solid var(--line); padding: 12px 0; }
details.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.faq summary::after { content: "+"; color: var(--tx2); font-size: 20px; line-height: 1; }
details.faq[open] summary::after { content: "–"; }
details.faq p { margin: 8px 0 0; color: var(--tx2); }

dialog { border: 0; border-radius: 20px; padding: 22px; width: min(440px, 92vw); background: var(--card); color: var(--tx); }
dialog::backdrop { background: rgb(10 5 25 / .5); backdrop-filter: blur(2px); }

/* ---------- flotantes ---------- */
.wa-flotante {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 15;
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: #25d366; color: #fff; box-shadow: 0 6px 20px rgb(0 0 0 / .2);
}
.wa-flotante svg { width: 30px; height: 30px; }
@media (max-width: 720px) { .wa-flotante { bottom: calc(84px + env(safe-area-inset-bottom)); } }
body[data-ruta="/chat"] .wa-flotante { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--tx); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: .25s; z-index: 50;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }

/* ---------- chat en vivo ---------- */
.dot.off { background: var(--warn); }
.msg.pendiente { opacity: .6; }
.msg a { color: inherit; text-decoration: underline; }
.msg img.adjunto { display: block; max-width: 220px; max-height: 260px; border-radius: 10px; margin-bottom: 4px; cursor: zoom-in; object-fit: cover; }
.chat form .adjuntar { padding: 0 12px; font-size: 18px; }
.tabs a.nuevo span::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 50%; background: var(--bad); vertical-align: top; }

/* ---------- pago ---------- */
.error { color: var(--bad); font-weight: 600; font-size: 14px; margin: 0; }
.total { padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--p) 8%, transparent); }
.total strong { font-size: 20px; }
.vista-previa { max-height: 180px; border-radius: 12px; object-fit: contain; background: var(--bg); }
dialog { max-height: 92dvh; overflow-y: auto; }
.msg { white-space: normal; }
.msg > span { white-space: pre-wrap; }
.chat form input, .chat form textarea { min-width: 0; }
.chat form .btn { flex: none; }
.chat-head .spacer { min-width: 0; }
