/* ─── Design system matched to TrueCurrent Margin Dashboard ──────────────── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800;900&family=Syne:wght@400;500;600;700&display=swap');

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

:root {
  --bg-deep: #06080d;
  --bg-primary: #0a0e17;
  --bg-card: #0f1520;
  --bg-elevated: #151c2b;
  --bg-hover: #1a2338;
  --border-subtle: #1e2a3e;
  --border-active: #2a3a55;
  --text-primary: #e8ecf4;
  --text-secondary: #8a94a8;
  --text-muted: #5a6478;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --equity-color: #3b7ddd;
  --equity-dim: rgba(59, 125, 221, 0.15);
  --pe-color: #c084fc;
  --pe-dim: rgba(192, 132, 252, 0.12);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.15);
  --green: #22c55e;
  --red: #ef4444;
  --radius: 10px;
  --radius-sm: 6px;
}

html {
  font-size: 15px;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 60px;
}

.hidden {
  display: none !important;
}

/* ─── Loading ─────────────────────────────────────────────────────────────── */
#loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 80vh;
  gap: 20px;
}

.loader-ring {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loader-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
#header {
  margin-bottom: 32px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-left h1 {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 6px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.logo-mark {
  display: none;
}

.btn-refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-refresh.spinning svg {
  animation: spin 0.6s linear infinite;
}

/* ─── Summary Cards ───────────────────────────────────────────────────────── */
#summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 22px 26px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s;
}

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

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.card-total::before {
  background: var(--accent);
}

.card-equity::before {
  background: var(--equity-color);
}

.card-pe::before {
  background: var(--pe-color);
}

.card-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  margin-bottom: 10px;
}

.card-value {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.card-total .card-value {
  color: var(--text-primary);
}

.card-equity .card-value {
  color: var(--equity-color);
}

.card-pe .card-value {
  color: var(--pe-color);
}

.card-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
}

.divider {
  opacity: 0.3;
}

/* ─── Controls ────────────────────────────────────────────────────────────── */
#controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.period-tabs,
.category-filter {
  display: flex;
  align-items: center;
  gap: 0;
}

.period-tabs .tab-label,
.category-filter .filter-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 10px;
  font-weight: 500;
}

.tab,
.filter-btn {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
  margin-left: -1px;
}

.tab:first-of-type,
.filter-btn:first-of-type {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  margin-left: 0;
}

.tab:last-of-type,
.filter-btn:last-of-type {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.tab:only-of-type,
.filter-btn:only-of-type {
  border-radius: var(--radius-sm);
}

.tab:hover,
.filter-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
  z-index: 1;
}

.tab.active {
  background: var(--accent);
  color: #06080d;
  border-color: var(--accent);
  font-weight: 600;
  z-index: 2;
}

.filter-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent);
  z-index: 2;
}

/* ─── Table ────────────────────────────────────────────────────────────────── */
#table-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.table-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.table-header .market-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

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

#markets-table th {
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
  white-space: nowrap;
}

#markets-table th.sortable {
  cursor: pointer;
  transition: color 0.2s;
}

#markets-table th.sortable:hover,
#markets-table th.active-sort {
  color: var(--accent);
}

.th-rank {
  width: 50px;
  text-align: center;
}

.th-cat {
  width: 120px;
}

.th-vol {
  width: 130px;
  text-align: right;
  padding-right: 20px;
}

.th-trades {
  width: 90px;
  text-align: right;
  padding-right: 20px;
}

.th-bar {
  width: 190px;
}

.th-start {
  width: 110px;
  text-align: right;
}

#markets-table td {
  padding: 14px 20px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s;
}

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

#markets-table tbody tr {
  transition: background 0.15s;
}

#markets-table tbody tr:hover {
  background: var(--bg-hover);
}

.td-rank {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.td-ticker {
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.td-cat {
  font-size: 0.75rem;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-equity {
  background: var(--equity-dim);
  color: var(--equity-color);
  border: 1px solid rgba(59, 125, 221, 0.3);
}

.badge-pe {
  background: var(--pe-dim);
  color: var(--pe-color);
  border: 1px solid rgba(192, 132, 252, 0.3);
}

.td-vol {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
}

.td-trades {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.td-start {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.td-bar {
  padding-right: 24px;
}

.vol-bar-container {
  width: 100%;
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.vol-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 2px;
}

.vol-bar-equity {
  background: linear-gradient(90deg, var(--equity-color), rgba(59, 125, 221, 0.4));
}

.vol-bar-pe {
  background: linear-gradient(90deg, var(--pe-color), rgba(192, 132, 252, 0.4));
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */
#footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
}

#footer strong {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Row Entrance Animation ──────────────────────────────────────────────── */
@keyframes fadeInRow {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.row-animate {
  animation: fadeInRow 0.25s ease-out both;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #summary-cards {
    grid-template-columns: 1fr;
  }

  #controls {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .th-bar,
  .td-bar {
    display: none;
  }

  .th-start,
  .td-start {
    display: none;
  }

  .header-left h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  #app {
    padding: 16px 12px 32px;
  }

  .card {
    padding: 16px;
  }

  .card-value {
    font-size: 1.5rem;
  }
}