/* ============ APEX CAPITAL — shared theme ============ */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,300;12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,500;1,9..144,300;1,9..144,400&family=JetBrains+Mono:wght@300;400;500;600&display=swap');

:root {
  --black: #050505;
  --ink: #0a0a0a;
  --surface: #111111;
  --surface-2: #161616;
  --surface-3: #1c1c1c;
  --line: #1f1f1f;
  --line-2: #2a2a2a;
  --bone: #f4f1ea;
  --muted: #7a7a78;
  --dim: #4a4a48;
  --acid: #d4ff3a;
  --acid-dim: #a3c92e;
  --buy: #4ade80;
  --sell: #ff4d4d;
  --plasma: #b57aff;
  --hot: #ff5e2e;
  --gold: #d4a93a;
  --danger: #ff4d4d;
  --warn: #ffb800;
  --ok: #4ade80;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
::selection { background: var(--acid); color: var(--black); }

html { scroll-behavior: smooth; }
body {
  background: var(--black);
  color: var(--bone);
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9999;
  opacity: 0.04; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--line-2); }
::-webkit-scrollbar-thumb:hover { background: var(--acid); }

a { color: inherit; text-decoration: none; }
.serif { font-family: 'Fraunces', serif; font-style: italic; font-weight: 400; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ============ APP NAV ============ */
.app-nav {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: rgba(5,5,5,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}
.app-nav .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -0.03em; font-size: 18px;
}
.logo-mark {
  width: 22px; height: 22px;
  background: var(--acid);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  position: relative;
}
.logo-mark::after {
  content: ''; position: absolute; inset: 30%;
  background: var(--black);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
.app-nav-links {
  display: flex; align-items: center; gap: 2px;
  list-style: none; padding: 0; margin: 0;
}
.app-nav-links > li { display: flex; align-items: center; }
.app-nav-links a, .app-nav-links .nav-dd-trigger {
  display: inline-flex; align-items: center;
  height: 36px; padding: 0 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}
.app-nav-links a:hover,
.app-nav-links .nav-dd:hover .nav-dd-trigger,
.app-nav-links .nav-dd:focus .nav-dd-trigger,
.app-nav-links .nav-dd:focus-within .nav-dd-trigger {
  color: var(--bone);
}
.app-nav-links a.active,
.app-nav-links .nav-dd-trigger.active {
  color: var(--acid);
  border-color: var(--line-2);
  background: var(--surface);
}

.app-nav-right { display: flex; align-items: center; gap: 14px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
}
.user-chip .avatar {
  width: 26px; height: 26px;
  background: var(--acid);
  color: var(--black);
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px;
  border-radius: 50%;
}

/* WS live indicator */
.ws-indicator {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted);
  cursor: default;
}
.ws-indicator .ws-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
}
.ws-indicator.on {
  color: var(--buy); border-color: rgba(74,222,128,0.4);
}
.ws-indicator.on .ws-dot {
  background: var(--buy);
  animation: pulse-live 1.4s ease-in-out infinite;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74,222,128,0.4); }
  50%      { opacity: 0.5; box-shadow: 0 0 0 4px rgba(74,222,128,0); }
}

/* Price flash on update */
@keyframes flash-up   { 0% { background: rgba(74,222,128,0.35); } 100% { background: transparent; } }
@keyframes flash-down { 0% { background: rgba(255,77,77,0.35); } 100% { background: transparent; } }
.flash-up   { animation: flash-up   0.6s ease-out; }
.flash-down { animation: flash-down 0.6s ease-out; }

/* nav dropdown */
.nav-dd { position: relative; outline: none; }
.nav-dd-menu {
  position: absolute; top: 100%; left: 0;
  min-width: 180px;
  background: var(--ink);
  border: 1px solid var(--line-2);
  list-style: none;
  padding: 6px;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s;
}
.nav-dd:hover .nav-dd-menu, .nav-dd:focus .nav-dd-menu, .nav-dd:focus-within .nav-dd-menu {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.nav-dd-menu a {
  display: block; padding: 8px 12px;
  font-size: 13px; color: var(--bone);
  border-left: 2px solid transparent;
}
.nav-dd-menu a:hover { background: var(--surface); border-color: var(--acid); }
.nav-dd-menu a.active { color: var(--acid); border-color: var(--acid); }

/* ============ WIDGETS ============ */
.widget {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.widget-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.widget-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted);
}
.widget-action a, .widget-action button {
  font-size: 11px;
  color: var(--muted);
  background: none; border: 0;
  cursor: pointer;
  font-family: inherit;
}
.widget-action a:hover, .widget-action button:hover { color: var(--acid); }

/* mini stats */
.mini-stat { padding: 14px 18px; }
.mini-stat .lbl { font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.18em; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.mini-stat .val { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; font-family: 'Bricolage Grotesque', sans-serif; }
.mini-stat .meta { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-top: 3px; }

/* ============ BUTTONS ============ */
.btn {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 22px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--bone);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { border-color: var(--bone); background: var(--surface); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--acid);
  border-color: var(--acid);
  color: var(--black);
  font-weight: 600;
}
.btn-primary:hover { background: var(--acid-dim); border-color: var(--acid-dim); color: var(--black); }
.btn-buy { background: var(--buy); border-color: var(--buy); color: var(--black); font-weight: 600; }
.btn-buy:hover { background: #65e898; border-color: #65e898; color: var(--black); }
.btn-sell { background: var(--sell); border-color: var(--sell); color: var(--bone); font-weight: 600; }
.btn-sell:hover { background: #ff6464; border-color: #ff6464; color: var(--bone); }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--bone); background: var(--surface); }
.btn-xl { padding: 16px 32px; font-size: 14px; }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-block { width: 100%; }

/* ============ INPUTS ============ */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field label {
  font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--muted); font-family: 'JetBrains Mono', monospace;
}
.input, .select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--bone);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 15px;
  padding: 13px 16px;
  transition: border-color 0.2s, background 0.2s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--acid);
  background: var(--surface-2);
}
.input.error { border-color: var(--danger); }
.input::placeholder { color: var(--dim); }
.input-help { font-size: 11px; color: var(--muted); margin-top: -4px; }

/* ============ CARD ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 24px;
}
.card-title {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); font-family: 'JetBrains Mono', monospace;
  margin-bottom: 16px;
}

/* ============ ALERTS ============ */
.alert {
  padding: 12px 16px;
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.alert-error { border-color: var(--danger); background: rgba(255,77,77,0.08); color: var(--danger); }
.alert-ok { border-color: var(--ok); background: rgba(74,222,128,0.08); color: var(--ok); }
.alert-info { border-color: var(--line-2); background: var(--surface); color: var(--bone); }

/* ============ AUTH PAGES ============ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } }
.auth-aside {
  background: var(--ink);
  border-right: 1px solid var(--line);
  padding: 50px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-aside::before {
  content: '';
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at 30% 30%, rgba(212,255,58,0.1), transparent 50%);
  pointer-events: none;
}
.auth-aside-content { position: relative; z-index: 2; max-width: 460px; }
.auth-aside h1 {
  font-size: clamp(36px, 4vw, 56px);
  letter-spacing: -0.04em;
  line-height: 1;
  font-weight: 600;
  margin: 40px 0 24px;
}
.auth-aside p { color: var(--muted); font-size: 15px; line-height: 1.6; }
.auth-aside .pills {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 28px;
  position: relative; z-index: 2;
}
.auth-aside .pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.15em;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--muted);
}
.auth-main {
  padding: 50px;
  display: flex; align-items: center; justify-content: center;
}
.auth-form-wrap { width: 100%; max-width: 420px; }
.auth-form-wrap h2 {
  font-size: 32px; letter-spacing: -0.03em; margin-bottom: 8px; font-weight: 600;
}
.auth-form-wrap .subtitle { color: var(--muted); font-size: 14px; margin-bottom: 36px; }
.auth-form-wrap .switch {
  margin-top: 28px; font-size: 13px; color: var(--muted); text-align: center;
}
.auth-form-wrap .switch a { color: var(--acid); border-bottom: 1px solid var(--acid); }

/* ============ APP LAYOUT ============ */
.app-shell { min-height: 100vh; }
.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 36px; flex-wrap: wrap; gap: 16px;
}
.page-title {
  font-size: clamp(32px, 4vw, 48px);
  letter-spacing: -0.03em;
  font-weight: 600;
  line-height: 1.05;
}
.page-subtitle {
  color: var(--muted); font-size: 14px; margin-top: 6px;
}

/* ============ STAT GRID ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  margin-bottom: 40px;
  border: 1px solid var(--line);
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--ink);
  padding: 24px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-size: 32px; font-weight: 500; letter-spacing: -0.02em;
}
.stat-meta {
  font-size: 12px; color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ============ TABLE ============ */
.tbl {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left; padding: 14px 16px;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 500;
}
.tbl td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.tbl tbody tr { transition: background 0.15s; }
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr:last-child td { border-bottom: 0; }

.pct-up { color: var(--buy); }
.pct-dn { color: var(--sell); }
.muted { color: var(--muted); }

/* ============ ICON ASSET ============ */
.asset-icon {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.asset-icon.btc { background: linear-gradient(135deg, #f7931a, #fdb147); color: #fff; }
.asset-icon.eth { background: linear-gradient(135deg, #627eea, #8fa3f1); color: #fff; }
.asset-icon.sol { background: linear-gradient(135deg, #9945ff, #14f195); color: #fff; }
.asset-icon.usdt { background: #26a17b; color: #fff; }
.asset-icon.brl { background: linear-gradient(135deg, #009c3b, #ffcc29); color: #fff; }
.asset-icon.xrp { background: #000; color: #fff; border: 1px solid #fff; }
.asset-icon.ada { background: #0033ad; color: #fff; }
.asset-icon.doge { background: #c2a633; color: #000; }
.asset-icon.avax { background: #e84142; color: #fff; }
.asset-icon.matic { background: #8247e5; color: #fff; }

.pair-cell { display: flex; align-items: center; gap: 12px; }
.pair-name { font-weight: 500; }
.pair-sym { font-size: 11px; color: var(--muted); }

/* ============ EMPTY ============ */
.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-2);
}

/* ============ UTIL ============ */
.row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.center { text-align: center; }
.kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
}
