:root {
  --bg: #0f1117;
  --bg-card: #161a23;
  --border: #262b36;
  --text: #e5e7eb;
  --text-muted: #9aa3b2;
  --text-faint: #7d8695;
  --accent: #4f7fff;
  --success: #4ade80;
  --error: #f87171;
  --warn: #e0a458;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  font-size: 13px;
}

.nav .brand { font-weight: 600; color: var(--text); margin-right: 12px; }
.nav .spacer { flex: 1; }
.nav .current-user { color: var(--text-faint); }

.maintenance-banner {
  background: #78350f;
  color: #fde68a;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
}

.container { max-width: 1600px; width: 96%; margin: 0 auto; padding: 24px; }

h1 { font-size: 20px; font-weight: 600; margin: 0 0 16px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

/* Tables stretch to fill their container when content is narrow, but are allowed to grow
   beyond it when content needs more room — .table-scroll then scrolls horizontally instead
   of every column being squeezed down to the point of breaking words mid-way. */
.table-scroll { width: 100%; overflow-x: auto; border-radius: 8px; }
table { width: max-content; min-width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
th { color: var(--text-faint); text-transform: uppercase; font-size: 11px; }
tr:last-child td { border-bottom: none; }

/* The one cell whose content is genuinely open-ended (matched text + a post snippet) —
   wraps within a bounded width instead of forcing the whole table to grow to fit it. */
.match-cell { white-space: normal; max-width: 640px; }

input[type=text], input[type=password], input[type=number], input[type=date], select {
  background: #1a1f2b;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}

button, .btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
button.secondary, .btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
button.danger, .btn.danger { background: transparent; border: 1px solid var(--error); color: var(--error); }

.status-done { color: var(--success); }
.status-error { color: var(--error); }
.status-pending, .status-running { color: var(--text-muted); }

.error-message { color: var(--error); margin-bottom: 12px; }

.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 16px; font-size: 13px; color: var(--text-muted); }
.tabs a { color: var(--text-muted); padding-bottom: 8px; display: inline-block; }
.tabs a.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

.stat-cards { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-cards .card { flex: 1; min-width: 160px; }
.stat-cards .stat-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; }
.stat-cards .stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }

.progress-track {
  position: relative;
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0 16px;
}
.progress-track .progress-bar {
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  animation: progress-slide 1.2s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { left: -40%; }
  100% { left: 100%; }
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 2px solid var(--text-faint);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: middle;
  animation: spinner-spin 0.7s linear infinite;
}
@keyframes spinner-spin {
  to { transform: rotate(360deg); }
}

.platform-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}
.platform-badge.instagram, .platform-badge.facebook { background: #e0245e; }
.platform-badge.vpn { background: #d97706; }
.platform-badge.foreign_agent { background: #9333ea; }

.fuzzy-label {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px dashed var(--text-faint);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-faint);
}

/* Уверенность — вспомогательный признак, а не отдельная тревога: намеренно приглушённее
   платформенных плашек, чтобы «высокая» у большинства строк не рябила. */
.confidence-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}
.confidence-badge.high { color: var(--text-muted); border: 1px solid var(--border); }
.confidence-badge.medium { color: var(--warn); border: 1px solid var(--warn); }
.confidence-badge.low { color: var(--text-faint); border: 1px dashed var(--text-faint); }

.result-filters { margin-bottom: 16px; }
.sortable-header a { color: inherit; }

.platform-badge.extremist { background: #7f1d1d; }
.platform-badge.extremist_material { background: #b45309; }
.platform-badge.custom_watch { background: #0891b2; }

.context-snippet {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-word;
}
.context-snippet mark {
  background: rgba(79, 127, 255, 0.35);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

@media (max-width: 640px) {
  .container { padding: 12px; }
  h1 { font-size: 17px; word-break: break-word; }

  .nav { padding: 10px 12px; gap: 12px; flex-wrap: wrap; }
  .nav .spacer { flex-basis: 100%; height: 0; }

  .filters { gap: 8px; }
  .filters label { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; font-size: 12px; }
  .filters input[type=text], .filters input[type=date], .filters select { width: 100%; }

  .stat-cards .card { min-width: 0; flex-basis: 100%; }

  th, td { padding: 8px; font-size: 12px; }
  .fuzzy-label { display: block; margin-left: 0; margin-top: 4px; width: fit-content; }
  .match-cell { max-width: 220px; }
}

.legacy-badge { display:inline-block; font-size:0.8em; color:#b78; border:1px solid #b78; border-radius:4px; padding:0 4px; }

/* Галочка «принудительно» у кнопок синхронизации реестров. Намеренно неброская: обычный путь —
   просто нажать «Обновить список», а снятие защиты нужно в редком исключении. */
.force-sync { display: block; font-size: 12px; color: var(--text-faint); margin: 6px 0 8px; cursor: pointer; }
.force-sync input { margin-right: 4px; }

/* Выделенное предупреждение внутри карточки (инструкция по архиву). */
.archive-note {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--warn);
  background: rgba(224, 164, 88, 0.08);
  border-radius: 0 4px 4px 0;
  line-height: 1.6;
}
.archive-note code {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 0.9em;
}

/* Полоса-анонс новых обновлений под меню. По умолчанию скрыта: скрипт в partials/nav.ejs
   показывает её, только если пользователь ещё не видел последнее обновление. */
.updates-banner {
  display: none;
  align-items: center;
  gap: 12px;
  background: rgba(79, 127, 255, 0.10);
  border-bottom: 1px solid rgba(79, 127, 255, 0.35);
  padding: 10px 24px;
  font-size: 13px;
  color: var(--text);
}
.updates-banner.is-visible { display: flex; }
.updates-banner a { color: var(--accent); font-weight: 600; white-space: nowrap; }
.updates-banner .updates-banner-text { flex: 1; }
.updates-banner .updates-banner-close {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  width: auto;
}
.updates-banner .updates-banner-close:hover { color: var(--text); }
