:root {
  --bg-base:       #090d13;
  --bg-surface:    #0e1520;
  --bg-elevated:   #162030;
  --bg-hover:      #1c2a3e;
  --border:        #1e2d40;
  --border-light:  #243648;
  --text-primary:  #e8edf5;
  --text-secondary:#8faabb;
  --text-muted:    #4a6070;

  --accent:        #3b82f6;
  --accent-dim:    #1d4ed8;
  --cyan:          #06b6d4;

  --sev-low:       #22c55e;
  --sev-medium:    #f59e0b;
  --sev-high:      #f97316;
  --sev-critical:  #ef4444;

  --lang-eng:      #60a5fa;
  --lang-rus:      #f87171;
  --lang-arm:      #a78bfa;

  --radius:        8px;
  --sidebar-w:     220px;
  --font:          'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Login screen ──────────────────────────────────────────────────────────── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  filter: drop-shadow(0 0 16px rgba(59,130,246,0.5));
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 36px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  margin-top: 10px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: color 0.15s;
}
.btn-ghost:hover { color: var(--text-secondary); }

.error-msg {
  color: var(--sev-critical);
  font-size: 12px;
  margin-top: 14px;
  min-height: 18px;
}

/* ── App layout ────────────────────────────────────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #0f1825 0%, #090d13 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nav-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.nav-logo { font-size: 22px; filter: drop-shadow(0 0 8px rgba(59,130,246,0.4)); flex-shrink: 0; }
.nav-title { font-size: 13px; font-weight: 700; letter-spacing: 0.3px; color: var(--text-primary); line-height: 1.2; }
.nav-subtitle { font-size: 10px; color: var(--text-muted); margin-top: 2px; letter-spacing: 0.3px; }

.nav-links {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.nav-link.active { background: rgba(59,130,246,0.15); color: var(--accent); border-left: 2px solid var(--accent); padding-left: 8px; }
.nav-link .icon { width: 16px; text-align: center; opacity: 0.7; }

.nav-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* ── Main content ──────────────────────────────────────────────────────────── */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Filters bar ───────────────────────────────────────────────────────────── */

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: rgba(59,130,246,0.15); border-color: var(--accent); color: var(--accent); }

/* ── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.card:hover { border-color: var(--border-light); background: var(--bg-elevated); }

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.card-body {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Badges ────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-low      { background: rgba(34,197,94,0.15);  color: var(--sev-low); }
.badge-medium   { background: rgba(245,158,11,0.15); color: var(--sev-medium); }
.badge-high     { background: rgba(249,115,22,0.15); color: var(--sev-high); }
.badge-critical { background: rgba(239,68,68,0.2);   color: var(--sev-critical); border: 1px solid rgba(239,68,68,0.3); }

.badge-eng { background: rgba(96,165,250,0.12); color: var(--lang-eng); }
.badge-rus { background: rgba(248,113,113,0.12); color: var(--lang-rus); }
.badge-arm { background: rgba(167,139,250,0.12); color: var(--lang-arm); }

.badge-type {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 2px 7px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  border-radius: 4px;
}

/* ── Confidence bar ────────────────────────────────────────────────────────── */

.confidence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.confidence-track {
  width: 80px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s;
}
.confidence-label { font-size: 11px; color: var(--text-muted); }

/* ── Actors list ───────────────────────────────────────────────────────────── */

.actors {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.actor-tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 4px;
}

/* ── Stats grid ────────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-primary);
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Bar chart ─────────────────────────────────────────────────────────────── */

.bar-chart { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 36px;
  align-items: center;
  gap: 8px;
}

.bar-label { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bar-track {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s;
}

.bar-count { font-size: 11px; color: var(--text-muted); text-align: right; }

/* ── Sparkline ─────────────────────────────────────────────────────────────── */

.sparkline-wrap { margin-top: 12px; }
.sparkline-wrap svg { width: 100%; height: 60px; overflow: visible; }

/* ── Pagination ────────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  justify-content: center;
}

.page-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-info { font-size: 12px; color: var(--text-muted); }

/* ── Empty state ───────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.35; }
.empty-state p { font-size: 13px; line-height: 1.6; }

/* ── Loading spinner ───────────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 10px;
}

/* ── Incident card specific ────────────────────────────────────────────────── */

.original-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  font-style: italic;
}

.incident-source-link {
  font-size: 11px;
  color: var(--accent);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 250px;
}

/* ── Settings ──────────────────────────────────────────────────────────────── */

.settings-section {
  margin-bottom: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.settings-section h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.channel-list { list-style: none; }
.channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}
.channel-name { font-size: 13px; font-weight: 500; }

.btn-danger {
  background: transparent;
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--sev-critical);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.12s;
}
.btn-danger:hover { opacity: 1; }

.action-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s;
  margin-right: 8px;
  margin-bottom: 8px;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); }

.status-msg {
  font-size: 12px;
  color: var(--sev-low);
  margin-top: 8px;
  min-height: 18px;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Mobile ────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  #app { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav-links {
    display: flex;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
  }

  .nav-link { white-space: nowrap; padding: 7px 12px; }

  .nav-footer { display: none; }

  .content { padding: 16px; }

  .bar-row { grid-template-columns: 100px 1fr 30px; }
}

/* ── Summary view ──────────────────────────────────────────────────────────── */

.summary-doc {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.summary-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  transition: background 0.12s;
}
.summary-section:last-child { border-bottom: none; }
.summary-section:hover { background: var(--bg-elevated); }
.summary-section:nth-child(2) { border-left-color: var(--cyan); }
.summary-section:nth-child(3) { border-left-color: var(--lang-arm); }
.summary-section:nth-child(4) { border-left-color: var(--sev-low); }
.summary-section:nth-child(5) { border-left-color: var(--sev-medium); }
.summary-section:nth-child(6) { border-left-color: var(--lang-rus); }

.summary-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.regen-pulse {
  color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.summary-bullets {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.summary-bullets li {
  position: relative;
  padding-left: 14px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.summary-bullets li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

.source-links {
  margin-left: 5px;
  white-space: nowrap;
}

.source-link {
  font-size: 10px;
  color: var(--accent);
  vertical-align: super;
  margin-left: 2px;
  opacity: 0.8;
}

.source-link:hover { opacity: 1; }
