/* ============================================================
   Reach Bot — тёмная тема в духе 101rtp.com:
   тёмный фон, зелёный акцент как основной сигнал "хорошо/активно",
   янтарный — как сигнал риска/просрочки (не декоративный, а по смыслу
   данных), карточки со скруглением, крупные "светящиеся" цифры охвата.
   ============================================================ */

:root {
  --bg: #0b0e13;
  --surface: #141a21;
  --surface-2: #1b222b;
  --border: #232c36;
  --accent: #34e27a;
  --accent-dim: #1f8f53;
  --accent-text: #04150c;
  --warn: #ffb020;
  --danger: #ff4d5e;
  --text: #e7edf3;
  --text-dim: #8a97a6;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Центрируем и даём пространству "дышать" */
#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 32px;
}

h2, h4 {
  font-family: 'Oswald', 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 16px;
  font-weight: 600;
}

h2 {
  font-size: 22px;
  color: var(--text);
}
h2::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  margin-right: 10px;
  box-shadow: 0 0 10px var(--accent);
}

h4 {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 32px;
  padding-left: 10px;
  border-left: 3px solid var(--accent-dim);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
}

.tab-btn {
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 12px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

button, input, select, textarea {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}

button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
button:hover { border-color: var(--accent-dim); }
button:active { transform: scale(0.97); }

/* Основное действие формы — заливка акцентом, как CTA-кнопки на 101rtp */
form button[type="submit"],
#btn-force-refresh {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
form button[type="submit"]:hover,
#btn-force-refresh:hover { background: #2bc96a; }

.btn-stop {
  border-color: var(--danger);
  color: var(--danger);
}
.btn-stop:hover { background: rgba(255, 77, 94, 0.12); }

/* Полное безвозвратное удаление — визуально ощутимо "опаснее" простого "Остановить" */
.btn-delete {
  border-color: var(--danger);
  background: rgba(255, 77, 94, 0.12);
  color: var(--danger);
}
.btn-delete:hover { background: rgba(255, 77, 94, 0.22); }

input, select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 226, 122, 0.18);
}

.form-row {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 640px;
}
.form-row label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  margin: 4px 0;
}
table.grid th, table.grid td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
table.grid th {
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
table.grid th:first-child { border-top-left-radius: var(--radius-sm); }
table.grid th:last-child { border-top-right-radius: var(--radius-sm); }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid a { color: var(--accent); text-decoration: none; }
table.grid a:hover { text-decoration: underline; }

/* Сигнатурный элемент: цифра охвата — крупный светящийся "чип",
   по аналогии с тем, как 101rtp выделяет ключевые цифры карточек */
.reach-stat {
  display: inline-block;
  font-family: 'Oswald', sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(52, 226, 122, 0.10);
  border: 1px solid rgba(52, 226, 122, 0.35);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
}
.reach-stat.empty {
  color: var(--text-dim);
  background: transparent;
  border-color: var(--border);
}

/* Статусы — компактные "чипы", как страна/лицензия у казино-карточек */
.badge-overdue, .badge-active, .badge-deleted {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active { color: var(--accent); background: rgba(52, 226, 122, 0.10); }
.badge-overdue { color: var(--warn); background: rgba(255, 176, 32, 0.14); }
.badge-deleted { color: var(--text-dim); background: rgba(138, 151, 166, 0.12); }

.state-message { color: var(--text-dim); font-size: 14px; }
.error { color: var(--danger); }
.hint { color: var(--text-dim); font-size: 12px; margin: 4px 0 8px; }

.monthly-row td {
  background: var(--surface-2);
  padding: 14px 16px;
}
.monthly-table { max-width: 480px; margin: 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--surface); padding: 16px; border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  max-width: 90vw; max-height: 90vh; overflow: auto;
}
.modal-box img { max-width: 100%; display: block; border-radius: var(--radius-sm); }

.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filters-erid {
  display: flex;
  gap: 6px;
}

table.grid th.sortable {
  cursor: pointer;
  user-select: none;
}
table.grid th.sortable:hover {
  color: var(--text);
}

.info-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  cursor: help;
}
.info-icon .info-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  text-align: left;
}
.info-icon:hover .info-tooltip,
.info-icon:focus .info-tooltip {
  display: block;
}
.date-range {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.date-range input[type="date"] {
  padding: 6px 8px;
}

.actions-cell {
  position: relative;
}
.actions-menu {
  position: relative;
  display: inline-block;
}
.actions-toggle {
  padding: 6px 10px;
  font-size: 16px;
  line-height: 1;
}
.actions-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 25;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 140px;
  flex-direction: column;
}
.actions-dropdown.open {
  display: flex;
}
.actions-dropdown button {
  border: none;
  border-radius: 0;
  text-align: left;
  background: transparent;
}
.actions-dropdown button:hover {
  background: var(--surface);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 20px;
  margin-bottom: 4px;
}
.form-grid .form-row {
  max-width: none;
  margin-bottom: 0;
}

.searchable-select {
  position: relative;
}
.searchable-select-input {
  width: 100%;
}
.searchable-select-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.searchable-select-item {
  padding: 9px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}
.searchable-select-item:hover {
  background: var(--accent-dim);
  color: var(--text);
}
.searchable-select-item.selected {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.searchable-select-input {
  border: 1px solid var(--border) !important;
  background: var(--surface-2) !important;
}
.searchable-select-empty {
  padding: 9px 12px;
  color: var(--text-dim);
  font-size: 13px;
}
