/* ============================================================
   API4ATKA — mobile-only design system
   Dark theme only. Tokens are authoritative — do not invent new ones.
   ============================================================ */

:root {
  /* surfaces */
  --bg:      #0a0a0a;
  --bg-1:    #0e0e10;
  --bg-2:    #141416;
  --panel:   #161618;
  --panel-2: #1c1c1f;

  /* borders */
  --border:   rgba(255,255,255,0.06);
  --border-2: rgba(255,255,255,0.10);
  --border-3: rgba(255,255,255,0.16);

  /* text */
  --text:   #f5f5f5;
  --text-2: #b8b8b8;
  --text-3: #7a7a7a;
  --text-4: #4d4d4d;

  /* semantic */
  --accent:    #4f9eff;
  --accent-dim:rgba(79,158,255,0.14);
  --long:      #10c76e;
  --long-dim:  rgba(16,199,110,0.14);
  --long-bg:   rgba(16,199,110,0.08);
  --short:     #ff4e54;
  --short-dim: rgba(255,78,84,0.14);
  --short-bg:  rgba(255,78,84,0.08);
  --warn:      #ffc300;
  --warn-dim:  rgba(255,195,0,0.14);

  /* radii */
  --r-1: 6px;
  --r-2: 10px;
  --r-3: 14px;
  --r-4: 20px;

  /* type */
  --font:      "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  /* chrome heights */
  --topbar-h: 56px;
  --nav-h:    60px;

  /* safe areas */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* motion */
  --dur: 180ms;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body, #root {
  height: 100%;
  min-height: 100dvh;
}
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
  overflow: hidden;   /* скролл живёт внутри .m-scroll, body не скроллим */
}

button { font-family: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font-family: inherit; color: inherit; }
input:focus, select:focus { outline: none; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pos  { color: var(--long); }
.neg  { color: var(--short); }
.muted{ color: var(--text-3); }
.dim2 { color: var(--text-2); }

::-webkit-scrollbar { width: 0; height: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   СВЕТЛАЯ ТЕМА — полное переопределение токенов.
   Принцип: переворачиваем shade всех surface/border/text, но оставляем
   семантические цвета (long/short/accent/warn) яркими и читаемыми.
   ============================================================ */
:root[data-theme="light"] {
  /* surfaces — светлые тона, контраст с тёмным текстом */
  --bg:      #f4f4f5;
  --bg-1:    #ffffff;
  --bg-2:    #ebebed;
  --bg-3:    #e0e0e3;
  --panel:   #ffffff;       /* критично: основной фон карточек */
  --panel-2: #f4f4f5;       /* вторичные блоки внутри карточек */

  /* borders — тёмные с прозрачностью */
  --border:   rgba(0, 0, 0, 0.08);
  --border-2: rgba(0, 0, 0, 0.12);
  --border-3: rgba(0, 0, 0, 0.20);

  /* text — тёмные, по убыванию контраста */
  --text:    #0a0a0a;
  --text-2:  #3a3a3a;
  --text-3:  #6a6a6a;
  --text-4:  #9a9a9a;

  /* semantic: те же hue, но чуть темнее для контраста на белом */
  --accent:    #2563eb;
  --accent-dim: rgba(37, 99, 235, 0.12);
  --long:      #059669;     /* зелёный темнее: emerald-600 */
  --long-bg:   rgba(5, 150, 105, 0.10);
  --long-dim:  rgba(5, 150, 105, 0.20);
  --short:     #dc2626;     /* красный темнее: red-600 */
  --short-bg:  rgba(220, 38, 38, 0.08);
  --short-dim: rgba(220, 38, 38, 0.18);
  --warn:      #d97706;     /* янтарь темнее */
  --warn-dim:  rgba(217, 119, 6, 0.14);
}

/* Точечные оверрайды для компонентов с hardcoded rgba(255,255,255,*).
   Эти rgba прибиты в темах и не покрываются переменными — переопределяем. */
:root[data-theme="light"] body {
  background: var(--bg);
  color: var(--text);
}
:root[data-theme="light"] .m-top-bar,
:root[data-theme="light"] .m-bottom-nav {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--border);
}
:root[data-theme="light"] .m-bottom-nav .ni-icon { color: var(--text-3); }
:root[data-theme="light"] .m-bottom-nav .ni.active .ni-icon,
:root[data-theme="light"] .m-bottom-nav .ni.active .ni-label { color: var(--accent); }
:root[data-theme="light"] .m-fab {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
:root[data-theme="light"] .m-sheet {
  background: var(--panel);
  border-top: 1px solid var(--border-2);
}
:root[data-theme="light"] .m-backdrop {
  background: rgba(0, 0, 0, 0.45);
}
:root[data-theme="light"] .m-toast {
  background: #0a0a0a;
  color: #f5f5f5;
}
:root[data-theme="light"] .m-card,
:root[data-theme="light"] .m-set-list,
:root[data-theme="light"] .m-set-row,
:root[data-theme="light"] .trade-card,
:root[data-theme="light"] .m-input {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}
:root[data-theme="light"] .m-input::placeholder { color: var(--text-3); }
:root[data-theme="light"] .m-hero {
  background: var(--panel);
  border: 1px solid var(--border);
}
:root[data-theme="light"] .m-segmented,
:root[data-theme="light"] .m-toggle2 {
  background: var(--bg-2);
}
:root[data-theme="light"] .m-segmented .active,
:root[data-theme="light"] .m-toggle2 .active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .m-button.primary {
  background: var(--accent);
  color: #fff;
}
:root[data-theme="light"] .m-button {
  background: var(--bg-2);
  color: var(--text);
}
:root[data-theme="light"] .m-button.ghost {
  background: transparent;
  color: var(--text-2);
}
:root[data-theme="light"] .m-button.danger,
:root[data-theme="light"] .m-button.short {
  background: var(--short);
  color: #fff;
}
:root[data-theme="light"] .m-button.long {
  background: var(--long);
  color: #fff;
}
:root[data-theme="light"] .m-switch {
  background: var(--border-3);
}
:root[data-theme="light"] .m-switch.on {
  background: var(--accent);
}
:root[data-theme="light"] .m-pill {
  background: var(--bg-2);
  color: var(--text-2);
}
:root[data-theme="light"] .m-pill.lev {
  background: var(--accent-dim);
  color: var(--accent);
}
:root[data-theme="light"] .skel {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
}
:root[data-theme="light"] .m-chip {
  background: var(--bg-2);
  color: var(--text-2);
}
:root[data-theme="light"] .m-chip.active {
  background: var(--accent);
  color: #fff;
}
:root[data-theme="light"] details summary,
:root[data-theme="light"] pre {
  color: var(--text-2);
}
:root[data-theme="light"] .day-summary {
  background: var(--panel-2);
  color: var(--text-2);
}
:root[data-theme="light"] .ptr {
  color: var(--text-3);
}
:root[data-theme="light"] .swipe-actions {
  background: var(--bg-2);
}
:root[data-theme="light"] .pct-btn {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border);
}
:root[data-theme="light"] .pct-btn.active {
  background: var(--accent);
  color: #fff;
}
:root[data-theme="light"] .ni .ni-label { color: var(--text-3); }
:root[data-theme="light"] .si {
  background: var(--bg-2);
  color: var(--text-2);
}
:root[data-theme="light"] .m-set-row .sc .st { color: var(--text); }
:root[data-theme="light"] .m-set-row .sc .ss { color: var(--text-3); }

/* Mode switcher (Futures/Spot/Bots) — внутри .m-app */
.m-mode-tabs {
  flex-shrink: 0;
}
.m-mode-tab.disabled { pointer-events: none; }

/* ============================================================
   App shell
   ============================================================ */
.m-app {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.m-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  /* touch-action: pan-y разрешает вертикальный скролл и одновременно
     позволяет нашему usePullToRefresh-хуку перехватывать touchmove когда
     scrollTop = 0 (вертикальный потяг). */
  touch-action: pan-y;
  padding: 12px 14px;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 24px);
}
.m-scroll.has-back { padding-top: 12px; }

/* ============================================================
   Top app bar
   ============================================================ */
.m-top-bar {
  position: sticky; top: 0; z-index: 40;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex; align-items: center; gap: 10px;
  padding-left: 14px; padding-right: 14px;
  background: rgba(10,10,10,0.72);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.m-brand {
  font-family: var(--font-mono);
  font-size: 14px; font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.m-brand-dim {
  color: rgba(79, 158, 255, 0.42);
}
.m-back {
  width: 36px; height: 36px; margin-left: -8px;
  display: grid; place-items: center;
  color: var(--text-2); border-radius: var(--r-1);
}
.m-back:active { background: var(--bg-2); }
.m-top-title { font-size: 16px; font-weight: 600; }
.m-top-spacer { flex: 1; }

.m-exch-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px; color: var(--text-2);
  font-family: var(--font-mono);
}
.m-bell {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  color: var(--text-2); border-radius: var(--r-1);
}
.m-bell:active { background: var(--bg-2); }
.m-bell .badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--short); color: #fff;
  font-size: 10px; font-weight: 700; font-family: var(--font-mono);
  border-radius: 999px;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
}

/* live dot */
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--long); flex-shrink: 0;
  position: relative;
}
.dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  background: var(--long); opacity: 0.35;
  animation: ring 2.2s ease-out infinite;
}
.dot.off { background: var(--text-3); }
.dot.off::after { display: none; }
.dot.warn { background: var(--warn); }
.dot.warn::after { background: var(--warn); }
@keyframes ring { 0%{transform:scale(.7);opacity:.5} 100%{transform:scale(2.6);opacity:0} }

/* ============================================================
   Bottom navigation
   ============================================================ */
.m-bottom-nav {
  position: relative; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(14,14,16,0.86);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border);
}
.m-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 10px; font-weight: 500;
  position: relative;
  transition: color var(--dur) var(--ease);
}
.m-nav-item .ni-icon { transition: transform var(--dur) var(--ease); }
.m-nav-item:active .ni-icon { transform: scale(0.88); }
.m-nav-item.active { color: var(--accent); }
.m-nav-item .ni-badge {
  position: absolute; top: 6px; left: calc(50% + 8px);
  min-width: 15px; height: 15px; padding: 0 4px;
  background: var(--warn); color: #000;
  font-size: 9.5px; font-weight: 700; font-family: var(--font-mono);
  border-radius: 999px; display: grid; place-items: center;
}

/* ============================================================
   FAB
   ============================================================ */
.m-fab {
  position: absolute;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  z-index: 45;
  width: 56px; height: 56px;
  border-radius: 18px;
  background: linear-gradient(160deg, #2b2b30, #161618);
  border: 1px solid var(--border-2);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03) inset;
  display: grid; place-items: center;
  color: var(--text);
  touch-action: none;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.m-fab:active { transform: scale(0.94); }
.m-fab .fab-hint {
  position: absolute; bottom: calc(100% + 8px); right: 0;
  white-space: nowrap;
  background: var(--panel-2); border: 1px solid var(--border-2);
  border-radius: var(--r-1); padding: 5px 9px;
  font-size: 11px; color: var(--text-2);
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity var(--dur), transform var(--dur);
}
.m-fab.armed { box-shadow: 0 8px 28px var(--short-dim), 0 0 0 1px var(--short-dim) inset; border-color: var(--short); }
.m-fab.armed .fab-hint { opacity: 1; transform: translateY(0); }

/* ============================================================
   Cards
   ============================================================ */
.m-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: 14px;
}
.m-card.flush { padding: 0; overflow: hidden; }

/* hero cards */
.m-hero {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: 16px;
  position: relative; overflow: hidden;
}
.m-hero + .m-hero { margin-top: 10px; }
.m-hero .h-label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: space-between;
}
.m-hero .h-value {
  font-family: var(--font-mono); font-weight: 700;
  font-size: 28px; letter-spacing: -0.03em;
  margin-top: 8px;
  display: flex; align-items: baseline; gap: 8px;
}
.m-hero .h-value .ccy { font-size: 14px; color: var(--text-3); font-weight: 500; }
.m-hero .h-sub { margin-top: 6px; font-size: 13px; color: var(--text-2); }
.m-hero .h-spark { position: absolute; right: 0; bottom: 0; width: 55%; height: 46%; opacity: 0.5; pointer-events: none; }

.delta-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
}
.delta-chip.up { color: var(--long); background: var(--long-bg); }
.delta-chip.down { color: var(--short); background: var(--short-bg); }

/* day-profit progress */
.m-progress {
  height: 6px; border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden; margin-top: 10px;
  display: flex;
}
.m-progress > i { height: 100%; display: block; }
.m-progress > .win { background: var(--long); }
.m-progress > .loss { background: var(--short); opacity: 0.6; }

/* ============================================================
   Section header
   ============================================================ */
.m-section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 2px 10px;
}
.m-section-h .t {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3);
  display: flex; align-items: center; gap: 8px;
}
.m-section-h .t .count {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-2);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 7px; letter-spacing: 0;
}
.m-section-h .a { font-size: 12px; color: var(--accent); }

/* ============================================================
   Pills / tags
   ============================================================ */
.m-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--r-1);
}
.m-pill.long  { color: var(--long); background: var(--long-bg); box-shadow: inset 0 0 0 1px var(--long-dim); }
.m-pill.short { color: var(--short); background: var(--short-bg); box-shadow: inset 0 0 0 1px var(--short-dim); }
.m-pill.lev   { color: var(--text-2); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--border); }
.m-pill.warn  { color: var(--warn); background: var(--warn-dim); }

.coin {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; color: #07120a;
}
.coin.sm { width: 20px; height: 20px; font-size: 8px; }

/* ============================================================
   Position card (swipeable)
   ============================================================ */
.swipe-wrap { position: relative; border-radius: var(--r-3); overflow: hidden; }
.swipe-wrap + .swipe-wrap { margin-top: 10px; }
.swipe-actions {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  font-weight: 600; font-size: 13px;
}
.swipe-actions .left  { color: var(--long); display: flex; align-items: center; gap: 8px; }
.swipe-actions .right { color: var(--accent); display: flex; align-items: center; gap: 8px; }
.swipe-actions.close-edit { background: linear-gradient(90deg, var(--long-bg), transparent 40%, transparent 60%, var(--accent-dim)); }
.swipe-actions.approve-reject { background: linear-gradient(90deg, var(--long-bg), transparent 40%, transparent 60%, var(--short-bg)); }
.swipe-actions .right.reject { color: var(--short); }

.swipe-fg {
  position: relative; z-index: 1;
  background: var(--panel);
  touch-action: pan-y;
  will-change: transform;
}

.pos-card { padding: 14px; }
.pos-card .row1 { display: flex; align-items: center; gap: 10px; }
.pos-card .sym { font-family: var(--font-mono); font-size: 15px; font-weight: 600; }
.pos-card .meta { display: flex; gap: 6px; margin-left: auto; }
.pos-card .grid2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px;
  margin-top: 12px; font-size: 13px;
}
.pos-card .kv .k { color: var(--text-3); font-size: 11px; }
.pos-card .kv .v { font-family: var(--font-mono); font-size: 13.5px; margin-top: 1px; }
.pos-card .pnl-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.pos-card .pnl-big { font-family: var(--font-mono); font-size: 18px; font-weight: 700; }
.pos-card .pnl-pct { font-family: var(--font-mono); font-size: 13px; }

/* expanded actions */
.pos-expand {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  margin-top: 12px;
}

/* pulse on pnl tick */
.pulse-up   { animation: pUp var(--dur) ease-out; }
.pulse-down { animation: pDown var(--dur) ease-out; }
@keyframes pUp   { 0%{ text-shadow: 0 0 12px var(--long); } 100%{ text-shadow: none; } }
@keyframes pDown { 0%{ text-shadow: 0 0 12px var(--short); } 100%{ text-shadow: none; } }

/* ============================================================
   Buttons
   ============================================================ */
.m-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 44px; padding: 0 16px;
  border-radius: var(--r-2);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 14px; font-weight: 500;
  transition: transform var(--dur) var(--ease), background var(--dur);
}
.m-button:active { transform: scale(0.97); }
.m-button.block { width: 100%; }
.m-button.lg { height: 56px; font-size: 16px; font-weight: 600; border-radius: var(--r-3); }
.m-button.sm { height: 36px; font-size: 13px; padding: 0 12px; }
.m-button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.m-button.primary:active { background: #3d8ae8; }
.m-button.long { background: var(--long); border-color: var(--long); color: #04130b; }
.m-button.short { background: var(--short); border-color: var(--short); color: #fff; }
.m-button.danger { background: var(--short-bg); border-color: var(--short-dim); color: var(--short); }
.m-button.ghost { background: transparent; border-color: var(--border); color: var(--text-2); }

/* ============================================================
   Segmented + filter pills
   ============================================================ */
.m-segmented {
  display: flex; gap: 2px; padding: 3px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-2);
}
.m-segmented button {
  flex: 1; height: 34px;
  font-size: 13px; font-weight: 500; color: var(--text-3);
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background var(--dur), color var(--dur);
}
.m-segmented button .n { font-family: var(--font-mono); font-size: 11px; color: var(--text-4); }
.m-segmented button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); }
.m-segmented button.active .n { color: var(--text-2); }

.m-filter-row { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.m-chip {
  flex-shrink: 0;
  height: 30px; padding: 0 12px;
  font-size: 12px; font-weight: 500; color: var(--text-3);
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex; align-items: center;
}
.m-chip.active { color: var(--text); background: var(--accent-dim); border-color: var(--accent); }

/* ============================================================
   Journal
   ============================================================ */
.m-date-divider {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  margin: 18px 4px 8px;
  text-transform: capitalize;
}
.trade-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-2); padding: 12px;
}
.trade-card + .trade-card { margin-top: 8px; }
.trade-card .tr1 { display: flex; align-items: center; gap: 8px; }
.trade-card .tr-sym { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.trade-card .tr-prices { font-family: var(--font-mono); font-size: 13px; color: var(--text-2); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.trade-card .tr-bottom { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 8px; }
.trade-card .tr-pnl { font-family: var(--font-mono); font-size: 15px; font-weight: 700; }
.trade-card .tr-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.arrow { color: var(--text-4); display: inline-flex; }
.close-reason {
  width: 24px; height: 24px; border-radius: 7px; margin-left: auto;
  display: grid; place-items: center; flex-shrink: 0;
}
.close-reason.tp { background: var(--long-bg); color: var(--long); }
.close-reason.sl { background: var(--short-bg); color: var(--short); }
.close-reason.manual { background: var(--bg-2); color: var(--text-2); }

.day-summary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 12px 0 4px; padding: 8px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-2);
}
.day-summary .sep { color: var(--text-4); }

/* ============================================================
   Signals
   ============================================================ */
.signal-card { padding: 0; }
.signal-card .sig-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.signal-card .sig-channel { font-size: 13px; font-weight: 600; }
.signal-card .sig-time { font-size: 11px; color: var(--text-3); margin-left: auto; font-family: var(--font-mono); }
.signal-card .sig-body { padding: 14px; }
.signal-card .sig-pair { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.signal-card .sig-pair .p { font-family: var(--font-mono); font-size: 17px; font-weight: 700; }
.sig-levels { display: flex; flex-direction: column; gap: 8px; }
.sig-level { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.sig-level .k { color: var(--text-3); }
.sig-level .v { font-family: var(--font-mono); font-weight: 500; }
.sig-level .v.tps { display: flex; gap: 8px; }
.sig-level .v .tp { color: var(--long); }
.sig-meta {
  display: flex; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 13px;
}
.sig-meta .k { color: var(--text-3); font-size: 11px; }
.sig-meta .v { font-family: var(--font-mono); font-size: 14px; font-weight: 500; margin-top: 2px; }
.sig-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 14px; }

/* ============================================================
   Settings
   ============================================================ */
.m-set-group { margin-top: 18px; }
.m-set-group > .label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); margin: 0 4px 8px;
}
.m-set-list {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-3); overflow: hidden;
}
.m-set-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; min-height: 52px;
  border-bottom: 1px solid var(--border);
  width: 100%; text-align: left;
}
.m-set-row:last-child { border-bottom: 0; }
.m-set-row:active { background: var(--bg-2); }
.m-set-row .si {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--bg-2); color: var(--text-2);
}
.m-set-row .sc { flex: 1; min-width: 0; }
.m-set-row .sc .st { font-size: 14px; color: var(--text); }
.m-set-row .sc .ss { font-size: 12px; color: var(--text-3); margin-top: 1px; font-family: var(--font-mono); }
.m-set-row .sr { display: flex; align-items: center; gap: 8px; color: var(--text-3); flex-shrink: 0; }
.m-set-row .sr .ok { color: var(--long); }

.m-switch {
  width: 44px; height: 26px; border-radius: 999px; padding: 2px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  transition: background var(--dur);
  flex-shrink: 0;
}
.m-switch::after {
  content: ""; display: block; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-3); transition: transform var(--dur) var(--ease), background var(--dur);
}
.m-switch.on { background: var(--accent); border-color: var(--accent); }
.m-switch.on::after { transform: translateX(18px); background: #fff; }

.m-toggle2 {
  display: inline-flex; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px;
}
.m-toggle2 button {
  padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--text-3); border-radius: 999px;
}
.m-toggle2 button.active { background: var(--accent); color: #fff; }

/* ============================================================
   Bottom sheet
   ============================================================ */
.m-backdrop {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.m-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 61;
  max-height: 86vh;
  background: var(--bg-1);
  border-top: 1px solid var(--border-2);
  border-radius: var(--r-4) var(--r-4) 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  touch-action: none;
  will-change: transform;
  animation: sheetUp var(--dur) var(--ease);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.m-sheet .grabber {
  width: 38px; height: 4px; border-radius: 999px; background: var(--border-3);
  margin: 10px auto 4px; flex-shrink: 0;
}
.m-sheet .sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 12px; border-bottom: 1px solid var(--border);
}
.m-sheet .sheet-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.m-sheet .sheet-close { width: 32px; height: 32px; display: grid; place-items: center; color: var(--text-3); border-radius: 8px; }
.m-sheet .sheet-close:active { background: var(--bg-2); }
.m-sheet .sheet-body { overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.m-sheet .sheet-foot {
  padding: 12px 16px calc(12px); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px;
}

.sheet-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin: 16px 0 8px; }
.sheet-label:first-child { margin-top: 0; }

.pct-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pct-btn {
  height: 46px; border-radius: var(--r-2);
  background: var(--bg-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: all var(--dur);
}
.pct-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.pct-btn.active.full { animation: fullPulse 1.6s ease-in-out infinite; }
@keyframes fullPulse { 0%,100%{ box-shadow: 0 0 0 0 var(--accent-dim);} 50%{ box-shadow: 0 0 0 4px transparent;} }

/* ============================================================
   Inputs
   ============================================================ */
.m-input {
  width: 100%; height: 48px; padding: 0 14px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-2);
  font-size: 16px; /* prevents iOS zoom */ color: var(--text);
  font-family: var(--font-mono);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.m-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.m-divider { height: 1px; background: var(--border); margin: 0; }

/* ============================================================
   Empty state
   ============================================================ */
.m-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 48px 28px; gap: 6px; min-height: 50vh;
}
.m-empty .art { color: var(--text-4); margin-bottom: 6px; }
.m-empty .et { font-size: 16px; font-weight: 600; }
.m-empty .em { font-size: 13px; color: var(--text-3); max-width: 260px; line-height: 1.5; }

/* ============================================================
   Toast
   ============================================================ */
.m-toast {
  position: absolute; left: 14px; right: 14px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  z-index: 70;
  background: var(--panel-2); border: 1px solid var(--border-2);
  border-radius: var(--r-2); padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  animation: toastUp var(--dur) var(--ease);
}
@keyframes toastUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.m-toast.err { border-color: var(--short-dim); }
.m-toast .tt { flex: 1; font-size: 13px; }
.m-toast .ta { font-size: 13px; font-weight: 600; color: var(--accent); flex-shrink: 0; }
.m-toast .tprog { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); border-radius: 0 0 var(--r-2) var(--r-2); animation: tprog 5s linear forwards; }
@keyframes tprog { from { width: 100%; } to { width: 0%; } }

/* ============================================================
   Skeleton
   ============================================================ */
.skel { background: linear-gradient(90deg, var(--bg-2) 0%, var(--panel-2) 50%, var(--bg-2) 100%); background-size: 200% 100%; animation: skel 1.4s ease-in-out infinite; border-radius: var(--r-1); }
@keyframes skel { 0%{ background-position: 200% 0;} 100%{ background-position: -200% 0;} }

/* pull to refresh */
.ptr {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 0; overflow: hidden; color: var(--text-3); font-size: 12px;
  transition: height var(--dur);
}
.ptr .spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Phone-frame preview chrome (preview only — not shipped)
   ============================================================ */
.stage {
  min-height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, #15151a, #060608 60%);
  padding: 24px;
}
.device {
  width: 390px; height: 844px;
  max-height: calc(100vh - 32px);
  aspect-ratio: 390 / 844;
  background: #000;
  border-radius: 52px;
  padding: 12px;
  box-shadow: 0 0 0 2px #1c1c1f, 0 0 0 11px #0c0c0e, 0 40px 80px rgba(0,0,0,0.6);
  position: relative;
}
.device-screen {
  width: 100%; height: 100%;
  border-radius: 42px; overflow: hidden;
  position: relative; background: var(--bg);
  /* simulate device safe areas inside the preview frame (env() is 0 in an iframe) */
  --safe-top: 44px;
  --safe-bottom: 18px;
}
.device .notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 124px; height: 32px; background: #000; border-radius: 0 0 18px 18px; z-index: 100;
}
.status-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 44px; z-index: 99;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; font-size: 13px; font-weight: 600; color: var(--text);
  pointer-events: none;
}
.status-bar .sb-time { font-family: var(--font); }
.status-bar .sb-icons { display: flex; align-items: center; gap: 5px; }
@media (max-width: 460px) {
  .stage { padding: 0; }
  .device { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; padding: 0; box-shadow: none; }
  .device-screen { border-radius: 0; --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); }
  .device .notch { display: none; }
  .status-bar { display: none; }
}
