:root {
  --bg: #0a0d14;
  --bg-2: #111622;
  --panel: #141a28;
  --panel-2: #1a2133;
  --line: #232c42;
  --txt: #e8edf7;
  --txt-2: #8b97b3;
  --txt-3: #5b6683;
  --up: #23d18b;
  --down: #ff5c78;
  --acc: #7c5cff;
  --acc-2: #22d3ee;
  --warn: #ffb545;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(124, 92, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, .10), transparent 55%),
    var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.layout { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: rgba(17, 22, 34, .78);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--acc), var(--acc-2));
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: .5px; color: #0a0d14;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 11px; color: var(--txt-3); }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: 11px;
  background: transparent; border: 1px solid transparent;
  color: var(--txt-2); font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: left; width: 100%;
  transition: .16s;
}
.nav-item .ico { font-size: 15px; opacity: .8; }
.nav-item:hover { background: var(--panel-2); color: var(--txt); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, .22), rgba(34, 211, 238, .10));
  border-color: rgba(124, 92, 255, .45);
  color: #fff;
}

.side-status { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }

.user-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 32px;
  background: linear-gradient(135deg, var(--acc), var(--acc-2));
  display: grid; place-items: center; color: #0a0d14; font-weight: 800; font-size: 13px;
  text-transform: uppercase;
}
.user-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.user-info strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info span { font-size: 10.5px; color: var(--txt-3); }
.user-out {
  margin-left: auto; flex: 0 0 auto; width: 27px; height: 27px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-2);
  cursor: pointer; font-size: 13px; line-height: 1;
}
.user-out:hover { color: var(--down); border-color: rgba(255, 92, 120, .45); }

.hint { font-size: 11.5px; color: var(--txt-3); margin-bottom: 14px; }
.hint b { color: var(--acc-2); font-weight: 600; }

.chg-list { display: flex; flex-direction: column; gap: 3px; white-space: normal; }
.chg-list span { font-size: 11.5px; color: var(--txt-2); }
.chg-list em { font-style: normal; color: var(--txt-3); }
.chg-list b { color: var(--up); font-weight: 600; }
.data tbody td.wrap { white-space: normal; min-width: 220px; max-width: 420px; line-height: 1.6; }

.pill.act { color: var(--acc-2); background: rgba(34, 211, 238, .12); }
.pill.warnp { color: var(--warn); background: rgba(255, 181, 69, .13); }
.side-price {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.side-price .label { display: block; font-size: 11px; color: var(--txt-3); margin-bottom: 4px; }
.side-price strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.side-price .unit { font-size: 11px; color: var(--txt-2); margin-left: 4px; }

.side-meta { display: flex; flex-direction: column; gap: 7px; font-size: 11.5px; }
.side-meta div { display: flex; justify-content: space-between; gap: 8px; }
.side-meta span { color: var(--txt-3); }
.side-meta b { color: var(--txt-2); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

.pulse { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--txt-3); }
.pulse i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--warn);
  box-shadow: 0 0 0 3px rgba(255, 181, 69, .18);
}
.pulse i.ok { background: var(--up); box-shadow: 0 0 0 3px rgba(35, 209, 139, .18); }
.pulse i.bad { background: var(--down); box-shadow: 0 0 0 3px rgba(255, 92, 120, .18); }

/* ---------------- Main ---------------- */
.main { flex: 1; padding: 26px 30px 46px; min-width: 0; }
.page { display: none; }
.page.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 18px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: .2px; }
.page-head p { color: var(--txt-3); font-size: 12.5px; margin-top: 5px; }
.head-right { display: flex; align-items: center; gap: 14px; }

.big-price { display: flex; align-items: baseline; gap: 7px; }
.big-price span { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big-price em { font-style: normal; font-size: 11.5px; color: var(--txt-3); }
.chg { font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 9px; background: var(--panel-2); color: var(--txt-2); }
.chg.up { color: var(--up); background: rgba(35, 209, 139, .12); }
.chg.down { color: var(--down); background: rgba(255, 92, 120, .12); }

.badge {
  padding: 7px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-2);
}
.badge.on { color: var(--up); border-color: rgba(35, 209, 139, .35); background: rgba(35, 209, 139, .10); }
.badge.off { color: var(--txt-3); }

/* ---------------- Cards ---------------- */
.cards {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.card {
  background: linear-gradient(160deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 17px; display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.card::after {
  content: ''; position: absolute; inset: 0 auto auto 0; width: 3px; height: 100%;
  background: var(--txt-3); opacity: .5;
}
.card.accent::after { background: linear-gradient(var(--acc), var(--acc-2)); opacity: 1; }
.card.pool::after { background: var(--up); opacity: 1; }
.card .ct { font-size: 11.5px; color: var(--txt-3); }
.card b { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; word-break: break-all; }
.card i { font-style: normal; font-size: 11px; color: var(--txt-2); }

/* ---------------- Panels ---------------- */
.panel {
  background: rgba(20, 26, 40, .72);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.panel-head h2 { font-size: 15px; font-weight: 650; }
.tag {
  font-size: 11px; color: var(--txt-2); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px;
}
.panel.mini { display: flex; flex-direction: column; gap: 7px; }
.panel.mini .ct { font-size: 11.5px; color: var(--txt-3); }
.panel.mini b { font-size: 20px; font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

canvas { width: 100%; display: block; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data thead th {
  text-align: left; padding: 9px 11px; color: var(--txt-3);
  font-weight: 600; font-size: 11.5px; white-space: nowrap;
  border-bottom: 1px solid var(--line); background: rgba(26, 33, 51, .5);
}
.data tbody td {
  padding: 9px 11px; border-bottom: 1px solid rgba(35, 44, 66, .55);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.data tbody tr:hover td { background: rgba(124, 92, 255, .06); }
.data .num, .data th.num { text-align: right; }
.data .empty { text-align: center; color: var(--txt-3); padding: 26px; }
.pill { padding: 3px 9px; border-radius: 7px; font-size: 11px; font-weight: 600; }
.pill.buy { color: var(--up); background: rgba(35, 209, 139, .13); }
.pill.sell { color: var(--down); background: rgba(255, 92, 120, .13); }
a.link { color: var(--acc-2); text-decoration: none; }
a.link:hover { text-decoration: underline; }

.kv td { padding: 8px 4px; border-bottom: 1px solid rgba(35, 44, 66, .5); font-size: 12.5px; }
.kv td:first-child { color: var(--txt-3); width: 46%; }
.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; word-break: break-all; }

/* ---------------- Controls ---------------- */
.controls { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
select, input[type="number"], input[type="text"] {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 9px; padding: 8px 10px; font-size: 12.5px; font-family: inherit;
  outline: none; min-width: 0;
}
select:focus, input:focus { border-color: var(--acc); }
.chk, .chk-lg { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--txt-2); cursor: pointer; }
input[type="checkbox"] { accent-color: var(--acc); width: 15px; height: 15px; cursor: pointer; }

.form {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px; margin-bottom: 15px;
}
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; color: var(--txt-3); }
.form .chk-lg { grid-column: span 2; flex-direction: row; align-items: center; color: var(--txt-2); }

.btns { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 15px; }
.btn {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--txt); font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: .15s;
}
.btn:hover { border-color: var(--acc); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--acc), #5b8cff); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; color: var(--txt-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.progress {
  position: relative; height: 24px; border-radius: 9px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 15px;
}
.progress > div {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--acc), var(--acc-2));
  transition: width .4s ease;
}
.progress span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}

.stat-row {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat-row > div {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.stat-row span { font-size: 11px; color: var(--txt-3); }
.stat-row b { font-size: 14px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }

.err { margin-top: 12px; font-size: 12px; color: var(--down); display: none; }
.err.show { display: block; }

.pager { display: flex; align-items: center; gap: 7px; margin-top: 13px; flex-wrap: wrap; }
.pager button {
  min-width: 34px; padding: 7px 10px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-2);
  font-size: 12px; cursor: pointer; font-family: inherit;
}
.pager button:hover:not(:disabled) { border-color: var(--acc); color: var(--txt); }
.pager button.cur { background: var(--acc); border-color: var(--acc); color: #fff; font-weight: 700; }
.pager button:disabled { opacity: .35; cursor: not-allowed; }
.pager .info { margin-left: auto; font-size: 11.5px; color: var(--txt-3); }

.ohlc { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--txt-2); }
.ohlc b { color: var(--txt); font-variant-numeric: tabular-nums; }

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: relative; }
  .nav { flex-direction: row; overflow-x: auto; }
  .side-status { display: none; }
  .main { padding: 18px 14px 34px; }
  .cards { grid-template-columns: 1fr; }
}
