:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #ecefe9;
  background: #111512;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #171c18;
  --line: #29312b;
  --muted: #89958c;
  --green: #d8fb64;
  --green-dark: #a4ca37;
  --red: #f18b83;
  --amber: #edbd6d;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #111512; }
button, input { font: inherit; }
button { color: inherit; }

.topbar { height: 64px; padding: 0 5.2vw; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #242b26; background: #131815; }
.brand-lockup, .topbar-right { display: flex; align-items: center; }
.brand-lockup { gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 8px; background: var(--green); color: #171a12; font-family: Consolas, monospace; font-weight: 700; font-size: 17px; }
.brand-name { font-size: 14px; font-weight: 600; }
.topbar-right { gap: 24px; }
.connection { display: inline-flex; align-items: center; gap: 8px; color: #a7b0a9; font: 10px Consolas, monospace; letter-spacing: .08em; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green-dark); box-shadow: 0 0 8px #a4ca3760; }
.quiet-button { padding: 7px 4px; border: 0; background: transparent; color: #a5aea7; font-size: 12px; cursor: pointer; }
.quiet-button:hover { color: #fff; }
.workspace { width: min(1160px, 89.6vw); margin: 0 auto; padding: 42px 0 32px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 9px; color: #8f9a91; font: 10px Consolas, monospace; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; line-height: 1.25; font-weight: 600; }
.heading-actions { display: flex; align-items: center; gap: 16px; }
.sync-state { color: var(--green); font: 11px Consolas, monospace; }
.sync-state::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 8px 1px 0; border-radius: 50%; background: currentColor; }
.sync-error { color: var(--red); }
.primary-button { min-height: 37px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--green); border-radius: 5px; padding: 0 13px; background: var(--green); color: #13170e; font-size: 12px; font-weight: 700; cursor: pointer; transition: background .14s ease, transform .14s ease; }
.primary-button:hover { background: #e4ff8a; }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; opacity: .75; }
.refresh-icon { font-size: 18px; line-height: 0; }
.is-loading .refresh-icon { animation: turn .8s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }

.summary-strip { display: grid; grid-template-columns: 1fr 1fr 1.35fr 1fr; border: 1px solid var(--line); border-radius: 5px; background: #151a16; }
.summary-item { min-width: 0; min-height: 80px; display: flex; flex-direction: column; justify-content: center; gap: 9px; padding: 14px 20px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item > span:first-child { color: var(--muted); font-size: 11px; }
.summary-item strong { overflow-wrap: anywhere; color: #f0f3ed; font: 500 17px Consolas, monospace; }
.summary-updated strong { font-size: 13px; }
.auto-refresh-item { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.switch-control { display: inline-flex; align-items: center; gap: 8px; color: #cad1ca; font-size: 11px; cursor: pointer; }
.switch-control input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 32px; height: 18px; border: 1px solid #465149; border-radius: 12px; background: #292f2b; transition: background .16s ease; }
.switch-track::after { content: ""; position: absolute; width: 12px; height: 12px; top: 2px; left: 2px; border-radius: 50%; background: #9ba59c; transition: transform .16s ease, background .16s ease; }
.switch-control input:checked + .switch-track { border-color: var(--green-dark); background: #5a712c; }
.switch-control input:checked + .switch-track::after { transform: translateX(14px); background: var(--green); }
.switch-control input:focus-visible + .switch-track { outline: 2px solid #fff; outline-offset: 3px; }

.data-section { margin-top: 32px; }
.eth-summary { grid-template-columns: repeat(4, 1fr); }
.eth-summary .summary-item small { color: #94a096; font: 11px "Segoe UI", "Microsoft YaHei", sans-serif; }
.pnl-section { margin-top: 35px; }
.pnl-strip { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.pnl-item { min-height: 100px; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 17px 20px; border-right: 1px solid var(--line); }
.pnl-item:last-child { border-right: 0; }
.pnl-item > span { color: var(--muted); font-size: 11px; }
.pnl-item strong { overflow-wrap: anywhere; color: #f0f3ed; font: 500 18px Consolas, monospace; }
.pnl-item small { color: #818d83; font: 10px Consolas, monospace; }
.pnl-total { background: #1d2419; }
.pnl-total strong { font-size: 21px; }
.pnl-positive { color: var(--green) !important; }
.pnl-negative { color: var(--red) !important; }
.ledger-note { margin-top: 10px; color: #89958c; font-size: 10px; line-height: 1.7; }
.ledger-warning { color: var(--amber); }
.sync-summary { grid-template-columns: 1fr 1fr; margin-top: 30px; }
.sync-summary .summary-item { min-height: 60px; flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; border: 0; }
.sync-summary .summary-item:first-child { border-right: 1px solid var(--line); }
.sync-summary .summary-item strong { font-size: 12px; }
.sync-summary .switch-control { margin-left: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.section-heading h2 { display: inline-block; margin: 0 10px 0 0; font-size: 14px; font-weight: 600; }
.section-heading p { display: inline; margin: 0; color: var(--muted); font-size: 11px; }
.section-count { color: #acb6ad; font: 11px Consolas, monospace; }
.table-frame { overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th { height: 39px; padding: 0 18px; color: #8f9a91; background: #1a201b; font-size: 10px; font-weight: 500; }
td { height: 51px; padding: 0 18px; border-top: 1px solid #252d27; color: #dce2dc; font-size: 12px; }
.numeric-cell { text-align: right; font-family: Consolas, monospace; font-size: 11px; }
th.numeric-cell, table th:nth-child(n+4) { text-align: right; }
.asset-cell { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.asset-mark { width: 23px; height: 23px; display: inline-grid; flex: 0 0 auto; place-items: center; border: 1px solid #425039; border-radius: 50%; background: #222c1c; color: var(--green); font: 10px Consolas, monospace; }
.symbol-cell { color: #f1f4ef; font-weight: 600; }
.side-buy { color: var(--green); }
.side-sell { color: var(--red); }
.time-cell { color: #99a49a; font: 11px Consolas, monospace; }
.loading-state, .empty-state { display: grid; min-height: 102px; place-items: center; color: #89958c; font-size: 12px; }
.empty-state { min-height: 88px; }
.orders-section { margin-top: 35px; }
.page-footer { display: flex; align-items: center; gap: 20px; margin-top: 25px; color: #768178; font-size: 10px; }
.page-footer span:first-child { color: var(--green-dark); }
.page-footer span:last-child { margin-left: auto; }

.login-page, .setup-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: #111512; }
.login-shell, .setup-shell { width: min(100%, 370px); padding: 33px 32px 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.login-shell > .brand-mark, .setup-shell > .brand-mark { width: 39px; height: 39px; margin-bottom: 23px; font-size: 20px; }
.login-shell .eyebrow, .setup-shell .eyebrow { margin-bottom: 8px; font-size: 9px; }
.login-shell h1, .setup-shell h1 { font-size: 21px; }
.login-copy, .setup-copy { margin: 10px 0 25px; color: #a1aca2; font-size: 12px; line-height: 1.7; }
.login-form { display: grid; gap: 10px; }
.login-form label { color: #c0c9c1; font-size: 11px; }
.login-form input[type="password"] { width: 100%; height: 39px; border: 1px solid #3a443b; border-radius: 4px; outline: 0; padding: 0 11px; background: #111512; color: #f4f5f1; }
.login-form input[type="password"]:focus { border-color: var(--green-dark); }
.login-form .primary-button { width: 100%; margin-top: 6px; }
.form-error { margin: 0; color: var(--red); font-size: 11px; }
.login-footnote { margin: 19px 0 0; color: #7f8b81; font-size: 10px; text-align: center; }
.env-list { overflow-x: auto; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 4px; padding: 13px; background: #111512; color: #d8fb64; font: 10px/1.8 Consolas, monospace; }
.setup-note { margin: 0; color: #a1aca2; font-size: 11px; line-height: 1.8; }

@media (max-width: 700px) {
  .topbar { height: 58px; padding: 0 5.5vw; }
  .workspace { width: 89vw; padding-top: 29px; }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 21px; }
  .heading-actions { width: 100%; justify-content: space-between; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .eth-summary { grid-template-columns: 1fr 1fr; }
  .summary-item { min-height: 72px; padding: 12px 14px; }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .eth-summary .summary-item:nth-child(2) { border-right: 0; }
  .eth-summary .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .auto-refresh-item { grid-column: 1 / -1; min-height: 54px; border-right: 0; }
  .pnl-strip { grid-template-columns: 1fr 1fr; }
  .pnl-item { min-height: 86px; padding: 14px; }
  .pnl-item:nth-child(2) { border-right: 0; }
  .pnl-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .pnl-total { background: var(--surface); }
  .sync-summary { grid-template-columns: 1fr; }
  .sync-summary .summary-item:first-child { border-right: 0; border-bottom: 1px solid var(--line); }
  .sync-summary .summary-item { min-height: 55px; }
  .summary-updated strong { font-size: 12px; }
  .section-heading { align-items: flex-start; }
  .section-heading p { display: block; margin-top: 5px; }
  .data-section { margin-top: 27px; }
  th, td { padding-right: 13px; padding-left: 13px; }
  .page-footer { flex-wrap: wrap; gap: 9px 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
