/* ============================================================
   QuantX — design system
   ============================================================ */
:root {
  --bg: #06070b;
  --bg-soft: #090b11;
  --surface: #0e1118;
  --surface-2: #141822;
  --surface-3: #1a1f2c;
  --line: #1b2130;
  --line-strong: #283044;
  --text: #e9edf7;
  --muted: #8b95ad;
  --dim: #5d6579;
  --up: #17c964;
  --up-soft: rgba(23, 201, 100, 0.12);
  --down: #ff4d5e;
  --down-soft: rgba(255, 77, 94, 0.12);
  --accent: #6c8cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(108, 140, 255, 0.14);
  --warn: #ffb020;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.85);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --topbar: 62px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.008em;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(108, 140, 255, 0.10), transparent 60%),
    radial-gradient(760px 460px at 90% 0%, rgba(34, 211, 238, 0.07), transparent 62%);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.025em; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232a3a; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #313a50; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.fs-11 { font-size: 11px; } .fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; }
.fs-18 { font-size: 18px; } .fs-22 { font-size: 22px; } .fs-28 { font-size: 28px; }
.w600 { font-weight: 600; } .w700 { font-weight: 700; }

/* ------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 20px;
  background: rgba(9, 11, 17, 0.82);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; letter-spacing: -0.04em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px rgba(108, 140, 255, 0.8);
}
.brand-mark svg { width: 17px; height: 17px; }

.nav { display: flex; gap: 2px; }
.nav a {
  padding: 8px 13px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 550;
  font-size: 13.5px;
  transition: background .16s, color .16s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-3); }

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

.balance-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12.5px;
}
.balance-chip .lbl { color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12.5px; color: #05060a;
  flex: none;
}

/* ---------------------------------------------------------- ticker tape */

.tape {
  display: flex; gap: 0; overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  height: 38px;
  position: relative;
}
.tape-track { display: flex; align-items: center; gap: 26px; padding: 0 20px; animation: tape 60s linear infinite; white-space: nowrap; }
.tape:hover .tape-track { animation-play-state: paused; }
@keyframes tape { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tape-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; }
.tape-item b { font-weight: 600; color: var(--muted); }

/* ------------------------------------------------------------- surfaces */

.page { position: relative; z-index: 1; padding: 22px; max-width: 1560px; margin: 0 auto; }
.page.wide { max-width: none; padding: 14px; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 40%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 620; font-size: 13.5px;
}
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }

/* --------------------------------------------------------------- inputs */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 550; }

.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--mono);
  font-size: 13.5px;
}
textarea.input, select.input { font-family: var(--sans); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--dim); font-family: var(--sans); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b95ad' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }

.input-group { position: relative; }
.input-group .suffix { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 11.5px; color: var(--dim); pointer-events: none; }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-weight: 600; font-size: 13px;
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: #333c52; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #4f6ef0); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.09); background: linear-gradient(135deg, var(--accent), #4f6ef0); }
.btn-buy { background: linear-gradient(135deg, #14b85c, #0f9c4c); border-color: transparent; color: #fff; }
.btn-sell { background: linear-gradient(135deg, #f0455a, #d8324a); border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 3px; padding: 3px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; }
.tabs button {
  flex: 1; padding: 7px 13px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-weight: 570; font-size: 12.5px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.tabs.buy-sell button.active[data-side='BUY'] { background: var(--up); color: #04140b; }
.tabs.buy-sell button.active[data-side='SELL'] { background: var(--down); color: #1a0206; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 12px; color: var(--muted); cursor: pointer;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: #38415a; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: #cdd8ff; }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 620; letter-spacing: .01em;
  border: 1px solid transparent;
}
.badge-up { background: var(--up-soft); color: var(--up); }
.badge-down { background: var(--down-soft); color: var(--down); }
.badge-neutral { background: var(--surface-3); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: #b3c4ff; }
.badge-warn { background: rgba(255, 176, 32, .13); color: var(--warn); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.live { background: var(--up); box-shadow: 0 0 0 0 rgba(23, 201, 100, .6); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(23, 201, 100, .55); }
  70% { box-shadow: 0 0 0 7px rgba(23, 201, 100, 0); }
  100% { box-shadow: 0 0 0 0 rgba(23, 201, 100, 0); }
}

/* --------------------------------------------------------------- tables */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 9px 14px;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .075em;
  color: var(--dim); background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.table td { padding: 11px 14px; border-bottom: 1px solid rgba(27, 33, 48, .65); }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: rgba(255, 255, 255, .022); }
.table tbody tr.clickable { cursor: pointer; }
.table .right, .table th.right { text-align: right; }
.table-wrap { overflow: auto; max-height: 100%; }

/* price flash */
.flash-up { animation: flashUp .7s ease-out; }
.flash-down { animation: flashDown .7s ease-out; }
@keyframes flashUp { 0% { background: rgba(23, 201, 100, .22); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: rgba(255, 77, 94, .22); } 100% { background: transparent; } }

/* -------------------------------------------------------------- helpers */

.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); font-weight: 600; }
.stat .v { font-size: 19px; font-weight: 660; font-family: var(--mono); letter-spacing: -.02em; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
  height: 13px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -100% 0; } }

.empty { padding: 44px 20px; text-align: center; color: var(--dim); font-size: 13px; }
.empty svg { width: 34px; height: 34px; opacity: .45; margin-bottom: 10px; }

.divider { height: 1px; background: var(--line); margin: 14px 0; }

.sparkline { width: 92px; height: 26px; display: block; }

.progress { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* --------------------------------------------------------------- toasts */

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 370px; }
.toast {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: 11px;
  box-shadow: var(--shadow);
  animation: toastIn .28s cubic-bezier(.2, .9, .3, 1.3);
  font-size: 13px;
}
.toast.ok { border-left-color: var(--up); }
.toast.err { border-left-color: var(--down); }
.toast.warn { border-left-color: var(--warn); }
.toast .t { font-weight: 620; margin-bottom: 2px; }
.toast .m { color: var(--muted); font-size: 12.5px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(28px) scale(.96); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(4, 5, 8, .74);
  backdrop-filter: blur(5px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: modalIn .24s cubic-bezier(.2, .9, .3, 1.15);
  max-height: 88vh; overflow: auto;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: 17px 19px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 19px; }
.modal-foot { padding: 15px 19px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.icon-btn { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 7px; line-height: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .nav { display: none; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page { padding: 14px; }
}
