/* ============================================
   TRADING CONTEST - Dashboard Layout
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Playfair+Display:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

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

/* ============================================
   Design Tokens
   ============================================ */
:root {
  /* Background Colors */
  --bg-deep: #0a0a0a;
  --bg-sidebar: #0f0f0f;
  --bg-main: #111111;
  --bg-card: #161616;
  --bg-card-hover: #1a1a1a;
  --bg-elevated: #1f1f1f;
  --bg-input: #0d0d0d;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Text */
  --text-primary: #fafafa;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-muted: rgba(255, 255, 255, 0.4);
  --text-faint: rgba(255, 255, 255, 0.2);

  /* Accent */
  --accent-gold: #f5a623;
  --accent-gold-soft: rgba(245, 166, 35, 0.12);
  --accent-gold-medium: rgba(245, 166, 35, 0.25);
  --profit: #10b981;
  --profit-soft: rgba(16, 185, 129, 0.1);
  --profit-medium: rgba(16, 185, 129, 0.2);
  --loss: #ef4444;
  --loss-soft: rgba(239, 68, 68, 0.1);
  --loss-medium: rgba(239, 68, 68, 0.2);

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-body: 'Inter', -apple-system, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Sizing */
  --sidebar-width: 64px;
  --header-height: 72px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Base
   ============================================ */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) 0;
  z-index: 100;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-gold) 0%, #e09000 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
  color: #000;
  margin-bottom: var(--space-xl);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.sidebar-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar-btn.active {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.sidebar-bottom {
  margin-top: auto;
}

#sidebar-user {
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================
   Freeze Banner
   ============================================ */
.freeze-banner {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.08) 100%);
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--loss);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.freeze-banner svg {
  flex-shrink: 0;
}

/* Push main content down when banner is visible */
.freeze-banner[style*="display: flex"] ~ .main-content {
  padding-top: 36px;
}

@media (max-width: 768px) {
  .freeze-banner {
    left: 0;
  }
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  background: var(--bg-main);
}

/* ============================================
   View System
   ============================================ */
.view {
  display: none;
  padding: var(--space-lg) var(--space-xl);
  animation: fadeIn var(--transition-slow);
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Header
   ============================================ */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.breadcrumb {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
  background: none;
  border: none;
  padding: 0;
  cursor: default;
}

.breadcrumb.clickable {
  cursor: pointer;
  transition: color var(--transition-fast);
}

.breadcrumb.clickable:hover {
  color: var(--text-primary);
}

.view-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

#user-status {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.user-email {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================
   Dashboard Grid
   ============================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-lg);
  align-items: start;
}

.stats-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.leaderboard-column,
.positions-column {
  min-width: 0;
}

/* ============================================
   Stat Cards
   ============================================ */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.stat-card.highlight {
  border-color: var(--profit-medium);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(16, 185, 129, 0.05) 100%);
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-badge {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.stat-value-large {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-bottom: var(--space-md);
}

.stat-value-large .stat-number {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-value-large .stat-suffix {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-value-large.positive .stat-number {
  color: var(--profit);
}

.stat-value-large.negative .stat-number {
  color: var(--loss);
}

.stat-chart {
  height: 48px;
  margin-bottom: var(--space-md);
  background: linear-gradient(90deg,
    transparent 0%,
    var(--profit-soft) 20%,
    var(--profit-medium) 40%,
    var(--profit-soft) 60%,
    transparent 100%
  );
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.stat-chart::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--profit);
  opacity: 0.5;
}

.stat-context {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

.stat-context-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-context-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.stat-item {
  text-align: center;
}

.stat-item-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.stat-item-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.card-header h2 {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-actions {
  display: flex;
  gap: var(--space-sm);
}

.card-body {
  padding: 0;
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Import Card */
.import-card {
  margin-bottom: var(--space-lg);
}

.import-card .card-header {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
}

.import-card .card-body {
  padding: var(--space-lg);
  padding-top: 0;
}

.import-card textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-primary);
  resize: vertical;
  min-height: 100px;
}

.import-card textarea::placeholder {
  color: var(--text-muted);
}

.import-card textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-soft);
}

.import-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.import-status {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.import-status.success {
  color: var(--profit);
}

.import-status.error {
  color: var(--loss);
}

/* ============================================
   Data Table
   ============================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th.col-rank { width: 70px; text-align: center; }
.data-table th.col-return { text-align: right; }
.data-table th.col-positions { text-align: center; width: 100px; }
.data-table th.col-spread { text-align: center; width: 80px; }
.data-table th.col-status { text-align: center; width: 140px; }

.spread-value { color: var(--text-muted); text-align: center; display: block; }

.data-table td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table cell styles */
.data-table td:first-child { text-align: center; }
.data-table td:nth-child(3) { text-align: right; }
.data-table td:nth-child(4) { text-align: center; }
.data-table td:nth-child(5) { text-align: center; }

/* Rank badge */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}

tr[data-rank="1"] .rank {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #e09000 100%);
  color: #000;
}

tr[data-rank="2"] .rank {
  background: linear-gradient(135deg, #a8a8a8 0%, #888 100%);
  color: #000;
}

tr[data-rank="3"] .rank {
  background: linear-gradient(135deg, #cd7f32 0%, #a66828 100%);
  color: #000;
}

/* Trader name */
.trader-name {
  font-weight: 500;
  color: var(--text-primary);
}

/* Return value */
.return-value {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
}

.return-value.positive { color: var(--profit); }
.return-value.negative { color: var(--loss); }

/* Stat value in table */
.stat-value {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: 4px;
}

.status-badge.open {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.status-badge.closed {
  background: var(--profit-soft);
  color: var(--profit);
}

.status-badge .progress {
  font-weight: 600;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

/* ============================================
   Position Cards
   ============================================ */
.position-card {
  border-bottom: 1px solid var(--border-subtle);
}

.position-card:last-child {
  border-bottom: none;
}

.position-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.position-header:hover {
  background: var(--bg-card-hover);
}

.position-info {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
}

.position-name {
  font-weight: 500;
  color: var(--text-primary);
}

.position-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.position-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.position-summary {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.leg-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.expand-icon {
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform var(--transition-fast);
}

.position-legs {
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
}

.leg-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}

.leg-item:last-child {
  margin-bottom: 0;
}

.leg-item.closed {
  opacity: 0.6;
}

.leg-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
}

.leg-ticker {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.leg-contract {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.leg-direction {
  display: inline-flex;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 4px;
}

.leg-direction.buy {
  background: var(--profit-soft);
  color: var(--profit);
}

.leg-direction.sell {
  background: var(--loss-soft);
  color: var(--loss);
}

.leg-quantity,
.leg-entry,
.leg-exit {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.leg-pl {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
}

.leg-pl.positive { color: var(--profit); }
.leg-pl.negative { color: var(--loss); }
.leg-pl.unrealized-positive { color: var(--profit); opacity: 0.8; }
.leg-pl.unrealized-negative { color: var(--loss); opacity: 0.8; }

.unrealized-label,
.live-label,
.frozen-label {
  font-size: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 2px;
  margin-left: 4px;
  vertical-align: middle;
}

.unrealized-label {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.live-label {
  background: var(--profit-soft);
  color: var(--profit);
}

.frozen-label {
  background: var(--loss-soft);
  color: var(--loss);
}

.leg-current {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--profit);
}

.closed-badge {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: 4px;
}

.leg-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.no-positions {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #e09000 100%);
  color: #000;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 166, 35, 0.3);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-remove:hover {
  background: var(--loss-soft);
  color: var(--loss);
}

.btn-close {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn-close:hover {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.btn-danger {
  background: var(--loss);
  color: #fff;
  font-weight: 600;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-edit,
.btn-delete {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-edit:hover {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.btn-delete:hover {
  background: var(--loss-soft);
  color: var(--loss);
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

input,
select {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-soft);
}

input::placeholder {
  color: var(--text-faint);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8.5L1.5 4h9L6 8.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-lg);
}

/* Legs section */
.legs-section {
  margin-top: var(--space-xl);
}

.legs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.legs-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

#legs-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.leg-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.leg-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  flex: 1;
}

.leg-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.leg-field label {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leg-field input,
.leg-field select {
  padding: 8px 10px;
  font-size: 0.8125rem;
}

.leg-field input.leg-ticker { width: 80px; font-family: var(--font-mono); text-transform: uppercase; }
.leg-field select.leg-type { width: 85px; }
.leg-field input.leg-strike { width: 85px; font-family: var(--font-mono); }
.leg-field input.leg-expiration { width: 130px; font-family: var(--font-mono); }
.leg-field select.leg-direction { width: 85px; }
.leg-field input.leg-quantity { width: 65px; font-family: var(--font-mono); }
.leg-field input.leg-entry { width: 90px; font-family: var(--font-mono); }

/* Price hint for market data */
.price-hint {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--text-muted);
}

.price-hint.loading {
  color: var(--text-faint);
}

.price-hint.success {
  color: var(--profit);
}

.price-hint.error {
  color: var(--loss);
}

.price-hint .price-data {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.btn-use-price {
  display: inline-flex;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 600;
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-use-price:hover {
  background: var(--accent-gold);
  color: #000;
}

/* Autocomplete dropdown */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.autocomplete-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.autocomplete-item:hover {
  background: var(--bg-elevated);
}

.autocomplete-symbol {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.autocomplete-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 150px;
}

/* Adjust leg field widths for new layout */
.leg-field-ticker {
  min-width: 140px;
}

.leg-field select.leg-expiration {
  width: 140px;
}

.leg-field select.leg-strike {
  width: 130px;
}

/* ============================================
   Auth
   ============================================ */
.auth-container {
  display: flex;
  justify-content: center;
  padding-top: var(--space-2xl);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
}

.auth-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-lg);
  background: var(--bg-elevated);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold);
}

.auth-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

.auth-card > p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: var(--space-xl);
}

.auth-card form {
  text-align: left;
}

.auth-card .form-group {
  margin-bottom: var(--space-md);
}

#auth-message {
  margin-top: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

#auth-message:empty {
  display: none;
}

#auth-message.success {
  background: var(--profit-soft);
  color: var(--profit);
}

#auth-message.error {
  background: var(--loss-soft);
  color: var(--loss);
}

/* ============================================
   Position Container
   ============================================ */
.position-container {
  max-width: 800px;
}

.position-container .card-body {
  padding: var(--space-lg);
}

.position-container .form-group {
  margin-bottom: var(--space-lg);
}

.position-container .legs-section {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
  z-index: 1000;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 90%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  transform: scale(0.95);
  transition: transform var(--transition-slow);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-body {
  padding: var(--space-lg);
}

.modal-body .form-group {
  margin-bottom: 0;
}

.modal-footer {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.modal-wide {
  max-width: 600px;
}

.edit-leg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-md);
}

.edit-leg-grid .form-group {
  margin-bottom: 0;
}

/* ============================================
   Utilities
   ============================================ */
.positive { color: var(--profit) !important; }
.negative { color: var(--loss) !important; }
.clickable-row { cursor: pointer; }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stats-column {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .view {
    padding: var(--space-md);
  }

  .stats-column {
    grid-template-columns: 1fr;
  }

  .view-header {
    flex-direction: column;
    gap: var(--space-md);
  }

  .stat-value-large .stat-number {
    font-size: 2rem;
  }

  .leg-row {
    flex-direction: column;
    align-items: stretch;
  }

  .leg-fields {
    flex-direction: column;
  }

  .leg-field {
    width: 100%;
  }

  .leg-field input,
  .leg-field select {
    width: 100% !important;
  }

  .btn-icon.btn-remove {
    align-self: flex-end;
  }

  .data-table th,
  .data-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.75rem;
  }

  .col-positions,
  .col-spread,
  .col-status {
    display: none;
  }
}
