@media (min-width: 992px) {
  html, body {
    height: 100vh !important;
    overflow: hidden !important;
  }
  body.screener-viewport-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }
  .screener-page {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: .4rem .8rem .6rem !important;
    overflow: hidden;
  }
  .screener-topbar {
    flex-shrink: 0;
    margin-bottom: .4rem;
  }
  .screener-grid-container {
    flex: 1 1 0;
    min-height: 0;
    height: 100% !important;
    display: grid;
    gap: 5px;
    width: 100%;
  }
}

.screener-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .45rem .75rem;
  border-radius: .65rem;
  flex-wrap: wrap;
}
.screener-nav-group {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}

@media (max-width: 991.98px) {
  .screener-page {
    padding: .75rem .5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
  }

  .screener-topbar {
    padding: .5rem !important;
    gap: .5rem !important;
  }
  .screener-nav-group {
    width: 100%;
    justify-content: flex-start;
    gap: .5rem !important;
  }

  .view-switcher-wrap {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .view-switcher-wrap::-webkit-scrollbar {
    display: none; 
  }

  .view-switcher-wrap .view-btn {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    word-break: keep-all;
    overflow-wrap: normal;
  }

  .screener-nav-group .form-select {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 45%;
  }
  #openSettingsBtn {
    width: 100%;
    background: rgba(0, 229, 255, 0.05);
    border: 1px solid rgba(0, 229, 255, 0.15);
  }

  .screener-grid-container {
    height: auto !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: none !important;
    display: grid;
    gap: 8px;
  }
  .screener-chart-card {
    height: 320px !important;
  }
}

.screener-grid-container[data-grid="2"]  { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
.screener-grid-container[data-grid="4"]  { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.screener-grid-container[data-grid="6"]  { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.screener-grid-container[data-grid="9"]  { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.screener-grid-container[data-grid="16"] { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }
.screener-grid-container[data-grid="20"] { grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(4, 1fr); }

.screener-chart-card {
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #111622);
  border: 1px solid var(--border, #1F2635);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.screener-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border, #1F2635);
  gap: 6px;
  font-size: .8rem;
  flex-shrink: 0;
}

.screener-ticker-title {
  color: var(--text-primary, #fff);
  font-weight: 800;
  font-family: monospace;
  font-size: .88rem;
  text-decoration: none;
}
.screener-ticker-title:hover {
  color: var(--cyan, #00E5FF);
}

.metric-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: .72rem;
  font-family: monospace;
  font-weight: 700;
  cursor: help;
}

/* Инструменты рисования */
.screener-tools-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}
.chart-tool-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #8B93A7);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: .8rem;
  cursor: pointer;
  transition: all .12s ease;
}
.chart-tool-btn:hover {
  color: var(--cyan, #00E5FF);
  background: rgba(0, 229, 255, 0.1);
}

/* Область канваса KLineChart */
.screener-canvas-area {
  flex: 1 1 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* Водяной знак монеты на фоне графика */
.chart-watermark-sym {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3.5rem;
  font-weight: 900;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.035);
  pointer-events: none;
  user-select: none;
  z-index: 0;
  letter-spacing: 2px;
}
[data-bs-theme="light"] .chart-watermark-sym {
  color: rgba(0, 0, 0, 0.04);
}

.param-input-sm-screener {
  width: 48px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border, #1F2635);
  border-radius: 4px;
  color: #fff;
  padding: 2px 4px;
  font-size: 0.8rem;
  font-family: monospace;
  text-align: center;
}

/* Адаптация инпутов под светлую тему */
[data-bs-theme="light"] .param-input-sm-screener {
  color: #0F172A !important;
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
}

@media (min-width: 992px) {
  .screener-topbar {
    flex-wrap: nowrap;
  }

  .screener-nav-group {
    min-width: 0;
  }

  .screener-nav-group .view-switcher-wrap {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; 
    -ms-overflow-style: none;
    min-width: 0;
  }
  .screener-nav-group .view-switcher-wrap::-webkit-scrollbar {
    display: none;
  }

  .view-switcher-wrap .view-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  } 

  .screener-nav-group.ms-auto {
    flex-shrink: 0;
  }
  .screener-nav-group.ms-auto .form-select,
  .screener-nav-group.ms-auto .btn {
    flex-shrink: 0;
  }
}