/* =========================================
   TradePlatform — Complete CSS
   Dark trading theme, no build tools
   ========================================= */

/* --- CSS Custom Properties (Default Theme) --- */
:root {
  --color-background: oklch(0.13 0.005 250);
  --color-foreground: oklch(0.95 0.01 250);
  --color-brand: oklch(0.65 0.18 250);
  --color-brand-light: oklch(0.75 0.14 250);
  --color-brand-dark: oklch(0.50 0.18 250);
  --color-profit: oklch(0.72 0.19 155);
  --color-loss: oklch(0.65 0.22 25);
  --color-warning: oklch(0.78 0.16 85);
  --color-surface: oklch(0.16 0.005 250);
  --color-raised: oklch(0.19 0.005 250);
  --color-overlay: oklch(0.22 0.005 250);
  --color-hover: oklch(0.25 0.008 250);
  --color-border-subtle: oklch(0.22 0.005 250);
  --color-border: oklch(0.28 0.008 250);
  --color-border-strong: oklch(0.38 0.01 250);
  --color-text-primary: oklch(0.95 0.01 250);
  --color-text-secondary: oklch(0.70 0.02 250);
  --color-text-muted: oklch(0.50 0.015 250);
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

/* --- Base / Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: inherit;
}

img, svg {
  display: block;
}

button {
  font-family: inherit;
}

/* --- Auth Layout --- */
#auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#auth-layout > div {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--color-text-primary);
  margin-bottom: 2rem;
}

#auth-content {
  width: 100%;
}

.auth-card {
  background-color: var(--color-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 2rem;
}

.auth-card > * + * {
  margin-top: 1rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--color-text-primary);
}

.auth-subtitle {
  font-size: 0.875rem;
  text-align: center;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

.auth-link {
  color: var(--color-brand);
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

/* --- Trader Layout --- */
#trader-layout {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */
#sidebar {
  width: 240px;
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  height: 3.5rem;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-subtle);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--color-border-subtle);
}

/* --- Navigation Links --- */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  color: var(--color-text-secondary);
  transition: background-color 0.15s, color 0.15s;
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background-color: var(--color-hover);
  color: var(--color-text-primary);
}

.nav-link.active {
  background-color: oklch(0.65 0.18 250 / 15%);
  color: var(--color-brand-light);
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Main Area --- */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* --- Header --- */
#header {
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border-subtle);
  background-color: var(--color-surface);
  padding: 0 1rem;
}

@media (min-width: 768px) {
  #header {
    padding: 0 1.5rem;
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  margin-right: 0.5rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-label {
  color: var(--color-text-muted);
  font-size: 10px;
}

.stat-value {
  font-family: var(--font-mono);
  color: var(--color-text-primary);
}

/* --- Page Content --- */
#page-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Trade terminal needs the page-content locked to viewport height (no scroll) */
#page-content.page-trade {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Sidebar Overlay (Mobile) --- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background-color: oklch(0 0 0 / 50%);
  z-index: 40;
}

.mobile-menu-btn {
  display: none !important;
}
@media (max-width: 767px) {
  .mobile-menu-btn {
    display: inline-flex !important;
  }
}

@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  #sidebar.open {
    transform: translateX(0);
  }
}


/* --- Cards --- */
.card {
  background-color: var(--color-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.card-xl {
  background-color: var(--color-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
}

.card > .card-header,
.card-xl > .card-header {
  border-bottom: 1px solid var(--color-border-subtle);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-weight: 600;
  color: var(--color-text-primary);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  border: none;
  font-family: var(--font-sans);
  gap: 0.5rem;
}

.btn-brand {
  background-color: var(--color-brand);
  color: white;
}

.btn-brand:hover {
  background-color: var(--color-brand-dark);
}

.btn-profit {
  background-color: var(--color-profit);
  color: white;
}

.btn-profit:hover {
  opacity: 0.9;
}

.btn-loss {
  background-color: var(--color-loss);
  color: white;
}

.btn-loss:hover {
  opacity: 0.9;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.btn-outline:hover {
  background-color: var(--color-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background-color: var(--color-hover);
  color: var(--color-text-primary);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-text-secondary);
}

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

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

/* --- Inputs --- */
.input {
  width: 100%;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px oklch(0.65 0.18 250 / 20%);
}

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

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
}

.data-table tr:hover {
  background-color: oklch(0.25 0.008 250 / 50%);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-blue {
  background-color: oklch(0.65 0.18 250 / 15%);
  color: var(--color-brand-light);
}

.badge-green {
  background-color: oklch(0.72 0.19 155 / 15%);
  color: var(--color-profit);
}

.badge-red {
  background-color: oklch(0.65 0.22 25 / 15%);
  color: var(--color-loss);
}

.badge-amber {
  background-color: oklch(0.78 0.16 85 / 15%);
  color: var(--color-warning);
}

.badge-muted {
  background-color: var(--color-overlay);
  color: var(--color-text-muted);
}

/* --- Toasts --- */
#toasts {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  color: white;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s, transform 0.3s;
}

.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background-color: var(--color-profit);
}

.toast-error {
  background-color: var(--color-loss);
}

.toast-info {
  background-color: var(--color-brand);
}

.toast-warning {
  background-color: var(--color-warning);
}

/* --- Text Utilities --- */
.text-profit { color: var(--color-profit); }
.text-loss { color: var(--color-loss); }
.text-warning { color: var(--color-warning); }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-brand { color: var(--color-brand); }

.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }

.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* --- Layout Utilities --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

.w-full { width: 100%; }
.hidden { display: none; }

/* --- Spacing Utilities --- */
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }

.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.ml-2 { margin-left: 0.5rem; }

.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }

/* --- Miscellaneous --- */
.skeleton {
  background-color: var(--color-overlay);
  border-radius: var(--radius);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.rounded-full { border-radius: 9999px; }

.border-t { border-top: 1px solid var(--color-border-subtle); }
.border-b { border-bottom: 1px solid var(--color-border-subtle); }

/* --- Order Book --- */
.order-book-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 0.125rem 0.75rem;
  font-size: 0.75rem;
  position: relative;
}

.order-book-row .bar {
  position: absolute;
  inset-block: 0;
  right: 0;
  opacity: 0.1;
}

.order-book-spread {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.375rem;
  border-top: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
  background-color: var(--color-surface);
}

/* --- Order Form --- */
.order-form .field-group {
  margin-bottom: 0;
}

.order-form .field-group > * + * {
  margin-top: 0.25rem;
}

.order-form .field-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* --- Market List --- */
.market-section { border-bottom: 1px solid var(--color-border-subtle); }
.market-section:last-child { border-bottom: none; }

.market-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  user-select: none;
}
.market-section-header:hover { background-color: var(--color-hover); }

.market-my-section .market-section-header { cursor: default; }
.market-my-section .market-section-header:hover { background: none; }

.market-section-title {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  flex: 1;
}
.market-my-section .market-section-title { color: var(--color-brand); }

.market-section-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.market-section-count {
  font-size: 0.625rem;
  color: var(--color-text-muted);
  background: var(--color-overlay);
  border-radius: 999px;
  padding: 0 0.35rem;
  line-height: 1.6;
}
.market-section-arrow {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  width: 12px;
  text-align: center;
}

.market-section-items { overflow: hidden; }
.market-section-items.collapsed { display: none; }

.market-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.25rem 0.75rem;
}

.market-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.375rem 0.5rem 0.375rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s;
  border-left: 2px solid transparent;
}
.market-item:hover { background-color: var(--color-hover); }
.market-item.active {
  border-left-color: var(--color-brand);
  background-color: oklch(0.65 0.18 250 / 5%);
}

.market-item-left {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.market-item-symbol {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.market-item-name {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.market-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}
.market-item-price { font-size: 0.7rem; line-height: 1.2; }
.market-item-change { font-size: 0.6rem; line-height: 1.2; }

.pin-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
}
.market-item:hover .pin-btn { opacity: 0.5; }
.pin-btn.active { opacity: 1; color: var(--color-brand); }
.pin-btn:hover { opacity: 1 !important; color: var(--color-brand); }

/* legacy .market-category kept for backward compat */
.market-category {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 0.375rem 0.75rem;
}

/* --- Chart / Timeframe Bar --- */
.timeframe-bar {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.tf-btn {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background-color 0.15s, color 0.15s;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
}

.tf-btn:hover {
  color: var(--color-text-primary);
  background-color: var(--color-hover);
}

.tf-btn.active {
  background-color: var(--color-brand);
  color: white;
}

/* --- Chart indicators (#52) --- */
.indicator-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--color-border-subtle);
  flex-wrap: wrap;
}
.indicator-add-wrap {
  position: relative;
}
.indicator-add {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  border-radius: var(--radius);
  background: transparent;
  border: 1px dashed var(--color-border-subtle);
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
}
.indicator-add:hover {
  color: var(--color-text-primary);
  border-color: var(--color-text-muted);
}
.indicator-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.25rem;
  z-index: 10;
  background: var(--color-bg-elevated, #1a1f2a);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  min-width: 7rem;
  overflow: hidden;
}
.indicator-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  cursor: pointer;
}
.indicator-menu-item:hover {
  background-color: var(--color-hover);
}
.indicator-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.indicator-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  font-family: var(--font-sans);
  border: 1px solid;
  border-radius: 999px;
  background: transparent;
}
.indicator-chip-x {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.7;
}
.indicator-chip-x:hover { opacity: 1; }

/* Indicator parameter modal (#53) */
.indicator-modal[hidden] { display: none; }
.indicator-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}
.indicator-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.indicator-modal-content {
  position: relative;
  z-index: 1;
  background: var(--color-bg-elevated, #1a1f2a);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  min-width: 14rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.indicator-modal-title {
  margin: 0 0 0.6rem 0;
  font-size: 0.95rem;
  color: var(--color-text-primary);
}
.indicator-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}
.indicator-modal-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.indicator-modal-field input[type="number"] {
  width: 5rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.indicator-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}
.indicator-modal-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-subtle);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}
.indicator-modal-btn:hover {
  color: var(--color-text-primary);
}
.indicator-modal-btn.primary {
  background-color: var(--color-brand);
  color: white;
  border-color: var(--color-brand);
}
.indicator-modal-btn.primary:hover { opacity: 0.9; }

/* --- Trade Terminal Layout --- */
.trade-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.trade-left {
  width: 256px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border-subtle);
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
}
.trade-left::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.trade-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.trade-right {
  width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--color-border-subtle);
  overflow-y: auto;
  padding: 1rem;
}

.trade-right > * + * {
  margin-top: 1rem;
}

.trade-tabs {
  border-top: 1px solid var(--color-border-subtle);
}

.trade-tabs-header {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

.tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--color-text-primary);
}

.tab-btn.active {
  color: var(--color-text-primary);
  border-bottom-color: var(--color-brand);
}

.tab-content {
  height: 192px;
  overflow-y: auto;
}

@media (max-width: 767px) {
  .trade-left {
    display: none;
  }

  .trade-right {
    display: none;
  }
}

/* --- Challenge Specific --- */
.gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.25rem;
}

.calendar-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  position: relative;
}

.faq-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background-color: var(--color-raised);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.875rem;
}

.faq-answer {
  border-top: 1px solid var(--color-border-subtle);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

/* --- Challenge Health Bar --- */
.challenge-health {
  height: 40px;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1rem;
}

.health-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.health-bar {
  width: 80px;
  height: 6px;
  background-color: var(--color-overlay);
  border-radius: 9999px;
  overflow: hidden;
}

.health-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* --- Hide lightweight-charts branding --- */
a[href*="tradingview"] { display: none !important; }

/* --- Loading Spinner --- */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* --- Responsive --- */
@media (max-width: 639px) {
  .hide-mobile {
    display: none;
  }
}

@media (min-width: 768px) {
  .md-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .md-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .lg-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .lg-grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1280px) {
  .xl-grid-5 {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Responsive combo grids: desktop-tablet-mobile */
.grid-4-2-1 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid-3-2-1 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid-2-1   { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid-5-3-1 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid-3-1   { display: grid; gap: 1rem; grid-template-columns: 1fr; }

@media (min-width: 640px) {
  .grid-4-2-1 { grid-template-columns: repeat(2, 1fr); }
  .grid-3-2-1 { grid-template-columns: repeat(2, 1fr); }
  .grid-5-3-1 { grid-template-columns: repeat(3, 1fr); }
  .grid-3-1   { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .grid-4-2-1 { grid-template-columns: repeat(4, 1fr); }
  .grid-3-2-1 { grid-template-columns: repeat(3, 1fr); }
  .grid-2-1   { grid-template-columns: 2fr 1fr; }
  .grid-5-3-1 { grid-template-columns: repeat(5, 1fr); }
}

/* --- Shop Plans Grid --- */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}
@media (min-width: 640px) { .plans-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .plans-grid { grid-template-columns: repeat(3, 1fr); } }

.plan-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.plan-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.plan-popular {
  border: 2px solid var(--color-brand);
  position: relative;
}
.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-brand);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.75rem;
  border-radius: 9999px;
  text-transform: uppercase;
  white-space: nowrap;
}
.plan-details {
  width: 100%;
  margin: 1rem 0;
}
.plan-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: 0.875rem;
}
.plan-row:last-child { border-bottom: none; }

.rules-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
  text-align: left;
}
@media (min-width: 640px) { .rules-grid { grid-template-columns: repeat(2, 1fr); } }

/* --- Calendar Grid --- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}
.calendar-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  min-height: 24px;
}

/* --- History Stats Grid --- */
@media (min-width: 640px) {
  .grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .grid-cols-2.lg\\:grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
}

/* --- Text Warning Color --- */
.text-warning { color: var(--color-warning, #eab308); }
.text-primary { color: var(--color-brand); }

/* --- Dashboard Market Overview --- */
.market-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
@media (min-width: 768px) { .market-overview-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .market-overview-grid { grid-template-columns: repeat(4, 1fr); } }

.market-overview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  background: var(--color-surface-2, rgba(255,255,255,0.03));
  color: inherit;
  transition: background 0.15s;
  gap: 0.5rem;
}
.market-overview-item:hover {
  background: var(--color-overlay, rgba(255,255,255,0.06));
}
.market-overview-link {
  display: flex;
  flex: 1;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.favorite-toggle {
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.25rem;
  color: var(--color-text-muted, #9ca3af);
  transition: color 0.15s ease, transform 0.1s ease;
}
.favorite-toggle:hover { transform: scale(1.15); }
.favorite-toggle.is-fav { color: var(--color-brand, #22c55e); }

/* --- Market Sessions (#12) --- */
.sessions-card .sessions-group { margin-bottom: 1rem; }
.sessions-card .sessions-group:last-child { margin-bottom: 0; }
.sessions-card .sessions-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted, #9ca3af);
  margin-bottom: 0.5rem;
}
.session-row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border-subtle, rgba(255,255,255,0.05));
}
.session-row:last-child { border-bottom: 0; }
.session-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.session-dot-open    { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.55); }
.session-dot-closed  { background: rgba(255,255,255,0.2); }
.session-name { font-weight: 600; font-size: 0.9rem; }
.session-hours-local { display: block; font-size: 0.7rem; opacity: 0.7; }
.session-status { font-size: 0.75rem; font-weight: 600; }
@media (max-width: 480px) {
  .session-hours-local { display: none; }
}

/* Markets card "Show all" — turn the grid into a scrollable column
   so the card doesn't push the entire dashboard down 30 rows. */
.market-overview-grid.markets-expanded {
  grid-template-columns: 1fr !important;
  max-height: 480px;
  overflow-y: auto;
}
@media (min-width: 768px) {
  .market-overview-grid.markets-expanded { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (min-width: 1200px) {
  .market-overview-grid.markets-expanded { grid-template-columns: repeat(3, 1fr) !important; }
}

/* --- Dashboard Scrolling Ticker --- */
.ticker-bar {
  width: 100%;
  overflow: hidden;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-subtle);
  position: relative;
}
.ticker-bar::before,
.ticker-bar::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  z-index: 2;
  pointer-events: none;
}
.ticker-bar::before {
  left: 0;
  background: linear-gradient(to right, var(--color-surface), transparent);
}
.ticker-bar::after {
  right: 0;
  background: linear-gradient(to left, var(--color-surface), transparent);
}
.ticker-track {
  display: flex;
  will-change: transform;
}
.ticker-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-right: 1px solid var(--color-border-subtle);
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
  transition: background 0.15s;
}
.ticker-item:hover {
  background: var(--color-hover);
}
.ticker-symbol {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--color-text-primary);
  min-width: 56px;
}
.ticker-price {
  font-size: 0.8rem;
  color: var(--color-text-primary);
}
.ticker-change {
  font-size: 0.7rem;
}
.ticker-spark {
  display: block;
}

/* --- Dashboard Content Area --- */
.dash-content {
  padding: 1.5rem;
  max-width: 1200px;
}

/* --- Dashboard Hero Card --- */
.dash-hero {
  position: relative;
}

/* --- Progress Bars (Challenge Progress) --- */
.progress-card {
  padding: 0;
}
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--color-overlay);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.5s ease;
}

/* --- Toggle Switch --- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background-color: var(--color-overlay);
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: var(--color-text-primary);
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .switch-slider {
  background-color: var(--color-brand);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}
