/* ============================================================================
   FairValue — design system foundation
   Warm finance-editorial: coral + mint on a warm off-white.
   Display: Fraunces (optical soft-serif). UI/data: Inter (tabular figures).
   Tokens map 1:1 to the brand spec; dark theme uses the same accents.
   ========================================================================== */

:root {
  /* Brand */
  --brand-primary:      #E8956A;  /* coral / peach — actions, key highlights */
  --brand-primary-dark: #C9764C;  /* hover / pressed */
  --brand-secondary:    #3FB28F;  /* mint — positive / undervalued / success */

  /* Semantic */
  --success: #2E9E7A;
  --warning: #E0A458;
  --danger:  #E06B6B;  /* overvalued / negative */

  /* Neutral (light) */
  --bg:       #FAFAF7;  /* app background — warm off-white */
  --surface:  #FFFFFF;  /* cards */
  --surface-2:#F4F1EB;  /* sunken / inset */
  --border:   #ECE7E1;
  --border-strong: #DDD6CC;
  --text:     #1F2421;  /* body */
  --muted:    #6B7280;
  --faint:    #9AA0A6;

  /* Accent tints */
  --primary-tint: #FBEEE4;
  --mint-tint:    #E4F3EC;
  --danger-tint:  #FBE9E9;

  /* Shape & shadow */
  --r-card: 14px;
  --r-btn:  9px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(31,36,33,.05), 0 1px 1px rgba(31,36,33,.03);
  --shadow:    0 1px 2px rgba(31,36,33,.04), 0 8px 24px -8px rgba(31,36,33,.10);
  --shadow-lg: 0 24px 60px -24px rgba(31,36,33,.28);
  --ring: 0 0 0 3px rgba(232,149,106,.32);

  /* Typography */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* Layout */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 64px;
  --maxw: 1440px;

  --ease: cubic-bezier(.22,.61,.36,1);
}

[data-theme="dark"] {
  --bg:       #0F1419;
  --surface:  #161B22;
  --surface-2:#1C232C;
  --border:   #232B36;
  --border-strong: #303A47;
  --text:     #E8EAED;
  --muted:    #9AA4B2;
  --faint:    #6B7686;

  --primary-tint: #2A2018;
  --mint-tint:    #14241E;
  --danger-tint:  #2A1A1A;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 1px 2px rgba(0,0,0,.35), 0 12px 32px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 30px 70px -28px rgba(0,0,0,.7);
  --ring: 0 0 0 3px rgba(232,149,106,.4);
}

/* ----------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
img, svg, canvas { display: block; max-width: 100%; }
.mark { width: 30px; height: 30px; flex: none; } /* square arrow mark; contexts may override */
.wordmark { height: 26px; width: auto; flex: none; } /* full wordmark; "fair"/tagline use currentColor */
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ----------------------------------------------------------- type */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 560; letter-spacing: -.01em; line-height: 1.1; color: var(--text); font-optical-sizing: auto; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.display { font-family: var(--font-display); }
.eyebrow {
  font-family: var(--font-sans); font-weight: 600; font-size: 12px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--brand-primary-dark);
}
[data-theme="dark"] .eyebrow { color: var(--brand-primary); }

/* ----------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r-btn); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; transition: transform .12s var(--ease), background .15s, box-shadow .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--brand-primary); color: #fff; box-shadow: 0 6px 16px -8px rgba(201,118,76,.7); }
.btn-primary:hover { background: var(--brand-primary-dark); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--faint); }
.btn-mint { background: var(--brand-secondary); color: #fff; }
.btn-mint:hover { filter: brightness(.95); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 7px; }

/* ----------------------------------------------------------- card */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 16px; }
.card-title-row { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ----------------------------------------------------------- chips / pills */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; line-height: 1.4;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.chip-mint   { background: var(--mint-tint);    color: var(--success); border-color: transparent; }
.chip-coral  { background: var(--primary-tint); color: var(--brand-primary-dark); border-color: transparent; }
.chip-danger { background: var(--danger-tint);  color: var(--danger);  border-color: transparent; }
.chip-pro {
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-primary-dark));
  color: #fff; border-color: transparent; box-shadow: 0 2px 8px -2px rgba(201,118,76,.6);
}

/* delta indicators */
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 13px; }
.delta.up   { color: var(--success); }
.delta.down { color: var(--danger); }

/* ----------------------------------------------------------- inputs */
.input, .select {
  width: 100%; padding: 11px 13px; border-radius: var(--r-btn);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { border-color: var(--brand-primary); box-shadow: var(--ring); outline: none; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }

/* ----------------------------------------------------------- helpers */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; }
.grow { flex: 1; }
.hidden { display: none !important; }
.up-val { color: var(--success); }
.down-val { color: var(--danger); }

/* tooltip — replaces the green "?" chip */
.help {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700;
  cursor: help; position: relative; border: 1px solid var(--border);
}
.help:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); width: max-content; max-width: 260px; padding: 9px 11px;
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.45;
  border-radius: 8px; box-shadow: var(--shadow); z-index: 50; text-align: left;
}

/* skeleton loaders */
.sk { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 8px; }
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  transform: translateX(-100%); animation: sk 1.3s infinite;
}
[data-theme="dark"] .sk::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
@keyframes sk { 100% { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-h { height: 28px; }

/* empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { margin: 0 auto 12px; color: var(--faint); }
.empty h4 { font-family: var(--font-sans); font-size: 15px; color: var(--text); margin-bottom: 4px; }

/* grain / atmosphere overlay (very subtle) */
.grain::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
