/* Demo «Estudio de viabilidad» · geometría común. Cada dirección cambia los tokens --sd-*. */
.sd {
  --sd-font: inherit; --sd-mono: ui-monospace, monospace;
  --sd-ground: transparent; --sd-surface: #fff; --sd-sub: #F4F4F5; --sd-line: #E5E6E8;
  --sd-ink: #111214; --sd-ink-2: #55585E; --sd-ink-3: #8A8D93;
  --sd-acc: #FF5A1F; --sd-acc-ink: #C2410C; --sd-ok: #157F4B;
  --sd-r: 14px; --sd-gutter: 48px;
  --sd-shadow: 0 1px 0 rgba(17,18,20,.04), 0 24px 48px -12px rgba(17,18,20,.18), 0 0 0 1px rgba(17,18,20,.06);
  --sd-shadow-sat: 0 1px 2px rgba(17,18,20,.06), 0 10px 24px -6px rgba(17,18,20,.22), 0 0 0 1px rgba(17,18,20,.06);
  position: relative; overflow: hidden; background: var(--sd-ground);
  font-family: var(--sd-font); color: var(--sd-ink); height: 460px;
  -webkit-user-select: none; user-select: none;
}
.sd .num { font-variant-numeric: tabular-nums; }
.sd .sd-cuota, .sd .sd-imp, .sd .sd-val { font-variant-numeric: proportional-nums; }
.sd-win {
  position: absolute; left: var(--sd-gutter); top: var(--sd-gutter); width: 760px; height: 470px;
  background: var(--sd-surface); border-radius: var(--sd-r); box-shadow: var(--sd-shadow); overflow: hidden;
}
.sd-bar { height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--sd-line); }
.sd-titulo { font-size: 13px; font-weight: 600; }
.sd-ej { font-size: 11px; font-weight: 600; color: var(--sd-ink-3); background: var(--sd-sub); padding: 3px 8px; border-radius: 99px; }
.sd-cuerpo { display: grid; grid-template-columns: 300px 1fr; height: calc(100% - 44px); }
.sd-col { padding: 22px 20px; border-right: 1px solid var(--sd-line); display: flex; flex-direction: column; gap: 18px; background: var(--sd-sub); }
.sd-lab { display: block; font-size: 12px; font-weight: 500; color: var(--sd-ink-2); line-height: 1.3; }
.sd-campo { display: flex; flex-direction: column; gap: 6px; }
.sd-val {
  display: flex; align-items: center; height: 40px; padding: 0 12px; background: var(--sd-surface);
  border: 1px solid var(--sd-line); border-radius: 9px; font-size: 15px; font-weight: 600;
}
.sd-sel { border-radius: 3px; transition: background .12s; }
.sd-sel.sel { background: color-mix(in srgb, var(--sd-acc) 26%, transparent); }
.sd-caret { width: 1.5px; height: 18px; background: var(--sd-ink); margin-left: 1px; opacity: 0; }
.sd-caret.on { animation: sd-parpadeo 1s steps(1) infinite; }
@keyframes sd-parpadeo { 0%, 100% { opacity: 1 } 50% { opacity: 0 } }
.sd-imp { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.sd-rail { position: relative; height: 4px; border-radius: 4px; background: var(--sd-line); margin: 10px 0 4px; }
.sd-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--sd-ink); }
.sd-thumb { position: absolute; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: var(--sd-surface); box-shadow: 0 0 0 1px rgba(17,18,20,.12), 0 2px 6px rgba(17,18,20,.18); }
.sd-seg { position: relative; display: grid; grid-auto-flow: column; justify-content: start; padding: 3px; background: var(--sd-line); border-radius: 10px; width: max-content; }
.sd-pill { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 7px; background: var(--sd-surface); box-shadow: 0 1px 2px rgba(17,18,20,.12); transition: transform .32s cubic-bezier(.3,.7,.2,1), width .32s cubic-bezier(.3,.7,.2,1); }
.sd-op { position: relative; padding: 7px 12px; font-size: 13px; font-weight: 500; color: var(--sd-ink-2); transition: color .2s; }
.sd-op.on { color: var(--sd-ink); font-weight: 600; }
.sd-res { padding: 26px 28px; display: flex; flex-direction: column; gap: 6px; }
.sd-cuota { display: flex; align-items: baseline; gap: 6px; font-size: 52px; font-weight: 700; letter-spacing: -.035em; line-height: 1.05; }
.sd-cuota small { font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--sd-ink-2); }
.sd-ltv { margin-top: 26px; max-width: 360px; }
.sd-ltv-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.sd-ltv-top b { font-size: 15px; }
.sd-ltv-rail { position: relative; height: 10px; border-radius: 10px; background: var(--sd-sub); box-shadow: inset 0 0 0 1px var(--sd-line); }
.sd-ltv-fill { position: absolute; inset: 0 auto 0 0; border-radius: 10px; background: var(--sd-acc); }
.sd-tercio { position: absolute; left: 66.67%; top: -6px; bottom: -6px; width: 2px; background: var(--sd-ink); border-radius: 2px; }
.sd-tercio span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; font: 600 11px/1.3 var(--sd-mono); font-style: normal; color: var(--sd-ink-2); }
.sd-estado { margin-top: 34px; display: inline-flex; align-items: center; gap: 8px; width: max-content; padding: 7px 12px 7px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--sd-sub); color: var(--sd-ink-3); transition: background .35s, color .35s; }
.sd-estado i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sd-estado.ok { background: color-mix(in srgb, var(--sd-ok) 12%, var(--sd-surface)); color: var(--sd-ok); }
/* Relleno al pie del resultado: barras, no palabras (el texto real está arriba) */
.sd-relleno { margin-top: 40px; display: grid; grid-template-columns: 1fr auto; gap: 14px 40px; padding-top: 22px; border-top: 1px solid var(--sd-line); max-width: 360px; }
.sd-relleno i { height: 7px; width: calc(var(--a) * 3); border-radius: 4px; background: var(--sd-line); }
.sd-relleno i:nth-child(even) { width: calc(var(--a) * 1.6); justify-self: end; }
.sd-sat {
  position: absolute; left: calc(var(--sd-gutter) - 24px); top: calc(var(--sd-gutter) - 17px); padding: 8px 14px 8px 12px; white-space: nowrap;
  background: var(--sd-surface); border-radius: 99px; box-shadow: var(--sd-shadow-sat); display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
}
.sd-sat i { width: 8px; height: 8px; border-radius: 50%; background: var(--sd-acc); }
.sd-sat span { color: var(--sd-ink-2); font-weight: 500; }
.sd-dev { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--sd-ink-3); opacity: 0; transform: translateY(-4px); transition: opacity .35s, transform .35s; }
.sd-dev.on { opacity: 1; transform: none; }
.sd-cur { position: absolute; left: 0; top: 0; width: 22px; height: 22px; z-index: 5; pointer-events: none; transition: transform .8s; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.35)); }
.sd-cur path { fill: var(--sd-ink); stroke: #fff; stroke-width: 1.6; stroke-linejoin: round; }
.sd-cur.pulsa { scale: .86; }
.sd-cur { transition-property: transform, scale; }

/* Compacta (≤ 600): otro diseño, no una reducción. Columna única, se recorta por abajo. */
@media (max-width: 600px) {
  .sd { height: 420px; --sd-gutter: 16px; }
  .sd-win { width: 340px; height: 470px; }
  .sd-cuerpo { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sd-col { border-right: 0; border-bottom: 1px solid var(--sd-line); padding: 16px; gap: 12px; }
  .sd-res { padding: 16px; }
  .sd-cuota { font-size: 40px; }
  .sd-ltv { margin-top: 14px; }
  .sd-estado { margin-top: 26px; }
  /* Relleno al pie del resultado: barras, no palabras (el texto real está arriba) */
.sd-relleno { margin-top: 40px; display: grid; grid-template-columns: 1fr auto; gap: 14px 40px; padding-top: 22px; border-top: 1px solid var(--sd-line); max-width: 360px; }
.sd-relleno i { height: 7px; width: calc(var(--a) * 3); border-radius: 4px; background: var(--sd-line); }
.sd-relleno i:nth-child(even) { width: calc(var(--a) * 1.6); justify-self: end; }
.sd-sat { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sd * { transition: none !important; animation: none !important; } }
/* La versión compacta manda sobre los ajustes de escritorio de cada página. */
@media (max-width: 600px) {
  .sd .sd-cuerpo { grid-template-columns: 1fr !important; grid-template-rows: auto 1fr; }
  .sd .sd-win { left: 16px !important; right: auto !important; width: calc(100% - 16px) !important; zoom: 1 !important; }
  .sd .sd-col { border-right: 0; }
  .sd .sd-sat, .sd .sd-relleno { display: none; }
  .sd .sd-titulo { margin-left: 0 !important; }
  .sd .sd-ej { font-size: 10px; padding: 2px 6px; }
  .sd .sd-bar { gap: 6px; padding: 0 12px; }
}
/* 03/11: ingresos y ratio de endeudamiento. Las barras van en naranja mientras se calcula
   y en verde cuando la operación queda dentro del 33 % del valor y del 35 % de los ingresos. */
.sd-par { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sd-m-dti { margin-top: 18px !important; }
.sd-ltv-fill { transition: width .6s, background-color .4s; }
/* Cada barra por su límite: verde dentro, rojo fuera. El estado, verde solo si cumplen las dos. */
.sd { --sd-mal: #C8321E; }
.sd-ltv.bien .sd-ltv-fill { background: var(--sd-ok); }
.sd-ltv.bien .sd-pct { color: var(--sd-ok); }
.sd-ltv.mal .sd-ltv-fill { background: var(--sd-mal); }
.sd-ltv.mal .sd-pct { color: var(--sd-mal); }
.sd-estado .sd-no, .sd-estado.mal .sd-si { display: none; }
.sd-estado.mal .sd-no { display: inline; }
.sd-estado.mal { background: color-mix(in srgb, var(--sd-mal) 10%, var(--sd-surface)); color: var(--sd-mal); }
.sd-tercio span { white-space: nowrap; }
