/* ===================================================
   BioWatch Agent - Dashboard Styles
   =================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-card-hover: #1f2b3d;
  --bg-panel: #141c2b;
  --border: #1e2d42;
  --border-light: #263348;
  --text-primary: #e8ecf1;
  --text-secondary: #8899aa;
  --text-muted: #5a6a7a;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --critical: #ef4444;
  --critical-bg: rgba(239, 68, 68, 0.1);
  --critical-glow: rgba(239, 68, 68, 0.3);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.1);
  --high: #f97316;
  --high-bg: rgba(249, 115, 22, 0.1);
  --medium: #eab308;
  --medium-bg: rgba(234, 179, 8, 0.1);
  --low: #22c55e;
  --low-bg: rgba(34, 197, 94, 0.1);
  --whatsapp: #25d366;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ==================== PRELOADER ==================== */
#preloader {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#preloader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.preloader-inner {
  text-align: center;
  max-width: 400px;
  padding: 2rem;
}

/* Imagem central com anéis orbitais */
.preloader-image-wrapper {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 0 auto 2.5rem;
}

.preloader-image {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  border: 4px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 40px rgba(59, 130, 246, 0.2), 0 0 80px rgba(239, 68, 68, 0.1);
}

.preloader-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  border-right-color: rgba(59, 130, 246, 0.3);
  animation: ringRotate 3s linear infinite;
  z-index: 2;
}

.preloader-ring.ring-outer {
  inset: -20px;
  border-width: 2px;
  border-top-color: var(--critical);
  border-right-color: rgba(239, 68, 68, 0.2);
  animation: ringRotateReverse 4s linear infinite;
}

.preloader-glow {
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
  z-index: 1;
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes ringRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes ringRotateReverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.preloader-text h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.preloader-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
}

.preloader-progress {
  width: 100%;
  max-width: 360px;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto 1.2rem;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--info));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.preloader-status {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
}

/* ==================== HEADER ==================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.8rem;
}

.logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.version {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-badge.online {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.offline {
  background: var(--critical-bg);
  color: var(--critical);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.last-scan {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.btn-icon.spinning svg {
  animation: spin 1s linear infinite;
}

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

/* ==================== MAIN ==================== */
.main {
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* ==================== STATS GRID ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.critical::before { background: var(--critical); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.info::before { background: var(--info); }
.stat-card.success::before { background: var(--success); }
.stat-card.neutral::before { background: var(--text-muted); }
.stat-card.whatsapp::before { background: var(--whatsapp); }

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}

.stat-card.critical:hover { border-color: rgba(239, 68, 68, 0.3); box-shadow: 0 4px 24px var(--critical-glow); }

.stat-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}

.stat-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.2;
  margin-top: 2px;
}

.stat-trend {
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 2px;
}

.stat-trend.up { color: var(--critical); }
.stat-trend.down { color: var(--success); }

/* ==================== CONTENT GRID ==================== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
  .content-grid { grid-template-columns: 1fr; }
}

/* ==================== PANELS ==================== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.panel-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel-body {
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.badge {
  font-size: 0.65rem;
  background: var(--accent-glow);
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
  font-weight: 500;
}

.btn-small {
  font-size: 0.7rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}

.btn-small:hover {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.filter-select {
  font-size: 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: inherit;
}

/* ==================== ALERTS FEED ==================== */
.alerts-panel {
  min-height: 500px;
  max-height: 70vh;
}

.alert-item {
  display: flex;
  gap: 0.8rem;
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
  animation: alertSlideIn 0.4s ease;
}

@keyframes alertSlideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.alert-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.alert-severity {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}

.alert-severity.critical { background: var(--critical); }
.alert-severity.high { background: var(--high); }
.alert-severity.medium { background: var(--medium); }
.alert-severity.low { background: var(--low); }

.alert-content { flex: 1; min-width: 0; }

.alert-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-meta {
  display: flex;
  gap: 0.8rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.alert-summary {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.alert-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.alert-cases {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
}

.alert-cases.has-cases {
  background: var(--critical-bg);
  color: var(--critical);
}

.alert-cases.no-cases {
  background: var(--info-bg);
  color: var(--info);
}

/* ==================== APPS / QUICK LINKS ==================== */
.apps-panel {
  max-height: 300px;
}

.app-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.app-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateX(4px);
}

.app-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.app-icon.sonora {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2));
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.app-icon.biowatched {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.app-icon.salao {
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.2), rgba(251, 146, 60, 0.2));
  border: 1px solid rgba(244, 114, 182, 0.3);
}

.app-info {
  flex: 1;
  min-width: 0;
}

.app-name {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.app-url {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.app-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: var(--transition);
}

.app-status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
  animation: pulse 2s infinite;
}

.app-status-dot.offline {
  background: var(--text-muted);
}

.app-status-dot.checking {
  background: var(--warning);
  animation: pulse 1s infinite;
}

.app-status-text {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.app-status-text.online { color: var(--success); }
.app-status-text.offline { color: var(--text-muted); }
.app-status-text.checking { color: var(--warning); }

.app-open-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.app-item:hover .app-open-btn {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ==================== KNOWLEDGE BASE ==================== */
.kb-panel {
  max-height: 300px;
}

.kb-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
}

.kb-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.kb-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.kb-info { flex: 1; min-width: 0; }

.kb-title {
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-detail {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ==================== WATCHLIST ==================== */
.watchlist-panel {
  max-height: 250px;
}

.virus-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}

.virus-item:hover {
  background: var(--bg-card);
}

.virus-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
}

.virus-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.virus-alerts-count {
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

.virus-alerts-count.has-alerts {
  background: var(--critical-bg);
  color: var(--critical);
}

.virus-alerts-count.no-alerts {
  background: var(--bg-card);
  color: var(--text-muted);
}

.virus-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.virus-dot.active { background: var(--success); }
.virus-dot.alerting {
  background: var(--critical);
  animation: pulse 1.5s infinite;
}

/* ==================== ACTIVITY LOG ==================== */
.log-panel {
  max-height: 200px;
}

.log-entry {
  display: flex;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  border-radius: 4px;
  transition: var(--transition);
}

.log-entry:hover {
  background: var(--bg-card);
}

.log-time {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.log-msg {
  color: var(--text-secondary);
  word-break: break-word;
}

.log-entry.error .log-msg { color: var(--critical); }
.log-entry.success .log-msg { color: var(--success); }
.log-entry.warn .log-msg { color: var(--warning); }

/* ==================== EMPTY STATES ==================== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state.small {
  padding: 1.5rem 1rem;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.empty-state span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==================== SCAN BAR ==================== */
.scan-bar {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1.2rem;
}

.scan-bar-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.scan-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.scan-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

.scan-spinner.idle {
  animation: none;
  border-color: var(--border);
}

.scan-progress {
  flex: 1;
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
}

.scan-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--info));
  border-radius: 2px;
  transition: width 0.5s ease;
}

.scan-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

/* ==================== RESPONSIVE ==================== */

/* --- Tablet (1024px) --- */
@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
  .right-column { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
}

/* --- Mobile (768px) --- */
@media (max-width: 768px) {
  /* Header mobile */
  .header {
    padding: 0.6rem 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .logo h1 { font-size: 0.95rem; }
  .version { display: none; }
  .last-scan { display: none; }
  .header-right { gap: 0.5rem; }
  .status-badge span:last-child { display: none; }
  .btn-icon { width: 32px; height: 32px; }

  /* Main padding */
  .main { padding: 0.8rem; }

  /* Stats grid mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
  }
  .stat-card {
    padding: 0.65rem 0.7rem;
    gap: 0.5rem;
  }
  .stat-icon { width: 32px; height: 32px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-value { font-size: 1rem; }
  .stat-label { font-size: 0.58rem; }
  .stat-trend { display: none; }

  /* Content grid: single column */
  .content-grid { grid-template-columns: 1fr; gap: 0.8rem; }
  .right-column { grid-template-columns: 1fr; }

  /* Panels mobile */
  .panel-header { padding: 0.75rem 0.8rem; }
  .panel-body { padding: 0.4rem; }

  /* Alerts feed mobile */
  .alerts-panel {
    min-height: auto;
    max-height: 50vh;
  }
  .alert-item { padding: 0.6rem; gap: 0.6rem; }
  .alert-title { font-size: 0.8rem; }
  .alert-meta { flex-wrap: wrap; gap: 0.4rem; font-size: 0.65rem; }
  .alert-summary { font-size: 0.73rem; -webkit-line-clamp: 2; }
  .alert-time { font-size: 0.6rem; }

  /* Scan bar mobile */
  .scan-bar { padding: 0.6rem 0.8rem; }
  .scan-bar-content { flex-wrap: wrap; gap: 0.5rem; }
  .scan-progress { order: 3; width: 100%; }
  .scan-status { font-size: 0.72rem; }
  .scan-meta { gap: 0.5rem; font-size: 0.62rem; }

  /* Watchlist mobile */
  .virus-item { padding: 0.5rem 0.6rem; }
  .virus-name { font-size: 0.78rem; }
  .virus-name span:last-child { display: none; }

  /* Log mobile */
  .log-entry { padding: 0.35rem 0.5rem; font-size: 0.68rem; }

  /* Agencies mobile */
  .agency-item { padding: 0.4rem 0.5rem; font-size: 0.7rem; }
  .agency-priority { display: none; }

  /* KB mobile */
  .kb-item { padding: 0.5rem; }
  .kb-title { font-size: 0.73rem; }

  /* Buttons touch-friendly */
  .btn-icon, .btn-small { min-height: 36px; min-width: 36px; }
  .filter-select { font-size: 0.75rem; padding: 0.4rem 0.6rem; min-height: 36px; }
  #btnScanAgencies { min-height: 36px; }
}

/* --- Small mobile (480px) --- */
@media (max-width: 480px) {
  /* Header ultra-compact */
  .header { padding: 0.5rem 0.6rem; }
  .logo h1 { font-size: 0.85rem; }
  .logo-icon svg { width: 20px; height: 20px; }

  /* Main tighter */
  .main { padding: 0.6rem; }

  /* Stats: 2 cols tighter */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.8rem;
  }
  .stat-card {
    padding: 0.55rem 0.6rem;
    gap: 0.4rem;
    border-radius: var(--radius-sm);
  }
  .stat-icon { width: 28px; height: 28px; }
  .stat-icon svg { width: 16px; height: 16px; }
  .stat-value { font-size: 0.9rem; }
  .stat-label { font-size: 0.55rem; }

  /* Panels tighter */
  .panel { border-radius: var(--radius-sm); }
  .panel-header { padding: 0.6rem 0.7rem; }
  .panel-header h2 { font-size: 0.78rem; }
  .panel-body { padding: 0.3rem; }

  /* Alerts compact */
  .alert-item { padding: 0.5rem; gap: 0.5rem; }
  .alert-severity { width: 3px; }
  .alert-title { font-size: 0.78rem; white-space: normal; }
  .alert-meta { font-size: 0.62rem; gap: 0.3rem; }
  .alert-summary { font-size: 0.7rem; }

  /* Preloader mobile */
  .preloader-image-wrapper { width: 200px; height: 200px; }
  .preloader-image { width: 150px; height: 150px; }
  .preloader-text h1 { font-size: 1.8rem; }
  .preloader-subtitle { font-size: 0.9rem; }

  /* Scan bar compact */
  .scan-bar { padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); }
  .scan-bar-content { gap: 0.4rem; }
  .scan-status { font-size: 0.68rem; }
  .scan-spinner { width: 12px; height: 12px; }

  /* Empty states */
  .empty-state { padding: 2rem 0.8rem; }
  .empty-state.small { padding: 1rem 0.5rem; }
  .empty-icon { font-size: 2rem; }
  .empty-state p { font-size: 0.8rem; }
  .empty-state span { font-size: 0.7rem; }

  /* Watchlist ultra-compact */
  .virus-item { padding: 0.4rem 0.5rem; }
  .virus-name { font-size: 0.75rem; gap: 0.3rem; }
  .virus-dot { width: 6px; height: 6px; }

  /* Log compact */
  .log-entry { font-size: 0.65rem; gap: 0.4rem; }
  .log-time { font-size: 0.6rem; }

  /* Badge & buttons */
  .badge { font-size: 0.6rem; padding: 0.15rem 0.5rem; }
  .btn-small { font-size: 0.65rem; }
}

/* ==================== 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); }

/* ==================== AGENCIES ==================== */
.agencies-panel {
  max-height: 350px;
}

.agencies-panel .panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agency-group {
  margin-bottom: 0.5rem;
}

.agency-group-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.2rem;
  font-weight: 600;
}

.agency-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-xs);
  transition: var(--transition);
  font-size: 0.75rem;
}

.agency-item:hover {
  background: var(--bg-card);
}

.agency-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

.agency-flag {
  font-size: 0.9rem;
  flex-shrink: 0;
}

.agency-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.agency-priority {
  font-size: 0.6rem;
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-weight: 500;
  flex-shrink: 0;
}

.agency-priority.high {
  background: var(--critical-bg);
  color: var(--critical);
}

.agency-priority.medium {
  background: var(--warning-bg);
  color: var(--warning);
}

.agency-priority.low {
  background: var(--bg-card);
  color: var(--text-muted);
}

.agency-priority.international,
.agency-priority.regional {
  background: var(--info-bg);
  color: var(--info);
}

#btnScanAgencies {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}

#btnScanAgencies:hover {
  background: var(--success);
  color: white;
}

/* ==================== ANIMATION HELPERS ==================== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 0.4s ease forwards;
}

/* ==================== ALERT DETAIL MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  min-width: 0;
  word-break: break-word;
}

.modal-severity-badge {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.modal-severity-badge.critical { background: var(--critical); color: var(--critical); }
.modal-severity-badge.high { background: var(--high); color: var(--high); }
.modal-severity-badge.medium { background: var(--medium); color: var(--medium); }
.modal-severity-badge.low { background: var(--low); color: var(--low); }

.modal-close {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--critical-bg);
  color: var(--critical);
  border-color: var(--critical);
}

.modal-body {
  padding: 1.4rem;
  overflow-y: auto;
  flex: 1;
}

/* Modal detail sections */
.modal-section {
  margin-bottom: 1.2rem;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.modal-field {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.modal-field:last-child {
  border-bottom: none;
}

.modal-field-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.modal-field-content {
  flex: 1;
  min-width: 0;
}

.modal-field-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.modal-field-value {
  font-size: 0.85rem;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.4;
}

.modal-field-value.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

/* Severity score badges */
.modal-severity-score {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.modal-severity-score.critical {
  background: var(--critical-bg);
  color: var(--critical);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.modal-severity-score.high {
  background: var(--high-bg);
  color: var(--high);
  border: 1px solid rgba(249, 115, 22, 0.2);
}

.modal-severity-score.medium {
  background: var(--medium-bg);
  color: var(--medium);
  border: 1px solid rgba(234, 179, 8, 0.2);
}

.modal-severity-score.low {
  background: var(--low-bg);
  color: var(--low);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

/* Cases grid */
.modal-cases-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.modal-case-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.5rem;
  text-align: center;
}

.modal-case-card .case-value {
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}

.modal-case-card .case-value.has-value { color: var(--critical); }
.modal-case-card .case-value.no-value { color: var(--text-muted); }

.modal-case-card .case-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}

/* Modal link */
.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  word-break: break-all;
  transition: color 0.2s;
}

.modal-link:hover {
  color: var(--info);
  text-decoration: underline;
}

/* Modal summary */
.modal-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Modal actions */
.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-btn {
  flex: 1;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
}

.modal-btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

.modal-btn-primary:hover {
  background: var(--info);
  border-color: var(--info);
}

.modal-btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.modal-btn-secondary:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Modal mobile */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 90vh;
    border-radius: var(--radius-sm);
  }
  .modal-header { padding: 1rem; }
  .modal-title { font-size: 0.85rem; }
  .modal-body { padding: 1rem; }
  .modal-cases-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-actions { flex-direction: column; }
}

@media (max-width: 480px) {
  .modal-content {
    width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
}
