:root {
  --bg: #0d1117; --panel: #151b24; --panel-2: #1c2430; --line: #2a3442;
  --text: #e6edf3; --muted: #93a1b3; --accent: #ff6b5b; --accent-2: #ffb35c; --good: #3ccf91;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 14px; }
.brand h1, .card h2 { font-family: 'IBM Plex Serif', Georgia, serif; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { display: grid; grid-template-columns: 360px 1fr; grid-template-rows: 100%; height: 100vh; }
aside { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.brand h1 span { color: var(--accent); }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
nav button { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 8px 2px; font-size: 11.5px; color: var(--muted); }
nav button:hover { background: var(--panel-2); color: var(--text); }
nav button.active { background: var(--panel-2); border-color: var(--line); color: var(--text); font-weight: 600; }
nav button .ico { display: block; font-size: 16px; margin-bottom: 2px; }
.scroll { overflow-y: auto; padding: 14px 16px 24px; flex: 1; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card h3 { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.card p { margin: 0 0 8px; line-height: 1.5; color: #cdd6e0; }
.pearl { border: 1px solid rgba(255,179,92,.22); padding: 8px 10px; background: rgba(255,179,92,.07); border-radius: 8px; color: #f3dcc0; font-size: 13px; line-height: 1.45; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 12px; }
.chip:hover { border-color: #46546a; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #1a0b09; font-weight: 600; }
.group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 0 6px; }
.phase-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.phase-pill i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-weight: 600; }
.switch input { width: 40px; height: 22px; accent-color: var(--good); }
.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.cmp td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.cmp td:nth-child(2), .cmp td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.cmp .up { color: var(--accent-2); } .cmp .down { color: #69b7ff; }

main { display: grid; grid-template-rows: 1fr 210px; min-width: 0; min-height: 0; }
#viewport { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 40%, #1a2230 0%, #0d1117 70%); }
#viewport canvas { display: block; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; letter-spacing: .02em; }
#labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.hud, .controls { z-index: 2; }
.lbl { font-size: 11.5px; font-weight: 600; color: #fff; background: rgba(13,17,23,.72); border: 1px solid rgba(255,255,255,.14); padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
.hud { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 12px; pointer-events: none; flex-wrap: wrap; }
.hud > * { pointer-events: auto; }
.readouts { display: grid; grid-template-columns: repeat(6, auto); gap: 4px 14px; background: rgba(21,27,36,.85); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(6px); }
.ro b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.ro span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
#phaseHud { background: rgba(21,27,36,.85); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; align-self: flex-start; }
.controls { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; background: rgba(21,27,36,.9); border: 1px solid var(--line); border-radius: 12px; padding: 6px; backdrop-filter: blur(6px); flex-wrap: wrap; justify-content: center; max-width: calc(100% - 24px); }
.controls button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; }
.controls button.on { background: #2b3a4f; border-color: #4b6280; }
.controls label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.controls input[type=range] { width: 90px; accent-color: var(--accent); }
#wiggersWrap { border-top: 1px solid var(--line); background: var(--panel); position: relative; }
#wiggers { width: 100%; height: 100%; display: block; cursor: crosshair; }
.disclaimer { position: absolute; right: 12px; bottom: 12px; font-size: 10.5px; color: #6f7d90; pointer-events: none; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  main { grid-template-rows: 62vh 180px; order: 1; }
  aside { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .readouts { grid-template-columns: repeat(3, auto); }
  .disclaimer, #phaseHud { display: none; }
  .lbl { font-size: 10px; padding: 2px 5px; }
}

/* --- Navegación entre regiones y visor genérico --- */
.region-nav { margin-top: 10px; width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; font: inherit; font-size: 13px; }
nav.tabs-auto { grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); }
main.no-chart { grid-template-rows: 1fr 0; }
main.no-chart #chartWrap { display: none; }
#chartWrap { border-top: 1px solid var(--line); background: var(--panel); position: relative; }
#chart { width: 100%; height: 100%; display: block; }
.cat { display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: #2b3a4f; color: #c9d7ea; margin-right: 6px; }
.cat.trauma { background: #4a2d2a; color: #ffc9bd; }
.cat.urgencia { background: #4a3a1c; color: #ffe0a3; }
.layer { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.layer:last-child { border-bottom: 0; }
.layer input { accent-color: var(--good); width: 18px; height: 18px; }
.cond-list { display: flex; flex-direction: column; gap: 6px; }
.cond-btn { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 13px; }
.cond-btn:hover { border-color: #46546a; }
.cond-btn.active { border-color: var(--accent); background: rgba(255,107,91,.08); }
.cond-btn small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.marker-lbl { font-size: 11px; font-weight: 600; color: #fff; background: rgba(120,20,20,.85); padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.hub-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.hub-card { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.hub-card:hover { border-color: var(--accent); }
.hub-card .ico { font-size: 24px; }
.hub-card b { display: block; font-size: 14px; }
.hub-card span { color: var(--muted); font-size: 12px; }
