/* QUANTA — Fintech Research Platform
   Design tokens: dark modern terminal aesthetic
   Tweakable via CSS custom properties at :root level
*/

:root {
  /* === Surfaces (dark modern, near-black) === */
  --bg-0: #07090b;          /* deepest — page bg */
  --bg-1: #0c0f13;          /* panel bg */
  --bg-2: #12161c;          /* elevated panel */
  --bg-3: #1a2027;          /* row hover / input bg */
  --bg-4: #232a33;          /* selected row / heavier */

  /* === Lines === */
  --line-1: #1c232b;        /* hairlines between panels */
  --line-2: #2a333d;        /* stronger separators */
  --line-3: #3a4552;        /* focus / interactive borders */

  /* === Text === */
  --fg-0: #e8ecf2;          /* primary */
  --fg-1: #b8c2cf;          /* secondary */
  --fg-2: #7e8a99;          /* tertiary / labels */
  --fg-3: #4f5965;          /* disabled / faint */

  /* === Financial semantic === */
  --pos: #22c573;           /* up / positive */
  --pos-bg: #0f2a1c;
  --neg: #ef5350;           /* down / negative */
  --neg-bg: #2a1213;
  --warn: #ffb84d;          /* warning */
  --info: #5ac8fa;          /* info / link */

  /* === Accent (tweakable) === */
  --accent: #ff9f1c;        /* amber by default */
  --accent-fg: #0a0a0a;
  --accent-soft: #2a1f0a;

  /* === Type === */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Roboto Mono", ui-monospace, Menlo, monospace;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;

  --font-display: var(--font-sans);
  --font-body: var(--font-sans);
  --font-data: var(--font-mono);

  /* === Density (tweakable) === */
  --row-h: 28px;
  --row-h-sm: 22px;
  --pad-1: 4px;
  --pad-2: 8px;
  --pad-3: 12px;
  --pad-4: 16px;
  --pad-5: 24px;

  /* === Sizes === */
  --t-xs: 10px;
  --t-sm: 11px;
  --t-md: 12px;
  --t-lg: 13px;
  --t-xl: 15px;
  --t-2xl: 18px;
  --t-3xl: 24px;
  --t-4xl: 32px;
  --t-5xl: 48px;

  /* === Radii (kept tight for terminal feel) === */
  --r-1: 2px;
  --r-2: 3px;
  --r-3: 4px;
  --r-card: 6px;
}

/* Light theme override */
[data-theme="light"] {
  --bg-0: #f6f4ee;
  --bg-1: #ffffff;
  --bg-2: #faf7f0;
  --bg-3: #ede8dc;
  --bg-4: #ddd6c4;
  --line-1: #e6dfce;
  --line-2: #d2c9b3;
  --line-3: #b6ab92;
  --fg-0: #14110a;
  --fg-1: #3a3528;
  --fg-2: #6a6353;
  --fg-3: #9a9382;
  --pos-bg: #d4ecd9;
  --neg-bg: #f3d6d6;
  --accent-soft: #fce8c8;
}

/* Pure terminal theme override */
[data-theme="terminal"] {
  --bg-0: #000000;
  --bg-1: #050505;
  --bg-2: #0a0a0a;
  --bg-3: #141414;
  --bg-4: #1f1f1f;
  --line-1: #1a1a1a;
  --line-2: #2a2a2a;
  --line-3: #3a3a3a;
  --fg-0: #ffb84d;
  --fg-1: #ff9f1c;
  --fg-2: #b87a14;
  --fg-3: #6a4a14;
  --pos: #00ff88;
  --neg: #ff4444;
  --font-display: var(--font-mono);
  --font-body: var(--font-mono);
}

/* Density: comfortable */
[data-density="comfortable"] {
  --row-h: 36px;
  --row-h-sm: 28px;
  --pad-2: 12px;
  --pad-3: 16px;
  --pad-4: 20px;
  --pad-5: 32px;
  --t-md: 13px;
  --t-lg: 14px;
}

/* Density: spacious */
[data-density="spacious"] {
  --row-h: 44px;
  --row-h-sm: 36px;
  --pad-2: 16px;
  --pad-3: 20px;
  --pad-4: 28px;
  --pad-5: 40px;
  --t-md: 14px;
  --t-lg: 16px;
}

/* Base reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-body);
  font-size: var(--t-md);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, textarea, select { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* Utility classes */
.mono { font-family: var(--font-data); font-feature-settings: "tnum"; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.fg-1 { color: var(--fg-1); }
.fg-2 { color: var(--fg-2); }
.fg-3 { color: var(--fg-3); }
.tabular { font-variant-numeric: tabular-nums; }
.uppercase { text-transform: uppercase; letter-spacing: 0.05em; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border: 2px solid var(--bg-0); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-3); }

/* Selection */
::selection { background: var(--accent); color: var(--accent-fg); }

/* Focus visible */
:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* === Common building blocks === */

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-card);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pad-2) var(--pad-3);
  border-bottom: 1px solid var(--line-1);
  font-size: var(--t-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-2);
}
.panel-header strong {
  color: var(--fg-1);
  font-weight: 600;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
  padding: 0 6px;
  font-size: var(--t-xs);
  font-family: var(--font-data);
  border-radius: var(--r-1);
  border: 1px solid var(--line-2);
  color: var(--fg-1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chip-pos { background: var(--pos-bg); color: var(--pos); border-color: transparent; }
.chip-neg { background: var(--neg-bg); color: var(--neg); border-color: transparent; }
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-warn { color: var(--warn); border-color: var(--warn); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  font-size: var(--t-md);
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--fg-0);
  border-radius: var(--r-2);
  transition: background 80ms, border-color 80ms;
}
.btn:hover { background: var(--bg-3); border-color: var(--line-3); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg-1);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--fg-0); }
.btn-sm { height: 22px; padding: 0 8px; font-size: var(--t-sm); }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  min-width: 16px;
  padding: 0 4px;
  font-family: var(--font-data);
  font-size: 9px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: var(--r-1);
  color: var(--fg-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 16px;
  padding: 0 5px;
  font-size: 9px;
  font-family: var(--font-data);
  background: var(--bg-3);
  color: var(--fg-2);
  border-radius: var(--r-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider { height: 1px; background: var(--line-1); }
.vdivider { width: 1px; background: var(--line-1); align-self: stretch; }

.sparkline {
  display: inline-block;
  width: 60px;
  height: 16px;
  vertical-align: middle;
}
