:root {
  --bg: #0b0e11;
  --panel: #151a21;
  --border: #232a33;
  --text: #e6e9ef;
  --muted: #8b95a5;
  --accent: #f0b90b;
  --up: #26a69a;
  --down: #ef5350;
  --ok: #26a69a;
  --bad: #ef5350;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 13px;
}

.wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.toolbar .group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar .label {
  color: var(--muted);
  margin-right: 4px;
  white-space: nowrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #1b222b;
  color: var(--text);
  padding: 4px 9px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.btn:hover {
  background: #232c37;
  border-color: #313c49;
}

/* 1s недоступен: пары нет на Spot, а на Futures такого интервала нет */
.btn.disabled,
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn.disabled:hover,
.btn:disabled:hover {
  background: transparent;
  border-color: var(--border);
}

.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #12151a;
  font-weight: 600;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Статус соединения */
.status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #1b222b;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status .st-text { display: none; }

.status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.status .st-ping {
  font-size: 11px;
  color: inherit;
  opacity: 0.9;
}

.status.online {
  color: var(--ok);
  border-color: rgba(38, 166, 154, 0.7);
  background: rgba(38, 166, 154, 0.1);
}

.status.offline {
  color: var(--bad);
  border-color: rgba(239, 83, 80, 0.7);
  background: rgba(239, 83, 80, 0.1);
}

.status.pending {
  color: var(--accent);
  border-color: rgba(240, 185, 11, 0.6);
  background: rgba(240, 185, 11, 0.1);
}

/* ---------- price line ---------- */

.pricebar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 0 0 0 14px;
  border-left: 1px solid var(--border);
  flex: 0 0 auto;
  min-width: 0;
}

.pricebar .price {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}

.pricebar .price.up { color: var(--up); }
.pricebar .price.down { color: var(--down); }

.pricebar .meta {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.pricebar .source-tag {
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #b9c2d0;
  border: 1px solid #2b323c;
  background: #151a20;
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
}

.m-pricebar { display: none; }

/* ---------- drawing tools ---------- */

.drawbar {
  flex: 0 0 auto;
  width: 38px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px 4px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
}

.drawbar .label {
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.drawbar .tool-btn,
.drawbar #clearDrawings {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 100%;
  height: 30px;
  flex: 0 0 auto;
  line-height: 1;
}

.drawbar .tool-ico {
  font-size: 16px;
  line-height: 1;
}

.drawbar .tool-txt,
.drawbar .draw-hint {
  display: none;
}

/* ---------- layout: скринер + график ---------- */

.content {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.screener {
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.scr-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.scr-title {
  font-weight: 600;
  letter-spacing: 0.3px;
}

.scr-count {
  color: var(--muted);
  font-size: 11px;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.scr-status {
  color: var(--muted);
  font-size: 10px;
}

.scr-status.bad { color: var(--bad); }

.scr-filters {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.scr-input {
  flex: 1 1 auto;
  min-width: 0;
  background: #0f141a;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  outline: none;
}

.scr-input:focus { border-color: var(--accent); }

.scr-vol-label {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted, #8b95a3);
  white-space: nowrap;
}

.scr-vol-label .scr-input-vol {
  flex: 0 0 60px;
  width: 60px;
  text-align: right;
  padding: 4px;
}

.scr-vol-unit {
  font-size: 11px;
  color: var(--muted, #8b95a3);
}

/* Скролл только вертикальный */
.scr-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.scr-table-wrap::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.scr-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.scr-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #11161c;
  color: var(--muted);
  font-weight: 500;
  text-align: right;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.scr-table thead th:first-child { text-align: left; }
.scr-table thead th:hover { color: var(--text); }

/* Убирает стандартную белую заливку кнопок заголовков */
.scr-table thead th .sort-btn {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: right;
  cursor: pointer;
}

.scr-table thead th:first-child .sort-btn { text-align: left; }

.scr-table thead th .sort-btn:hover,
.scr-table thead th .sort-btn:active {
  background: transparent !important;
  color: var(--text);
}

.scr-table thead th .sort-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.scr-table thead th.sorted-desc::after {
  content: ' ▾';
  color: var(--accent);
}

.scr-table thead th.sorted-asc::after {
  content: ' ▴';
  color: var(--accent);
}

/* Колонка NATR */
.scr-table thead th[data-sort="natr"],
.scr-table tbody td.scr-natr {
  width: 6.5ch;
  min-width: 6.5ch;
  max-width: 6.5ch;
  padding-left: 2px;
  padding-right: 2px;
  text-align: right;
}

/* Расширенная колонка объёма, чтобы полностью помещалось, например, 12.34M */
.scr-table thead th[data-sort="volume"],
.scr-table tbody td.scr-vol {
  width: 10ch;
  min-width: 10ch;
  max-width: 10ch;
  padding-left: 4px;
  padding-right: 4px;
  overflow: visible;
}

/* Колонка «Монета» */
.scr-table thead th[data-sort="symbol"],
.scr-table tbody td.scr-base {
  width: 11ch;
  min-width: 11ch;
  max-width: 11ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Остальные колонки */
.scr-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid rgba(35, 42, 51, 0.5);
}

.scr-table tbody tr:hover { background: #1b222a; }
.scr-table tbody tr.active { background: #1f2833; }

.scr-table tbody td {
  padding: 3px 8px;
  text-align: right;
  white-space: nowrap;
}

.scr-table tbody td.scr-base {
  text-align: left;
  font-weight: 600;
  color: #e6e9ef;
}

.scr-table tbody td.scr-num { color: #cfd6e0; }
.scr-table tbody td.scr-natr { color: #a9b4c4; }
.scr-table tbody td.up { color: var(--up); }
.scr-table tbody td.down { color: var(--down); }

main {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  position: relative;
}

.chart {
  position: absolute;
  inset: 0;
}

.draw-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.draw-canvas.drawing { cursor: crosshair; }

.error-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(239, 83, 80, 0.12);
  border: 1px solid rgba(239, 83, 80, 0.5);
  color: #ffb4b2;
  font-size: 12px;
  display: none;
  z-index: 5;
}

.error-banner.visible { display: block; }

/* ---------- авторизация ---------- */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #141b24 0%, #0b0e11 70%);
  padding: 20px;
}

.auth-box {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 26px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.auth-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.auth-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-widget {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  width: 100%;
}

.auth-warn {
  color: #ffb4b2;
  background: rgba(239, 83, 80, 0.12);
  border: 1px solid rgba(239, 83, 80, 0.45);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.5;
  text-align: left;
}

/* ---------- пользователь в шапке ---------- */

.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: #1b222b;
  border: 1px solid var(--border);
}

.user-avatar-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.user-name {
  font-size: 12px;
  color: #cfd6e0;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-logout {
  font-size: 11px;
  padding: 3px 8px;
}

/* ---------- реклама справа ---------- */

.adpanel {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.ad-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
}

.ad-title {
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.ad-note {
  font-size: 10px;
  color: #5d6675;
}

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #10151b;
  border: 1px dashed #2b3440;
  border-radius: 6px;
  color: #46505f;
  font-size: 11px;
  letter-spacing: 0.5px;
}

#adSlotTop {
  min-height: 250px;
  flex: 0 0 auto;
}

#adSlotBottom {
  min-height: 420px;
  flex: 0 0 auto;
}

.ad-slot-size { pointer-events: none; }

/* ---------- адаптив ---------- */

@media (max-width: 1400px) {
  .adpanel { flex: 0 0 260px; }
}

@media (max-width: 1180px) {
  .adpanel { display: none; }
}

@media (max-width: 1000px) {
  .screener { flex: 0 0 280px; }
}

/* ---------- мобильная шапка и всплывающий выбор ---------- */

.m-toolbar { display: none; }
.picker,
.picker-backdrop { display: none; }

.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
}

.picker-backdrop.open { display: block; }

.picker {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 91;
  max-height: 70vh;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.picker.open { display: flex; }

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.picker-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.picker-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 5px;
}

.picker-close:hover {
  background: #232c37;
  color: var(--text);
}

.picker-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.picker-item {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 11px 12px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
}

.picker-item:hover { background: #1e2630; }

.picker-item.active {
  background: rgba(240, 185, 11, 0.14);
  color: var(--accent);
  font-weight: 600;
}

.picker-item.disabled,
.picker-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: transparent;
}

.picker-item.disabled:hover,
.picker-item:disabled:hover { background: transparent; }

.picker-item-sub {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.picker-item.active .picker-item-sub { color: #d9a908; }

.picker-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- мобильные ---------- */

@media (max-width: 820px) {
  html, body { font-size: 12px; }

  .wrapper {
    height: 100vh;
    height: 100dvh;
  }

  .toolbar { display: none; }

  .m-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .m-toolbar::-webkit-scrollbar { display: none; }

  .m-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    background: #1b222b;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 7px;
    padding: 7px 10px;
    min-height: 36px;
    font-size: 12px;
    cursor: pointer;
  }

  .m-btn:active { background: #232c37; }

  .m-btn-label {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
  }

  .m-btn-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .m-caret {
    color: var(--muted);
    font-size: 10px;
  }

  .m-toolbar .status {
    margin-left: auto;
    flex: 0 0 auto;
  }

  .btn {
    padding: 7px 10px;
    font-size: 12px;
    min-height: 32px;
  }

  .status {
    margin-left: 0;
    flex: 0 0 auto;
  }

  .user-box {
    margin-left: 0;
    padding-left: 8px;
    flex: 0 0 auto;
  }

  .user-name { max-width: 80px; }

  .pricebar {
    padding: 4px 8px;
    gap: 10px;
    flex-wrap: wrap;
    border-left: none;
  }

  .pricebar .price { font-size: 16px; }
  .pricebar .source-tag { margin-left: auto; }

  .m-pricebar {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px 8px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
  }

  .m-pricebar .price {
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .m-pricebar .price.up { color: var(--up); }
  .m-pricebar .price.down { color: var(--down); }

  .m-pricebar .meta {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }

  .m-pricebar .source-tag {
    margin-left: auto;
    font-size: 11px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #b9c2d0;
    border: 1px solid #2b323c;
    background: #151a20;
    border-radius: 4px;
    padding: 2px 8px;
    white-space: nowrap;
  }

  .drawbar {
    width: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 8px;
    gap: 5px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .drawbar::-webkit-scrollbar { display: none; }
  .drawbar .label,
  .draw-hint { display: none; }

  .drawbar .tool-btn,
  .drawbar #clearDrawings {
    flex-direction: row;
    gap: 5px;
    width: auto;
    padding: 6px 10px;
    font-size: 12px;
  }

  .drawbar .tool-ico { font-size: 13px; }
  .drawbar .tool-txt { font-size: 12px; }

  .content {
    flex-direction: column;
    position: relative;
  }

  .screener {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    flex: 0 0 auto;
    height: 58vh;
    max-height: 58vh;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.5);
    transform: translateY(calc(100% - 42px));
    transition: transform 0.22s ease;
    will-change: transform;
  }

  .screener.open { transform: translateY(0); }

  .scr-head {
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    position: relative;
  }

  .scr-head::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: #333d4a;
  }

  main {
    flex: 1 1 auto;
    min-height: 0;
  }

  .draw-hint { display: none; }
}

@media (max-width: 420px) {
  .screener {
    height: 64vh;
    max-height: 64vh;
  }

  .scr-table { font-size: 11px; }

  .scr-table thead th,
  .scr-table tbody td {
    padding: 4px 6px;
  }

  /* На узком экране сохраняем запас для суффикса M/B */
  .scr-table thead th[data-sort="volume"],
  .scr-table tbody td.scr-vol {
    width: 10ch;
    min-width: 10ch;
    max-width: 10ch;
    padding-left: 3px;
    padding-right: 3px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .btn:hover {
    background: #1b222b;
    border-color: var(--border);
  }

  .scr-table tbody tr:hover { background: transparent; }
  .scr-table tbody tr:active { background: #1b222a; }
}

.draw-canvas { touch-action: none; }

/* ---------- всплывающее окно о сработавшем сигнале ---------- */

.signal-toast {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 95;
  min-width: 210px;
  max-width: 300px;
  padding: 10px 34px 10px 12px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.signal-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.signal-toast:hover { background: #1b222b; }

.signal-toast-head {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 3px;
}

.signal-toast-pair {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.signal-toast-nums {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.signal-toast-close {
  position: absolute;
  top: 6px;
  right: 6px;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 5px;
}

.signal-toast-close:hover {
  background: #232c37;
  color: var(--text);
}

@media (max-width: 820px) {
  .signal-toast {
    top: 8px;
    left: 8px;
    right: 8px;
    max-width: none;
  }
}


/* SCREENER COMPACT COLUMNS FIX */
.scr-table {
  width: 100% !important;
  table-layout: fixed !important;
}

.scr-table thead th,
.scr-table tbody td {
  min-width: 0 !important;
  padding-left: 3px !important;
  padding-right: 3px !important;
}

.scr-table thead th[data-sort="symbol"],
.scr-table tbody td.scr-base {
  width: 20% !important;
  max-width: none !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scr-table thead th[data-sort="price"],
.scr-table tbody td:nth-child(2) {
  width: 22% !important;
  max-width: none !important;
}

.scr-table thead th[data-sort="pct"],
.scr-table tbody td:nth-child(3) {
  width: 18% !important;
  max-width: none !important;
}

.scr-table thead th[data-sort="natr"],
.scr-table tbody td.scr-natr {
  width: 17% !important;
  max-width: none !important;
  padding-left: 2px !important;
  padding-right: 2px !important;
}

.scr-table thead th[data-sort="volume"],
.scr-table tbody td.scr-vol {
  width: 23% !important;
  max-width: none !important;
  padding-left: 2px !important;
  padding-right: 2px !important;
}
/* Компактная таблица скринера */
.scr-table {
  width: 100% !important;
  table-layout: fixed !important;
}

.scr-table thead th,
.scr-table tbody td {
  min-width: 0 !important;
  padding-left: 3px !important;
  padding-right: 3px !important;
}

.scr-table thead th[data-sort="symbol"],
.scr-table tbody td.scr-base {
  width: 20% !important;
  max-width: none !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scr-table thead th[data-sort="price"],
.scr-table tbody td:nth-child(2) {
  width: 22% !important;
  max-width: none !important;
}

.scr-table thead th[data-sort="pct"],
.scr-table tbody td:nth-child(3) {
  width: 18% !important;
  max-width: none !important;
}

.scr-table thead th[data-sort="natr"],
.scr-table tbody td.scr-natr {
  width: 17% !important;
  max-width: none !important;
  padding-left: 2px !important;
  padding-right: 2px !important;
}

.scr-table thead th[data-sort="volume"],
.scr-table tbody td.scr-vol {
  width: 23% !important;
  max-width: none !important;
  padding-left: 2px !important;
  padding-right: 2px !important;
}
/* ---------- вкладки приложения ---------- */

.view-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 7px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.view-tabs .btn {
  min-height: 34px;
}

.view-tabs .btn:not(.active) {
  background: transparent;
}

/* ---------- панель мультиграфика ---------- */

.multi-view,
.density-view {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.multi-view[hidden],
.density-view[hidden] {
  display: none !important;
}

.multi-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.multi-controls label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  white-space: nowrap;
}

.multi-controls select {
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #1b222b;
  color: var(--text);
  font: inherit;
}

#multiStatus {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.multi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  padding: 10px;
}

/* Колонки для выбранного числа окон */
.multi-grid[data-count="3"],
.multi-grid[data-count="6"],
.multi-grid[data-count="9"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.multi-grid[data-count="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.multi-grid[data-count="12"],
.multi-grid[data-count="16"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.multi-grid[data-count="25"],
.multi-grid[data-count="50"] {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.multi-card {
  position: relative;
  min-width: 0;
  height: 250px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0b0e11;
}

.multi-card-title {
  position: absolute;
  top: 7px;
  left: 8px;
  z-index: 2;
  padding: 3px 6px;
  border: 1px solid rgba(35, 42, 51, 0.8);
  border-radius: 4px;
  background: rgba(11, 14, 17, 0.78);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.multi-card-chart {
  position: absolute;
  inset: 0;
}

/* ---------- заготовка вкладки «Плотность» ---------- */

.density-placeholder {
  max-width: 620px;
  margin: 40px auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  text-align: center;
}

.density-placeholder h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 18px;
}

.density-placeholder p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

/* На телефоне мультиграфики идут вертикальным списком */
@media (max-width: 820px) {
  .view-tabs {
    gap: 5px;
    padding: 6px;
  }

  .view-tabs .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 7px;
    font-size: 11px;
  }

  .multi-controls {
    gap: 8px;
    padding: 8px;
  }

  .multi-controls label {
    gap: 5px;
    font-size: 11px;
  }

  .multi-controls select {
    min-height: 34px;
    max-width: 105px;
    padding: 5px;
    font-size: 12px;
  }

  #multiStatus {
    flex-basis: 100%;
    margin-left: 0;
  }

  .multi-grid,
  .multi-grid[data-count] {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .multi-card {
    height: 260px;
  }
}

@media (max-width: 420px) {
  .multi-controls {
    gap: 6px;
  }

  .multi-card {
    height: 230px;
  }
}
/* ---------- исправление размеров и прокрутки мультиграфика ---------- */

.multi-view:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow: hidden;
}

.multi-controls {
  flex: 0 0 auto;
}

.multi-grid {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 0;
  overflow: auto;
  align-content: stretch;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Высота карточек определяется сеткой, а не фиксированными 250px */
.multi-card {
  height: auto;
  min-height: 0;
}

.multi-card-chart,
.multi-card-chart canvas {
  touch-action: pan-y !important;
}

/* Desktop: сетка заполняет рабочую область */
.multi-grid[data-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.multi-grid[data-count="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.multi-grid[data-count="6"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.multi-grid[data-count="9"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

.multi-grid[data-count="12"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

.multi-grid[data-count="16"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.multi-grid[data-count="25"] {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
}

/* Для 50 карточек сохраняем удобный минимальный размер и прокрутку */
.multi-grid[data-count="50"] {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(160px, 1fr));
}

/* Телефон: компактные настройки и графики друг под другом */
@media (max-width: 820px) {
  .multi-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 8px;
    padding: 6px 8px;
  }

  .multi-controls label {
    display: flex;
    justify-content: space-between;
    gap: 5px;
    min-width: 0;
    font-size: 10px;
  }

  .multi-controls select {
    width: 62%;
    max-width: none;
    min-width: 0;
    min-height: 30px;
    padding: 4px;
    font-size: 11px;
  }

  #multiStatus {
    display: none;
  }

  .multi-grid,
  .multi-grid[data-count] {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: minmax(42vh, 42vh);
    gap: 8px;
    padding: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .multi-card {
    height: auto;
    min-height: 0;
  }

  .multi-card-chart,
  .multi-card-chart canvas {
    touch-action: pan-y !important;
  }
}
