:root {
  --bg-main: #0b0813;
  --bg-card: rgba(22, 16, 38, 0.65);
  --bg-sidebar: #07050d;
  --bg-input: rgba(10, 6, 21, 0.8);

  --accent-primary: #ff7a00; /* Naranja Neón */
  --accent-primary-hover: #ff8f1f;
  --accent-primary-glow: rgba(255, 122, 0, 0.25);
  --accent-secondary: #8b5cf6; /* Violeta Eléctrico */
  --accent-success: #10b981;
  --accent-success-glow: rgba(16, 185, 129, 0.15);
  --accent-warning: #f59e0b;
  --accent-warning-glow: rgba(245, 158, 11, 0.15);
  --accent-danger: #ef4444;
  --accent-danger-glow: rgba(239, 68, 68, 0.15);

  --border-color: rgba(168, 85, 247, 0.12);
  --border-glow: rgba(255, 122, 0, 0.08);

  --text-main: #f8fafc;
  --text-dim: #7c8b9e;
  --text-muted: #4f5e74;

  --font-header: "Outfit", sans-serif;
  --font-body: "Outfit", sans-serif;
  --font-mono: "Fira Code", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar global */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 122, 0, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Layout Wrapper Principal */
.dashboard-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(
      circle at 10% 20%,
      rgba(139, 92, 246, 0.06) 0%,
      transparent 40%
    ),
    radial-gradient(
      circle at 80% 80%,
      rgba(255, 122, 0, 0.04) 0%,
      transparent 45%
    );
  background-attachment: fixed;
  padding-left: 250px;
}

/* SIDEBAR LATERAL PREMIUM */
.sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  flex-shrink: 0;
  z-index: 100;
  transition: all 0.3s ease;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  margin-bottom: 2rem;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-text {
  font-family: var(--font-header);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.logo-text span {
  color: var(--accent-primary);
  font-weight: 300;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.menu-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
  padding-left: 0.75rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.menu-item:hover,
.menu-item.active {
  color: var(--text-main);
  background: rgba(255, 122, 0, 0.04);
  border-color: rgba(255, 122, 0, 0.12);
  box-shadow: 0 4px 20px rgba(255, 122, 0, 0.03);
}

.menu-item.active {
  border-left: 3px solid var(--accent-primary);
  background: rgba(255, 122, 0, 0.08);
}

.menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.menu-item:hover svg {
  transform: scale(1.1);
  color: var(--accent-primary);
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--font-mono);
}

/* ÁREA DE CONTENIDO CENTRAL */
.main-content {
  flex-grow: 1;
  height: 100vh;
  padding: 0 2rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  max-width: 100%;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* HEADER SUPERIOR CON PERFIL */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: rgba(7, 5, 13, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 90;
  margin-left: -2rem;
  margin-right: -2rem;
  margin-bottom: 1.5rem;
}

.header-title-area h2 {
  font-family: var(--font-header);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.header-title-area p {
  font-size: 0.62rem;
  color: var(--accent-primary);
  font-family: var(--font-mono);
  letter-spacing: 2px;
  margin-top: 0.1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.action-icon-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  color: var(--text-dim);
}

.action-icon-btn:hover {
  background: rgba(255, 122, 0, 0.05);
  border-color: rgba(255, 122, 0, 0.2);
  color: var(--accent-primary);
}

.action-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-primary);
  color: #000;
  font-size: 0.6rem;
  font-weight: 800;
  min-width: 15px;
  height: 15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  box-shadow: 0 0 10px var(--accent-primary-glow);
}

/* Switch de Tema */
.theme-toggle-wrap {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 3px;
  border-radius: 20px;
}

/* PERFIL DE USUARIO */
.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 1rem;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.avatar-wrapper {
  position: relative;
}

.avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-primary);
  box-shadow: 0 0 12px rgba(255, 122, 0, 0.2);
}

.avatar-status-dot {
  width: 10px;
  height: 10px;
  background: var(--accent-success);
  border: 2px solid var(--bg-main);
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  right: 0;
  box-shadow: 0 0 6px var(--accent-success);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-main);
}

.user-role {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* GRID DE MÉTRICAS (4 columnas + Gráficos SVG Sparkline) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.metric-card-premium {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card-premium::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--border-color),
    transparent
  );
}

.metric-card-premium:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 122, 0, 0.25);
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.4),
    0 0 25px var(--border-glow);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.metric-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.metric-icon-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 122, 0, 0.05);
  border: 1px solid rgba(255, 122, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

.metric-card-premium:nth-child(2) .metric-icon-badge {
  background: rgba(139, 92, 246, 0.05);
  border-color: rgba(139, 92, 246, 0.15);
  color: var(--accent-secondary);
}

.metric-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-header);
  letter-spacing: -0.5px;
}

.metric-growth {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-success);
  display: flex;
  align-items: center;
  gap: 2px;
}

.metric-growth.down {
  color: var(--accent-danger);
}

/* Gráficos Sparkline SVG */
.sparkline-container {
  width: 100%;
  height: 70px;
  margin-top: auto;
}

.sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* GRID PRINCIPAL INFERIOR */
.bottom-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 1.5rem;
}

.dashboard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.panel-title {
  font-family: var(--font-header);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--accent-primary);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-primary-glow);
}

.dashboard-panel.secondary .panel-title::before {
  background: var(--accent-secondary);
}

/* TABLAS DE ALTA DENSIDAD */
.compact-table-wrapper {
  overflow-x: auto;
  flex-grow: 1;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
}

.compact-table th {
  text-align: left;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 800;
}

.compact-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  vertical-align: middle;
}

.compact-table tr:hover td {
  background: rgba(255, 122, 0, 0.01);
}

/* Celdas Complejas */
.table-module-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.table-module-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-main);
}

.table-module-sub {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.table-session-id {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--accent-primary);
  font-weight: 700;
}

.table-session-meta {
  font-size: 0.65rem;
  color: var(--text-dim);
}

/* Badges y Chips de Estado */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-chip.success {
  background: rgba(16, 185, 129, 0.08);
  color: var(--accent-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.03);
}

.status-chip.pending {
  background: rgba(245, 158, 11, 0.08);
  color: var(--accent-warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-chip.danger {
  background: rgba(239, 68, 68, 0.08);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-indicator-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* Interruptor (Switch) Premium */
.switch-wrapper {
  display: flex;
  justify-content: flex-end;
}

.switch-premium {
  width: 38px;
  height: 18px;
  background: #1e1b29;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 2px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
}

.switch-premium:hover {
  border-color: rgba(255, 122, 0, 0.2);
}

.switch-premium.active {
  background: var(--accent-primary);
  border-color: rgba(255, 122, 0, 0.4);
  box-shadow: 0 0 12px var(--accent-primary-glow);
}

.switch-knob {
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.switch-premium.active .switch-knob {
  transform: translateX(20px);
}

/* TERMINAL DE LOGS PREMIUM (Kernel Log) */
.terminal-premium {
  background: #06040a;
  border: 1px solid rgba(168, 85, 247, 0.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  height: 380px;
  overflow: hidden;
}

.terminal-header {
  background: #0d0a14;
  border-bottom: 1px solid rgba(168, 85, 247, 0.08);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.terminal-buttons {
  display: flex;
  gap: 5px;
}

.term-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
}
.term-dot.yellow {
  background: #f59e0b;
}
.term-dot.green {
  background: #10b981;
}

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent-primary);
  font-weight: 700;
  letter-spacing: 1px;
}

.terminal-body {
  padding: 0.75rem 1rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  line-height: 1.45;
  flex-grow: 1;
}

.terminal-line {
  margin-bottom: 0.25rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.term-time {
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}

.term-msg {
  color: #b4c6d8;
  word-break: break-all;
}

.term-msg.important {
  color: var(--accent-primary);
  text-shadow: 0 0 8px rgba(255, 122, 0, 0.35);
}

.term-msg.system {
  color: var(--accent-secondary);
}

.term-msg.ocr {
  color: #10b981;
}

/* BOTONES PREMIUM CON GLOW */
.btn-premium-glow {
  background: linear-gradient(135deg, var(--accent-primary), #ff8f1f);
  border: none;
  color: #000;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(255, 122, 0, 0.2);
}

.btn-premium-glow:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 122, 0, 0.4);
}

.btn-premium-glow:active {
  transform: translateY(1px);
}

/* AUDITORÍA DE ENTORNO EN SIDEBAR / MODAL DETALLES */
.audit-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.audit-mini-pill {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
}

.audit-pill-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.audit-pill-val {
  font-size: 0.75rem;
  font-weight: 800;
  margin-top: 2px;
}

/* Flash Alerts */
.flash-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.flash-premium-item {
  background: rgba(15, 10, 28, 0.85);
  border-left: 4px solid var(--accent-primary);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  backdrop-filter: blur(12px);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slide-in-premium 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-in-premium {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* RESPONSIVE LAYOUT */
.sidebar-toggle-checkbox {
  display: none;
}

.sidebar-toggle-btn {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 1400px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1200px) {
  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .dashboard-wrapper {
    padding-left: 0;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    transform: translateX(-100%);
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar-toggle-checkbox:checked ~ .sidebar {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  }

  .sidebar-toggle-checkbox:checked ~ .sidebar-backdrop {
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 150;
    animation: fade-in-backdrop 0.25s ease;
  }

  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    color: var(--text-main);
    flex-shrink: 0;
  }

  .sidebar-toggle-btn svg {
    width: 20px;
    height: 20px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .top-header {
    padding: 0.5rem 1.25rem;
    margin-left: -1rem;
    margin-right: -1rem;
  }

  .main-content {
    padding: 0 1rem 1.5rem 1rem;
  }

  .header-title-area h2 {
    font-size: 0.95rem;
  }

  .header-title-area p {
    font-size: 0.55rem;
    letter-spacing: 1px;
  }

  .header-actions {
    gap: 0.75rem;
  }

  .action-icon-btn {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 600px) {
  .user-info {
    display: none;
  }

  .user-profile-card {
    padding-left: 0.5rem;
    border-left: none;
  }
}

@keyframes fade-in-backdrop {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Selector de ventana de tiempo */
.time-window-selector {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(22, 16, 38, 0.4);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 12px;
  backdrop-filter: blur(12px);
  margin-bottom: 0.5rem;
}

.selector-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.btn-group-premium {
  display: flex;
  background: rgba(7, 5, 13, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 2px;
  border-radius: 8px;
  gap: 2px;
}

.btn-window {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}

.btn-window:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
}

.btn-window.active {
  color: #000;
  background: linear-gradient(135deg, var(--accent-primary), #ff8f1f);
  box-shadow: 0 2px 10px var(--accent-primary-glow);
}

