/* =========================================================
   CalcEléctrica Pro — page styles (uses tokens from styles.css)
   ========================================================= */
.calc-app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr); gap: 20px; align-items: start; }
.calc-form { display: grid; gap: 16px; }
.grid-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.field { min-width: 0; }
.calc-form .field__label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.calc-form .num > span { display: flex; align-items: center; gap: 6px; }
.calc-form .seg { margin: 0; }
.calc-form .seg button { padding: 10px 8px; font-size: 13.5px; line-height: 1.2; }
.calc-form .seg button small { display: block; font-size: 11px; font-weight: 600; opacity: 0.75; }
.seg--4 { grid-auto-columns: 1fr; }
.num__err { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--red); display: none; }
.num.is-invalid { box-shadow: inset 0 0 0 2px var(--red); }
.num.is-invalid .num__err { display: block; }
.num.shake { animation: shake 360ms var(--ease-out); }
.num--sm { padding: 6px 12px; }
.num--sm input { font-size: 18px; }
.num--inline { padding: 4px 12px; min-width: 200px; }
.num--inline input { font-size: 14px; font-family: var(--font-body); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* switch */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 10px 12px; border-radius: 14px; background: var(--tint); box-shadow: inset 0 0 0 1px var(--line); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__ui { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); flex: none; transition: background-color 200ms ease; }
.switch__ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transition: transform 250ms var(--ease-out); }
.switch input:checked + .switch__ui { background: var(--sun); }
.switch input:checked + .switch__ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__ui { outline: 2px solid var(--sun); outline-offset: 2px; }
.switch__txt { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.switch__txt b { color: var(--text); }

/* stepper */
.stepper__row { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
.stepper__row input { text-align: center; }
.stepper__btn { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--text); transition: transform 140ms var(--ease-out), background-color 150ms ease; }
.stepper__btn:active { transform: scale(0.92); }
.stepper__btn .i { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .stepper__btn:hover { background: var(--hover); } }

.dv-pick { display: grid; gap: 10px; }
.num[hidden] { display: none; }
.dv-pick .chipset { margin: 0; }

/* method illustration */
.method-art { height: 92px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.method-art svg { width: 100%; height: 100%; display: block; }
.method-art .m-wall { fill: var(--line-2); }
.method-art .m-ins { fill: #f5d58a; opacity: 0.55; }
.method-art .m-ground { fill: #b08a5a; opacity: 0.35; }
.method-art .m-pipe { fill: none; stroke: var(--muted); stroke-width: 3; }
.method-art .m-tray { fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-dasharray: 4 3; }
.method-art .m-wire { stroke: var(--ink); stroke-width: 1.5; }
.method-art .m-txt { fill: var(--muted); font: 700 10px var(--font-mono); }
.method-art .c1 { fill: #e5484d; } .method-art .c2 { fill: #3b5bff; } .method-art .c3 { fill: #10131b; } .method-art .c4 { fill: #22c55e; }
:root[data-theme="dark"] .method-art .c3 { fill: #9aa3b8; }
.method-art g.cables { animation: methodIn 400ms var(--ease-out) both; }
@keyframes methodIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- results ---------- */
.calc-out { position: sticky; top: calc(var(--nav-h) + 12px); display: grid; gap: 14px; }
.rec { position: relative; overflow: hidden; padding: 22px; border-radius: 22px; background: linear-gradient(150deg, #151b2c, #0b0f19); color: #eef1f6; box-shadow: 0 30px 60px -30px rgba(10, 14, 25, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.rec::before { content: ""; position: absolute; right: -90px; top: -90px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(245, 200, 0, 0.35), transparent 70%); pointer-events: none; }
.rec__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.rec__eyebrow { font: 600 12px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: #a3abbe; }
.rec__label { position: relative; font-family: var(--font-display); font-size: clamp(24px, 2.6vw, 34px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin-top: 10px; color: #fff; transition: opacity 200ms ease, filter 200ms ease, transform 250ms var(--ease-out); }
.rec__label.swap { opacity: 0; filter: blur(4px); transform: translateY(4px); }
.rec__label em { font-style: normal; color: #f5c800; }
.rec__sub { position: relative; margin-top: 6px; font-size: 14px; color: #a3abbe; }
.rec__chips { position: relative; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.rec__chips span { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); font-size: 13px; }
.rec__chips .i { width: 16px; height: 16px; color: #f5c800; }
.rec.is-bad .rec__label { color: #ff8a8a; }
.rec .badge--ok { background: rgba(52, 211, 153, 0.16); color: #34d399; }
.rec .badge--bad { background: rgba(255, 107, 107, 0.16); color: #ff8a8a; }
.rec .badge--warn { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kpis > div, .factors > div { padding: 12px 14px; border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: grid; align-content: start; min-width: 0; }
.kpis span, .factors span { font-size: 11.5px; font-weight: 700; color: var(--muted); line-height: 1.3; }
.kpis b { font-family: var(--font-display); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin-top: 4px; }
.kpis small { font-size: 12px; color: var(--muted); }
.factors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.factors b { font-family: var(--font-mono); font-size: 15px; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.dvbox { padding: 16px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.dvbox__row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dvbox__row span { font-size: 13px; font-weight: 700; color: var(--muted); }
.dvbox__row b { font-family: var(--font-display); font-size: 22px; font-variant-numeric: tabular-nums; }
.dvbar { position: relative; height: 12px; border-radius: 6px; margin: 22px 0 8px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.dvbar__fill { position: absolute; inset: 0; border-radius: inherit; transform-origin: 0 50%; transform: scaleX(0); background: var(--green); transition: transform 500ms var(--ease-out), background-color 300ms ease; }
.dvbar__fill.bad { background: var(--red); }
.dvbar__limit { position: absolute; top: -6px; bottom: -6px; width: 2px; border-radius: 1px; background: var(--text); transition: left 400ms var(--ease-out); }
.dvbar__limit i { position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%); font: 700 11px var(--font-mono); font-style: normal; color: var(--muted); white-space: nowrap; }
.dvbox__note { font-size: 13px; color: var(--muted); }
.dvbox__note b { color: var(--text); }

.warns { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.warns li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; font-size: 13.5px; background: rgba(245, 158, 11, 0.12); color: var(--text); animation: chipIn 300ms var(--ease-out) both; }
.warns li .i { width: 18px; height: 18px; color: #d97706; flex: none; margin-top: 1px; }
.warns li.info { background: rgba(59, 91, 255, 0.1); }
.warns li.info .i { color: var(--sky); }

.cmp h3, .memo summary { font-size: 15px; }
.cmp h3 { margin-bottom: 10px; }
.cmp__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cmpc { padding: 14px; border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 4px; align-content: start; font-size: 13px; transition: transform 200ms var(--ease-out); }
.cmpc__tag { font: 700 11px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cmpc b { font-family: var(--font-display); font-size: 24px; letter-spacing: -0.02em; }
.cmpc__row { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); }
.cmpc__row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.cmpc__why { margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--line-2); line-height: 1.4; }
.cmpc.is-sel { background: rgba(245, 200, 0, 0.1); box-shadow: inset 0 0 0 2px var(--sun); }
.cmpc.is-fail .cmpc__why { color: var(--red); }
.cmpc.is-ok .cmpc__why { color: var(--green); }
.cmpc.is-empty { opacity: 0.5; place-content: center; text-align: center; color: var(--muted); }

.memo { border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.memo summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 800; }
.memo summary::-webkit-details-marker { display: none; }
.memo summary .i { color: var(--sun-ink); }
.memo ol { margin: 0; padding: 0 18px 16px 40px; display: grid; gap: 10px; font-size: 13.5px; color: var(--muted); }
.memo li b { color: var(--text); }
.memo code { font-family: var(--font-mono); font-size: 12.5px; color: var(--text); background: var(--tint); padding: 2px 6px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); overflow-wrap: anywhere; }

/* ---------- cuadro de cargas ---------- */
.loads { margin-top: 22px; }
.loads .panel__head { flex-wrap: wrap; }
.loads__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.loads__scroll { overflow-x: auto; }
.ltable { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 860px; }
.ltable th { text-align: left; font: 700 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ltable td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.ltable .r { text-align: right; }
.ltable tbody tr { transition: background-color 300ms ease; }
.ltable tbody tr.flash { animation: rowFlash 1.2s var(--ease-out); }
@keyframes rowFlash { from { background: rgba(245, 200, 0, 0.28); } }
@media (hover: hover) and (pointer: fine) { .ltable tbody tr:hover { background: var(--hover); } }
.ltable tfoot td { font-weight: 800; border-bottom: 0; }
.ltable .cond { font-weight: 700; white-space: nowrap; }
.ltable .del { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); transition: color 150ms ease, background-color 150ms ease, transform 140ms var(--ease-out); }
.ltable .del:active { transform: scale(0.9); }
.ltable .del .i { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .ltable .del:hover { color: var(--red); background: rgba(229, 72, 77, 0.1); } }
.dvtag { display: inline-block; padding: 3px 8px; border-radius: 8px; font-weight: 800; font-size: 12px; }
.dvtag.ok { background: rgba(16, 185, 129, 0.12); color: var(--green); }
.dvtag.bad { background: rgba(229, 72, 77, 0.12); color: var(--red); }
.loads__empty { display: grid; place-items: center; gap: 10px; padding: 34px 20px; text-align: center; color: var(--muted); }
.loads__empty .i { width: 40px; height: 40px; color: var(--sun-ink); stroke-width: 1.4; }
.loads__empty[hidden] { display: none; }

.disclaimer { margin-top: 20px; }
.disclaimer code { font-family: var(--font-mono); font-size: 12px; }

/* ---------- printable report ---------- */
.report { display: none; }
@media print {
  @page { margin: 14mm; }
  .calc-app, .loads, .app-head__actions { display: none !important; }
  .report { display: block; color: #000; font-size: 11.5pt; }
  .report h2 { font-size: 16pt; margin: 0 0 4pt; }
  .report h3 { font-size: 12.5pt; margin: 14pt 0 6pt; border-bottom: 1px solid #999; padding-bottom: 3pt; }
  .report table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  .report th, .report td { border: 1px solid #bbb; padding: 4pt 6pt; text-align: left; }
  .report th { background: #eee; }
  .report .kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4pt 16pt; }
  .report .kv div { display: flex; justify-content: space-between; border-bottom: 1px dotted #bbb; padding: 2pt 0; }
  .report .big { font-size: 15pt; font-weight: 800; padding: 8pt 10pt; border: 2px solid #000; display: inline-block; margin: 4pt 0; }
  .report .memo-p { margin: 0; padding-left: 16pt; }
  .report .memo-p li { margin: 2pt 0; }
  .disclaimer { box-shadow: none; border: 1px solid #ccc; }
  .app-head p { display: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .calc-app { grid-template-columns: 1fr; }
  .calc-out { position: static; }
}
@media (max-width: 600px) {
  .grid-fields { grid-template-columns: minmax(0, 1fr); }
  .grid-fields > * { grid-column: 1 / -1; }
  .kpis, .factors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cmp__grid { grid-template-columns: 1fr; }
  .seg--4 { grid-template-columns: repeat(2, 1fr); grid-auto-flow: row; }
  .seg--4 .seg__thumb { display: none; }
  .seg--4 button[aria-checked="true"] { background: var(--sun); }
  .calc-form .seg button small { display: none; }
  .num--inline { min-width: 0; flex: 1 1 100%; }
  .app-head__actions { width: 100%; }
  .app-head__actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .rec__label, .dvbar__fill, .dvbar__limit, .switch__ui::after { transition: none; }
  .ltable tbody tr.flash, .method-art g.cables { animation: none; }
}
