:root {
  --bg-color: #050505;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.1);
  --accent-purple: #9d00ff;
  --accent-green: #00ff88;
  --accent-red: #ff3e3e;
  --text-main: #ffffff;
  --text-dim: #a0a0a0;
  --neon-glow: 0 0 20px rgba(157, 0, 255, 0.3);
  --input-bg: rgba(255, 255, 255, 0.05);
  /* Fondo Dark */
  --input-text: #fff;
}

[data-theme="light"] {
  --bg-color: #f5f5f5;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(0, 0, 0, 0.1);
  --text-main: #1a1a1a;
  --text-dim: #666666;
  --input-bg: rgba(0, 0, 0, 0.05);
  /* Fondo Light (oscuro leve para contraste) */
  --input-text: #1a1a1a;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  transition: background-color 0.3s ease;
}

/* Sidebar / Intelligence Panel */
.sidebar {
  width: 280px;
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* Ensure items stack from top */
  padding: 10px;
  /* overflow-y: auto; REMOVED to allow fixed footer */
  overflow: clip;
  /* New: Scroll happens in inner container */
  transition: transform 0.3s ease;
  z-index: 1000;
  height: 100vh;
  /* Default height for desktop */
}

/* Make internal list scrollable and take all remaining space */
.sidebar-scroll-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 5px;
  margin-bottom: 10px;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(157, 0, 255, 0.5));
}

.logo-text {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #9d00ff 0%, #ff00ff 50%, #00ff88 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 12px rgba(157, 0, 255, 0.3));
}

/* User Status Panel */
.user-status-panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 20px;
}

[data-theme="light"] .user-status-panel {
  background: rgba(0, 0, 0, 0.03);
}

/* Theme Selector */
.theme-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.theme-btn {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.theme-btn.active {
  background: var(--accent-purple);
  color: white;
  border-color: var(--accent-purple);
}

/* Light mode: sidebar needs a light background */
[data-theme="light"] .sidebar {
  background: rgba(245, 245, 245, 0.97);
}

/* Light mode: sidebar headers */
[data-theme="light"] .sidebar-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Light mode: indicator checkbox hover */
[data-theme="light"] .indicator-checkbox:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}

/* Light mode: theme button active state — keep white text on purple */
[data-theme="light"] .theme-btn.active {
  color: white;
}

/* Light mode: text in sidebar */
[data-theme="light"] .indicator-name {
  color: #1a1a1a;
}

/* Light mode: active tab buttons (admin modal, market explorer) */
[data-theme="light"] .tab-btn.active {
  color: white;
}

/* Light mode: auth-btn purple should keep white text */
[data-theme="light"] .auth-btn.primary,
[data-theme="light"] #update-chart-btn {
  color: white;
}

/* Light mode: run-script-btn and similar purple buttons */
[data-theme="light"] button[style*="accent-purple"] {
  color: white;
}


/* Indicator Library */
.indicator-library {
  margin-bottom: 24px;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-main);
}

.indicator-item {
  margin-bottom: 10px;
}

.indicator-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 6px;
  transition: all 0.2s ease;
  background: transparent;
  /* Clean look */
  border: 1px solid transparent;
}

.indicator-checkbox:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.indicator-checkbox input[type="checkbox"] {
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  position: relative;
  transition: all 0.3s ease;
}

.indicator-checkbox input[type="checkbox"]:checked+.checkmark {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
}

.indicator-checkbox input[type="checkbox"]:checked+.checkmark::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.indicator-name {
  font-size: 0.9rem;
  color: var(--text-main);
}

/* --- Collapsible Sidebar Sections --- */
.sidebar-section {
  margin-bottom: 8px;
  border-bottom: 1px solid var(--glass-border);
  border-radius: 0;
  background: transparent;
  /* Removed overflow: hidden to allow full expansion */
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar-header {
  padding: 14px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: transparent;
  transition: background 0.2s;
  border-radius: 6px;
}

.sidebar-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-header h3,
.sidebar-header h4 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  pointer-events: none;
  /* Evita que el click en el texto no dispare el header */
}

.sidebar-chevron {
  font-size: 0.7rem;
  color: var(--text-dim);
  transition: transform 0.3s ease;
}

.sidebar-section.open .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-content {
  padding: 8px 12px 16px 12px;
  display: none;
  /* Oculto por defecto */
  border-top: none;
}

.sidebar-section.open .sidebar-content {
  display: block;
}

.indicator-description {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin: 4px 0 0 28px;
  line-height: 1.3;
}


.custom-script-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

.subsection-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.instruction-list {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.6;
  padding-left: 20px;
  margin: 8px 0;
}

.instruction-list li {
  margin-bottom: 6px;
}

.script-link {
  color: var(--accent-purple);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.script-link:hover {
  color: var(--accent-green);
}

.info-box {
  background: rgba(157, 0, 255, 0.1);
  border: 1px solid rgba(157, 0, 255, 0.3);
  border-radius: 8px;
  padding: 10px;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-main);
  line-height: 1.4;
}


.market-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px;
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: var(--accent-purple);
  background: rgba(157, 0, 255, 0.05);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 4px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  min-width: 0;
  /* CRITICAL: Prevents flex child from overflowing viewport */
  overflow: hidden;
  /* Ensures child elements don't bleed out */
}

.header {
  position: relative;
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 12px 12px 0 0;
  margin-bottom: 10px;
}

.asset-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.asset-name {
  font-weight: 600;
  font-size: 1.1rem;
}

.asset-badge {
  background: var(--accent-green);
  color: #000;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
}

/* --- Estilos de Controles (Glassmorphism) --- */
.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-wrapper label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header input,
.header select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
}

#update-chart-btn {
  background: var(--accent-purple);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 14px;
}

#update-chart-btn:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

/* --- Market Explorer (Estilo MetaTrader) --- */
.market-selector-container {
  position: relative;
  min-width: 250px;
}

.glass-input-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 10px 15px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

[data-theme="light"] .glass-input-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: #1a1a1a;
}

.glass-input-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-purple);
}

[data-theme="light"] .glass-input-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  border-color: var(--accent-purple);
}

.market-explorer-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: 500px;
  background: rgba(10, 10, 10, 0.98);
  color: white;
  /* FIX: Force white text even in Light Mode */
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--accent-purple);
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8), 0 0 15px rgba(157, 0, 255, 0.2);
  z-index: 99999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideIn 0.2s cubic-bezier(0, 0, 0.2, 1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.explorer-header {
  padding: 15px;
  border-bottom: 1px solid var(--glass-border);
}

.explorer-header input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 10px;
  color: white;
  /* FIX: Force white text */
  outline: none;
}

.explorer-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 5px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 6px;
}

.tab-btn.active {
  background: var(--accent-purple);
  color: white;
}

.explorer-content {
  max-height: 350px;
  overflow-y: auto;
  padding: 10px;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.market-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.market-item:hover {
  background: rgba(157, 0, 255, 0.1);
  border-color: var(--accent-purple);
  transform: translateX(3px);
}

.market-item .symbol {
  font-weight: 700;
  font-size: 0.85rem;
}

.market-item .price {
  color: var(--accent-green);
  font-family: 'Inter', monospace;
  font-size: 0.8rem;
}

.market-item.forex .price {
  color: #3e94ff;
}

.market-item.stocks .price {
  color: #ff9d00;
}

.market-item.futures .price {
  color: #00e5ff;
}

.market-item.indices .price {
  color: #ff00ea;
}

/* --- Controles de Cabecera (Refinado) --- */

.control-group {
  display: flex;
  gap: 15px;
  align-items: center;
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-wrapper label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header input,
.header select {
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--input-text);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

/* FIX: Opciones legibles en fondo oscuro (Default Dark) */
.header select option {
  background-color: #1a1a1a;
  color: #ffffff;
  padding: 10px;
}

/* FIX: Opciones legibles en modo claro */
[data-theme="light"] .header select option {
  background-color: #ffffff;
  color: #1a1a1a;
}

#update-chart-btn {
  background: var(--accent-purple);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 14px;
}

#update-chart-btn:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}


.chart-container {
  flex: 1;
  background: #000;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  min-height: 350px;
  display: flex;
  flex-direction: column;
}

#tradingview_widget {
  width: 100%;
  height: 100%;
  flex: 1;
}

.overlay-info {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.badge {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  border: 1px solid var(--glass-border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-green {
  background: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
}

.dot-purple {
  background: var(--accent-purple);
  box-shadow: 0 0 10px var(--accent-purple);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 10px;
}

/* --- Auth Overlay & Login Styles --- */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.auth-card {
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid var(--glass-border);
  padding: 40px;
  border-radius: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

[data-theme="light"] .auth-card {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}

.auth-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  outline: none;
  margin-top: 5px;
}

.auth-btn.primary {
  background: var(--accent-purple);
  color: white;
  box-shadow: 0 0 15px rgba(157, 0, 255, 0.3);
}

.auth-btn.primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.auth-btn.secondary {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-main);
}

.auth-btn.google {
  background: white;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--glass-border);
}

.auth-divider::before {
  margin-right: 10px;
}

.auth-divider::after {
  margin-left: 10px;
}

.status-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  text-align: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* --- Admin Panel Styles (Premium) --- */

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}

.modal-content.glass-panel {
  background: linear-gradient(145deg, rgba(15, 15, 20, 0.98), rgba(8, 8, 12, 0.98));
  border: 1px solid rgba(157, 0, 255, 0.2);
  border-radius: 16px;
  box-shadow:
    0 0 40px rgba(157, 0, 255, 0.15),
    0 20px 60px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 18px 24px;
  background: linear-gradient(135deg, rgba(157, 0, 255, 0.12), rgba(0, 255, 136, 0.05));
  border-bottom: 1px solid rgba(157, 0, 255, 0.15);
}

.modal-header h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #9d00ff, #ff00ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
}

.close-btn:hover {
  background: rgba(255, 62, 62, 0.2);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 6px;
  margin-left: 20px;
}

.admin-tabs .tab-btn {
  flex: none;
  padding: 7px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.25s;
}

.admin-tabs .tab-btn:hover {
  background: rgba(157, 0, 255, 0.1);
  border-color: rgba(157, 0, 255, 0.3);
  color: #fff;
}

.admin-tabs .tab-btn.active {
  background: linear-gradient(135deg, #9d00ff, #7b00cc);
  border-color: transparent;
  color: #fff !important;
  box-shadow: 0 0 14px rgba(157, 0, 255, 0.4);
}

/* Modal Body */
.modal-body {
  padding: 20px 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-body::-webkit-scrollbar {
  width: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(157, 0, 255, 0.3);
  border-radius: 4px;
}

/* Admin Controls */
.admin-controls {
  margin-bottom: 16px;
}

.admin-controls .auth-btn {
  background: rgba(157, 0, 255, 0.15);
  border: 1px solid rgba(157, 0, 255, 0.3);
  color: #c77dff;
  font-size: 0.78rem;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-controls .auth-btn:hover {
  background: rgba(157, 0, 255, 0.25);
  color: #fff;
}

/* User Table */
.user-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
}

.user-table thead tr {
  background: rgba(157, 0, 255, 0.06);
}

.user-table th {
  padding: 10px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(157, 0, 255, 0.12);
  text-align: left;
}

.user-table td {
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--text-main);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.user-table tr:last-child td {
  border-bottom: none;
}

.user-table tbody tr {
  transition: background 0.2s;
  border-radius: 8px;
}

.user-table tbody tr:hover {
  background: rgba(157, 0, 255, 0.06);
}

/* Status Badges */
.status-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
}

.status-pending {
  background: rgba(255, 157, 0, 0.15);
  color: #ffbd2e;
  border: 1px solid rgba(255, 157, 0, 0.3);
}

.status-active {
  background: rgba(0, 255, 136, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(0, 255, 136, 0.25);
}

.status-banned {
  background: rgba(255, 62, 62, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(255, 62, 62, 0.3);
}

/* Admin Panel Sidebar Button */
#admin-panel-btn {
  margin-top: 10px;
  width: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
  padding: 8px 16px;
  font-size: 0.78rem;
  font-weight: bold;
  background: linear-gradient(135deg, rgba(157, 0, 255, 0.2), rgba(157, 0, 255, 0.1));
  border: 1px solid rgba(157, 0, 255, 0.35);
  color: #c77dff;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s;
}

#admin-panel-btn:hover {
  background: linear-gradient(135deg, rgba(157, 0, 255, 0.35), rgba(157, 0, 255, 0.2));
  color: #fff;
  box-shadow: 0 0 16px rgba(157, 0, 255, 0.3);
}

[data-theme="light"] #admin-panel-btn {
  background: rgba(157, 0, 255, 0.08);
  border-color: rgba(157, 0, 255, 0.3);
  color: #7b2fbe;
}

/* Action Buttons (User Row) */
.action-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  transition: all 0.25s;
  margin-right: 4px;
  white-space: nowrap;
}

.action-btn:hover {
  transform: translateY(-1px);
}

.action-btn.approve {
  border-color: rgba(0, 255, 136, 0.25);
  color: var(--accent-green);
}

.action-btn.approve:hover {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--accent-green);
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

.action-btn.block {
  border-color: rgba(255, 62, 62, 0.25);
  color: var(--accent-red);
}

.action-btn.block:hover {
  background: rgba(255, 62, 62, 0.15);
  border-color: var(--accent-red);
  color: #fff;
  box-shadow: 0 0 10px rgba(255, 62, 62, 0.2);
}

.action-btn.promote {
  border-color: rgba(157, 0, 255, 0.25);
  color: #c77dff;
}

.action-btn.promote:hover {
  background: rgba(157, 0, 255, 0.15);
  border-color: var(--accent-purple);
  color: #fff;
  box-shadow: 0 0 10px rgba(157, 0, 255, 0.2);
}

.action-btn.access {
  border-color: rgba(0, 255, 255, 0.2);
  color: var(--accent-cyan, #00e5ff);
}

.action-btn.access:hover {
  background: rgba(0, 255, 255, 0.1);
  border-color: var(--accent-cyan, #00e5ff);
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

/* Q33 Toggle button */
.q33-toggle {
  font-weight: 800 !important;
  font-size: 0.7rem !important;
  width: 58px;
  text-align: center;
  border-radius: 20px !important;
  padding: 4px 0 !important;
  letter-spacing: 0.5px;
}

.q33-toggle.on {
  background: rgba(0, 255, 136, 0.15) !important;
  border-color: var(--accent-green) !important;
  color: var(--accent-green) !important;
}

.q33-toggle.off {
  background: rgba(255, 255, 255, 0.03) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #555 !important;
}


/* --- MOBILE OPTIMIZATION --- */

/* 1. Portrait Lock Overlay */
#mobile-orientation-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 999999;
  color: white;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

/* Only lock orientation AFTER login — body gets .orientation-lock-active from auth.js */
@media screen and (orientation: portrait) and (max-width: 900px) {
  body.orientation-lock-active #mobile-orientation-warning {
    display: flex;
  }
}

/* 2. Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 1.5rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* 3. Sidebar Backdrop (oscurece el fondo al abrir menú) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* 4. Mobile Landscape Adjustments */
@media screen and (max-width: 900px),
screen and (max-height: 500px) {

  /* Hamburger Button */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    top: 7px;
    left: 8px;
    padding: 5px 9px;
    font-size: 1.1rem;
    z-index: 2001;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    backdrop-filter: blur(12px);
  }

  /* Sidebar as Drawer */
  .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    z-index: 3000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.9);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(5, 5, 5, 0.98);
    padding-bottom: 20px;
    overflow: hidden;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Open State */
  .sidebar.mobile-open {
    left: 0 !important;
  }

  /* Header Fixed on Top — más compacto */
  header,
  .header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 44px;
    z-index: 900;
    background: var(--bg-color);
    padding: 0 10px 0 48px;
    font-size: 0.75rem;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border-radius: 0;
    margin-bottom: 0;
    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  header::-webkit-scrollbar,
  .header::-webkit-scrollbar {
    display: none;
  }

  /* Hide main-content wrapper (chart is fixed) */
  .main-content {
    padding: 0;
    gap: 0;
  }

  /* Chart fills remaining space */
  .chart-container {
    position: fixed;
    top: 44px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 44px);
    height: calc(100dvh - 44px);
    border-radius: 0;
    border: none;
    margin: 0;
    padding: 0;
    z-index: 1;
    min-height: unset;
  }

  /* Input wrappers más compactos */
  .input-wrapper {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .input-wrapper label {
    display: none;
  }

  .input-wrapper select {
    padding: 3px 5px;
    font-size: 0.7rem;
    height: 28px;
    border-radius: 6px;
  }

  #update-chart-btn {
    padding: 0 8px;
    font-size: 0.7rem;
    height: 28px;
    margin-top: 0;
    border-radius: 6px;
  }

  /* Market Explorer Button más compacto */
  .glass-input-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  /* Dropdown reposicionado para móvil */
  .market-explorer-dropdown {
    /* On mobile: use fixed positioning so it always renders above the chart canvas */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-height: 100vh !important;
    overflow-y: auto !important;
    z-index: 999999 !important;
    border-radius: 0 0 12px 12px;
  }

  .market-grid {
    grid-template-columns: 1fr;
  }

  /* Overlay info badges ocultos en móvil */
  .overlay-info {
    top: 8px;
    right: 8px;
  }

  .badge {
    padding: 3px 8px;
    font-size: 0.65rem;
  }

  /* Admin Modal responsive */
  .modal-content.glass-panel {
    max-width: 98vw !important;
    max-height: 90vh;
    overflow-y: auto;
    padding: 12px;
    border-radius: 12px;
  }

  .modal-content .modal-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .admin-tabs {
    flex-wrap: wrap;
    gap: 6px !important;
  }

  .admin-tabs .tab-btn {
    font-size: 0.75rem;
    padding: 6px 10px;
  }

  /* User table scroll horizontal en móvil */
  .user-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Sound button más pequeño */
  #sound-toggle-btn {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  /* Price/status en header */
  #current-price,
  #connection-status {
    font-size: 0.75rem !important;
  }

  /* ====== SIDEBAR COMPACTO EN MÓVIL ====== */

  /* Logo más pequeño */
  .logo-container {
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 10px;
  }

  .logo-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
  }

  .logo-text {
    font-size: 0.8rem !important;
    letter-spacing: 1px;
  }

  /* User status panel */
  .user-status-panel {
    padding: 6px 8px;
    margin-bottom: 8px;
  }

  .user-status-panel div {
    font-size: 0.62rem !important;
  }

  #current-user-email {
    font-size: 0.68rem !important;
  }

  #logout-btn-sidebar {
    padding: 4px !important;
    font-size: 0.62rem !important;
  }

  /* Admin panel btn */
  #admin-panel-btn {
    font-size: 0.7rem !important;
    padding: 6px 10px !important;
  }

  /* Theme selector */
  .theme-selector {
    gap: 4px;
    margin-bottom: 10px;
  }

  .theme-btn {
    padding: 4px 8px;
    font-size: 0.65rem;
  }

  /* Section headers */
  .sidebar-header {
    padding: 6px;
  }

  .sidebar-header h3,
  .sidebar-header h4 {
    font-size: 0.7rem !important;
  }

  .sidebar-chevron {
    font-size: 0.55rem;
  }

  /* Section content */
  .sidebar-content {
    padding: 4px 6px 6px 6px;
  }

  /* Indicator checkboxes */
  .indicator-item {
    margin-bottom: 3px;
  }

  .indicator-checkbox {
    padding: 4px 6px;
    gap: 6px;
  }

  .checkmark {
    width: 13px;
    height: 13px;
    border-radius: 3px;
  }

  .indicator-name {
    font-size: 0.68rem !important;
  }

  .indicator-description {
    font-size: 0.56rem !important;
    margin: 1px 0 0 20px;
  }

  .indicator-value {
    font-size: 0.6rem !important;
  }

  /* Quantum Script section */
  .subsection-title {
    font-size: 0.68rem;
  }

  .helper-text {
    font-size: 0.58rem;
  }

  .instruction-list {
    font-size: 0.58rem;
    padding-left: 14px;
  }

  .info-box {
    padding: 5px;
    font-size: 0.58rem;
  }

  #quantum-script-editor {
    font-size: 0.62rem !important;
    min-height: 50px !important;
    max-height: 80px !important;
  }

  #run-script-btn,
  #save-script-btn,
  #delete-script-btn {
    font-size: 0.62rem !important;
    padding: 5px !important;
  }

  #reset-script-btn {
    padding: 5px 7px !important;
    font-size: 0.8rem !important;
  }

  #strategy-name-input,
  #saved-strategies-select {
    font-size: 0.62rem !important;
    padding: 4px !important;
  }

  /* Stat cards (Radar, Señal Activa, Volumen) */
  .stat-card {
    padding: 6px;
    border-radius: 8px;
    margin-bottom: 6px;
  }

  .stat-label {
    font-size: 0.58rem;
    letter-spacing: 0.5px;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  #active-signal {
    font-size: 0.82rem !important;
  }

  /* Signal History */
  #signal-history-list div {
    padding: 4px 6px !important;
    margin-bottom: 3px !important;
    font-size: 0.65rem !important;
  }

  #signal-history-list span {
    font-size: 0.62rem !important;
  }

  /* Admin section in sidebar */
  #admin-panel-btn-sidebar {
    font-size: 0.65rem !important;
    padding: 5px !important;
  }

  #admin-sidebar-section .sidebar-header h3 {
    font-size: 0.7rem !important;
  }

  /* Footer C2A text */
  .sidebar>div:last-child {
    font-size: 0.5rem !important;
    padding: 4px !important;
  }

  /* ====== CHART OVERLAY LABELS ====== */

  /* Texto sobre la gráfica (señales, marcadores) más pequeño */
  .overlay-info {
    top: 4px;
    right: 4px;
    gap: 3px;
  }

  .badge {
    padding: 2px 6px;
    font-size: 0.58rem;
    border-radius: 4px;
  }

  /* Left panel (historial, radar, señal activa) sobre la gráfica */
  .left-panel {
    top: 4px;
    left: 4px;
    max-width: 140px;
  }

  .left-panel .stat-card {
    padding: 4px 6px;
  }

  .left-panel .stat-label {
    font-size: 0.52rem;
  }

  .left-panel .stat-value {
    font-size: 0.78rem;
  }
}

/* ========================================
   CHART TOOLBAR — Timeframe, Zoom, Tools
   ======================================== */
#chart-toolbar {
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--glass-border);
}

[data-theme="light"] #chart-toolbar {
  background: rgba(245, 245, 245, 0.95);
}

/* Timeframe Quick Buttons */
.tf-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.02em;
}

.tf-btn:hover {
  background: rgba(157, 0, 255, 0.15);
  color: var(--text-main);
}

.tf-btn.active {
  background: var(--accent-purple);
  color: #fff;
  border-color: var(--accent-purple);
  box-shadow: 0 0 8px rgba(157, 0, 255, 0.4);
}

/* Tool Buttons (Zoom, Screenshot, Drawing) */
.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
  font-family: 'Inter', sans-serif;
  line-height: 1;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--glass-border);
}

.tool-btn.active {
  background: rgba(0, 255, 136, 0.15);
  color: var(--accent-green);
  border-color: var(--accent-green);
}

[data-theme="light"] .tool-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Price Alert Line Style */
.alert-price-line {
  border-top: 1px dashed #FFD700 !important;
}

/* Context Menu (Right-click) */
.chart-context-menu {
  position: fixed;
  background: rgba(15, 15, 15, 0.96);
  border: 1px solid var(--accent-purple);
  border-radius: 8px;
  padding: 6px 0;
  z-index: 100000;
  min-width: 200px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  animation: slideIn 0.15s ease;
}

.chart-context-menu .ctx-item {
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-context-menu .ctx-item:hover {
  background: rgba(157, 0, 255, 0.2);
}

/* Mobile: Stack toolbar */
@media screen and (max-width: 768px) {
  #chart-toolbar {
    padding: 3px 6px;
    gap: 1px;
  }

  .tf-btn {
    padding: 4px 6px;
    font-size: 0.65rem;
  }

  .tool-btn {
    padding: 3px 7px;
    font-size: 0.75rem;
  }

  #chart-toolbar,
  #chart-toolbar-2 {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #chart-toolbar::-webkit-scrollbar,
  #chart-toolbar-2::-webkit-scrollbar {
    display: none;
  }

  .journal-modal,
  .calendar-modal,
  .theme-modal,
  .pip-calc-modal {
    min-width: unset !important;
    width: 92vw !important;
    max-height: 85vh !important;
  }

  #chart-toast {
    max-width: 90vw;
    font-size: 0.7rem !important;
  }

  #ohlcv-legend {
    font-size: 0.6rem !important;
    max-width: 85%;
  }

  #candle-countdown {
    font-size: 0.65rem !important;
  }
}

/* Toolbar 2 base styling */
#chart-toolbar-2 .tool-btn {
  font-size: 0.8rem;
}