/* ─── keyframes ─── */
@keyframes fadeUp {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  50%      { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0); }
}
@keyframes gradientShift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.05); }
  66%      { transform: translate(-30px, 40px) scale(0.95); }
}
@keyframes flashUp {
  0%   { background-color: rgba(52, 211, 153, 0.25); }
  100% { background-color: transparent; }
}
@keyframes flashDown {
  0%   { background-color: rgba(244, 63, 94, 0.25); }
  100% { background-color: transparent; }
}
@keyframes liveDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.7; }
}

/* ─── Tabs ─── */
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: rgb(148 163 184);
  transition: all 0.2s;
  cursor: pointer;
}
.tab-btn:hover { color: rgb(241 245 249); }
.tab-btn.active {
  background: linear-gradient(135deg, rgba(91, 111, 245, 0.15), rgba(139, 92, 246, 0.15));
  color: rgb(241 245 249);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.3);
}

/* ─── Stat cards (Portfolio tab) ─── */
.stat-card {
  position: relative;
  border-radius: 1rem;
  padding: 1.25rem 1.4rem;
  background: linear-gradient(135deg, rgba(28, 27, 64, 0.5), rgba(13, 13, 31, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  overflow: hidden;
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(139, 92, 246, 0.08));
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.stat-card:hover {
  border-color: rgba(139, 92, 246, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 10px 40px -12px rgba(139, 92, 246, 0.4);
}
.stat-card:hover::before { opacity: 1; }
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgb(148 163 184);
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* ─── Pair sidebar ─── */
.pair-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  position: relative;
}
.pair-item:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.15);
}
.pair-item.active {
  background: linear-gradient(135deg, rgba(91, 111, 245, 0.18), rgba(139, 92, 246, 0.18));
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 24px -6px rgba(139, 92, 246, 0.4);
}
.pair-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%;
  height: 50%; width: 3px;
  background: linear-gradient(180deg, #5b6ff5, #8b5cf6);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.8);
}
.pair-item .symbol {
  font-weight: 700;
  font-size: 13px;
  color: rgb(241 245 249);
  letter-spacing: -0.01em;
}
.pair-item .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}
.pair-item .meta-count { color: rgb(148 163 184); }
.pair-item .open-dot {
  width: 6px; height: 6px;
  background: rgb(167, 139, 250);
  border-radius: 50%;
  box-shadow: 0 0 6px rgb(167, 139, 250);
  animation: liveDot 1.6s ease-in-out infinite;
  display: inline-block;
  margin-left: 6px;
}

/* ─── Pair info bar ─── */
.info-block { display: flex; flex-direction: column; gap: 2px; }
.info-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: rgb(148 163 184); font-weight: 600; }
.info-value { font-size: 14px; font-weight: 600; color: rgb(241 245 249); }
.badge-binance {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, rgba(240, 185, 11, 0.15), rgba(240, 185, 11, 0.05));
  color: rgb(252, 211, 77);
  border: 1px solid rgba(240, 185, 11, 0.25);
}

/* ─── Timeframe bar ─── */
.tf-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: rgb(148 163 184);
  transition: all 0.18s;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
}
.tf-btn:hover { color: rgb(241 245 249); background: rgba(255, 255, 255, 0.04); }
.tf-btn.active {
  background: linear-gradient(135deg, rgba(91, 111, 245, 0.25), rgba(139, 92, 246, 0.25));
  color: rgb(241 245 249);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.4);
}

/* ─── Filters (Portfolio tab) ─── */
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.filter-group > label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: rgb(148 163 184); }
.filter-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(28, 27, 64, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgb(241 245 249);
  border-radius: 8px;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  font-weight: 500;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%237c93ff' d='M6 8L2 4h8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all 0.2s;
  cursor: pointer;
}
.filter-select:hover  { border-color: rgba(139, 92, 246, 0.4); }
.filter-select:focus  { outline: none; border-color: rgba(139, 92, 246, 0.6); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }
.filter-select option { background: #13152e; }

/* Toggle */
.filter-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500; color: rgb(203 213 225);
  cursor: pointer; user-select: none;
}
.toggle-track {
  position: relative; width: 32px; height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.25s;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 999px;
  background: rgb(148 163 184);
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.peer:checked ~ .toggle-track {
  background: linear-gradient(135deg, rgb(91 111 245), rgb(139 92 246));
  border-color: transparent;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}
.peer:checked ~ .toggle-track .toggle-thumb { left: 16px; background: white; }

/* ─── Tables ─── */
.th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgb(148 163 184);
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: rgba(28, 27, 64, 0.4);
  backdrop-filter: blur(12px);
  z-index: 1;
}
.th:hover { color: rgb(167 139 250); }
.th.text-right { text-align: right; }

#signals-tbody tr, #trade-tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.15s ease;
  animation: fadeUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
#signals-tbody tr:hover, #trade-tbody tr:hover {
  background: rgba(139, 92, 246, 0.04);
}
#signals-tbody td, #trade-tbody td {
  padding: 12px 16px;
  font-size: 12.5px;
  white-space: nowrap;
  vertical-align: middle;
}
#signals-tbody tr.row-test td, #trade-tbody tr.row-test td { opacity: 0.55; font-style: italic; }
.tabular { font-variant-numeric: tabular-nums; font-family: 'JetBrains Mono', monospace; }

.flash-up   { animation: flashUp   1.1s ease-out; }
.flash-down { animation: flashDown 1.1s ease-out; }

/* Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid;
}
.badge-long {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 95, 70, 0.2));
  color: rgb(110, 231, 183);
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 16px -4px rgba(16, 185, 129, 0.4);
}
.badge-short {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.2), rgba(159, 18, 57, 0.2));
  color: rgb(253, 164, 175);
  border-color: rgba(244, 63, 94, 0.3);
  box-shadow: 0 0 16px -4px rgba(244, 63, 94, 0.4);
}
.badge-open {
  background: linear-gradient(135deg, rgba(91, 111, 245, 0.2), rgba(139, 92, 246, 0.2));
  color: rgb(167, 139, 250);
  border-color: rgba(139, 92, 246, 0.4);
}
.badge-open .live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgb(167, 139, 250);
  box-shadow: 0 0 8px rgb(167, 139, 250);
  animation: liveDot 1.6s ease-in-out infinite;
}
.badge-closed {
  background: rgba(255, 255, 255, 0.04);
  color: rgb(148 163 184);
  border-color: rgba(255, 255, 255, 0.08);
}
.badge-test {
  background: rgba(139, 92, 246, 0.12);
  color: rgb(196, 181, 253);
  border-color: rgba(139, 92, 246, 0.25);
}

/* PnL color + glow */
.pnl-pos { color: rgb(52, 211, 153); text-shadow: 0 0 12px rgba(52, 211, 153, 0.4); font-weight: 600; }
.pnl-neg { color: rgb(251, 113, 133); text-shadow: 0 0 12px rgba(251, 113, 133, 0.4); font-weight: 600; }

/* Action buttons */
.btn-row {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s;
  border: 1px solid;
}
.btn-close {
  background: linear-gradient(135deg, rgba(91, 111, 245, 0.2), rgba(139, 92, 246, 0.2));
  color: rgb(196, 181, 253);
  border-color: rgba(139, 92, 246, 0.35);
}
.btn-close:hover {
  background: linear-gradient(135deg, rgba(91, 111, 245, 0.35), rgba(139, 92, 246, 0.35));
  box-shadow: 0 0 16px -2px rgba(139, 92, 246, 0.5);
  transform: translateY(-1px);
}
.btn-reopen {
  background: rgba(255, 255, 255, 0.04);
  color: rgb(203 213 225);
  border-color: rgba(255, 255, 255, 0.08);
}
.btn-reopen:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

/* Stat-value gradient */
.stat-grad-pos { background: linear-gradient(135deg, #34d399, #10b981); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-grad-neg { background: linear-gradient(135deg, #fb7185, #f43f5e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-grad-neutral { background: linear-gradient(135deg, #c7d2fe, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Dialog */
::backdrop { background: rgba(7, 7, 19, 0.85); backdrop-filter: blur(8px); }
dialog[open] { animation: fadeUp 0.3s cubic-bezier(0.22, 1, 0.36, 1); }

/* Custom scrollbars */
.overflow-x-auto::-webkit-scrollbar,
.overflow-y-auto::-webkit-scrollbar,
.overflow-auto::-webkit-scrollbar { height: 8px; width: 8px; }
.overflow-x-auto::-webkit-scrollbar-track,
.overflow-y-auto::-webkit-scrollbar-track,
.overflow-auto::-webkit-scrollbar-track { background: transparent; }
.overflow-x-auto::-webkit-scrollbar-thumb,
.overflow-y-auto::-webkit-scrollbar-thumb,
.overflow-auto::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.2); border-radius: 4px; }
.overflow-x-auto::-webkit-scrollbar-thumb:hover,
.overflow-y-auto::-webkit-scrollbar-thumb:hover,
.overflow-auto::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.35); }
