:root {
  --bg: #0f1420;
  --bg-panel: #1a2233;
  --bg-elev: #222d42;
  --borde: #2e3a52;
  --texto: #e8edf5;
  --texto-tenue: #9aa8bf;
  --acento: #4db6ac;
  --acento-fuerte: #26a69a;
  --resalte: #ffd166;
  --seleccion: #ff8a65;
  --sombra: 0 8px 30px rgba(0, 0, 0, 0.35);
  --radio: 14px;
  font-size: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef2f7;
    --bg-panel: #ffffff;
    --bg-elev: #f4f7fb;
    --borde: #d6deea;
    --texto: #1c2836;
    --texto-tenue: #5a6b82;
    --acento: #009688;
    --acento-fuerte: #00796b;
    --resalte: #f4a900;
    --seleccion: #e64a19;
    --sombra: 0 8px 30px rgba(60, 80, 110, 0.15);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-elev), var(--bg));
  color: var(--texto);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.cabecera {
  text-align: center;
  padding: 1.4rem 1rem 0.6rem;
}
.cabecera h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: 0.3px;
}
.subtitulo {
  margin: 0.35rem auto 0;
  max-width: 640px;
  color: var(--texto-tenue);
  font-size: 0.95rem;
}

/* ---- Controles ---- */
.controles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}
.sistemas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  background: var(--bg-panel);
  padding: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--borde);
  box-shadow: var(--sombra);
}
.btn-sistema {
  border: none;
  background: transparent;
  color: var(--texto-tenue);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.btn-sistema:hover { color: var(--texto); background: var(--bg-elev); }
.btn-sistema.activa {
  background: var(--acento-fuerte);
  color: #fff;
}
.btn-sistema .icono { font-size: 1.05rem; }

.toggle-vista {
  display: inline-flex;
  background: var(--bg-panel);
  border: 1px solid var(--borde);
  border-radius: 999px;
  padding: 0.3rem;
  box-shadow: var(--sombra);
}
.btn-vista {
  border: none;
  background: transparent;
  color: var(--texto-tenue);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.btn-vista.activa { background: var(--acento); color: #04211d; }

/* ---- Escenario ---- */
.escenario {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr minmax(300px, 380px);
  gap: 1.2rem;
  padding: 0 1.2rem 1.2rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  align-items: stretch;
}

.visor {
  background: var(--bg-panel);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: 60vh;
  position: relative;
}
.visor svg {
  width: 100%;
  height: auto;
  max-height: 72vh;
  display: block;
}

/* ---- Partes interactivas del SVG ---- */
.visor svg .parte {
  cursor: pointer;
  transition: fill 0.12s, opacity 0.12s, stroke 0.12s;
}
.visor svg .parte:hover,
.visor svg .parte.resaltada {
  fill: var(--resalte) !important;
  stroke: var(--resalte) !important;
  opacity: 1 !important;
}
.visor svg .parte.seleccionada {
  fill: var(--seleccion) !important;
  stroke: var(--seleccion) !important;
  opacity: 1 !important;
}
/* las líneas (nervios) sólo tienen trazo: resaltamos su grosor */
.visor svg .parte.linea:hover,
.visor svg .parte.linea.seleccionada {
  stroke-width: 6 !important;
}
/* elementos decorativos no interactivos */
.visor svg .base { pointer-events: none; }

/* ---- Panel de detalle ---- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 1.4rem;
  overflow-y: auto;
  max-height: 82vh;
}
.panel-vacio {
  color: var(--texto-tenue);
  text-align: center;
  margin-top: 2rem;
  font-size: 0.95rem;
  line-height: 1.5;
}
.panel-vacio-icono { font-size: 2.4rem; margin-bottom: 0.6rem; }

.badge {
  display: inline-block;
  background: var(--acento-fuerte);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}
.panel-detalle h2 {
  margin: 0.6rem 0 0.5rem;
  font-size: 1.45rem;
}
.descripcion {
  color: var(--texto);
  line-height: 1.55;
  margin: 0 0 1rem;
}
.bloque { margin-top: 1rem; }
.bloque h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--acento);
  margin: 0 0 0.4rem;
  border-bottom: 1px solid var(--borde);
  padding-bottom: 0.3rem;
}
.bloque ul {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.5;
}
.bloque li { margin-bottom: 0.3rem; }

.oculto { display: none !important; }

/* ---- Tooltip ---- */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: #000000d9;
  color: #fff;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 100;
  transform: translate(-50%, calc(-100% - 12px));
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #000000d9;
}

/* ---- Pie ---- */
.pie {
  text-align: center;
  color: var(--texto-tenue);
  font-size: 0.8rem;
  padding: 0.8rem 1rem 1.4rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .escenario {
    grid-template-columns: 1fr;
  }
  .panel { max-height: none; }
  .visor { min-height: 50vh; }
  .visor svg { max-height: 60vh; }
}
