/* ============================================================
   ALGORA TRADE — Unified Design System v1
   One system for marketing + dashboard.
   Dark-first. Data-dense capable. WCAG AA.
   ============================================================ */

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

:root {
  /* ---------- COLOR: surfaces ---------- */
  /* Cool-neutral deep slate. Not warm-gold-dark, not VS-Code-blue-dark.
     A single background family that works for both editorial marketing
     and dense trading panels. */
  --bg-0: #0a0b0f;          /* page canvas (deepest) */
  --bg-1: #0f1117;          /* primary surface */
  --bg-2: #14161f;          /* raised surface / panels */
  --bg-3: #1a1d28;          /* elevated / hover surface */
  --bg-4: #232734;          /* input / inset */

  --border-1: #1f2230;      /* hairline divider */
  --border-2: #2a2e3e;      /* default border */
  --border-3: #3a3f52;      /* strong border / focus ring track */

  /* ---------- COLOR: text hierarchy ---------- */
  --text-1: #f2f3f7;        /* primary (AA on bg-0..bg-4) */
  --text-2: #b6bac7;        /* secondary */
  --text-3: #7e8494;        /* tertiary / metadata */
  --text-4: #565a6b;        /* quaternary / disabled */
  --text-inv: #0a0b0f;      /* on light fills */

  /* ---------- COLOR: brand accent ---------- */
  /* Refined gold — kept from current brand, tuned slightly less saturated
     so it survives next to semantic red/green without clashing. */
  --gold-50:  #fbf3dc;
  --gold-100: #f4e0a6;
  --gold-300: #e8c476;
  --gold-500: #d9a441;       /* primary accent */
  --gold-600: #b8882e;
  --gold-700: #8a651f;
  --gold-900: #3d2d0e;
  --gold-glow: rgba(217,164,65,0.14);

  /* ---------- COLOR: semantic (market) ---------- */
  /* Tuned to equal chroma so up/down feel balanced, not one screaming. */
  --up-100: #bff0d1;
  --up-400: #3dd07a;         /* default up */
  --up-500: #22b866;
  --up-700: #0f6b3b;
  --up-bg:  rgba(34,184,102,0.10);

  --down-100: #f5c6c2;
  --down-400: #ef6a60;        /* default down */
  --down-500: #e14c3f;
  --down-700: #7a1f18;
  --down-bg:  rgba(225,76,63,0.10);

  --warn-400: #f2b94a;
  --warn-bg:  rgba(242,185,74,0.10);

  --info-400: #5fb3d4;
  --info-bg:  rgba(95,179,212,0.10);

  --neutral-400: #8a90a2;
  --neutral-bg:  rgba(138,144,162,0.10);

  /* ---------- TYPOGRAPHY ---------- */
  --font-display: 'Space Grotesk', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-sans:    'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Type scale — paired for marketing (editorial scale) + dashboard (tight). */
  --fs-10: 10px;   /* dashboard micro label */
  --fs-11: 11px;   /* table meta */
  --fs-12: 12px;   /* dashboard body */
  --fs-13: 13px;   /* dashboard primary / marketing small */
  --fs-14: 14px;   /* UI default */
  --fs-16: 16px;   /* marketing body */
  --fs-18: 18px;   /* lead */
  --fs-20: 20px;
  --fs-24: 24px;
  --fs-32: 32px;
  --fs-40: 40px;
  --fs-56: 56px;
  --fs-72: 72px;

  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.5;
  --lh-loose: 1.65;

  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-caps: 0.12em;         /* eyebrow labels */
  --tracking-numeric: 0.02em;      /* mono numerics */

  /* ---------- SPACING (4px grid) ---------- */
  --s-0: 0;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;
  --s-32: 128px;

  /* ---------- RADII ---------- */
  --r-0: 0;
  --r-1: 2px;      /* dashboard pills / tight */
  --r-2: 4px;      /* default inputs / buttons */
  --r-3: 6px;      /* cards */
  --r-4: 10px;     /* larger panels */
  --r-5: 14px;     /* marketing cards */
  --r-full: 999px;

  /* ---------- SHADOWS ---------- */
  --shadow-1: 0 1px 0 rgba(255,255,255,0.02) inset, 0 1px 2px rgba(0,0,0,0.3);
  --shadow-2: 0 4px 16px rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.02) inset;
  --shadow-3: 0 20px 48px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.03) inset;
  --shadow-glow-gold: 0 0 0 1px rgba(217,164,65,0.35), 0 0 24px rgba(217,164,65,0.15);
  --shadow-focus: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--gold-500);

  /* ---------- TRANSITIONS ---------- */
  --t-fast: 120ms cubic-bezier(.2,.7,.3,1);
  --t-med: 200ms cubic-bezier(.2,.7,.3,1);

  /* ---------- Z ---------- */
  --z-nav: 50;
  --z-modal: 100;
  --z-toast: 200;
}

/* ============================================================
   BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: var(--lh-normal);
  color: var(--text-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--gold-500); color: var(--text-inv); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }

/* Numeric tabular lining figures — essential for tables/prices */
.num, .mono, .price, td.num, th.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-numeric);
}

/* Eyebrow label (used in both marketing + dashboard) */
.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-3);
}

/* Display headings */
.display-xl {
  font-family: var(--font-display);
  font-size: clamp(48px, 6vw, 88px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 500;
}
.display-l {
  font-family: var(--font-display);
  font-size: clamp(36px, 4vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 500;
}
.display-m {
  font-family: var(--font-display);
  font-size: var(--fs-32);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 500;
}

/* Semantic text helpers */
.t-up   { color: var(--up-400); }
.t-down { color: var(--down-400); }
.t-warn { color: var(--warn-400); }
.t-info { color: var(--info-400); }
.t-gold { color: var(--gold-500); }
.t-2    { color: var(--text-2); }
.t-3    { color: var(--text-3); }
.t-4    { color: var(--text-4); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 36px;
  padding: 0 var(--s-4);
  font-size: var(--fs-13);
  font-weight: 500;
  letter-spacing: 0;
  border-radius: var(--r-2);
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn .arr { display: inline-block; transition: transform var(--t-fast); }
.btn:hover .arr { transform: translateX(2px); }

/* Primary — gold, high-value CTAs */
.btn-primary {
  background: var(--gold-500);
  color: var(--text-inv);
  border-color: var(--gold-500);
}
.btn-primary:hover { background: var(--gold-300); border-color: var(--gold-300); }
.btn-primary:active { background: var(--gold-600); border-color: var(--gold-600); }
.btn-primary:disabled { background: var(--bg-3); border-color: var(--bg-3); color: var(--text-4); cursor: not-allowed; }

/* Secondary — outlined, default action */
.btn-secondary {
  background: var(--bg-2);
  color: var(--text-1);
  border-color: var(--border-2);
}
.btn-secondary:hover { background: var(--bg-3); border-color: var(--border-3); }
.btn-secondary:active { background: var(--bg-1); }
.btn-secondary:disabled { color: var(--text-4); background: var(--bg-1); cursor: not-allowed; }

/* Ghost — minimal */
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-2); color: var(--text-1); }
.btn-ghost:active { background: var(--bg-3); }
.btn-ghost:disabled { color: var(--text-4); cursor: not-allowed; }

/* Sizes */
.btn-sm { height: 28px; padding: 0 var(--s-3); font-size: var(--fs-12); }
.btn-lg { height: 44px; padding: 0 var(--s-5); font-size: var(--fs-14); }

/* Semantic variants (for dashboard) */
.btn-up   { background: var(--up-bg); color: var(--up-400); border-color: color-mix(in oklab, var(--up-400) 30%, transparent); }
.btn-up:hover   { background: color-mix(in oklab, var(--up-400) 18%, transparent); }
.btn-down { background: var(--down-bg); color: var(--down-400); border-color: color-mix(in oklab, var(--down-400) 30%, transparent); }
.btn-down:hover { background: color-mix(in oklab, var(--down-400) 18%, transparent); }

/* Icon-only button */
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  justify-content: center;
  color: var(--text-2);
  background: transparent;
  border-color: transparent;
  border-radius: var(--r-2);
}
.btn-icon:hover { background: var(--bg-3); color: var(--text-1); }

/* ============================================================
   PANELS / CARDS
   ============================================================ */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
}
.panel-raised {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
}
.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-1);
  min-height: 40px;
}
.panel-hd .title {
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-2);
}
.panel-bd { padding: var(--s-4); }
.panel-bd-flush { padding: 0; }

/* Marketing card (more breathing room, larger radius) */
.card-mkt {
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border-2);
  border-radius: var(--r-5);
  padding: var(--s-8);
  transition: border-color var(--t-med), transform var(--t-med);
}
.card-mkt:hover { border-color: var(--border-3); }

/* ============================================================
   TABLES / ROWS (dashboard density)
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-12);
  line-height: var(--lh-snug);
}
.table thead th {
  text-align: left;
  font-weight: 500;
  font-size: var(--fs-10);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-3);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-1);
  position: sticky; top: 0; z-index: 1;
}
.table tbody td {
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border-1);
  color: var(--text-1);
}
.table tbody tr:hover td { background: var(--bg-2); cursor: pointer; }
.table tbody tr.is-selected td { background: color-mix(in oklab, var(--gold-500) 8%, transparent); }
.table td.num, .table th.num { text-align: right; }

.row-divider { border-top: 1px solid var(--border-1); }

/* ============================================================
   PILLS / BADGES
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 8px;
  font-size: var(--fs-10);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  border-radius: var(--r-1);
  border: 1px solid transparent;
  font-family: var(--font-sans);
}
.pill-lg { height: 24px; padding: 0 10px; font-size: var(--fs-11); }
.pill-up    { background: var(--up-bg); color: var(--up-400); border-color: color-mix(in oklab, var(--up-400) 25%, transparent); }
.pill-down  { background: var(--down-bg); color: var(--down-400); border-color: color-mix(in oklab, var(--down-400) 25%, transparent); }
.pill-warn  { background: var(--warn-bg); color: var(--warn-400); border-color: color-mix(in oklab, var(--warn-400) 25%, transparent); }
.pill-info  { background: var(--info-bg); color: var(--info-400); border-color: color-mix(in oklab, var(--info-400) 25%, transparent); }
.pill-gold  { background: color-mix(in oklab, var(--gold-500) 14%, transparent); color: var(--gold-300); border-color: color-mix(in oklab, var(--gold-500) 30%, transparent); }
.pill-neutral { background: var(--neutral-bg); color: var(--text-2); border-color: var(--border-2); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-up    { background: var(--up-400); box-shadow: 0 0 8px var(--up-400); }
.dot-down  { background: var(--down-400); box-shadow: 0 0 8px var(--down-400); }
.dot-warn  { background: var(--warn-400); box-shadow: 0 0 8px var(--warn-400); }
.dot-live  { background: var(--up-400); box-shadow: 0 0 0 0 var(--up-400); animation: pulse 2s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--up-400) 60%, transparent); }
  70%  { box-shadow: 0 0 0 6px color-mix(in oklab, var(--up-400) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--up-400) 0%, transparent); }
}

/* ============================================================
   INPUTS
   ============================================================ */
.input {
  height: 36px;
  padding: 0 var(--s-3);
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  color: var(--text-1);
  font-size: var(--fs-13);
  width: 100%;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.input::placeholder { color: var(--text-4); }
.input:hover { border-color: var(--border-3); }
.input:focus { outline: none; border-color: var(--gold-500); background: var(--bg-3); }
.input:disabled { color: var(--text-4); background: var(--bg-1); cursor: not-allowed; }
.input-sm { height: 28px; font-size: var(--fs-12); }

.label {
  display: block;
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--s-2);
}

.input-group {
  display: flex;
  align-items: center;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  padding: 0 var(--s-3);
  height: 36px;
  gap: var(--s-2);
  transition: border-color var(--t-fast);
}
.input-group:focus-within { border-color: var(--gold-500); }
.input-group .input { border: 0; background: transparent; padding: 0; height: 100%; }
.input-group .prefix,
.input-group .suffix { color: var(--text-3); font-size: var(--fs-12); }

/* ============================================================
   NAV TABS
   ============================================================ */
.tabs {
  display: inline-flex;
  gap: 0;
  border-bottom: 1px solid var(--border-1);
}
.tab {
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-13);
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.tab:hover { color: var(--text-1); }
.tab[aria-selected="true"] {
  color: var(--text-1);
  border-bottom-color: var(--gold-500);
}

/* Segmented control variant */
.seg {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  padding: 2px;
  gap: 2px;
}
.seg button {
  padding: 4px 10px;
  font-size: var(--fs-12);
  color: var(--text-3);
  border-radius: 3px;
  height: 26px;
  font-weight: 500;
}
.seg button:hover { color: var(--text-1); }
.seg button[aria-pressed="true"] {
  background: var(--bg-4);
  color: var(--text-1);
  box-shadow: var(--shadow-1);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,6,9,0.7);
  backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: grid; place-items: center;
}
.modal {
  width: min(560px, 92vw);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border-1);
}
.modal-bd { padding: var(--s-6); }
.modal-ft {
  display: flex; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border-1);
  background: var(--bg-1);
}

/* ============================================================
   LAYOUT HELPERS
   ============================================================ */
.container { max-width: 1280px; margin: 0 auto; padding: 0 var(--s-8); }
.stack-1 > * + * { margin-top: var(--s-1); }
.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-4 > * + * { margin-top: var(--s-4); }
.stack-6 > * + * { margin-top: var(--s-6); }
.stack-8 > * + * { margin-top: var(--s-8); }
.hstack { display: flex; align-items: center; gap: var(--s-3); }
.hstack-2 { display: flex; align-items: center; gap: var(--s-2); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }

/* Ticker marquee (marketing + dashboard top) */
.ticker {
  display: flex; align-items: center; gap: var(--s-6);
  height: 32px;
  padding: 0 var(--s-4);
  background: var(--bg-0);
  border-bottom: 1px solid var(--border-1);
  overflow: hidden;
  font-size: var(--fs-11);
  white-space: nowrap;
}
.ticker-item { display: inline-flex; align-items: center; gap: var(--s-2); }
.ticker-item .sym { color: var(--text-3); letter-spacing: var(--tracking-caps); font-weight: 600; }
.ticker-item .val { color: var(--text-1); }

/* Divider with label */
.rule {
  display: flex; align-items: center; gap: var(--s-3);
  color: var(--text-3); font-size: var(--fs-11);
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
}
.rule::before, .rule::after {
  content: ""; flex: 1; height: 1px; background: var(--border-1);
}

/* Spark/chart placeholder backgrounds (subtle stripes for missing imagery) */
.ph-stripes {
  background-image: repeating-linear-gradient(45deg, var(--bg-2) 0 8px, var(--bg-1) 8px 16px);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  color: var(--text-4);
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  display: grid; place-items: center;
}
