/* ============================================================
   PANEL IPTV — STUDIO WHITE v4
   Concepto: panel de control premium con tema claro.
   Sidebar oscuro contraste · contenido blanco puro.
   Acento azul índigo · señal roja solo para críticos.
   Tipografía: Space Grotesk · Inter · JetBrains Mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&family=Inter:wght@400;500;600;700&display=swap');

/* ── Custom properties ───────────────────────────────────── */
:root {
  /* Fondos blancos */
  --bg:          #EEF1F8;
  --surface:     #FFFFFF;
  --surface-alt: #F7F8FE;
  --surface-2:   #EDF0F9;
  --surface-3:   #E4E8F4;

  /* Bordes */
  --border:      rgba(79,92,146,0.12);
  --border-2:    rgba(79,92,146,0.20);
  --border-3:    rgba(79,92,146,0.32);

  /* Sombras (muy sutiles — diseño blanco requiere ligereza) */
  --shadow-xs:   0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm:   0 1px 4px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow:      0 4px 16px rgba(15,23,42,0.08), 0 1px 4px rgba(15,23,42,0.04);
  --shadow-lg:   0 12px 40px rgba(15,23,42,0.12), 0 4px 8px rgba(15,23,42,0.06);
  --shadow-blue: 0 4px 20px rgba(37,99,235,0.14), 0 1px 4px rgba(37,99,235,0.08);

  /* Texto */
  --text:        #0F172A;
  --text-2:      #475569;
  --muted:       #94A3B8;

  /* Acento principal: azul índigo (UI interactivo — formularios, tablas) */
  --blue:        #2563EB;
  --blue-dark:   #1D4ED8;
  --blue-light:  #3B82F6;
  --blue-dim:    rgba(37,99,235,0.08);
  --blue-glow:   rgba(37,99,235,0.22);
  --blue-border: rgba(37,99,235,0.25);

  /* ── Colores de MARCA — extraídos del logo (rojo "amix") ── */
  --brand:        #E53935;   /* rojo principal del logo */
  --brand-dark:   #B71C1C;   /* variante oscura */
  --brand-light:  #EF5350;   /* variante clara / hover */
  --brand-vivid:  #FF5252;   /* acento brillante */
  --brand-dim:    rgba(229,57,53,0.10);
  --brand-glow:   rgba(229,57,53,0.30);
  --brand-border: rgba(229,57,53,0.32);

  /* Señal / crítico: rojo (mantiene mismo valor que brand para consistencia) */
  --red:         #E53935;
  --red-dark:    #B71C1C;
  --red-dim:     rgba(229,57,53,0.08);
  --red-border:  rgba(229,57,53,0.25);

  /* Semánticos */
  --green:       #16A34A;
  --green-dim:   rgba(22,163,74,0.10);
  --green-border:rgba(22,163,74,0.25);
  --amber:       #D97706;
  --amber-dim:   rgba(217,119,6,0.10);
  --danger:      #DC2626;
  --danger-dim:  rgba(220,38,38,0.08);

  /* Sidebar — Diseño 4 "White Carbon" (fondo blanco, acento rojo marca) */
  --sb-bg:            #FFFFFF;
  --sb-surface:       rgba(229,57,53,0.05);
  --sb-border:        rgba(229,57,53,0.12);
  --sb-text:          #1A1D23;          /* texto oscuro sobre fondo blanco */
  --sb-muted:         rgba(26,29,35,0.38);
  --sb-hover:         rgba(229,57,53,0.07);
  --sb-active:        var(--brand);     /* píldora roja sólida */
  --sb-active-text:   #FFFFFF;
  --sb-active-border: transparent;

  /* Tipografías */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Radio */
  --r-xs: 4px;
  --r-sm: 8px;
  --r:    11px;
  --r-lg: 14px;
  --r-xl: 20px;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }

/* Scrollbar sutil */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

/* Textura de fondo muy sutil */
body {
  background-image:
    radial-gradient(ellipse 900px 500px at 70% -5%, rgba(37,99,235,0.04) 0%, transparent 60%),
    radial-gradient(ellipse 500px 400px at 0% 100%, rgba(99,102,241,0.03) 0%, transparent 60%);
}

/* ============================================================
   MARCA / LOGO
   ============================================================ */
.brand-logo         { height: 34px; width: auto; }
/* Diseño 4 White: logo en colores originales sobre fondo blanco */
.brand-logo-sidebar { height: 28px; filter: none; }
.login-brand        { display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.sidebar-brand      { justify-content: flex-start; padding-left: 2px; margin-bottom: 2px; }

/* Indicador LIVE — Diseño 4: badge compacto */
.rec-indicator {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand-vivid);
  background: rgba(229,57,53,0.13);
  border: 1px solid rgba(229,57,53,0.28);
  border-radius: 999px;
  padding: 3px 10px 3px 7px;
  margin: 6px 0 18px 2px;
}
.rec-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand-vivid);
  flex-shrink: 0;
  animation: pulse-rec 2s ease-in-out infinite;
}
.rec-dot.small { width: 5px; height: 5px; }

@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  .rec-dot, .login-bars span { animation: none; }
}

/* ============================================================
   LOGIN  — fondo azul degradado, card blanca
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  /* Gradiente del logo: oscuro → rojo marca → naranja cálido */
  background: linear-gradient(135deg, #0A0D18 0%, #7B1010 45%, #C62020 75%, #E53935 100%);
}

/* Malla de puntos sobre el gradiente */
.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(255,255,255,0.10) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}
.login-screen::after {
  content: '';
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 65%);
  pointer-events: none;
}

/* Barras de señal */
.login-bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 7px;
  opacity: 0.06;
  pointer-events: none;
}
.login-bars span {
  width: 14px;
  background: #fff;
  border-radius: 3px 3px 0 0;
  animation: bar-wave 2.8s ease-in-out infinite;
}
.login-bars span:nth-child(1) { height: 22%; animation-delay: 0.00s; }
.login-bars span:nth-child(2) { height: 48%; animation-delay: 0.18s; }
.login-bars span:nth-child(3) { height: 74%; animation-delay: 0.36s; }
.login-bars span:nth-child(4) { height: 34%; animation-delay: 0.54s; }
.login-bars span:nth-child(5) { height: 61%; animation-delay: 0.72s; }
.login-bars span:nth-child(6) { height: 29%; animation-delay: 0.90s; }
.login-bars span:nth-child(7) { height: 54%; animation-delay: 1.08s; }
.login-bars span:nth-child(8) { height: 19%; animation-delay: 1.26s; }

@keyframes bar-wave {
  0%, 100% { transform: scaleY(0.5); }
  50%       { transform: scaleY(1); }
}

/* Card de login — blanca sobre el fondo azul */
.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.20),
    0 32px 80px rgba(0,0,0,0.35),
    0 8px 20px rgba(0,0,0,0.20);
}

/* Inputs dentro del login card (fondo blanco — usar estilo normal) */
.login-card .field { color: var(--text-2); }
.login-card .field input {
  background: var(--surface-alt);
  border: 1.5px solid var(--border-2);
  color: var(--text);
}
.login-card .field input::placeholder { color: var(--muted); }
.login-card .field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
  background: var(--surface);
}
.login-card .login-sub { color: var(--muted); }
.login-card .error-text { color: var(--red); }

.login-sub {
  margin: 6px 0 28px;
  color: var(--muted);
  font-size: 0.80rem;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}

/* ============================================================
   INPUTS / CAMPOS
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.field input, .field select {
  background: var(--surface-alt);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r);
  padding: 11px 13px;
  color: var(--text);
  font-size: 0.92rem;
  font-family: var(--font-body);
  outline: none;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.field input:focus, .field select:focus {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

.error-text {
  color: var(--red);
  font-size: 0.82rem;
  margin-top: 10px;
  text-align: center;
  font-weight: 600;
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1.5px solid transparent;
  border-radius: var(--r);
  padding: 10px 20px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 13px; font-size: 0.78rem; border-radius: var(--r-sm); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue-dark);
  box-shadow: 0 2px 8px var(--blue-glow);
}
.btn-primary:hover {
  background: var(--blue-dark);
  box-shadow: 0 4px 16px var(--blue-glow);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-2);
  color: var(--text-2);
  box-shadow: var(--shadow-xs);
}
.btn-ghost:hover {
  background: var(--surface-alt);
  border-color: var(--border-3);
  color: var(--text);
}

.btn-danger-outline {
  background: transparent;
  border-color: var(--red-border);
  color: var(--red);
}
.btn-danger-outline:hover {
  background: var(--red-dim);
  border-color: var(--red);
}

/* ── Row action dropdown — Metro Actions style ── */
.row-actions {
  position: relative;
  display: inline-block;
}

/* "Actions ▾" toggle button */
.row-actions__toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: var(--r-sm, 8px);
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  color: var(--muted, #475569);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.row-actions__toggle:hover {
  background: var(--surface-hover, #f1f5f9);
  border-color: var(--muted, #94a3b8);
  color: var(--text, #1e293b);
}
/* Chevron SVG rotates when open */
.row-actions__toggle .ra-chevron {
  display: inline-block;
  width: 12px;
  height: 12px;
  transition: transform 0.18s;
  flex-shrink: 0;
  opacity: 0.7;
}
.row-actions.open .row-actions__toggle .ra-chevron {
  transform: rotate(180deg);
}

/* Dropdown panel */
.row-actions__menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  min-width: 196px;
  z-index: 300;
  overflow: hidden;
  padding: 6px 0;
}
.row-actions.open .row-actions__menu {
  display: block;
}

/* Individual items */
.row-actions__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text, #1e293b);
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.row-actions__item:hover {
  background: var(--surface-hover, #f1f5f9);
}
.row-actions__item.danger {
  color: var(--red, #ef4444);
}
.row-actions__item.danger:hover {
  background: var(--red-dim, #fef2f2);
}

/* Colored icon tile (Metro Cards style) */
.row-actions__icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 1;
}

.row-actions__divider {
  height: 1px;
  background: var(--border, #e2e8f0);
  margin: 4px 0;
}

/* ── Playlist list (full-width rows) ── */
.playlist-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.playlist-card {
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.18s, border-color 0.18s;
}
.playlist-card:hover {
  box-shadow: 0 3px 14px rgba(0,0,0,0.07);
  border-color: var(--brand, #6366f1);
}

/* Avatar */
.plc-avatar {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

/* Name + bouquet */
.plc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  flex-shrink: 0;
}
.plc-info {
  display: flex;
  flex-direction: column;
}
.plc-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text, #1e293b);
  white-space: nowrap;
}
.plc-bouquet {
  font-size: 0.73rem;
  color: var(--muted, #64748b);
  margin-top: 1px;
}

/* Status badge pushed after header */
.plc-header .status-tag {
  flex-shrink: 0;
}

/* Format pill toggle — inline, centred in row */
.plc-format-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.plc-format-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted, #94a3b8);
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}
.plc-fmt-toggle {
  display: flex;
  background: var(--surface-hover, #f1f5f9);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}
.plc-fmt-btn {
  padding: 4px 13px;
  border: none;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--muted, #64748b);
  transition: background 0.15s, color 0.15s;
}
.plc-fmt-btn.active {
  background: var(--surface, #fff);
  color: var(--brand, #6366f1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.plc-fmt-hint {
  font-size: 0.72rem;
  color: var(--muted, #94a3b8);
}

/* Action buttons — right-aligned, fixed width */
.plc-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.plc-actions .btn {
  font-size: 0.8rem;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px; height: 38px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--r);
  background: var(--surface);
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}
.mobile-menu-btn span {
  display: block;
  height: 1.5px;
  width: 16px;
  margin: 0 auto;
  background: var(--text-2);
  border-radius: 2px;
}
.sidebar-backdrop { display: none; }
.topbar { gap: 12px; }

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.dashboard {
  display: flex;           /* flex permite que el sidebar cambie su ancho libremente */
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
}

/* El contenido ocupa el resto */
.content { flex: 1; min-width: 0; }

/* ── SIDEBAR — Diseño 4 "White Carbon" ── */
.sidebar {
  background: var(--sb-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  padding: 20px 12px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  /* sombra suave hacia el contenido */
  box-shadow: 4px 0 24px rgba(0,0,0,0.10), 2px 0 8px rgba(229,57,53,0.06);
  width: 250px;
  transition: width 0.28s cubic-bezier(0.4,0,0.2,1);
  flex-shrink: 0;
}

/* Metro Cards: sin línea de acento en el borde */
.sidebar::before { display: none; }

/* ── BOTÓN TOGGLE (colapsar / expandir) — Diseño 4 White ── */
.sb-toggle {
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%);
  z-index: 20;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(229,57,53,0.22);
  background: #FFFFFF;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.sb-toggle:hover {
  background: var(--brand);
  border-color: var(--brand-dark);
  color: #fff;
  box-shadow: 0 0 10px var(--brand-glow);
}
.sb-toggle-ico {
  display: inline-block;
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  line-height: 1;
  font-size: 0.62rem;
}

/* ── ESTADO COLAPSADO ── */
.sidebar.collapsed {
  width: 64px;
  padding-left: 0;      /* sin padding lateral → contenido perfectamente centrado */
  padding-right: 0;
  align-items: center;  /* centra todo el flex column */
}
.sidebar.collapsed .sb-toggle-ico {
  transform: rotate(180deg);
}
/* Ocultar elementos que solo se muestran en estado abierto */
.sidebar.collapsed .sb-full,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-item.active::before {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
/* Mostrar elementos que solo se muestran colapsado */
.sb-collapsed-logo,
.sb-collapsed-user,
.sb-collapsed-logout { display: none; }
.sidebar.collapsed .sb-collapsed-logo { display: flex; justify-content: center; margin-bottom: 8px; }
.sidebar.collapsed .sb-collapsed-user { display: flex; justify-content: center; font-size: 1rem; }
.sidebar.collapsed .sb-collapsed-logout { display: flex; }

/* Metro Cards — collapsed: el nav ocupa todo el ancho para centrar correctamente */
.sidebar.collapsed .nav {
  width: 100%;
  align-items: center;
}
/* Cada item es un cuadro fijo centrado que solo muestra el tile del ícono */
.sidebar.collapsed .nav-item {
  justify-content: center;
  align-items: center;
  padding: 5px 0;
  width: 52px;
  margin: 0 auto;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0;
}
/* La caja del ícono ya lleva el color — el item solo la contiene */
.sidebar.collapsed .nav-item.active .nav-ico {
  background: var(--ni, #E53935);
  box-shadow: 0 4px 12px var(--ni-sh, rgba(229,57,53,0.4));
  transform: scale(1.06);
}
/* Hover sobre cualquier ítem en colapsado */
.sidebar.collapsed .nav-item:hover .nav-ico {
  background: var(--ni-bg, #EFF6FF);
  box-shadow: 0 2px 8px var(--ni-sh, rgba(37,99,235,0.15));
}
/* Ocultar la barra indicadora derecha en colapsado */
.sidebar.collapsed .nav-item.active::after { display: none; }
/* Caja del ícono en modo colapsado — más grande y bien centrada */
.sidebar.collapsed .nav-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.sidebar.collapsed .nav-ico svg {
  width: 18px;
  height: 18px;
}

/* ── TOOLTIP — aparece al hover sobre item cuando sidebar está colapsado ── */
.sidebar.collapsed .nav-item {
  position: relative;
}
.sidebar.collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: #FFFFFF;
  border: 1.5px solid #e2e8f0;
  color: #1A1D23;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
  box-shadow: var(--shadow);
  z-index: 500;
  letter-spacing: 0.01em;
}
/* Flecha del tooltip */
.sidebar.collapsed .nav-item::before {
  content: '';
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  border: 5px solid transparent;
  border-right-color: #e2e8f0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 499;
}
.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .nav-item:hover::before {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Label del nav (span) — transición suave */
.nav-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.18s ease;
}

/* ── Metro Cards: color tokens por sección ── */
.nav-item[data-nav-color="blue"]   { --ni: #2563EB; --ni-bg: #EFF6FF; --ni-sh: rgba(37,99,235,0.22); }
.nav-item[data-nav-color="purple"] { --ni: #7C3AED; --ni-bg: #F5F3FF; --ni-sh: rgba(124,58,237,0.22); }
.nav-item[data-nav-color="teal"]   { --ni: #059669; --ni-bg: #ECFDF5; --ni-sh: rgba(5,150,105,0.22); }
.nav-item[data-nav-color="amber"]  { --ni: #D97706; --ni-bg: #FFFBEB; --ni-sh: rgba(217,119,6,0.22); }
.nav-item[data-nav-color="pink"]   { --ni: #DB2777; --ni-bg: #FDF2F8; --ni-sh: rgba(219,39,119,0.22); }
.nav-item[data-nav-color="cyan"]   { --ni: #0891B2; --ni-bg: #ECFEFF; --ni-sh: rgba(8,145,178,0.22); }
.nav-item[data-nav-color="red"]    { --ni: #E53935; --ni-bg: #FFF1F0; --ni-sh: rgba(229,57,53,0.22); }
.nav-item[data-nav-color="green"]  { --ni: #16A34A; --ni-bg: #F0FDF4; --ni-sh: rgba(22,163,74,0.22); }
.nav-item[data-nav-color="slate"]  { --ni: #475569; --ni-bg: #F1F5F9; --ni-sh: rgba(71,85,105,0.22); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

/* ── Metro Cards nav items ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: #64748b;
  padding: 5px 8px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s, box-shadow 0.14s, color 0.14s;
  position: relative;
  overflow: visible;
}
.nav-item:hover {
  background: rgba(0,0,0,0.035);
  color: #374151;
}
/* Activo: fondo de color suave + borde outline sutil */
.nav-item.active {
  background: var(--ni-bg, #FFF1F0);
  color: var(--ni, #E53935);
  font-weight: 700;
  box-shadow: 0 2px 8px var(--ni-sh, rgba(229,57,53,0.22));
  outline: 1.5px solid transparent;
}
/* Barra indicadora derecha en activo */
.nav-item.active::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 99px;
  background: var(--ni, #E53935);
  opacity: 0.85;
  pointer-events: none;
}
.nav-item.active::before { display: none; }

/* ── Caja del ícono (tile) ── */
.nav-ico {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--ni-bg, #F1F5F9);
  transition: background 0.14s, box-shadow 0.14s;
}
.nav-item.active .nav-ico {
  background: var(--ni, #E53935);
  box-shadow: 0 3px 10px var(--ni-sh, rgba(229,57,53,0.4));
}
.nav-ico svg {
  width: 15px;
  height: 15px;
  stroke: var(--ni, #475569);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  transition: stroke 0.14s;
}
.nav-item:hover .nav-ico svg { transform: none; }
.nav-item.active .nav-ico svg {
  stroke: #fff;
  filter: none;
}

.nav-section {
  font-size: 0.60rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sb-muted);
  padding: 16px 12px 4px;
  opacity: 0.40;
}

/* Diseño 4 White: separador pie — línea roja sutil sobre fondo blanco */
.sidebar-footer {
  position: relative;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  align-items: stretch;
}
.sidebar-footer::before {
  content: '';
  position: absolute;
  top: 0; left: 8px; right: 8px;
  height: 1px;
  background: #e2e8f0;
  box-shadow: none;
}
.whoami {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.80rem;
  font-family: var(--font-mono);
  color: var(--sb-text);
  padding: 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: 0.04em;
}
/* Diseño 4: role-pill sólida roja pequeña */
.role-pill {
  background: var(--brand);
  border: none;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.58rem;
  font-weight: 800;
  color: #FFFFFF;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  flex-shrink: 0;
}
.role-pill.role-user {
  background: #64748b;   /* gris neutro para rol "user" */
}

/* ── Modo Solo Lectura ────────────────────────────────────────────────────── */
/* Cuando el usuario tiene rol "user", aplicamos body.view-only para
   ocultar todos los controles de acción (crear, editar, borrar). */
body.view-only .admin-action {
  display: none !important;
}
/* Banner informativo que solo aparece en modo solo lectura */
.readonly-banner {
  display: none;
  align-items: center;
  gap: 8px;
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: #92400e;
  font-weight: 600;
  margin: 0 0 16px;
}
body.view-only .readonly-banner { display: flex; }

.sb-collapsed-user {
  font-size: 1.2rem;
  color: var(--sb-muted);
  padding: 2px 0;
}
.sb-collapsed-logout {
  justify-content: center;
  width: 100%;
  padding: 8px 0;
  font-size: 1rem;
  border-color: rgba(26,29,35,0.12);
  color: var(--sb-muted);
  background: transparent;
  box-shadow: none;
}
.sb-collapsed-logout:hover {
  background: rgba(229,57,53,0.07);
  border-color: var(--brand-border);
  color: var(--brand);
}

/* Diseño 4 White: btn-ghost oscuro sobre blanco */
.sidebar .btn-ghost {
  background: transparent;
  border-color: rgba(26,29,35,0.14);
  color: var(--sb-muted);
  box-shadow: none;
}
.sidebar .btn-ghost:hover {
  background: rgba(229,57,53,0.07);
  border-color: var(--brand-border);
  color: var(--brand);
}

/* ── CONTENIDO PRINCIPAL ── */
.content {
  padding: 30px 38px;
  overflow-y: auto;
  background: transparent;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.topbar-title h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0 0 3px;
  color: var(--text);
  letter-spacing: -0.025em;
}
.topbar-title p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  color: var(--text-2);
  font-size: 0.80rem;
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
}

.view { display: none; }
.view.active { display: block; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.22s, transform 0.2s, border-color 0.22s;
}
.stat-card:hover {
  box-shadow: var(--shadow-blue);
  transform: translateY(-2px);
  border-color: var(--blue-border);
}

/* Borde izquierdo de color */
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  background: linear-gradient(180deg, var(--blue), var(--blue-light));
  border-radius: 0 3px 3px 0;
}

/* Decoración geométrica de fondo */
.stat-card::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 100px; height: 100px;
  background: radial-gradient(circle, var(--blue-dim) 0%, transparent 70%);
  pointer-events: none;
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
}
.stat-sub {
  font-size: 0.74rem;
  color: var(--muted);
  font-family: var(--font-mono);
  margin-top: 1px;
}

.bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 5px;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue-dark), var(--blue-light));
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.bar-fill.warn   { background: linear-gradient(90deg, #B45309, var(--amber)); }
.bar-fill.danger { background: linear-gradient(90deg, var(--red-dark), var(--red)); }

/* ============================================================
   PANEL CARDS
   ============================================================ */
.panel-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.panel-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-2);
}

.panel-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.panel-card-head h2 {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ── Status dots ── */
.fw-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.fw-status-dot.on {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
  animation: pulse-green 2.5s ease-in-out infinite;
}
.fw-status-dot.off {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-dim);
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(22,163,74,0); }
}

.fw-status-text {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ── Filas de puertos del firewall ── */
.fw-port-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 0.84rem;
  transition: background 0.15s, border-color 0.18s, box-shadow 0.18s;
  overflow: hidden;       /* necesario para el panel monitor */
}
.fw-port-row:hover {
  background: var(--surface);
  border-color: var(--blue-border);
  box-shadow: var(--shadow-blue);
}

.fw-port-label { color: var(--text); flex: 1; font-weight: 500; min-width: 80px; }
.fw-port-num {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--blue);
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Panel de monitor (aparece al hover) ── */
.fw-port-monitor {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  flex-shrink: 0;
  transition:
    max-width 0.38s cubic-bezier(0.4,0,0.2,1),
    opacity   0.25s ease;
  white-space: nowrap;
}
.fw-port-row:hover .fw-port-monitor {
  max-width: 190px;
  opacity: 1;
}

.fw-port-bar-wrap {
  width: 70px;
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-2);
}
.fw-port-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-dark), var(--blue-light));
  border-radius: 999px;
  transition: width 0.5s ease;
  min-width: 2px;
}
.fw-port-bar-fill.active-high {
  background: linear-gradient(90deg, var(--green), #4ADE80);
}

.fw-port-conn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.3s;
}
.fw-port-conn.active { color: var(--green); font-weight: 700; }

/* ── Inline forms ── */
.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}
.inline-form.wrap { flex-wrap: wrap; }
.inline-form input, .inline-form select {
  background: var(--surface-alt);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r);
  padding: 10px 13px;
  color: var(--text);
  font-size: 0.87rem;
  outline: none;
  flex: 1;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.inline-form input:focus, .inline-form select:focus {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

.hint-text {
  font-size: 0.81rem;
  color: var(--muted);
  margin: 10px 0 0;
  line-height: 1.5;
}
.hint-text.ok  { color: var(--green); font-weight: 600; }
.hint-text.err { color: var(--red);   font-weight: 600; }

/* Terminal output */
.raw-output {
  background: #0F172A;
  border: 1.5px solid rgba(37,99,235,0.15);
  border-radius: var(--r);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: #93C5FD;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  line-height: 1.65;
}

/* ============================================================
   TABLAS
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table thead { position: sticky; top: 0; z-index: 2; }
.data-table th {
  text-align: left;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 10px 14px;
  border-bottom: 2px solid var(--blue-dim);
  background: var(--surface-alt);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  vertical-align: middle;
  color: var(--text);
}
.data-table tr { transition: background 0.12s; }
.data-table tbody tr:nth-child(even) { background: var(--surface-alt); }
.data-table tbody tr:hover { background: var(--blue-dim); }
.data-table tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); font-style: italic; }

/* Status tags */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-tag.active {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.status-tag.expired {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid var(--red-border);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--blue);
  margin-bottom: 12px;
  opacity: 0.75;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1.5px;
  background: linear-gradient(90deg, var(--blue-dim), transparent);
}
.section-label-spaced { margin-top: 32px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 28px 30px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
/* Franja azul superior */
.modal-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), #818CF8);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-head h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--text);
}
.modal-close {
  background: var(--surface-alt);
  border: 1.5px solid var(--border-2);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  transition: all 0.15s;
  line-height: 1;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-form .field input { width: 100%; }

/* ============================================================
   TÚNEL SSH — componentes visuales
   ============================================================ */

/* Pill de estado del túnel */
.tunnel-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1.5px solid transparent;
  transition: all 0.3s;
}
.tunnel-status-pill.connected {
  background: var(--green-dim);
  border-color: var(--green-border);
  color: var(--green);
}
.tunnel-status-pill.disconnected {
  background: var(--danger-dim);
  border-color: var(--red-border);
  color: var(--danger);
}
.tunnel-latency {
  font-family: var(--font-mono);
  font-size: 0.70rem;
  opacity: 0.80;
  margin-left: 2px;
}

/* Diagrama animado Panel ↔ Astra */
.tunnel-diagram {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 22px;
  margin: 0 0 20px;
  overflow: hidden;
  position: relative;
}
.tunnel-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.tunnel-node-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.tunnel-node-icon.connected {
  background: var(--green-dim);
  border-color: var(--green-border);
  color: var(--green);
  box-shadow: 0 0 12px rgba(22,163,74,0.20);
}
.tunnel-node-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tunnel-node-sub {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
}

/* Línea con paquetes animados */
.tunnel-line {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 60px;
  position: relative;
}
.tunnel-line-track {
  width: 100%;
  height: 3px;
  background: var(--surface-2);
  border-radius: 99px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-2);
}
.tunnel-packet {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 3px;
  border-radius: 99px;
  background: var(--blue);
  opacity: 0;
  box-shadow: 0 0 6px var(--blue-glow);
}
/* Paquetes solo viajan cuando el túnel está conectado */
.tunnel-diagram.active .tunnel-packet:nth-child(1) { animation: pkt-flow 2.4s 0.0s linear infinite; }
.tunnel-diagram.active .tunnel-packet:nth-child(2) { animation: pkt-flow 2.4s 0.8s linear infinite; }
.tunnel-diagram.active .tunnel-packet:nth-child(3) { animation: pkt-flow 2.4s 1.6s linear infinite; }

@keyframes pkt-flow {
  0%   { left: -10px; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { left: calc(100% + 4px); opacity: 0; }
}
.tunnel-line-label {
  font-size: 0.64rem;
  color: var(--muted);
  white-space: nowrap;
  font-family: var(--font-mono);
}

/* Pasos del wizard */
.tunnel-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.tunnel-step:hover { border-color: var(--border-2); }
.tunnel-step-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--muted);
  color: #fff;
  font-size: 0.70rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  transition: background 0.3s;
}
.tunnel-step-badge.done {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}
.tunnel-step-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

/* Grid de configuración */
.tunnel-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}
.tunnel-config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tunnel-config-field input {
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--text);
  outline: none;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.tunnel-config-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

/* Details/Summary estilo panel */
.tunnel-details {
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color 0.18s;
}
.tunnel-details[open] { border-color: var(--border-2); }
.tunnel-details > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: color 0.15s, background 0.15s;
}
.tunnel-details > summary::-webkit-details-marker { display: none; }
.tunnel-details > summary::before {
  content: '▶';
  font-size: 0.55rem;
  transition: transform 0.2s;
  flex-shrink: 0;
  color: var(--muted);
}
.tunnel-details[open] > summary::before { transform: rotate(90deg); }
.tunnel-details > summary:hover { color: var(--text); background: var(--surface-2); }
.tunnel-details > *:not(summary) { padding: 0 14px 14px; }

@media (max-width: 640px) {
  .tunnel-config-grid { grid-template-columns: 1fr; }
  .tunnel-diagram { padding: 14px 14px; }
}

/* ============================================================
   HEALTH BANNER
   ============================================================ */
.health-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 22px;
  box-shadow: var(--shadow-xs);
  transition: all 0.3s;
}
.health-banner.ok     { background: var(--green-dim); border-color: var(--green-border); color: var(--green); }
.health-banner.warn   { background: var(--amber-dim); border-color: rgba(217,119,6,0.25); color: var(--amber); }
.health-banner.danger { background: var(--danger-dim); border-color: var(--red-border); color: var(--red); }

/* ============================================================
   SPARKLINES
   ============================================================ */
.sparkline { width: 100%; height: 22px; display: block; margin: 4px 0; }

/* ============================================================
   WIZARD SRT
   ============================================================ */
.srt-wizard-progress { display: flex; align-items: center; margin: 18px 0 24px; }
.srt-wizard-step-dot { display: flex; align-items: center; gap: 8px; }
.srt-wizard-step-dot .dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.srt-wizard-step-dot .label { font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.srt-wizard-step-dot.active .dot {
  background: var(--blue);
  border-color: var(--blue-dark);
  color: #fff;
  box-shadow: 0 0 0 3px var(--blue-dim);
}
.srt-wizard-step-dot.active .label { color: var(--text); font-weight: 700; }
.srt-wizard-step-dot.done .dot {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}
.srt-wizard-line {
  flex: 1;
  height: 1.5px;
  background: var(--border-2);
  margin: 0 8px;
}
.srt-wizard-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.srt-tabs {
  display: flex;
  background: var(--surface-alt);
  border-radius: var(--r);
  padding: 3px;
  margin: 12px 0 16px;
  gap: 3px;
  border: 1.5px solid var(--border-2);
}
.srt-tab {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: calc(var(--r) - 3px);
  font-size: 0.77rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.srt-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}

.srt-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.srt-full   { width: 100%; margin-bottom: 8px; box-sizing: border-box; }

.srt-preview {
  background: #0F172A;
  color: #6EE7B7;
  border: 1.5px solid rgba(34,211,238,0.15);
  border-radius: var(--r);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  word-break: break-all;
  white-space: pre-wrap;
  margin: 0 0 14px;
  line-height: 1.65;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}
.field-check input { accent-color: var(--blue); width: 15px; height: 15px; }

/* ============================================================
   IPTV APPS GRID (Recommended Players)
   ============================================================ */
.iptv-apps-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.iptv-app-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  transition: box-shadow 0.18s, border-color 0.18s;
}
.iptv-app-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
  border-color: var(--border-2);
}

/* Icon square */
.iac-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.iac-icon svg {
  width: 26px;
  height: 26px;
}

/* Info block */
.iac-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.iac-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
}
.iac-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}
.iac-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.iac-tag {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.tag-android  { background: #DCFCE7; color: #166534; }
.tag-ios      { background: #EFF6FF; color: #1D4ED8; }
.tag-tv       { background: #F5F3FF; color: #6D28D9; }
.tag-free     { background: #F0FDF4; color: #15803D; }
.tag-premium  { background: #FEF9C3; color: #A16207; }

/* Action buttons */
.iac-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  min-width: 110px;
}
.iac-actions .btn {
  text-align: center;
  text-decoration: none;
  display: block;
  white-space: nowrap;
}

/* Mobile: stack vertically */
@media (max-width: 600px) {
  .iptv-app-card {
    flex-wrap: wrap;
    gap: 12px;
  }
  .iac-actions {
    width: 100%;
    flex-direction: row;
    min-width: unset;
  }
  .iac-actions .btn { flex: 1; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1000px) {
  .dashboard { grid-template-columns: 218px 1fr; }
}

/* ── 860 px — tablets y móviles ── */
@media (max-width: 860px) {
  /* Layout */
  .dashboard { display: block; }
  .mobile-menu-btn { display: flex; }

  /* Sidebar: drawer deslizante */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(278px, 85vw);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    height: 100%;
    overflow-y: auto;
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-shadow: 6px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  /* Ocultar botón de colapsar en móvil (no aplica en drawer) */
  .sidebar .sb-toggle { display: none; }
  /* Siempre mostrar etiquetas en el drawer */
  .sidebar .nav-label,
  .sidebar .sb-full   { display: revert !important; }
  .sidebar .sb-collapsed-logo,
  .sidebar .sb-collapsed-user,
  .sidebar .sb-collapsed-logout { display: none !important; }

  /* Backdrop */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.60);
    backdrop-filter: blur(4px);
    z-index: 150;
  }
  .sidebar-backdrop[hidden] { display: none; }

  /* Contenido */
  .content {
    padding: 16px;
    padding-top: max(56px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  /* Topbar */
  .topbar { margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
  .topbar-title h1 { font-size: 1.25rem; }
  .topbar-status { display: none; }

  /* Stats */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 1.7rem; }

  /* Botones táctiles */
  .btn     { min-height: 44px; }
  .btn-sm  { min-height: 38px; font-size: 0.82rem; }
  .btn-xs  { min-height: 34px; }

  /* Forms inline → columna */
  .inline-form { flex-direction: column; align-items: stretch; gap: 8px; }
  .inline-form input,
  .inline-form select,
  .inline-form button { width: 100%; box-sizing: border-box; }
  .inline-form button { margin-left: 0 !important; margin-top: 0; }

  /* SRT grids */
  .srt-grid-2 { grid-template-columns: 1fr; }
  .srt-tabs   { flex-wrap: wrap; }
  .srt-tab    { flex: 1 1 auto; font-size: 0.73rem; }

  /* Tablas: scroll horizontal */
  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.8rem;
  }
  .data-table th,
  .data-table td { white-space: nowrap; padding: 10px 10px; }

  /* Panel cards */
  .panel-card { padding: 14px 16px; }
  .panel-card-head {
    flex-wrap: wrap;
    gap: 8px;
  }
  .panel-card-head h2 { font-size: 0.92rem; }
  .panel-card-head > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .panel-card-head > div .btn { flex: 1 1 auto; }

  /* Tarjetas IPTV Lists — apila verticalmente */
  .playlist-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }
  .plc-header {
    min-width: unset;
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
  }
  .plc-format-row {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
    border-top: 1px solid var(--border, #e2e8f0);
    border-bottom: 1px solid var(--border, #e2e8f0);
  }
  .plc-actions {
    gap: 8px;
    justify-content: stretch;
  }
  .plc-actions .btn { flex: 1; justify-content: center; }

  /* Row Actions dropdown — alinear a la derecha del viewport si está al borde */
  .row-actions { position: relative; }
  .row-actions__menu {
    right: 0;
    left: auto;
    min-width: 170px;
  }

  /* Modales — casi pantalla completa */
  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: 88vh;
    overflow-y: auto;
  }

  /* Login */
  .login-card { padding: 32px 22px; max-width: 360px; }

  /* Firewall monitor siempre visible */
  .fw-port-monitor { max-width: 180px !important; opacity: 1 !important; }

  /* Backup cards en columna */
  .backup-row { flex-direction: column; gap: 10px; }
  .backup-row .btn { width: 100%; }

  /* Wizard SRT navigation */
  #srt-wizard-card .inline-form { flex-direction: row; flex-wrap: wrap; }
  #srt-wizard-card .inline-form .btn { flex: 1 1 auto; }
}

/* ── 600 px — móviles medianos ── */
@media (max-width: 600px) {
  .topbar-title h1 { font-size: 1.1rem; }
  .topbar-title p  { font-size: 0.75rem; }

  /* Stat grid: 2 col → 2 col pequeño */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 14px 14px; }
  .stat-value { font-size: 1.5rem; }

  /* Panel card head: botones en fila completa */
  .panel-card-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .panel-card-head h2 { font-size: 0.88rem; }
  .panel-card-head > div { width: 100%; }

  /* Tarjeta playlist más compacta */
  .plc-avatar { width: 32px; height: 32px; font-size: 0.75rem; border-radius: 7px; }
  .plc-name   { font-size: 0.82rem; }
  .plc-fmt-btn { padding: 4px 10px; font-size: 0.72rem; }

  /* Clients table: ocultar columna Created en mobile */
  .data-table .col-created { display: none; }
}

/* ── 420 px — móviles pequeños ── */
@media (max-width: 420px) {
  .content { padding: 10px; padding-top: max(50px, env(safe-area-inset-top)); }
  .login-card { padding: 24px 16px; }
  .stat-grid  { grid-template-columns: 1fr 1fr; gap: 7px; }
  .stat-value { font-size: 1.35rem; }
  .stat-label { font-size: 0.62rem; }
  .panel-card { padding: 12px 14px; }
  .modal-box  { border-radius: 14px 14px 0 0; padding: 18px 16px; }

  /* Topbar muy compacto */
  .topbar-title h1 { font-size: 1rem; }

  /* Playlists: acciones en columna */
  .plc-actions { flex-direction: column; }
  .plc-actions .btn { width: 100%; }

  /* Tabla: texto aún más pequeño */
  .data-table { font-size: 0.74rem; }
  .data-table th, .data-table td { padding: 8px 8px; }
}

/* ══════════════════════════════════════════════════════════════════
   Monitoreo — diseño Neon Gauge White
   ══════════════════════════════════════════════════════════════════ */
.mon-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
}
.mon-section-line {
  width: 18px;
  height: 2px;
  border-radius: 1px;
  flex-shrink: 0;
}
.mon-section-title {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  white-space: nowrap;
}
.mon-section-rule {
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

/* ── Grids ── */
.mon-grid-panel {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  align-items: start;
}
.mon-grid-astra {
  display: grid;
  grid-template-columns: auto auto 1fr 1fr;
  gap: 10px;
  align-items: start;
}
.mon-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* ── Gauge card ── */
.mon-gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 12px 10px;
  box-shadow: 0 1px 4px rgba(15,23,42,0.06);
}

/* ── SVG gauge rings ── */
.gauge-track {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 6;
  stroke-dasharray: 141.37 188.50;
  stroke-linecap: round;
  transform-origin: 40px 40px;
  transform: rotate(135deg);
}
.gauge-fill {
  fill: none;
  stroke-width: 6;
  stroke-dasharray: 141.37 188.50;
  stroke-dashoffset: 141.37;
  stroke-linecap: round;
  transform-origin: 40px 40px;
  transform: rotate(135deg);
  transition: stroke-dashoffset 0.55s ease, stroke 0.3s ease;
}
.gauge-val {
  font-size: 12px;
  font-weight: 800;
  fill: #0f172a;
  text-anchor: middle;
  font-family: Inter, system-ui, sans-serif;
}
.gauge-lbl {
  font-size: 9px;
  fill: #94a3b8;
  text-anchor: middle;
  font-family: Inter, system-ui, sans-serif;
}

/* ── Num card ── */
.mon-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--mon-accent, #2563eb);
  border-radius: 10px;
  padding: 14px 16px 10px;
  box-shadow: 0 1px 4px rgba(15,23,42,0.06);
  display: flex;
  flex-direction: column;
}
.mon-label {
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.mon-value-row {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-bottom: 4px;
}
.mon-value {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}
.mon-value-sm {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #0f172a;
  margin-bottom: 4px;
}
.mon-unit {
  font-size: 11px;
  color: #94a3b8;
}
.mon-sub {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
}
.mon-sparkline {
  width: 100%;
  height: 32px;
  display: block;
  margin: 6px 0 4px;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .mon-grid-panel { grid-template-columns: repeat(3, 1fr); }
  .mon-grid-astra { grid-template-columns: auto auto 1fr; }
}
@media (max-width: 700px) {
  .mon-grid-panel { grid-template-columns: repeat(2, 1fr); }
  .mon-grid-astra { grid-template-columns: 1fr 1fr; }
  .mon-grid-3     { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .mon-grid-panel { grid-template-columns: 1fr 1fr; }
  .mon-grid-3     { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════
   Monitoreo — Estilo Minimal Flat
   ══════════════════════════════════════════════════════════════════ */
.mf-block {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.07);
  margin-bottom: 16px;
  overflow: hidden;
}
.mf-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 11px;
  border-top: 2px solid #e2e8f0;
  border-bottom: 1px solid #f1f5f9;
}
.mf-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mf-block-title {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  flex: 1;
}

/* Rows (CPU, RAM, Disco) */
.mf-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 13px 20px;
  border-bottom: 1px solid #f1f5f9;
  gap: 16px;
}
.mf-row > .mf-label {
  padding-top: 3px;
  flex-shrink: 0;
  width: 120px;
}
.mf-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* 3-col grid (Red, TCP, Astra, Cache, Speedtest) */
.mf-col-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid #f1f5f9;
}
.mf-col {
  padding: 13px 20px 13px;
  border-right: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
}
.mf-col:last-child { border-right: none; }

/* Typography */
.mf-label {
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.mf-val-row {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-bottom: 2px;
}
.mf-value {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.mf-value-sm {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #0f172a;
  margin-bottom: 3px;
}
.mf-unit {
  font-size: 11px;
  color: #94a3b8;
}
.mf-sub {
  font-size: 10px;
  color: #cbd5e1;
  margin-top: 1px;
}

/* Pill bar */
.mf-pill {
  width: 100%;
  height: 3px;
  background: #f1f5f9;
  border-radius: 99px;
  margin-top: 8px;
  overflow: hidden;
}
.mf-pill-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  transition: width 0.55s ease;
}

/* Sparkline */
.mf-spark {
  width: 100%;
  height: 28px;
  display: block;
  margin: 6px 0 3px;
}

/* Responsive */
@media (max-width: 700px) {
  .mf-col-grid { grid-template-columns: 1fr 1fr; }
  .mf-col:nth-child(2) { border-right: none; }
  .mf-col:nth-child(3) { border-top: 1px solid #f1f5f9; grid-column: span 2; }
}
@media (max-width: 420px) {
  .mf-col-grid { grid-template-columns: 1fr; }
  .mf-col { border-right: none; border-top: 1px solid #f1f5f9; }
  .mf-col:nth-child(3) { grid-column: auto; }
  .mf-row { flex-direction: column; }
  .mf-right { align-items: flex-start; width: 100%; }
}
