:root {
  --bg: #07090f;
  --surface: #0e131f;
  --surface-2: #131a2a;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --muted: #8b9bb4;
  --gold: #f5c542;
  --gold-dim: rgba(245, 197, 66, 0.14);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.14);
  --red: #f43f5e;
  --red-dim: rgba(244, 63, 94, 0.14);
  --amber: #f59e0b;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(245, 197, 66, 0.07), transparent 65%),
    radial-gradient(700px 450px at 10% 0%, rgba(34, 197, 94, 0.045), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.ltr { direction: ltr; unicode-bidi: isolate; font-family: 'JetBrains Mono', monospace; }
.gold { color: var(--gold); }
.green { color: var(--green); }
.red { color: var(--red); }
.muted { color: var(--muted); font-size: 0.85rem; }
.hidden { display: none !important; }

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 20px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* NAVBAR */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  background: rgba(14, 19, 31, 0.86);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 20px;
  flex-wrap: wrap;
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, #fde047, #ca8a04);
  box-shadow: 0 0 14px rgba(245, 197, 66, 0.7);
}
.brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: 0.4px; font-family: 'JetBrains Mono', monospace; }
.sim-chip {
  font-size: 0.72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: var(--muted); border: 1px solid var(--border);
}

.nav-tabs {
  display: flex; gap: 4px; background: rgba(255, 255, 255, 0.035);
  padding: 4px; border-radius: 999px; border: 1px solid var(--border);
}
.nav-tab {
  background: transparent; color: var(--muted); border: none;
  padding: 6px 16px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 0.86rem; transition: all 0.18s ease;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { background: var(--surface-2); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,0.35); }

.nav-actions { display: flex; align-items: center; gap: 8px; }
.live-price-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(245, 197, 66, 0.08); border: 1px solid rgba(245, 197, 66, 0.25);
}
.price-num { font-weight: 700; font-size: 0.96rem; color: var(--gold); }
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.65); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.04); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; font-family: inherit; font-size: 0.82rem; font-weight: 600;
  transition: all 0.16s ease;
}
.icon-btn:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.08); }
.icon-btn.active { border-color: rgba(245, 197, 66, 0.45); background: var(--gold-dim); color: var(--gold); }

/* SLIDE-DOWN SETTINGS DRAWER */
.settings-drawer {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 16px 20px;
}
.drawer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; align-items: end; }
.drawer-field { display: flex; flex-direction: column; gap: 6px; }
.drawer-field label { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.seg-control { display: flex; background: var(--bg); padding: 3px; border-radius: 10px; border: 1px solid var(--border); gap: 4px; }
.seg-btn {
  flex: 1; background: transparent; color: var(--muted); border: none; border-radius: 7px;
  padding: 6px 10px; cursor: pointer; font-family: inherit; font-size: 0.8rem; font-weight: 700;
}
.seg-btn.active { background: var(--surface-2); color: var(--gold); }
.inline-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip-btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 11px; cursor: pointer; font-family: inherit; font-size: 0.8rem; font-weight: 700;
}
.chip-btn:hover { border-color: var(--gold); color: var(--gold); }
.gold-btn { background: var(--gold); color: #090c14; border-color: var(--gold); }
.gold-btn:hover { background: #fcd34d; color: #090c14; }
.field-input, .field-select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 10px; font-family: inherit; font-size: 0.82rem;
}
.field-input { width: 96px; }

/* VIEWS */
.view { display: none; flex-direction: column; gap: 16px; }
.view.active { display: flex; }

/* HERO SIGNAL RADAR CARD */
.signal-hero {
  border-radius: 20px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(19, 26, 42, 0.92), rgba(11, 15, 26, 0.96));
  transition: all 0.35s ease;
}
.signal-hero.state-buy {
  border-color: rgba(34, 197, 94, 0.55);
  background: linear-gradient(145deg, rgba(16, 48, 32, 0.88), rgba(10, 18, 22, 0.96));
  box-shadow: 0 0 36px rgba(34, 197, 94, 0.14);
}
.signal-hero.state-sell {
  border-color: rgba(244, 63, 94, 0.55);
  background: linear-gradient(145deg, rgba(54, 16, 26, 0.88), rgba(14, 12, 20, 0.96));
  box-shadow: 0 0 36px rgba(244, 63, 94, 0.14);
}
.signal-hero.state-watch {
  border-color: rgba(245, 197, 66, 0.50);
  background: linear-gradient(145deg, rgba(52, 40, 14, 0.72), rgba(14, 16, 26, 0.96));
  box-shadow: 0 0 28px rgba(245, 197, 66, 0.10);
}

.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.hero-status-wrap { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 280px; }

.radar-ring {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(245, 197, 66, 0.45);
  background: radial-gradient(circle, rgba(245, 197, 66, 0.25) 0%, transparent 70%);
  position: relative;
}
.radar-ring::after {
  content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--gold);
  animation: radarPulse 2.2s ease-out infinite;
}
.state-buy .radar-ring { border-color: var(--green); background: radial-gradient(circle, rgba(34,197,94,0.3), transparent 70%); }
.state-buy .radar-ring::after { background: var(--green); }
.state-sell .radar-ring { border-color: var(--red); background: radial-gradient(circle, rgba(244,63,94,0.3), transparent 70%); }
.state-sell .radar-ring::after { background: var(--red); }

@keyframes radarPulse {
  0% { transform: scale(0.85); opacity: 1; }
  70% { transform: scale(1.65); opacity: 0.15; }
  100% { transform: scale(0.85); opacity: 1; }
}

.hero-kicker { font-size: 0.78rem; color: var(--gold); font-weight: 700; margin-bottom: 2px; }
.state-buy .hero-kicker { color: var(--green); }
.state-sell .hero-kicker { color: var(--red); }
.hero-title { font-size: 1.45rem; font-weight: 800; line-height: 1.25; }
.hero-reason { font-size: 0.92rem; color: var(--muted); margin-top: 4px; }

.hero-right { display: flex; align-items: center; gap: 10px; }
.quality-pill {
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px 14px; text-align: center;
}
.q-lbl { display: block; font-size: 0.7rem; color: var(--muted); }
.q-val { font-size: 1.05rem; color: var(--gold); }

.ghost-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; cursor: pointer; font-family: inherit;
  font-size: 0.82rem; font-weight: 700; transition: all 0.16s ease;
}
.ghost-btn:hover { color: var(--text); border-color: var(--gold); background: var(--gold-dim); }

/* ACTIVE TRADE DETAILS BOX INSIDE HERO */
.hero-trade-box {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
}
.trade-levels-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.level-tile {
  background: rgba(7, 9, 15, 0.55); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px;
}
.level-tile span { font-size: 0.74rem; color: var(--muted); }
.level-tile strong { font-size: 1.05rem; }
.sl-tile strong { color: var(--red); }
.tp-tile strong { color: var(--green); }
.trade-why {
  font-size: 0.86rem; color: #dbe7f5; background: rgba(255, 255, 255, 0.04);
  padding: 10px 14px; border-radius: 10px; border-right: 3px solid var(--gold);
}

/* 1-MINUTE CHART PANEL */
.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px 16px;
}
.chart-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.chart-title-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-title-group h2 { font-size: 1rem; font-weight: 700; }
.tf-badge {
  background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(245, 197, 66, 0.35);
  padding: 2px 10px; border-radius: 8px; font-size: 0.76rem; font-weight: 700;
}
.spread-inline { font-size: 0.78rem; color: var(--muted); }

.chart-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mini-check { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; color: var(--muted); cursor: pointer; }
.mini-btn {
  background: rgba(255, 255, 255, 0.04); color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font-family: inherit; font-size: 0.78rem; font-weight: 600;
}
.mini-btn:hover { color: var(--text); border-color: var(--border-strong); }

.m1-chart { width: 100%; height: 430px; border-radius: 12px; overflow: hidden; background: #090d16; }

/* 4-CARD SUMMARY STRIP */
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--muted); }
.stat-big { font-size: 1.28rem; font-weight: 800; }
.stat-sub { font-size: 0.78rem; color: var(--muted); }
.mini-switch { display: inline-flex; gap: 4px; }
.mini-switch button {
  background: rgba(255,255,255,0.05); color: var(--gold); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px; font-size: 0.72rem; cursor: pointer; font-family: 'JetBrains Mono', monospace;
}
.mini-switch button:hover { background: var(--gold-dim); }
.dot-tag {
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.05); color: var(--text);
}

/* SECONDARY VIEWS (TRADES & ANALYTICS) */
.panel-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.glass-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h3 { font-size: 1rem; font-weight: 700; }
.sub-title { font-size: 0.86rem; color: var(--gold); margin: 14px 0 8px; }

.soft-banner {
  background: rgba(245, 197, 66, 0.08); border: 1px solid rgba(245, 197, 66, 0.22);
  color: #f4d887; padding: 9px 12px; border-radius: 10px; font-size: 0.8rem; margin-bottom: 12px;
}

.criteria-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.crit-card {
  background: rgba(255, 255, 255, 0.025); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
}
.crit-top { display: flex; justify-content: space-between; font-size: 0.78rem; font-weight: 700; }
.crit-sub { font-size: 0.7rem; color: var(--muted); direction: ltr; text-align: left; margin-top: 2px; }

.mini-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini-kpi {
  background: rgba(255, 255, 255, 0.025); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 10px; display: flex; flex-direction: column; gap: 2px;
}
.mini-kpi span { font-size: 0.72rem; color: var(--muted); }
.mini-kpi strong { font-size: 0.86rem; }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 700; font-size: 0.76rem; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; font-family: 'JetBrains Mono', monospace;
}
.badge-buy { background: var(--green-dim); color: var(--green); }
.badge-sell { background: var(--red-dim); color: var(--red); }
.badge-wait { background: rgba(255,255,255,0.06); color: var(--muted); }

/* TOAST POPUP */
.toast-container {
  position: fixed; bottom: 20px; left: 20px; z-index: 9999;
  display: flex; flex-direction: column-reverse; gap: 10px; max-width: 380px;
}
.toast {
  background: rgba(14, 19, 31, 0.96); backdrop-filter: blur(12px);
  border: 1px solid var(--gold); border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.55); animation: slideIn 0.25s ease;
}
.toast.buy { border-color: var(--green); }
.toast.sell { border-color: var(--red); }
.toast-title { font-weight: 800; font-size: 0.96rem; margin-bottom: 4px; }
.toast-body { font-size: 0.82rem; color: var(--muted); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 960px) {
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid-2 { grid-template-columns: 1fr; }
  .m1-chart { height: 340px; }
}
@media (max-width: 600px) {
  .summary-strip { grid-template-columns: 1fr; }
  .navbar { border-radius: 18px; }
  .btn-lbl { display: none; }
}
