/* ==========================================================================
   THINGS FOR TRADERS DESIGN SYSTEM
   Version: 2.0 - Production Grade / CSP Compliant
   ========================================================================== */

@import url('/static/tokens.css?v=20260928');

:root {
  /* =========================================================================
     TYPOGRAPHY SYSTEM
     ========================================================================= */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, 'Liberation Mono', monospace;
  --font-serif: 'Merriweather', 'Georgia', 'Times New Roman', serif;
  
  /* Font Sizes - Using rem for accessibility */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  
  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  
  /* Letter Spacing */
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;
  --tracking-widest: 0.1em;

  /* =========================================================================
     COLOR SYSTEM - base colours live in /static/tokens.css (dark default)
     ========================================================================= */
  
  /* Alpha / tint variants (base colours: tokens.css) */
  --primary-light: rgba(5, 150, 105, 0.12);
  
  --accent-light: rgba(37, 99, 235, 0.12);
  
  --danger-light: rgba(225, 29, 72, 0.12);
  
  --warn-hover: #d97706;
  --warn-light: rgba(245, 158, 11, 0.12);
  
  --info-light: rgba(14, 165, 233, 0.12);

  --architect: #1E3A8A;   /* Architect Profile - Deep Blue */
  --architect-hover: #1e40af;
  --architect-light: rgba(30, 58, 138, 0.12);

  --backtester: #7C3AED;  /* Backtester Profile - Vivid Purple */
  --backtester-hover: #6D28D9;
  --backtester-light: rgba(124, 58, 237, 0.12);
  --backtester-accent: #A78BFA; /* Light purple for accents */

  /* On-color contrasts (text on colored backgrounds) */

  /* Border Colors */
  
  /* Shadows - CSP Safe (no inline styles needed) */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-glow-primary: 0 0 20px rgba(16, 185, 129, 0.3);
  --shadow-glow-accent: 0 0 20px rgba(59, 130, 246, 0.3);
  --shadow-glow-danger: 0 0 20px rgba(239, 68, 68, 0.3);

  /* Overlay tokens (accessibility-oriented) */
  --overlay-heavy: rgba(15, 23, 42, 0.5);
  --overlay-modal: rgba(15, 23, 42, 0.75);

  /* Alpha variants for layering */
  --accent-alpha-1: rgba(96, 165, 250, 0.55);
  --accent-alpha-2: rgba(96, 165, 250, 0.42);
  --accent-alpha-3: rgba(96, 165, 250, 0.34);
  --accent-alpha-4: rgba(96, 165, 250, 0.22);
  --accent-alpha-5: rgba(96, 165, 250, 0.18);
  
  --primary-alpha-1: rgba(16, 185, 129, 0.18);
  --primary-alpha-2: rgba(16, 185, 129, 0.45);
  --primary-alpha-3: rgba(16, 185, 129, 0.65);
  
  --danger-alpha-1: rgba(239, 68, 68, 0.18);
  --danger-alpha-2: rgba(239, 68, 68, 0.45);
  
  --muted-alpha-1: rgba(148, 163, 184, 0.32);
  --muted-alpha-2: rgba(148, 163, 184, 0.18);
  
  --warn-alpha-1: rgba(245, 158, 11, 0.18);
  --warn-alpha-2: rgba(245, 158, 11, 0.45);
  
  /* White tints for glass effects */
  --white-alpha-02: rgba(255, 255, 255, 0.02);
  --white-alpha-04: rgba(255, 255, 255, 0.04);
  --white-alpha-05: rgba(255, 255, 255, 0.05);
  --white-alpha-06: rgba(255, 255, 255, 0.06);
  --white-alpha-08: rgba(255, 255, 255, 0.08);
  --white-alpha-12: rgba(255, 255, 255, 0.12);
  --white-alpha-90: rgba(255, 255, 255, 0.92);
  --white-alpha-92: rgba(255, 255, 255, 0.94);
  --white-alpha-95: rgba(255, 255, 255, 0.97);
  --white-alpha-96: rgba(255, 255, 255, 0.98);

  /* =========================================================================
     SPACING SYSTEM
     ========================================================================= */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */

  /* =========================================================================
     BORDER RADIUS
     ========================================================================= */
  --radius-none: 0;
  --radius-sm: 0.25rem;  /* 4px */
  --radius-md: 0.375rem; /* 6px */
  --radius-lg: 0.5rem;   /* 8px */
  --radius-xl: 0.75rem;  /* 12px */
  --radius-2xl: 1rem;    /* 16px */
  --radius-3xl: 1.5rem;  /* 24px */
  --radius-full: 9999px;

  /* =========================================================================
     TRANSITIONS & ANIMATIONS
     ========================================================================= */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-slower: 500ms ease;
  
  /* Easing Functions */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* =========================================================================
     Z-INDEX SCALE
     ========================================================================= */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
  --z-max: 9999;

  /* =========================================================================
     LAYOUT
     ========================================================================= */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1536px;
  
  --header-height: 4rem;
  --footer-min-height: 12rem;
  --sidebar-width: 280px;
}

/* Profile page adopts a light surface palette */
body.profile-body {
  --bg: #f6f9fc;
  --panel: #ffffff;
  --panel-2: #f0f4fb;
  --fg: #111b2b;
  --muted: #475569;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 16px 44px rgba(15, 23, 42, 0.12);
  --overlay-weak: rgba(15, 23, 42, 0.08);
  --overlay-medium: rgba(15, 23, 42, 0.12);
  --overlay-strong: rgba(15, 23, 42, 0.2);
}

/* Dark is the default in tokens.css; light is opt-in via <html data-theme="light|auto">. */

/* ==========================================================================
   GLOBAL RESET & BASE STYLES
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--fg);
  background-color: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--fg);
  margin: 0 0 var(--space-4);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  margin: 0 0 var(--space-4);
  line-height: var(--leading-relaxed);
}

/* Financial Data Typography */
.font-mono,
.tabular-nums,
[data-financial],
.financial-data,
.price,
.pnl,
.percentage {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' on, 'lnum' on;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   LINKS & INTERACTIVE ELEMENTS
   ========================================================================== */

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

.visually-hidden,
.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;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--on-accent);
  padding: var(--space-3) var(--space-6);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  z-index: var(--z-max);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
  outline: 2px solid white;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (forced-colors: active) {
  .btn,
  .badge,
  .chip {
    border: 2px solid currentColor;
  }
}

/* ==========================================================================
   LAYOUT CONTAINERS
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 640px) {
  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

/* Page wrapper for sticky footer */
.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-wrapper > main {
  flex: 1 0 auto;
}

.page-wrapper > footer {
  flex-shrink: 0;
}

/* Utility classes to prefer tokens over literals */
.bg-panel { background: var(--panel) !important; }
.bg-panel-2 { background: var(--panel-2) !important; }
.text-fg { color: var(--fg) !important; }
.text-muted { color: var(--muted) !important; }

/* ==========================================================================
   BUTTON SYSTEM
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  text-decoration: none;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm), var(--shadow-glow-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), var(--shadow-glow-primary);
}

.btn-secondary {
  background: var(--panel);
  color: var(--fg);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: var(--border-strong);
}

.btn-tertiary {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-tertiary:hover:not(:disabled) {
  color: var(--fg);
  background: var(--overlay-weak);
  border-color: var(--border-strong);
}

.btn-accent {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow-accent);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  box-shadow: var(--shadow-glow-danger);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: var(--space-2);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--fg);
  background: var(--overlay-weak);
}

/* Button Sizes */
.btn-xs {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius-xl);
}

/* ==========================================================================
   CARD SYSTEM
   ========================================================================== */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-alpha-3);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4 {
  margin: 0;
}

.card-title {
  font-weight: var(--font-semibold);
  font-size: var(--text-lg);
  color: var(--fg);
}

.card-body {
  padding: var(--space-4) 0;
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

/* Creative Card - Premium variant with gradient accents */
.creative-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.creative-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.creative-card:hover::before {
  opacity: 1;
}

.creative-card:hover {
  border-color: var(--accent-alpha-2);
  box-shadow: var(--shadow-lg);
}

/* Glass Panel - Frosted glass effect */
.glass-panel {
  background: var(--white-alpha-90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--overlay-weak);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   BADGE / PILL SYSTEM
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  border-radius: var(--radius-md);
  white-space: nowrap;
}

/* Direction Badges */
.badge-long,
.badge.long {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-alpha-2);
}

.badge-short,
.badge.short {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-alpha-2);
}

.badge-neutral {
  background: var(--accent-light);
  color: var(--link);
  border: 1px solid var(--accent-alpha-3);
}

/* Status Badges */
.badge-success,
.badge.success {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-warning,
.badge.warning,
.badge.status {
  background: var(--warn-light);
  color: var(--warn);
}

.badge-danger,
.badge.error {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-info,
.badge.info {
  background: var(--info-light);
  color: var(--info);
}

/* Timeframe Badges */
.badge.time,
.badge-timeframe {
  background: var(--accent-light);
  color: var(--link);
  border: 1px solid var(--accent-alpha-4);
}

/* Status Active/Closed */
.badge.status-active {
  background: var(--primary-light);
  color: var(--primary);
}

.badge.status-closed {
  background: var(--danger-light);
  color: var(--danger);
}

/* Pill variant - fully rounded */
.pill,
.badge-pill {
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
}

/* ==========================================================================
   CHIP / FILTER SYSTEM
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--fg);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.chip:hover {
  border-color: var(--accent);
  background: var(--accent-alpha-5);
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip.active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-glow-accent);
}

.filter-chip {
  padding: var(--space-2) var(--space-4);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--fg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary-alpha-2);
}

.filter-chip.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm), 0 0 12px var(--accent-alpha-4);
}

/* Gradients: prefer tokenized gradients so designers can update centrally */
.league-grad-intraday { background: linear-gradient(135deg, rgba(16,185,129,.16), rgba(96,165,250,.12)); }

/* ==========================================================================
   TABLE SYSTEM
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--accent-alpha-3);
  border-radius: var(--radius-full);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}

thead {
  background: var(--panel-2);
  position: sticky;
  top: 0;
  z-index: 1;
}

thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

/* Right-align numerical columns */
thead th[data-type="number"],
thead th.text-right,
tbody td[data-type="number"],
tbody td.text-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr {
  transition: background-color var(--transition-fast);
}

tbody tr:nth-child(even) {
  background: var(--overlay-weak);
}

tbody tr:hover {
  background: var(--accent-alpha-5);
}

tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Financial data cells */
tbody td.financial,
tbody td[data-type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Positive/Negative styling */
.positive,
.pos,
.text-success {
  color: var(--primary);
}

.negative,
.neg,
.text-danger {
  color: var(--danger);
}

/* ==========================================================================
   FORM INPUTS
   ========================================================================== */

input,
textarea,
select {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-3);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-alpha-4);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

input:disabled,
textarea:disabled,
select:disabled {
  background: var(--panel-2);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Input with label */
.form-field,
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-field label,
.field label,
.field-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--muted);
}

/* Filter group styling */
.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--panel-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  transition: border-color var(--transition-fast);
}

.filter-group:focus-within {
  border-color: var(--accent);
}

.filter-group label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--muted);
  font-weight: var(--font-semibold);
  white-space: nowrap;
}

.filter-group select,
.filter-group input {
  background: transparent;
  border: none;
  padding: 0;
  min-width: 100px;
}

.filter-group select:focus,
.filter-group input:focus {
  box-shadow: none;
}

/* ==========================================================================
   NAVIGATION SYSTEM
   ========================================================================== */

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-6);
  max-width: var(--container-xl);
  margin: 0 auto;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg);
  text-decoration: none;
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-tight);
}

.brand-link svg {
  color: var(--primary);
}

.nav-primary {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.nav-group {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-trigger::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  opacity: 0.65;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.nav-trigger:hover,
.nav-group:hover .nav-trigger,
.nav-group:focus-within .nav-trigger {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  transform: translateY(-1px);
}

.nav-group:hover .nav-trigger::after,
.nav-group:focus-within .nav-trigger::after {
  transform: rotate(-180deg);
  opacity: 1;
}

.nav-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-2);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: var(--z-dropdown);
}

.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.nav-dropdown a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg);
  text-decoration: none;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-dropdown a:hover,
.nav-dropdown a:focus {
  background: var(--accent-alpha-5);
  color: var(--link);
}

.nav-divider {
  height: 1px;
  margin: var(--space-2) 0;
  background: var(--border);
}

/* ==========================================================================
   FOOTER SYSTEM
   ========================================================================== */

footer {
  background: var(--bg-sunken);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

footer.dark-footer {
  background: #1a1a2e;
  color: #e2e8f0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer.dark-footer a {
  color: #94a3b8;
}

footer.dark-footer a:hover {
  color: white;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-8);
  padding: var(--space-12) 0;
}

.footer-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer-nav li::before {
  display: none; /* Remove bullet points */
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: var(--space-6) 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ==========================================================================
   DEBUG & DEVELOPER TOOLS TOGGLE
   ========================================================================== */

.debug-section,
[data-debug],
.raw-payload,
.verbose-snapshot {
  display: none;
}

body.debug-mode .debug-section,
body.debug-mode [data-debug],
body.debug-mode .raw-payload,
body.debug-mode .verbose-snapshot {
  display: block;
}

.debug-toggle {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  color: var(--muted);
  cursor: pointer;
  z-index: var(--z-fixed);
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.debug-toggle:hover {
  opacity: 1;
}

/* ==========================================================================
   AD CONTAINER CONSTRAINTS
   ========================================================================== */

[data-ad-zone] {
  max-width: 100%;
  overflow: hidden;
  margin: var(--space-4) auto;
}

[data-ad-zone="sidebar"] {
  max-width: 300px;
}

[data-ad-zone="footer"],
[data-ad-zone="feed"] {
  max-width: 728px;
}

/* ==========================================================================
   ANALYSIS CHART MEDIA CONSTRAINTS
   ========================================================================== */

.analysis-layout .chart-container {
  margin: var(--space-10) 0;
  padding: var(--space-5);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.analysis-layout .chart-container img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.analysis-layout .chart-caption {
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
  text-align: center;
  font-style: italic;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.hidden { display: none !important; }
.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; }

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Flexbox utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* Gap utilities */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Margin utilities */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

/* Padding utilities */
.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* Width utilities */
.w-full { width: 100%; }
.max-w-sm { max-width: var(--container-sm); }
.max-w-md { max-width: var(--container-md); }
.max-w-lg { max-width: var(--container-lg); }
.max-w-xl { max-width: var(--container-xl); }
.max-w-7xl { max-width: 80rem; } /* 1280px - Desktop content constraint */
.mx-auto { margin-left: auto; margin-right: auto; }

/* Constrained table wrapper - prevents infinite stretch */
.table-container {
  max-width: var(--container-xl);
  margin: 0 auto;
  overflow-x: auto;
}

/* Card grid with consistent padding */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-6);
  width: 100%;
  max-width: 100%;
}

.card-grid--dense {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-5);
  width: 100%;
  max-width: 100%;
}

/* Consistent card padding */
.card { padding: var(--space-6); }
.card--compact { padding: var(--space-4); }

/* Border radius */
.rounded { border-radius: var(--radius-lg); }
.rounded-lg { border-radius: var(--radius-xl); }
.rounded-xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }

/* Z-index */
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* ==========================================================================
   EMPTY STATES & LOADING PLACEHOLDERS
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-xl);
  color: var(--muted);
  min-height: 200px;
}

.empty-state__icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-4);
  color: var(--muted);
  opacity: 0.5;
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--fg-secondary);
  margin-bottom: var(--space-2);
}

.empty-state__description {
  font-size: var(--text-sm);
  max-width: 320px;
  margin-bottom: var(--space-4);
}

.empty-state__action {
  margin-top: var(--space-4);
}

/* Skeleton Loader */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--panel-2);
  border-radius: var(--radius-lg);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--overlay-weak) 50%,
    transparent 100%
  );
  animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-2);
}

.skeleton-text--sm { width: 40%; }
.skeleton-text--md { width: 60%; }
.skeleton-text--lg { width: 80%; }
.skeleton-text--full { width: 100%; }

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-xl);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   CONTRAST & ACCESSIBILITY OVERRIDES
   Production-grade styles ensuring WCAG AA compliance
   ========================================================================== */

/* Ensure text contrast on all panel surfaces */
.card,
.glass-panel,
.creative-card,
.feed-hero,
.feed-insights,
.profile-overview-card,
.tab-rail,
.nav-dropdown,
.hero-stat,
.metric-card,
.stat-tile {
  color: var(--fg);
}

/* Interactive elements inside cards */
.card a,
.glass-panel a,
.creative-card a {
  color: var(--link);
}

.card a:hover,
.glass-panel a:hover,
.creative-card a:hover {
  color: var(--link-hover);
}

/* Muted text consistency */
.muted,
.text-muted {
  color: var(--muted);
}

/* Headers within cards */
.card-header,
.card-title {
  color: var(--fg);
}

/* End of Merit Trading Design System v2.0 */

