/* Shrimp's Manager app. Colours are the TP SL BE panel theme (T_* in the EA). */
:root {
  --bg: #0D0F12;          /* T_BG */
  --bg-2: #090B0E;        /* T_EDIT_BG */
  --card: #14171C;        /* T_CARD */
  --card-2: #1A1E25;      /* T_TAB_ON */
  --border: #262A32;      /* T_CARD_BORDER */
  --line: #23272F;        /* T_LINE */
  --btn: #1C2028;         /* T_BTN */
  --btn-border: #323844;  /* T_BTN_BORDER */
  --fg: #ECEDEF;          /* T_FG */
  --muted: #8B919C;       /* T_MUTED */
  --muted-fg: #B5BAC3;    /* T_MUTED_FG */
  --gold: #E2B23C;        /* T_ACCENT */
  --gold-2: #F2C94C;      /* T_ACCENT_TXT */
  --good: #3FB950;        /* T_GOOD */
  --bad: #F0716B;         /* T_BAD */
  --amber: #E6A028;       /* T_AMBER */
  --danger: #B3261E;      /* T_DANGER */
  --danger-2: #D9443A;    /* T_DANGER_BRD */
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font: 15px/1.4 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* ---------- auth ---------- */
/* Sign-in backdrop: Higgsfield "gold light on black" (style A). The plain colour paints
   first, so the page never waits for the image. */
.auth { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: calc(32px + var(--safe-t)) 24px calc(32px + var(--safe-b));
  background: var(--bg) url(img/signin-tall.jpg) center bottom / cover no-repeat; }
@media (min-aspect-ratio: 3/4) { .auth { background-image: url(img/signin-wide.jpg); } }
/* The Higgsfield loop sits on top of the still image and fades in once it can play. */
.auth { position: relative; overflow: hidden; }
.auth > :not(.auth-video) { position: relative; z-index: 1; }
.auth-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center bottom;
  opacity: 0; transition: opacity 1.6s ease; pointer-events: none; }
.auth-video.on { opacity: 1; }
.auth-hero, .auth-form { animation: rise .9s cubic-bezier(.2,.7,.2,1) both; }
.auth-form { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) { .auth-hero, .auth-form { animation: none; } }
.auth-hero { text-align: center; margin-bottom: 28px; }
.auth-form { background: rgba(13,15,18,.62); border: 1px solid rgba(226,178,60,.22); border-radius: 20px; padding: 22px 18px;
  backdrop-filter: blur(14px) saturate(120%); -webkit-backdrop-filter: blur(14px) saturate(120%); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.auth-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 10px 40px rgba(226,178,60,.18); }
.auth-hero h1 { font-size: 26px; margin: 16px 0 4px; letter-spacing: -0.02em; }
.auth-form { width: 100%; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--muted-fg); }
.field input, .row-input input, .big-input {
  width: 100%; padding: 14px 14px; border-radius: 12px; border: 1px solid var(--btn-border); background: var(--bg-2); outline: none;
  transition: border-color .15s, box-shadow .15s; }
.field input:focus, .row-input input:focus, .big-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226,178,60,.18); }
.form-err { color: var(--bad); font-size: 14px; min-height: 1.2em; margin: 0; }

/* ---------- buttons ---------- */
.btn { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--btn-border); background: var(--btn); font-weight: 600; font-size: 14px;
  transition: transform .08s, background .15s, border-color .15s; }
.btn:active, .act:active { transform: scale(.97); }
.btn.gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #15120A; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.danger-o { border-color: rgba(217,68,58,.6); color: var(--bad); }
.btn:disabled { opacity: .5; }

/* ---------- layout ---------- */
#main { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(13,15,18,.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.acct-switch { display: flex; flex-direction: column; align-items: flex-start; background: none; border: 0; padding: 4px 0; min-width: 0; }
.acct-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.acct-name::after { content: " ▾"; color: var(--muted); font-size: 12px; }
.acct-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: 12px; white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on i { background: var(--good); box-shadow: 0 0 0 0 rgba(63,185,80,.6); animation: pulse 2s infinite; }
.pill.off i { background: var(--bad); }
.pill b { font-weight: 600; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(63,185,80,.55); } 70% { box-shadow: 0 0 0 8px rgba(63,185,80,0); } 100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); } }

.views { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view { padding: 14px 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.spacer { height: 8px; }
.section { font-size: 13px; font-weight: 600; color: var(--muted-fg); margin: 22px 2px 10px; letter-spacing: .02em; }
.danger-h { color: var(--bad); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.grid { display: grid; gap: 10px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.card .grid { margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; padding: 18px 16px 16px;
  background: radial-gradient(130% 120% at 100% 0%, rgba(226,178,60,.14), transparent 55%), linear-gradient(180deg, #171A20, var(--card)); }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.mode-tag { font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--btn-border); color: var(--muted-fg); }
.mode-tag.real { color: var(--gold-2); border-color: rgba(226,178,60,.5); }
.hero-equity { font-size: 38px; font-weight: 700; margin-top: 6px; letter-spacing: -0.03em; transition: color .3s; }
.hero-pnl { font-size: 17px; font-weight: 600; margin-top: 2px; }
.hero-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.hero-grid div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hero-grid b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flash-up { animation: flashUp .6s; } .flash-down { animation: flashDown .6s; }
@keyframes flashUp { 0% { color: var(--good); } } @keyframes flashDown { 0% { color: var(--bad); } }

.banner { margin-top: 10px; padding: 11px 13px; border-radius: 12px; font-size: 14px; }
.banner.bad { background: rgba(179,38,30,.16); border: 1px solid rgba(217,68,58,.45); color: #FFB4AE; }
.banner.warn { background: rgba(230,160,40,.12); border: 1px solid rgba(230,160,40,.4); color: #F5CF8A; }

/* ---------- action buttons ---------- */
.act { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 14px; min-height: 86px;
  background: var(--btn); border: 1px solid var(--btn-border); border-radius: 14px; transition: transform .08s, border-color .15s, background .15s; position: relative; }
.act b { font-size: 16px; }
.act small { color: var(--muted); font-size: 12px; }
.act .ic { width: 22px; height: 22px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 6px; }
.act.primary { background: linear-gradient(160deg, rgba(242,201,76,.16), rgba(226,178,60,.04)), var(--btn); border-color: rgba(226,178,60,.55); }
.act.sm { min-height: 64px; padding: 12px 10px; align-items: center; text-align: center; }
.act.sm b { color: var(--gold-2); font-size: 17px; }
.act.busy::after, .btn.busy::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 1px solid var(--gold); animation: busy 1s infinite; pointer-events: none; }
.btn { position: relative; }
@keyframes busy { 50% { opacity: .2; } }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-2); border: 1px solid var(--btn-border); border-radius: 10px; padding: 3px; margin-bottom: 10px; }
.seg button { border: 0; background: none; padding: 8px; border-radius: 8px; color: var(--muted-fg); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--card-2); color: var(--gold-2); box-shadow: inset 0 0 0 1px var(--btn-border); }
.big-input { font-size: 22px; font-weight: 600; text-align: center; }

/* hold to close */
.hold { position: relative; overflow: hidden; width: 100%; height: 72px; border-radius: 16px; border: 1px solid var(--danger-2);
  background: rgba(179,38,30,.14); color: #FFD3CF; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.hold-fill { position: absolute; inset: 0; width: 0; background: linear-gradient(90deg, var(--danger), var(--danger-2)); }
.hold.holding .hold-fill { width: 100%; transition: width 1s linear; }
.hold-text { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hold-text b { font-size: 17px; letter-spacing: .02em; }
.hold-text small { font-size: 12px; opacity: .75; }

/* ---------- positions ---------- */
.pos-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.sym-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.sym-card b { font-size: 15px; }
.sym-card .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted-fg); margin-top: 4px; }
.pos-list { display: flex; flex-direction: column; gap: 8px; }
.pos-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.pos-item .sym { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.side { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; letter-spacing: .05em; }
.side.buy { background: rgba(63,185,80,.14); color: var(--good); } .side.sell { background: rgba(240,113,107,.14); color: var(--bad); }
.pos-item .pnl { font-weight: 700; font-size: 16px; text-align: right; }
.pos-item .det { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.pos-item .det b { color: var(--muted-fg); font-weight: 600; }
.pos-item.unmanaged { opacity: .55; }

/* ---------- activity ---------- */
.quick { margin-bottom: 12px; }
.feed { display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 11px 13px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.alert { border-color: rgba(230,160,40,.45); background: linear-gradient(180deg, rgba(230,160,40,.08), transparent), var(--card); }
.msg time { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.msg b { color: var(--gold-2); }
.msg code, .toast code { background: var(--bg-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.msg pre { white-space: pre-wrap; margin: 4px 0 0; font-size: 12.5px; }

/* ---------- more ---------- */
.row-input { display: flex; gap: 8px; margin-top: 10px; }
.row-input input { flex: 1; min-width: 0; padding: 12px; }
.acct-list { display: flex; flex-direction: column; gap: 6px; }
.acct-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); width: 100%; text-align: left; }
.acct-row.on { border-color: rgba(226,178,60,.6); }
.acct-row small { color: var(--muted); display: block; }
.meta { display: flex; flex-direction: column; gap: 8px; margin: 22px 0 10px; }
.meta div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.meta b { font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.install b { display: block; margin-bottom: 4px; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b)); background: rgba(13,15,18,.9); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.on { color: var(--gold-2); }
.tabbar .badge { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #15120A; font-size: 10.5px; font-style: normal; line-height: 17px; }
.tabbar .dot { position: absolute; top: 5px; left: calc(50% + 10px); width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(76px + var(--safe-b)); z-index: 20; max-width: 520px; margin: 0 auto;
  background: rgba(26,30,37,.97); border: 1px solid var(--btn-border); border-radius: 16px; padding: 12px 14px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); animation: up .22s ease-out; }
.toast.done { border-color: rgba(63,185,80,.5); } .toast.fail { border-color: rgba(217,68,58,.6); }
.toast-head { display: flex; align-items: center; gap: 8px; }
.toast-head b { flex: 1; font-size: 15px; }
.toast-ms { font-size: 12px; color: var(--muted); }
.toast-body { font-size: 13.5px; color: var(--muted-fg); margin-top: 6px; white-space: pre-wrap; max-height: 40vh; overflow-y: auto; }
.toast-body:empty { display: none; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(226,178,60,.25); border-top-color: var(--gold); animation: spin .7s linear infinite; flex: none; }
.toast.done .spin { animation: none; border: 0; background: var(--good); mask: none; }
.toast.done .spin::after { content: "✓"; display: block; color: #0D0F12; font-size: 11px; font-weight: 800; text-align: center; line-height: 16px; }
.toast.fail .spin { animation: none; border: 0; background: var(--danger-2); }
.toast.fail .spin::after { content: "!"; display: block; color: #fff; font-size: 11px; font-weight: 800; text-align: center; line-height: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { width: 100%; max-width: 560px; background: var(--card); border: 1px solid var(--border); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + var(--safe-b)); animation: up .25s ease-out; max-height: 85vh; overflow-y: auto; }
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--btn-border); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 6px; font-size: 19px; }
.sheet p { margin: 0 0 14px; color: var(--muted-fg); font-size: 14px; }
.sheet .grid { margin-top: 14px; }
.pair-code { font: 700 40px/1.1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .18em; color: var(--gold-2); text-align: center;
  padding: 18px 0; border: 1px dashed rgba(226,178,60,.5); border-radius: 14px; background: var(--bg-2); user-select: all; -webkit-user-select: all; }
.steps { margin: 14px 0 0; padding-left: 20px; color: var(--muted-fg); font-size: 14px; }
.steps li { margin-bottom: 6px; }
@keyframes fade { from { opacity: 0; } }

@media (min-width: 720px) {
  .hero-equity { font-size: 44px; }
}
@media (max-width: 360px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
}
