/* =========================================================
   Finance Capital — Global stylesheet
   Vanilla CSS, no external dependencies.
   ========================================================= */

:root {
  /* Light theme (default) */
  --bg: #f4f6f9;
  --bg-elevated: #ffffff;
  --bg-subtle: #eef1f6;
  --bg-hover: #f0f3f8;
  --text: #1a2233;
  --text-muted: #5a6679;
  --text-faint: #8a93a6;
  --border: #e2e6ee;
  --border-strong: #ccd2de;
  --accent: #1268d3;
  --accent-hover: #0f57b3;
  --accent-soft: #e7f0fc;
  --teal: #0d9488;
  --up: #138a4e;
  --up-bg: #e7f6ee;
  --down: #cc2d3a;
  --down-bg: #fdeaec;
  --shadow-sm: 0 1px 2px rgba(20, 30, 50, 0.06);
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08), 0 1px 2px rgba(20, 30, 50, 0.04);
  --shadow-lg: 0 8px 24px rgba(20, 30, 50, 0.10);
  --radius: 10px;
  --radius-sm: 6px;
  --nav-h: 60px;
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo,
    Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-subtle: #1c232d;
  --bg-hover: #20272f;
  --text: #e6edf3;
  --text-muted: #9aa6b4;
  --text-faint: #6e7a89;
  --border: #262d36;
  --border-strong: #353d48;
  --accent: #3b8aef;
  --accent-hover: #5b9ff2;
  --accent-soft: #14233b;
  --teal: #2dd4bf;
  --up: #2ec27e;
  --up-bg: #11271c;
  --down: #f0626f;
  --down-bg: #2a1417;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: 2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- Top bar / nav ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.nav {
  display: flex;
  align-items: center;
  height: var(--nav-h);
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1.18rem;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand svg { width: 26px; height: 26px; display: block; }
.brand .accent { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.nav-links a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.94rem;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}
.nav-links a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--accent); }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
html[data-theme="dark"] .theme-toggle .sun { display: none; }
html[data-theme="dark"] .theme-toggle .moon { display: block; }

.nav-toggle { display: none; }

/* ---------- Ticker tape ---------- */
.ticker {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}
.ticker-track {
  display: inline-flex;
  align-items: center;
  padding: 8px 0;
  will-change: transform;
  animation: ticker-scroll 60s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.ticker-item {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 0 18px;
  border-right: 1px solid var(--border);
  font-size: 0.86rem;
}
.ticker-item .sym { font-weight: 700; color: var(--text); }
.ticker-item .px { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ticker-item .chg { font-weight: 600; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
}

/* ---------- Hero / converter ---------- */
.hero {
  padding: 40px 0 28px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 40px;
  align-items: center;
}
.hero-copy .eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 14px;
}
.hero-copy h1 { font-size: 2.4rem; margin-bottom: 12px; }
.hero-copy .lead { font-size: 1.08rem; color: var(--text-muted); max-width: 32em; }
.hero-stats {
  display: flex;
  gap: 28px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.hero-stat .v { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-stat .l { font-size: 0.82rem; color: var(--text-faint); }

/* Converter card */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.converter {
  padding: 22px;
}
.converter h3 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.converter h3 svg { width: 18px; height: 18px; color: var(--accent); }
.conv-row { margin-bottom: 12px; }
.conv-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}
.conv-field {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.conv-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.conv-field input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 11px 13px;
  color: var(--text);
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.conv-field input:focus { outline: none; }
.conv-field select {
  border: none;
  border-left: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6679' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.conv-field select:focus { outline: none; }

.conv-swap {
  display: flex;
  justify-content: center;
  margin: -2px 0 10px;
}
.swap-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s, background 0.15s;
  box-shadow: var(--shadow-sm);
}
.swap-btn:hover { background: var(--accent-soft); }
.swap-btn.spin { transform: rotate(180deg); }
.swap-btn svg { width: 18px; height: 18px; }

.conv-result {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.conv-result .out {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.conv-result .out .ccy { font-size: 1rem; color: var(--text-muted); font-weight: 600; margin-left: 4px; }
.conv-rate {
  margin-top: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.conv-rate .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 3px var(--up-bg);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.45} }

/* ---------- Sections ---------- */
.section { padding: 30px 0; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}
.section-head h2 { margin: 0; }
.section-head .sub { color: var(--text-faint); font-size: 0.88rem; margin: 2px 0 0; }
.updated {
  font-size: 0.8rem;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.updated .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); animation: pulse 2s infinite; }
.updated.stale .dot { background: var(--text-faint); animation: none; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th, table.data td {
  padding: 12px 16px;
  text-align: right;
  white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
table.data tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data td { color: var(--text); font-variant-numeric: tabular-nums; }
.coin-cell { display: flex; align-items: center; gap: 11px; }
.coin-badge {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.72rem; color: #fff;
  flex-shrink: 0;
}
.coin-name { display: flex; flex-direction: column; line-height: 1.2; }
.coin-name .nm { font-weight: 600; }
.coin-name .tk { font-size: 0.78rem; color: var(--text-faint); }
.pair-cell { font-weight: 600; }
.pair-cell small { color: var(--text-faint); font-weight: 400; }

.chg-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.84rem;
}
.chg-up { color: var(--up); background: var(--up-bg); }
.chg-down { color: var(--down); background: var(--down-bg); }
.chg-up svg, .chg-down svg { width: 11px; height: 11px; }

.spark { display: block; }

/* ---------- Chart ---------- */
.chart-card { padding: 20px; }
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}
.chart-title { display: flex; align-items: baseline; gap: 12px; }
.chart-title .price { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.asset-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.asset-tab {
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
}
.asset-tab:hover { background: var(--bg-hover); }
.asset-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chart-canvas-wrap { position: relative; width: 100%; }
#priceChart { display: block; width: 100%; height: 280px; }

/* ---------- News ---------- */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.news-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
}
.news-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.news-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 8px;
}
.news-card h3 { font-size: 1rem; margin: 0 0 8px; }
.news-card h3 a { color: var(--text); }
.news-card h3 a:hover { color: var(--accent); text-decoration: none; }
.news-card p { font-size: 0.88rem; color: var(--text-muted); margin: 0 0 12px; flex: 1; }
.news-meta {
  font-size: 0.78rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}
.news-meta .src { font-weight: 600; color: var(--text-muted); }

/* ---------- CTA strip ---------- */
.cta {
  background: linear-gradient(120deg, var(--accent), var(--teal));
  color: #fff;
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.cta h2 { color: #fff; margin: 0 0 6px; }
.cta p { color: rgba(255,255,255,0.88); margin: 0; max-width: 40em; }
.cta .btn { background: #fff; color: var(--accent); border-color: #fff; white-space: nowrap; }
.cta .btn:hover { background: #f0f4fa; }

/* ---------- Footer ---------- */
.footer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 44px 0 24px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr);
  gap: 32px;
}
.footer-brand .brand { margin-bottom: 12px; }
.footer-brand p { font-size: 0.88rem; color: var(--text-muted); max-width: 28em; }
.footer-social { display: flex; gap: 10px; margin-top: 14px; }
.footer-social a {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.footer-social a:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--border-strong); }
.footer-social svg { width: 17px; height: 17px; }
.footer-col h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin: 0 0 12px;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { color: var(--text-muted); font-size: 0.9rem; }
.footer-col a:hover { color: var(--accent); text-decoration: none; }
.footer-bottom {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-bottom p { margin: 0; font-size: 0.82rem; color: var(--text-faint); }
.footer-disclaimer { font-size: 0.78rem; color: var(--text-faint); margin-top: 8px; }

/* ---------- Content pages ---------- */
.page-hero {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 44px 0;
}
.page-hero .eyebrow {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
}
.page-hero h1 { margin: 8px 0 6px; font-size: 2.1rem; }
.page-hero p { color: var(--text-muted); margin: 0; max-width: 44em; }
.prose {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 20px;
}
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: 6px; }
.prose .muted { color: var(--text-muted); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.value-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 24px 0;
}
.value-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.value-card .ic {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.value-card .ic svg { width: 20px; height: 20px; }
.value-card h3 { font-size: 1rem; margin: 0 0 6px; }
.value-card p { font-size: 0.9rem; color: var(--text-muted); margin: 0; }

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}
.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; }
.field-group input, .field-group textarea, .field-group select {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.field-group input:focus, .field-group textarea:focus, .field-group select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-group textarea { resize: vertical; min-height: 120px; }
.form-note { font-size: 0.82rem; color: var(--text-faint); margin-top: 4px; }
.contact-info dt { font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); margin-top: 16px; }
.contact-info dd { margin: 4px 0 0; }

.badge-soft {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--teal);
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .hero-copy h1 { font-size: 1.9rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px 24px; }
  .footer-brand { grid-column: 1 / -1; }
  .contact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  h1 { font-size: 1.7rem; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    flex-direction: column;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 8px 12px;
    gap: 2px;
    margin: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 11px 12px; }
  .nav-toggle { display: inline-flex; }
  .hero { padding: 26px 0 18px; }
  .hero-copy h1 { font-size: 1.6rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
  .cta { padding: 24px; }
  .section { padding: 22px 0; }
}
@media (max-width: 420px) {
  .footer-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 18px; }
}
