@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&display=swap');

:root{
  --accent:#B8E353;
  --accent-ink:#26330C;

  --bg:#FFFFFF;
  --bg-soft:#E9E6FA;
  --surface:#FFFFFF;
  --surface-2:#F6F5FC;
  --text:#202238;
  --text-soft:#55566E;
  --brand:#3E3A8C;
  --brand-strong:#2E2B6B;
  --brand-contrast:#FFFFFF;
  --data:#2D7DD2;
  --border:#D9D5EE;
  --focus:#2D7DD2;
  --success:#2E7D5B; --success-bg:#E7F4EC;
  --error:#B3282B; --error-bg:#FBEAEA;
  --loading:#8A6D00; --loading-bg:#FBF3D8;
  --disabled:#8B8D9C; --disabled-bg:#EDEDF2;

  --font-display:'Space Grotesk','Arial Narrow',sans-serif;
  --font-body:'Inter',system-ui,sans-serif;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#181A2E; --bg-soft:#20223C; --surface:#20223C; --surface-2:#262A48;
    --text:#EEECFB; --text-soft:#B7B4D6;
    --brand:#4B45A8; --brand-strong:#5E58C4; --brand-contrast:#FFFFFF;
    --data:#6FB3EF;
    --border:#383B5E;
    --focus:#6FB3EF;
    --success:#7BD9A8; --success-bg:#123826;
    --error:#F0917A; --error-bg:#3B1C16;
    --loading:#F0C868; --loading-bg:#3A2E0F;
    --disabled:#93A4BC; --disabled-bg:#262A48;
  }
}
:root[data-theme="dark"]{
  --bg:#181A2E; --bg-soft:#20223C; --surface:#20223C; --surface-2:#262A48;
  --text:#EEECFB; --text-soft:#B7B4D6;
  --brand:#4B45A8; --brand-strong:#5E58C4; --brand-contrast:#FFFFFF;
  --data:#6FB3EF;
  --border:#383B5E;
  --focus:#6FB3EF;
  --success:#7BD9A8; --success-bg:#123826;
  --error:#F0917A; --error-bg:#3B1C16;
  --loading:#F0C868; --loading-bg:#3A2E0F;
  --disabled:#93A4BC; --disabled-bg:#262A48;
}

*{ box-sizing:border-box; }
html{ font-size:16px; }
body{ margin:0; background:var(--bg); color:var(--text); font-family:var(--font-body); line-height:1.55; }
@media (prefers-reduced-motion: reduce){ *{ animation-duration:.001ms !important; transition-duration:.001ms !important; scroll-behavior:auto !important; } }

h1,h2,h3{ font-family:var(--font-display); font-weight:700; text-wrap:balance; margin:0 0 .4em; color:var(--text); }
p{ margin:0 0 1em; max-width:62ch; }
.fig-num{ font-family:var(--font-display); font-variant-numeric:tabular-nums; }

.skip-link{ position:absolute; left:8px; top:-48px; background:var(--brand); color:var(--brand-contrast); padding:10px 16px; border-radius:4px; z-index:100; transition:top .15s ease; }
.skip-link:focus{ top:8px; }

a{ color:var(--data); }
button, input, select{ font-family:inherit; font-size:1rem; color:inherit; }
button{ cursor:pointer; }
:focus-visible{ outline:3px solid var(--focus); outline-offset:2px; border-radius:2px; }

.shell{ display:flex; min-height:100vh; }
.rail{ display:none; }
.col-main{ flex:1; min-width:0; display:flex; flex-direction:column; }

.mobile-topbar{ display:flex; align-items:center; gap:10px; padding:14px 16px; border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--bg); z-index:10; }
.mobile-topbar .page-title{ font-family:var(--font-display); font-weight:700; font-size:1.05rem; }

.brand-mark{ width:34px; height:34px; flex:none; object-fit:contain; }
.brand-lockup{ display:flex; align-items:center; gap:10px; text-decoration:none; color:var(--text); }
.brand-lockup .wordmark{ font-family:var(--font-display); font-weight:700; font-size:1.15rem; letter-spacing:-.01em; }

main{ flex:1; padding:24px 16px 100px; max-width:1180px; width:100%; margin:0 auto; }
.view-title{ font-size:clamp(1.5rem,4vw,2rem); }
.eyebrow{ font-family:var(--font-body); font-weight:600; font-size:.78rem; letter-spacing:.06em; text-transform:uppercase; color:var(--brand); margin:0 0 .5em; }

.tabbar{ position:fixed; left:0; right:0; bottom:0; display:flex; background:var(--surface); border-top:1px solid var(--border); z-index:20; }
.tabbar .tab{ flex:1; min-height:56px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; background:none; border:none; color:var(--text-soft); font-size:.68rem; font-weight:500; padding:6px 2px; }
.tabbar .tab .ico{ width:20px; height:20px; }
.tabbar .tab[aria-current="page"]{ color:var(--brand); font-weight:600; box-shadow: inset 0 2px 0 var(--brand); }

.rail .tab{ display:flex; flex-direction:column; align-items:center; gap:4px; background:none; border:none; color:var(--text-soft); font-size:.68rem; font-weight:500; padding:10px 4px; width:100%; border-radius:8px; }
.rail .tab .ico{ width:22px; height:22px; }
.rail .tab[aria-current="page"]{ color:var(--brand); font-weight:600; background:var(--bg-soft); }

@media (min-width:768px){
  .mobile-topbar{ display:none; }
  .tabbar{ display:none; }
  .rail{ display:flex; flex-direction:column; align-items:center; gap:22px; width:96px; padding:22px 8px; border-right:1px solid var(--border); position:sticky; top:0; height:100vh; background:var(--surface); flex:none; }
  .rail nav{ display:flex; flex-direction:column; gap:10px; width:100%; margin-top:12px; }
  main{ padding:40px 32px 64px; }
}

/* ---------- Cuenta (login/registro) ---------- */
.mobile-topbar .page-title{ flex:1; }

.account-entry{ display:flex; align-items:center; gap:8px; background:none; border:none; color:var(--text-soft); font-size:.72rem; font-weight:600; padding:4px 10px 4px 4px; border-radius:20px; cursor:pointer; }
.account-entry:hover{ color:var(--brand); }
.account-avatar{ width:28px; height:28px; border-radius:50%; background:var(--brand); color:var(--brand-contrast); display:flex; align-items:center; justify-content:center; font-size:.72rem; font-weight:700; flex:none; line-height:1; }
.account-avatar-empty{ background:var(--bg-soft); color:var(--brand); border:1.5px solid var(--border); }
.account-avatar-lg{ width:56px; height:56px; border-radius:50%; background:var(--brand); color:var(--brand-contrast); display:flex; align-items:center; justify-content:center; font-size:1.3rem; font-weight:700; margin:0 auto 14px; }

.rail-account{ margin-top:auto; width:100%; padding-top:14px; border-top:1px solid var(--border); display:flex; justify-content:center; }
.rail-account .account-entry{ flex-direction:column; gap:4px; padding:8px 4px; }

.auth-grid{ display:grid; gap:24px; grid-template-columns:1fr; margin-top:24px; max-width:760px; }
@media (min-width:768px){ .auth-grid{ grid-template-columns:.8fr 1.2fr; align-items:start; } }
.auth-illus{ background:var(--bg-soft); border:1.5px solid var(--border); border-radius:16px; padding:28px; display:flex; align-items:center; justify-content:center; }
.auth-illus svg{ width:100%; max-width:200px; height:auto; }
.auth-illus svg circle:first-child{ transition: transform .4s ease; }

#cuenta-logged-in{ text-align:center; max-width:360px; }

.ico-dot{ width:16px; height:16px; border-radius:50%; border:2px solid currentColor; }
.ico-dot::after{ content:''; }
.ico-target{ width:18px; height:18px; border-radius:50%; border:2px solid currentColor; position:relative; }
.ico-target::after{ content:''; position:absolute; inset:5px; border-radius:50%; background:currentColor; }
.ico-book{ width:18px; height:14px; border:2px solid currentColor; border-radius:2px; position:relative; }
.ico-book::after{ content:''; position:absolute; left:50%; top:-2px; bottom:-2px; border-left:2px solid currentColor; }
.ico-sliders{ display:flex; align-items:flex-end; gap:3px; height:18px; }
.ico-sliders span{ width:3px; background:currentColor; border-radius:1px; }
.ico-help{ width:18px; height:18px; border-radius:50%; border:2px solid currentColor; display:flex; align-items:center; justify-content:center; font-size:.65rem; font-weight:700; }

.btn{ display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:10px 20px; border-radius:6px; border:1.5px solid transparent; font-weight:600; font-size:.94rem; text-decoration:none; }
.btn-primary{ background:var(--brand); color:var(--brand-contrast); }
.btn-primary:hover{ background:var(--brand-strong); }
.btn-primary:disabled{ background:var(--disabled-bg); color:var(--disabled); cursor:not-allowed; }
.btn-secondary{ background:transparent; border-color:var(--border); color:var(--text); }
.btn-secondary:hover{ border-color:var(--brand); color:var(--brand); }
.btn-ghost{ background:none; border:none; color:var(--data); font-weight:600; padding:6px 4px; min-height:auto; text-underline-offset:3px; text-decoration:underline; }
.btn-block{ width:100%; }

.card{ background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:20px; }
.card + .card{ margin-top:16px; }
.stack{ display:flex; flex-direction:column; gap:16px; }
.grid-2{ display:grid; gap:16px; grid-template-columns:1fr; }
@media (min-width:640px){ .grid-2{ grid-template-columns:1fr 1fr; } }
.grid-3{ display:grid; gap:16px; grid-template-columns:1fr; }
@media (min-width:900px){ .grid-3{ grid-template-columns:repeat(3,1fr); } }

.chip{ display:inline-flex; align-items:center; gap:6px; font-size:.78rem; font-weight:500; padding:4px 12px; border-radius:20px; border:1px solid var(--border); color:var(--text-soft); }
.chip.chip-accent{ background:var(--accent); color:var(--accent-ink); border-color:transparent; font-weight:600; }
.chip.chip-brand{ background:var(--bg-soft); color:var(--brand); border-color:transparent; font-weight:600; }

.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:16px; }
.field label{ font-size:.82rem; font-weight:600; }
.field .hint{ font-size:.78rem; color:var(--text-soft); margin-top:-2px; }
.field input[type="text"], .field input[type="number"], .field input[type="search"], .field input[type="date"], .field input[type="password"]{
  min-height:44px; border:1.5px solid var(--border); border-radius:6px; padding:0 14px; background:var(--surface); color:var(--text);
}
.field input.invalid{ border-color:var(--error); }
.field .error-msg{ font-size:.8rem; color:var(--error); }

.segmented{ display:flex; flex-wrap:wrap; gap:8px; }
.seg-opt{ position:relative; }
.seg-opt input{ position:absolute; opacity:0; width:1px; height:1px; }
.seg-opt span{ display:inline-flex; min-height:44px; align-items:center; padding:0 16px; border:1.5px solid var(--border); border-radius:20px; font-size:.88rem; font-weight:500; color:var(--text); }
.seg-opt input:checked + span{ background:var(--brand); border-color:var(--brand); color:var(--brand-contrast); font-weight:700; }
.seg-opt input:focus-visible + span{ outline:3px solid var(--focus); outline-offset:2px; }

.progress-track{ height:10px; border-radius:6px; background:var(--surface-2); overflow:hidden; border:1px solid var(--border); }
.progress-fill{ height:100%; background:var(--brand); border-radius:6px 0 0 6px; }
@media (prefers-reduced-motion:no-preference){ .progress-fill{ transition:width .4s ease; } }

.state-msg{ display:flex; gap:10px; align-items:flex-start; padding:12px 14px; border-radius:8px; font-size:.88rem; }
.state-msg::before{ content:''; width:9px; height:9px; border-radius:50%; margin-top:6px; flex:none; }
.state-msg.error{ background:var(--error-bg); color:var(--error); }
.state-msg.error::before{ background:var(--error); }
.state-msg.success{ background:var(--success-bg); color:var(--success); }
.state-msg.success::before{ background:var(--success); }
.state-msg.loading{ background:var(--loading-bg); color:var(--loading); }
.state-msg.loading::before{ background:var(--loading); }
.state-msg strong{ display:block; margin-bottom:2px; color:inherit; }

.spinner{ width:22px; height:22px; border-radius:50%; border:3px solid var(--border); border-top-color:var(--brand); flex:none; }
@media (prefers-reduced-motion:no-preference){ .spinner{ animation:spin .8s linear infinite; } }
@keyframes spin{ to{ transform:rotate(360deg); } }

.hero{ background:var(--bg-soft); border-radius:16px; padding:32px 24px; margin-bottom:32px; }
@media (min-width:768px){ .hero{ padding:56px 48px; display:grid; grid-template-columns:1.1fr .9fr; gap:32px; align-items:center; } }
.hero .display{ font-family:var(--font-display); font-weight:700; font-size:clamp(2.1rem,5vw,3.1rem); line-height:1.05; text-wrap:balance; }
.illus{ background:var(--surface); border:1.5px solid var(--border); border-radius:12px; aspect-ratio:4/3; display:flex; align-items:center; justify-content:center; }

.benefit{ display:flex; gap:14px; align-items:flex-start; }
.benefit .ico-target, .benefit .ico-book, .benefit .ico-sliders{ color:var(--brand); flex:none; margin-top:2px; }

.footer-site{ margin-top:56px; padding-top:32px; border-top:1px solid var(--border); }
.footer-grid{ display:grid; gap:24px; grid-template-columns:1fr; }
@media (min-width:640px){ .footer-grid{ grid-template-columns:repeat(3,1fr); } }
.footer-site h3{ font-size:1rem; font-family:var(--font-body); font-weight:600; }
.footer-site details{ font-size:.86rem; color:var(--text-soft); margin-bottom:8px; }
.footer-site summary{ cursor:pointer; color:var(--text); font-weight:500; padding:4px 0; }
.footer-legal{ margin-top:28px; font-size:.78rem; color:var(--text-soft); }

.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; }

.diag-progress{ display:flex; align-items:center; gap:12px; margin-bottom:20px; }
.diag-progress .step-label{ font-size:.82rem; color:var(--text-soft); white-space:nowrap; }

details.faq{ border:1px solid var(--border); border-radius:8px; padding:4px 16px; margin-bottom:10px; }
details.faq summary{ padding:12px 0; font-weight:600; cursor:pointer; }
details.faq p{ padding-bottom:14px; color:var(--text-soft); font-size:.92rem; }

.lesson-row{ display:flex; align-items:center; gap:14px; padding:14px 0; border-bottom:1px solid var(--border); }
.lesson-row:last-child{ border-bottom:none; }
.lesson-row .meta{ flex:1; min-width:0; }
.lesson-row .meta h3{ font-size:.98rem; margin-bottom:4px; }
.lesson-row .sub{ font-size:.8rem; color:var(--text-soft); display:flex; gap:8px; align-items:center; }

.filters{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:20px; }
.filters button{ min-height:36px; padding:0 14px; border-radius:20px; border:1.5px solid var(--border); background:var(--surface); color:var(--text-soft); font-size:.84rem; font-weight:500; }
.filters button[aria-pressed="true"]{ background:var(--brand); border-color:var(--brand); color:var(--brand-contrast); font-weight:700; }

.sim-row{ display:grid; grid-template-columns:1fr 100px; gap:12px; align-items:center; margin-bottom:6px; }
.sim-row input[type="range"]{ width:100%; accent-color:var(--brand); }
.sim-result{ text-align:center; padding:28px 16px; background:var(--bg-soft); border-radius:12px; margin:20px 0; }
.sim-result .amount{ font-family:var(--font-display); font-weight:700; font-size:clamp(2rem,6vw,2.8rem); color:var(--brand); }

.empty-state{ text-align:center; padding:48px 20px; }
.empty-state .ico-target{ width:56px; height:56px; margin:0 auto 16px; color:var(--brand); }

/* ---------- Movimiento e interactividad ---------- */

.view{ animation: viewIn .45s cubic-bezier(.16,1,.3,1); }
@keyframes viewIn{
  from{ opacity:0; transform:translateY(14px); }
  to{ opacity:1; transform:translateY(0); }
}

.btn{ transition: transform .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease; }
.btn:active{ transform:scale(.96); }
.btn-primary:not(:disabled):hover{ transform:translateY(-1px); box-shadow:0 6px 16px -6px rgba(46,43,107,.45); }
.btn-secondary:not(:disabled):hover{ transform:translateY(-1px); }

.card{ transition: transform .2s ease, box-shadow .2s ease; }
.card:hover{ box-shadow:0 8px 24px -12px rgba(32,34,56,.18); }

.chip, .seg-opt span, .filters button{ transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .15s ease; }
.seg-opt input:checked + span{ transform:scale(1.03); }

.tab{ transition: color .2s ease; }
@keyframes tabPop{ 0%{ transform:scale(1); } 45%{ transform:scale(1.14); } 100%{ transform:scale(1); } }
.tab[aria-current="page"]{ animation: tabPop .35s ease; }

.brand-mark{ transition: transform .4s cubic-bezier(.34,1.56,.64,1); }
.brand-lockup:hover .brand-mark{ transform: rotate(18deg); }

.state-msg{ animation: msgIn .3s ease; }
@keyframes msgIn{ from{ opacity:0; transform:translateY(-6px) scale(.98); } to{ opacity:1; transform:translateY(0) scale(1); } }
.state-msg.success{ animation: msgIn .3s ease, celebrate 1.4s ease .3s 1; }
@keyframes celebrate{ 0%,100%{ box-shadow:0 0 0 0 rgba(46,125,91,0); } 50%{ box-shadow:0 0 0 6px rgba(46,125,91,.2); } }

.diag-step{ animation: stepIn .35s cubic-bezier(.16,1,.3,1); }
@keyframes stepIn{ from{ opacity:0; transform:translateX(16px); } to{ opacity:1; transform:translateX(0); } }

.reveal{ opacity:0; transform:translateY(18px); transition: opacity .55s ease, transform .55s ease; }
.reveal.in{ opacity:1; transform:translateY(0); }

.illus img{ transition: transform .4s ease; }
.illus:hover img{ transform: scale(1.04) rotate(-2deg); }

.stat-num{ font-weight:700; font-size:clamp(2.1rem,5vw,2.6rem); color:var(--brand); margin:0 0 8px; }

.breakdown-row{ margin-bottom:14px; }
.breakdown-row:last-child{ margin-bottom:0; }
.breakdown-label{ display:flex; justify-content:space-between; align-items:baseline; font-size:.82rem; font-weight:600; margin-bottom:6px; }
