:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --ink: #111113;
  --muted: #8e8e93;
  --green: #18c261;
  --green-soft: #e8f8ee;
  --red: #ff3b30;
  --red-soft: #fdecea;
  --shadow: 0 8px 28px rgba(16,16,20,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; }
#app { max-width: 430px; margin: 0 auto; padding: 10px 16px 18px; min-height: 100vh; }
.hidden { display: none !important; }
.stale { background: #fff3cd; color: #6b4e00; padding: 8px 12px; border-radius: 12px; font-size: 12px; margin-bottom: 10px; }

.top { display: flex; align-items: center; gap: 10px; }
.app-icon { width: 44px; height: 44px; border-radius: 12px; flex: none; background: #161618; }
.titles { flex: 1; min-width: 0; }
h1 { margin: 0; font-size: 24px; letter-spacing: -0.5px; font-weight: 800; line-height: 1.05; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.online-pill { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 999px;
  padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--green); box-shadow: var(--shadow); }
.online-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 3px rgba(24,194,97,.18); }
.online-pill.offline { color: var(--muted); }
.online-pill.offline .dot { background: #c7c7cc; box-shadow: none; }

.sim-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.sim-badge { background: #111; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .4px;
  padding: 3px 6px; border-radius: 6px; }
.sim-copy { color: var(--muted); font-size: 13.5px; font-weight: 500; flex: 1; }
.mult-pill { margin-left: auto; border-radius: 999px; padding: 5px 11px; font-weight: 700; font-size: 14px; color: #fff;
  background: var(--green); }
.mult-pill.down { background: var(--red); }

.equity-block { margin-top: 6px; }
.equity { font-weight: 800; letter-spacing: -2px; line-height: 1; color: var(--ink); display: flex; align-items: baseline; }
.eq-main { font-size: 56px; }
.eq-frac { font-size: 28px; color: #c4c4c8; letter-spacing: -1px; font-weight: 700; }
.pnl-row { display: flex; align-items: flex-start; justify-content: space-between; margin-top: 4px; }
.pnl { font-size: 18px; font-weight: 700; }
.pnl.up { color: var(--green); }
.pnl.down { color: var(--red); }
.chart-wrap { position: relative; margin: 2px -4px 4px; height: 68px; }
.chart-caption { position: absolute; right: 8px; top: 0; color: var(--muted); font-size: 12px; }
#chart { width: 100%; height: 64px; display: block; overflow: visible; }
#chart .line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.crew-card { overflow: hidden; }
.card { background: var(--card); border-radius: 24px; box-shadow: var(--shadow); padding: 12px 14px 10px; margin-top: 10px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.6px; }
.muted { color: var(--muted); font-size: 13px; font-weight: 500; text-align: right; }

.crew-speech { display: flex; justify-content: flex-end; min-height: 0; padding: 0 4px 2px; }
.crew-speech .speech { position: relative; left: auto; right: auto; bottom: auto; transform: none;
  max-width: 90%; white-space: normal; text-align: left; }
.crew-speech .speech::after { left: auto; right: 18px; }
.bots-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 4px; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.bots-scroll::-webkit-scrollbar { display: none; }
.bot-col { flex: 0 0 58px; width: 58px; scroll-snap-align: start; text-align: center; position: relative; }
.speech { position: absolute; left: 50%; bottom: 108px; transform: translateX(-50%);
  background: #1c1c1e; color: #fff; font-size: 11px; font-weight: 600; line-height: 1.25;
  padding: 8px 10px; border-radius: 14px; white-space: nowrap; max-width: 240px;
  overflow: hidden; text-overflow: ellipsis; z-index: 2; box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.speech::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px;
  background: #1c1c1e; transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.bot-col:last-child .speech { left: auto; right: 0; transform: none; }
.bot { width: 58px; height: 64px; position: relative; margin: 0 auto; }
.bot-antenna { position: absolute; left: 50%; top: 0; width: 3px; height: 12px; background: var(--c); transform: translateX(-50%);
  border-radius: 2px; z-index: 1; }
.bot-antenna span { position: absolute; left: 50%; top: -5px; width: 9px; height: 9px; background: var(--c);
  border-radius: 50%; transform: translateX(-50%); }
.bot-body { position: absolute; left: 6px; top: 11px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--c); box-shadow: 0 8px 14px rgba(16,16,20,.16); }
.bot-arm { position: absolute; top: 27px; width: 12px; height: 12px; border-radius: 50%; background: var(--c);
  box-shadow: 0 4px 8px rgba(16,16,20,.12); z-index: 0; }
.bot-arm.left { left: 0px; }
.bot-arm.right { right: 0px; }
.bot-face { position: absolute; left: 6px; top: 8px; width: 34px; height: 30px; background: #1a1b22;
  border-radius: 16px; }
.eye { position: absolute; top: 7px; width: 7px; height: 11px; background: #fff; border-radius: 4px; }
.eye.l { left: 7px; }
.eye.r { right: 7px; }
.bot-col.active .bot { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.bot-name { margin-top: 6px; font-size: 11px; font-weight: 700; }
.bot-hold { color: var(--muted); font-size: 11px; margin-top: 1px; }
.status-pill { display: inline-block; margin-top: 4px; background: #f1f1f4; color: #6e6e73; font-size: 10.5px;
  font-weight: 600; padding: 3px 8px; border-radius: 999px; text-transform: lowercase; }
.status-pill.on { background: #e8f8ee; color: #128a45; }

.trade { display: flex; align-items: center; gap: 10px; border-radius: 16px; padding: 8px 8px; margin: 4px 0 0;
  cursor: pointer; border: 0; width: 100%; text-align: left; font: inherit; }
.trade.up { background: var(--green-soft); }
.trade.down { background: var(--red-soft); }
.trade.flat { background: #f4f4f6; }
.tok { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 800; font-size: 12px; flex: none; }
.trade-main { flex: 1; min-width: 0; }
.trade-sym { font-weight: 800; font-size: 16px; }
.trade-sub { color: var(--muted); font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade-right { text-align: right; }
.trade-pnl { font-weight: 800; font-size: 16px; }
.trade.up .trade-pnl { color: var(--green); }
.trade.down .trade-pnl { color: var(--red); }
.trade-state { font-size: 11px; color: var(--muted); }

.goal-track-wrap { position: relative; padding: 8px 4px 4px; }
.goal-now { display: inline-block; background: #111; color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 8px; margin-bottom: 8px; }
.goal-now.down { background: var(--red); }
.goal-track { position: relative; height: 54px; }
.goal-line { position: absolute; left: 8px; right: 8px; top: 10px; height: 6px; background: #ececf0; border-radius: 99px; overflow: hidden; }
.goal-fill { height: 100%; background: var(--green); border-radius: 99px; width: 0; }
.goal-fill.down { background: var(--red); }
.goal-marks { position: absolute; left: 8px; right: 8px; top: 3px; }
.mark { position: absolute; transform: translateX(-50%); text-align: center; }
.mark i { display: block; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid #d8d8de;
  margin: 0 auto 4px; box-sizing: border-box; }
.mark.done i { border-color: var(--green); background: var(--green); }
.mark.goal i { border-color: #2f7bff; background: #fff; width: 20px; height: 20px; margin-top: -2px; }
.mark .lbl { font-size: 9px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.mark.goal .lbl { color: #2f7bff; }

.disclaimer { text-align: center; color: var(--muted); font-size: 10px; margin: 10px 8px 0; }

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 24px 24px 0 0;
  padding: 10px 18px 28px; max-height: 86vh; overflow: auto; }
.sheet-handle { width: 36px; height: 5px; border-radius: 99px; background: #ddd; margin: 4px auto 12px; }
.sheet-panel h3 { margin: 0 0 8px; font-size: 22px; }
.sheet-panel dl { margin: 0; display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 13.5px; }
.sheet-panel dt { color: var(--muted); }
.sheet-panel dd { margin: 0; word-break: break-all; }
.sheet-panel a { color: #0b62d6; }
.hist { margin-top: 12px; font-size: 13px; }
.hist li { margin: 0 0 8px; }
.sheet-close { display: block; width: 100%; margin-top: 16px; background: #111; color: #fff; border: 0;
  border-radius: 14px; padding: 12px; font: inherit; font-weight: 700; }

.login { max-width: 430px; margin: 0 auto; min-height: 100vh; padding: 72px 24px 36px;
  display: flex; flex-direction: column; align-items: flex-start; }
.login h1 { margin: 12px 0 0; }
.login .sub { margin: 4px 0 24px; }
.login form { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #6e6e73; }
.login input { font: inherit; color: var(--ink); font-weight: 500; font-size: 16px; padding: 12px 14px;
  border-radius: 14px; border: 1px solid #e6e6ea; background: #fff; }
.login button[type=submit] { margin-top: 8px; background: #111; color: #fff; border: 0;
  border-radius: 14px; padding: 14px; font: inherit; font-weight: 700; width: 100%; }
.login-error { color: var(--red); font-size: 13px; font-weight: 600; margin: 0; }
