:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #fbfdf9;
  --panel-strong: #ffffff;
  --text: #111714;
  --muted: #67726c;
  --line: #d8dfda;
  --positive: #087a5a;
  --positive-soft: #dff5ea;
  --negative: #b93f47;
  --negative-soft: #f7dde0;
  --amber: #8b6500;
  --amber-soft: #f3e7b5;
  --ink-soft: #e8eee9;
  --shadow: 0 16px 40px rgba(17, 23, 20, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(88px + env(safe-area-inset-bottom));
}

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

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.ghost-button,
.secondary-button,
.danger-button,
.action-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease;
}

.ghost-button {
  padding: 0 13px;
  background: var(--panel);
  color: var(--text);
}

.secondary-button {
  padding: 0 16px;
  background: var(--panel-strong);
  color: var(--text);
}

.danger-button {
  padding: 0 16px;
  border-color: transparent;
  background: var(--negative);
  color: #fff;
}

.ghost-button:active,
.secondary-button:active,
.danger-button:active,
.action-button:active,
.tab:active {
  transform: scale(0.98);
}

.content {
  display: block;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.metric {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.notice-card {
  grid-column: 1 / -1;
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.notice-title {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 780;
}

.notice-action {
  margin-top: 14px;
}

.metric-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  font-size: 24px;
  font-weight: 760;
  line-height: 1.08;
}

.metric-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0 10px;
}

.section-head span {
  min-width: 34px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.position-list,
.event-list,
.strategy-list,
.settings-panel {
  display: grid;
  gap: 7px;
}

.list-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: -2px 0 9px;
}

.list-toolbar label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.list-toolbar select {
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 820;
  padding: 0 10px;
}

.position-item,
.position-card,
.strategy-card,
.event-row,
.empty-state,
.settings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.position-card {
  padding: 14px;
}

.position-item {
  overflow: hidden;
}

.position-row {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(84px, auto) minmax(20px, auto) auto 18px;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.position-row:active {
  background: #f0f5ef;
}

.row-index {
  width: 23px;
  height: 23px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.row-token,
.row-performance {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.row-symbol {
  font-size: 14px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-name,
.row-multiple {
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-performance {
  justify-items: end;
}

.row-pnl {
  max-width: 98px;
  font-size: 11px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recovery-status {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 820;
  white-space: nowrap;
}

.recovery-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 999px;
  background: var(--negative);
  box-shadow: 0 0 0 3px var(--negative-soft);
}

.recovery-status.recovered .recovery-dot {
  background: var(--positive);
  box-shadow: 0 0 0 3px var(--positive-soft);
}

.row-status {
  min-height: 21px;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--ink-soft);
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  text-transform: uppercase;
}

.row-status.open {
  background: var(--positive-soft);
  color: var(--positive);
}

.row-chevron {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.position-detail {
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.position-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.position-detail .position-head {
  margin-top: 12px;
}

.token-title {
  min-width: 0;
}

.token-symbol {
  margin-bottom: 3px;
  font-size: 18px;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.token-name {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.chip {
  flex: none;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.chip.open,
.chip.paper {
  background: var(--positive-soft);
  color: var(--positive);
}

.chip.closed {
  background: var(--ink-soft);
  color: var(--muted);
}

.chip.loss {
  background: var(--negative-soft);
  color: var(--negative);
}

.position-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.stat {
  min-height: 62px;
  padding: 10px;
  border-radius: 8px;
  background: #f0f5ef;
}

.stat.compact {
  min-height: 58px;
  padding: 9px;
}

.stat-label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-value {
  font-size: 15px;
  font-weight: 780;
  overflow-wrap: anywhere;
}

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

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

.position-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.trade-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.market-button {
  width: 100%;
  font-weight: 850;
}

.input-action,
.target-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.target-inputs {
  grid-template-columns: minmax(0, 1fr) auto;
}

.input-action label,
.target-inputs label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.input-action input,
.target-inputs input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 780;
  padding: 0 10px;
}

.target-panel {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.target-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.target-orders {
  display: grid;
  gap: 7px;
}

.target-order {
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  background: #f0f5ef;
  font-size: 13px;
  font-weight: 760;
}

.target-order span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-empty {
  color: var(--muted);
  font-size: 12px;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 820;
}

.chart-link {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  margin-top: 10px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 820;
  text-decoration: none;
}

.action-button {
  min-width: 0;
  padding: 0 8px;
  background: #111714;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.action-button.hold {
  background: var(--amber-soft);
  color: var(--amber);
}

.event-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  padding: 9px 10px;
}

.event-title {
  font-size: 13px;
  font-weight: 780;
}

.event-note,
.event-time {
  color: var(--muted);
  font-size: 11px;
}

.strategy-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.strategy-card.disabled {
  opacity: 0.68;
}

.strategy-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.strategy-name {
  font-size: 17px;
  font-weight: 860;
}

.strategy-range {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.strategy-toggle {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.strategy-toggle.active {
  border-color: transparent;
  background: var(--positive);
  color: #fff;
}

.strategy-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.strategy-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.strategy-foot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.settings-panel {
  padding: 14px;
}

.settings-label {
  margin-bottom: 5px;
  font-size: 15px;
  font-weight: 820;
}

.settings-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.language-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.language-option {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 820;
}

.language-option.active {
  border-color: #111714;
  background: #111714;
  color: #fff;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(720px, 100%);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(216, 223, 218, 0.9);
  background: rgba(245, 247, 244, 0.92);
  backdrop-filter: blur(14px);
}

.tab {
  min-width: 0;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.tab.active {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(35, 26, 12, 0.08);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(18, 15, 11, 0.38);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 24px 80px rgba(14, 10, 4, 0.22);
}

.modal p {
  color: var(--muted);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 430px) {
  .position-row {
    grid-template-columns: 25px minmax(0, 1fr) minmax(78px, auto) 16px 16px;
    gap: 6px;
    padding: 7px 8px;
  }

  .recovery-status span:last-child,
  .row-status {
    display: none;
  }

  .row-pnl {
    max-width: 82px;
  }

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

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

  .strategy-foot {
    grid-template-columns: 1fr;
  }

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

  .action-button {
    min-height: 44px;
  }

  .input-action,
  .target-inputs {
    grid-template-columns: 1fr;
  }

  .target-inputs .action-button,
  .input-action .action-button {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
