/* ── Reset & Tokens ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #F4F0E8;
  --bg-alt:      #ECE7DE;
  --surface:     #EAE5DB;
  --surface2:    #E2DDD3;
  --border:      rgba(100,88,72,0.16);
  --border2:     rgba(100,88,72,0.26);
  --accent:      #1D5246;
  --accent-soft: rgba(29,82,70,0.08);
  --brass:       #8A6B32;
  --brass-soft:  rgba(138,107,50,0.08);
  --text:        #1A1714;
  --muted:       #7A7063;
  --red:         #8B3A30;
  --green:       #2E6B50;
  --radius:      4px;
  --serif:       'DM Serif Display', Georgia, serif;
  --sans:        'DM Sans', system-ui, sans-serif;
  --mono:        'JetBrains Mono', monospace;
  --ease:        0.18s cubic-bezier(0.4,0,0.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
}

main { flex: 1; padding-top: 56px; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 3px; }

/* ── Container ── */
.container { max-width: 1140px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Navbar ── */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 56px;
  display: flex; align-items: center;
  padding: 0 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border2);
}
.nav-inner {
  width: 100%; max-width: 1140px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-logo {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: 0.01em;
}
.nav-links {
  display: flex; list-style: none; gap: 2rem;
}
.nav-links a {
  font-size: 0.82rem; color: var(--muted);
  transition: color var(--ease); font-weight: 500;
  letter-spacing: 0.02em; text-transform: uppercase;
}
.nav-links a:hover { color: var(--text); }
.nav-actions { display: flex; align-items: center; gap: 0.6rem; }
.nav-btn {
  font-size: 0.8rem; font-weight: 500; padding: 0.38rem 1rem;
  border-radius: 6px; transition: all var(--ease); cursor: pointer;
  letter-spacing: 0.02em;
}
.nav-btn-ghost {
  border: 1px solid var(--border2); color: var(--muted); background: transparent;
}
.nav-btn-ghost:hover { border-color: var(--brass); color: var(--text); }
.nav-btn-primary {
  background: var(--accent); color: #fff; border: none;
}
.nav-btn-primary:hover { background: #369e88; }

/* User menu */
.user-menu { position: relative; }
.user-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--border2);
  background: var(--surface); cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: border-color var(--ease);
}
.user-btn:hover { border-color: var(--brass); }
.user-avatar-letter {
  font-size: 0.8rem; font-weight: 600; color: var(--brass);
}
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 210px; background: var(--bg); border: 1px solid var(--border2);
  border-radius: var(--radius); overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.dropdown-email {
  padding: 0.65rem 0.9rem; font-size: 0.75rem; color: var(--muted);
  border-bottom: 1px solid var(--border); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dropdown-item {
  display: block; padding: 0.55rem 0.9rem; font-size: 0.82rem; color: var(--text);
  transition: background var(--ease);
}
.dropdown-item:hover { background: var(--surface); }
.dropdown-logout { color: var(--red); }

/* Mobile */
.mobile-toggle {
  display: none; flex-direction: column; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.mobile-toggle span {
  display: block; width: 20px; height: 1.5px; background: var(--muted);
  border-radius: 2px; transition: all var(--ease);
}
.mobile-menu {
  display: none; position: fixed; top: 56px; left: 0; right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border2); z-index: 99;
  flex-direction: column; padding: 0.75rem 1.5rem;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  padding: 0.65rem 0; font-size: 0.9rem; color: var(--muted);
  border-bottom: 1px solid var(--border); transition: color var(--ease);
}
.mobile-menu a:last-child { border-bottom: none; }
.mobile-menu a:hover { color: var(--text); }

/* ── Flash ── */
.flash-area {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 0.4rem;
  max-width: 440px; width: 90%;
}
.flash {
  padding: 0.65rem 1.1rem; border-radius: 8px;
  background: var(--accent-soft); border: 1px solid rgba(29,82,70,0.22);
  color: var(--accent); font-size: 0.85rem; text-align: center;
  animation: slideDown 0.3s ease;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.flash.fade-out { opacity: 0; transform: translateY(-10px); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Hero ── */
.hero {
  padding: 4.5rem 1.5rem 4rem; text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.hero-content { max-width: 620px; margin: 0 auto; }
.hero-tag {
  font-size: 0.72rem; color: var(--brass); font-family: var(--mono);
  font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  margin-bottom: 1.25rem;
}
.hero-title {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 1rem;
}
.hero-sub {
  font-size: 0.95rem; color: var(--muted); max-width: 480px;
  margin: 0 auto 2rem; line-height: 1.75;
}
.hero-btns {
  display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.6rem 1.5rem; border-radius: 7px; font-weight: 500;
  font-size: 0.85rem; cursor: pointer; transition: all var(--ease); border: none;
  font-family: var(--sans); letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: #369e88; }
.btn-ghost {
  border: 1px solid var(--border2); color: var(--text); background: transparent;
}
.btn-ghost:hover { border-color: var(--brass); color: var(--brass); }
.btn-full { width: 100%; }

/* ── Sections ── */
.section { padding: 4rem 0; }
.section-alt { background: var(--bg-alt); }

/* ── Page Header ── */
.page-header {
  padding: 2.5rem 0 1.5rem; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 400;
}
.page-sub { color: var(--muted); margin-top: 0.4rem; font-size: 0.88rem; }
.page-sub a { color: var(--accent); }
.page-sub a:hover { text-decoration: underline; }

/* ── KPI Cards ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.kpi-label {
  font-size: 0.7rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-family: var(--mono); font-weight: 500;
}
.kpi-value {
  font-size: 1.35rem; font-weight: 600;
  font-family: var(--sans);
  letter-spacing: -0.02em;
}
.kpi-change {
  font-size: 0.78rem; font-family: var(--mono);
}
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }

/* ── Market Tabs ── */
.market-tabs {
  display: flex; gap: 0; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.market-tab {
  padding: 0.6rem 1.25rem; font-size: 0.8rem; font-weight: 500;
  color: var(--muted); cursor: pointer; transition: all var(--ease);
  background: none; border: none; border-bottom: 2px solid transparent;
  font-family: var(--sans); letter-spacing: 0.02em;
  text-transform: uppercase;
}
.market-tab:hover { color: var(--text); }
.market-tab.active {
  color: var(--text); border-bottom-color: var(--brass);
}

/* ── Toolbar ── */
.market-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.search-box {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 0.45rem 0.9rem; flex: 1; max-width: 280px;
  transition: border-color var(--ease);
}
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--muted); flex-shrink: 0; }
.search-box input {
  background: none; border: none; outline: none; color: var(--text);
  font-size: 0.82rem; font-family: var(--sans); width: 100%;
}
.search-box input::placeholder { color: var(--muted); }
.market-meta { display: flex; align-items: center; gap: 0.6rem; font-size: 0.72rem; color: var(--muted); font-family: var(--mono); }
.status-dot::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--green); margin-right: 5px;
}

/* ── Data Table ── */
.table-wrap { overflow-x: auto; }
.market-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.market-table th {
  text-align: left; padding: 0.6rem 0.9rem; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  font-family: var(--mono); border-bottom: 1px solid var(--border2);
  white-space: nowrap; font-weight: 500;
}
.market-table td {
  padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border);
  white-space: nowrap; vertical-align: middle;
}
.market-table tbody tr { transition: background var(--ease); }
.market-table tbody tr:hover { background: var(--surface2); }
.th-rank { width: 42px; }
.th-price, .th-change, .th-mcap { text-align: right; }
.td-right { text-align: right; font-family: var(--mono); font-size: 0.83rem; }
.th-star { width: 42px; text-align: center; }
.th-chart { width: 100px; }

.coin-name-cell {
  display: flex; align-items: center; gap: 0.65rem;
}
.coin-img { width: 24px; height: 24px; border-radius: 50%; }
.coin-symbol { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; margin-left: 0.2rem; font-family: var(--mono); }

.change-up { color: var(--green); }
.change-down { color: var(--red); }

.star-btn {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  color: var(--muted); transition: color var(--ease); padding: 2px;
}
.star-btn:hover { color: var(--brass); }
.star-btn.starred { color: var(--brass); }

.sparkline-canvas { width: 100px; height: 28px; }

.loading-cell { text-align: center; padding: 2.5rem !important; }
.spinner {
  width: 24px; height: 24px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 3rem 0; color: var(--muted); }
.empty-state p { margin-bottom: 1.25rem; font-size: 0.95rem; }

/* ── Asset Table (stocks/commodities/forex) ── */
.asset-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.asset-table th {
  text-align: left; padding: 0.55rem 0.9rem;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-family: var(--mono); font-weight: 500;
  border-bottom: 1px solid var(--border2); white-space: nowrap;
}
.asset-table th.r { text-align: right; }
.asset-table td {
  padding: 0.58rem 0.9rem; border-bottom: 1px solid var(--border);
  white-space: nowrap; vertical-align: middle;
}
.asset-table tbody tr { transition: background var(--ease); }
.asset-table tbody tr:hover { background: var(--surface2); }
.asset-table tbody tr:last-child td { border-bottom: none; }
.asset-table td.r {
  text-align: right;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
  font-family: var(--mono); font-size: 0.83rem;
}
.asset-sym { font-weight: 600; font-size: 0.82rem; letter-spacing: 0.02em; }
.asset-name-text { font-size: 0.8rem; color: var(--muted); margin-top: 0.1rem; }

/* ── Sort controls ── */
.sort-group {
  display: flex; align-items: center; gap: 0.5rem;
}
.sort-label {
  font-size: 0.72rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--mono); font-weight: 500;
}
.sort-select {
  font-size: 0.82rem; font-family: var(--sans);
  padding: 0.38rem 0.75rem; border-radius: 5px;
  background: var(--surface); border: 1px solid var(--border2);
  color: var(--text); cursor: pointer; outline: none;
  transition: border-color var(--ease);
}
.sort-select:focus { border-color: var(--accent); }

/* ── Detail panel (expanded stock row) ── */
.detail-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  margin-top: 1rem;
}
.detail-header {
  display: flex; align-items: baseline; gap: 0.75rem;
  margin-bottom: 1rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.detail-sym { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.02em; }
.detail-name { font-size: 0.85rem; color: var(--muted); }
.detail-price { font-size: 1.2rem; font-weight: 600; font-family: var(--mono); margin-left: auto; }
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem 1.5rem;
}
.detail-item { display: flex; flex-direction: column; }
.detail-key {
  font-size: 0.68rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--mono); font-weight: 500;
}
.detail-val {
  font-size: 0.88rem; font-weight: 500; margin-top: 0.1rem;
  font-variant-numeric: tabular-nums;
}

/* Row clickable hint */
.asset-table tbody tr.clickable { cursor: pointer; }
.asset-table tbody tr.clickable:hover { background: var(--surface); }
.asset-table tbody tr.row-active { background: var(--surface2); }

/* ── Sparkline SVG ── */
.spark-svg { display: block; }

/* Fallback card grid (unused but kept for safety) */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

/* ── News ── */
.news-tabs {
  display: flex; gap: 0; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 0.55rem 1.1rem; font-size: 0.8rem;
  font-weight: 500; background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer; transition: all var(--ease);
  font-family: var(--sans);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--brass); }

.news-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.news-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  display: flex; flex-direction: column; gap: 0.4rem;
  transition: border-color var(--ease);
}
.news-card:hover { border-color: var(--border2); }
.news-card h3 {
  font-size: 0.92rem; font-weight: 500; line-height: 1.5;
}
.news-card h3 a { color: var(--text); transition: color var(--ease); }
.news-card h3 a:hover { color: var(--accent); }
.news-domain { font-size: 0.72rem; color: var(--accent); font-family: var(--mono); }
.news-meta {
  display: flex; gap: 0.75rem; font-size: 0.72rem; color: var(--muted); margin-top: auto;
  font-family: var(--mono);
}
.load-more-wrap { text-align: center; margin-top: 1.5rem; }

/* ── Home Sections ── */
.home-section-title {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: 1.5rem;
}
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}
.overview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  display: flex; justify-content: space-between; align-items: center;
  transition: border-color var(--ease);
}
.overview-card:hover { border-color: var(--border2); }
.ov-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.2rem; }
.ov-value { font-size: 1.1rem; font-weight: 600; font-family: var(--mono); }
.ov-change { font-size: 0.75rem; font-family: var(--mono); }

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2rem;
}
.feature-item {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--ease);
}
.feature-item:hover { border-color: var(--border2); }
.feature-item h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
}
.feature-item p {
  font-size: 0.85rem; color: var(--muted); line-height: 1.65; margin-bottom: 0.75rem;
}
.feature-link {
  font-size: 0.78rem; font-weight: 500; color: var(--accent);
  transition: color var(--ease);
}
.feature-link:hover { color: var(--brass); }

/* CTA */
.cta-section {
  text-align: center; max-width: 460px; margin: 0 auto;
  padding: 3rem 0;
}
.cta-section h2 {
  font-family: var(--serif);
  font-size: 1.5rem; font-weight: 400; margin-bottom: 0.6rem;
}
.cta-section p { color: var(--muted); margin-bottom: 1.75rem; font-size: 0.92rem; }

/* ── Auth ── */
.auth-section {
  min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center;
  padding: 2.5rem 1.5rem; background: var(--surface);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2.25rem;
}
.auth-card h1 {
  font-family: var(--serif);
  font-size: 1.4rem; font-weight: 400; margin-bottom: 0.2rem;
}
.auth-sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.75rem; }
.auth-card label {
  display: block; font-size: 0.72rem; font-weight: 500; color: var(--muted);
  margin-bottom: 0.35rem; margin-top: 0.9rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.auth-card label:first-of-type { margin-top: 0; }
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="text"] {
  width: 100%; padding: 0.6rem 0.9rem; font-size: 0.88rem;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 4px; color: var(--text); font-family: var(--sans);
  outline: none; transition: border-color var(--ease);
}
.auth-card input:focus { border-color: var(--accent); }
.auth-card input::placeholder { color: var(--muted); }
.auth-card .btn { margin-top: 1.25rem; }
.auth-links {
  text-align: center; margin-top: 1.25rem; font-size: 0.82rem; color: var(--muted);
}
.auth-links a { color: var(--brass); transition: color var(--ease); }
.auth-links a:hover { color: var(--text); }
.auth-divider { margin: 0 0.4rem; }

/* ── Footer ── */
footer {
  padding: 1.25rem 0; border-top: 1px solid var(--border); margin-top: auto;
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
}
.footer-logo {
  font-family: var(--serif);
  font-size: 0.88rem; color: var(--text);
}
.footer-copy { font-size: 0.7rem; color: var(--muted); }

/* ── Animations ── */
.fade-up {
  opacity: 0; transform: translateY(16px);
  animation: fadeUp 0.5s ease forwards;
}
.fade-up:nth-child(1) { animation-delay: 0.05s; }
.fade-up:nth-child(2) { animation-delay: 0.12s; }
.fade-up:nth-child(3) { animation-delay: 0.2s; }
.fade-up:nth-child(4) { animation-delay: 0.28s; }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.45s ease, transform 0.45s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-actions { display: none; }
  .mobile-toggle { display: flex; }
  .hide-mobile { display: none; }
  .feature-row { grid-template-columns: 1fr; }
  .news-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .asset-grid { grid-template-columns: 1fr; }
  .hero { padding: 3rem 1.5rem 3rem; }
  .footer-inner { justify-content: center; text-align: center; }
}
@media (max-width: 480px) {
  .section { padding: 2.5rem 0; }
  .hero-btns { flex-direction: column; align-items: center; }
  .auth-card { padding: 1.5rem; }
  .kpi-row { grid-template-columns: 1fr; }
}
