
/* --- CSS VARIABLES --------------------------------------- */
:root {
  --bg:       #0a0c10;
  --bg2:      #10141c;
  --bg3:      #161b26;
  --border:   rgba(255,255,255,0.07);
  --border2:  rgba(255,255,255,0.12);
  --text:     #e8eaf0;
  --text2:    #8891a8;
  --text3:    #4a5568;
  --accent:   #00d4aa;
  --accent2:  #0099ff;
  --red:      #ff4560;
  --green:    #00d4aa;
  --gold:     #f5c842;
  --purple:   #8b5cf6;
  --radius:   12px;
  --radius-sm:8px;
  --shadow:   0 4px 24px rgba(0,0,0,0.4);
  --font-display: 'Syne', sans-serif;
  --font-mono:    'DM Mono', monospace;
  --font-body:    'DM Sans', sans-serif;
  --sidebar-w:    240px;
  --header-h:     60px;
}
[data-theme="light"] {
  --bg:       #f0f2f7;
  --bg2:      #ffffff;
  --bg3:      #e8ebf2;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.14);
  --text:     #1a1f2e;
  --text2:    #5a6480;
  --text3:    #9aa0b8;
  --shadow:   0 4px 24px rgba(0,0,0,0.08);
}

/* --- RESET ----------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; transition: background .3s, color .3s; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select { font-family: inherit; }
ul { list-style: none; }

/* --- SCROLLBAR ------------------------------------------- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* --- PAGES ----------------------------------------------- */
.page { display: none; }
.page.active { display: flex; }
body.booting-auth #page-login,
body.booting-auth #page-app { display: none !important; }

/* ------------------------------------------------------------
   LOGIN PAGE
-------------------------------------------------------------- */
#page-login {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 20% 50%, rgba(0,212,170,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 30%, rgba(0,153,255,0.07) 0%, transparent 70%);
}
.login-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--border) 1px, transparent 1px),
                    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.4;
}
.login-box {
  position: relative; z-index: 1;
  width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 48px 44px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: fadeUp .6s ease both;
}
.login-logo {
  display: flex; align-items: center; gap: 12px; margin-bottom: 36px;
}
.login-logo .logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.logo-icon.has-image {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border2);
}
.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}
.login-logo .logo-text {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--text2); font-size: 13px; margin-bottom: 32px; }

.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.form-input {
  width: 100%; padding: 12px 16px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,212,170,0.12); }
.form-input::placeholder { color: var(--text3); }

.btn-primary {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: var(--radius-sm); color: #fff;
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  letter-spacing: .02em; transition: opacity .2s, transform .1s;
  margin-top: 8px;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:active { transform: scale(.99); }

.login-demo { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text2); }
.login-demo span { color: var(--accent); font-family: var(--font-mono); }
.login-error { display: none; background: rgba(255,69,96,0.12); border: 1px solid rgba(255,69,96,0.3); color: var(--red); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }

/* ------------------------------------------------------------
   MAIN APP LAYOUT
-------------------------------------------------------------- */
#page-app {
  flex-direction: row;
  min-height: 100vh;
}

/* --- SIDEBAR ----------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: background .3s;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.sidebar-logo .logo-text {
  font-family: var(--font-display); font-size: 18px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav-section { margin-bottom: 24px; }
.nav-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text3); padding: 0 8px; margin-bottom: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; color: var(--text2);
  cursor: pointer; transition: all .15s;
  position: relative;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(0,212,170,0.1); color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 2px 2px 0; background: var(--accent);
}
.nav-icon { width: 18px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 6px;
  border-radius: 99px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg3); cursor: pointer;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text2); }
.user-role.wallet-live,
.user-role.wallet-demo,
.user-role.wallet-none {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.user-role.wallet-live {
  color: #00d4aa;
  background: rgba(0,212,170,0.14);
  border-color: rgba(0,212,170,0.28);
}
.user-role.wallet-live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00d4aa;
}
.user-role.wallet-demo {
  color: #0099ff;
  background: rgba(0,153,255,0.14);
  border-color: rgba(0,153,255,0.28);
}
.user-role.wallet-demo::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0099ff;
}
.user-role.wallet-none {
  color: var(--text2);
  background: var(--bg2);
  border-color: var(--border);
}

/* --- MAIN CONTENT ------------------------------------------- */
.main-content {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

/* --- TOP HEADER ----------------------------------------------- */
.top-header {
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: flex-start;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.header-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-search-wrap {
  flex: 1;
  min-width: 160px;
  max-width: 420px;
  position: relative;
}
.header-search-input {
  width: 100%;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.header-search-input:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(0, 153, 255, 0.14);
}
.header-search-input::placeholder { color: var(--text2); }
.header-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 42px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: var(--bg2);
  box-shadow: var(--shadow);
  z-index: 120;
  padding: 6px;
}
.header-search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.header-search-item:hover,
.header-search-item.active {
  background: var(--bg3);
}
.header-search-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.header-search-sym {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.header-search-name {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-search-hint {
  margin-left: auto;
  font-size: 10px;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}
.header-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  margin-left: auto;
}
.header-btn {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.header-btn:hover { color: var(--text); border-color: var(--border2); }

/* Ticker bar */
.ticker-bar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  overflow: hidden; white-space: nowrap; padding: 8px 0;
}
.ticker-inner {
  display: inline-flex; gap: 40px;
  animation: ticker 80s linear infinite;
  will-change: transform;
}
.ticker-bar:hover .ticker-inner { animation-play-state: paused; }
.ticker-item {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.ticker-sym { font-family: var(--font-mono); font-weight: 500; color: var(--text); }
.ticker-price { font-family: var(--font-mono); }
.ticker-chg { font-family: var(--font-mono); font-size: 11px; }
.ticker-chg.up { color: var(--green); }
.ticker-chg.down { color: var(--red); }

/* --- VIEWS --------------------------------------------------- */
.view { display: none; flex: 1; padding: 24px; flex-direction: column; gap: 20px; overflow-y: auto; min-width: 0; }
.view.active { display: flex; }

/* --- CARDS --------------------------------------------------- */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); transition: background .3s;
  min-width: 0;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.card-action { font-size: 12px; color: var(--accent); cursor: pointer; font-weight: 500; }
.card-action:hover { opacity: .8; }

/* --- GRID LAYOUTS --------------------------------------------- */
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; }

/* --- STAT CARDS ----------------------------------------------- */
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  position: relative; overflow: hidden;
  min-width: 0;
  transition: border-color .2s, transform .2s;
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.stat-card.green::before { background: var(--green); }
.stat-card.red::before { background: var(--red); }
.stat-card.blue::before { background: var(--accent2); }
.stat-card.gold::before { background: var(--gold); }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text2); margin-bottom: 8px; }
.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.stat-sub { font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat-badge {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  padding: 2px 7px; border-radius: 99px;
}
.stat-badge.up { background: rgba(0,212,170,0.12); color: var(--green); }
.stat-badge.down { background: rgba(255,69,96,0.12); color: var(--red); }
.stat-icon {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 32px; opacity: 0.07;
}

/* --- TABLE --------------------------------------------------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text2); padding: 0 12px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--bg3); }
.tbl .mono { font-family: var(--font-mono); }
.tbl .up { color: var(--green); }
.tbl .down { color: var(--red); }

/* --- BADGES --------------------------------------------------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .05em;
}
.badge-buy     { background: rgba(0,212,170,0.12);  color: var(--green); }
.badge-sell    { background: rgba(255,69,96,0.12);   color: var(--red); }
.badge-filled  { background: rgba(0,212,170,0.1);    color: var(--green); }
.badge-pending { background: rgba(245,200,66,0.12);  color: var(--gold); }
.badge-cancel  { background: rgba(255,255,255,0.05); color: var(--text2); }
.badge-approved { background: rgba(0,212,170,0.14); color: var(--green); }
.badge-waiting  { background: rgba(245,158,11,0.16); color: #f59e0b; }
.badge-rejected { background: rgba(255,69,96,0.14); color: var(--red); }
.badge-stock   { background: rgba(0,153,255,0.1);    color: var(--accent2); }
.badge-crypto  { background: rgba(245,200,66,0.1);   color: var(--gold); }
.badge-forex   { background: rgba(0,212,170,0.1);    color: var(--green); }
.badge-commodity { background: rgba(139,92,246,0.1); color: var(--purple); }

/* --- TYPE FILTERS --------------------------------------------- */
.filter-tabs {
  display: flex; gap: 6px;
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 4px;
}
.filter-tab {
  padding: 6px 14px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--text2);
  cursor: pointer; transition: all .15s;
}
.filter-tab.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
}
.pagination button.active {
  background: rgba(0,212,170,0.16);
  border-color: rgba(0,212,170,0.3);
  color: var(--accent);
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pagination-info {
  margin-right: auto;
  color: var(--text2);
  font-size: 12px;
}
.pagination-dots {
  padding: 0 2px;
  color: var(--text3);
  font-weight: 700;
}

/* --- ORDER FORM ----------------------------------------------- */
.order-form { display: flex; flex-direction: column; gap: 14px; }
.order-type-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 4px; gap: 4px;
}
.order-type-btn {
  padding: 9px; border-radius: 6px; font-size: 13px; font-weight: 700;
  text-align: center; cursor: pointer; transition: all .15s;
  color: var(--text2);
}
.order-type-btn.buy.active  { background: rgba(0,212,170,0.15); color: var(--green); }
.order-type-btn.sell.active { background: rgba(255,69,96,0.15);  color: var(--red); }
.order-type-btn:not(.active):hover { background: var(--bg2); color: var(--text); }
.order-input-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text2); margin-bottom: 5px; }
.order-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font-mono); font-size: 14px;
  outline: none; transition: border-color .2s;
}
.order-input:focus { border-color: var(--accent); }
.order-input[readonly] {
  border-color: var(--border);
  color: var(--text2);
  background: color-mix(in oklab, var(--bg3) 82%, #94a3b8 18%);
  cursor: not-allowed;
}
select.order-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text2) 50%),
    linear-gradient(135deg, var(--text2) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
select.order-input:hover {
  border-color: var(--border);
}

.header-btn.text-btn {
  width: auto;
  min-width: 52px;
  padding: 0 10px;
  font-size: 12px;
  font-family: var(--font-display);
}
.order-summary {
  background: var(--bg3); border-radius: var(--radius-sm); padding: 12px 14px;
}
.order-summary-row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.order-summary-row:last-child { margin-bottom: 0; font-weight: 700; font-size: 13px; }
.order-summary-row span:first-child { color: var(--text2); }
.order-summary-row span:last-child { font-family: var(--font-mono); }
.btn-buy  { width: 100%; padding: 12px; border-radius: var(--radius-sm); font-family: var(--font-display); font-size: 14px; font-weight: 700; letter-spacing: .03em; background: rgba(0,212,170,0.15); color: var(--green); border: 1px solid rgba(0,212,170,0.3); transition: all .15s; }
.btn-buy:hover  { background: rgba(0,212,170,0.25); }
.btn-sell { width: 100%; padding: 12px; border-radius: var(--radius-sm); font-family: var(--font-display); font-size: 14px; font-weight: 700; letter-spacing: .03em; background: rgba(255,69,96,0.15);  color: var(--red);   border: 1px solid rgba(255,69,96,0.3);  transition: all .15s; }
.btn-sell:hover { background: rgba(255,69,96,0.25); }

.sell-ratio-wrap {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.sell-ratio-slider {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      rgba(0,212,170,0.92) 0%,
      rgba(0,153,255,0.92) var(--ratio, 0%),
      rgba(255,255,255,0.14) var(--ratio, 0%),
      rgba(255,255,255,0.08) 100%
    );
  border: 1px solid rgba(0,153,255,0.25);
  outline: none;
  transition: background .2s ease;
}
.sell-ratio-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}
.sell-ratio-slider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}
.sell-ratio-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid rgba(0,153,255,0.9);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0,153,255,0.22);
}
.sell-ratio-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0,153,255,0.9);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0,153,255,0.22);
}

.sell-ratio-meta {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
}

.sell-ratio-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sell-ratio-actions button {
  min-height: 28px;
  border: 1px solid rgba(0,153,255,0.3);
  background: rgba(0,153,255,0.1);
  color: #9cd4ff;
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  transition: all .15s;
}
.sell-ratio-actions button:hover {
  background: rgba(0,153,255,0.2);
  color: #d4ecff;
}
.sell-ratio-actions button.active {
  border-color: rgba(0,212,170,0.55);
  background: linear-gradient(135deg, rgba(0,212,170,0.28), rgba(0,153,255,0.24));
  color: #e7fffb;
  box-shadow: 0 0 0 1px rgba(0,212,170,0.18) inset;
}

.chart-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.asset-logo {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg3);
  object-fit: cover;
}

.asset-logo-fallback {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

/* --- MARKET ITEM ----------------------------------------------- */
.market-item {
  display: flex; align-items: center;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .1s; gap: 10px;
}
.market-item:hover { background: var(--bg3); }
.market-item.active { background: rgba(0,212,170,0.08); }
.market-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.market-info { flex: 1; min-width: 0; }
.market-sym  { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.market-name { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.market-price-col { text-align: right; }
.market-price { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.market-chg   { font-family: var(--font-mono); font-size: 11px; }
.market-chg.up { color: var(--green); }
.market-chg.down { color: var(--red); }
.asset-mini-fav {
  margin-left: 8px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--text2);
  border-radius: 8px;
  font-size: 12px;
  padding: 3px 6px;
  cursor: pointer;
}
.asset-mini-fav.active {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.12);
}
.asset-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.asset-fav-btn,
.asset-link-btn,
.asset-trade-btn {
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--text);
  border-radius: 10px;
  font-size: 12px;
  padding: 7px 10px;
  cursor: pointer;
}
.asset-fav-btn.active {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.12);
}
.asset-link-btn:hover,
.asset-fav-btn:hover { background: var(--bg3); }
.asset-trade-btn {
  margin-left: auto;
  color: var(--green);
  border-color: rgba(0,212,170,0.35);
  background: rgba(0,212,170,0.12);
}

/* --- CHART CONTAINER ------------------------------------------ */
.chart-wrap { position: relative; width: 100%; }
.tv-chart-wrap {
  width: 100%; border-radius: var(--radius); overflow: hidden;
  background: var(--bg3); border: 1px solid var(--border);
}

/* --- NOTIFICATIONS ------------------------------------------- */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 13px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .3s ease;
  max-width: 300px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent2); }

/* --- ANIMATIONS ----------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); display: inline-block;
  animation: pulse 1.8s ease-in-out infinite;
}

/* --- PORTFOLIO DONUT ------------------------------------------ */
.donut-wrap { display: flex; align-items: center; gap: 24px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* --- RESPONSIVE ----------------------------------------------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
  .chart-toolbar { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; width: 100%; padding-bottom: 78px; }
  .top-header { padding: 0 12px; gap: 8px; }
  .ticker-bar { display: none; }
  .view { padding: 16px; }
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .stat-value { font-size: 19px; }
}
@media (max-width: 600px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .login-box { width: 95vw; padding: 32px 24px; }
  .modal { width: calc(100vw - 24px); padding: 20px; }
  .top-header { min-height: 56px; height: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; }
  .header-title { font-size: 15px; max-width: 30vw; }
  .header-search-wrap { grid-column: 1 / -1; max-width: none; min-width: 0; order: 4; }
  .header-search-input { height: 36px; font-size: 12px; }
  .header-live { display: none !important; }
  .header-actions { gap: 6px; }
  .header-btn { width: 40px; height: 40px; }
  .view { padding: 12px; gap: 14px; }
  .card-header { gap: 10px; flex-wrap: wrap; }
  .card-action { font-size: 11px; }
  .stat-value { font-size: 18px; }
  .pagination { justify-content: center; }
  .pagination-info { width: 100%; margin-right: 0; text-align: center; }
}
@media (max-width: 420px) {
  .header-title { max-width: 24vw; }
  .mobile-nav-item { padding: 8px 10px; font-size: 11px; }
}

/* --- MODAL ----------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 16px; padding: 28px; width: 440px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: fadeUp .25s ease;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.modal-close { font-size: 20px; color: var(--text2); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }

/* --- EMPTY STATE ----------------------------------------------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text2); }
.empty-state .icon { font-size: 36px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 13px; }

/* --- SPARKLINE ----------------------------------------------- */
.sparkline-canvas { display: block; }

button, .nav-item, .filter-tab, .order-type-btn, .card-action, .header-btn {
  min-height: 44px;
}
.card-action {
  display: inline-flex;
  align-items: center;
}

.mobile-nav {
  display: none;
}
.mobile-nav-item {
  border: 0;
  background: transparent;
  color: var(--text2);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.mobile-nav-item.active {
  background: rgba(0,212,170,0.14);
  color: var(--accent);
}
@media (max-width: 900px) {
  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  }
}


