/* ============================================================
   CSN Metrics — Design System
   Brand: blue → green (khớp logo). Data-dense, chuyên nghiệp.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Brand */
  --blue-900: #1e3a8a;
  --blue-800: #1e40af;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-400: #4ade80;

  --brand-gradient: linear-gradient(135deg, #1e40af 0%, #2563eb 45%, #22c55e 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(30,64,175,.08), rgba(34,197,94,.08));

  /* Semantic — light */
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --accent: #16a34a;
  --on-primary: #ffffff;

  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --fg: #0f172a;
  --fg-muted: #475569;
  --fg-subtle: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --up: #16a34a;
  --down: #dc2626;
  --ring: rgba(37, 99, 235, .45);

  /* Type */
  --font-sans: "Be Vietnam Pro", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Spacing & shape */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow: 0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 18px 50px -12px rgba(30,64,175,.28);
  --container: 1200px;
  --nav-h: 68px;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --accent: #22c55e;
  --on-primary: #06122e;

  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #18233b;
  --fg: #e9eef7;
  --fg-muted: #aab6cc;
  --fg-subtle: #8090a8;
  --border: #233149;
  --border-strong: #33425e;

  --up: #34d399;
  --down: #f87171;
  --ring: rgba(96,165,250,.5);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 6px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 22px 60px -14px rgba(0,0,0,.6);
  --brand-gradient-soft: linear-gradient(135deg, rgba(59,130,246,.14), rgba(34,197,94,.12));
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; color: var(--fg); letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
p { color: var(--fg-muted); }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
.section { padding-block: clamp(3.5rem, 7vw, 6rem); }
.tabnum { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.text-up { color: var(--up); }
.text-down { color: var(--down); }
.muted { color: var(--fg-subtle); }
.center { text-align: center; }
.gradient-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--primary);
  background: var(--brand-gradient-soft);
  border: 1px solid var(--border);
  padding: .4rem .85rem; border-radius: 999px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 46px; padding: .7rem 1.4rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: .98rem; line-height: 1;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { color: #fff; box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.btn-ghost { background: var(--surface); color: var(--fg); border-color: var(--border-strong); }
.btn-ghost:hover { color: var(--fg); border-color: var(--primary); background: var(--surface-2); }
.btn-sm { min-height: 38px; padding: .5rem 1rem; font-size: .9rem; }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav {
  height: var(--nav-h); display: flex; align-items: center; gap: 1.2rem;
}
.brand { display: flex; align-items: center; gap: .65rem; margin-right: auto; font-weight: 800; letter-spacing: -.02em; color: var(--fg); font-size: 1.18rem; }
.brand:hover { color: var(--fg); }
.brand .logo { width: 38px; height: 38px; flex: none; }
.brand small { display: block; font-size: .62rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-subtle); }
.brand b { line-height: 1; }

.nav-links { display: flex; align-items: center; gap: .25rem; list-style: none; }
.nav-links a {
  display: inline-block; padding: .55rem .8rem; border-radius: 8px;
  color: var(--fg-muted); font-weight: 500; font-size: .95rem;
  transition: background .15s ease, color .15s ease;
}
.nav-links a:hover { color: var(--fg); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--primary); font-weight: 600; background: var(--brand-gradient-soft); }

.nav-actions { display: flex; align-items: center; gap: .5rem; }
.theme-toggle, .nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--fg-muted);
  transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover, .nav-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }
.nav-toggle { display: none; }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: fixed; inset: var(--nav-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .5rem 16px 1rem; box-shadow: var(--shadow);
    transform: translateY(-130%); transition: transform .28s ease; visibility: hidden;
  }
  .nav-links.open { transform: translateY(0); visibility: visible; }
  .nav-links a { padding: .85rem .6rem; border-radius: 10px; font-size: 1rem; }
}

/* ---------- Hero ---------- */
.hero { position: relative; padding-block: clamp(3.5rem, 8vw, 7rem); overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 60% at 80% 0%, rgba(34,197,94,.12), transparent 60%),
    radial-gradient(55% 55% at 10% 10%, rgba(30,64,175,.14), transparent 60%);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.hero h1 { margin: 1rem 0; }
.hero p.lead { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--fg-muted); max-width: 42ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.8rem; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 1.8rem; margin-top: 2.4rem; }
.hero-stats div b { display: block; font-size: 1.7rem; font-weight: 800; color: var(--fg); }
.hero-stats div span { font-size: .85rem; color: var(--fg-subtle); }
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } .hero-visual { order: -1; } }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.card.hover:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card h3 { margin-bottom: .5rem; }
.card .icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 12px; margin-bottom: 1rem;
  background: var(--brand-gradient-soft); color: var(--primary);
}
.card .icon svg { width: 24px; height: 24px; }

.section-head { max-width: 720px; margin: 0 auto 2.6rem; text-align: center; }
.section-head p { margin-top: .8rem; }

/* ---------- KPI strip ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
@media (max-width: 760px) { .kpi-strip { grid-template-columns: repeat(2,1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.3rem; }
.kpi span { font-size: .82rem; color: var(--fg-subtle); }
.kpi b { display: block; font-size: 1.55rem; font-weight: 800; margin-top: .25rem; }

/* ---------- Ticker ---------- */
.ticker { background: var(--surface); border-block: 1px solid var(--border); overflow: hidden; }
.ticker-track { display: flex; gap: 2.2rem; padding: .7rem 0; white-space: nowrap; width: max-content; animation: ticker 40s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 500; }
.ticker-item .sym { font-weight: 700; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; flex-wrap: wrap; white-space: normal; width: 100%; } }

/* ---------- Market table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.market { width: 100%; border-collapse: collapse; min-width: 720px; }
table.market th, table.market td { padding: .9rem 1rem; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.market th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-subtle); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
table.market th:nth-child(1), table.market th:nth-child(2),
table.market td:nth-child(1), table.market td:nth-child(2) { text-align: left; }
table.market tbody tr { transition: background .12s; }
table.market tbody tr:hover { background: var(--surface-2); }
table.market td:last-child, table.market th:last-child { text-align: center; }
.coin-cell { display: inline-flex; align-items: center; gap: .65rem; }
.coin-cell img { width: 26px; height: 26px; border-radius: 50%; }
.coin-cell b { font-weight: 600; }
.coin-cell span { color: var(--fg-subtle); font-size: .8rem; text-transform: uppercase; }
.pill { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .5rem; border-radius: 6px; font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.pill.up { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.pill.down { color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }
.spark { width: 120px; height: 38px; }

.table-toolbar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-box input {
  width: 100%; height: 44px; padding: 0 1rem 0 2.6rem; font: inherit;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--fg);
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.search-box svg { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--fg-subtle); }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; color: transparent; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.state-msg { padding: 2.5rem 1rem; text-align: center; color: var(--fg-subtle); }
.state-msg .btn { margin-top: 1rem; }

/* ---------- Steps ---------- */
.steps { counter-reset: step; }
.step { position: relative; padding-left: 4rem; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 2.8rem; height: 2.8rem;
  display: grid; place-items: center; border-radius: 12px;
  background: var(--brand-gradient); color: #fff; font-weight: 800; font-size: 1.1rem;
}

/* ---------- Article / prose ---------- */
.prose { max-width: 760px; margin-inline: auto; }
.prose > * + * { margin-top: 1.1rem; }
.prose h2 { margin-top: 2.4rem; }
.prose h3 { margin-top: 1.8rem; }
.prose ul, .prose ol { padding-left: 1.4rem; color: var(--fg-muted); }
.prose li + li { margin-top: .4rem; }
.prose img { border-radius: var(--radius); margin-block: 1.5rem; }
.placeholder-note {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--brand-gradient-soft); padding: 1.2rem 1.4rem; color: var(--fg-muted);
}

/* ---------- Article cards ---------- */
.post { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.post .thumb { aspect-ratio: 16/9; background: var(--brand-gradient); display: grid; place-items: center; color: rgba(255,255,255,.85); }
.post .thumb svg { width: 54px; height: 54px; }
.post .body { padding: 1.3rem 1.4rem 1.5rem; display: flex; flex-direction: column; flex: 1; }
.post .tag { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.post h3 { margin: .5rem 0; font-size: 1.15rem; }
.post .meta { margin-top: auto; padding-top: 1rem; font-size: .82rem; color: var(--fg-subtle); }

/* ---------- FAQ ---------- */
.faq details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0 1.3rem; margin-bottom: .8rem; }
.faq summary { list-style: none; cursor: pointer; padding: 1.1rem 0; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; color: var(--primary); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding-bottom: 1.1rem; }

/* ---------- Breadcrumb ---------- */
.breadcrumb { font-size: .85rem; color: var(--fg-subtle); padding-top: 1.5rem; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; }
.breadcrumb li::after { content: "/"; margin-left: .4rem; color: var(--border-strong); }
.breadcrumb li:last-child::after { content: ""; }

/* ---------- Page hero (inner) ---------- */
.page-hero { padding-block: clamp(2.5rem, 5vw, 4rem) clamp(2rem, 4vw, 3rem); background: var(--brand-gradient-soft); border-bottom: 1px solid var(--border); }
.page-hero h1 { margin-top: .6rem; }
.page-hero p { margin-top: .8rem; max-width: 60ch; }

/* ---------- Form ---------- */
.form-grid { display: grid; gap: 1.1rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.field label .req { color: var(--down); }
.field input, .field textarea, .field select {
  width: 100%; padding: .8rem 1rem; font: inherit; color: var(--fg);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.field .help { font-size: .82rem; color: var(--fg-subtle); margin-top: .35rem; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: start; }
@media (max-width: 820px) { .contact-grid { grid-template-columns: 1fr; } }
.contact-item { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: 1.4rem; }
.contact-item .icon { flex: none; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-gradient-soft); color: var(--primary); }

/* ---------- CTA band ---------- */
.cta-band { background: var(--brand-gradient); border-radius: var(--radius-lg); padding: clamp(2.2rem, 5vw, 3.5rem); color: #fff; text-align: center; box-shadow: var(--shadow-lg); }
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.9); max-width: 52ch; margin: .8rem auto 1.8rem; }
.cta-band .btn-ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.4); }
.cta-band .btn-ghost:hover { background: rgba(255,255,255,.24); color: #fff; }
.cta-band .btn-primary { background: #fff; color: var(--blue-800); }
.cta-band .btn-primary:hover { color: var(--blue-800); }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding-block: 3.5rem 2rem; margin-top: 1rem; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 2rem; }
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.8rem; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-grid h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-subtle); margin-bottom: 1rem; }
.footer-grid ul { list-style: none; padding: 0; }
.footer-grid li { margin-bottom: .6rem; }
.footer-grid a { color: var(--fg-muted); font-size: .95rem; }
.footer-grid a:hover { color: var(--primary); }
.footer-grid p { font-size: .92rem; max-width: 32ch; }
.footer-social { display: flex; gap: .6rem; margin-top: 1.1rem; }
.footer-social a { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--fg-muted); }
.footer-social a:hover { color: var(--primary); border-color: var(--primary); }
.footer-bottom { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: .8rem; justify-content: space-between; font-size: .86rem; color: var(--fg-subtle); }

/* ---------- Disclaimer ---------- */
.disclaimer { font-size: .82rem; color: var(--fg-subtle); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; }

/* ---------- Skip link ---------- */
.skip-link { position: absolute; left: -999px; top: .5rem; z-index: 200; background: var(--primary); color: #fff; padding: .6rem 1rem; border-radius: 8px; }
.skip-link:focus { left: .5rem; color: #fff; }

/* ---------- Utilities ---------- */
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 2rem; } .mb-2 { margin-bottom: 2rem; }
.flex { display: flex; } .gap { gap: 1rem; } .wrap { flex-wrap: wrap; }
.list-check { list-style: none; padding: 0; }
.list-check li { position: relative; padding-left: 1.9rem; margin-bottom: .7rem; color: var(--fg-muted); }
.list-check li::before { content: ""; position: absolute; left: 0; top: .35em; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--brand-gradient-soft); background-size: cover; }
.list-check li::after { content: "✓"; position: absolute; left: .28rem; top: .1em; color: var(--accent); font-weight: 800; font-size: .85rem; }
