:root {
  color-scheme: dark;
  --bg: #070b10;
  --surface: #0f1720;
  --surface-2: #141e29;
  --surface-3: #192534;
  --stroke: #243241;
  --text: #edf3f8;
  --muted: #8b9bad;
  --green: #25c38b;
  --red: #ef5d68;
  --amber: #f3b546;
  --blue: #6ea8fe;
  --radius: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

body {
  padding: env(safe-area-inset-top) 0 calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(7, 11, 16, 0.96);
}

.brand {
  font-size: 16px;
  font-weight: 800;
}

.muted,
.meta {
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.badge.live,
.positive,
.active {
  color: var(--green);
}

.badge.pause,
.warning {
  color: var(--amber);
}

.badge.danger,
.negative,
.safety {
  color: var(--red);
}

.badge.neutral {
  color: var(--muted);
}

.icon-button,
.command,
.tab,
select,
input {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.icon-button {
  width: 36px;
  height: 36px;
  font-size: 22px;
  line-height: 1;
}

.page {
  padding: 12px;
  min-height: calc(100vh - 142px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.notice {
  padding: 11px;
  margin-bottom: 10px;
  border-radius: var(--radius);
}

.notice.error {
  border: 1px solid #69343b;
  background: #21161b;
  color: #ffb4bd;
}

.notice.success {
  border: 1px solid #175c47;
  background: #10231e;
  color: #7be4ba;
}

.hidden {
  display: none;
}

.summary,
.card {
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-title,
.card-row,
.signal-row,
.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pending-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.balance {
  margin-top: 10px;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
}

.section-title {
  margin: 16px 2px 9px;
  color: #cbd6df;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics,
.levels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.metric,
.levels span {
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.metric strong,
.levels strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

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

.scan-grid {
  grid-template-columns: 1fr 1fr;
}

.scan-grid button {
  grid-column: 1 / -1;
}

.command,
select,
input {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

.small-command {
  min-height: 28px;
  padding: 5px 8px;
  font-size: 12px;
}

.command:disabled,
input:disabled {
  opacity: 0.42;
}

.risk-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.risk-grid button {
  align-self: end;
}

.leverage-grid {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.leverage-row {
  display: grid;
  grid-template-columns: 1fr 96px 18px;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.leverage-row input {
  width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.full-width {
  width: 100%;
}

.positive-button {
  border-color: #167354;
  color: #7be4ba;
}

.warning-button {
  border-color: #866225;
  color: #ffd27c;
}

.danger-outline {
  border-color: #73333c;
  color: #ffb2ba;
}

.danger-button {
  border-color: #8e3844;
  background: #301a20;
  color: #ffb2ba;
}

.strategy-row,
.signal-row,
.history-row,
.result-row,
.health-row {
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: 6px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
  border-radius: 0;
  border-width: 0 0 1px;
  background: transparent;
}

.result-card {
  padding-bottom: 10px;
}

.result-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--stroke);
  font-weight: 800;
}

.result-card-head strong,
.result-grid strong,
.result-row strong {
  font-variant-numeric: tabular-nums;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  padding-top: 12px;
}

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

.result-grid strong {
  display: block;
  padding-top: 3px;
  color: var(--text);
  font-size: 15px;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
}

.history-row:first-child {
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.history-result {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.history-result span,
.history-result strong {
  display: block;
}

.empty-state {
  min-height: 60px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.strategy-row {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: center;
  gap: 8px;
}

.strategy-row input {
  width: 18px;
  height: 18px;
}

.symbol {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.signal-status {
  font-weight: 800;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  border-top: 1px solid var(--stroke);
  background: rgba(7, 11, 16, 0.99);
}

.tab {
  position: relative;
  min-height: 58px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tab::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
}

.tab.active {
  background: rgba(10, 19, 28, 0.96);
  color: var(--blue);
}

.tab.active::before {
  background: #2d9cff;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
}

.modal.hidden {
  display: none;
}

.modal-sheet {
  width: min(420px, 100%);
  padding: 16px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--surface);
}

.modal-sheet h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (min-width: 820px) {
  .page {
    max-width: 980px;
    margin: 0 auto;
  }

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