/* ===== RESET ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #ffffff;
  color: #3a2f4a;
  line-height: 1.6;
  font-size: 16px;
}

/* ===== HEADER MEJORADO ===== */
.header {
  position: relative;
  background: linear-gradient(135deg, #fdf2f8 0%, #f3e8ff 50%, #fdf2f8 100%);
  padding: 4rem 2rem 3rem;
  text-align: center;
  border-bottom: 2px solid #f0d9ee;
  overflow: hidden;
}

.stickers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.sticker {
  position: absolute;
  font-size: 2rem;
  opacity: 0.35;
  filter: drop-shadow(0 4px 10px rgba(190, 150, 210, 0.3));
  animation: float 6s ease-in-out infinite;
}

.s1 { top: 12%; left: 6%;  font-size: 2.6rem; animation-delay: 0s;   }
.s2 { top: 22%; right: 8%; font-size: 2.2rem; animation-delay: 1s;   }
.s3 { bottom: 18%; left: 10%; font-size: 2.4rem; animation-delay: 2s; }
.s4 { bottom: 12%; right: 12%; font-size: 2.3rem; animation-delay: 3s; }
.s5 { top: 50%; left: 3%;  font-size: 1.9rem; animation-delay: 1.5s; }
.s6 { top: 55%; right: 4%; font-size: 2rem;   animation-delay: 2.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-12px) rotate(8deg); }
}

.header-content {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid #e8a3c7;
  color: #b06a94;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  box-shadow: 0 2px 10px rgba(232, 163, 199, 0.2);
}

.badge-icon { font-size: 1rem; }

.header-title {
  font-size: 3rem;
  font-weight: 800;
  color: #5a3d75;
  line-height: 1.1;
  letter-spacing: -1.5px;
  margin-bottom: 1rem;
}

.header-title-accent {
  display: block;
  font-size: 1.5rem;
  font-weight: 500;
  color: #b06a94;
  letter-spacing: 0;
  margin-top: 0.5rem;
  font-style: italic;
}

.header-description {
  font-size: 1.05rem;
  color: #7e5a9b;
  max-width: 700px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.header-description strong { color: #6b4a8a; }

.formula-box {
  display: inline-block;
  background: #ffffff;
  padding: 1.5rem 2.5rem;
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(190, 150, 210, 0.22);
  border: 1px solid #f0d9ee;
  margin-bottom: 2rem;
  position: relative;
}

.formula-box::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 20px;
  right: 20px;
  height: 4px;
  background: linear-gradient(90deg, #e8a3c7, #c4a7e7);
  border-radius: 4px;
}

.formula-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.formula-label {
  font-size: 0.75rem;
  color: #a98bc4;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.formula {
  font-size: 2rem;
  font-weight: 800;
  color: #b06a94;
  letter-spacing: 1px;
}

.formula-sub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed #f0d9ee;
  font-size: 0.85rem;
  color: #a98bc4;
}

.formula-eq {
  font-family: 'Cambria Math', Georgia, serif;
  font-style: italic;
  color: #7e5a9b;
  font-size: 1rem;
}

.header-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8rem;
  max-width: 700px;
  margin: 0 auto 2rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #f0d9ee;
  border-radius: 12px;
  padding: 0.7rem 0.5rem;
  backdrop-filter: blur(4px);
  transition: transform 0.2s, background 0.2s;
}

.meta-item:hover {
  transform: translateY(-2px);
  background: #ffffff;
}

.meta-icon { font-size: 1.2rem; }

.meta-label {
  font-size: 0.7rem;
  color: #a98bc4;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.meta-value {
  font-size: 0.95rem;
  color: #6b4a8a;
  font-weight: 700;
}

.header-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed #d4b8e8;
  border-radius: 14px;
  padding: 1rem 1.5rem;
  max-width: 800px;
  margin: 0 auto;
}

.nav-title {
  font-size: 0.8rem;
  color: #a98bc4;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.nav-links a {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  background: #ffffff;
  border: 1px solid #f0d9ee;
  border-radius: 999px;
  color: #7e5a9b;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s;
}

.nav-links a:hover {
  background: #fdf2f8;
  border-color: #e8a3c7;
  color: #b06a94;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(232, 163, 199, 0.25);
}

@media (max-width: 640px) {
  .header { padding: 2.5rem 1rem 2rem; }
  .header-title { font-size: 1.8rem; letter-spacing: -0.5px; }
  .header-title-accent { font-size: 1rem; }
  .header-description { font-size: 0.95rem; }
  .formula { font-size: 1.5rem; }
  .formula-box { padding: 1rem 1.5rem; }
  .sticker { font-size: 1.4rem; opacity: 0.25; }
  .nav-links a { font-size: 0.75rem; padding: 0.3rem 0.7rem; }
}

/* ===== KPIs ===== */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.kpi-card {
  background: #fdf8ff;
  border: 1px solid #f0d9ee;
  border-radius: 12px;
  padding: 1.2rem;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(190, 150, 210, 0.18);
}

.kpi-ok { background: #f0fdf4; border-color: #bbf7d0; }
.kpi-bad { background: #fef2f2; border-color: #fecaca; }

.kpi-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: #6b4a8a;
}

.kpi-ok .kpi-value { color: #16a34a; }
.kpi-bad .kpi-value { color: #dc2626; }

.kpi-label {
  display: block;
  font-size: 0.85rem;
  color: #9b7bb8;
  margin-top: 0.3rem;
}

/* ===== SECCIONES ===== */
.section {
  max-width: 1200px;
  margin: 2.5rem auto;
  padding: 0 2rem;
}

.section h2 {
  font-size: 1.35rem;
  color: #6b4a8a;
  margin-bottom: 1.2rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid #f3e8ff;
}

/* ===== TABLAS ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #f0d9ee;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead { background: #fdf2f8; }

th {
  padding: 0.9rem 1rem;
  text-align: left;
  color: #6b4a8a;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 0.8rem 1rem;
  border-top: 1px solid #f7eef9;
  color: #4a3a5a;
}

tbody tr:hover { background: #fdf8ff; }

.badge { font-size: 1.1rem; }

/* ===== DATOS ORIGINALES ===== */
.datos-originales {
  margin-top: 1.5rem;
  background: #fdf8ff;
  border: 1px dashed #d4b8e8;
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
}

.datos-originales h3 {
  color: #6b4a8a;
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.datos-originales p {
  color: #7e5a9b;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.datos-originales ul { list-style: none; padding-left: 0; }

.datos-originales li { padding: 0.35rem 0; font-size: 0.92rem; }

.datos-originales a {
  color: #b06a94;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid #f0d9ee;
  transition: color 0.2s;
}

.datos-originales a:hover {
  color: #6b4a8a;
  border-bottom-color: #b06a94;
}

/* ===== GRÁFICOS ===== */
.chart-container {
  background: #ffffff;
  border: 1px solid #f0d9ee;
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
  height: 360px;
}

/* ===== DIAGRAMA ===== */
.diagrama {
  background: #ffffff;
  border: 1px solid #f0d9ee;
  border-radius: 12px;
  padding: 1rem;
}

/* ===== VIDEOS ===== */
.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.2rem;
}

.video-card {
  background: #fdf8ff;
  border: 1px solid #f0d9ee;
  border-radius: 12px;
  padding: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.video-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(190, 150, 210, 0.18);
}

.video-card h4 {
  color: #6b4a8a;
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.video-frame {
  background: #f3e8ff;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-info {
  font-size: 0.82rem;
  color: #9b7bb8;
  margin-top: 0.6rem;
  text-align: center;
}

/* ===== NOTA CRÍTICA ===== */
.nota-critica {
  background: #fef6fb;
  border-left: 4px solid #e8a3c7;
  border-radius: 0 12px 12px 0;
  padding: 1.5rem 2rem;
}

.nota-critica h2 {
  border-bottom: none;
  margin-bottom: 0.8rem;
}

.nota-critica p {
  margin-bottom: 0.8rem;
  color: #5a4a6a;
  font-size: 0.95rem;
}

.nota-critica strong { color: #6b4a8a; }

/* ===== CONCLUSIÓN ===== */
.conclusion {
  background: #fdf2f8;
  border-radius: 12px;
  padding: 1.5rem 2rem;
}

.conclusion h2 { border-bottom: none; }

.conclusion p {
  color: #5a4a6a;
  font-size: 0.97rem;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 2rem;
  color: #b8a3c4;
  font-size: 0.85rem;
  border-top: 1px solid #f7eef9;
  margin-top: 3rem;
}

@media (max-width: 640px) {
  .header h1 { font-size: 1.5rem; }
  .section { padding: 0 1rem; }
  .kpis { padding: 0 1rem; }
  th, td { padding: 0.6rem 0.7rem; font-size: 0.85rem; }
}

/* ===== SECCIÓN DE VIDEO CARGAS ===== */
.section-desc {
  color: #9b7bb8;
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
}

.video-destacado {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  background: #fdf8ff;
  border: 1px solid #f0d9ee;
  border-radius: 14px;
  padding: 1.2rem;
  align-items: center;
}

.video-frame-grande {
  border-radius: 10px;
  overflow: hidden;
  background: #f3e8ff;
  aspect-ratio: 16 / 9;
}

.video-frame-grande video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-destacado-info h3 {
  color: #6b4a8a;
  font-size: 1.1rem;
  margin-bottom: 0.6rem;
}

.video-destacado-info p {
  color: #7e5a9b;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0.8rem;
}

.video-destacado-info ul { list-style: none; padding-left: 0; }

.video-destacado-info li {
  font-size: 0.85rem;
  color: #9b7bb8;
  padding: 0.25rem 0;
  border-bottom: 1px dashed #f0d9ee;
}

.video-destacado-info li strong { color: #6b4a8a; }

@media (max-width: 768px) {
  .video-destacado { grid-template-columns: 1fr; }
}

/* ===== ÍNDICE LATERAL (SCROLL SPY) ===== */
.indice-lateral {
  position: fixed;
  top: 100px;
  left: 20px;
  width: 200px;
  background: #ffffff;
  border: 1px solid #f0d9ee;
  border-radius: 14px;
  padding: 1rem 0.8rem;
  box-shadow: 0 4px 20px rgba(190, 150, 210, 0.15);
  z-index: 90;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  transition: transform 0.3s, opacity 0.3s;
}

.indice-titulo {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #a98bc4;
  font-weight: 700;
  padding: 0 0.6rem 0.6rem;
  border-bottom: 1px solid #f7eef9;
  margin-bottom: 0.6rem;
}

.indice-lista {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.indice-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  color: #9b7bb8;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.25s;
  border-left: 3px solid transparent;
}

.indice-item:hover {
  background: #fdf2f8;
  color: #b06a94;
  border-left-color: #e8a3c7;
}

.indice-item.activo {
  background: linear-gradient(90deg, #fdf2f8 0%, #f3e8ff 100%);
  color: #6b4a8a;
  font-weight: 700;
  border-left-color: #b06a94;
  transform: translateX(3px);
}

.indice-item.activo .indice-icono { transform: scale(1.15); }

.indice-icono {
  font-size: 1rem;
  transition: transform 0.25s;
}

.indice-texto {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body { padding-left: 240px; }

.section { scroll-margin-top: 30px; }

@media (max-width: 1100px) {
  .indice-lateral { display: none; }
  body { padding-left: 0; }
}

.indice-lateral::-webkit-scrollbar { width: 4px; }
.indice-lateral::-webkit-scrollbar-thumb {
  background: #e8a3c7;
  border-radius: 4px;
}

/* ============================================================
   ====== SECCIÓN SEMÁFORO ARDUINO ======
   ============================================================ */
.arduino-panel {
  background: #fdf8ff;
  border: 1px solid #f0d9ee;
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(190, 150, 210, 0.1);
}

.arduino-leds {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

.led-card {
  background: #ffffff;
  border: 1px solid #f0d9ee;
  border-radius: 12px;
  padding: 1.2rem 0.8rem;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.led-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(190, 150, 210, 0.2);
}

.led-card h4 {
  color: #6b4a8a;
  font-size: 0.95rem;
  margin: 0.6rem 0 0.8rem;
  font-weight: 600;
}

.led-card .circulo {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin: 0 auto;
  border: 3px solid #e0d0ec;
  background: #f0e8f5;
  transition: all 0.3s;
}

/* Colores encendidos */
.led-verde    .circulo.encendido { background: #4ade80; box-shadow: 0 0 20px #4ade80; border-color: #22c55e; }
.led-amarillo .circulo.encendido { background: #fde047; box-shadow: 0 0 20px #fde047; border-color: #eab308; }
.led-rojo     .circulo.encendido { background: #f87171; box-shadow: 0 0 20px #f87171; border-color: #dc2626; }

.led-botones {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.led-botones button {
  flex: 1;
  padding: 0.45rem 0.8rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-on { background: #d8f0d8; color: #2d7a2d; }
.btn-on:hover { background: #b8e6b8; transform: translateY(-1px); }

.btn-off { background: #f5d8e8; color: #b04a7a; }
.btn-off:hover { background: #efc0d8; transform: translateY(-1px); }

.arduino-modos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.modo-btn {
  padding: 0.9rem 1rem;
  border: 1px solid #e8a3c7;
  border-radius: 10px;
  background: #ffffff;
  color: #6b4a8a;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
}

.modo-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(190, 150, 210, 0.25);
}

.modo-sema {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: #fbbf24;
  color: #92400e;
}
.modo-sema:hover { background: linear-gradient(135deg, #fde68a, #fcd34d); }

.modo-nav {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
  border-color: #e8a3c7;
  color: #9d174d;
}
.modo-nav:hover { background: linear-gradient(135deg, #fbcfe8, #f9a8d4); }

.modo-manual {
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
  border-color: #c4a7e7;
  color: #6b21a8;
}
.modo-manual:hover { background: linear-gradient(135deg, #e9d5ff, #d8b4fe); }

.modo-off {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border-color: #f87171;
  color: #991b1b;
}
.modo-off:hover { background: linear-gradient(135deg, #fecaca, #fca5a5); }

.arduino-estado {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem;
  background: #ffffff;
  border: 1px dashed #d4b8e8;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #7e5a9b;
  font-weight: 500;
}

.estado-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d0d0d0;
  transition: all 0.3s;
}

.estado-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: pulse-dot 2s infinite;
}

.estado-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@media (max-width: 640px) {
  .arduino-leds { grid-template-columns: 1fr; }
}