:root {
  color-scheme: dark;
  --bg: #06110c;
  --bg-2: #071810;
  --panel: rgba(18, 47, 34, 0.74);
  --panel-strong: rgba(20, 58, 42, 0.92);
  --panel-soft: rgba(161, 255, 114, 0.08);
  --surface: rgba(13, 35, 25, 0.82);
  --surface-2: rgba(28, 61, 46, 0.7);
  --surface-3: rgba(54, 91, 71, 0.74);
  --line: rgba(210, 255, 217, 0.14);
  --line-soft: rgba(210, 255, 217, 0.08);
  --text: #f6fff4;
  --text-2: #cfe4d4;
  --muted: #91aa9a;
  --muted-2: #667d70;
  --accent: #9cff6f;
  --accent-strong: #d9ff88;
  --accent-deep: #355f28;
  --danger: #ff6877;
  --warn: #eaff7f;
  --good: #9cff6f;
  --pending-quantity: #ff9b3d;
  --risk-warn-on-light: #9a3d00;
  --risk-danger-on-light: #7d0915;
  --blue: #8fd9ff;
  --up: #9cff6f;
  --down: #ff6877;
  --up-soft: rgba(156, 255, 111, 0.14);
  --up-line: rgba(156, 255, 111, 0.36);
  --down-soft: rgba(255, 104, 119, 0.12);
  --down-line: rgba(255, 104, 119, 0.32);
  --accent-soft: rgba(217, 255, 136, 0.13);
  --accent-line: rgba(217, 255, 136, 0.34);
  --soft: rgba(156, 255, 111, 0.12);
  --glass: linear-gradient(150deg, rgba(34, 85, 62, 0.76), rgba(7, 24, 17, 0.94));
  --glass-border: rgba(224, 255, 220, 0.14);
  --radius: 24px;
  --radius-sm: 18px;
  --radius-xs: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
  --shadow-soft: 0 14px 36px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: none;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  margin: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(1000px 560px at 72% -12%, rgba(195, 255, 185, 0.2), transparent 62%),
    linear-gradient(140deg, #123d2c 0%, #082317 38%, #03100a 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: 0;
  overscroll-behavior: none;
}

body.modal-open {
  overflow: hidden;
}

body.wallet-login-visible {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(156, 255, 111, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(156, 255, 111, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 76%);
}

.account-head,
.ladder-title,
.section-heading h2,
.trade-section > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #102313;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  box-shadow: 0 10px 28px rgba(156, 255, 111, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.section-icon {
  width: 30px;
  height: 30px;
  border-radius: 12px;
}

.section-icon svg {
  width: 18px;
  height: 18px;
}

h2 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 760;
  letter-spacing: 0;
  text-wrap: pretty;
}

main {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 1480px;
  min-height: 100%;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

.account-card,
.metric,
section,
details.collapsible-section {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.wallet-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background:
    radial-gradient(680px 420px at 50% 38%, rgba(156, 255, 111, 0.14), transparent 64%),
    rgba(2, 10, 7, 0.72);
  backdrop-filter: blur(18px);
}

.account-card {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 22px;
  min-width: 0;
  overflow: hidden;
  padding: 16px 18px;
  background:
    linear-gradient(115deg, rgba(151, 255, 121, 0.9), rgba(226, 255, 126, 0.82)),
    var(--glass);
  color: #06100a;
}

.account-card::after {
  content: "BALANCE";
  position: absolute;
  right: -20px;
  top: -20px;
  color: rgba(6, 31, 14, 0.12);
  font-size: clamp(48px, 10vw, 118px);
  font-weight: 900;
  letter-spacing: -0.06em;
  pointer-events: none;
}

.account-card .section-icon {
  color: var(--accent-strong);
  background: rgba(6, 20, 12, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.account-head {
  position: relative;
  z-index: 1;
  flex: 0 1 auto;
}

.account-head h2 {
  margin: 0;
  color: #07150b;
  font-size: 16px;
  white-space: nowrap;
}

.account-pill {
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  min-height: 26px;
  min-width: 0;
  padding: 0 12px;
  overflow: hidden;
  color: rgba(5, 25, 12, 0.84);
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid rgba(5, 25, 12, 0.14);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-switcher {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  margin-left: auto;
  margin-right: 18px;
  padding: 4px;
  background: rgba(5, 25, 12, 0.16);
  border: 1px solid rgba(5, 25, 12, 0.16);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 24px rgba(5, 25, 12, 0.12);
}

.account-switch-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 28px;
  padding: 0 13px;
  color: rgba(5, 25, 12, 0.68);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 860;
  line-height: 1;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.account-switch-link:hover,
.account-switch-link:focus-visible {
  color: #041109;
  background: rgba(255, 255, 255, 0.24);
  outline: none;
}

.account-switch-link:active {
  transform: translateY(1px);
}

.account-switch-link.active {
  color: #f6fff4;
  background: linear-gradient(135deg, rgba(4, 17, 9, 0.94), rgba(13, 42, 23, 0.9));
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 18px rgba(5, 25, 12, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.ws-status {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  min-width: 11px;
  width: 11px;
  min-height: 11px;
  height: 11px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(5, 25, 12, 0.46);
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 104, 119, 0.18), 0 0 18px rgba(255, 104, 119, 0.5);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.ws-status::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.ws-status.connected {
  background: #0b8f3d;
  box-shadow: 0 0 0 4px rgba(11, 143, 61, 0.18), 0 0 18px rgba(11, 143, 61, 0.56);
}

.ws-status.disconnected {
  background: var(--danger);
}

.account-grid {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  flex: 1 1 520px;
  flex-wrap: wrap;
  gap: 9px 22px;
  min-width: 0;
}

.account-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.account-item > span {
  color: rgba(5, 25, 12, 0.62);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.account-item > span::after {
  content: ":";
  margin-left: 2px;
  color: rgba(5, 25, 12, 0.42);
}

.account-item strong,
.account-item strong .account-equity-current,
.account-item strong .account-equity-snapshot {
  color: #020906;
}

.account-item strong {
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  line-height: 1.2;
}

.account-item strong.tone-warn {
  color: #12370d;
}

.account-item strong.tone-danger {
  color: #7d0915;
}

.account-risk-item strong.tone-warn {
  color: var(--risk-warn-on-light);
}

.account-risk-item strong.tone-danger {
  color: var(--risk-danger-on-light);
}

.account-fee-item,
.account-risk-item {
  flex: 1 1 260px;
}

.account-fee-breakdown,
.account-risk-breakdown {
  color: rgba(5, 25, 12, 0.54);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 680;
  line-height: 1.2;
  white-space: nowrap;
}

.metric {
  position: relative;
  min-height: 56px;
  overflow: hidden;
  padding: 10px 12px;
}

.forecast-section {
  position: relative;
  overflow: hidden;
  padding: 15px 18px 13px;
  background: linear-gradient(112deg, rgba(35, 36, 31, 0.98), rgba(13, 28, 22, 0.96));
  border-color: rgba(255, 186, 77, 0.3);
  box-shadow: var(--shadow-soft), inset 3px 0 0 rgba(255, 179, 71, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.forecast-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.forecast-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.forecast-title h2 {
  margin: 0;
  font-size: 15px;
}

.forecast-title > div > span {
  display: block;
  margin-top: 2px;
  color: #cbbda5;
  font-size: 10px;
  font-weight: 720;
}

.forecast-icon {
  color: #2d1a05;
  background: #ffb347;
  box-shadow: 0 9px 24px rgba(255, 168, 52, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.forecast-boundary {
  flex: 0 0 auto;
  color: #d3c6b4;
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.forecast-body {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 2fr);
  align-items: stretch;
  gap: 0;
  border-top: 1px solid rgba(255, 218, 164, 0.13);
  border-bottom: 1px solid rgba(255, 218, 164, 0.13);
}

.forecast-critical {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(105px, 0.7fr);
  gap: 0;
  min-width: 0;
  border-right: 1px solid rgba(255, 218, 164, 0.13);
}

.forecast-primary {
  min-width: 0;
  padding: 15px 16px 14px 0;
}

.forecast-primary + .forecast-primary {
  padding-left: 16px;
  border-left: 1px solid rgba(255, 218, 164, 0.13);
}

.forecast-primary > span,
.forecast-metric > span {
  display: block;
  color: #9e9587;
  font-size: 10px;
  font-weight: 720;
  line-height: 1.2;
}

.forecast-primary strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: #ffbd5b;
  font-family: var(--mono);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  line-height: 1.05;
}

.forecast-primary small {
  display: block;
  margin-top: 6px;
  color: #a99e8e;
  font-family: var(--mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.forecast-ratio strong {
  color: #ff6f7d;
}

.forecast-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
}

.forecast-metric {
  min-width: 0;
  padding: 12px 13px;
  border-right: 1px solid rgba(255, 218, 164, 0.1);
  border-bottom: 1px solid rgba(255, 218, 164, 0.1);
}

.forecast-metric:nth-child(4n) {
  border-right: 0;
}

.forecast-metric:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.forecast-metric strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: #f8f2e8;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  line-height: 1.15;
}

.forecast-metric.loss strong,
.forecast-metric.fee strong {
  color: #ff9b78;
}

.forecast-model {
  padding-top: 10px;
  overflow-wrap: anywhere;
  color: #a99e8e;
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.forecast-unavailable {
  display: none;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: #cbbda5;
  border-top: 1px solid rgba(255, 218, 164, 0.13);
  border-bottom: 1px solid rgba(255, 218, 164, 0.13);
  font-size: 12px;
  text-align: center;
}

.forecast-section.unavailable .forecast-body,
.forecast-section.unavailable .forecast-model {
  display: none;
}

.forecast-section.unavailable .forecast-unavailable {
  display: flex;
}

.label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.value {
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 740;
  line-height: 1.15;
}

section,
details.collapsible-section {
  min-width: 0;
  padding: 15px;
}

.ladder-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 30px;
  margin-bottom: 11px;
  overflow: hidden;
}

.ladder-title {
  flex: 0 0 auto;
  justify-self: start;
  grid-column: 1;
  grid-row: 1;
  z-index: 1;
  overflow: hidden;
  padding-right: 8px;
  background: inherit;
  white-space: nowrap;
}

.ladder-title h2 {
  flex: 0 0 auto;
  margin: 0;
  line-height: 1;
  white-space: nowrap;
}

.ladder-sync {
  overflow: hidden;
  color: var(--muted-2);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ladder-sync:empty {
  display: none;
}

.ladder-sync.error {
  color: var(--down);
}

.ladder-spread {
  display: inline-flex;
  align-items: baseline;
  justify-self: center;
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 0;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ladder-spread[hidden] {
  display: none;
}

.ladder-spread strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 740;
}

.ladder-spread em {
  color: var(--muted-2);
  font-size: 10px;
  font-style: normal;
}

.ladder-spread em::before {
  content: "·";
  margin-right: 6px;
}

.ladder-stats {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  grid-column: 3;
  grid-row: 1;
  z-index: 1;
  gap: 8px;
  width: max-content;
  min-width: max-content;
  max-width: none;
  padding-left: 8px;
  background: inherit;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.ladder-stats::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.ladder-stat,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.ladder-stat {
  flex: 0 0 auto;
  justify-content: center;
  gap: 6px;
  min-width: max-content;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
  line-height: 1;
  white-space: nowrap;
}

.ladder-stat::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.ladder-stat.close,
.ladder-stat.close strong {
  color: var(--up);
}

.ladder-stat.open,
.ladder-stat.open strong {
  color: var(--down);
}

.ladder-stat.close {
  border-color: var(--up-line);
  background: var(--up-soft);
}

.ladder-stat.open {
  border-color: var(--down-line);
  background: var(--down-soft);
}

.ladder-stat strong {
  display: inline-block;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  line-height: 1;
  text-align: right;
}

.ladder-current {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.ladder-current-main {
  display: inline-flex;
  align-items: baseline;
  flex: 0 0 auto;
  gap: 5px;
  min-width: max-content;
  white-space: nowrap;
}

.ladder-current-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
  line-height: 1;
}

.ladder-current-label:empty {
  display: none;
}

.ladder-current strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  line-height: 1;
}

.ladder-current-qty {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  line-height: 1;
}

.ladder-current-qty:empty {
  display: none;
}

.close-summary {
  display: grid;
  grid-template-columns: minmax(154px, 1.12fr) 20px minmax(88px, 1fr) 20px minmax(100px, 1fr) 20px minmax(88px, 1fr);
  align-items: stretch;
  gap: 7px;
  margin: 0 0 11px;
  padding: 7px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(3, 16, 10, 0.32);
}

.close-summary-operator {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 18px;
  height: 18px;
  align-self: center;
  color: var(--muted-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 860;
  line-height: 1;
  text-shadow: 0 0 14px rgba(156, 255, 111, 0.12);
}

.close-summary-operator.equals {
  color: var(--accent-strong);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.close-summary-item,
.grid-highlight,
.derived-item,
.preview-metric {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.close-summary-item {
  position: relative;
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 58px;
  overflow: hidden;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
}

button.close-summary-item {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  appearance: none;
}

button.close-summary-item.open-unclosed.operable {
  cursor: pointer;
  border-color: rgba(255, 184, 77, 0.42);
}

button.close-summary-item.open-unclosed.operable:hover,
button.close-summary-item.open-unclosed.operable:focus-visible {
  background: rgba(255, 184, 77, 0.1);
  outline: none;
}

button.close-summary-item:disabled {
  color: inherit;
  opacity: 1;
}

.close-summary-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--muted-2);
  opacity: 0.72;
}

.close-summary-item span,
.grid-highlight-label,
.grid-detail-title,
.preview-metric span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-transform: uppercase;
}

.close-summary-values {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.close-summary-values strong {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 820;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.close-summary-item.open-unclosed.has-unclosed > span,
.close-summary-item.open-unclosed.has-unclosed .close-summary-values strong,
.close-summary-item.bad-debts > span,
.close-summary-item.bad-debts .close-summary-values strong {
  color: var(--pending-quantity);
}

.close-summary-unit {
  margin-left: 2px;
  color: var(--muted);
  font-size: 0.6em;
  font-weight: 680;
  line-height: 1;
  vertical-align: baseline;
}

.close-summary-values em {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  flex: 0 0 auto;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
  font-style: normal;
  line-height: 1;
  white-space: nowrap;
}

.close-summary-values em::after {
  content: "单";
  margin-left: 2px;
  color: var(--muted-2);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.close-summary-item.seed,
.close-summary-item.ordinary {
	gap: 4px;
	font-variant-numeric: tabular-nums;
}

.close-summary-ordinary-recycled {
  display: grid;
  grid-template-columns: 10px 10px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 3px;
  min-width: 0;
  padding-top: 3px;
  border-top: 1px dashed var(--accent-line);
  font-family: var(--mono);
}

.close-summary-ordinary-recycled > span,
.close-summary-ordinary-recycled b {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.close-summary-ordinary-recycled strong {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  white-space: nowrap;
}

.close-summary-ordinary-recycled .close-summary-unit {
  margin-left: 1px;
  font-size: 0.6em;
}

.close-summary-ordinary-recycled em {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9px;
  font-style: normal;
  line-height: 1;
  white-space: nowrap;
}

.close-summary-ordinary-recycled em::after {
  content: "单";
  margin-left: 2px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.close-summary-label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
}

.close-summary-drift {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  max-width: calc(100% - 42px);
  overflow: hidden;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  letter-spacing: -0.02em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.close-summary-drift {
  min-height: 20px;
  margin: 0;
  padding: 2px 6px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  box-shadow: none;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 100ms ease;
}

button.close-summary-drift:not(:disabled) {
  cursor: pointer;
}

button.close-summary-drift:not(:disabled):hover {
  color: var(--accent-strong);
  background: rgba(156, 255, 111, 0.16);
  border-color: var(--accent-strong);
  transform: translateY(-1px);
}

button.close-summary-drift:not(:disabled):active {
  transform: translateY(0);
}

button.close-summary-drift:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

button.close-summary-drift:disabled {
  cursor: default;
  opacity: 0.72;
}

button.close-summary-drift[hidden] {
  display: none;
}

.close-summary-drift.warn {
  color: var(--accent-strong);
}

.close-summary-item.seed::before {
  background: var(--up);
}

.close-summary-item.ordinary::before,
.close-summary-item.bad-debts::before,
.close-summary-item.total::before {
  background: var(--accent-strong);
}

.close-summary-item.total {
  background: linear-gradient(135deg, rgba(156, 255, 111, 0.15), rgba(255, 255, 255, 0.045));
  border-color: var(--accent-line);
}

.close-summary-item.total strong {
  color: var(--text);
  font-size: 15px;
}

.ladder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(3, 16, 10, 0.42);
}

.ladder-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: transparent;
}

.ladder-panel + .ladder-panel {
  border-left: 1px solid var(--line-soft);
}

.ladder-rows {
  --ladder-visible-rows: 5;
  --ladder-row-size: 34px;
  display: grid;
  flex: 1 1 auto;
  min-height: calc(var(--ladder-visible-rows) * var(--ladder-row-size));
  max-height: calc(var(--ladder-visible-rows) * var(--ladder-row-size));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
  scrollbar-width: thin;
}

.ladder-rows::-webkit-scrollbar {
  width: 5px;
}

.ladder-rows::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.ladder-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  transition: background 0.14s ease, transform 0.14s ease;
}

.ladder-row:first-child {
  border-top: 0;
}

.ladder-row:hover {
  background: rgba(255, 255, 255, 0.055);
}

.ladder-price {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ladder-qty {
  min-width: 0;
  color: var(--text-2);
  text-align: right;
  white-space: nowrap;
}

.ladder-qty.partial-fill,
.ladder-qty.risk-exposure {
  color: var(--pending-quantity);
  font-weight: 650;
}

.order-marker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.order-kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
}

.order-kind.close {
  color: var(--up);
  border: 1px solid var(--up-line);
  background: var(--up-soft);
}

.order-kind.open {
  color: var(--down);
  border: 1px solid var(--down-line);
  background: var(--down-soft);
}

.ladder-row.close .ladder-price {
  color: var(--up);
}

.ladder-row.open .ladder-price {
  color: var(--down);
}

.seed-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  color: var(--up);
  background: var(--bg-2);
  border: 1px solid var(--up-line);
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--bg-2);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
}

.bad-debts-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
  color: var(--accent-strong);
  background: var(--bg-2);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--bg-2);
  font-size: 6px;
  font-weight: 900;
}

.reprice-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  color: var(--accent-strong);
  background: var(--bg-2);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--bg-2);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
}

.ioc-badge {
  position: absolute;
  right: -5px;
  bottom: -4px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 10px;
  color: var(--accent-strong);
  background: var(--bg-2);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--bg-2);
  font-size: 5px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}

.ladder-empty,
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: 12px;
}

.ladder-empty {
  min-height: 170px;
}

.section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  margin: -2px -2px 0;
  padding: 2px;
  list-style: none;
  cursor: pointer;
}

.section-summary::-webkit-details-marker {
  display: none;
}

.section-summary h2 {
  margin: 0;
}

.summary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 60px;
  min-height: 32px;
  padding: 0 14px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 660;
}

.summary-action::before {
  content: "展开";
}

details[open] .summary-action::before {
  content: "收起";
}

.section-content {
  padding-top: 14px;
}

form {
  display: grid;
  gap: 12px;
}

.form-grid,
.derived-grid,
.modal-preview {
  display: grid;
  gap: 10px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.derived-grid,
.modal-preview {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .full-span {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

label.full-span {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.4;
}

label.full-span input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

input,
select {
  width: 100%;
  height: 46px;
  padding: 8px 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font: inherit;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

select option {
  color: var(--text);
  background: #10251a;
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.085);
  box-shadow: 0 0 0 4px rgba(156, 255, 111, 0.12);
}

input[readonly] {
  color: var(--muted);
  background: var(--surface);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--up);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.derived-item,
.preview-metric {
  min-height: 66px;
  padding: 11px 12px;
  border-radius: var(--radius-xs);
}

.derived-item .value,
.preview-metric strong {
  display: block;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.preview-metric span {
  display: block;
  margin-bottom: 7px;
}

.actions,
.modal-actions,
.grid-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 9px;
}

.modal-actions {
  justify-content: flex-end;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  touch-action: manipulation;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease, transform 0.06s ease;
}

button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(225, 255, 224, 0.24);
}

button:active {
  transform: scale(0.985);
}

button.primary,
.add-grid-inline,
button[data-restart],
button[data-early],
#editEarlyStartBtn {
  color: #071207;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border-color: rgba(217, 255, 136, 0.6);
  box-shadow: 0 14px 30px rgba(156, 255, 111, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  font-weight: 820;
}

button.primary:hover,
.add-grid-inline:hover,
button[data-restart]:hover,
button[data-early]:hover,
#editEarlyStartBtn:hover {
  color: #051007;
  background: linear-gradient(135deg, #ebff91, #a7ff75);
  border-color: rgba(234, 255, 145, 0.74);
}

button.danger,
button[data-stop],
button[data-delete] {
  color: var(--down);
  background: var(--down-soft);
  border-color: var(--down-line);
}

button.danger:hover,
button[data-stop]:hover,
button[data-delete]:hover {
  color: #ffc8ce;
  background: rgba(255, 104, 119, 0.18);
  border-color: var(--down);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button:disabled:hover {
  transform: none;
}

button.is-busy {
  cursor: progress;
}

button.is-busy:hover {
  transform: none;
  box-shadow: none;
}

button.is-busy:disabled {
  opacity: 0.84;
}

.btn-icon {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
}

.btn-spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.68s linear infinite;
}

.btn-busy-label {
  line-height: 1;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

.grid-list {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.grid-list.is-busy {
  pointer-events: none;
}

.grid-list.is-busy > .grid-card {
  opacity: 0.56;
  transition: opacity 0.16s ease;
}

.grid-list.is-busy::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 6;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  animation: btn-spin 0.8s linear infinite;
}

.grid-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 15px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.grid-card-head {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.grid-card-headline,
.grid-title-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px 10px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.grid-card-headline::-webkit-scrollbar,
.grid-title-row::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.grid-title {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 6px 11px;
  overflow: hidden;
  color: #071207;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border: 1px solid rgba(217, 255, 136, 0.56);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 880;
  letter-spacing: 0.02em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-title-icon {
  width: 15px;
  height: 15px;
}

.grid-status {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: max-content;
  margin-left: auto;
}

.grid-status .pill {
  max-width: 100%;
  overflow-wrap: normal;
}

.grid-subtitle {
  flex: 0 0 auto;
  padding-left: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}

.grid-inline-meta {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  min-height: 30px;
  padding: 0 11px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
  line-height: 1;
  white-space: nowrap;
}

.grid-inline-dot {
  color: var(--muted-2);
}

.pill {
  flex: 0 0 auto;
  padding: 3px 10px;
  color: var(--text-2);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
}

.pill.warn {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.pill.danger {
  color: var(--down);
  background: var(--down-soft);
  border-color: var(--down-line);
}

.grid-highlights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.grid-highlight {
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
}

.grid-highlight-value {
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  line-height: 1.15;
}

.grid-highlight-value.val-accent,
.grid-field strong.val-accent,
.grid-field strong.val-warn,
.warning-list li {
  color: var(--accent-strong);
}

.grid-highlight-value.val-good,
.grid-field strong.val-good,
.grid-field strong.val-arb-profit,
.pnl-positive {
  color: var(--up);
}

.grid-highlight-value.val-danger,
.grid-field strong.val-danger,
.grid-field strong.val-arb-loss,
.pnl-negative {
  color: var(--down);
}

.grid-highlight-value.val-blue,
.grid-field strong.val-blue,
.grid-field strong.val-trade-count {
  color: var(--blue);
}

.grid-field strong.val-trade-count,
.grid-field strong.val-arb-profit,
.grid-field strong.val-arb-loss,
.pnl-positive,
.pnl-negative {
  font-weight: 820;
}

.grid-detail-block {
  display: grid;
  gap: 8px;
}

.grid-detail-block + .grid-detail-block {
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.grid-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
  min-width: 0;
}

.grid-fields-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-field {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.grid-field-key {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.grid-field-key::after {
  content: ":";
  margin-left: 2px;
  color: var(--muted-2);
}

.grid-field strong {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 680;
  line-height: 1.4;
  text-align: left;
  text-wrap: pretty;
}

.grid-fields-position {
  gap: 8px 12px;
}

.grid-fields-position .grid-field {
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
}

.grid-fields-position .grid-field-key {
  font-size: 11px;
  line-height: 1.2;
  white-space: normal;
}

.grid-fields-position .grid-field-key::after {
  display: none;
}

.grid-fields-position .grid-field strong {
  font-size: 12px;
  font-weight: 680;
  line-height: 1.2;
}

.grid-meta-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.grid-updated,
.window-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.grid-updated strong {
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 660;
}

.window-toggle {
  min-height: 0;
  padding: 0 0 1px;
  color: var(--accent-strong);
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  appearance: none;
}

.window-toggle:hover {
  color: var(--accent);
  background: none;
  transform: none;
}

.window-toggle:disabled {
  color: var(--muted-2);
  cursor: default;
  opacity: 1;
  text-decoration-color: transparent;
}

.window-detail {
  display: none;
  margin-top: -2px;
  padding: 10px 12px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 1.45;
}

.window-detail.open {
  display: block;
}

.grid-card-actions {
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.grid-card-actions button {
  flex: 1 1 auto;
  min-width: 76px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  min-width: 0;
  overflow: hidden;
}

.grid-list-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 8px;
  min-width: max-content;
}

.add-grid-inline {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 15px;
  white-space: nowrap;
}

.add-grid-inline[hidden] {
  display: none;
}

.section-heading h2,
.trade-section > h2 {
  margin: 0;
}

.section-heading h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 30px;
  overflow-x: hidden;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: auto;
}

.section-heading h2::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.grid-list-title-text {
  flex: 0 0 auto;
  white-space: nowrap;
}

.grid-list-summary {
  display: none;
  align-items: center;
  align-self: center;
  flex: 0 1 auto;
  gap: 0;
  height: 32px;
  min-width: 0;
  max-width: 100%;
  padding: 3px 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  white-space: nowrap;
  line-height: 1;
}

.grid-list-summary.has-grid {
  display: inline-flex;
}

.grid-summary-coin,
.grid-summary-meta,
.grid-summary-status,
.grid-summary-direction {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 24px;
  height: 24px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  box-shadow: none;
  line-height: 1;
  white-space: nowrap;
}

.grid-list-summary > :not(:first-child) {
  border-left: 1px solid var(--line-soft);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.grid-summary-coin {
  gap: 7px;
  padding: 0 9px 0 3px;
  color: var(--text);
  font-size: 12px;
  font-weight: 840;
  letter-spacing: 0.035em;
}

.grid-summary-coin svg,
.grid-summary-coin .grid-symbol-icon {
  width: 18px;
  height: 18px;
}

.grid-symbol-icon {
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 50%;
}

.grid-summary-coin.missing .grid-symbol-icon {
  display: none;
}

.grid-summary-coin-text {
  display: inline-block;
}

.grid-summary-meta {
  flex: 0 1 auto;
  gap: 4px;
  min-width: 0;
  padding: 0 9px;
  overflow: hidden;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  letter-spacing: -0.015em;
}

.grid-summary-meta .grid-inline-direction,
.grid-summary-meta .grid-inline-dot {
  flex: 0 0 auto;
}

.grid-summary-meta .grid-inline-range {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-summary-status {
  justify-content: center;
  gap: 5px;
  min-width: 32px;
  margin: 0;
  padding: 0 8px;
  color: var(--up);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 820;
  appearance: none;
  touch-action: manipulation;
  transition: background 0.14s ease, color 0.14s ease;
}

.grid-summary-status:hover,
.grid-summary-status:focus-visible {
  color: var(--up);
  background: rgba(255, 255, 255, 0.065);
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.grid-summary-status:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: -2px;
}

.grid-summary-status.is-expanded {
  min-width: max-content;
  padding: 0 10px;
  font-family: inherit;
  letter-spacing: 0;
}

.grid-summary-status::before {
  content: "";
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
  opacity: 0.88;
}

.grid-summary-status.warn {
  color: var(--accent-strong);
}

.grid-summary-status.danger {
  color: var(--down);
}

.grid-summary-direction {
  gap: 4px;
  padding: 0 8px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 740;
}

.grid-summary-direction.long {
  color: var(--up);
}

.grid-summary-direction.short {
  color: var(--down);
}

.grid-direction-code {
  font-family: var(--mono);
  font-size: 0.88em;
  font-weight: 880;
  opacity: 0.58;
}

.trade-section > h2 {
  margin-bottom: 12px;
}

.trade-heading {
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.trade-heading::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.trade-title-text {
  flex: 0 0 auto;
  white-space: nowrap;
}

.trade-day-stats {
  display: inline-flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: 4px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.trade-day-stat {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 3px;
  white-space: nowrap;
}

.trade-day-stat strong {
  color: var(--accent-strong);
  font-weight: 800;
}

.trade-stats-trigger {
  display: inline-flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 2px 2px 2px 0;
  overflow: hidden;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: inherit;
  font: inherit;
  text-align: left;
}

.trade-stats-trigger:hover,
.trade-stats-trigger:focus-visible {
  background: rgba(143, 217, 255, 0.07);
}

.trade-stats-trigger:focus-visible {
  outline: 1px solid rgba(143, 217, 255, 0.58);
  outline-offset: -1px;
}

.trade-stats-trigger-chevron {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  color: var(--blue);
  transition: transform 160ms ease, color 160ms ease;
}

.trade-stats-trigger:hover .trade-stats-trigger-chevron {
  color: #d5f2ff;
  transform: translateY(2px);
}

.trade-stats-backdrop {
  z-index: 32;
  align-items: flex-end;
  padding: 0;
  background: rgba(0, 7, 4, 0.72);
}

.trade-stats-sheet {
  display: flex;
  flex-direction: column;
  width: min(960px, calc(100% - 32px));
  max-height: min(720px, calc(100vh - 34px));
  max-height: min(720px, calc(100dvh - 34px));
  overflow: hidden;
  background: #081b12;
  border: 1px solid rgba(143, 217, 255, 0.2);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.52);
  animation: trade-stats-sheet-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes trade-stats-sheet-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.trade-stats-grabber {
  flex: 0 0 auto;
  width: 44px;
  height: 4px;
  margin: 9px auto 2px;
  background: rgba(207, 228, 212, 0.28);
  border-radius: 2px;
}

.trade-stats-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px 13px;
  border-bottom: 1px solid var(--line-soft);
}

.trade-stats-modal-head .icon-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: 8px;
}

.trade-stats-sheet-body {
  min-height: 0;
  padding: 14px 18px max(18px, env(safe-area-inset-bottom));
  overflow: auto;
}

.trade-stats-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.trade-stats-range {
  display: inline-grid;
  grid-template-columns: repeat(2, 48px);
  gap: 2px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.trade-stats-range-btn {
  height: 28px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
}

.trade-stats-range-btn:hover {
  color: var(--text);
}

.trade-stats-range-btn.is-active {
  color: #07130d;
  background: var(--accent-strong);
  box-shadow: 0 4px 12px rgba(217, 255, 136, 0.14);
}

.trade-stats-window {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 720;
  white-space: nowrap;
}

.trade-stats-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.trade-stats-metric {
  min-width: 0;
  padding: 8px 12px;
}

.trade-stats-metric + .trade-stats-metric {
  border-left: 1px solid var(--line-soft);
}

.trade-stats-metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.trade-stats-metric strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  line-height: 1.1;
}

.trade-stats-chart-wrap {
  position: relative;
  width: 100%;
  height: 320px;
  min-height: 260px;
  margin-top: 12px;
  overflow: hidden;
}

.trade-stats-chart-scroll {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(143, 217, 255, 0.42) transparent;
}

.trade-stats-chart-canvas {
  height: 100%;
  min-width: 100%;
}

.trade-stats-chart-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
}

.trade-stats-chart-y-axis-title {
  fill: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 840;
  line-height: 1;
}

.trade-stats-chart-y-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 820;
  line-height: 1;
  white-space: nowrap;
}

.trade-stats-chart-grid {
  stroke: rgba(207, 228, 212, 0.09);
  stroke-width: 1;
}

.trade-stats-chart-zero {
  stroke: rgba(255, 212, 121, 0.34);
  stroke-width: 1;
  stroke-dasharray: 4 5;
}

.trade-stats-chart-count {
  fill: rgba(143, 217, 255, 0.26);
  stroke: none;
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: fill 140ms ease, transform 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.trade-stats-chart-count.is-selected {
  fill: rgba(143, 217, 255, 0.62);
  stroke: none;
  transform: scale(1.1, 1.04);
}

.trade-stats-chart-profit {
  fill: none;
  stroke: #ffd479;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.trade-stats-chart-point {
  stroke: #081b12;
  stroke-width: 2;
}

.trade-stats-chart-point.is-up { fill: var(--up); }
.trade-stats-chart-point.is-down { fill: var(--down); }
.trade-stats-chart-point.is-flat { fill: #ffd479; }
.trade-stats-chart-point.is-selected {
  opacity: 1;
  stroke-width: 2;
}

.trade-stats-chart-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 820;
}

.trade-stats-chart-axis-title {
  fill: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 840;
}

.trade-stats-chart-hit {
  cursor: crosshair;
}

.trade-stats-chart-hit rect {
  fill: transparent;
  stroke: transparent;
}

.trade-stats-chart-hit:hover rect,
.trade-stats-chart-hit:focus rect {
  fill: transparent;
  stroke: none;
}

.trade-stats-chart-hit:focus {
  outline: none;
}

.trade-stats-point-detail {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-height: 34px;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(143, 217, 255, 0.055);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trade-stats-point-detail-time {
  min-width: 118px;
  color: var(--text-2);
  font-weight: 820;
}

.trade-stats-point-detail b {
  color: var(--blue);
  font-size: 13px;
}

.trade-stats-point-detail-profit {
  margin-left: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.trade-stats-point-detail strong {
  color: #ffd479;
  font-size: 13px;
}

.trade-stats-point-detail-unit {
  color: var(--text-2);
  font-size: 10px;
  font-style: normal;
  font-weight: 820;
}

.trade-stats-chart-state {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 12px;
}

.trade-stats-chart-state.is-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border: 2px solid rgba(143, 217, 255, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}

.trade-stats-chart-state.is-loading {
  display: flex;
}

.trade-stats-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding-top: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.trade-stats-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trade-stats-legend i {
  display: inline-block;
  flex: 0 0 auto;
}

.trade-stats-legend-bar {
  width: 10px;
  height: 8px;
  background: rgba(143, 217, 255, 0.3);
  border: 1px solid rgba(143, 217, 255, 0.56);
}

.trade-stats-legend-line {
  width: 14px;
  height: 2px;
  background: #ffd479;
}

.icon-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid var(--line);
  border-radius: 15px;
}

.icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(225, 255, 224, 0.24);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.icon-btn.refreshing svg {
  animation: spin-refresh 0.9s linear infinite;
}

@keyframes spin-refresh {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.empty-state {
  padding: 24px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: rgba(3, 16, 10, 0.42);
  text-align: center;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(3, 16, 10, 0.42);
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.table-wrap::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.trade-wrap {
  position: relative;
  height: 254px;
  max-height: 254px;
  overflow: auto;
  scrollbar-gutter: stable both-edges;
  will-change: scroll-position;
}

table {
  width: 100%;
  min-width: 920px;
  background: transparent;
  border-collapse: collapse;
}

.trade-table {
  min-width: 600px;
  background: transparent;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  font-size: 12px;
  font-weight: 700;
}

.trade-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 36px;
  color: var(--muted);
  background: rgba(18, 47, 34, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.02em;
}

.trade-table td {
  height: 46px;
  background: rgba(10, 29, 20, 0.58);
  vertical-align: middle;
}

.trade-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.055);
}

.trade-table th,
.trade-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.trade-table th:nth-child(1),
.trade-table td:nth-child(1) {
  width: 62px;
}

.trade-table th:nth-child(2),
.trade-table td:nth-child(2) {
  width: 84px;
  padding-right: 4px;
}

.trade-table tbody tr:not(.table-empty):not(.trade-loading) td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(10, 29, 20, 0.96);
}

.trade-table tbody tr:not(.table-empty):not(.trade-loading) td:nth-child(2) {
  position: sticky;
  left: 62px;
  z-index: 2;
  background: rgba(10, 29, 20, 0.96);
  box-shadow: 7px 0 12px -7px rgba(0, 0, 0, 0.64);
}

.trade-table tbody tr:not(.table-empty):not(.trade-loading):hover td:nth-child(1),
.trade-table tbody tr:not(.table-empty):not(.trade-loading):hover td:nth-child(2) {
  background: rgba(21, 54, 39, 0.96);
}

.trade-table th:nth-child(1) {
  left: 0;
  z-index: 5;
}

.trade-table th:nth-child(2) {
  left: 62px;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 7px 0 12px -7px rgba(0, 0, 0, 0.64);
}

.trade-loading td,
.table-empty td {
  color: var(--muted);
  text-align: center;
}

.trade-loading td {
  font-size: 11px;
}

.table-empty td {
  padding: 22px 12px;
}

tr:last-child td {
  border-bottom: 0;
}

.trade-dir.long {
  color: var(--up);
  background: var(--up-soft);
  border-color: var(--up-line);
}

.trade-dir.short {
  color: var(--down);
  background: var(--down-soft);
  border-color: var(--down-line);
}

.num-cell {
  color: var(--text-2);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: left;
}

.time-cell {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.muted,
.message {
  color: var(--muted);
}

.message {
  min-height: 20px;
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: hidden;
  background: linear-gradient(150deg, rgba(23, 55, 40, 0.98), rgba(5, 18, 12, 0.99));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

.bad-debt-modal {
  width: min(360px, calc(100vw - 24px));
}

.bad-debt-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: rgba(156, 255, 111, 0.07);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-xs);
}

.bad-debt-summary-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.bad-debt-summary-copy span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.04em;
}

.bad-debt-summary-copy strong {
  overflow: hidden;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 840;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bad-debt-summary-route {
  flex: 0 0 auto;
  padding: 5px 7px;
  color: var(--accent-strong);
  background: rgba(3, 16, 10, 0.44);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 780;
  line-height: 1;
  white-space: nowrap;
}

.bad-debt-fields {
  display: grid;
  gap: 11px;
}

.bad-debt-fields label {
  display: grid;
  gap: 6px;
}

.bad-debt-fields input[readonly] {
  color: var(--accent-strong);
  background: rgba(156, 255, 111, 0.07);
  border-color: var(--accent-line);
}

.bad-debt-guard {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(156, 255, 111, 0.07);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-xs);
  font-size: 10px;
  line-height: 1.2;
}

.bad-debt-actions {
  display: grid;
  grid-template-columns: minmax(84px, 0.65fr) minmax(0, 1.35fr);
}

.modal-head {
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 13px;
  background: rgba(12, 35, 24, 0.92);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.modal-title strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 760;
}

.modal-title span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.confirm-backdrop {
  z-index: 40;
  padding: 20px;
}

.confirm-modal {
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);
  overflow: hidden;
  border-color: rgba(217, 255, 136, 0.24);
}

.confirm-hero {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 18px 13px;
}

.confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  color: #071207;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border: 1px solid rgba(217, 255, 136, 0.58);
  border-radius: 16px;
  box-shadow: 0 16px 34px rgba(156, 255, 111, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.44);
}

.confirm-icon-svg {
  width: 22px;
  height: 22px;
}

.confirm-copy {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.confirm-kicker {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.confirm-copy strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 820;
  line-height: 1.22;
}

.confirm-copy p {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
}

.confirm-detail {
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.confirm-actions {
  justify-content: flex-end;
  padding: 0 18px 18px;
}

.confirm-actions button {
  min-width: 118px;
}

.confirm-modal.has-preview {
  width: min(760px, 100%);
}

.confirm-modal.has-preview .confirm-hero {
  padding-bottom: 11px;
}

.confirm-preview {
  display: grid;
  flex: 1 1 auto;
  gap: 12px;
  min-height: 0;
  margin: 0 18px 14px;
  padding: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(3, 13, 8, 0.48);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.create-preview-head,
.seed-preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.create-preview-head > div,
.seed-preview-title {
  min-width: 0;
}

.create-preview-head > div {
  display: grid;
  gap: 3px;
}

.create-preview-head strong,
.seed-preview-title strong {
  color: var(--text);
  font-size: 13px;
}

.create-preview-head span,
.seed-preview-title span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.create-preview-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  color: var(--accent-strong) !important;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  font-weight: 800;
}

.create-preview-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.create-preview-metric {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  min-height: 86px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xs);
}

.create-preview-metric > span {
  color: var(--muted);
  font-size: 10px;
}

.create-preview-metric > strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.create-preview-metric > small {
  overflow-wrap: anywhere;
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1.4;
}

.create-preview-metric.tone-danger > strong { color: var(--danger); }
.create-preview-metric.tone-warn > strong { color: var(--warn); }
.create-preview-metric.tone-accent > strong { color: var(--accent-strong); }
.create-preview-metric.tone-blue > strong { color: var(--blue); }
.create-preview-metric.tone-good > strong { color: var(--good); }

.seed-preview-block {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.seed-preview-table {
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xs);
}

.seed-preview-row {
  display: grid;
  grid-template-columns: 38px repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  min-height: 31px;
  padding: 5px 9px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.seed-preview-row:last-child {
  border-bottom: 0;
}

.seed-preview-row > :not(:first-child) {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.seed-preview-row > span:first-child {
  color: var(--muted-2);
}

.seed-preview-header {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--surface);
  font-size: 9px;
  font-weight: 700;
}

.seed-preview-profit {
  color: var(--good);
}

.create-preview-notes {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 9px 12px 9px 26px;
  color: var(--muted);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-xs);
  font-size: 9px;
  line-height: 1.45;
}

.confirm-modal.has-preview .confirm-actions {
  padding-top: 0;
}

.confirm-modal.tone-danger {
  border-color: rgba(255, 104, 119, 0.34);
}

.confirm-modal.tone-danger .confirm-icon {
  color: #2b0509;
  background: linear-gradient(135deg, #ff9aa4, var(--down));
  border-color: var(--down-line);
  box-shadow: 0 16px 34px rgba(255, 104, 119, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.confirm-modal.tone-danger .confirm-kicker,
.confirm-modal.tone-warn .confirm-kicker {
  color: var(--warn);
}

.confirm-modal.tone-warn {
  border-color: var(--accent-line);
}

.ws-status-modal {
  width: min(520px, 100%);
}

.ws-status-body {
  gap: 12px;
}

.ws-status-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.ws-status-hero > div {
  display: grid;
  gap: 4px;
}

.ws-status-hero > div > span {
  color: var(--muted);
  font-size: 11px;
}

.ws-status-indicator {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  background: var(--down);
  border: 1px solid var(--down-line);
  border-radius: 50%;
  box-shadow: 0 0 0 5px var(--down-soft), 0 0 18px rgba(255, 104, 119, 0.34);
}

.ws-status-indicator.connected {
  background: var(--up);
  border-color: var(--up-line);
  box-shadow: 0 0 0 5px var(--up-soft), 0 0 18px rgba(44, 207, 111, 0.3);
}

.ws-status-state {
  color: var(--down);
  font-size: 17px;
  font-weight: 840;
}

.ws-status-state.connected {
  color: var(--up);
}

.ws-status-details {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ws-status-details > div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid var(--line-soft);
}

.ws-status-details > div:last-child {
  border-bottom: 0;
}

.ws-status-details dt {
  color: var(--muted);
  font-size: 11px;
}

.ws-status-details dd {
  min-width: 0;
  margin: 0;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.ws-cache-maintenance {
  display: grid;
  gap: 6px;
  padding: 12px 13px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
}

.ws-cache-maintenance strong {
  color: var(--accent-strong);
  font-size: 12px;
}

.ws-cache-maintenance p {
  margin: 0;
  color: var(--text-2);
  font-size: 11px;
  line-height: 1.55;
}

.ws-cache-message {
  min-height: 0;
  color: var(--accent-strong);
  font-size: 11px;
}

.ws-cache-message:empty {
  display: none;
}

.ws-status-actions {
  display: grid;
  grid-template-columns: minmax(88px, 0.7fr) minmax(0, 1.3fr);
}

.cache-clear-btn {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.cache-clear-btn:hover {
  color: #071207;
  background: var(--accent);
  border-color: var(--accent-strong);
}

.modal-body {
  display: grid;
  flex: 1 1 auto;
  gap: 14px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.modal-preview {
  position: relative;
}

.modal-preview.is-loading {
  opacity: 0.55;
}

.modal-preview.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  animation: btn-spin 0.8s linear infinite;
}

.warning-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.warning-list li {
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  main {
    gap: 10px;
    padding: 12px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .account-grid {
    flex-basis: 100%;
  }

  .forecast-body {
    grid-template-columns: minmax(270px, 0.9fr) minmax(0, 1.6fr);
  }

  .forecast-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .forecast-metric:nth-child(4n) {
    border-right: 1px solid rgba(255, 218, 164, 0.1);
  }

  .forecast-metric:nth-child(3n) {
    border-right: 0;
  }

  .form-grid,
  .derived-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-fields-compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  section,
  details.collapsible-section {
    padding: 12px;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1 1 140px;
  }

  button,
  input,
  select {
    min-height: 44px;
  }
}

@media (max-width: 760px) {
  .close-summary {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .close-summary::-webkit-scrollbar {
    display: none;
  }

  .close-summary-item {
    flex: 0 0 96px;
    scroll-snap-align: start;
  }

  .close-summary-item.total {
    flex-basis: 116px;
  }

  .close-summary-item.ordinary {
    flex-basis: 100px;
  }

  .close-summary-operator {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    border: 0;
    background: transparent;
  }

  .close-summary-item {
    min-height: 52px;
    padding: 8px 9px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .confirm-backdrop {
    align-items: flex-end;
    padding: 12px;
  }

  .confirm-modal {
    width: 100%;
    border-radius: 22px;
  }

  .confirm-preview {
    margin: 0 12px 12px;
    padding: 10px;
  }

  .create-preview-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .create-preview-metric {
    min-height: 78px;
  }

  .seed-preview-row {
    grid-template-columns: 28px repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding-right: 6px;
    padding-left: 6px;
    font-size: 9px;
  }

  .confirm-hero {
    gap: 12px;
    padding: 16px 16px 12px;
  }

  .confirm-actions {
    display: grid;
    grid-template-columns: 1fr;
    padding: 0 16px 16px;
  }

  .confirm-actions button {
    width: 100%;
  }

  main {
    gap: 8px;
    padding: 8px max(8px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  section,
  details.collapsible-section {
    padding: 10px;
    border-radius: 18px;
  }

  h2 {
    font-size: 14px;
  }

  .account-card {
    gap: 8px 10px;
    padding: 12px;
    border-radius: 20px;
  }

  .forecast-section {
    padding: 11px 12px 10px;
    border-radius: 18px;
  }

  .forecast-heading {
    align-items: flex-start;
    margin-bottom: 9px;
  }

  .forecast-boundary {
    max-width: 42%;
    padding-top: 4px;
    overflow-wrap: anywhere;
    font-size: 9px;
    text-align: right;
  }

  .forecast-body {
    grid-template-columns: 1fr;
  }

  .forecast-critical {
    grid-template-columns: minmax(0, 1.45fr) minmax(90px, 0.65fr);
    border-right: 0;
    border-bottom: 1px solid rgba(255, 218, 164, 0.13);
  }

  .forecast-primary {
    padding: 12px 10px 11px 0;
  }

  .forecast-primary + .forecast-primary {
    padding-left: 12px;
  }

  .forecast-primary strong {
    font-size: 19px;
  }

  .forecast-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .forecast-metric,
  .forecast-metric:nth-child(3n) {
    padding: 9px 10px;
    border-right: 1px solid rgba(255, 218, 164, 0.1);
    border-bottom: 1px solid rgba(255, 218, 164, 0.1);
  }

  .forecast-metric:nth-child(2n) {
    border-right: 0;
  }

  .forecast-metric:last-child {
    grid-column: span 2;
    border-right: 0;
    border-bottom: 0;
  }

  .forecast-model {
    padding-top: 8px;
    font-size: 9px;
  }

  .account-head h2 {
    font-size: 14px;
  }

  .account-pill {
    max-width: 164px;
    min-height: 22px;
    padding: 0 9px;
    font-size: 10px;
  }

  .account-switcher {
    order: 2;
    margin-left: 0;
    margin-right: 18px;
    padding: 3px;
  }

  .account-switch-link {
    min-width: 52px;
    min-height: 25px;
    padding: 0 10px;
    font-size: 10px;
  }

  .account-grid {
    order: 3;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
  }

  .account-item {
    min-width: 0;
  }

  .account-fee-item,
  .account-risk-item {
    grid-column: span 2;
  }

  .account-item span {
    font-size: 10px;
  }

  .account-item strong {
    font-size: 12px;
  }

  .account-fee-breakdown,
  .account-risk-breakdown {
    font-size: 10px;
  }

  .section-icon {
    width: 28px;
    height: 28px;
    border-radius: 11px;
  }

  .metric {
    min-height: 50px;
    padding: 8px 9px;
  }

  .value {
    font-size: 15px;
  }

  .ladder-heading {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
    min-height: 24px;
    margin-bottom: 7px;
  }

  .ladder-title {
    gap: 5px;
    min-width: max-content;
  }

  .ladder-title h2 {
    font-size: 12px;
  }

  .ladder-sync {
    font-size: 9px;
  }

  .ladder-stats {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
  }

  .ladder-stat {
    flex: 0 0 auto;
    min-width: max-content;
    min-height: 23px;
    padding: 0 7px;
    gap: 4px;
    font-size: 9px;
  }

  .ladder-stat::before {
    width: 4px;
    height: 4px;
  }

  .ladder-stat strong {
    font-size: 11px;
  }

  .ladder-current {
    min-height: 31px;
    gap: 3px;
    padding: 0 8px;
  }

  .ladder-current-label {
    font-size: 9px;
  }

  .ladder-current strong {
    font-size: 12px;
  }

  .ladder-current-qty {
    font-size: 8px;
  }

  .close-summary {
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 6px;
    padding: 5px;
  }

  .close-summary-item {
    grid-column: span 3;
    min-height: 46px;
    padding: 7px 8px;
    gap: 4px;
    border-radius: 12px;
  }

  .close-summary-item.total {
    grid-column: span 10;
    min-height: 54px;
  }

  .close-summary-item.seed,
  .close-summary-item.ordinary,
  .close-summary-item.bad-debts {
    grid-column: span 5;
  }

  .close-summary-item.ordinary {
    grid-column: span 10;
  }

  .close-summary-item span,
  .close-summary-drift {
    font-size: 10px;
  }

  .close-summary-values {
    align-items: end;
    gap: 4px;
  }

  .close-summary-values strong {
    font-size: 13px;
  }

  .close-summary-unit {
    margin-left: 1px;
    font-size: 0.56em;
  }

  .close-summary-values em {
    font-size: 10px;
  }

  .close-summary-item.total strong {
    font-size: 14px;
  }

  .ladder-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 15px;
  }

  .ladder-rows {
    --ladder-row-size: 31px;
  }

  .ladder-row {
    grid-template-columns: 18px minmax(0, 1fr) auto;
    gap: 5px;
    min-height: 31px;
    padding: 0 7px;
  }

  .order-kind {
    width: 17px;
    height: 17px;
    font-size: 10px;
  }

  .ladder-price {
    font-size: 13px;
  }

  .ladder-qty {
    font-size: 11px;
  }

  .grid-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .grid-card {
    gap: 8px;
    padding: 11px;
    border-radius: 18px;
  }

  .grid-card-head {
    gap: 5px;
  }

  .grid-title-row {
    gap: 5px 8px;
  }

  .grid-title {
    padding: 5px 10px;
    font-size: 12px;
  }

  .grid-subtitle {
    padding-left: 2px;
    font-size: 11px;
  }

  .grid-highlight {
    padding: 7px 8px;
    border-radius: 12px;
  }

  .grid-highlight-value {
    margin-top: 3px;
    font-size: 12px;
  }

  .grid-detail-block {
    gap: 6px;
  }

  .grid-detail-block + .grid-detail-block {
    padding-top: 8px;
  }

  .grid-detail-title {
    font-size: 10px;
  }

  .grid-card-actions {
    gap: 6px;
  }

  .grid-card-actions button {
    flex: 1 1 96px;
    min-height: 40px;
    padding: 0 10px;
    font-size: 12px;
  }

  .summary-action {
    min-height: 34px;
  }

  .form-grid,
  .derived-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-fields,
  .grid-fields-compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 8px;
  }

  .grid-field {
    align-items: flex-start;
    flex-direction: column;
    gap: 1px;
  }

  .grid-field-key {
    font-size: 10px;
    line-height: 1.15;
    white-space: normal;
  }

  .grid-field-key::after {
    display: none;
  }

  .grid-field strong {
    font-size: 11px;
    line-height: 1.2;
  }

  .grid-fields-position {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px 7px;
  }

  .grid-fields-position .grid-field-key {
    font-size: 10px;
  }

  .grid-fields-position .grid-field strong {
    font-size: 10px;
  }

  .grid-meta-footer {
    align-items: center;
    gap: 6px 8px;
    font-size: 10px;
  }

  .grid-updated strong {
    font-size: 10px;
  }

  .window-summary {
    gap: 4px;
  }

  .window-detail {
    padding: 7px 8px;
    font-size: 11px;
  }

  .section-heading {
    margin-bottom: 8px;
  }

  .icon-btn {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    border-radius: 13px;
  }

  input,
  select {
    font-size: 16px;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: calc(100% - 24px);
    max-height: 92vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  .modal-preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    margin-right: -10px;
    margin-left: -10px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .trade-wrap {
    height: 242px;
    max-height: 242px;
  }

  .trade-table {
    min-width: 560px;
  }

  th,
  td {
    padding: 7px 5px;
  }

  .trade-table th {
    height: 32px;
  }

  .trade-table td {
    height: 42px;
  }

  .trade-stats-sheet {
    width: 100%;
    max-height: calc(100vh - 18px);
    max-height: calc(100dvh - 18px);
    border-right: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
  }

  .trade-stats-modal-head {
    padding: 9px 14px 12px;
  }

  .trade-stats-sheet-body {
    padding: 12px 12px max(16px, env(safe-area-inset-bottom));
  }

  .trade-stats-chart-wrap {
    width: calc(100% + 20px);
    height: 280px;
    min-height: 240px;
    margin-right: -10px;
    margin-left: -10px;
  }

  .trade-stats-metric {
    padding: 8px;
  }

  .trade-stats-metric strong {
    font-size: 17px;
  }

  .trade-stats-legend {
    justify-content: flex-start;
  }
}

@media (max-width: 360px) {
  .form-grid,
  .derived-grid,
  .grid-highlights {
    grid-template-columns: 1fr;
  }

  .grid-fields,
  .grid-fields-compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .close-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .close-summary-item,
  .close-summary-item.total,
  .close-summary-item.seed {
    grid-column: auto;
  }

  .close-summary-item.total {
    grid-column: span 2;
  }
}
