:root {
  --bg: #0b0e11;
  --panel: #12161a;
  --panel-2: #171d22;
  --line: rgba(234, 236, 239, .11);
  --text: #eaecef;
  --muted: #8f9aa6;
  --green: #02c076;
  --red: #f6465d;
  --amber: #f0b90b;
  --blue: #2f8cff;
  --shadow: 0 18px 60px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 22% 0%, rgba(2, 192, 118, .08), transparent 32%),
    radial-gradient(circle at 78% 12%, rgba(240, 185, 11, .08), transparent 28%),
    var(--bg);
  font: 14px/1.5 "Inter", "Microsoft YaHei", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
input, select, button { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 62px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 17, .88);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0; }
.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--green), var(--amber));
  box-shadow: 0 0 26px rgba(2, 192, 118, .3);
}
.nav { display: flex; gap: 8px; margin-left: auto; }
.nav a, .logout, .user-chip {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
}
.nav a:hover, .logout:hover { color: var(--text); border-color: rgba(234,236,239,.24); }
.user-chip { color: var(--text); background: rgba(255,255,255,.035); }

.page, .dashboard { width: min(1600px, calc(100vw - 40px)); margin: 24px auto 60px; }
.page.narrow { width: min(620px, calc(100vw - 40px)); }
.section-head, .hero-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 18px;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 16px; }
.eyebrow { margin: 0 0 7px; color: var(--amber); text-transform: uppercase; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; }

.hero-strip {
  min-height: 118px;
  padding: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(18,22,26,.96), rgba(18,22,26,.76));
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.metric-card, .panel {
  border: 1px solid var(--line);
  background: rgba(18, 22, 26, .9);
  border-radius: 8px;
  box-shadow: 0 10px 34px rgba(0,0,0,.25);
}
.metric-card { padding: 18px; }
.metric-card span { display: block; color: var(--muted); margin-bottom: 8px; }
.metric-card strong { font-size: 28px; line-height: 1; }
.panel { padding: 16px; }
.panel-title, .table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 14px;
}
.filters { align-self: start; position: sticky; top: 82px; }
.filters label, .form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  margin-bottom: 12px;
}
input, select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  background: #0d1115;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}
input:focus, select:focus { border-color: rgba(2, 192, 118, .56); box-shadow: 0 0 0 3px rgba(2,192,118,.08); }
select[multiple] { min-height: 118px; }
.field-help { color: var(--muted); font-size: 12px; }

.center { display: grid; gap: 14px; }
.command-bar {
  display: grid;
  grid-template-columns: repeat(11, minmax(82px, 1fr));
  gap: 8px;
}
.cmd, .btn {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #1a2027;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.cmd:hover, .btn:hover { transform: translateY(-1px); border-color: rgba(234,236,239,.25); }
.cmd.green, .btn.primary { background: rgba(2, 192, 118, .16); border-color: rgba(2, 192, 118, .46); }
.cmd.red, .btn.danger { background: rgba(246, 70, 93, .16); border-color: rgba(246, 70, 93, .48); }
.cmd.amber, .btn.amber { background: rgba(240, 185, 11, .16); border-color: rgba(240, 185, 11, .46); }
.btn.secondary { background: #151b21; color: var(--muted); }
.btn.full { width: 100%; }
.btn.tiny { min-height: 30px; padding: 5px 8px; font-size: 12px; }
.btn.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.account-tools { display: grid; gap: 12px; }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.inline-form label { margin: 0; min-width: 180px; }
.inline-form.compact input, .inline-form.compact select { min-width: 150px; }
.mini-form { display: inline-flex; gap: 6px; align-items: center; margin: 2px; }
.mini-form select { min-height: 30px; padding: 4px 6px; width: auto; }

.table-wrap { overflow: auto; }
.account-table-wrap { max-height: calc(100vh - 330px); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}
.data-table th, .data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #12161a;
  color: #aeb7c2;
  font-size: 12px;
}
.data-table tr:hover td { background: rgba(255,255,255,.025); }
.empty { text-align: center; color: var(--muted); padding: 32px !important; }
.account-main { display: grid; gap: 2px; }
.account-main span { color: var(--muted); font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.gain { color: var(--green); }
.loss { color: var(--red); }
.flash { animation: flash .8s ease; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
}
.badge.green { color: var(--green); border-color: rgba(2,192,118,.34); background: rgba(2,192,118,.08); }
.badge.red { color: var(--red); border-color: rgba(246,70,93,.34); background: rgba(246,70,93,.08); }
.badge.amber { color: var(--amber); border-color: rgba(240,185,11,.34); background: rgba(240,185,11,.08); }
.actions-cell { min-width: 140px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(8px);
}
.modal-backdrop.hidden { display: none; }
.modal {
  width: min(460px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161a;
  box-shadow: var(--shadow);
}
.wide-modal { width: min(680px, 100%); }
.modal p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.key-box {
  display: block;
  padding: 14px;
  border: 1px solid rgba(2,192,118,.35);
  border-radius: 7px;
  color: var(--green);
  background: #0d1115;
  white-space: normal;
  word-break: break-all;
}

.alert {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
}
.alert.success { color: var(--green); border-color: rgba(2,192,118,.35); background: rgba(2,192,118,.08); }
.alert.danger { color: var(--red); border-color: rgba(246,70,93,.35); background: rgba(246,70,93,.08); }
.toast-box { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: grid; gap: 8px; }
.toast {
  min-width: 260px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151b21;
  box-shadow: var(--shadow);
}
.toast.success { border-color: rgba(2,192,118,.4); color: var(--green); }
.toast.danger { border-color: rgba(246,70,93,.4); color: var(--red); }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-shell { width: min(460px, 100%); }
.auth-shell.wide { width: min(760px, 100%); }
.auth-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18,22,26,.94);
  box-shadow: var(--shadow);
}
.auth-brand { margin-bottom: 24px; }
.auth-link { color: var(--muted); }
.auth-link a { color: var(--green); }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.disclaimer-box {
  max-height: 180px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #c8d0d8;
  background: #0d1115;
}
.check-line { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 10px !important; color: var(--text) !important; }
.check-line input { width: auto; min-height: auto; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flash {
  0% { text-shadow: 0 0 0 transparent; }
  30% { text-shadow: 0 0 16px currentColor; }
  100% { text-shadow: 0 0 0 transparent; }
}

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .filters { position: static; }
  .command-bar { grid-template-columns: repeat(4, minmax(82px, 1fr)); }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 12px; }
  .nav { order: 3; width: 100%; overflow: auto; }
  .page, .dashboard { width: min(100vw - 20px, 1600px); margin-top: 12px; }
  .hero-strip, .section-head { display: grid; align-items: start; }
  .metrics { grid-template-columns: 1fr; }
  .command-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .inline-form, .inline-form label { display: grid; width: 100%; }
  .metric-card strong { font-size: 24px; }
}
