/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #060b14;
  --bg2: #0a1220;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-glow: rgba(0,195,255,0.2);

  --accent: #00c3ff;
  --accent2: #7b61ff;
  --green: #00e698;
  --red: #ff4757;
  --orange: #ffa502;
  --yellow: #ffd32a;

  --text: #e8edf8;
  --text2: #7a8ba8;
  --text3: #4a5e78;

  --font: 'Inter', sans-serif;
  --mono: 'JetBrains Mono', monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --glow: 0 0 40px rgba(0,195,255,0.06);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== AMBIENT BACKGROUND ===== */
.ambient-bg {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: float 8s ease-in-out infinite;
}
.orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #00c3ff, transparent);
  top: -200px; left: -100px;
  animation-delay: 0s;
}
.orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #7b61ff, transparent);
  bottom: -150px; right: -100px;
  animation-delay: 3s;
}
.orb-3 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #00e698, transparent);
  top: 50%; right: 30%;
  animation-delay: 5s;
}
@keyframes float {
  0%,100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

/* ===== HEADER ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: rgba(6,11,20,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px rgba(0,195,255,0.3);
}
.logo-text {
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.logo-accent { color: var(--accent); }
.header-badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,230,152,0.1);
  border: 1px solid rgba(0,230,152,0.3);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px; font-weight: 700;
  color: var(--green);
  letter-spacing: 1px;
}
.pulse-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

.header-center { flex: 1; display: flex; justify-content: center; }
.pair-selector {
  display: flex; gap: 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 4px;
}
.pair-btn {
  background: none; border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font);
  font-size: 12px; font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
}
.pair-btn:hover { color: var(--text); background: var(--surface-hover); }
.pair-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 0 15px rgba(0,195,255,0.25);
}

.header-right { display: flex; align-items: center; gap: 10px; }
.status-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px; font-weight: 500;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text2);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text3);
  transition: background 0.3s;
}
.status-badge.connected .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-badge.connected { border-color: rgba(0,230,152,0.2); color: var(--green); }
.status-badge.error .status-dot { background: var(--red); }
.status-badge.error { border-color: rgba(255,71,87,0.2); color: var(--red); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  position: relative;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); border-color: var(--accent); }
.alert-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  background: var(--red);
  border-radius: 8px;
  font-size: 10px; font-weight: 700;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  display: none;
}
.alert-badge.visible { display: flex; }

/* ===== MAIN ===== */
.main {
  position: relative; z-index: 1;
  padding: 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ===== STATS BAR ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  backdrop-filter: blur(8px);
  transition: border-color 0.3s;
}
.stat-card:hover { border-color: var(--border-glow); }
.stat-label {
  font-size: 11px; font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.stat-value {
  font-size: 22px; font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat-value.small { font-size: 16px; }
.stat-change {
  font-size: 12px; font-weight: 600;
  margin-top: 4px;
}
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
.mono { font-family: var(--mono); }

/* Signal pill */
.signal-pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 12px; font-weight: 700;
  letter-spacing: 1px;
  background: rgba(122,139,168,0.15);
  color: var(--text2);
  border: 1px solid rgba(122,139,168,0.2);
  transition: all 0.3s;
}
.signal-pill.large { font-size: 14px; padding: 8px 20px; margin: 6px 0; }
.signal-pill.buy {
  background: rgba(0,230,152,0.15);
  color: var(--green);
  border-color: rgba(0,230,152,0.3);
  box-shadow: 0 0 15px rgba(0,230,152,0.1);
}
.signal-pill.sell {
  background: rgba(255,71,87,0.15);
  color: var(--red);
  border-color: rgba(255,71,87,0.3);
  box-shadow: 0 0 15px rgba(255,71,87,0.1);
}
.signal-pill.hold {
  background: rgba(255,165,2,0.15);
  color: var(--orange);
  border-color: rgba(255,165,2,0.3);
}

/* Risk Meter */
.risk-meter-container { margin: 8px 0; }
.risk-meter {
  height: 8px; border-radius: 4px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
  position: relative;
}
.risk-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--green), var(--orange), var(--red));
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.risk-label {
  font-size: 11px; font-weight: 600;
  color: var(--text2);
  display: block; margin-top: 4px;
}

/* ===== CONTENT GRID ===== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
}
.col-left { display: flex; flex-direction: column; gap: 16px; }
.col-right { display: flex; flex-direction: column; gap: 16px; }

/* ===== CARD ===== */
.card {
  background: rgba(10,18,32,0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
}
.card-title svg { color: var(--accent); }

/* ===== CHART ===== */
.chart-card { min-height: 300px; }
.chart-wrapper {
  padding: 16px;
  height: 300px;
  position: relative;
}
.timeframe-tabs {
  display: flex; gap: 3px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px; padding: 2px;
}
.tf-btn {
  background: none; border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px; font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.tf-btn:hover { color: var(--text); }
.tf-btn.active { background: var(--accent); color: #fff; }

/* ===== INDICATOR ROW ===== */
.indicator-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.indicator-card {
  background: rgba(10,18,32,0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  backdrop-filter: blur(8px);
  transition: border-color 0.3s;
}
.indicator-card:hover { border-color: var(--border-glow); }
.ind-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.ind-name { font-size: 11px; font-weight: 600; color: var(--text2); }
.ind-signal {
  font-size: 11px; font-weight: 700;
  color: var(--text3);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px; border-radius: 4px;
}
.ind-signal.buy { color: var(--green); background: rgba(0,230,152,0.1); }
.ind-signal.sell { color: var(--red); background: rgba(255,71,87,0.1); }
.ind-signal.neutral { color: var(--orange); background: rgba(255,165,2,0.1); }
.ind-value {
  font-size: 18px; font-weight: 700;
  color: var(--text);
  margin-top: 8px;
}

/* RSI Gauge */
.gauge-track {
  height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--green) 0%, var(--green) 30%, rgba(255,255,255,0.1) 30%, rgba(255,255,255,0.1) 70%, var(--red) 70%);
  position: relative;
}
.gauge-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  border-radius: 4px;
  background: transparent;
}
.rsi-pointer {
  position: absolute;
  top: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  transform: translateX(-50%);
  transition: left 0.5s;
}
.gauge-labels {
  display: flex; justify-content: space-between;
  font-size: 9px; color: var(--text3);
  margin-top: 3px;
}

/* BB Info */
.bb-info { margin: 4px 0; }
.bb-row {
  display: flex; justify-content: space-between;
  font-size: 11px; padding: 3px 0;
  color: var(--text2);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.bb-row.mid { color: var(--accent); }
.bb-row:last-child { border-bottom: none; }

/* MACD bars mini chart */
.macd-bars { height: 60px; }

/* ===== SIGNALS PANEL ===== */
.signals-card .card-header { padding-bottom: 8px; }
.signal-pills-mini { display: flex; gap: 4px; }
.signals-list {
  padding: 8px 0;
  max-height: 220px;
  overflow-y: auto;
}
.signals-list::-webkit-scrollbar { width: 3px; }
.signals-list::-webkit-scrollbar-track { background: transparent; }
.signals-list::-webkit-scrollbar-thumb { background: var(--text3); border-radius: 2px; }

.signal-row {
  display: flex; align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  gap: 12px;
  transition: background 0.15s;
}
.signal-row:hover { background: var(--surface-hover); }
.signal-row:last-child { border-bottom: none; }
.signal-row-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.signal-row-icon.buy { background: rgba(0,230,152,0.1); color: var(--green); }
.signal-row-icon.sell { background: rgba(255,71,87,0.1); color: var(--red); }
.signal-row-icon.hold { background: rgba(255,165,2,0.1); color: var(--orange); }
.signal-row-body { flex: 1; }
.signal-row-name { font-size: 12px; font-weight: 600; color: var(--text); }
.signal-row-desc { font-size: 11px; color: var(--text2); margin-top: 1px; }
.signal-row-tag {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px; border-radius: 4px;
}
.signal-row-tag.buy { color: var(--green); background: rgba(0,230,152,0.1); }
.signal-row-tag.sell { color: var(--red); background: rgba(255,71,87,0.1); }
.signal-row-tag.hold { color: var(--orange); background: rgba(255,165,2,0.1); }

.loading-shimmer {
  height: 40px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  margin: 8px 20px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== RISK PANEL ===== */
.risk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 8px 0;
}
.risk-item {
  display: flex; flex-direction: column;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  border-right: 1px solid rgba(255,255,255,0.04);
}
.risk-item:nth-child(even) { border-right: none; }
.risk-item:nth-last-child(-n+2) { border-bottom: none; }
.risk-item-label { font-size: 10px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.risk-item-value {
  font-size: 14px; font-weight: 700;
  color: var(--text);
  margin-top: 3px;
}
.risk-item-value.red { color: var(--red); }
.risk-item-value.green { color: var(--green); }
.risk-item-value.orange { color: var(--orange); }

.capital-input-row {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.capital-label { font-size: 12px; color: var(--text2); white-space: nowrap; }
.input-group { display: flex; align-items: center; flex: 1; }
.input-prefix {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-right: none;
  padding: 6px 10px;
  border-radius: 6px 0 0 6px;
  font-size: 13px; color: var(--text2);
}
.capital-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 0 6px 6px 0;
  padding: 6px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.capital-input:focus { border-color: var(--accent); }

/* ===== ALERTS PANEL ===== */
.alert-setup {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.alert-setup-row { display: flex; gap: 6px; align-items: center; }
.alert-select, .alert-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.2s;
}
.alert-select { flex: 1.5; }
.alert-input { flex: 1; }
.alert-select:focus, .alert-input:focus { border-color: var(--accent); }
.alert-select option { background: #0f1d2e; }
.btn-add-alert {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  color: #fff;
  font-size: 18px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.btn-add-alert:hover { opacity: 0.85; transform: scale(1.05); }

.alert-rules {
  padding: 8px 20px 0;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 80px; overflow-y: auto;
}
.alert-rule-item {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(0,195,255,0.06);
  border: 1px solid rgba(0,195,255,0.12);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11px; color: var(--accent);
}
.alert-rule-del {
  background: none; border: none;
  color: var(--text3); cursor: pointer;
  font-size: 14px; line-height: 1;
  padding: 0 2px;
}
.alert-rule-del:hover { color: var(--red); }

.alerts-feed {
  max-height: 200px;
  overflow-y: auto;
  padding: 8px 0;
}
.alerts-feed::-webkit-scrollbar { width: 3px; }
.alerts-feed::-webkit-scrollbar-thumb { background: var(--text3); border-radius: 2px; }
.no-alerts {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text3);
}

.alert-feed-item {
  display: flex; align-items: flex-start;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  gap: 10px;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
.alert-feed-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-feed-body { flex: 1; }
.alert-feed-title { font-size: 12px; font-weight: 600; color: var(--text); }
.alert-feed-desc { font-size: 11px; color: var(--text2); margin-top: 1px; }
.alert-feed-time { font-size: 10px; color: var(--text3); margin-top: 2px; }
.alert-feed-item.danger .alert-feed-title { color: var(--red); }
.alert-feed-item.success .alert-feed-title { color: var(--green); }
.alert-feed-item.warning .alert-feed-title { color: var(--orange); }

.clear-btn {
  background: none; border: none;
  font-size: 11px; color: var(--text3);
  cursor: pointer; font-family: var(--font);
}
.clear-btn:hover { color: var(--red); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column-reverse;
  gap: 8px;
  z-index: 999;
}
.toast {
  min-width: 300px;
  background: rgba(10,18,32,0.95);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex; align-items: flex-start; gap: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  backdrop-filter: blur(16px);
  animation: toastIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
.toast.hide {
  animation: toastOut 0.3s ease forwards;
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px) scale(0.9); }
}
.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-body {}
.toast-title { font-size: 13px; font-weight: 700; color: var(--text); }
.toast-desc { font-size: 12px; color: var(--text2); margin-top: 2px; }
.toast.buy { border-color: rgba(0,230,152,0.3); }
.toast.sell { border-color: rgba(255,71,87,0.3); }
.toast.warning { border-color: rgba(255,165,2,0.3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .content-grid { grid-template-columns: 1fr; }
  .col-right { display: grid; grid-template-columns: 1fr 1fr; }
  .alerts-card { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .stats-bar { grid-template-columns: repeat(3, 1fr); }
  .indicator-row { grid-template-columns: repeat(2, 1fr); }
  .pair-selector { display: none; }
  .col-right { display: flex; flex-direction: column; }
}
@media (max-width: 600px) {
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .header { padding: 10px 14px; }
  .main { padding: 12px 14px; }
}
