body {
  font-family: Arial, sans-serif;
  background-color: #1e1e1e;
  color: #e0e0e0;
  margin: 0;
  padding: 20px;
  box-sizing: border-box;
  min-height: 100vh;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
}

html, body {
  overflow-x: hidden; /* чтобы страница не расширялась из-за широких элементов */
  min-height: 100%;
}

.container {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 40px);
  height: auto;
}

.sidebar {
  background: #2b2b2b;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  width: 280px;
  text-align: center;
  max-height: none;
  overflow: visible;
  box-sizing: border-box;
}

h1 {
  font-size: 22px;
  margin-bottom: 20px;
  color: #fff;
}

.buttons {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auto-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 1000;
}

.auto-modal-content {
  background: #2b2b2b;
  border-radius: 12px;
  width: min(900px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  gap: 16px;
}

.auto-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auto-modal-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.auto-control-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.auto-control-item label {
  font-size: 14px;
  color: #b0b0b0;
}

.auto-control-item input {
  background: #1e1e1e;
  color: #fff;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.auto-control-buttons {
  display: flex;
  gap: 10px;
}

.auto-status {
  font-size: 14px;
  color: #b0b0b0;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  background: #232323;
  min-height: 46px;
  display: flex;
  align-items: center;
}

.auto-table {
  min-height: 200px;
}

.auto-table table {
  min-width: 700px;
}

.auto-note {
  margin-left: 6px;
  cursor: help;
  font-size: 12px;
  display: inline-block;
}

.auth-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.auth-controls button,
.buttons button {
  margin-bottom: 0;
}

button {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.2;
  box-sizing: border-box;
  margin: 0;
}
button:hover { opacity: 0.9; }
.btn-green { background: #4CAF50; color: white; }

/* Цвет просмотренных ссылок */
a:visited {
  color: #b0b0b0;
}

/* Ссылки в таблицах */
#dataTable a {
  color: #4da3ff;
  text-decoration: underline;
}
#dataTable a:visited {
  color: #b0b0b0 !important;
}

/* Стили для аналитики */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.analytics-item {
  background: #2b2b2b;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  border-left: 4px solid #4CAF50;
  transition: transform 0.2s, box-shadow 0.2s;
}

.analytics-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

.analytics-item.primary {
  border-left-color: #2196F3;
}

.analytics-item.success {
  border-left-color: #4CAF50;
}

.analytics-item.warning {
  border-left-color: #FF9800;
}

.analytics-item.error {
  border-left-color: #F44336;
}

.analytics-metric {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 8px;
}

.analytics-value {
  font-size: 32px;
  font-weight: bold;
  color: #4CAF50;
  margin-bottom: 8px;
}

.analytics-item.primary .analytics-value {
  color: #2196F3;
}

.analytics-item.success .analytics-value {
  color: #4CAF50;
}

.analytics-item.warning .analytics-value {
  color: #FF9800;
}

.analytics-item.error .analytics-value {
  color: #F44336;
}

.analytics-description {
  font-size: 14px;
  color: #b0b0b0;
  line-height: 1.4;
}
.btn-red { background: #d9534f; color: white; }
.btn-blue { background: #0078d4; color: white; }
.btn-orange { background: #ff8c00; color: white; }
.btn-gray { background: #555; color: white; }
.btn-purple { background: #7b2cbf; color: white; }
.btn-disabled {
  background: #555 !important;
  color: #aaa !important;
  cursor: not-allowed !important;
}

.output {
  flex: 1;
  background: #2b2b2b;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  overflow: visible;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* общий контейнер для настроек и таблицы */
#dataWrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
  min-height: 0; /* позволяет дочернему flex-элементу с overflow работать корректно */
}

#output {
  flex: 1 1 auto; /* занимает всё оставшееся место */
  min-height: 0; /* позволяет вложенному скроллу работать корректно */
  display: flex;
  flex-direction: column;
}

#applySettingsBox {
  margin-bottom: 15px;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0; /* не сжимается, фиксированная высота содержимого */
}

/* Убираем дублирующие стили для #output */

.table-scroll {
  flex: 1 1 auto; /* занимает все доступное место */
  width: 100%;
  overflow: auto; /* Скролл по всем направлениям */
  -webkit-overflow-scrolling: touch;
  min-height: 0; /* Важно для flex-элементов */
  border: 1px solid #444; /* Видимая граница для контейнера */
}

.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-shrink: 0; /* Не сжимается */
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
}

.chart-toggle {
  display: inline-flex;
  gap: 6px;
  background: #1f1f1f;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid #3a3a3a;
}

.chart-toggle-btn {
  background: transparent;
  color: #bdbdbd;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: auto;
  letter-spacing: 0.2px;
}

.chart-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.chart-toggle-btn-active {
  background: #2f81f7;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(47, 129, 247, 0.35);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed; /* изменено на фиксированную разметку */
}

th, td {
  border: 1px solid #444;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* длинные PRE-блоки (JSON, логи) не должны растягивать страницу */
pre {
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* делаем vacancy_name максимально широким */
th.vacancy_name,
td.vacancy_name {
  width: 100%;
}

th {
  background: #3a3a3a;
  color: #fff;
}

tr:nth-child(even) {
  background: #2e2e2e;
}

.add-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
  margin-bottom: 12px;
}

.auto-settings-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auto-settings-actions button {
  min-width: 140px;
}


.chart-card {
  margin: 20px 0 20px;
  padding: 20px;
  background: #1f1f1f;
  border-radius: 12px;
  box-sizing: border-box;
}

.chart-container {
  position: relative;
  height: 250px;
}

.chart-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 768px) {
  .chart-card {
    padding: 12px;
    margin: 10px 0 20px;
  }

  .chart-container {
    height: 200px;
  }
}
/* ===================== */
/*     МОБИЛЬНАЯ ВЕРСТКА */
/* ===================== */

@media (max-width: 768px) {
  html,
  body {
    padding: 10px;
    min-height: 100vh;
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .container {
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    width: 100%;
    min-height: 0;
    height: auto;
  }

  /* Верхняя шапка вместо боковой панели */
  .sidebar {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    position: static;
    top: auto;
    z-index: auto;
    box-sizing: border-box;
    overflow: visible;
    max-height: none;
  }

  .sidebar h1 {
    margin: 0 0 10px 0;
    font-size: 18px;
  }

  /* Кнопки навигации в строке, переносятся */
  .buttons {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 8px;
    justify-content: flex-start;
    align-items: stretch;
  }

  .auth-controls {
    gap: 8px;
  }

  /* Одинаковая ширина кнопок, почти на весь экран */
  .buttons button,
  .table-actions button,
  .auth-controls button,
  .btn-blue,
  .btn-green,
  .btn-red,
  .btn-orange,
  .btn-gray,
  .btn-purple {
    flex: 1 1 100%;
    min-width: 100%;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 10px;
    font-size: 16px;
  }

  /* Блок контента ниже */
  .output {
    padding: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 0;
    height: auto;
    overflow: visible;
    display: flex;
    flex-direction: column; /* Важно для flex-компоновки */
  }

  /* Панель действий над таблицами */
  .table-actions {
    flex-direction: column; /* в столбик на мобильных */
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .chart-toggle {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .chart-toggle-btn {
    flex: 1 1 auto;
    text-align: center;
    padding: 10px 12px;
    font-size: 15px;
  }

  /* table-scroll на мобильных */
  .table-scroll {
    flex: 1 1 auto; /* Занимает оставшееся место */
    height: auto;
    max-height: none;
    border: 1px solid #444; /* Видимая граница для контейнера */
  }

  /* элементы панели действий занимают полную ширину */
  .table-actions > * {
    width: 100%;
    box-sizing: border-box;
  }
  #applyControls button {
    width: 100%;
  }

  /* Горизонтальный скролл таблиц удобнее */

  table {
    font-size: 13px;
    min-width: 640px; /* даём горизонтальный скролл при узком экране */
    width: max-content; /* таблица шире экрана скроллится внутри контейнера, не растягивает вьюпорт */
  }

  th, td {
    padding: 8px;
  }

  textarea {
  }

  .auto-modal {
    padding: 0;
  }

  .auto-modal-content {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 16px;
  }

  .auto-modal-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .auto-control-buttons {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 600px) {
  .auto-settings-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .auto-settings-actions button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  /* Landscape styles removed */
}

@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
  /* Styles removed */
}

/* Отдельная настройка для горизонтального режима не требуется —
   используется тот же мобильный layout, позволяющий странице расти по высоте. */

textarea {
  width: 100%;
  min-height: 180px;
  background: #1e1e1e;
  color: #fff;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
  resize: vertical;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #b0b0b0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.empty-state p {
  margin: 0;
  font-size: 16px;
}

.auth-actions {
  display: flex;
  gap: 10px;
}
