/* ═══════════════════════════════════════════════════════════════════════
   Alpha by Opsynx AI — Dashboard
   Brand: Space Grotesk / Inter · #d40c1a red · #000 dark
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --bg:         #000000;
  --surface:    #0a0a0a;
  --surface-2:  #111111;
  --surface-3:  #1a1a1a;
  --border:     #222222;
  --border-hi:  #333333;
  --text:       #f0f0f0;
  --text-2:     #999999;
  --dim:        #666666;
  --red:        #d40c1a;
  --red-glow:   rgba(212, 12, 26, 0.15);
  --red-border: rgba(212, 12, 26, 0.4);
  --green:      #37ca37;
  --green-dim:  rgba(55, 202, 55, 0.12);
  --red-dim:    rgba(212, 12, 26, 0.12);
  --neg-color:  #f85149;
  --font-head:  'Space Grotesk', -apple-system, sans-serif;
  --font-body:  'Inter', -apple-system, sans-serif;
  --mono:       'Space Grotesk', ui-monospace, SFMono-Regular, monospace;
  --radius:     12px;
  --radius-sm:  8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--text);
}

.brand-mark.small { font-size: 13px; gap: 5px; }

.brand-icon {
  color: var(--red);
  font-size: 1.2em;
}

.brand-ai {
  color: var(--red);
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: var(--border-hi);
}

.brand-product {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s ease-in-out infinite;
}

.pulse-dot.paused {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
  animation: pulse-red 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--green); }
  50% { opacity: 0.5; box-shadow: 0 0 16px var(--green); }
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--red); }
  50% { opacity: 0.5; box-shadow: 0 0 16px var(--red); }
}

.live-text {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--green);
}

.live-text.paused { color: var(--red); }

.last-updated {
  font-size: 11px;
  color: var(--dim);
  font-family: var(--mono);
}

/* ── Main ────────────────────────────────────────────────────────────── */
main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px 28px 48px;
}

/* ── Metric cards ────────────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 36px;
}

.metric-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.3s ease;
}

.metric-card:hover {
  border-color: var(--border-hi);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.metric-card.highlight {
  border-color: var(--red-border);
  background: linear-gradient(170deg, var(--red-glow) 0%, var(--surface-2) 40%);
}

.metric-card.highlight::before { background: var(--red); }

.metric-card.card-pos { border-color: rgba(55, 202, 55, 0.3); }
.metric-card.card-pos::before { background: var(--green); }
.metric-card.card-neg { border-color: var(--red-border); }
.metric-card.card-neg::before { background: var(--neg-color); }

.metric-label {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin-bottom: 12px;
}

.metric-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  transition: color 0.3s ease;
}

.metric-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  margin-top: 8px;
}

.tau {
  font-weight: 400;
  color: var(--dim);
  margin-left: 3px;
  font-size: 0.7em;
}

/* Flash animation on data refresh */
@keyframes flash-in {
  0% { color: var(--red); }
  100% { color: inherit; }
}
.flash { animation: flash-in 0.6s ease; }

/* ── Panel (sections) ────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin: 0;
}

.badge-count {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  background: var(--red-glow);
  color: var(--red);
  border: 1px solid var(--red-border);
  padding: 2px 9px;
  border-radius: 20px;
}

/* ── Position cards ─────────────────────────────────────────────────── */
.positions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 20px 24px;
}

.position-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.position-card:hover {
  border-color: var(--red-border);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.pos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-3);
}

.pos-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pos-uid {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
}

.pos-label {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.pos-pnl {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
}

.pos-pnl.pos { background: var(--green-dim); color: var(--green); }
.pos-pnl.neg { background: var(--red-dim); color: var(--neg-color); }

.pos-body { padding: 12px 16px; }

.pos-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
}

.pos-key {
  color: var(--text-2);
  font-weight: 500;
}

.pos-val {
  font-family: var(--mono);
  font-weight: 500;
}

.pos-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-3);
}

.pos-score {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.staked-total {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  font-family: var(--font-body);
  background: var(--surface-3);
}

.staked-total strong {
  color: var(--text);
  font-family: var(--mono);
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}

th {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  background: var(--surface-3);
  position: sticky;
  top: 0;
}

tr:last-child td { border-bottom: none; }

.trade-row {
  transition: background 0.15s ease;
}

.trade-row:hover td { background: var(--surface-2); }

/* Action badges */
.action-badge {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--dim);
}

.action-badge.entry {
  color: var(--green);
  background: var(--green-dim);
  border-color: rgba(55, 202, 55, 0.3);
}

.action-badge.exit {
  color: var(--neg-color);
  background: var(--red-dim);
  border-color: var(--red-border);
}

.action-badge.skip {
  color: #d29922;
  background: rgba(210, 153, 34, 0.1);
  border-color: rgba(210, 153, 34, 0.3);
}

.sn-tag {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--red);
}

.reason-cell {
  white-space: normal;
  max-width: 240px;
  word-break: break-word;
}

.result-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Shared ──────────────────────────────────────────────────────────── */
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--dim) !important; }
.pos { color: var(--green) !important; }
.neg { color: var(--neg-color) !important; }

.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--dim);
  font-size: 14px;
}

/* ── Footer ──────────────────────────────────────────────────────────── */
footer {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 28px 40px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--dim);
  flex-wrap: wrap;
}

.footer-sep { color: var(--border-hi); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .topbar-inner { padding: 0 16px; height: 52px; }
  .brand-divider, .brand-product { display: none; }
  .last-updated { display: none; }
  main { padding: 20px 16px 36px; }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .metric-card { padding: 16px 18px; }
  .metric-value { font-size: 22px; }
  .metric-sub { font-size: 11px; }

  .positions-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 16px;
  }

  .panel-header { padding: 14px 16px; }
  th, td { padding: 10px 12px; font-size: 12px; }
  .reason-cell { max-width: 160px; }
}

@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr; }
  .metric-value { font-size: 26px; }
  .brand-mark { font-size: 15px; }
}

/* ── Live trades terminal ─────────────────────────────────────────────── */
.terminal-panel .panel-header {
  justify-content: space-between;
}

.terminal-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-dot.small {
  width: 6px;
  height: 6px;
}

.terminal-label {
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--green);
}

.terminal {
  background: #050505;
  padding: 16px 20px;
  max-height: 340px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  scroll-behavior: smooth;
  border-top: 1px solid #111;
}

/* Custom scrollbar for terminal */
.terminal::-webkit-scrollbar { width: 6px; }
.terminal::-webkit-scrollbar-track { background: transparent; }
.terminal::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }
.terminal::-webkit-scrollbar-thumb:hover { background: var(--dim); }

.terminal-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  white-space: nowrap;
  overflow: hidden;
}

.terminal-line.new {
  animation: termSlideIn 0.35s ease both;
  background: rgba(212, 12, 26, 0.06);
}

@keyframes termSlideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); background: transparent; }
}

.term-ts {
  color: var(--dim);
  font-size: 11px;
  min-width: 60px;
}

.term-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 8px;
  border-radius: 3px;
  min-width: 50px;
  text-align: center;
  background: var(--surface-3);
  color: var(--dim);
  border: 1px solid var(--border);
}

.term-badge.entry {
  color: var(--green);
  background: var(--green-dim);
  border-color: rgba(55, 202, 55, 0.25);
}

.term-badge.exit {
  color: var(--neg-color);
  background: var(--red-dim);
  border-color: var(--red-border);
}

.term-badge.skip {
  color: #d29922;
  background: rgba(210, 153, 34, 0.1);
  border-color: rgba(210, 153, 34, 0.25);
}

.term-sn {
  color: var(--red);
  font-weight: 700;
  min-width: 40px;
}

.term-name {
  color: var(--text-2);
  min-width: 100px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.term-amt {
  color: var(--text);
  font-weight: 600;
  min-width: 80px;
  text-align: right;
}

.term-result {
  color: var(--dim);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.term-msg { flex: 1; }

@media (max-width: 768px) {
  .terminal { font-size: 11px; padding: 12px 14px; max-height: 260px; }
  .terminal-line { gap: 6px; }
  .term-name { display: none; }
  .term-result { display: none; }
}

/* ── Entrance animations ─────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.metric-card {
  animation: fadeUp 0.5s ease both;
}

.metric-card:nth-child(1) { animation-delay: 0.05s; }
.metric-card:nth-child(2) { animation-delay: 0.1s; }
.metric-card:nth-child(3) { animation-delay: 0.15s; }
.metric-card:nth-child(4) { animation-delay: 0.2s; }
.metric-card:nth-child(5) { animation-delay: 0.25s; }

.position-card {
  animation: fadeUp 0.4s ease both;
}

.position-card:nth-child(1) { animation-delay: 0.1s; }
.position-card:nth-child(2) { animation-delay: 0.15s; }
.position-card:nth-child(3) { animation-delay: 0.2s; }
.position-card:nth-child(4) { animation-delay: 0.25s; }
.position-card:nth-child(5) { animation-delay: 0.3s; }
.position-card:nth-child(6) { animation-delay: 0.35s; }

.trade-row {
  animation: fadeUp 0.3s ease both;
}

.trade-row:nth-child(n) { animation-delay: calc(0.05s * var(--i, 0)); }
