/* Pensada para proyectar en clase: fondo oscuro, números grandes y un color
   fijo por energía (Ec coral, Ep azul, Em blanco) en gráfico, leyenda y tablas. */
:root {
  --bg: #0E0F11;
  --card: #16181B;
  --card2: #1C1F23;
  --line: #2A2E33;
  --ink: #F2F1EC;
  --muted: #8D9298;
  --ec: #FF7A59;
  --ep: #5AA2FF;
  --em: #F2F1EC;
  --fz: #C9A2FF;
  --ok: #5BD08A;
  --warn: #F2B544;
  --bad: #FF6B6B;
  --sans: "Geist", "Segoe UI", system-ui, sans-serif;
  --mono: "Geist Mono", Consolas, ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }

/* barra superior */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: max(18px, env(safe-area-inset-top)) 28px 18px; border-bottom: 1px solid var(--line); }
.title h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.conn { display: flex; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; color: var(--muted);
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on { color: var(--ink); } .pill.on i { background: var(--ok); box-shadow: 0 0 0 4px rgba(91,208,138,.18); }

.btn { border: 1px solid var(--line); background: var(--card2); padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 500; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: #3B4047; background: #23272C; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #fff; border-color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible, .link:focus-visible { outline: 2px solid var(--ep); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 4px; }
.link:hover { color: var(--ink); }

.banner { margin: 16px 28px 0; padding: 12px 16px; border-radius: 12px; border: 1px solid rgba(242,181,68,.4); background: rgba(242,181,68,.08); line-height: 1.5; }

main { padding: 20px 28px 40px; max-width: 1440px; margin: 0 auto; display: grid; gap: 16px; }

/* controles */
.bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button small { font-weight: 400; font-family: var(--mono); font-size: 12px; margin-left: 6px; opacity: .8; }
.seg button[aria-selected="true"] { background: var(--card2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.mass { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.mass input { width: 84px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-family: var(--mono); text-align: right; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.phase { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 16px; min-height: 24px; }
.phase i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.phase.run i { background: var(--ok); animation: pulse 1.2s infinite; }
.phase.wait i { background: var(--ep); animation: pulse .7s infinite; }
.phase.done i { background: var(--ep); }
.phase.bad i { background: var(--bad); } .phase.bad { color: #FFB1A8; }
.phase.warn i { background: var(--warn); }
@keyframes pulse { 50% { opacity: .25; } }

/* escenario: gráfico + lectura */
.stage { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; min-width: 0; }
.chart { display: flex; flex-direction: column; gap: 10px; }
.chart canvas { width: 100%; height: 380px; display: block; }
.legend { display: flex; gap: 20px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 7px; }
.legend b { color: var(--ink); font-weight: 500; margin-left: 4px; }
.legend.force { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.legend .f i { background: var(--fz); height: 4px; } .legend .w i { background: none; border-top: 2px dashed var(--muted); height: 0; }
.chart canvas.small { height: 200px; }
.legend .ec i { background: var(--ec); } .legend .ep i { background: var(--ep); } .legend .em i { background: var(--em); height: 4px; }

.readout { display: grid; gap: 16px; align-content: start; }
.lab { display: block; font-size: 13px; color: var(--muted); }
.lab.fz { color: var(--fz); }
.lab.ec { color: var(--ec); } .lab.ep { color: var(--ep); } .lab.em { color: var(--em); }
.eq { display: block; font-family: var(--mono); font-size: 13px; color: var(--muted); margin-top: 2px; }
.big { display: block; font-family: var(--mono); font-weight: 500; font-size: 44px; letter-spacing: -0.03em; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.big small { font-size: 18px; color: var(--muted); margin-left: 6px; letter-spacing: 0; }

.versus { display: grid; gap: 18px; }
.versus .way + .way { padding-top: 18px; border-top: 1px solid var(--line); }
.diff { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 12px; background: var(--card2); }
.diff span { color: var(--muted); font-size: 14px; }
.diff b { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.diff.good b { color: var(--ok); } .diff.meh b { color: var(--warn); }

.facts { margin: 0; display: grid; gap: 0; padding: 6px 20px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.live { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check .row span { color: var(--muted); font-size: 14px; }
.check .row b { font-family: var(--mono); font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }
.check p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 10px 0 0; }
.work p { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 12px 0 0; }

/* tablas */
.table header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.table h2, .how h2 { margin: 0; font-size: 15px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 13px; }
td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
tr.sum td { border-bottom: 0; color: var(--ink); font-weight: 600; }
td.good { color: var(--ok); } td.meh { color: var(--warn); }
td.empty { text-align: center; color: var(--muted); font-family: var(--sans); padding: 22px; }
.table { overflow-x: auto; }

/* cómo se calcula */
.how { padding: 6px 0 0; }
.how ol { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; counter-reset: p; }
.how li { counter-increment: p; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.how li::before { content: counter(p); font-family: var(--mono); font-size: 12px; color: var(--muted); }
.how li b { display: block; font-family: var(--mono); font-size: 18px; font-weight: 500; margin: 4px 0 6px; }
.how li span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.note { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 14px 0 0; max-width: 90ch; }

@media (max-width: 1020px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .how ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart canvas { height: 300px; }
}
@media (max-width: 640px) {
  .top { padding: max(14px, env(safe-area-inset-top)) 16px 14px; }
  main { padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
  .banner { margin: 12px 16px 0; }
  .seg { width: 100%; } .seg button { flex: 1; padding: 10px 8px; } .seg button small { display: none; }
  .actions { margin-left: 0; width: 100%; } .actions .btn { flex: 1 1 calc(50% - 4px); min-height: 44px; }
  .mass input { font-size: 16px; min-height: 44px; }
  .chart canvas { height: 240px; }
  .chart canvas.small { height: 170px; }
  .card { padding: 14px 16px; }
  .big { font-size: 34px; }
  .how ol { grid-template-columns: minmax(0, 1fr); }
  .conn { width: 100%; } .conn .btn { flex: 1; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .phase i { animation: none !important; } }
