/* ── RESET & ROOT ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
:root {
  /* ── Dark palette (OLED black) ── */
  --bg:        #000000;
  --surface:   #0d0d0d;
  --s2:        #0d0d0d;
  --s3:        #161616;
  --border:    #1f1f1f;
  --text:      #e6e8ea;
  --muted:     #848e9c;
  --accent:    #f7a600;
  --ac-d:      rgba(247,166,0,.13);
  --green:     #0ecb81;
  --green-d:   rgba(14,203,129,.12);
  --red:       #f6465d;
  --red-d:     rgba(246,70,93,.12);
  --yellow:    #f7a600;
  --yellow-d:  rgba(247,166,0,.12);
  /* ── Semantic aliases ── */
  --card-bg:        var(--s2);
  --card-border:    rgba(255,255,255,.07);
  --item-border:    rgba(255,255,255,.055);
  --card-gradient:  var(--s2);
  --card-inset:     transparent;
  --card-shadow:    rgba(0,0,0,.45);
  --text-muted:     var(--muted);
  --input-bg:       var(--s2);
  --input-border:   rgba(255,255,255,.1);
  --metric-bg:      rgba(255,255,255,.04);
  --equity-bg:      rgba(255,255,255,.02);
  --log-bg:         #000000;
  --msg-ok-bg:      rgba(14,203,129,.1);
  --msg-err-bg:     rgba(246,70,93,.1);
  --topbar-bg:      rgba(0,0,0,.97);
  --nav-bg:         rgba(0,0,0,.98);
  --modal-overlay:  rgba(0,0,0,.82);
  /* ── Chat / panel colors ── */
  --chat-bg-color:    #0c0c0e;
  --chat-bg-filter:   brightness(0.3);
  --chat-surface:     #0c0c0e;
  --chat-border:      rgba(255,255,255,.09);
  --chat-border-soft: rgba(255,255,255,.07);
  --chat-bubble-bot:  rgb(28 32 30);
  --chat-bubble-me:   rgb(28 55 79);
  --chat-bubble-text: #e0d9ff;
  --chat-sep-line:    rgba(255,255,255,.08);
  --chat-sep-text:    rgba(255,255,255,.35);
  --chat-input-bg:    rgba(255,255,255,.06);
  --chat-input-bdr:   rgba(255,255,255,.12);
  --chat-ph-color:    rgba(255,255,255,.3);
  --chat-dim:         rgba(255,255,255,.06);
  --chat-dim-hover:   rgba(255,255,255,.1);
  --chat-muted-text:  rgba(255,255,255,.35);
  --chat-send-dis:    rgba(255,255,255,.45);
  --chat-reply-close: rgba(255,255,255,.18);
  --chat-empty-ico:   rgba(255,255,255,.25);
  --chat-scroll-thumb:rgba(255,255,255,.12);
  --chat-overlay:     rgba(0,0,0,.55);
  /* ── Layout ── */
  --radius:      8px;
  --radius-sm:   6px;
  --r:           6px;
  --nav-h:       62px;
  --top-h:       56px;
  --sidebar-w:   200px;
  /* ── Spacing scale ── */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 16px;
  --sp-4: 24px; --sp-5: 32px; --sp-6: 48px;
  /* ── Typography ── */
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Consolas', 'Monaco', monospace;
}

/* ── Light theme ──────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f5f5f5;
  --surface:   #ffffff;
  --s2:        #fafafa;
  --s3:        #f0f0f0;
  --border:    #e0e0e0;
  --text:      #1a1a1a;
  --muted:     #707a8a;
  --ac-d:      rgba(247,166,0,.1);
  --green:     #03a66d;
  --green-d:   rgba(3,166,109,.1);
  --red:       #cf304a;
  --red-d:     rgba(207,48,74,.1);
  --yellow:    #f7a600;
  --yellow-d:  rgba(247,166,0,.1);
  --card-bg:        #ffffff;
  --card-border:    rgba(0,0,0,.07);
  --item-border:    rgba(0,0,0,.06);
  --card-gradient:  #ffffff;
  --card-inset:     transparent;
  --card-shadow:    rgba(0,0,0,.05);
  --input-bg:       #ffffff;
  --input-border:   rgba(0,0,0,.12);
  --metric-bg:      rgba(0,0,0,.04);
  --equity-bg:      rgba(0,0,0,.03);
  --log-bg:         #f9f9f9;
  --msg-ok-bg:      rgba(3,166,109,.08);
  --msg-err-bg:     rgba(207,48,74,.08);
  --topbar-bg:      rgba(255,255,255,.96);
  --nav-bg:         rgba(255,255,255,.97);
  --modal-overlay:  rgba(0,0,0,.4);
  /* ── Chat / panel colors (light) ── */
  --chat-bg-color:    #dde8f0;
  --chat-bg-filter:   brightness(0.92);
  --chat-surface:     #f0f4f8;
  --chat-border:      rgba(0,0,0,.1);
  --chat-border-soft: rgba(0,0,0,.07);
  --chat-bubble-bot:  #e8edf2;
  --chat-bubble-me:   #1a73c8;
  --chat-bubble-text: #1a1a1a;
  --chat-sep-line:    rgba(0,0,0,.1);
  --chat-sep-text:    rgba(0,0,0,.4);
  --chat-input-bg:    #ffffff;
  --chat-input-bdr:   rgba(0,0,0,.14);
  --chat-ph-color:    rgba(0,0,0,.35);
  --chat-dim:         rgba(0,0,0,.05);
  --chat-dim-hover:   rgba(0,0,0,.08);
  --chat-muted-text:  rgba(0,0,0,.45);
  --chat-send-dis:    rgba(0,0,0,.3);
  --chat-reply-close: rgba(0,0,0,.12);
  --chat-empty-ico:   rgba(0,0,0,.25);
  --chat-scroll-thumb:rgba(0,0,0,.15);
  --chat-overlay:     rgba(0,0,0,.35);
}

/* ── Theme transition ─────────────────────────────────── */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition: background-color .2s ease, color .2s ease,
              border-color .2s ease, box-shadow .2s ease !important;
}

/* ── Theme toggle button ──────────────────────────────── */
.theme-btn {
  background: none; border: none; color: var(--muted);
  padding: 0; border-radius: 0; cursor: pointer; font-size: 16px; line-height: 1;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  min-width: 34px; min-height: 34px; transition: color .15s;
}
.theme-btn:hover { color: var(--accent); }

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--font); -webkit-font-smoothing: antialiased;
  font-size: 14px; overscroll-behavior: none; overflow-x: clip;
}

/* ── Global scrollbar — тонкие полупрозрачные вместо OS-дефолтного ── */
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent; }
[data-theme="light"] * { scrollbar-color: rgba(0,0,0,.15) transparent; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) * { scrollbar-color: rgba(0,0,0,.15) transparent; }
}
/* WebKit (Chrome, Safari, Edge) */
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
[data-theme="light"] *::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); }
[data-theme="light"] *::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.25); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) *::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); }
  :root:not([data-theme="dark"]) *::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.25); }
}
input, select, button { font-family: var(--font); }

/* ── Focus visible ────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ── ANIMATED BORDER SHIMMER ──────────────────────────── */
@keyframes _bsh { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@keyframes _bsv { 0% { transform: translateY(-100%); } 100% { transform: translateY(300%); } }

/* card: bottom border shimmer (::after used by loading skeleton → use ::before) */
.card::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 45%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(247,166,0,.5), transparent);
  animation: _bsh 7s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}
.card.loading::before { display: none; }

/* card-hdr: bottom border shimmer */
.card-hdr { position: relative; overflow: hidden; }
.card-hdr::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 40%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(247,166,0,.35), transparent);
  animation: _bsh 9s ease-in-out infinite 1.5s;
  pointer-events: none;
  z-index: 2;
}

/* chart-wrap: bottom border shimmer (::before = loading bar → use ::after) */
#chart-wrap::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 35%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(247,166,0,.55), transparent);
  animation: _bsh 11s ease-in-out infinite 3s;
  pointer-events: none;
  z-index: 2;
}

/* wb (bot status block): left border vertical shimmer */
.wb { position: relative; overflow: hidden; }
.wb::after {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 3px; height: 45%;
  background: linear-gradient(180deg, transparent, rgba(247,166,0,.75), transparent);
  animation: _bsv 5s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

/* info-box: left border vertical shimmer */
.info-box { position: relative; overflow: hidden; }
.info-box::after {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 3px; height: 45%;
  background: linear-gradient(180deg, transparent, rgba(247,166,0,.65), transparent);
  animation: _bsv 6s ease-in-out infinite 2s;
  pointer-events: none;
  z-index: 2;
}

/* disable all shimmers in light mode */
[data-theme="light"] .card::before,
[data-theme="light"] .card-hdr::after,
[data-theme="light"] #chart-wrap::after,
[data-theme="light"] .wb::after,
[data-theme="light"] .info-box::after { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .card::before,
  :root:not([data-theme="dark"]) .card-hdr::after,
  :root:not([data-theme="dark"]) #chart-wrap::after,
  :root:not([data-theme="dark"]) .wb::after,
  :root:not([data-theme="dark"]) .info-box::after { display: none; }
}

/* ── CHART LOADING BAR ────────────────────────────────── */
@keyframes chartScan { 0% { left: -60%; } 100% { left: 100%; } }
#chart-wrap { position: relative; }
#chart-wrap.chart-loading::before {
  content: '';
  position: absolute;
  top: 0; left: -60%; width: 60%;
  height: 2px;
  z-index: 10;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: chartScan 1.0s ease-in-out infinite;
}

/* ── APP SHELL ────────────────────────────────────────── */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
#app { display: flex; flex-direction: column; min-height: 100vh; animation: pageFadeIn .2s ease-out; }
.main-content {
  flex: 1;
  padding-bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(247,166,0,.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 80% 80%, rgba(59,130,246,.05) 0%, transparent 60%);
}
[data-theme="light"] .main-content { background: none; }
.container { padding: 12px; max-width: 100%; }
/* page-grid: на мобиле flex-column с gap, на десктопе 2-колонный grid */
.page-grid { display: flex; flex-direction: column; gap: 12px; }

/* ── Balance page layout (2-col на desktop, flex-col на mobile) ── */
.bal-layout { display: flex; flex-direction: column; gap: 12px; }
.bal-left   { display: flex; flex-direction: column; gap: 12px; }

/* ── DASHBOARD LAYOUT ─────────────────────────────────── */
.dash-main {
  flex: 1;
  padding-bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
}
@media (min-width: 768px) {
  .dash-main { margin-left: var(--sidebar-w); padding-bottom: 24px; }
  .dash-inner { max-width: 1160px; margin: 0 auto; padding: 16px; }
}
.dash-inner { padding: 1px; display: flex; flex-direction: column; gap: 12px; }

/* ── PTR ──────────────────────────────────────────────── */
@keyframes ptr-spin { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ── CARD ─────────────────────────────────────────────── */
.card {
  position: relative;
  overflow: clip;
  /* background: var(--card-bg); */
  /* border: 1px solid var(--card-border); */
  /* border-radius: 0; */
  padding: 5px 16px;
  /* box-shadow: 0 2px 12px var(--card-shadow); */
}
.card + .card { margin-top: 10px; }

/* ── COLLAPSIBLE CARD ─────────────────────────────────── */
.card-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--card-border);
  font-size: 13px; font-weight: 600; color: var(--text);
}
.card-hdr:hover { background: var(--metric-bg); }
.chevron { margin-left: auto; font-size: 16px; color: var(--muted); transition: transform .25s ease; }
.chevron.open { transform: rotate(180deg); }
.card-body { overflow: hidden; transition: max-height .25s ease, opacity .2s ease; max-height: 3000px; opacity: 1; }
.card-body.collapsed { max-height: 0; opacity: 0; pointer-events: none; }
.sh-chevron { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px 4px; display: flex; align-items: center; transition: color .15s; }
.sh-chevron:hover { color: var(--text); }
.sh-chevron svg { transition: transform .25s ease; }
.sh-chevron.open svg { transform: rotate(180deg); }

/* ── SECTION HEADER ───────────────────────────────────── */
.sh { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--item-border); }
.sh-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sh-tip { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.sh-badge { margin-left: auto; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--ac-d); color: var(--accent); }
.sh-refresh { margin-left: auto; font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 3px 7px; border-radius: 0; transition: color .15s, background .15s; }
.sh-refresh:hover { color: var(--accent); background: var(--ac-d); }

/* ── PAGE HEADER ──────────────────────────────────────── */
.page-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.page-hdr-title { font-size: 13px; font-weight: 700; color: var(--text); }
.page-hdr-badge { font-size: 11px; font-weight: 700; background: var(--ac-d); color: var(--accent); padding: 2px 8px; border-radius: 10px; }

/* ── CHART ────────────────────────────────────────────── */
#chart-wrap {
  /* background: var(--card-bg); */
  /* border: 1px solid var(--card-border); */
  /* border-radius: 0; */
  overflow: hidden;
  /* box-shadow: 0 2px 12px var(--card-shadow); */
}
#chart-wrap.maximized { position: fixed; inset: 0; z-index: 150; border-radius: 0; border: none; }
#chart-wrap.maximized #chart-container { height: calc(100vh - 44px) !important; }
#chart-wrap .ch-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: relative;
}
#chart-wrap .ch-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 8%, rgba(247,166,0,.18) 25%, rgba(247,166,0,.48) 50%, rgba(247,166,0,.18) 75%, transparent 92%);
  pointer-events: none;
}
#chart-wrap .ch-sym { display: inline-flex; align-items: center; line-height: 1; white-space: nowrap; flex-shrink: 0; }
#chart-wrap .ch-tf  { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.ch-scroll { display: flex; flex-wrap: nowrap; align-items: center; gap: 5px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; min-width: 0; flex: 1 1 0%; }
.ch-scroll::-webkit-scrollbar { display: none; }
.ch-scroll > * { flex-shrink: 0; white-space: nowrap; }
.ch-sep { width: 1px; height: 14px; background: rgba(255,255,255,.1); flex-shrink: 0; margin: 0 2px; }
[data-theme="light"] .ch-sep { background: rgba(0,0,0,.12); }
#chart-container { height: 320px; touch-action: none; position: relative; overflow: hidden; }
#chart-container.hidden { height: 0 !important; overflow: hidden; }
/* Sticky chart + height reduction on scroll — все платформы (мобайл и Windows PWA) */
#chart-wrap {
  position: sticky;
  top: var(--top-h);
  z-index: 55;
  border-bottom: 1px solid transparent;
  transition: box-shadow .28s, border-bottom-color .28s;
  will-change: height;
}
#chart-container {
  will-change: height;
}
#chart-wrap.chart-pinned {
  box-shadow: 0 6px 28px rgba(0,0,0,.55);
  border-bottom-color: var(--border);
}
#chart-wrap.chart-pinned #macd-container,
#chart-wrap.chart-pinned #pctb-container { display: none !important; }
#chart-loader {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #000000; gap: 10px; pointer-events: none;
}
[data-theme="light"] #chart-loader { background: #f4f7fc; }
#chart-loader[hidden] { display: none; }
#chart-loader-sym { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: .02em; opacity: .85; }
.chart-loader-dots { display: flex; gap: 5px; }
.chart-loader-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: _chartDot 1.2s ease-in-out infinite; }
.chart-loader-dots span:nth-child(2) { animation-delay: .2s; }
.chart-loader-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes _chartDot { 0%,80%,100% { transform: scale(.6); opacity: .3; } 40% { transform: scale(1); opacity: 1; } }
/* MACD — только визуальный виджет, touch блокируется (пан/зум управляется main-chart) */
#macd-container canvas { pointer-events: none; }
.price-dec-btn {
  background: var(--s3); border: none; color: var(--muted);
  padding: 3px 7px; border-radius: 4px; cursor: pointer;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
  transition: all .15s; letter-spacing: .03em;
}
.price-dec-btn:hover { background: var(--ac-d); color: var(--accent); }
/* Theme segmented control (Settings page) */
.theme-seg { display: flex; gap: 6px; }
.theme-seg-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 8px; border-radius: 0; border: 1.5px solid var(--border); background: var(--s2); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .18s; }
.theme-seg-btn:hover { border-color: var(--accent); color: var(--text); }
.theme-seg-btn.active { border-color: var(--accent); background: var(--ac-d); color: var(--accent); }
.theme-seg-icon { font-size: 16px; line-height: 1; }

/* TF pill-group */
.ch-tf-group {
  display: flex;
  align-items: center;
  background: var(--s3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
  flex-shrink: 0;
}
.ch-tf-btn {
  background: none; border: none; color: var(--muted);
  padding: 2px 8px; border-radius: 4px;
  cursor: pointer; font-size: 11px; font-weight: 700;
  flex-shrink: 0; transition: all .15s;
}
.ch-tf-btn.on {
  background: var(--accent); color: #000;
  box-shadow: 0 1px 8px rgba(247,166,0,.55), 0 0 18px rgba(247,166,0,.18);
}
.ch-tf-btn:not(.on):hover { color: var(--text); background: var(--border); }

/* Indicator buttons — compact pill style */
.ind-btn {
  background: var(--s3); border: 1px solid transparent; color: var(--muted);
  padding: 3px 7px; border-radius: 4px;
  cursor: pointer; font-size: 10px; font-weight: 700;
  flex-shrink: 0; transition: all .15s; letter-spacing: .03em;
  position: relative;
}
.ind-btn.on {
  color: var(--accent); background: var(--ac-d);
  border-color: rgba(247,166,0,.32);
  box-shadow: 0 0 10px rgba(247,166,0,.18), inset 0 1px 0 rgba(247,166,0,.12);
  text-shadow: 0 0 10px rgba(247,166,0,.5);
}
.ind-btn:not(.on):hover { color: var(--text); background: var(--border); border-color: var(--border); }
/* .eq-spark removed (sparklines replaced by unified chart tabs) */

.ind-btn-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; min-width: 0; flex-shrink: 1; }
.ind-btn-row::-webkit-scrollbar { display: none; }
.ind-btn-row > * { flex-shrink: 0; white-space: nowrap; }

/* ── BALANCE ──────────────────────────────────────────── */
.bal-total-card {
  /* background: var(--s2); */
  /* border: 1px solid rgba(247,166,0,.25); */
  /* border-radius: 0; */
  margin-bottom: 14px;
  min-height: 80px;
  overflow: hidden;
}
.bal-hdr { display: flex; align-items: center; gap: 10px; padding: 5px; cursor: pointer; user-select: none; }
.bal-hdr:hover .bal-toggle-btn { border-color: var(--accent); color: var(--accent); }
.bal-hdr-main { flex: 1; min-width: 0; }
.bal-total-label { font-size: 11px; font-weight: 700; letter-spacing: .07em; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.bal-total-val   { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.bal-total-sub   { font-size: 12px; color: var(--muted); margin-top: 6px; }
.bal-toggle-btn {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--s3, rgba(255,255,255,.04)); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.bal-toggle-btn svg { transition: transform .25s ease; }
.bal-toggle-btn.open svg { transform: rotate(180deg); }
/* Collapsible grid */
.bal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  /* padding: 0 16px 16px; */
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .35s ease, opacity .25s ease, padding .35s ease;
  pointer-events: none;
}
.bal-grid.open { max-height: 4000px; opacity: 1; pointer-events: auto; }
@media (min-width: 600px) { .bal-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .bal-grid { grid-template-columns: repeat(4, 1fr); } }
.bal-asset-card {
  background: var(--card-bg);
  /* border: 1px solid var(--card-border); */
  /* border-radius: 0; */
  padding: 10px;
  /* transition: border-color .15s; */
}
.bal-asset-card:hover { border-color: rgba(255,255,255,.1); }
.bal-asset-top  { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bal-asset-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
  color: #fff; background: var(--asset-color, var(--s3));
}
.bal-asset-info { flex: 1; min-width: 0; }
.bal-asset-sym  { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.1; }
.bal-asset-name { font-size: 11px; color: var(--muted); margin-top: 1px; }
.bal-asset-usd  { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -.2px; font-variant-numeric: tabular-nums; }
.bal-asset-divider { height: 1px; background: var(--border); margin-bottom: 8px; }
.bal-asset-amounts { display: flex; flex-direction: column; gap: 4px; }
.bal-asset-row  { display: flex; justify-content: space-between; align-items: baseline; }
.bal-asset-lbl  { font-size: 11px; color: var(--muted); }
.bal-asset-num  { font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── EQUITY CURVE ─────────────────────────────────────── */
.eq-card { padding: 14px; margin-bottom: 14px; }
.eq-period-row { display: flex; gap: 5px; margin-bottom: 10px; }
.eq-period-btn {
  background: var(--s3); border: none; color: var(--muted);
  padding: 3px 11px; border-radius: 0;
  cursor: pointer; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  transition: all .15s;
}
.eq-period-btn.on { background: var(--ac-d); color: var(--accent); }
.eq-period-btn:not(.on):hover { background: var(--border); color: var(--text); }
.eq-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 480px) { .eq-stats { grid-template-columns: repeat(3, 1fr); } }
.eq-stat { text-align: center; }
.eq-stat-val { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.eq-stat-lbl { font-size: 10px; color: var(--muted); margin-top: 2px; font-weight: 600; letter-spacing: .04em; }
.eq-chart-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.eq-tab-btn {
  background: var(--s3); border: none; color: var(--muted);
  padding: 3px 9px; border-radius: 0;
  cursor: pointer; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  transition: all .15s; white-space: nowrap;
}
.eq-tab-btn.on { background: var(--ac-d); color: var(--accent); }
.eq-tab-btn:not(.on):hover { background: var(--border); color: var(--text); }
.eq-canvas-wrap { width: 100%; margin-bottom: 0; overflow: hidden; }
.eq-canvas-wrap canvas { display: block; width: 100%; }

/* ── TRADE FORM ───────────────────────────────────────── */
.ob-trade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.trade-form { display: flex; flex-direction: column; gap: 10px; }
.side-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-btn { padding: 11px; border: 1px solid var(--border); /* border-radius: 0; */ background: var(--s2); color: var(--muted); font-weight: 600; cursor: pointer; font-size: 10px; transition: all .15s; text-align: center; }
.side-btn:active { transform: scale(.98); }
.side-btn.buy.on  { border-color: rgba(14,203,129,.5); color: var(--green); background: rgba(14,203,129,.08); }
.side-btn.sell.on { border-color: rgba(246,70,93,.5);  color: var(--red);   background: rgba(246,70,93,.08); }
.field-label { font-size: 9px; color: var(--muted); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.inp, .sel {
  width: 100%; padding: 10px 12px;
  background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: 0; color: var(--text); font-size: 9.5px; outline: none;
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none;
}
.inp:focus, .sel:focus { border-color: rgba(247,166,0,.6); box-shadow: 0 0 0 2px rgba(247,166,0,.1); }
.inp::placeholder { color: var(--muted); }
.trade-btn { padding: 13px; border: none; border-radius: 0; font-size: 14px; font-weight: 700; cursor: pointer; transition: opacity .15s, transform .1s; letter-spacing: .02em; min-height: 44px; width: 100%; }
.trade-btn:active { transform: scale(.98); opacity: .9; }
.trade-btn.buy  { background: var(--green); color: #fff; }
.trade-btn.sell { background: var(--red);   color: #fff; }

/* ── ORDER BOOK ───────────────────────────────────────── */
.ob-wrap { font-size: 10px; /* border: 1px solid var(--border); */ border-radius: 0; overflow: hidden; }
.ob-hdr { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 5px 8px; /* background: var(--s2); */ /* border-bottom: 1px solid var(--border); */ }
.ob-hdr span { font-size: 10px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.ob-hdr span:not(:first-child) { text-align: right; }
.ob-row { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 1.5px 8px; position: relative; overflow: hidden; cursor: pointer; }
.ob-row::before { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: var(--bar, 0%); opacity: .22; pointer-events: none; }
.ob-row.ob-ask::before { background: var(--green); }
.ob-row.ob-bid::before { background: var(--red); }
.ob-row:hover { background: var(--s3); }
.ob-row.ob-ask .ob-p { color: #0ecb81; font-weight: 600; }
.ob-row.ob-bid .ob-p { color: #f6465d; font-weight: 600; }
.ob-row.ob-wall .ob-s { font-weight: 800; }
.ob-row.ob-wall::before { opacity: .45; }
.ob-row.ob-ask.ob-bbo { background: rgba(14,203,129,.06); }
.ob-row.ob-bid.ob-bbo { background: rgba(246,70,93,.06); }
.ob-s, .ob-t { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.ob-mid { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--s2); }
.ob-mid-price { font-size: 14px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.ob-spread { font-size: 10px; color: var(--muted); }
.ob-obi { font-size: 10px; margin-left: auto; white-space: nowrap; }
.ob-dom { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-top: 1px solid var(--border); background: var(--s2); overflow: hidden; }
.ob-dom-b { color: #f6465d; font-size: 9px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ob-dom-s { color: #0ecb81; font-size: 9px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ob-dom-bar { flex: 1; height: 8px; display: flex; border-radius: 2px; overflow: hidden; min-width: 30px; }

/* ── ITEM LIST ────────────────────────────────────────── */
.item-list { display: flex; flex-direction: column; gap: 6px; }
.item-empty { text-align: center; color: var(--muted); padding: 28px 0; font-size: 13px; }
.item-row { display: flex; align-items: center; gap: 12px; padding: 11px 13px; /* border-radius: 0; */ /* background: var(--s2); */ /* border: 1px solid var(--item-border); */ transition: background .15s; }
.item-row:hover { background: var(--s3); }
.item-badge { flex-shrink: 0; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; min-width: 52px; text-align: center; }
.item-badge.buy   { background: var(--green-d); color: var(--green); }
.item-badge.sell  { background: var(--red-d);   color: var(--red);   }
.item-badge.long  { background: var(--green-d); color: var(--green); }
.item-badge.short { background: var(--red-d);   color: var(--red);   }
.item-body  { flex: 1; min-width: 0; }
.item-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta  { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.item-right { flex-shrink: 0; text-align: right; }
.item-pnl   { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.item-pnl.pos { color: var(--green); }
.item-pnl.neg { color: var(--red); }
.item-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.x-btn { padding: 5px 10px; background: none; border: 1px solid rgba(246,70,93,.35); border-radius: 0; color: var(--red); cursor: pointer; font-size: 11px; font-weight: 600; transition: background .15s; flex-shrink: 0; min-height: 44px; display: flex; align-items: center; }
.x-btn:hover { background: var(--red-d); }

/* ── ALERTS ───────────────────────────────────────────── */
.al-in { flex: 1; min-width: 60px; padding: 10px 12px; background: transparent; border: none; border-bottom: 1.5px solid var(--input-border); border-radius: 0; color: var(--text); font-size: 15px; outline: none; -webkit-appearance: none; transition: border-color .15s, box-shadow .15s; }
.al-in:focus { border-bottom-color: rgba(247,166,0,.7); box-shadow: 0 2px 0 0 rgba(247,166,0,.12); }
.al-in::placeholder { color: var(--muted); }
.al-sel { padding: 10px 10px; background: transparent; border: none; border-bottom: 1.5px solid var(--input-border); border-radius: 0; color: var(--text); font-size: 15px; outline: none; -webkit-appearance: none; }
.add-btn { padding: 10px 16px; background: var(--accent); border: none; border-radius: 0; color: #000; font-size: 14px; cursor: pointer; white-space: nowrap; font-weight: 700; transition: opacity .15s, transform .1s; min-height: 44px; }
.add-btn:hover { opacity: .88; }
.add-btn:active { transform: scale(.97); }
.al-list { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.al-item { display: flex; align-items: center; gap: 10px; padding: 10px 13px; background: var(--s2); border: none; border-bottom: 1px solid var(--item-border); border-radius: 0; font-size: 13px; }
.al-sym { font-weight: 700; min-width: 38px; }
.al-dir { color: var(--muted); }
.al-val { flex: 1; font-weight: 600; }

/* ── WORKER BANNER ────────────────────────────────────── */
.wb { padding: 14px 16px; /* border-radius: 0; */ /* background: var(--s2); */ /* border: 1px solid var(--item-border); */ border-left: 3px solid var(--muted); transition: border-left-color .3s; }
.wb-head   { display: flex; align-items: center; gap: 9px; min-height: 28px; }
.wb-icon   { font-size: 20px; line-height: 1; flex-shrink: 0; display: flex; align-items: center; }
.wb-status { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; line-height: 1.3; }
.wb-scan   { margin-left: auto; flex-shrink: 0; display: flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 6px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); }
.wb-scan-lbl { font-size: 11px; color: var(--muted); font-weight: 500; }
.wb-scan-cd  { font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; min-width: 34px; }
.wb-detail { margin-top: 10px; }
.wb-ctx    { font-size: 11px; color: var(--muted); margin-bottom: 8px; line-height: 1.5; }
/* Chip row */
.wb-chips     { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wb-sym-name  { font-size: 13px; font-weight: 800; color: var(--text); letter-spacing: .01em; }
.wb-sep       { font-size: 10px; color: var(--border); }
.wb-chip      { display: inline-flex; align-items: center; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 5px; white-space: nowrap; line-height: 1.7; letter-spacing: .02em; }
.wb-chip.tf   { background: rgba(255,255,255,.05); color: var(--muted); border: 1px solid rgba(255,255,255,.08); }
.wb-chip.fut  { background: rgba(247,166,0,.1); color: var(--accent); border: 1px solid rgba(247,166,0,.22); }
.wb-chip.spot { background: rgba(14,203,129,.09); color: var(--green); border: 1px solid rgba(14,203,129,.2); }
.wb-chip.risk      { background: rgba(255,255,255,.04); color: var(--muted); border: 1px solid rgba(255,255,255,.07); }
.wb-chip.auto-mode { background: rgba(99,179,237,.12); color: #63b3ed; border: 1px solid rgba(99,179,237,.28); letter-spacing: .06em; }

/* ── STAT GRID ────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.stat-card {
  background: var(--s2);
  border: 1px solid var(--item-border);
  /* border-radius: 0; */
  padding: 12px 14px;
  transition: background .15s;
}
.stat-card:hover { background: var(--s3); }
.stat-card .lbl { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-card .val { font-size: 16px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ── SETTINGS ─────────────────────────────────────────── */
.save-btn { padding: 11px 20px; background: var(--accent); border: none; border-radius: 0; color: #000; font-size: 14px; cursor: pointer; font-weight: 700; transition: opacity .15s, transform .1s; min-height: 44px; }
.save-btn:hover { opacity: .88; }
.save-btn:active { transform: scale(.98); }
.danger-btn { padding: 11px 20px; background: transparent; border: 1px solid rgba(246,70,93,.35); border-radius: 0; color: var(--red); font-size: 14px; cursor: pointer; font-weight: 600; width: 100%; transition: background .15s, border-color .15s; min-height: 44px; }
.danger-btn:hover { background: var(--red-d); border-color: rgba(246,70,93,.6); }
.danger-btn:active { transform: scale(.98); }

/* ── ACTION ROW BUTTON ───────────────────────────────── */
.action-row-btn {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 13px 14px; border-radius: 0; cursor: pointer;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  text-align: left; transition: background .15s, border-color .15s, transform .1s;
}
.action-row-btn:hover  { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.13); }
.action-row-btn:active { transform: scale(.985); }
.action-row-btn--danger { background: rgba(246,70,93,.06); border-color: rgba(246,70,93,.2); }
.action-row-btn--danger:hover { background: rgba(246,70,93,.11); border-color: rgba(246,70,93,.35); }
.arb-icon {
  font-size: 20px; width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.arb-icon-muted { background: rgba(255,255,255,.07); }
.arb-icon-red   { background: rgba(246,70,93,.12); }
.arb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.arb-label { font-size: 14px; font-weight: 600; color: var(--text); }
.action-row-btn--danger .arb-label { color: var(--red); }
.arb-sub  { font-size: 11px; color: var(--muted); }
.arb-arrow { font-size: 20px; color: var(--muted); line-height: 1; margin-left: 4px; }

/* ── MSG ──────────────────────────────────────────────── */
.msg { font-size: 12px; padding: 8px 12px; border-radius: 6px; display: none; }
.msg.ok  { background: var(--msg-ok-bg);  color: var(--green); border: 1px solid rgba(14,203,129,.25); }
.msg.err { background: var(--msg-err-bg); color: var(--red);   border: 1px solid rgba(246,70,93,.25); }

/* ── DIVIDER / INFO BOX ───────────────────────────────── */
.divider  { height: 1px; background: var(--border); margin: 12px 0; }
.info-box { background: var(--s2); border: 1px solid var(--item-border); border-left: 3px solid var(--accent); border-radius: 0; padding: 10px 12px; font-size: 12px; color: var(--muted); line-height: 1.55; }

/* ── TOAST ────────────────────────────────────────────── */
#toast-ct { position: fixed; top: calc(var(--top-h) + 10px); right: 12px; z-index: 1000; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; max-width: 290px; word-break: break-word; animation: tIn .2s ease, tOut .3s 3.5s ease forwards; background: #000; }
.toast.ok     { background: #000; color: var(--green); border: 1px solid rgba(14,203,129,.35); }
.toast.err    { background: #000; color: var(--red);   border: 1px solid rgba(246,70,93,.35); }
.toast.info   { background: #000; color: var(--text);  border: 1px solid var(--border); }
.toast.signal { background: #000; color: var(--text);  border: 1px solid var(--border); border-left: 3px solid var(--accent); cursor: pointer; line-height: 1.5; }
@keyframes tIn  { from{transform:translateX(110%);opacity:0} to{transform:none;opacity:1} }
@keyframes tOut { to{transform:translateX(110%);opacity:0} }

/* ── MODAL ────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: var(--modal-overlay); display: flex; align-items: flex-end; justify-content: center; z-index: 200; backdrop-filter: blur(4px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 0 0; padding: 22px; width: 100%; max-width: 480px; }
.modal h3 { font-size: 15px; margin-bottom: 8px; }
.modal p  { color: var(--muted); font-size: 13px; line-height: 1.55; margin-bottom: 18px; }
.modal-btns { display: flex; gap: 8px; margin-top: 14px; }
.modal-btns button { flex: 1; padding: 12px; border: none; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 700; min-height: 44px; }
.btn-cancel { background: var(--s2); color: var(--text); border: 1px solid var(--border) !important; }
.btn-ok     { background: var(--accent); color: #000; }
.btn-danger { background: var(--red); color: #fff; }

/* ── LOG PANEL ────────────────────────────────────────── */
.log-panel { background: var(--log-bg); /* border: 1px solid var(--border); */ /* border-radius: 0; */ padding: 10px 12px; font-family: var(--font-mono); font-size: 11px; line-height: 1.65; max-height: 240px; overflow-y: auto; color: var(--muted); scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.log-panel::-webkit-scrollbar { width: 4px; }
.log-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.log-line { white-space: pre-wrap; word-break: break-all; padding: 1px 0; }
.log-line.ll-trade { color: #0ecb81; }
.log-line.ll-close { color: #10b981; }
.log-line.ll-sig   { color: #f59e0b; }
.log-line.ll-err   { color: #f6465d; }
.log-line.ll-skip  { color: #4a5a72; }
.log-line.ll-sys   { color: #f7a600; opacity:.8; }

/* ── INDICATOR BARS (last analysis) ──────────────────── */
.la-bar-row   { display:flex; align-items:center; gap:8px; margin-bottom:7px; }
.la-bar-label { font-size:11px; font-weight:600; color:var(--muted); width:70px; flex-shrink:0; }
.la-bar-track { flex:1; height:5px; background:var(--input-border); border-radius: 3px; overflow:hidden; }
.la-bar-fill  { height:100%; border-radius: 3px; transition: width .4s ease; }
.la-bar-fill.ok  { background: var(--green); }
.la-bar-fill.no  { background: var(--red); }
.la-bar-fill.neu { background: var(--accent); }
.la-bar-val   { font-size:11px; font-weight:700; width:48px; text-align:right; flex-shrink:0; font-variant-numeric: tabular-nums; }
.la-bar-val.ok  { color: var(--green); }
.la-bar-val.no  { color: var(--red); }
.la-bar-val.neu { color: var(--accent); }
.la-badge-long  { font-size:11px;font-weight:700;padding:2px 8px;border-radius: 4px;background:var(--green-d);color:var(--green);border:1px solid rgba(14,203,129,.25); }
.la-badge-short { font-size:11px;font-weight:700;padding:2px 8px;border-radius: 4px;background:var(--red-d);color:var(--red);border:1px solid rgba(246,70,93,.25); }
.la-badge-none  { font-size:11px;font-weight:700;padding:2px 8px;border-radius: 4px;background:var(--metric-bg);color:var(--muted);border:1px solid var(--border); }
.scan-mode-badge { font-size:10px;font-weight:600;padding:2px 6px;border-radius: 4px;letter-spacing:.02em; }
.scan-mode-badge.spot    { background:rgba(14,203,129,.1);color:var(--green);border:1px solid rgba(14,203,129,.2); }
.scan-mode-badge.futures { background:rgba(247,166,0,.1);color:var(--accent);border:1px solid rgba(247,166,0,.25); }
.scan-conf { font-size:12px;font-weight:700;white-space:nowrap; }

/* ── INDICATOR GRID ───────────────────────────────────── */
.ind-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 5px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.ind-card {
  position: relative;
  cursor: pointer;
  padding: 7px 8px 6px 10px;
  border-radius: 0;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.07);
  border-left: 2.5px solid rgba(255,255,255,.15);
  transition: background .12s, border-color .12s;
  overflow: hidden;
}
.ind-card:hover { background: rgba(255,255,255,.07); }
.ind-card.ok  { border-left-color: rgba(14,203,129,.8);  background: rgba(14,203,129,.055); border-color: rgba(14,203,129,.18); }
.ind-card.no  { border-left-color: rgba(246,70,93,.8);   background: rgba(246,70,93,.055);  border-color: rgba(246,70,93,.18);  }
.ind-card.neu { border-left-color: rgba(247,166,0,.7);   background: rgba(247,166,0,.045);  border-color: rgba(247,166,0,.18);  }
.ind-card.ok:hover  { background: rgba(14,203,129,.09); }
.ind-card.no:hover  { background: rgba(246,70,93,.09);  }
.ind-card.neu:hover { background: rgba(247,166,0,.075); }
.ind-cname {
  font-size: 9.5px; font-weight: 700; color: var(--muted);
  letter-spacing: .035em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.ind-cval {
  font-size: 12px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.ind-card.ok  .ind-cval { color: var(--green); }
.ind-card.no  .ind-cval { color: var(--red); }
.ind-card.neu .ind-cval { color: var(--accent); }
.ind-card > div:nth-child(3) {
  font-size: 9px; color: var(--muted); margin-top: 2px; opacity: .65;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Status dot (top-right corner) */
.ind-card::before {
  content: '';
  position: absolute; top: 6px; right: 6px;
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,.18);
}
.ind-card.ok::before  { background: rgba(14,203,129,.9);  box-shadow: 0 0 4px rgba(14,203,129,.4); }
.ind-card.no::before  { background: rgba(246,70,93,.9);   box-shadow: 0 0 4px rgba(246,70,93,.4);  }
.ind-card.neu::before { background: rgba(247,166,0,.85);  box-shadow: 0 0 4px rgba(247,166,0,.35); }

.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.filter-item { background: var(--s2); border: none; border-bottom: 1px solid var(--item-border); border-right: 1px solid var(--item-border); border-radius: 0; padding: 9px 11px; }
.filter-item .f-name { font-size: 11px; font-weight: 700; color: var(--accent); }
.filter-item .f-desc { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

/* ── EQUITY CURVE (history) ───────────────────────────── */
.equity-wrap { margin-bottom: 12px; }
.equity-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.equity-stat { background: var(--s2); border: none; border-bottom: 1px solid var(--item-border); border-right: 1px solid var(--item-border); border-radius: 0; padding: 9px 11px; }
.equity-stat .lbl { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.equity-stat .val { font-size: 14px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.equity-svg-wrap { background: var(--equity-bg); border: none; border-bottom: 1px solid var(--item-border); border-radius: 0; padding: 8px; overflow: hidden; }
.equity-svg-wrap svg { display: block; width: 100%; }

/* ── SCANNER SECTION CARDS ────────────────────────────── */
.sc-card {
  background: rgba(30,35,41,.55);
  /* backdrop-filter: blur(12px); */
  -webkit-backdrop-filter: blur(12px);
  /* border: 1px solid rgba(255,255,255,.07); */
  /* border-radius: 0; */
  overflow: hidden;
  /* box-shadow: 0 4px 24px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.06); */
}
[data-theme="light"] .sc-card {
  background: rgba(255,255,255,.72);
  border-color: rgba(0,0,0,.08);
  box-shadow: 0 4px 24px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.9);
}
.sc-card + .sc-card { margin-top: 10px; }
/* Внутри page-grid отступы управляются gap — убираем все margin между дочерними */
.page-grid > * { margin-top: 0 !important; }
.sc-hdr { display: flex; align-items: center; gap: 8px; padding: 12px 16px; cursor: pointer; user-select: none; border-bottom: 1px solid rgba(255,255,255,.06); transition: background .15s; }
.sc-hdr:hover { background: rgba(255,255,255,.03); }
[data-theme="light"] .sc-hdr { border-bottom-color: rgba(0,0,0,.06); }
.sc-hdr-icon { display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.sc-hdr-title { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.sc-hdr-cnt { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 0; background: var(--ac-d); color: var(--accent); min-width: 20px; text-align: center; }
.sc-hdr-cnt.zero { background: rgba(255,255,255,.06); color: var(--muted); }
.sc-hdr-chev { color: var(--muted); font-size: 13px; transition: transform .22s ease; margin-left: 2px; }
.sc-hdr-chev.open { transform: rotate(180deg); }
.sc-body { overflow: hidden; transition: max-height .35s ease, opacity .25s ease; max-height: 30000px; opacity: 1; }
.sc-body.collapsed { max-height: 0; opacity: 0; pointer-events: none; }
.sc-inner { padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.sc-empty { padding: 20px 14px; text-align: center; font-size: 12px; color: var(--muted); }

/* ── SCANNER CARDS ────────────────────────────────────── */
.scan-grid { display: flex; flex-direction: column; gap: 6px; }
.scan-card {
  background: var(--s1);
  /* border: 1px solid var(--item-border); */
  /* border-radius: 0; */
  /* padding: 12px 14px; */
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.scan-card:hover { background: var(--s3); border-color: var(--border); box-shadow: 0 2px 12px rgba(0,0,0,.15); }
.scan-card.sig-long  { border-left: 3px solid var(--green); background: var(--green-d); }
.scan-card.sig-short { border-left: 3px solid var(--red);   background: var(--red-d); }
.scan-signal-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .06em; padding: 3px 14px 2px; display: flex; align-items: center; gap: 6px; }
.scan-signal-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.scan-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px 0; }
.scan-card-sym { font-size: 15px; font-weight: 700; flex: 1; min-width: 0; }
.scan-card-price { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.scan-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 0 14px; }
.scan-metric { background: var(--metric-bg); border-radius: 0; padding: 6px 8px; }
.scan-metric-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.scan-metric-val { font-size: 13px; font-weight: 700; margin-top: 2px; }
.scan-trade-btn { flex: 1; height: 34px; padding: 0 14px; border: 1px solid var(--accent); border-radius: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 600; transition: opacity .15s, filter .1s; white-space: nowrap; }
.scan-trade-btn:hover { filter: brightness(1.1); }
.scan-trade-btn:active { opacity: .85; }
.scan-add-btn { flex: 1; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 500; transition: border-color .15s, color .15s; white-space: nowrap; }
.scan-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.scan-add-btn:disabled { opacity: .4; cursor: default; }
.scan-remove-btn { width: 34px; height: 34px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 0; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: border-color .15s, color .15s; }
.scan-remove-btn:hover { border-color: rgba(246,70,93,.5); color: var(--red); }
.scan-remove-btn:disabled { opacity: .4; cursor: default; }
.scan-sig-row { display: flex; align-items: center; gap: 6px; padding: 0 14px; margin-top: -2px; }
.scan-card-actions { display: flex; gap: 6px; padding: 2px 14px 10px; }
.scan-empty { text-align: center; color: var(--muted); padding: 28px 0; font-size: 13px; }
.scan-card-err { font-size: 12px; color: var(--red); line-height: 1.4; padding: 0 14px; }
.scan-spark { border-radius: 0; overflow: hidden; margin: 0; position: relative; }
.scan-spark-click { cursor: pointer; transition: opacity .15s; }
.scan-spark-click:hover { opacity: .78; }
.scan-spark-click::after { content: '⛶'; position:absolute; top:4px; right:6px; font-size:12px; color:rgba(255,255,255,.55); pointer-events:none; }
.scan-needs { display:flex; align-items:center; flex-wrap:wrap; gap:5px; padding:7px 9px; margin:0 14px; background:rgba(255,255,255,.03); border-radius: 0; border:1px solid rgba(255,255,255,.06); }
.scan-needs-lbl { font-size:10px; font-weight:700; color:var(--muted); letter-spacing:.5px; text-transform:uppercase; margin-right:2px; flex-shrink:0; }
.scan-need-tag { font-size:8px; padding:0px 4px; /* border-radius: 0; */ background:rgba(247,166,0,.1); color:var(--accent); border:0px solid rgba(247,166,0,.2); white-space:nowrap; line-height:1.6; }
.scan-needs-ok { background:rgba(14,203,129,.05); border-color:rgba(14,203,129,.15); gap:6px; }

/* ── LA-STATUS ────────────────────────────────────────── */
.la-status {
  /* background: var(--s2); */
  border-right: 3px solid rgb(247, 166, 0);
  /* border-radius: 0; */
  /* padding: 12px 14px; */
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  /*transition: background .15s, border-color .15s, box-shadow .15s;*/
  /* box-shadow: 0 1px 6px rgba(0,0,0,.1); */
}
.la-status:hover { background: var(--s3); border-color: var(--accent); box-shadow: 0 2px 12px rgba(247,166,0,.12); }
.la-status-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.la-status-score { font-size:13px; font-weight:700; display:flex; align-items:center; gap:5px; }
.la-status-cnt {
  font-size:11px; color:var(--muted);
  background: var(--metric-bg); padding:2px 8px; border-radius: 0;
  border: 1px solid var(--item-border);
}
.la-status-dir {
  font-size:11px; padding:2px 9px; border-radius: 0;
  background: var(--metric-bg); color:var(--muted);
  border:1px solid var(--item-border); font-weight:600; letter-spacing:.03em;
}
.la-status-cd { font-size:10px; color:var(--muted); }
.la-status-cd span { color:var(--accent); font-weight:700; }
.la-needs { display:flex; align-items:center; flex-wrap:wrap; gap:5px; margin-top:10px; padding-top:10px; border-top:1px solid var(--item-border); }
.la-needs-ok { border-top-color:rgba(14,203,129,.15); gap:6px; }
.la-needs-ok-lbl { color:var(--green) !important; }

/* ── COIN ICON ────────────────────────────────────────── */
.ci { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; background: var(--metric-bg); display: flex; align-items: center; justify-content: center; overflow: hidden; border: none; }
.ci img { width: 32px; height: 32px; object-fit: contain; display: block; border-radius: 50%; }
.ci-fb { width: 32px; height: 32px; border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.ci-tb .ci { width: 20px; height: 20px; }
.ci-tb .ci img { width: 20px; height: 20px; }
.ci-tb .ci-fb { width: 20px; height: 20px; font-size: 7px; }

/* ── PASSWORD EYE ─────────────────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap .inp { padding-right: 42px; }
.pw-eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 4px; line-height: 1; transition: color .15s; }
.pw-eye:hover { color: var(--text); }

/* ── TABS ─────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 2px; margin-bottom: 14px; /* background: var(--s2); */ border-radius: 0; padding: 3px; }
.tab-btn { flex: 1; padding: 8px; border: none; /* border-radius: 0; */ background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.tab-btn.on { /* background: var(--s3); */ color: var(--text); border-bottom: 3px solid rgb(247, 166, 0); }
.tab-count { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; background: var(--ac-d); color: var(--accent); min-width: 18px; text-align: center; }
.tab-count.hidden { display: none; }

/* ── SKELETON BASE ────────────────────────────────────── */
.skel-pulse {
  background: linear-gradient(90deg, var(--s2) 25%, var(--s3) 50%, var(--s2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 0;
}
/* Skeleton ind-card (для la-bars) */
.ind-card.skel { pointer-events: none; border-left-color: rgba(255,255,255,.08); background: rgba(255,255,255,.02); }
.ind-card.skel .skel-pulse:first-child  { height: 8px;  width: 65%; margin-bottom: 5px; }
.ind-card.skel .skel-pulse:last-child   { height: 11px; width: 45%; }
/* Skeleton item-row (для ордеров) */
.item-row.skel { pointer-events: none; }
.item-row.skel .skel-badge  { width: 38px; height: 20px; border-radius: 0; flex-shrink: 0; }
.item-row.skel .skel-title  { height: 11px; width: 60%; margin-bottom: 4px; }
.item-row.skel .skel-meta   { height: 9px;  width: 40%; }
/* Skeleton сделок (история + dashboard) */
.trade-row-skel { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.trade-row-skel .skel-badge  { width: 42px; height: 22px; border-radius: 0; flex-shrink: 0; }
.trade-row-skel .skel-body   { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.trade-row-skel .skel-line-a { height: 12px; width: 55%; }
.trade-row-skel .skel-line-b { height: 10px; width: 38%; }
.trade-row-skel .skel-pnl    { width: 52px; height: 20px; border-radius: 0; }
/* Skeleton bal-card */
.bal-card.skel { pointer-events: none; }
.bal-card.skel .skel-pulse:nth-child(1) { height: 13px; width: 48px; margin-bottom: 8px; }
.bal-card.skel .skel-pulse:nth-child(2) { height: 18px; width: 80px; margin-bottom: 5px; }
.bal-card.skel .skel-pulse:nth-child(3) { height: 10px; width: 55px; }
/* Skeleton wb (worker status) */
.wb-skel { display: flex; flex-direction: column; gap: 7px; padding: 4px 0; }
.wb-skel .skel-pulse:nth-child(1) { height: 14px; width: 50%; }
.wb-skel .skel-pulse:nth-child(2) { height: 11px; width: 75%; }
.wb-skel .skel-pulse:nth-child(3) { height: 11px; width: 60%; }

/* ── SKELETON SCAN CARDS ──────────────────────────────── */
.scan-card-skel { pointer-events: none; }
.scan-card-skel .skel-ci  { width:32px; height:32px; border-radius: 50%; flex-shrink:0; }
.scan-card-skel .skel-sym { height:13px; width:48px; }
.scan-card-skel .skel-price { height:11px; width:68px; margin-left:auto; }
.scan-card-skel .skel-m  { height:44px; border-radius: 0; }
.scan-card-skel .skel-act { height:34px; border-radius: 0; flex:1; }

/* ── DESKTOP ──────────────────────────────────────────── */
@media (min-width: 768px) {
  .container { max-width: 1160px; margin: 0 auto; padding: 16px; }
  #chart-container { height: 460px; }
  #chart-container.hidden { height: 0 !important; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }

  /* 2-column page grid */
  .page-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
  }
  .page-grid .col-full { grid-column: 1 / -1; }
  .page-grid .sc-card { align-self: start; }

  /* dashboard 2-col: chart full, then cards split */
  .dash-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
  .dash-inner > #chart-wrap { grid-column: 1 / -1; }
}

/* ── NOTIFICATION PANEL ─────────────────────────────── */
.np-overlay {
  display: none; position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  align-items: flex-end; justify-content: flex-end;
}
.np-panel {
  width: min(380px, 100vw);
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.np-panel--open { transform: translateX(0); }
@media (max-width: 480px) {
  .np-overlay { align-items: flex-end; justify-content: stretch; }
  .np-panel {
    width: 100vw; height: 92dvh;
    border-left: none; border-top: 1px solid var(--border);
    border-radius: 0;
    transform: translateY(100%);
  }
  .np-panel--open { transform: translateY(0); }
}

.np-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.np-title { font-size: 16px; font-weight: 700; color: var(--text); }
.np-close {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 6px;
  border-radius: 6px; transition: color .15s;
}
.np-close:hover { color: var(--text); }

/* Sound toggle row */
.np-sound-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.np-sound-icon { font-size: 18px; color: var(--accent); flex-shrink: 0; }
.np-sound-text { flex: 1; min-width: 0; }
.np-sound-main { font-size: 14px; font-weight: 600; color: var(--text); display: block; }
.np-sound-sub  { font-size: 12px; color: var(--muted); display: block; margin-top: 1px; }

/* iOS-style toggle */
.np-toggle { position: relative; flex-shrink: 0; cursor: pointer; }
.np-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.np-toggle-track {
  display: block; width: 44px; height: 26px; border-radius: 13px;
  background: var(--border); transition: background .2s;
  position: relative;
}
.np-toggle input:checked + .np-toggle-track { background: var(--accent); }
.np-toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.np-toggle input:checked + .np-toggle-track .np-toggle-thumb { left: 21px; }

/* List */
.np-list-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 8px;
  flex-shrink: 0;
}
.np-list-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.np-clear {
  background: none; border: none; font-size: 12px; color: var(--muted);
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
  transition: color .15s;
}
.np-clear:hover { color: var(--red); }
.np-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
.np-loading, .np-empty {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 32px 0;
}

.np-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 8px; border-radius: 6px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: background .12s;
}
.np-item:hover { background: var(--metric-bg); }
.np-ico {
  font-size: 18px; flex-shrink: 0; width: 32px; height: 32px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06);
}
.np-ico-trade { background: rgba(14,203,129,.12); }
.np-ico-chat  { background: rgba(123,97,255,.12); }
.np-ico-scan  { background: rgba(0,174,228,.12); }
.np-ico-alert { background: rgba(247,166,0,.12); }

.np-item-body { flex: 1; min-width: 0; }
.np-item-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.np-item-text  { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-item { cursor: pointer; }
.np-item--expanded .np-item-text { white-space: normal; overflow: visible; text-overflow: unset; }
.np-item-time  { font-size: 10px; color: var(--muted); flex-shrink: 0; margin-top: 2px; }
.np-badge {
  position: absolute; top: 1px; right: 1px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--red, #f6465d); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 16px;
  border-radius: 8px; text-align: center;
  align-items: center; justify-content: center;
  pointer-events: none;
}
.np-show-btn {
  display: block; width: 100%; margin-top: 4px; padding: 8px;
  background: none; border: 1px solid var(--border); border-radius: 0;
  color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.np-show-btn:hover { background: var(--metric-bg); }

/* ── Page loader ───────────────────────────────────────── */
#page-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .38s ease, visibility .38s ease;
}
#page-loader.pl-out { opacity: 0; visibility: hidden; pointer-events: none; }
.pl-wrap  { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.pl-ring  {
  width: 62px; height: 62px; border-radius: 14px;
  background: linear-gradient(135deg, #0ecb81 0%, #2563eb 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 32px rgba(14,203,129,.22);
}
.pl-ring svg { width: 34px; height: 34px; }
.pl-name  { font-size: 14px; font-weight: 800; letter-spacing: .12em; color: rgba(255,255,255,.45); }
[data-theme="light"] .pl-name { color: rgba(0,0,0,.55); }
.pl-bars  { display: flex; gap: 5px; align-items: flex-end; height: 30px; }
.pl-bars span {
  display: block; width: 5px; border-radius: 2px;
  background: var(--accent, #f7a600);
  animation: pl-eq 1s ease-in-out infinite;
}
.pl-bars span:nth-child(1) { height: 10px; animation-delay: 0s; }
.pl-bars span:nth-child(2) { height: 20px; animation-delay: .15s; }
.pl-bars span:nth-child(3) { height: 30px; animation-delay: .30s; }
.pl-bars span:nth-child(4) { height: 20px; animation-delay: .45s; }
.pl-bars span:nth-child(5) { height: 10px; animation-delay: .60s; }
@keyframes pl-eq {
  0%,100% { opacity: .22; transform: scaleY(.45); }
  50%      { opacity: 1;   transform: scaleY(1); }
}
