:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --panel-soft: #f7f8fa;
  --line: #dfe3e8;
  --line-strong: #cbd1d8;
  --text: #15181d;
  --muted: #737b86;
  --accent: #1769e0;
  --accent-hover: #1258bd;
  --accent-soft: #e9f1fd;
  --positive: #11875d;
  --positive-soft: #e4f5ee;
  --danger: #c64045;
  --danger-soft: #fae9ea;
  --warning: #a16a0a;
  --warning-soft: #fff2d8;
  --sidebar: #111419;
  --sidebar-panel: #191d23;
  --sidebar-text: #aeb5bf;
  --shadow: 0 10px 28px rgba(18, 24, 31, .06);
  --topbar-height: 64px;
  --sidebar-width: 248px;
}

:root[data-theme="dark"] {
  --bg: #0b0d10;
  --panel: #121519;
  --panel-strong: #171a1f;
  --panel-soft: #0f1215;
  --line: #252a31;
  --line-strong: #343a43;
  --text: #eef0f3;
  --muted: #8e96a1;
  --accent: #4d8dff;
  --accent-hover: #6aa0ff;
  --accent-soft: #17243a;
  --positive: #36c995;
  --positive-soft: #102a22;
  --danger: #f06b70;
  --danger-soft: #321a1d;
  --warning: #e9ad49;
  --warning-soft: #302616;
  --sidebar: #0d0f12;
  --sidebar-panel: #171a1f;
  --sidebar-text: #969ea9;
  --shadow: 0 12px 32px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(390px, 46%) 1fr;
  background: var(--bg);
}
.auth-intro {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: 14vh clamp(44px, 7vw, 116px) 8vh;
  color: #f5f7fa;
  background-color: #101318;
}
.auth-intro::after {
  content: "";
  position: absolute;
  right: 10%;
  bottom: 18%;
  width: 38%;
  height: 1px;
  background: #2f3741;
  box-shadow: 70px -54px 0 #2f3741, 140px -24px 0 #2f3741, 210px -96px 0 #2f3741;
  transform: rotate(-18deg);
  opacity: .75;
}
.auth-mark, .brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #3c4653;
  background: #1a1f26;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.auth-mark { margin-bottom: 34px; }
.eyebrow {
  margin: 0;
  color: #7f8996;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
}
.auth-intro h1 {
  max-width: 620px;
  margin: 14px 0 18px;
  font-size: clamp(38px, 4.3vw, 62px);
  line-height: 1.14;
  font-weight: 700;
}
.auth-intro > div > p:last-child {
  max-width: 480px;
  margin: 0;
  color: #a8b0ba;
  font-size: 16px;
}
.auth-status { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-status > span { width: 9px; height: 9px; border-radius: 50%; background: #36c995; box-shadow: 0 0 0 5px rgba(54,201,149,.12); }
.auth-status strong, .auth-status small { display: block; }
.auth-status strong { font-size: 13px; }
.auth-status small { color: #7f8996; margin-top: 2px; }
.auth-main { display: grid; place-items: center; padding: 88px 28px 40px; }
.auth-box { width: min(410px, 100%); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 750; }
.brand > span:not(.brand-mark) { color: var(--accent); font-size: 11px; }
.auth-box > .brand { font-size: 18px; }
.auth-box h2 { margin: 52px 0 7px; font-size: 29px; line-height: 1.2; }
.auth-box > p { margin: 0; color: var(--muted); }
.auth-box form, .auth-box label, #verify-area { display: grid; gap: 8px; }
.auth-box form { gap: 18px; margin: 30px 0 16px; }
.public-topbar {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 46%;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
}

label { color: var(--muted); font-size: 12px; font-weight: 650; }
input, select {
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  background: var(--panel-soft);
  color: var(--text);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
input:focus, select:focus { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
input[type="checkbox"] { width: 15px; min-height: 15px; margin: 0 7px 0 0; accent-color: var(--accent); }

.primary, .secondary, .quiet-button, .icon-button, .profile-button, .link-button {
  border: 0;
  background: transparent;
  color: var(--text);
}
.primary, .secondary, .button-row button {
  min-height: 36px;
  border-radius: 5px;
  padding: 8px 13px;
  font-weight: 700;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); }
.secondary { border: 1px solid var(--line); background: var(--panel-strong); color: var(--text); }
.secondary:hover { border-color: var(--line-strong); background: var(--panel-soft); }
.link-button { padding: 0; color: var(--accent); font-weight: 650; }
.form-message { min-height: 21px; color: var(--danger); }

.topbar {
  position: fixed;
  z-index: 8;
  inset: 0 0 auto;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px 0 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(12px);
}
.topbar .brand { min-width: calc(var(--sidebar-width) - 18px); }
.brand-mark { width: 32px; height: 32px; border-color: var(--line-strong); background: var(--panel-strong); color: var(--text); }
.brand-name { display: flex; flex-direction: column; font-size: 15px; line-height: 1.2; }
.brand-name small { color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 1.3px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.status-dot { margin-right: 8px; color: var(--muted); font-size: 12px; }
.status-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 4px var(--positive-soft); }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 5px; }
.icon-button:hover { background: var(--panel-soft); }
.profile-button { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 4px; padding-left: 14px; border-left: 1px solid var(--line); font-size: 12px; font-weight: 650; }

.sidebar {
  position: fixed;
  z-index: 7;
  top: var(--topbar-height);
  bottom: 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 12px 12px;
  overflow-y: auto;
  border-right: 1px solid #1d2127;
  background: var(--sidebar);
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar nav { display: grid; gap: 2px; }
.nav-section { margin: 15px 11px 5px; color: #59616c; font-size: 10px; font-weight: 750; letter-spacing: 1.2px; }
.nav-section:first-child { margin-top: 2px; }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 560;
}
.sidebar a::before { content: attr(data-icon); width: 22px; color: #5f6874; font: 700 9px/1 Inter, Arial, sans-serif; }
.sidebar a:hover { background: var(--sidebar-panel); color: #e7e9ec; }
.sidebar a.active { border-color: #2a3038; background: #1a1e24; color: #fff; }
.sidebar a.active::before { color: #6aa0ff; }
.sidebar-bottom { padding: 12px 8px 4px; border-top: 1px solid #20242a; }
.quiet-button { width: 100%; padding: 8px; color: var(--sidebar-text); text-align: left; }
.quiet-button:hover { color: #fff; }

.content {
  max-width: 1720px;
  min-height: calc(100vh - var(--topbar-height));
  margin: var(--topbar-height) 0 0 var(--sidebar-width);
  padding: 28px 30px 48px;
}
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 5px; font-size: 23px; line-height: 1.25; font-weight: 720; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.page-head > strong { font-size: 20px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric, .panel, .strategy-card { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow); }
.metric { position: relative; min-height: 104px; padding: 17px 18px; overflow: hidden; }
.metric::after { content: ""; position: absolute; top: 0; right: 0; width: 34px; height: 2px; background: var(--line-strong); }
.metric span { display: block; color: var(--muted); font-size: 11px; font-weight: 650; }
.metric strong { display: block; margin-top: 8px; font-size: 22px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.positive { color: var(--positive) !important; }
.negative { color: var(--danger) !important; }
.layout-two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(310px, .8fr); gap: 14px; }
.panel { padding: 18px; }
.panel + .panel { margin-top: 14px; }
.layout-two > .panel + .panel { margin-top: 0; }
.panel h2 { margin: 0 0 14px; font-size: 14px; font-weight: 720; }
.panel p { color: var(--muted); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 5px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { height: 38px; background: var(--panel-soft); color: var(--muted); font-size: 11px; font-weight: 680; }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--panel-soft) 70%, transparent); }
td { font-size: 12px; font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px; border-radius: 4px; background: var(--positive-soft); color: var(--positive); font-size: 10px; font-weight: 750; }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.button-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.button-row button { border: 1px solid var(--line); background: var(--panel-strong); color: var(--text); }
.button-row button:hover { border-color: var(--line-strong); background: var(--panel-soft); }
.button-row .primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button-row .danger { color: var(--danger); }

.strategy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.strategy-card { padding: 17px; }
.strategy-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.strategy-card h3 { margin: 0; font-size: 15px; }
.strategy-meta { margin: 7px 0; color: var(--muted); font-size: 11px; }
.strategy-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 15px 0; padding-top: 13px; border-top: 1px solid var(--line); }
.strategy-card dt { color: var(--muted); font-size: 11px; }
.strategy-card dd { margin: 0; text-align: right; font-size: 12px; font-weight: 680; font-variant-numeric: tabular-nums; }
.new-strategy { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.new-strategy.panel { margin-bottom: 16px; }
.new-strategy .wide { grid-column: 1 / -1; }
.advanced-settings { grid-column: 1 / -1; padding: 14px 0 0; border-top: 1px solid var(--line); }
.advanced-settings summary { cursor: pointer; font-weight: 700; }
.advanced-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 11px; margin-top: 14px; }
.advanced-grid label:has(input[type="checkbox"]) { display: flex; align-items: center; min-height: 40px; padding-top: 20px; }

.chart { display: block; width: 100%; height: 270px; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day { min-height: 58px; padding: 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 11px; }
.day.positive { background: var(--positive-soft); }
.day.negative { background: var(--danger-soft); }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 18px; min-height: 68px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row small { display: block; margin-top: 3px; color: var(--muted); }
.admin-shell { max-width: 1320px; margin: 0 auto; padding: 76px 24px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.admin-head h1 { margin: 5px 0; }
.notice { margin: 12px 0; padding: 11px 13px; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--line)); border-left: 3px solid var(--warning); border-radius: 4px; background: var(--warning-soft); color: var(--warning); }

.exchange-summary { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
.account-setup { margin-bottom: 16px; padding: 0; overflow: hidden; }
.account-setup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.account-setup-head h2 { margin-bottom: 4px; }
.account-setup-head p { margin: 0; font-size: 12px; }
.account-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 20px; }
.account-form .wide { grid-column: 1 / -1; }
.field-note { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 500; }
.exchange-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.exchange-option { position: relative; display: block; }
.exchange-option input { position: absolute; opacity: 0; pointer-events: none; }
.exchange-option span { display: flex; align-items: center; gap: 9px; min-height: 48px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); color: var(--muted); font-size: 12px; font-weight: 720; cursor: pointer; }
.exchange-option span::before { content: attr(data-mark); display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--text); font-size: 8px; }
.exchange-option input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 10%, transparent); }
.credential-hint { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); color: var(--muted); font-size: 11px; }
.credential-hint strong { color: var(--text); }
.switch-line { display: flex; align-items: center; min-height: 40px; margin-top: 20px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); color: var(--text); font-size: 12px; }
.account-list { display: grid; gap: 10px; }
.account-card { display: grid; grid-template-columns: minmax(230px, 1.2fr) repeat(3, minmax(120px, .65fr)) auto; align-items: center; gap: 16px; min-height: 98px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow); }
.account-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.exchange-mark { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--panel-soft); font-size: 9px; font-weight: 800; }
.account-identity h3 { overflow: hidden; margin: 0 0 4px; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.account-identity p, .account-stat span { margin: 0; color: var(--muted); font-size: 10px; }
.account-stat strong { display: block; margin-top: 4px; font-size: 12px; }
.account-actions { display: flex; justify-content: flex-end; gap: 6px; min-width: 230px; }
.test-result { display: none; grid-column: 1 / -1; margin: -4px 0 0 52px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.test-result.visible { display: block; }
.test-result.success { color: var(--positive); }
.test-result.error { color: var(--danger); }
.empty-state { padding: 46px 24px; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--text); }
.hidden { display: none !important; }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .account-card { grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(110px, .6fr)) auto; }
  .account-card .account-stat:nth-of-type(3) { display: none; }
  .advanced-grid { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 72px; }
  .brand-name, .nav-section, .sidebar a { font-size: 0; }
  .topbar .brand { min-width: 54px; }
  .sidebar { padding-inline: 9px; }
  .sidebar a { justify-content: center; padding: 8px; }
  .sidebar a::before { width: auto; font-size: 10px; }
  .sidebar-bottom { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .layout-two { grid-template-columns: 1fr; }
  .layout-two > .panel + .panel { margin-top: 0; }
  .new-strategy { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .advanced-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .account-card { grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(100px, .5fr)); }
  .account-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .test-result { margin-left: 0; }
}

@media (max-width: 680px) {
  :root { --topbar-height: 58px; --sidebar-width: 0px; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-intro { min-height: 250px; padding: 88px 25px 30px; }
  .auth-intro h1 { font-size: 34px; }
  .auth-intro > div > p:last-child { font-size: 14px; }
  .auth-status { display: none; }
  .auth-main { place-items: start center; padding: 36px 22px 60px; }
  .public-topbar { left: 0; height: 58px; padding: 0 18px; }
  .auth-box h2 { margin-top: 18px; }
  .topbar { padding: 0 12px; }
  .topbar .brand { min-width: 36px; }
  .brand-name, .status-dot { display: none; }
  .profile-button { max-width: 130px; }
  .sidebar { top: auto; right: 0; width: 100%; height: 58px; padding: 5px 8px; border-top: 1px solid #20242a; border-right: 0; overflow-x: auto; overflow-y: hidden; }
  .sidebar nav { display: flex; width: max-content; }
  .sidebar a { flex: 0 0 42px; }
  .content { margin-left: 0; padding: 20px 15px 84px; }
  .page-head { display: block; }
  .page-head > button, .page-head > .button-row { margin-top: 13px; }
  .metrics, .exchange-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 92px; padding: 14px; }
  .metric strong { font-size: 18px; }
  .new-strategy, .account-form { grid-template-columns: 1fr; }
  .new-strategy .wide, .account-form .wide { grid-column: 1; }
  .advanced-grid { grid-template-columns: 1fr; }
  .exchange-picker { grid-template-columns: 1fr; }
  .account-card { grid-template-columns: 1fr 1fr; }
  .account-identity, .account-actions, .test-result { grid-column: 1 / -1; }
  .setting-row { align-items: flex-start; flex-direction: column; }
  .setting-row .button-row { width: 100%; }
  .admin-head { align-items: flex-start; flex-direction: column; }
}
