/* ============================================================
   AI TURBO TRADE — Trader Dashboard
   ============================================================ */
:root {
  --primary: #00e5ff;
  --primary-2: #0077ff;
  --primary-gradient: linear-gradient(90deg, #00e5ff, #0077ff);
  --green: #00d67d;
  --red: #ff3b6b;
  --text-muted: #b5b9c9;
  --glass: rgba(24, 27, 36, 0.7);
  --glass-border: rgba(255, 255, 255, 0.07);
  --display-font: 'Space Grotesk', 'Inter', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
}

body {
  background: radial-gradient(circle at top left, #0f1320, #0a0c12 80%);
  color: #ffffff;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
.dash-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 12px 28px;
  background: rgba(15, 17, 22, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
}
.dash-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--primary);
  font-family: var(--display-font);
  font-weight: 700;
  font-size: 19px;
}
.dash-logo img { width: 52px; height: 52px; }
.dash-nav {
  display: flex;
  gap: 22px;
  margin-left: 8px;
}
.dash-nav a {
  color: #cdd1e0;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: color 0.25s ease;
}
.dash-nav a:hover { color: var(--primary); }
.logout-btn {
  margin-left: auto;
  background: transparent;
  border: 1.5px solid rgba(255, 82, 82, 0.55);
  color: #ff8aa6;
  border-radius: 999px;
  padding: 8px 20px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.logout-btn:hover {
  background: rgba(255, 59, 107, 0.12);
  box-shadow: 0 0 14px rgba(255, 59, 107, 0.25);
}

/* ── Layout ─────────────────────────────────────────────── */
.dash-main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 118px 22px 60px;
}
.dash-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}
.dash-head h1 {
  font-family: var(--display-font);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #ffffff, #b8ecff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.dash-head p {
  color: var(--text-muted);
  font-size: 14.5px;
  margin-top: 4px;
}

.filter-tabs {
  display: inline-flex;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.filter-tabs .tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.filter-tabs .tab:hover { color: #ffffff; }
.filter-tabs .tab.active {
  background: var(--primary-gradient);
  color: #06121c;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.35);
}

/* ── Loading / empty ────────────────────────────────────── */
.dash-loading {
  text-align: center;
  padding: 90px 0;
  color: var(--text-muted);
}
.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid rgba(0, 229, 255, 0.15);
  border-top-color: var(--primary);
  animation: dash-spin 0.9s linear infinite;
}
@keyframes dash-spin { to { transform: rotate(360deg); } }

.dash-empty {
  text-align: center;
  padding: 70px 30px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
}
.dash-empty .empty-icon { font-size: 52px; margin-bottom: 16px; }
.dash-empty h2 {
  font-family: var(--display-font);
  margin-bottom: 10px;
}
.dash-empty p {
  color: var(--text-muted);
  max-width: 440px;
  margin: 0 auto 28px;
  line-height: 1.7;
}
.empty-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.cta {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 12px;
  background: var(--primary-gradient);
  color: #06121c;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.25s ease;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.3);
}
.cta:hover { transform: translateY(-2px); filter: brightness(1.12); }
.cta.ghost {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  box-shadow: none;
}

/* ── Stat cards ─────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px 20px 16px;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.stat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 229, 255, 0.28);
  box-shadow: 0 12px 34px rgba(0, 229, 255, 0.1);
}
.stat-card .k {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #7e849b;
  margin-bottom: 8px;
}
.stat-card .v {
  font-family: var(--display-font);
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.25;
}
.stat-card .v.pos {
  background: linear-gradient(90deg, #00d67d, #6ff0b6);
  -webkit-background-clip: text;
  background-clip: text;
}
.stat-card .v.neg {
  background: linear-gradient(90deg, #ff3b6b, #ff8aa6);
  -webkit-background-clip: text;
  background-clip: text;
}
.stat-card .s {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ── Chart cards ────────────────────────────────────────── */
.chart-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 22px;
}
.chart-card h3 {
  font-family: var(--display-font);
  font-size: 15.5px;
  letter-spacing: 0.3px;
  margin-bottom: 16px;
  color: #e8ebf5;
}
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.charts-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
  margin-bottom: 0;
}
@media (max-width: 820px) {
  .charts-row { grid-template-columns: 1fr; }
}

/* ── Recent trades table ────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.dash-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}
.dash-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #7e849b;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.dash-table td {
  padding: 12px;
  font-size: 14px;
  color: #dfe3f0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dash-table tbody tr {
  transition: background 0.2s ease;
}
.dash-table tbody tr:hover { background: rgba(0, 229, 255, 0.04); }
.dash-table .muted { color: #8b93a8; font-size: 13px; }

.badge-src {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-src.binary { background: rgba(0, 229, 255, 0.12); color: var(--primary); }
.badge-src.forex  { background: rgba(157, 122, 255, 0.14); color: #b79aff; }

.chip-side {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
}
.chip-side.buy  { background: rgba(0, 214, 125, 0.12); color: var(--green); }
.chip-side.sell { background: rgba(255, 59, 107, 0.12); color: var(--red); }

.pl-pos { color: var(--green); font-weight: 700; }
.pl-neg { color: var(--red); font-weight: 700; }
.pl-zero { color: #8b93a8; font-weight: 600; }

/* ── Expandable trade details (mirrors the binary history panel) ── */
.dash-table tr.clickable { cursor: pointer; }
.dash-table th.chev-col, .dash-table td.chev-col { width: 34px; text-align: center; }
.chev {
  display: inline-block;
  color: #8b93a8;
  font-size: 13px;
  transition: transform 0.3s ease, color 0.3s ease;
}
tr.clickable.open { background: rgba(0, 229, 255, 0.05); }
tr.clickable.open .chev {
  transform: rotate(180deg);
  color: var(--primary);
}
tr.clickable.open td { border-bottom-color: transparent; }

.details-tr > td {
  padding: 0 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}
.trade-detail {
  background: rgba(10, 14, 22, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 2px 34px;
  animation: detail-in 0.3s ease-out;
}
@keyframes detail-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.td-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.055);
  white-space: nowrap;
}
.td-label { color: #8b93a8; }
.td-value { color: #dfe3f0; font-weight: 600; font-variant-numeric: tabular-nums; }

.res-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 2px 10px;
  border-radius: 5px;
  border: 1px solid;
}
.res-badge.win  { color: #00e676; border-color: #00e676; background: rgba(0, 230, 118, 0.12); }
.res-badge.loss { color: #ff5252; border-color: #ff5252; background: rgba(255, 82, 82, 0.12); }
.res-badge.tie  { color: #9aa3b5; border-color: #7b8494; background: rgba(128, 128, 128, 0.15); }

/* ── Footer ─────────────────────────────────────────────── */
.dash-footer {
  text-align: center;
  padding: 26px 20px 30px;
  color: #7e849b;
  font-size: 13px;
  border-top: 1px solid var(--glass-border);
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 720px) {
  .dash-nav { display: none; }
  .dash-header { padding: 10px 16px; }
  .dash-logo img { width: 42px; height: 42px; }
  .dash-main { padding-top: 100px; }
  .dash-head { align-items: flex-start; flex-direction: column; }
}

/* ── Filters row (account tabs + strategy tag filter) ───── */
.dash-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.tag-filter {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: #dfe3f0;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  cursor: pointer;
}
.tag-filter:focus {
  outline: none;
  border-color: var(--primary);
}
.tag-filter option {
  background: #12151d;
  color: #ffffff;
}

/* ── Card subtitle ──────────────────────────────────────── */
.card-sub {
  color: #7e849b;
  font-size: 13px;
  margin: -8px 0 16px;
}

/* ── Win-rate heatmap ───────────────────────────────────── */
.heatmap-wrap {
  overflow-x: auto;
  padding-bottom: 6px;
}
.heatmap {
  min-width: 640px;
}
.hm-row {
  display: grid;
  grid-template-columns: 42px repeat(24, 1fr);
  gap: 3px;
  margin-bottom: 3px;
  align-items: center;
}
.hm-daylabel {
  font-size: 11.5px;
  font-weight: 600;
  color: #7e849b;
  text-align: right;
  padding-right: 8px;
}
.hm-hourlabel {
  font-size: 10.5px;
  color: #5d6478;
  text-align: center;
  height: 14px;
  line-height: 14px;
}
.hm-cell {
  display: block;
  height: 22px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  cursor: default;
  transition: transform 0.15s ease;
}
.hm-cell:hover {
  transform: scale(1.18);
}
.hm-cell.win  { background: rgba(0, 214, 125, 0.75); }
.hm-cell.mid  { background: rgba(240, 185, 11, 0.55); }
.hm-cell.loss { background: rgba(255, 59, 107, 0.7); }
.hm-cell.empty { background: rgba(255, 255, 255, 0.04); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12.5px;
  color: #7e849b;
}
.hm-key {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  margin-left: 14px;
}
.hm-key:first-child { margin-left: 0; }
.hm-key.hm-win  { background: rgba(0, 214, 125, 0.75); }
.hm-key.hm-mid  { background: rgba(240, 185, 11, 0.55); }
.hm-key.hm-loss { background: rgba(255, 59, 107, 0.7); }
.hm-key.hm-empty { background: rgba(255, 255, 255, 0.06); }

/* ── Strategy tag chip in the trades table ──────────────── */
.tag-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(0, 229, 255, 0.09);
  border: 1px solid rgba(0, 229, 255, 0.3);
  vertical-align: middle;
}

/* ── Trade journal editor (inside detail rows) ──────────── */
.trade-journal {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px dashed rgba(0, 229, 255, 0.25);
  border-radius: 12px;
  background: rgba(0, 229, 255, 0.03);
}
.tj-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}
.tj-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tj-tag, .tj-notes {
  width: 100%;
  background: rgba(10, 13, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #ffffff;
  font-size: 13.5px;
  font-family: inherit;
  padding: 9px 12px;
}
.tj-tag:focus, .tj-notes:focus {
  outline: none;
  border-color: var(--primary);
}
.tj-notes { resize: vertical; }
.tj-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.tj-save {
  background: var(--primary-gradient);
  border: none;
  border-radius: 8px;
  color: #06121c;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  cursor: pointer;
}
.tj-save:disabled { opacity: 0.6; cursor: wait; }
.tj-status { font-size: 12.5px; color: #7e849b; }
.tj-status.ok { color: var(--green); }
.tj-status.err { color: var(--red); }
