:root {
  --bg-main: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);
  --accent: #8b5cf6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-main);
  background-image: radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
                    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.08) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  padding: 16px;
  line-height: 1.5;
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  transition: all 0.2s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.header-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.brand-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-title p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.controls-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 2px 10px var(--danger-glow); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }
.btn-warning { background: var(--warning); color: #000; font-weight: 700; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-outline { background: transparent; border-color: var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.2); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-live { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-paper { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }

.badge-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.badge-dot.green { background: #10b981; box-shadow: 0 0 6px #10b981; }
.badge-dot.red { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
.badge-dot.yellow { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card { padding: 12px 16px; }
.metric-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; }
.metric-value { font-size: 1.25rem; font-weight: 700; }
.metric-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.tabs-nav {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  scrollbar-width: thin;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.tab-btn:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.04); }
.tab-btn.active { color: #fff; background: var(--primary); box-shadow: 0 2px 8px var(--primary-glow); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.chart-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.chart-box { width: 100%; height: 480px; position: relative; background: #0d1322; border-radius: 8px; overflow: hidden; }
.rsi-box { width: 100%; height: 150px; margin-top: 8px; background: #0d1322; border-radius: 8px; overflow: hidden; }

.table-responsive { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: right; font-size: 0.82rem; }
th { background: rgba(255, 255, 255, 0.03); color: var(--text-muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); white-space: nowrap; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { background: #111827; border: 1px solid var(--border-color); border-radius: 16px; width: 90%; max-width: 520px; padding: 24px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; }
.form-input { width: 100%; background: #1f2937; border: 1px solid var(--border-color); border-radius: 8px; padding: 8px 12px; color: #fff; font-size: 0.85rem; }
.form-input:focus { outline: none; border-color: var(--primary); }

.grid-ladder { display: flex; flex-direction: column-reverse; gap: 2px; margin-top: 10px; background: #0d1322; padding: 8px; border-radius: 8px; max-height: 380px; overflow-y: auto; }
.grid-level-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; font-size: 0.75rem; border-radius: 4px; background: rgba(255, 255, 255, 0.02); }
.grid-level-row.current { background: rgba(59, 130, 246, 0.25); border: 1px solid var(--primary); font-weight: 700; }

.log-terminal { background: #070a12; border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; font-family: monospace; font-size: 0.75rem; height: 400px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.log-entry { display: flex; gap: 8px; }
.log-time { color: var(--text-muted); }
.log-info { color: #38bdf8; }
.log-trade { color: #34d399; font-weight: 600; }
.log-warn { color: #fbbf24; }
.log-error { color: #f87171; font-weight: 600; }
.log-safety { color: #e879f9; font-weight: 700; }

@media (max-width: 768px) {
  .header-container { flex-direction: column; align-items: stretch; }
  .controls-group { justify-content: flex-start; }
  .chart-box { height: 340px; }
}

/* Full-Screen Login Backdrop */
.login-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.login-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.login-card {
  width: 90%;
  max-width: 420px;
  padding: 32px 28px;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7),
              0 0 30px rgba(59, 130, 246, 0.15);
}
