@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #f1f4f2;
  --line: #e5e9e7;
  --text: #0e1512;
  --muted: #6b7570;
  --green: #00c853;
  --green-dark: #00a844;
  --green-tint: rgba(0,200,83,0.08);
  --red: #ff3b30;
  --red-tint: rgba(255,59,48,0.08);
  --amber: #ff9500;
  --blue: #3d6bff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16,24,20,0.04), 0 8px 24px rgba(16,24,20,0.06);
  --shadow-lg: 0 4px 12px rgba(16,24,20,0.06), 0 16px 40px rgba(16,24,20,0.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 800; letter-spacing: -0.03em; margin: 0; }
.mono { font-family: 'JetBrains Mono', monospace; }
a { color: inherit; text-decoration: none; }

/* ---------- Top nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--line);
}

.topnav-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 28px;
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 17px; letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 12px rgba(0,200,83,0.35);
}
.brand-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--amber); background: rgba(255,149,0,0.12);
  padding: 3px 7px; border-radius: 5px; margin-left: 2px;
}

.main-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-link {
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 14px;
  color: var(--muted); transition: all .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--green-tint); color: var(--green-dark); }
.nav-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.admin-link { color: var(--amber); }
.admin-link.active { background: rgba(255,149,0,0.12); color: var(--amber); }

.topnav-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.balance-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 14px;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(0,200,83,0.5);
  animation: pulse-dot 1.8s infinite;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(0,200,83,0.45); }
  70% { box-shadow: 0 0 0 7px rgba(0,200,83,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,200,83,0); }
}
.logout-btn {
  font-weight: 600; font-size: 14px; color: var(--muted);
  padding: 8px 14px; border-radius: 10px; transition: all .15s ease;
}
.logout-btn:hover { background: var(--red-tint); color: var(--red); }

/* ---------- Ticker tape ---------- */
.ticker-wrap {
  overflow: hidden; border-top: 1px solid var(--line);
  background: #0e1512;
  mask-image: linear-gradient(90deg, transparent, black 4%, black 96%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, black 4%, black 96%, transparent);
}
.ticker-track {
  display: flex; width: max-content;
  animation: ticker-scroll 38s linear infinite;
}
.ticker-wrap:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-33.333%); }
}
.ticker-item {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 22px; font-size: 13px; font-weight: 600; color: #cfd8d3;
  white-space: nowrap; border-right: 1px solid rgba(255,255,255,0.08);
}
.ticker-item b { color: #fff; font-weight: 700; }
.ticker-dot { width: 6px; height: 6px; border-radius: 50%; }
.ticker-dot.crypto { background: var(--blue); }
.ticker-dot.stock { background: var(--amber); }

/* ---------- Layout ---------- */
.content { max-width: 1280px; margin: 0 auto; padding: 32px 28px 60px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 14px; }

.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.3fr 1fr; }

/* ---------- Cards ---------- */
.card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow);
  animation: card-in .5s ease both;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card + .card { animation-delay: .05s; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card h3 { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.card .big { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; font-family: 'JetBrains Mono', monospace; }
.card .delta { font-size: 13px; font-weight: 700; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }

.paper-stamp {
  position: absolute; top: 12px; right: -30px; transform: rotate(35deg);
  background: var(--amber); color: #2b1900;
  font-weight: 800; font-size: 10px; letter-spacing: 0.1em;
  padding: 3px 36px; text-transform: uppercase;
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--line); }
tbody tr { border-bottom: 1px solid var(--line); transition: background .12s ease; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.asset-cell { display: flex; align-items: center; gap: 10px; }
.asset-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: #fff; flex-shrink: 0;
}

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

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge.buy { background: var(--green-tint); color: var(--green-dark); }
.badge.sell { background: var(--red-tint); color: var(--red); }
.badge.crypto { background: rgba(61,107,255,0.1); color: var(--blue); }
.badge.stock { background: rgba(255,149,0,0.12); color: var(--amber); }
.badge.admin { background: rgba(255,149,0,0.12); color: var(--amber); }

/* ---------- Forms ---------- */
input, select, button {
  font-family: inherit; font-size: 14px;
  background: var(--surface-2); color: var(--text);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px;
  width: 100%; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-tint); }

button {
  cursor: pointer; font-weight: 700; border: none;
  background: var(--green); color: #fff;
  box-shadow: 0 4px 14px rgba(0,200,83,0.3);
  transition: transform .1s ease, box-shadow .15s ease, opacity .15s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,200,83,0.4); }
button:active { transform: translateY(0); }
button.secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--line); box-shadow: none; }
button.secondary:hover { background: var(--surface-2); box-shadow: none; }
button.danger { background: var(--red); box-shadow: 0 4px 14px rgba(255,59,48,0.3); }
button.danger:hover { box-shadow: 0 6px 18px rgba(255,59,48,0.4); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }

.trade-toggle { display: flex; gap: 10px; margin-bottom: 18px; }

.flash { padding: 13px 16px; border-radius: 12px; margin-bottom: 20px; font-size: 14px; font-weight: 600; }
.flash.ok { background: var(--green-tint); color: var(--green-dark); border: 1px solid rgba(0,200,83,0.25); }
.flash.err { background: var(--red-tint); color: var(--red); border: 1px solid rgba(255,59,48,0.25); }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(0,200,83,0.08), transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(61,107,255,0.06), transparent 45%),
              var(--bg);
  padding: 20px;
}
.auth-card {
  width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 36px; box-shadow: var(--shadow-lg);
  animation: card-in .5s ease both;
}
.auth-card .brand { justify-content: flex-start; }
.brand-sub { color: var(--amber); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.muted { color: var(--muted); }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.text-right { text-align: right; }
.small { font-size: 12.5px; }

@media (max-width: 900px) {
  .main-nav { display: none; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 40px; }
  .topnav-inner { padding: 12px 16px; }
}
