:root {
  color-scheme: dark;
  --bg: #0e1117;
  --panel: #161b24;
  --panel-2: #1c2330;
  --line: #2a3342;
  --text: #eaeef5;
  --muted: #9aa8bc;
  --green: #29d397;
  --red: #ff7085;
  --accent: #66d9cf;
  --sidebar-width: 232px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.65 "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
button, input, select { font: inherit; }
button, a, summary, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, p { margin: 0; }
h1 { font-size: 27px; font-weight: 650; line-height: 1.4; }
h2 { font-size: 16px; font-weight: 600; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 50; padding: 12px; background: var(--panel); }
.skip-link:focus { top: 12px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  padding: 32px 18px 22px;
  background: #121722;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: var(--text); text-decoration: none; }
.brand strong { display: block; font-size: 17px; }
.avatar { border-radius: 12px; object-fit: cover; background: var(--panel-2); flex-shrink: 0; }
.sub { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.side-nav { margin-top: 36px; }
.nav-group { margin: 26px 14px 10px; color: #7f8da2; font-size: 12px; }
.nav-group:first-child { margin-top: 0; }
.side-nav a { display: flex; align-items: center; gap: 13px; min-height: 46px; padding: 11px 14px; margin: 4px 0; border-radius: 8px; text-decoration: none; color: #b4bfd0; }
.side-nav a:hover { background: var(--panel-2); color: var(--text); }
.side-nav a[aria-current="page"] { background: #203334; color: #8ce7de; box-shadow: inset 3px 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 40px 14px 0; color: #7f8da2; font-size: 11px; }
.sidebar-mark { font-size: 17px; font-weight: 700; letter-spacing: 2px; color: #aeb9cb; }
.sidebar-foot p { margin-top: 6px; }
.workspace { margin-left: var(--sidebar-width); padding: 0 clamp(24px, 3.5vw, 68px); min-height: 100vh; }
.site-head, main, footer { max-width: 1560px; margin: 0 auto; }
.site-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 38px 0 0; }
.page-heading { display: flex; align-items: center; gap: 14px; }
.page-category { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.page-description { margin: 12px 0 32px; color: var(--muted); }
.sync { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.dot { flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--green); box-shadow: 0 0 0 4px #29d39712; }
.dot.err { background: var(--red); }
.menu-toggle.reset, .sidebar-backdrop { display: none; }

.panel { min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; margin-bottom: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; padding: 24px; }
.panel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.meta, .muted { color: var(--muted); }
.meta { font-size: 12px; }
.reset { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 16px; border: 1px solid #3b4759; border-radius: 8px; background: transparent; color: var(--text); font-size: 13px; cursor: pointer; }
.reset:hover { background: var(--panel-2); border-color: #67758b; }
.reset:disabled { opacity: .45; cursor: not-allowed; }
.primary { color: #102a28; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.primary:hover { color: #102a28; background: #9ae8df; border-color: #9ae8df; }
.text-link { font-size: 13px; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.overview-grid { display: grid; gap: 28px; padding: 0 24px 24px; min-width: 0; }
.overview-kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 18px; }
.metric { min-width: 0; padding: 20px; background: var(--panel-2); border-radius: 10px; }
.metric .label { color: var(--muted); font-size: 12px; }
.metric .value { margin-top: 10px; font-size: 23px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.metric .value small { font-size: 10px; font-weight: 400; color: var(--muted); }
.metric .hint { color: var(--muted); font-size: 11px; margin-top: 8px; overflow-wrap: anywhere; }
.overview-kpis .metric { min-height: 134px; }
.overview-kpis .value { font-size: clamp(20px,1.8vw,28px); }
.platform-wrap { border: 1px solid var(--line); border-radius: 10px; }
.cell-main { font-size: 15px; font-weight: 600; }
.cell-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.platform-table { min-width: 760px; }
.platform-table a { text-decoration: none; }
.platform-table td { padding-top: 22px; padding-bottom: 22px; }
.overview-links { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 24px; }
.destination { padding: 28px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); text-decoration: none; }
.destination:hover { background: var(--panel); border-color: #4d6775; }
.destination svg { color: var(--accent); width: 24px; height: 24px; }
.destination h2 { margin-top: 18px; }
.destination p { margin-top: 8px; color: var(--muted); font-size: 13px; }
.destination > span { display: inline-block; margin-top: 26px; color: var(--accent); font-size: 12px; }

#position-meta { flex-basis: 100%; }
.table-wrap { max-width: 100%; overflow: auto; scrollbar-width: thin; scrollbar-color: #4b596d var(--panel); }
.table-wrap:focus-visible { outline-offset: -2px; }
table { border-collapse: collapse; min-width: 900px; width: 100%; font-size: 13px; }
th, td { padding: 18px 20px; text-align: left; white-space: nowrap; border-top: 1px solid var(--line); }
th { color: var(--muted); background: #1a202b; font-size: 12px; font-weight: 500; }
tbody tr:hover { background: #ffffff03; }
td small { font-size: 11px; }
.num { text-align: right; }
.coin { font-weight: 650; }
.coin small { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 400; }
.tag, .platform { display: inline-block; padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.tag.long { color: var(--green); background: #29d39712; }
.tag.short { color: var(--red); background: #ff708512; }
.platform.binance { color: #f0c53e; background: #f0c53e12; }
.platform.okx { color: #c7d0dc; background: #c7d0dc12; }
.green { color: var(--green); }
.red { color: var(--red); }
.empty { padding: 32px 24px; border-top: 1px solid var(--line); color: var(--muted); }
.scroll-body { max-height: 65vh; }
.scroll-body thead th { position: sticky; top: 0; z-index: 1; }
.source-details, .strategy-details { color: var(--muted); font-size: 12px; padding: 18px 24px; }
.source-details { border-top: 1px solid var(--line); }
.strategy-details { padding-top: 0; }
summary { cursor: pointer; width: fit-content; padding: 4px 0; }
summary:hover { color: var(--text); }
details p { margin-top: 12px; max-width: 90ch; line-height: 1.9; }
code { color: var(--accent); font-size: 11px; }
.paper-stats, .gate-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; padding: 0 24px 28px; }
.paper-skips, .notice { margin: 0 24px 24px; padding: 14px 18px; color: #bfd2dc; border: 1px solid #335455; border-radius: 8px; background: #66d9cf06; font-size: 12px; overflow-wrap: anywhere; }
.paper-skips:not(.ok), .notice.warn { color: #f0bcc4; border-color: #69404c; background: #ff708506; }
.panel-head.sub-head { border-top: 1px solid var(--line); margin-top: 24px; }
.gate-positions { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,320px),1fr)); gap: 20px; padding: 0 24px; }
.gate-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.gate-card-head, .gate-card-title, .gate-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.gate-card-lev, .gate-card-foot { color: var(--muted); font-size: 11px; }
.gate-card-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin: 20px 0; }
.gate-card-grid div { min-width: 0; }
.gate-card-grid span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.gate-card-grid strong { overflow-wrap: anywhere; font-size: 13px; font-weight: 600; }
.gate-events { max-height: 480px; overflow-y: auto; }
.gate-event { padding: 18px 24px; border-top: 1px solid var(--line); }
.gate-event-line { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.gate-event-time, .gate-event-result { font-size: 11px; color: var(--muted); }
.gate-event-result { margin-left: auto; }
.gate-event-result.red { color: var(--red); }
.gate-event-result.green { color: var(--green); }
.gate-event-action { font-size: 13px; font-weight: 600; }
.gate-event-detail { margin-top: 6px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.settings-view { max-width: 1040px; }
.settings-panel { padding: 28px; }
.settings-heading { margin-bottom: 24px; }
.settings-heading p, .settings-note { color: var(--muted); font-size: 12px; line-height: 1.9; margin-top: 8px; max-width: 80ch; }
.settings-note { margin: 20px 0; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px 32px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 8px; font-size: 13px; }
.field small { color: var(--muted); font-size: 11px; }
input, select { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; background: #10151e; color: var(--text); border: 1px solid #364255; border-radius: 7px; }
input:disabled { opacity: .5; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 62px; }
.input-wrap > span { position: absolute; right: 14px; top: 12px; color: var(--muted); font-size: 12px; pointer-events: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: .65; }
.form-actions, .settings-save { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; }
.form-actions { margin-top: 24px; }
.form-actions p, .settings-save p { font-size: 12px; }
.settings-save { padding: 4px 0 20px; }
.admin-dialog { width: min(440px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 14px; padding: 32px; background: var(--panel); color: var(--text); }
.admin-dialog::backdrop { background: #05080dcc; }
.admin-dialog h2 { font-size: 21px; }
.admin-dialog #admin-description { color: var(--muted); font-size: 13px; margin: 12px 0 24px; }
.admin-dialog #admin-status { min-height: 22px; font-size: 12px; margin-top: 12px; }
#admin-lock { width: 100%; margin-bottom: 20px; font-size: 12px; }
footer { border-top: 1px solid var(--line); padding: 24px 0 32px; margin-top: 56px; color: #7f8da2; font-size: 11px; line-height: 1.9; }
footer a { color: var(--muted); }

@media (max-width: 1280px) {
  :root { --sidebar-width: 208px; }
  .workspace { padding: 0 28px; }
  .overview-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .overview-links { gap: 16px; }
  .destination { padding: 22px; }
}
@media (max-width: 900px) {
  .sidebar { display: none; width: 252px; }
  .sidebar-open .sidebar { display: flex; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: #0009; border: 0; z-index: 20; }
  .workspace { margin-left: 0; padding: 0 24px; }
  .menu-toggle.reset { display: inline-flex; font-size: 20px; padding: 4px 12px; }
  .site-head { padding-top: 26px; }
  .sidebar-open { overflow: hidden; }
}
@media (max-width: 620px) {
  .workspace { padding: 0 16px; }
  .site-head { flex-wrap: wrap; gap: 18px; }
  h1 { font-size: 23px; }
  .sync { width: 100%; font-size: 11px; }
  .page-description { font-size: 13px; margin-bottom: 24px; }
  .overview-grid { padding: 0 16px 16px; gap: 20px; }
  .overview-kpis { gap: 12px; }
  .metric { padding: 16px; }
  .overview-kpis .metric { min-height: 130px; }
  .metric .value, .overview-kpis .value { font-size: 19px; }
  .metric .value small { display: block; margin-top: 4px; }
  .panel-head { padding: 20px 16px; }
  .panel-actions { gap: 8px; }
  .overview-links, .form-grid { grid-template-columns: minmax(0,1fr); }
  .destination > span { margin-top: 18px; }
  .paper-stats, .gate-stats { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 0 16px 20px; gap: 12px; }
  .notice, .paper-skips { margin-left: 16px; margin-right: 16px; }
  .source-details, .strategy-details { padding-left: 16px; padding-right: 16px; }
  .settings-panel { padding: 22px 18px; }
  .gate-positions { padding: 0 16px; }
  .gate-card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  th, td { padding: 16px; }
  footer { margin-top: 36px; }
}
