:root {
  color-scheme: dark;
  --bg: #0d1115;
  --panel: #151b22;
  --panel-2: #111820;
  --text: #edf2f7;
  --muted: #8fa0af;
  --line: #26323e;
  --accent: #45d6c5;
  --accent-2: #6ba6ff;
  --warning: #f0b35a;
  --danger: #ef6678;
  --success: #58d68d;
  --shadow: rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
select {
  font: inherit;
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding-top: 0;
}

.global-exposure {
  min-width: 0;
  flex: 1 1 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0b1016;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.global-exposure.positive {
  border-color: rgba(88, 214, 141, 0.38);
  background: rgba(88, 214, 141, 0.08);
}

.global-exposure.negative {
  border-color: rgba(239, 102, 120, 0.38);
  background: rgba(239, 102, 120, 0.08);
}

.refresh-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  justify-content: flex-end;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.ok {
  background: var(--success);
}

.dot.error {
  background: var(--danger);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
}

.text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1016;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
  white-space: nowrap;
}

.text-button:hover {
  border-color: var(--accent);
}

.account-switcher {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.account-select-group {
  display: grid;
  gap: 8px;
  width: 100%;
}

.account-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.account-title {
  color: var(--muted);
  font-size: 12px;
}

.wallet-address {
  max-width: 190px;
  min-width: 0;
  border: 1px solid rgba(69, 214, 197, 0.28);
  border-radius: 999px;
  background: rgba(69, 214, 197, 0.08);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  padding: 6px 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-address:hover,
.wallet-address:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.wallet-address.copied {
  border-color: rgba(88, 214, 141, 0.42);
  background: rgba(88, 214, 141, 0.1);
  color: var(--success);
}

.wallet-address.failed {
  border-color: rgba(239, 102, 120, 0.42);
  background: rgba(239, 102, 120, 0.1);
  color: var(--danger);
}

.account-picker {
  position: relative;
  width: 100%;
}

.account-select-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 12px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1016;
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  text-align: left;
}

.account-select-button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(69, 214, 197, 0.35);
}

.account-select-name {
  min-width: 0;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-select-pnl {
  min-width: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.account-select-chevron {
  position: relative;
  width: 12px;
  height: 12px;
}

.account-select-chevron::before {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg);
  transform-origin: center;
}

.account-picker.open .account-select-chevron::before {
  top: 5px;
  transform: rotate(225deg);
}

.account-options {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1016;
  box-shadow: 0 18px 38px var(--shadow);
  padding: 6px;
}

.account-options[hidden] {
  display: none;
}

.account-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
}

.account-option:hover,
.account-option:focus-visible,
.account-option.selected {
  border-color: rgba(69, 214, 197, 0.36);
  background: rgba(69, 214, 197, 0.08);
  outline: none;
}

.account-option-name {
  min-width: 0;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-option-pnl {
  min-width: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.account-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.account-meta {
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  overflow-wrap: anywhere;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0b1016;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 7px 10px;
  white-space: nowrap;
}

.status-pill.positive {
  border-color: rgba(88, 214, 141, 0.44);
  color: var(--success);
}

.status-pill.negative {
  border-color: rgba(239, 102, 120, 0.44);
  color: var(--danger);
}

.status-pill.warning {
  border-color: rgba(240, 179, 90, 0.5);
  color: var(--warning);
}

.legacy-summary {
  display: none;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px var(--shadow);
}

.soft-label {
  color: var(--muted);
  font-size: 12px;
}

.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

.warning-text {
  color: var(--warning);
}

.neutral {
  color: var(--text);
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.panel {
  min-height: 220px;
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.positions-summary {
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: right;
}

.positions-summary strong {
  min-width: 0;
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.position-list {
  display: grid;
  gap: 10px;
}

.position-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10171e;
  padding: 12px;
}

.position-card-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.position-market {
  min-width: 0;
  font-size: 15px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.position-side {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 7px 9px;
}

.position-side.long {
  border-color: rgba(88, 214, 141, 0.42);
  color: var(--success);
}

.position-side.short {
  border-color: rgba(239, 102, 120, 0.42);
  color: var(--danger);
}

.position-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 0;
}

.position-stat {
  display: grid;
  grid-template-columns: minmax(0, 82px) minmax(0, 1fr);
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.position-stat span {
  color: var(--muted);
  font-size: 12px;
}

.position-stat strong {
  min-width: 0;
  font-size: 13px;
  line-height: 1.2;
  text-align: right;
  justify-self: end;
  overflow-wrap: anywhere;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 24px 12px;
}

.history-panel {
  min-height: 0;
}

.history-header > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  background: #10171e;
  padding: 10px;
}

.history-item.success {
  border-left-color: var(--success);
}

.history-item.failed {
  border-left-color: var(--danger);
}

.history-item.warn {
  border-left-color: var(--warning);
}

.history-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.history-title strong,
.history-title span {
  min-width: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.history-title strong {
  color: var(--text);
}

.history-title span {
  flex: 0 1 auto;
  font-weight: 800;
  text-align: right;
}

.history-meta,
.history-details {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.threshold-list {
  display: grid;
  gap: 8px;
}

.threshold {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #10171e;
}

.threshold.active {
  border-color: var(--accent-2);
}

.threshold strong {
  font-size: 13px;
}

.threshold span {
  color: var(--muted);
  font-size: 12px;
}

.threshold code {
  color: var(--text);
  font-size: 12px;
}

@media (min-width: 760px) {
  .shell {
    width: min(1180px, 100%);
    padding: 20px;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

  .top-actions {
    justify-content: flex-end;
    width: min(620px, 100%);
    padding-top: 0;
  }

  .global-exposure {
    font-size: 13px;
  }

  h1 {
    font-size: 30px;
  }

  .account-switcher {
    align-items: flex-end;
    flex-direction: row;
    margin: 18px 0;
  }

  .account-select-group {
    width: min(360px, 100%);
  }

  .account-meta {
    text-align: right;
  }

  .account-status-row {
    justify-content: flex-end;
  }

  .content-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.9fr);
  }

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

  .position-stat {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .position-stat strong {
    text-align: left;
    justify-self: start;
  }
}

@media (min-width: 940px) {
  .content-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
  }
}
