:root {
  --bg-0: #0b0e14;
  --bg-1: #11151d;
  --bg-2: #171c26;
  --bg-3: #1f2530;
  --border: #262d3a;
  --text-0: #f2f4f8;
  --text-1: #aab2c4;
  --text-2: #6b7386;
  --green: #16c784;
  --green-dim: #0f7a52;
  --red: #ea3943;
  --red-dim: #8f242b;
  --blue: #3b82f6;
  --gold: #f0b90b;
  --radius: 10px;
  --radius-lg: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

button, input, select { font-family: inherit; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-0); }
.btn-ghost:hover { background: var(--bg-3); }
.btn-up { background: var(--green); color: #05140d; }
.btn-up:hover { filter: brightness(1.08); }
.btn-down { background: var(--red); color: #1a0506; }
.btn-down:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { background: var(--red-dim); color: #fff; }

/* ---------- Auth pages ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(59,130,246,.10), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(22,199,132,.08), transparent 45%),
    var(--bg-0);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
}
.auth-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.auth-logo img { height: 44px; }
.auth-logo .fallback { font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.auth-title { text-align: center; font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.auth-subtitle { text-align: center; color: var(--text-1); font-size: 13px; margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-1); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  border-radius: var(--radius);
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
}
.field input:focus { border-color: var(--blue); }
.field-error { color: var(--red); font-size: 12px; margin-top: 6px; }
.auth-footer { text-align: center; font-size: 13px; color: var(--text-1); margin-top: 18px; }
.status-banner {
  background: rgba(22,199,132,.12);
  border: 1px solid var(--green-dim);
  color: var(--green);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.auth-role-switch { display: flex; gap: 6px; justify-content: center; margin-bottom: 22px; }
.auth-role-switch a {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-1);
}
.auth-role-switch a.active { background: var(--bg-3); color: var(--text-0); border-color: var(--bg-3); }

/* ---------- App shell (dashboards) ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.sidebar-brand img { height: 28px; }
.sidebar-brand .fallback-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--green));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #fff;
}
.sidebar-brand .name { font-weight: 700; font-size: 15px; }
.sidebar-role-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-2);
  padding: 0 8px 14px;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: 14px;
  font-weight: 500;
}
.nav-link:hover { background: var(--bg-2); color: var(--text-0); }
.nav-link.active { background: var(--bg-3); color: var(--text-0); }
.sidebar-footer { margin-top: auto; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius);
  background: var(--bg-2); margin-bottom: 10px;
}
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-3); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.user-chip .meta { min-width: 0; }
.user-chip .meta .n { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .meta .r { font-size: 11px; color: var(--text-2); }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; }
.page { padding: 24px; }

.burger-btn {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text-0); font-size: 16px; cursor: pointer; margin-right: 12px; flex-shrink: 0;
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90;
}
.sidebar-backdrop.open { display: block; }

/* ---------- Cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px;
}
.stat-card .label { font-size: 12px; color: var(--text-1); margin-bottom: 8px; }
.stat-card .value { font-size: 26px; font-weight: 700; }

.card {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-1); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-flex; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-green { background: rgba(22,199,132,.14); color: var(--green); }
.badge-red { background: rgba(234,57,67,.14); color: var(--red); }
.badge-gray { background: var(--bg-3); color: var(--text-1); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 160px; margin-bottom: 0; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pagination-pages { display: flex; align-items: center; gap: 6px; }
.pagination .btn-sm { padding: 7px 12px; min-width: 36px; }
.pagination-current { cursor: default; }
.pagination-disabled { opacity: .4; cursor: not-allowed; }
.pagination-dots { color: var(--text-2); padding: 0 4px; font-size: 13px; }

/* ---------- Trading screen ---------- */
.trade-shell { background: var(--bg-0); min-height: 100vh; color: var(--text-0); padding-bottom: 66px; }
.trade-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}
.trade-topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.trade-topbar .brand img { height: 24px; }
.trade-topbar nav { display: flex; gap: 18px; font-size: 13px; color: var(--text-1); }
.trade-topbar .balance { font-size: 13px; color: var(--text-1); }
.trade-topbar .balance b { color: var(--text-0); }

.ticker {
  display: flex; align-items: flex-end; gap: 20px; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.ticker .price-block .pair { font-size: 12px; color: var(--text-1); margin-bottom: 2px; }
.ticker .price-block .price { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ticker .price-block .price.up { color: var(--green); }
.ticker .price-block .price.down { color: var(--red); }
.ticker .stat { font-size: 12px; color: var(--text-1); }
.ticker .stat b { display: block; color: var(--text-0); font-size: 13px; font-weight: 600; margin-top: 2px; }

.timeframes { display: flex; gap: 4px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.timeframes button {
  background: transparent; border: none; color: var(--text-1);
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.timeframes button.active { background: var(--bg-3); color: var(--green); }

.chart-wrap { position: relative; padding: 14px 18px 0; }
#chart { width: 100%; height: 420px; background: var(--bg-1); border-radius: var(--radius-lg); border: 1px solid var(--border); }

.trade-panel { display: flex; gap: 12px; padding: 18px; flex-wrap: wrap; }
.trade-panel .btn { flex: 1; min-width: 160px; padding: 16px; font-size: 15px; }

/* Countdown modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,6,10,.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.countdown-modal {
  width: 100%; max-width: 340px;
  background: linear-gradient(180deg, #14304f, #0f2a44);
  border: 1px solid #1f4066;
  border-radius: var(--radius-lg);
  padding: 26px 22px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.countdown-modal .count { font-size: 42px; font-weight: 800; color: var(--green); line-height: 1; margin-bottom: 6px; }
.countdown-modal .caption { font-size: 12px; color: var(--text-1); margin-bottom: 18px; }
.countdown-modal .rows { text-align: left; margin-bottom: 20px; }
.countdown-modal .row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; }
.countdown-modal .row .k { color: var(--text-1); }
.countdown-modal .row .v { font-weight: 700; }
.countdown-modal .row .v.up { color: var(--green); }
.countdown-modal .row .v.down { color: var(--red); }
.countdown-modal .actions { display: flex; gap: 10px; }
.countdown-modal .actions .btn { flex: 1; }

.history-empty { color: var(--text-2); font-size: 13.5px; padding: 20px 0; text-align: center; }

.badge-blue { background: rgba(59,130,246,.14); color: var(--blue); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 12px 18px;
  color: var(--text-1);
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab:hover { color: var(--text-0); }
.tab.active { color: var(--text-0); border-bottom-color: var(--blue); }
.tab-panel[hidden] { display: none; }

/* ---------- Toggle switch ---------- */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .15s ease;
  cursor: pointer;
}
.toggle .track::before {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--text-1);
  border-radius: 50%;
  transition: transform .15s ease, background .15s ease;
}
.toggle input:checked + .track { background: var(--green-dim); border-color: var(--green); }
.toggle input:checked + .track::before { transform: translateX(18px); background: var(--green); }

/* ---------- Search / filter row ---------- */
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-row input[type="search"], .filter-row input[type="text"].search-input {
  flex: 1; min-width: 200px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-0);
  border-radius: var(--radius); padding: 10px 12px; font-size: 13.5px; outline: none;
}
.filter-pill {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-1); font-size: 12.5px; font-weight: 600;
}
.filter-pill.active { background: var(--bg-3); color: var(--text-0); border-color: var(--bg-3); }

/* ---------- Entity list rows (admins, all-users) ---------- */
.entity-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.entity-row:last-child { border-bottom: none; }
.entity-main { display: flex; gap: 12px; min-width: 260px; flex: 1; }
.entity-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-3); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.entity-meta .row1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.entity-meta .row1 .name { font-weight: 700; font-size: 14px; }
.entity-meta .row2 { font-size: 12.5px; color: var(--text-2); }
.entity-meta .code-row { font-size: 12px; color: var(--text-2); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.entity-meta .code-row code { background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; color: var(--text-0); font-size: 12px; }
.entity-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }

/* ---------- Inline control groups (user management row) ---------- */
.control-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.control-group label { font-size: 11.5px; color: var(--text-2); }
.control-group input[type="number"], .control-group input[type="text"] {
  width: 90px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text-0);
  border-radius: 8px; padding: 7px 9px; font-size: 12.5px; outline: none;
}
.control-strip {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 0; border-top: 1px dashed var(--border); margin-top: 10px; font-size: 12.5px; color: var(--text-1);
}
.control-strip .item { display: flex; align-items: center; gap: 8px; }
.control-strip .sep { width: 1px; height: 16px; background: var(--border); }

/* ---------- Stat mini charts (admin dashboard) ---------- */
.mini-chart-card .mini-chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.mini-chart-card .range-pills { display: flex; gap: 6px; }
.mini-chart-card svg { width: 100%; height: 90px; display: block; }

/* ---------- Chat / support ---------- */
.chat-layout { display: flex; align-items: stretch; height: 620px; max-height: 75vh; }

.chat-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue), var(--green));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}

.chat-list { width: 280px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; padding: 8px; }
.chat-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius); margin-bottom: 2px; min-width: 0;
}
.chat-list-item:hover { background: var(--bg-2); }
.chat-list-item.active { background: var(--bg-3); }
.chat-list-meta { min-width: 0; flex: 1; }
.chat-list-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-list-name { font-size: 13.5px; font-weight: 600; color: var(--text-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-time { font-size: 11px; color: var(--text-2); flex-shrink: 0; }
.chat-list-preview { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.chat-list-count {
  flex-shrink: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--blue); color: #fff; font-size: 10.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.chat-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 560px; }
.chat-thread-header {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-thread-name { font-size: 14.5px; font-weight: 700; }
.chat-thread-sub { font-size: 12px; color: var(--text-2); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-0);
}
.chat-bubble-row { display: flex; }
.chat-bubble-row.user { justify-content: flex-start; }
.chat-bubble-row.admin { justify-content: flex-end; }
.chat-bubble { max-width: 70%; padding: 9px 13px 7px; border-radius: 14px; font-size: 13.5px; line-height: 1.4; }
.chat-bubble.user { background: var(--bg-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-bubble.admin { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble-time { font-size: 10px; opacity: .65; margin-top: 3px; text-align: right; }

.chat-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input {
  flex: 1; background: var(--bg-2); border: 1px solid var(--border); color: var(--text-0);
  border-radius: 999px; padding: 11px 16px; font-size: 13.5px; outline: none;
}
.chat-input:focus { border-color: var(--blue); }
.chat-send-btn {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; border: none; cursor: pointer;
  background: var(--blue); color: #fff; font-size: 15px; display: flex; align-items: center; justify-content: center;
}
.chat-send-btn:hover { filter: brightness(1.08); }

.chat-empty { color: var(--text-2); font-size: 13px; text-align: center; margin: auto; padding: 20px; }

/* ---------- Sim / impersonation banners ---------- */
.impersonate-banner {
  background: rgba(240,185,11,.12); border: 1px solid var(--gold); color: var(--gold);
  padding: 10px 18px; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.impersonate-banner button { background: transparent; border: 1px solid var(--gold); color: var(--gold); border-radius: var(--radius); padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }

.notice-banner {
  background: rgba(240,185,11,.10); border-bottom: 1px solid var(--gold); color: var(--text-0);
  padding: 12px 18px; font-size: 13.5px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.notice-banner button { background: transparent; border: 1px solid var(--border); color: var(--text-1); border-radius: var(--radius); padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; flex-shrink: 0; }

.bank-info {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-1); padding: 8px 0; border-top: 1px dashed var(--border); margin-top: 10px;
}
.bank-info b { color: var(--text-0); }
.bank-info .icon-btn-sm { background: transparent; border: none; color: var(--text-2); cursor: pointer; padding: 2px; }

.method-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.method-tile {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--bg-2); border-radius: var(--radius);
  padding: 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.method-tile input { position: absolute; opacity: 0; pointer-events: none; }
.method-tile.active { border-color: var(--blue); background: rgba(59,130,246,.12); color: var(--blue); }

/* ---------- Assets / balance hero ---------- */
.balance-hero {
  background: linear-gradient(160deg, var(--blue), #6d28d9);
  border-radius: var(--radius-lg); padding: 28px 20px; text-align: center; color: #fff;
  margin-bottom: 20px;
}
.balance-hero .mark {
  width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  margin: 0 auto 14px;
}
.balance-hero .label { font-size: 11px; letter-spacing: .6px; opacity: .85; }
.balance-hero .value { font-size: 32px; font-weight: 800; margin: 6px 0 20px; }
.balance-hero-actions { display: flex; gap: 10px; }
.balance-hero-actions .btn { flex: 1; }
.balance-hero .withdraw-cta { background: #fff; color: var(--blue); font-weight: 700; }
.balance-hero .withdraw-cta:hover { filter: brightness(0.97); }
.balance-hero .deposit-cta { background: rgba(255,255,255,.16); color: #fff; font-weight: 700; border: 1px solid rgba(255,255,255,.4); }
.balance-hero .deposit-cta:hover { background: rgba(255,255,255,.24); }

.balance-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.balance-row:last-child { border-bottom: none; }
.balance-row .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.balance-row .meta { flex: 1; }
.balance-row .meta .k { font-weight: 600; font-size: 13.5px; }
.balance-row .meta .sub { font-size: 11.5px; color: var(--text-2); }
.balance-row .v { font-weight: 700; font-size: 14px; }

/* ---------- Bottom mobile nav (trading area) ---------- */
.bottom-nav {
  display: flex;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bg-1); border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around; align-items: flex-end;
}
.bottom-nav a, .bottom-nav-bell {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; color: var(--text-2); flex: 1; min-width: 0; padding: 4px 0;
}
.bottom-nav-bell {
  position: relative; background: none; border: none; outline: none; font-family: inherit; cursor: pointer;
}
.notif-badge-nav { position: absolute; top: 0; right: 22%; }
.bottom-nav a .ic, .bottom-nav-bell .ic { font-size: 19px; line-height: 1; }
.bottom-nav a.active { color: var(--blue); font-weight: 600; }
.bottom-nav a.bottom-nav-center {
  margin-top: -22px;
}
.bottom-nav a.bottom-nav-center .ic {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 6px 16px rgba(59,130,246,.4);
}
.bottom-nav a.bottom-nav-center.active .ic { background: var(--green); box-shadow: 0 6px 16px rgba(22,199,132,.4); }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 95;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 0 0 transparent;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 10px 0 40px rgba(0,0,0,.35); }
  .burger-btn { display: flex; }
  .ticker { gap: 14px; }
  .ticker .price-block .price { font-size: 24px; }
  .chat-layout { flex-direction: column; height: 80vh; }
  .chat-list { width: 100%; height: 160px; border-right: none; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .trade-topbar nav { display: none; }
  .trade-grid { grid-template-columns: 1fr; padding: 12px; }

  /* Tables (transaction history, withdrawals, admin lists, ...) overflow their
     card on narrow screens instead of squeezing columns unreadably — let the
     table itself scroll horizontally rather than breaking the page layout. */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  th, td { white-space: nowrap; }
}

/* ==========================================================================
   Home page (public landing) — ticker bar, market list, theme switcher
   ========================================================================== */
.home-shell { min-height: 100vh; padding-bottom: 66px; }
.home-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--bg-1); flex-wrap: wrap;
}
.home-topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; }
.home-topbar .brand img { height: 30px; }
.home-topbar .brand .tag { font-size: 11px; font-weight: 500; color: var(--text-2); display: block; }
.home-topbar .right { display: flex; align-items: center; gap: 12px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(22,199,132,.12); color: var(--green); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 700;
}
.live-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text-1); display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* ---------- Notification bell ---------- */
.notif-bell-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg-1);
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 320px; max-width: 86vw; z-index: 200;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,.35); overflow: hidden;
}
.notif-panel-header {
  padding: 12px 16px; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--border);
}
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-2); }
.notif-item-top { display: flex; align-items: center; gap: 8px; }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; flex-shrink: 0; }
.notif-item.unread .notif-dot { background: var(--blue); }
.notif-item.unread .notif-title { font-weight: 700; }
.notif-title { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 11px; color: var(--text-2); flex-shrink: 0; }
.notif-body { margin: 8px 0 0 15px; font-size: 12.5px; color: var(--text-1); line-height: 1.45; }
.notif-empty { padding: 24px 16px; text-align: center; font-size: 12.5px; color: var(--text-2); }

/* Two distinct mobile positions depending on which bell opened the panel
   (data-opened-by, set in the JS): the bottom-nav bell drops it up, anchored
   above the bottom nav; the header bell drops it down, anchored below the
   header. Both use position:fixed with viewport-relative margins rather than
   the desktop right:0-relative-to-bell anchor, because on mobile the header
   bell isn't flush against the screen edge (balance/logout sit after it in
   the topbar), so right:0 there pushes the panel partly off-screen.
   Placed after the base .notif-panel rule (not inside the earlier shared
   media-query block) so it actually wins the cascade instead of being
   overridden by the base rule that comes later in the file. */
@media (max-width: 860px) {
  .notif-panel[data-opened-by="mobile"] {
    position: fixed; top: auto; bottom: 74px; left: 12px; right: 12px; width: auto; max-width: none;
  }
  .notif-panel[data-opened-by="desktop"] {
    position: fixed; top: 60px; bottom: auto; left: 12px; right: 12px; width: auto; max-width: none;
  }
}

/* Independent notification panel for the bottom-nav "Alerts" button —
   separate from .notif-panel (the header bell's) on purpose: always a
   fixed drop-up above the bottom nav, nothing shared with the header. */
.notif-panel-mobile {
  position: fixed; bottom: 74px; left: 12px; right: 12px; z-index: 200;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,.35); overflow: hidden;
}

.theme-switcher { position: relative; }
.theme-switcher .trigger {
  display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-0); cursor: pointer;
}
.theme-menu {
  position: absolute; top: calc(100% + 8px); right: 0; width: 190px; z-index: 30;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 8px; box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.theme-menu[hidden] { display: none; }
.theme-menu .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); padding: 6px 8px; }
.theme-menu button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  background: transparent; border: none; color: var(--text-1); border-radius: 8px; padding: 9px 8px; font-size: 13px; cursor: pointer;
}
.theme-menu button:hover { background: var(--bg-2); }
.theme-menu button.active { background: rgba(22,199,132,.12); color: var(--green); }

.ticker-tape {
  display: flex; overflow-x: auto; gap: 0; border-bottom: 1px solid var(--border); background: var(--bg-0);
}
.ticker-tape .tt-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-right: 1px solid var(--border);
  white-space: nowrap; font-size: 12.5px;
}
.ticker-tape .tt-item b { font-weight: 700; }
.ticker-tape .tt-item .chg.up { color: var(--green); }
.ticker-tape .tt-item .chg.down { color: var(--red); }

.welcome-bar { padding: 20px 24px 6px; }
.welcome-bar .hi { font-size: 12px; color: var(--text-2); }
.welcome-bar .name { font-size: 20px; font-weight: 800; }

.market-list { padding: 10px 24px 40px; }
.market-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 6px; border-bottom: 1px solid var(--border);
}
.market-row:last-child { border-bottom: none; }
.market-row .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.coin-mark {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; background: var(--bg-2);
}
.coin-mark-fallback {
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--green));
}
.market-row .sym { font-weight: 700; font-size: 14.5px; }
.market-row .full-name { font-size: 12px; color: var(--text-2); }
.market-row .right { text-align: right; }
.market-row .px { font-weight: 700; font-size: 14.5px; }
.market-row .chg { font-size: 12.5px; }
.market-row .chg.up { color: var(--green); }
.market-row .chg.down { color: var(--red); }
.market-row.clickable { cursor: pointer; }
.market-row.clickable:hover { background: var(--bg-1); border-radius: var(--radius); }

.home-cta { display: flex; gap: 10px; padding: 0 24px 24px; }

/* ==========================================================================
   Quick Trade panel (per-coin trade screen)
   ========================================================================== */
.trade-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; padding: 16px 18px; align-items: start; }
@media (max-width: 980px) { .trade-grid { grid-template-columns: 1fr; } }

.coin-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding: 4px 0 16px; }
.coin-header .left { display: flex; align-items: center; gap: 14px; }
.coin-header .px-now { font-size: 26px; font-weight: 800; }
.coin-header .px-now.up { color: var(--green); }
.coin-header .px-now.down { color: var(--red); }
.coin-header .stats-inline { display: flex; gap: 26px; }
.coin-header .stats-inline .s-label { font-size: 11px; color: var(--text-2); }
.coin-header .stats-inline .s-value { font-size: 13.5px; font-weight: 700; margin-top: 2px; }

.quick-trade .available { font-size: 11.5px; color: var(--text-2); }
.quick-trade .amount-field {
  display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px 4px 4px 12px; margin: 8px 0 16px;
}
.quick-trade .amount-field input {
  flex: 1; background: transparent; border: none; color: var(--text-0); font-size: 18px; font-weight: 700; outline: none; padding: 8px 0;
}
.quick-trade .amount-field .cur-badge {
  width: 32px; height: 32px; border-radius: 8px; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.quick-trade .buy-buttons { display: flex; gap: 10px; margin-bottom: 18px; }
.quick-trade .buy-buttons .btn { flex: 1; padding: 14px; font-size: 14.5px; }
.duration-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.duration-opt {
  border: 1px solid var(--border); background: var(--bg-2); border-radius: var(--radius);
  padding: 10px 6px; text-align: center; cursor: pointer;
}
.duration-opt .pct { font-weight: 800; font-size: 14px; }
.duration-opt .dur { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.duration-opt.active { border-color: var(--blue); background: rgba(59,130,246,.12); }
.duration-opt.active .pct { color: var(--blue); }
.return-row {
  display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--text-1);
  padding: 10px 0; border-top: 1px dashed var(--border); margin-bottom: 10px;
}
.return-row b { color: var(--green); font-size: 14px; }
.balance-warning {
  background: rgba(234,57,67,.12); border: 1px solid var(--red-dim); color: var(--red);
  border-radius: var(--radius); padding: 9px 12px; font-size: 12.5px; margin-bottom: 10px;
}
.balance-warning[hidden] { display: none; }

/* ==========================================================================
   Platform branding (super admin settings)
   ========================================================================== */
.card-subtitle { font-size: 13px; color: var(--text-2); margin: -10px 0 20px; }
.field-hint { font-size: 12px; color: var(--text-2); margin-top: 6px; }

.brand-preview {
  background: var(--bg-2); border: 1px dashed var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; margin-bottom: 22px;
}
.brand-preview-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2);
  margin-bottom: 12px;
}
.brand-preview-row { display: flex; align-items: center; gap: 12px; }
.brand-preview-mark {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-weight: 800; font-size: 16px; color: #fff;
}
.brand-preview-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-preview-name { font-weight: 700; font-size: 16px; }
.brand-preview-tagline { font-size: 12.5px; color: var(--text-1); min-height: 16px; }
.brand-preview-hint { font-size: 11.5px; color: var(--text-2); margin-top: 12px; }

.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-thumb {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: var(--bg-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-weight: 700; color: var(--text-1);
}
.logo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.logo-choose-btn { cursor: pointer; }
.logo-remove-btn {
  background: transparent; border: none; color: var(--red); font-size: 13px;
  font-weight: 600; cursor: pointer; padding: 6px 4px;
}
.logo-remove-btn:hover { text-decoration: underline; }

.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] {
  width: 44px; height: 42px; padding: 2px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-2); cursor: pointer; flex-shrink: 0;
}
.color-hex-input { flex: 1; text-transform: uppercase; }
.color-presets { display: flex; gap: 8px; margin-top: 10px; }
.color-preset {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border);
  cursor: pointer; padding: 0;
}
.color-preset:hover { border-color: var(--text-1); }

.branding-actions { display: flex; gap: 10px; margin-top: 22px; }
.branding-note {
  margin-top: 16px; font-size: 12px; color: var(--text-2);
  background: var(--bg-2); border-radius: var(--radius); padding: 10px 12px;
}

/* ==========================================================================
   KYC document preview (admin review)
   ========================================================================== */
.kyc-view-link { color: var(--blue); font-size: 13px; font-weight: 600; }
.kyc-view-link:hover { text-decoration: underline; }

.kyc-preview-overlay {
  position: fixed; inset: 0; background: rgba(5,6,10,.75); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 30px;
}
.kyc-preview-overlay[hidden] { display: none; }
.kyc-preview-box {
  position: relative; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; max-width: min(720px, 90vw); max-height: 85vh;
}
.kyc-preview-close {
  position: absolute; top: -14px; right: -14px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-0);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.kyc-preview-body img { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: var(--radius); }
.kyc-preview-body iframe { width: min(680px, 85vw); height: 75vh; border: none; border-radius: var(--radius); }

/* ==========================================================================
   "My" account page — deliberately light-card styling regardless of the
   active dark/cyberpunk/light theme, to match the reference design.
   ========================================================================== */
.profile-page { margin: 18px; max-width: 480px; }
.profile-hero {
  border-radius: var(--radius-lg); padding: 22px 20px 26px; margin-bottom: 18px;
  background: linear-gradient(135deg, #2f7ff0, #1a5fd0); color: #fff; text-align: center;
}
.profile-avatar {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 12px;
  background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.4);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700;
}
.profile-email { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.profile-meta { font-size: 12.5px; color: rgba(255,255,255,.85); margin-bottom: 3px; }
.profile-score { color: #ffd23f; font-weight: 700; }
.profile-score-bar { height: 4px; border-radius: 999px; background: rgba(255,255,255,.25); margin-top: 14px; overflow: hidden; }
.profile-score-bar .fill { height: 100%; background: #ffd23f; border-radius: 999px; }

.profile-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.profile-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: #fff; border: 1px solid #eceef5; border-radius: var(--radius-lg); color: #17172b;
  box-shadow: 0 1px 2px rgba(20,20,40,.04);
}
.profile-row-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: #f1edfb; display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.profile-row-meta { flex: 1; min-width: 0; }
.profile-row-meta .t { font-weight: 700; font-size: 14px; }
.profile-row-meta .s { font-size: 12px; color: #8b8daf; margin-top: 1px; }
.profile-row .chev { color: #c1c3d6; font-size: 20px; }

.profile-signout {
  width: 100%; padding: 13px; border-radius: var(--radius-lg); border: 1px solid #fbd4d7;
  background: #fef2f3; color: #e0293a; font-weight: 700; font-size: 14px; cursor: pointer;
}
.profile-signout:hover { background: #fde3e5; }

/* ==========================================================================
   Auth pages (login / register) — light card redesign
   ========================================================================== */
.auth-shell-light {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px; background: #f5f6fa;
}
.auth-header-light { text-align: center; margin-bottom: 26px; }
.auth-mark-light {
  width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #7c3aed, #4c1d95);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.auth-mark-light img { width: 100%; height: 100%; object-fit: cover; }
.auth-mark-light .fallback { color: #fff; font-weight: 800; font-size: 20px; }
.auth-title-light { font-size: 24px; font-weight: 800; color: #17172b; margin: 0 0 6px; }
.auth-subtitle-light { font-size: 14px; color: #6b6d8a; }

.auth-card-light {
  width: 100%; max-width: 420px; background: #fff; border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(30,20,70,.08); padding: 28px;
}
.field-light { margin-bottom: 18px; }
.field-light .row-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: #6b6d8a; margin-bottom: 7px;
}
.field-light .row-label a { text-transform: none; font-weight: 600; color: #6d28d9; font-size: 12.5px; }
.input-icon-wrap { position: relative; }
.input-icon-wrap .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #9799b8; font-size: 15px; pointer-events: none; }
.input-icon-wrap input {
  width: 100%; padding: 12px 14px 12px 40px; border-radius: 10px; border: 1px solid #e1e2ee;
  background: #fbfbfe; color: #17172b; font-size: 14px; outline: none;
}
.input-icon-wrap input:focus { border-color: #7c3aed; background: #fff; }
.input-icon-wrap .toggle-visibility {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer;
  background: none; border: none; color: #9799b8; font-size: 14px; padding: 4px;
}
.field-light-hint { font-size: 11.5px; color: #9799b8; margin-top: 6px; }

.btn-gradient-purple {
  width: 100%; padding: 13px; border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #7c3aed, #4c1d95); color: #fff; font-weight: 700; font-size: 14.5px;
}
.btn-gradient-purple:hover { filter: brightness(1.06); }

.auth-divider-light { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; font-size: 12px; color: #9799b8; }
.auth-divider-light::before, .auth-divider-light::after { content: ''; flex: 1; height: 1px; background: #ececf5; }

.btn-outline-purple {
  display: block; width: 100%; text-align: center; padding: 12px; border-radius: 10px;
  border: 1px solid #e1e2ee; color: #17172b; font-weight: 700; font-size: 14px; background: #fff;
}
.btn-outline-purple:hover { background: #faf9ff; border-color: #d9d4f5; }

.auth-agree-light { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: #6b6d8a; margin: -4px 0 18px; }
.auth-agree-light input { margin-top: 2px; }

.auth-error-light {
  background: #fef2f3; border: 1px solid #fbd4d7; color: #e0293a;
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 16px;
}

/* ==========================================================================
   Themes — Deep Space (default), Cyberpunk, Light
   ========================================================================== */
[data-theme="cyberpunk"] {
  --bg-0: #05060f; --bg-1: #0c0e1c; --bg-2: #131629; --bg-3: #1b1f3b;
  --border: #2a2f57; --text-0: #f2f0ff; --text-1: #a9a3d9; --text-2: #6f699e;
  --green: #00f5c4; --green-dim: #0a8f74; --red: #ff2e6b; --red-dim: #9c1a44;
  --blue: #7c3aed; --gold: #ffd23f;
}

[data-theme="light"] {
  --bg-0: #f5f6fa; --bg-1: #ffffff; --bg-2: #f0f1f7; --bg-3: #e7e8f3;
  --border: #e1e2ee; --text-0: #17172b; --text-1: #55577a; --text-2: #8b8daf;
  --green: #0f9d63; --green-dim: #0b7a4c; --red: #d92d43; --red-dim: #a81f34;
  --blue: #6d28d9; --gold: #b8860b;
}
