:root {
  --bg: #11151c; --panel: #171c25; --line: #2a3140; --text: #d8dee9; --dim: #7d889b;
  --up: #26a69a; --down: #ef5350; --hold: #5e81ac; --step: #3b4a63; --auto: #6d5a80; --close: #ebcb8b;
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-t: var(--tg-content-safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 15px/1.25 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; user-select: none;
  -webkit-user-select: none; }
.dim { color: var(--dim); }
.small { font-size: 12.5px; }

#app { display: flex; flex-direction: column; height: var(--tg-viewport-height, 100dvh);
  padding: calc(6px + var(--safe-t)) 10px calc(8px + var(--safe-b)); gap: 6px; }

#top { display: flex; align-items: center; gap: 8px; }
.eqbox { flex: 1; min-width: 0; }
#eq { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
#ret { font-variant-numeric: tabular-nums; }
#stats { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: var(--panel); border-radius: 10px; width: 42px; height: 42px; display: grid; place-items: center;
  font-size: 22px; flex: none; }

#tf { display: flex; align-items: center; gap: 4px; }
#tf button { flex: 1; max-width: 64px; height: 34px; border-radius: 8px; background: var(--panel); color: var(--dim);
  font-weight: 600; }
#tf button.on { background: #2b3445; color: var(--text); box-shadow: inset 0 0 0 1px #4c566a; }
#vn { margin-left: auto; white-space: nowrap; }

#chartWrap { position: relative; flex: 1; min-height: 120px; border-radius: 10px; overflow: hidden; background: var(--bg);
  touch-action: none; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#loading { position: absolute; left: 10px; top: 8px; color: var(--dim); display: none; }
#loading.on { display: block; }

#status { min-height: 44px; text-align: center; }
#st1 { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; min-height: 24px; }
#st2 { min-height: 16px; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--close); }

#controls { flex: none; }
.panel { display: flex; flex-direction: column; gap: 8px; }
[hidden] { display: none !important; }
.sizes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.sizes button { height: 40px; border-radius: 8px; background: var(--panel); color: var(--dim); font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1.05; }
.sizes button small { display: block; font-size: 10.5px; font-weight: 500; }
.sizes button.on { background: #2b3445; color: var(--text); box-shadow: inset 0 0 0 1px #81a1c1; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.act { height: 58px; border-radius: 12px; font-weight: 800; font-size: 16px; letter-spacing: .3px; color: #0d1117;
  line-height: 1.1; }
.act:active { filter: brightness(1.18); transform: scale(.98); }
.act.buy { background: var(--up); } .act.sell { background: var(--down); } .act.hold { background: var(--hold); color: #eef2f8; }
.act.step { background: var(--step); color: var(--text); font-size: 15px; }
.act.auto { background: var(--auto); color: #f2eaf7; font-size: 15px; }
.act.auto.on { background: #b48ead; color: #1a1020; }
.act.close { background: var(--close); }
.act.next { background: #81a1c1; }
.act.danger { background: transparent; color: var(--down); box-shadow: inset 0 0 0 1.5px var(--down); height: 48px; }
.wide { width: 100%; }
.act:disabled { opacity: .45; }

#settings { position: fixed; inset: 0; background: rgba(8, 10, 14, .72); display: flex; align-items: flex-end; z-index: 5; }
#settings[hidden] { display: none; }
.sheet { width: 100%; background: var(--panel); border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + var(--safe-b)); max-height: 92%; overflow: auto; }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .icon { background: #232a36; width: 44px; height: 44px; }
#ml { width: 72px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  text-align: center; font: inherit; font-size: 18px; font-weight: 700; }
.check { justify-content: flex-start; }
.check input { width: 26px; height: 26px; accent-color: #81a1c1; flex: none; }
.sheet p { margin: 6px 0 4px; }
.sheet .act { margin-top: 14px; }
