/* ══════════════════════════════════════════════════════════════════
   Raven Trader Dashboard — dark theme, polished, no framework
   ══════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Mokoto';
  src: url('/static/fonts/Mokoto-Demo.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b0d12;
  --bg-elevated: #12151c;
  --bg-hover: #1a1e27;
  --border: #22262f;
  --border-light: #2a2f3a;
  --text: #e6e8ec;
  --text-dim: #8a8f9a;
  --text-faint: #5c6270;
  --green: #22c55e;
  --green-dim: #16a34a;
  --green-bg: rgba(34, 197, 94, 0.08);
  --red: #ef4444;
  --red-dim: #dc2626;
  --red-bg: rgba(239, 68, 68, 0.08);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.08);
  --gold: #eab308;
  --blue: #3b82f6;
  --purple: #a855f7;
  --accent: #22c55e;
  --mono: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar — bigger, with logo ────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(10px);
}

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

.brand-logo {
  width: 64px;
  height: 64px;
  display: block;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-title {
  font-family: 'Mokoto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 38px;
  font-weight: 400;
  letter-spacing: 4px;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 20px rgba(234, 179, 8, 0.2);
}

.brand-sub {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-faint);
  text-transform: uppercase;
  font-weight: 500;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.status .divider {
  color: var(--text-faint);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot.online {
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse 2s ease-in-out infinite;
}

.dot.offline {
  background: var(--red);
  animation: pulse 4s ease-in-out infinite;
}

.dot.idle {
  background: var(--amber);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

.mode {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.mode.paper {
  background: rgba(59, 130, 246, 0.2);
  color: var(--blue);
}

.mode.live {
  background: var(--red-bg);
  color: var(--red);
}

/* ── Main layout — 2-column: main content left, activity feed right ── */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  padding: 20px 28px;
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.main-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.side-col {
  position: sticky;
  top: 130px;
}

/* ── Stat cards ─────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: var(--border-light);
}

.stat-label {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 600;
}

.stat-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  margin-top: 4px;
  color: var(--text);
  transition: color 0.5s, background-color 0.5s;
  padding: 2px 0;
  border-radius: 4px;
}

.stat-value.up { color: var(--green); }
.stat-value.down { color: var(--red); }

.stat-value.flash-up { background: var(--green-bg); animation: flash 800ms ease-out; }
.stat-value.flash-down { background: var(--red-bg); animation: flash 800ms ease-out; }

@keyframes flash {
  0% { background-color: var(--green-bg); }
  100% { background-color: transparent; }
}

.stat-sub {
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--mono);
  margin-top: 2px;
}

.stat-sub.up { color: var(--green); }
.stat-sub.down { color: var(--red); }

/* ── Panels ─────────────────────────────────────────────────── */

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.panel-sub {
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--mono);
}

.panel-body {
  padding: 12px 18px 16px;
}

.empty {
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* ── Winners grid (full-width layout) ───────────────────────── */

.winners-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.winner-card {
  padding: 14px 16px;
  border-left: 3px solid var(--green);
  background: var(--green-bg);
  border-radius: 4px;
  transition: all 0.3s ease;
}

.winner-card:hover {
  background: rgba(34, 197, 94, 0.12);
}

.winner-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.winner-symbol {
  font-weight: 700;
  font-size: 15px;
}

.winner-pnl {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
}

.winner-pnl .amount {
  color: var(--green);
  font-weight: 600;
}

.winner-pnl .pct {
  color: var(--green);
  font-weight: 600;
}

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

.sparkline {
  margin: 8px 0;
  height: 48px;
}

.winner-foot {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
}

/* ── Tables ─────────────────────────────────────────────────── */

.holdings-table, .signals-table, .orders-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}

.holdings-table th, .signals-table th, .orders-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.holdings-table td, .signals-table td, .orders-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.holdings-table tr:last-child td,
.signals-table tr:last-child td,
.orders-table tr:last-child td {
  border-bottom: none;
}

.holdings-table tr:hover td,
.signals-table tr:hover td,
.orders-table tr:hover td {
  background: var(--bg-hover);
}

.holdings-table .pnl-up, .signals-table .pnl-up { color: var(--green); }
.holdings-table .pnl-down, .signals-table .pnl-down { color: var(--red); }

.sym {
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.side-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.side-badge.buy { background: var(--green-bg); color: var(--green); }
.side-badge.sell { background: var(--red-bg); color: var(--red); }

.status-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.status-badge.filled { background: var(--green-bg); color: var(--green); }
.status-badge.pending { background: var(--amber-bg); color: var(--amber); }
.status-badge.rejected { background: var(--red-bg); color: var(--red); }

.signal-badge {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.signal-badge.buy { background: var(--green-bg); color: var(--green); }
.signal-badge.sell { background: var(--red-bg); color: var(--red); }
.signal-badge.hold { background: rgba(138, 143, 154, 0.1); color: var(--text-dim); }

/* Score bars in signals table */
.score-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-bar {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
  border-radius: 2px;
  transition: width 0.5s ease;
}

.score-val {
  font-weight: 600;
  min-width: 20px;
}

/* ── Activity feed (compact, in top-row) ────────────────────── */

.feed-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 150px);
  overflow: hidden;
}

.feed-body {
  overflow-y: auto;
  padding: 0;
  flex: 1;
}

.feed-body::-webkit-scrollbar { width: 6px; }
.feed-body::-webkit-scrollbar-track { background: var(--bg-elevated); }
.feed-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.feed-event {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  animation: slide-in 400ms ease-out;
  transition: background 0.2s;
}

.feed-event:hover {
  background: var(--bg-hover);
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
    background: var(--bg-hover);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    background: transparent;
  }
}

.feed-event .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.feed-event .icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.feed-event .headline {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.feed-event .time {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  flex-shrink: 0;
}

.feed-event .detail {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 24px;
  line-height: 1.4;
  font-family: var(--mono);
}

.feed-event.level-trade {
  border-left: 3px solid var(--green);
  padding-left: 13px;
}

.feed-event.level-success {
  border-left: 3px solid var(--green);
  padding-left: 13px;
}

.feed-event.level-warn {
  border-left: 3px solid var(--amber);
  padding-left: 13px;
}

.feed-event.level-error {
  border-left: 3px solid var(--red);
  padding-left: 13px;
}

/* ── Sound toggle ───────────────────────────────────────────── */

.sound-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.sound-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.sound-btn.active {
  color: var(--green);
  border-color: var(--green);
}

/* ── Footer ─────────────────────────────────────────────────── */

.footer {
  padding: 20px 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.footer .divider { margin: 0 8px; }
