/* Whale Terminal — user PWA (App P1b). Dark, mobile-first. */
:root {
  --bg:        #0a1827;
  --bg-2:      #0d1f35;
  --card:      #11283f;
  --card-2:    #163450;
  --line:      #1f3e5c;
  --text:      #e8f1fb;
  --muted:     #8aa6c2;
  --accent:    #3da9fc;
  --pos:       #34d399;
  --neg:       #f87171;
  --warn:      #fbbf24;
  --radius:    14px;
  --tap:       44px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; }
.view { padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom)); }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 18px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* boot + spinner */
.boot-logo { width: 92px; height: 92px; opacity: .9; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.login-card { width: 100%; max-width: 360px; padding: 28px 22px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 2px; }
.login-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .3px; }
.login-sub { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field span { font-size: 13px; color: var(--muted); }
.field input {
  min-height: var(--tap);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 16px; padding: 0 14px; width: 100%;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.err { color: var(--neg); font-size: 14px; min-height: 18px; margin: 0; }
.btn {
  min-height: var(--tap); border: 0; border-radius: 10px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s ease, opacity .15s ease;
}
.btn:active { filter: brightness(.92); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: #04223b; }
.btn-link { background: none; border: 0; color: var(--accent); font-size: 14px; cursor: pointer; padding: 6px; min-height: 32px; }
.btn-link:active { opacity: .7; }
.mfa-secret { font-family: monospace; font-size: 18px; letter-spacing: 2px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 6px 0; word-break: break-all; user-select: all; }
.mfa-recovery { font-family: monospace; font-size: 13px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 6px 0; line-height: 1.8; user-select: all; }

/* topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 14px; }
.topbar-id { display: flex; align-items: center; gap: 10px; }
.topbar-logo { width: 34px; height: 34px; }
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-sub { font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  font-size: 18px; cursor: pointer;
}
.icon-btn:active { background: var(--card-2); }
/* admin personal lens — Mine/All segmented switch (P3) */
.view-switch { display: flex; gap: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.vs-btn { min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.vs-btn.active { background: var(--accent); color: #04223b; }
.vs-btn:active { filter: brightness(.95); }

/* P&L strip */
.pnl-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 12px; margin-bottom: 8px;
}
.pnl-cell { text-align: center; }
.pnl-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.pnl-value { font-size: 18px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* sections */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 2px 10px; }

/* account cards */
.accounts { display: flex; flex-direction: column; gap: 10px; }
.acct {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px;
}
.acct-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.acct-name { font-weight: 700; font-size: 15px; }
.acct-broker { font-size: 12px; color: var(--muted); }
.acct-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.acct-stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.acct-stat .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.acct-pnl-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.acct-pnl-row .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.acct-pnl-row .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-left: auto; }
.acct-reset { min-height: 32px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card-2); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.acct-reset:active { filter: brightness(.92); }
.acct-reset[disabled] { opacity: .55; }
.dd-bar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 12px; }
.dd-fill { height: 100%; background: var(--pos); transition: width .3s ease; }
.dd-fill.warn { background: var(--warn); }
.dd-fill.danger { background: var(--neg); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted); }
.badge.live { background: rgba(52,211,153,.15); color: var(--pos); }
.badge.paused { background: rgba(248,113,113,.15); color: var(--neg); }

/* positions */
.positions { display: flex; flex-direction: column; gap: 8px; }
.pos-row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.pos-sym { font-weight: 700; }
.pos-meta { font-size: 12px; color: var(--muted); }
.pos-side { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.pos-side.long { background: rgba(52,211,153,.15); color: var(--pos); }
.pos-side.short { background: rgba(248,113,113,.15); color: var(--neg); }
.pos-pnl { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 22px; border: 1px dashed var(--line); border-radius: var(--radius); }
.foot { margin-top: 22px; text-align: center; font-size: 12px; }

@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .dd-fill { transition: none; } }

/* tabs (P1c) */
.tabs { display: flex; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.tab-btn { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; }
.tab-btn.active { background: var(--card-2); color: var(--text); }
.tab-btn:active { filter: brightness(.95); }

/* channels (P1c) */
.hint { font-size: 13px; margin: -2px 2px 14px; }
.channels { display: flex; flex-direction: column; gap: 12px; }
.ch-acct { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.ch-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.ch-name { font-weight: 700; font-size: 15px; }
.ch-count { font-size: 12px; color: var(--muted); }
.small { font-size: 13px; }
.ch-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 13px; font-size: 13px; }
.chip-x { width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(248,113,113,.15); color: var(--neg); font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.chip-x:active { background: rgba(248,113,113,.32); }
.chip-x[disabled] { opacity: .5; }
.ch-add { display: flex; gap: 8px; margin-top: 12px; }
.ch-add select { flex: 1; min-height: var(--tap); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 15px; padding: 0 12px; }
.ch-add select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-add { min-height: var(--tap); padding: 0 18px; border: 0; border-radius: 10px; background: var(--accent); color: #04223b; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-add:active { filter: brightness(.92); }
.btn-add[disabled] { opacity: .55; }

/* toast (P1c) */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); max-width: 88%; background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; font-size: 14px; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast.ok { border-color: var(--pos); }
.toast.err { border-color: var(--neg); }

/* pause / resume orders (P1e) */
.acct-pause { width: 100%; min-height: var(--tap); margin-top: 14px; border: 1px solid var(--warn); border-radius: 10px; background: rgba(251,191,36,.12); color: var(--warn); font-size: 15px; font-weight: 600; cursor: pointer; }
.acct-pause:active { filter: brightness(.95); }
.acct-pause[disabled] { opacity: .55; }
.acct-pause.resume { border-color: var(--pos); background: rgba(52,211,153,.12); color: var(--pos); }

/* notifications (P2a.4) */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; }
.toggle-row:first-of-type { border-top: 0; }
.toggle { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s ease; }
.toggle:checked { background: var(--pos); }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.toggle:checked::after { transform: translateX(18px); }
.toggle[disabled] { opacity: .6; }
.btn-danger { min-height: var(--tap); padding: 0 18px; border: 1px solid var(--neg); border-radius: 10px; background: rgba(248,113,113,.12); color: var(--neg); font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 10px; }
.btn-danger:active { filter: brightness(.95); }
.code-box { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 26px; font-weight: 700; letter-spacing: 4px; text-align: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: var(--accent); }
.code-hint { font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .toggle, .toggle::after { transition: none; } }

/* G-LOGINSCALE: desktop — enlarge the sign-in / setup / reset card. The base is mobile-first
   (360px card), which looks tiny lost on a big screen. Phones (<600px) are unchanged. */
@media (min-width: 600px) {
  .login-card { max-width: 390px; padding: 33px 30px; gap: 14px; }
  .login-logo { width: 72px; height: 72px; margin-bottom: 3px; }
  .login-title { font-size: 24px; }
  .login-sub { font-size: 14px; margin-bottom: 8px; }
  .login-card .field span { font-size: 12px; }
  .login-card .field input { font-size: 13px; }
  .login-card .err { font-size: 12px; }
  .login-card .btn { font-size: 14px; min-height: 40px; }
  .login-card .btn-link { font-size: 12px; }
}
