 :root {
  /* Dark theme base */
  --bg: #0b0e11;
  --panel: #131722;
  --panel-2: #0f1320;
  --text: #e5e7eb;
  --muted: #9aa3af;
  --up: #16a34a;
  --down: #ef4444;
  --border: #1f2937;

  /* M365 Copilot-like gradient (violet → blue → cyan) */
  --accent1: #8b5cf6; /* violet-500 */
  --accent2: #3b82f6; /* blue-500  */
  --accent3: #06b6d4; /* cyan-500  */
}

/* Utility gradient class */
.gradient {
  background: linear-gradient(135deg, var(--accent1), var(--accent2), var(--accent3));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Top nav */
.topnav {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 16px;
  padding: 12px 20px; background: rgba(15, 19, 32, 0.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-img { height: 28px; width: 28px; border-radius: 6px; display: inline-block; object-fit: cover; }
.brand-name { font-weight: 700; letter-spacing: .3px; }
.menu { justify-self: center; display: none; gap: 18px; }
.menu a { color: var(--muted); text-decoration: none; }
.menu a:hover { color: var(--text); }
.actions { justify-self: end; display: flex; gap: 10px; }
.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
}
.btn.primary {
  border: none; color: #0b0e11; font-weight: 700;
  background: linear-gradient(135deg, var(--accent1), var(--accent2), var(--accent3));
}
.btn.ghost { background: #0f1320; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.buy { background: var(--up); border-color: transparent; margin-right: 8px; }
.btn.sell { background: var(--down); border-color: transparent; }

@media (min-width: 900px) {
  .menu { display: flex; }
}

/* Ticker */
.ticker {
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: #0f1320;
}
.ticker-track {
  display: flex; gap: 28px; padding: 10px 20px;
  white-space: nowrap; animation: slide 40s linear infinite;
}
.ticker-item { display: inline-flex; gap: 10px; color: var(--muted); }
.ticker-item .sym { color: var(--text); font-weight: 600; }
.ticker-item .price { color: var(--text); }
.ticker-item .chg.up { color: var(--up); }
.ticker-item .chg.down { color: var(--down); }

@keyframes slide { from { transform: translateX(0) } to { transform: translateX(-50%) } }

/* Layout */
.layout {
  display: grid; gap: 12px; padding: 12px; max-width: 1500px; margin: 0 auto;
  grid-template-areas:
    "markets"
    "trade"
    "orderbook"
    "trades"
    "wallets"
    "deposit";
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--panel-2); border-bottom: 1px solid var(--border);
}
.panel-body { padding: 12px 14px; }

.markets { grid-area: markets; }
.trade   { grid-area: trade; }
.orderbook { grid-area: orderbook; }
.trades { grid-area: trades; }
.wallets { grid-area: wallets; }
.deposit { grid-area: deposit; }

@media (min-width: 1100px) {
  .layout {
    grid-template-columns: 320px 1fr 360px;
    grid-template-areas:
      "markets trade orderbook"
      "trades  trade orderbook"
      "wallets wallets deposit";
  }
}

/* Tables & inputs */
.input {
  width: 100%; background: #0b0f1a; border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 10px;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 10px 8px; border-bottom: 1px solid var(--border);
}
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .3px; }
.table td.right, .table th.right { text-align: right; }
.row { cursor: pointer; }
.row:hover { background: #0f1320; }

/* Trade */
.pair-info h2 { margin: 0 0 4px 0; }
.stats { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.chart-wrap { height: 380px; }
.sub-panel { border-top: 1px solid var(--border); background: #0f1320; }
.tabs { display: flex; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tab { background: #0b0f1a; color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; cursor: pointer; }
.tab.active { background: linear-gradient(135deg, var(--accent1), var(--accent2), var(--accent3)); color: #0b0e11; border-color: transparent; }

.order-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 14px;
}
.col-span-2 { grid-column: span 2; }
.label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.mt8 { margin-top: 8px; }

/* Order book */
.orderbook-body {
  display: grid; grid-template-columns: 1fr 100px 1fr; gap: 8px;
}
.ob-header { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.ob-list { display: grid; gap: 4px; max-height: 440px; overflow: auto; }
.ob-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; font-variant-numeric: tabular-nums;
  position: relative; padding: 4px 6px; border-radius: 6px;
}
.ob-row .bgbar {
  position: absolute; inset: 0; z-index: 0; border-radius: 6px; opacity: .22;
}
.ob-row > span { z-index: 1; }
.ob-list.asks .ob-row .bgbar { background: var(--down); }
.ob-list.bids .ob-row .bgbar { background: var(--up); }
.ob-mid { display: grid; place-items: center; gap: 4px; color: var(--muted); border-inline: 1px solid var(--border); }

/* Trades */
.trades .panel-body { max-height: 280px; overflow: auto; }

/* Wallets */
.wallets .panel-body { overflow-x: auto; }

/* Deposit */
.grid-1-1 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.deposit-box {
  margin-top: 12px; padding: 12px; border: 1px dashed var(--border); border-radius: 12px; background: #0b0f1a;
}
.address-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.address-row code {
  display: inline-block; padding: 8px 10px; border-radius: 10px; background: #0f1320; color: var(--text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.tips { margin: 8px 0 0 16px; color: var(--muted); font-size: 12px; }
.tips li { margin: 4px 0; }

/* Footer */
.footer {
  margin: 16px auto 40px; max-width: 1500px; padding: 14px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  color: var(--muted);
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* Light theme */
.light {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --text: #0b0e11;
  --muted: #475569;
  --border: #e5e7eb;
}
.light .btn.ghost { background: #f3f4f6; }
.light .row:hover { background: #f8fafc; }
.light .ticker { background: #ffffff; }
