/* ============================================================
   Meridian — Charcoal & Emerald design system
   ============================================================ */
:root {
  --bg:        #0F1318;
  --bg-2:      #141A21;
  --bg-3:      #1A222C;
  --raised:    #1F2833;
  --line:      #28323E;
  --line-soft: #202932;
  --text:      #E9E7E1;
  --muted:     #93A0AE;
  --muted-2:   #6C7885;
  --emerald:   #1E7A5A;
  --emerald-2: #34B37E;
  --emerald-3: #5AD6A0;
  --emerald-ghost: rgba(52,179,126,0.12);
  --emerald-line:  rgba(52,179,126,0.28);
  --gold:      #C9A24B;
  --danger:    #E06B6B;
  --danger-ghost: rgba(224,107,107,0.12);
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 18px 50px -22px rgba(0,0,0,0.7);
  --maxw:      1180px;
  --maxw-tool: 1560px;
  --ease:      cubic-bezier(.22,.9,.32,1);
  --ease-out:  cubic-bezier(.16,.84,.44,1);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Space Grotesk', var(--font-body);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15.5px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body {
  background-image:
    radial-gradient(900px 500px at 85% -5%, rgba(52,179,126,0.10), transparent 60%),
    radial-gradient(700px 500px at 5% 0%, rgba(30,122,90,0.08), transparent 55%);
  background-attachment: fixed;
  animation: bgdrift 26s ease-in-out infinite;
}
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 26px; }
.container-wide { max-width: min(var(--maxw-tool), 94vw); margin: 0 auto; padding: 0 26px; }
a { color: var(--emerald-3); text-decoration: none; }
a:hover { color: var(--emerald-2); }
h1,h2,h3,h4,h5 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; line-height: 1.18; margin: 0 0 .5em; }
h1 { font-size: 2.55rem; letter-spacing: -0.025em; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.22rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--font-head); text-transform: uppercase; letter-spacing: .22em;
  font-size: .72rem; color: var(--emerald-2); font-weight: 600; margin-bottom: 1rem;
}

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(15,19,24,0.82); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.nav-inner { display: flex; align-items: center; gap: 28px; height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--font-head); }
.brand-mark { color: var(--text); flex: none; }
.brand-name { font-weight: 700; font-size: 1.16rem; letter-spacing: -0.01em; }
.brand-sub { font-size: .64rem; text-transform: uppercase; letter-spacing: .2em; color: var(--muted-2); align-self: center; padding-top: 3px; }
.nav-center { display: flex; gap: 6px; margin-left: 8px; flex: 1; }
.nav-link {
  color: var(--muted); padding: 8px 12px; border-radius: 8px; font-size: .92rem; font-weight: 500;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-2); }
.nav-link.is-active { color: var(--emerald-3); }
.nav-user { display: flex; align-items: center; gap: 12px; }
.nav-whom { color: var(--muted); font-size: .86rem; }
.inline { display: inline; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-head); font-weight: 600; font-size: .92rem;
  padding: 11px 20px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: background .24s var(--ease), border-color .24s var(--ease), color .24s var(--ease), transform .24s var(--ease), box-shadow .24s var(--ease);
  white-space: nowrap; line-height: 1;
}
.btn-sm { padding: 8px 14px; font-size: .85rem; }
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.btn-primary { background: var(--emerald); color: #fff; box-shadow: 0 8px 22px -10px rgba(52,179,126,0.7); }
.btn-primary:hover { background: var(--emerald-2); color: #fff; transform: translateY(-2px); box-shadow: 0 14px 30px -12px rgba(52,179,126,0.65); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--emerald-line); color: var(--emerald-3); transform: translateY(-2px); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(224,107,107,0.35); }
.btn-danger:hover { background: var(--danger-ghost); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn .arrow, .card-link .arrow, .arrow-left { display: inline-block; transition: transform .3s var(--ease); }
.btn:hover .arrow, .card-link:hover .arrow { transform: translateX(4px); }
.btn:hover .arrow-left { transform: translateX(-4px); }

/* ---------- badges & flashes ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-3); color: var(--muted); border: 1px solid var(--line);
}
.badge.emerald { color: var(--emerald-3); background: var(--emerald-ghost); border-color: var(--emerald-line); }
.badge.gold { color: var(--gold); background: rgba(201,162,75,0.1); border-color: rgba(201,162,75,0.3); }
.flash { padding: 12px 16px; border-radius: 10px; margin: 0 0 20px; font-size: .92rem; border: 1px solid; }
.flash-info { background: var(--emerald-ghost); border-color: var(--emerald-line); color: var(--emerald-3); }
.flash-error { background: var(--danger-ghost); border-color: rgba(224,107,107,0.35); color: var(--danger); }

/* ---------- hero ---------- */
.hero { padding: 92px 0 64px; position: relative; }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 54px; align-items: center; }
.hero h1 { margin-bottom: 20px; }
.hero .lede { font-size: 1.16rem; color: var(--muted); max-width: 34ch; margin-bottom: 30px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-panel {
  background: linear-gradient(160deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow);
}
.hero-panel h4 { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .18em; margin-bottom: 6px; }
.hero-sub { font-size: .82rem; color: var(--muted-2); margin: 0 0 2px; min-height: 1.3em; }
.hero-chart-fade { transition: opacity .26s ease; }
.hero-dots { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.hero-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.hero-dots span.on { background: var(--emerald-2); transform: scale(1.3); }
.hero-chip { display:flex; gap:8px; margin-top:16px; flex-wrap: wrap; }

/* ---------- sections ---------- */
.section { padding: 64px 0; }
.section-tight { padding: 40px 0; }
.section-head { max-width: 60ch; margin-bottom: 38px; }
.divider { border: none; border-top: 1px solid var(--line-soft); margin: 0; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-80-20 { grid-template-columns: 4fr 1fr; }
.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; transition: border-color .3s var(--ease), transform .3s var(--ease), box-shadow .3s var(--ease);
}
.card-hover:hover { border-color: var(--emerald-line); transform: translateY(-5px); box-shadow: var(--shadow); }
.card-locked { opacity: .68; }
.card-locked:hover { opacity: 1; }
.card h3 { margin-bottom: 8px; }
.card .card-ico {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--emerald-ghost); color: var(--emerald-3); margin-bottom: 16px;
  border: 1px solid var(--emerald-line); transition: transform .35s var(--ease);
}
.card-hover:hover .card-ico { transform: translateY(-2px) scale(1.08); }
.card-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-weight: 600; font-family: var(--font-head); font-size: .9rem; }

/* ---------- stats ---------- */
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 18px; }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .13em; color: var(--muted-2); margin-bottom: 6px; }
.stat-value { font-family: var(--font-head); font-size: 1.55rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.stat.good .stat-value { color: var(--emerald-3); }
.stat.bad .stat-value { color: var(--danger); }

/* ---------- forms / auth ---------- */
.auth-wrap { min-height: calc(100vh - 66px); display: grid; place-items: center; padding: 48px 0; }
.auth-card {
  width: 100%; max-width: 440px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 38px; box-shadow: var(--shadow);
}
.auth-card.wide { max-width: 560px; }
.auth-head { text-align: center; margin-bottom: 26px; }
.auth-head h2 { margin-bottom: 6px; }
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: .82rem; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.field-hint { display: block; font-size: .76rem; color: var(--muted-2); margin-top: 5px; }
.input, .select, textarea.input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-family: var(--font-body); font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-ghost);
}
textarea.input { resize: vertical; min-height: 90px; line-height: 1.55; }
.input-toggle-wrap { position: relative; }
.input-toggle-wrap .input { padding-right: 42px; }
.input-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer; padding: 8px;
  color: var(--muted-2); display: flex; align-items: center; border-radius: 6px;
  transition: color .15s;
}
.input-toggle:hover { color: var(--text); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.product-check {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
  cursor: pointer; transition: border-color .15s;
}
.product-check:hover { border-color: var(--emerald-line); }
.product-check input { margin-top: 3px; accent-color: var(--emerald); flex: none; }
.product-check.select-all { background: var(--bg-2); border-style: dashed; }

.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--radius-sm); padding: 22px 14px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--emerald-line); background: var(--emerald-ghost); }
.auth-alt { text-align: center; margin-top: 20px; font-size: .9rem; color: var(--muted); }

/* ---------- page header ---------- */
.page-head { padding: 44px 0 26px; border-bottom: 1px solid var(--line-soft); }
.page-head .eyebrow { margin-bottom: .6rem; }
.page-head h1 { font-size: 2rem; }
.page-head p { color: var(--muted); max-width: 62ch; margin-top: 6px; }

/* ---------- insights / articles ---------- */
.article-list { display: grid; gap: 18px; }
.article-item {
  display: grid; grid-template-columns: 130px 1fr; gap: 22px; padding: 22px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .3s var(--ease), transform .3s var(--ease), box-shadow .3s var(--ease);
}
.article-item:hover { border-color: var(--emerald-line); transform: translateY(-3px); box-shadow: var(--shadow); }
.article-meta { font-size: .8rem; color: var(--muted-2); }
.article-item h3 { margin: 8px 0 6px; }
.article-item h3 a { color: var(--text); }
.article-item h3 a:hover { color: var(--emerald-3); }
.article-body { max-width: 72ch; }
.article-body p { color: #cfd4d1; }
.prose { white-space: pre-wrap; line-height: 1.75; color: #d6dbd8; }

/* ---------- tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th, table.tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
table.tbl th { color: var(--muted-2); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tr:last-child td { border-bottom: none; }

/* Caps a long table to ~10 visible rows with a contained scrollbar for the
   rest (e.g. a table built from an uploaded file with hundreds of rows) —
   keeps the page from growing arbitrarily tall. Header stays pinned. */
.tbl-scroll {
  max-height: 442px; overflow-y: auto; overflow-x: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
}
.tbl-scroll table.tbl { margin: 0; }
.tbl-scroll table.tbl thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; }

/* ---------- workspace / tools ---------- */
.tool-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 26px; align-items: start; }
.panel {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  min-width: 0; overflow-x: auto;
}
.panel.sticky { position: sticky; top: 86px; }
.panel h3 { font-size: 1.05rem; }
.panel-note { font-size: .82rem; color: var(--muted); margin-bottom: 18px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button {
  flex: 1; background: transparent; border: none; color: var(--muted); font-family: var(--font-head);
  font-weight: 600; font-size: .82rem; padding: 8px 6px; border-radius: 7px; cursor: pointer; transition: all .14s;
}
.seg button.on { background: var(--emerald); color: #fff; }
.result-empty { display: grid; place-items: center; min-height: 340px; color: var(--muted-2); text-align: center; }
.chart-wrap { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.chart-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .13em; color: var(--muted-2); margin-bottom: 10px; padding: 4px 4px 0; }
svg .grid-line { stroke: var(--line-soft); stroke-width: 1; }
svg .axis-text { fill: var(--muted-2); font-size: 10px; font-family: var(--font-body); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.mini-label { font-size:.72rem; text-transform:uppercase; letter-spacing:.12em; color:var(--muted-2); margin: 22px 0 8px; }
.scenario-desc {
  font-size: .82rem; line-height: 1.55; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 13px; margin: 10px 0 0;
}
.chain-note {
  font-size: .8rem; line-height: 1.5; color: var(--emerald-3); background: var(--emerald-ghost);
  border: 1px solid var(--emerald-line); border-radius: var(--radius-sm); padding: 8px 12px; margin: 10px 0 0;
}

/* ---------- chart hover tooltip ---------- */
.chart-tooltip {
  position: fixed; z-index: 9999; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s ease, transform .12s ease;
  background: var(--bg-3); border: 1px solid var(--emerald-line); color: var(--text);
  font-family: var(--font-body); font-size: .78rem; line-height: 1.45;
  padding: 7px 11px; border-radius: 8px; box-shadow: var(--shadow);
  max-width: 280px; white-space: normal;
}
.chart-tooltip.show { opacity: 1; transform: translateY(0); }
svg .chart-hit { cursor: pointer; }

/* ---------- admin ---------- */
.admin-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; }

/* ---------- misc ---------- */
.spread { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 14px; }
.foot { border-top: 1px solid var(--line-soft); margin-top: 80px; background: var(--bg-2); }
.foot-inner { padding: 46px 0 30px; }
.foot-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 600; margin-bottom: 26px; }
.foot-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; max-width: 640px; }
.foot-cols h5 { color: var(--muted-2); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; margin-bottom: 10px; }
.foot-cols a, .foot-cols span { display: block; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.foot-cols a:hover { color: var(--emerald-3); }
.foot-legal { margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--line-soft); color: var(--muted-2); font-size: .82rem; }

/* ---------- spinner ---------- */
.spin { width: 26px; height: 26px; border-radius: 50%; margin: 0 auto 12px;
  border: 2.5px solid var(--line); border-top-color: var(--emerald-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- motion: page-load drift + scroll reveal ---------- */
@keyframes bgdrift {
  0%, 100% { background-position: 85% -5%, 5% 0%; }
  50%      { background-position: 78% 2%, 11% 4%; }
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes float   { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Scroll-triggered reveal: JS (site.js) adds .in when an element enters the viewport. */
.reveal {
  opacity: 0; transform: translateY(22px);
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
}
.reveal.in { opacity: 1; transform: translateY(0); }
.reveal.d1 { transition-delay: .08s; }
.reveal.d2 { transition-delay: .16s; }

/* Reveal-stagger: direct children fade up in sequence once the container is in view. */
.reveal-stagger > * {
  opacity: 0; transform: translateY(20px);
  transition: opacity .6s var(--ease-out), transform .6s var(--ease-out);
}
.reveal-stagger.in > * { opacity: 1; transform: translateY(0); }
.reveal-stagger.in > *:nth-child(1) { transition-delay: .02s; }
.reveal-stagger.in > *:nth-child(2) { transition-delay: .10s; }
.reveal-stagger.in > *:nth-child(3) { transition-delay: .18s; }
.reveal-stagger.in > *:nth-child(4) { transition-delay: .26s; }
.reveal-stagger.in > *:nth-child(5) { transition-delay: .34s; }
.reveal-stagger.in > *:nth-child(6) { transition-delay: .42s; }

/* Hero: fires on load rather than scroll (it's already in view). */
.hero-copy > * { opacity: 0; animation: fadeUp .7s var(--ease-out) both; }
.hero-copy > .eyebrow  { animation-delay: .02s; }
.hero-copy > h1        { animation-delay: .10s; }
.hero-copy > .lede     { animation-delay: .24s; }
.hero-copy > .hero-cta { animation-delay: .38s; }
.hero-panel {
  opacity: 0; position: relative;
  animation: fadeUp .8s var(--ease-out) .2s both, float 7s ease-in-out 1.4s infinite;
}
.hero-chip .badge { opacity: 0; animation: fadeUp .5s var(--ease-out) both; }
.hero-chip .badge:nth-child(1) { animation-delay: .56s; }
.hero-chip .badge:nth-child(2) { animation-delay: .63s; }
.hero-chip .badge:nth-child(3) { animation-delay: .70s; }
.hero-chip .badge:nth-child(4) { animation-delay: .77s; }
.hero-chip .badge:nth-child(5) { animation-delay: .84s; }

@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal-stagger > *, .hero-copy > *, .hero-panel, .hero-chip .badge {
    opacity: 1 !important; transform: none !important; animation: none !important; transition: none !important;
  }
  body { animation: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 940px) {
  .hero-grid, .tool-grid, .grid-3, .grid-2, .grid-80-20, .field-row, .foot-cols { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .nav-center { display: none; }
  h1 { font-size: 2rem; } .hero { padding: 56px 0 40px; }
  .panel.sticky { position: static; }
  .article-item { grid-template-columns: 1fr; }
}
