/* ============================================
   SOC AI Agent - Global Styles
   ============================================ */

:root {
  --primary: #1E3A8A;
  --primary-dark: #152C6B;
  --primary-light: #2B4FA8;
  --secondary: #38BDF8;
  --secondary-dark: #0EA5E9;
  --bg: #FFFFFF;
  --bg-light: #F5F7FA;
  --bg-dark: #E8ECF1;
  --text: #212121;
  --text-light: #757575;
  --text-muted: #9E9E9E;
  --success: #4CAF50;
  --success-light: #E8F5E9;
  --warning: #FF9800;
  --warning-light: #FFF3E0;
  --danger: #F44336;
  --danger-light: #FFEBEE;
  --info: #2196F3;
  --info-light: #E3F2FD;
  --border: #E0E0E0;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Dark Mode Variables ---- */
html[data-theme="dark"] {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #3B82F6;
  --secondary: #38BDF8;
  --secondary-dark: #0EA5E9;
  --bg: #0F172A;
  --bg-light: #1E293B;
  --bg-dark: #334155;
  --text: #F1F5F9;
  --text-light: #94A3B8;
  --text-muted: #64748B;
  --success: #22C55E;
  --success-light: rgba(34, 197, 94, 0.15);
  --warning: #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.15);
  --danger: #EF4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --info: #3B82F6;
  --info-light: rgba(59, 130, 246, 0.15);
  --border: #334155;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

/* ---- Theme Toggle Button ---- */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  margin-right: 8px;
}
.theme-toggle:hover {
  background: var(--primary);
  color: #fff;
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-light);
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

/* ============================================
   Layout
   ============================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1000;
  transition: var(--transition);
  box-shadow: 2px 0 12px rgba(0,0,0,0.1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand img {
  height: 112px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  scrollbar-width: none;           /* Firefox */
  -ms-overflow-style: none;        /* IE/Edge */
}

.sidebar-nav::-webkit-scrollbar {
  display: none;                   /* Chrome/Safari */
}

.sidebar-nav ul {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
  color: rgba(255,255,255,0.75);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(255,255,255,0.15);
  box-shadow: inset 3px 0 0 var(--secondary);
}

.sidebar-nav i {
  width: 22px;
  text-align: center;
  font-size: 1.05rem;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  text-align: center;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

.topbar {
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.user-menu:hover {
  background: var(--bg-light);
}

.user-menu .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  flex-shrink: 0;
}

.user-menu .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.user-menu .user-info {
  line-height: 1.3;
}

.user-menu .user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-menu .user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

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

/* ============================================
   Mobile Sidebar Toggle
   ============================================ */

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999;
}

@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .sidebar-overlay.active {
    display: block;
  }
}

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-light);
}

/* ============================================
   Stats Grid
   ============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 1399px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 991px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

/* ============ Page toolbar utility ============ */
.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.if-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 991px) {
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .filters-bar,
  .filter-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .filters-bar select,
  .filters-bar input,
  .filters-bar button,
  .filter-bar select,
  .filter-bar input,
  .filter-bar button {
    max-width: 100%;
  }
}

@media (max-width: 767px) {
  .topbar-title {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .if-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .if-filter-bar select,
  .if-filter-bar input {
    min-width: 0 !important;
    width: 100% !important;
  }
  #tiHistoryContent {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============ RESPONSIVE 480px — iPhone 12/13/14 target ============ */
@media (max-width: 480px) {
    .topbar { padding: 8px 12px; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
    .topbar > .d-flex:first-child { flex: 1 1 auto; min-width: 0; max-width: 100%; }
    .topbar-title { font-size: 1rem; max-width: 100%; }
    .topbar-actions {
      width: 100%;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 8px;
    }
    .topbar-actions .btn { max-width: 100%; }
    .topbar-actions .btn .btn-label-hide-xs { display: none; }
    .user-menu { min-width: 0; max-width: 100%; }
    .user-menu .user-info { display: none; }
    .card { padding: 12px; border-radius: 6px; }
    .card-header { padding: 10px 12px; }
    .card-body { padding: 10px 12px; }
    .table-container { max-width: 100%; margin: 0 -4px; }
    table { font-size: 0.78rem; }
    th, td { padding: 6px 8px; }
    .tabs { flex-wrap: wrap; gap: 2px; }
    .tabs .tab { padding: 6px 10px; font-size: 0.78rem; }
    .stats-grid { grid-template-columns: 1fr !important; gap: 8px; }
    .stat-card { padding: 10px 12px; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .form-row { flex-direction: column; gap: 6px; }
    .form-row > * { width: 100%; }
    .grid-2 { grid-template-columns: 1fr; gap: 10px; }
    input, select, textarea { font-size: 0.85rem; padding: 6px 8px; }
    .form-group { margin-bottom: 10px; }
    .form-group label { font-size: 0.78rem; }
    .modal { width: 98%; max-width: 100%; margin: 0 auto; border-radius: 8px; }
    .modal-body { padding: 12px 16px; }
    .modal-header { padding: 10px 16px; }
    .modal-footer { padding: 10px 16px; flex-direction: column; gap: 8px; }
    .modal-footer .btn { width: 100%; }
    .btn { padding: 6px 14px; font-size: 0.82rem; }
    .btn-sm { padding: 4px 10px; font-size: 0.75rem; }
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.1rem; }
    h3 { font-size: 1rem; }
    h4 { font-size: 0.92rem; }
    .filter-bar,
    .filters-bar { flex-direction: column; gap: 6px; align-items: stretch; }
    .filter-bar select, .filter-bar input, .filter-bar button,
    .filters-bar select, .filters-bar input, .filters-bar button {
      width: 100% !important;
      max-width: 100% !important;
    }
    .filters-bar .export-dropdown { width: 100%; margin-left: 0 !important; }
    .page-toolbar { flex-direction: column; align-items: stretch; }
    .page-toolbar .btn { width: 100%; }
    .settings-card .card-header { flex-wrap: wrap; gap: 8px; }
    .settings-save-area .btn { width: 100%; }
    .profile-card-header { flex-wrap: wrap; gap: 8px; }
    #twoFactorSetup .d-flex { flex-direction: column; align-items: stretch; }
    #twoFactorSetup .d-flex .btn { width: 100%; }
    .page-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .charts-grid { grid-template-columns: 1fr; gap: 12px; }
    .chart-container { min-height: 220px; }
    .profile-grid { grid-template-columns: 1fr; gap: 12px; }
    .badge { font-size: 0.7rem; padding: 2px 6px; }
    .section-title { font-size: 0.9rem; margin-bottom: 8px; }
    .toast { max-width: 90vw; font-size: 0.82rem; padding: 10px 14px; }
    .stats-row { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; gap: 6px; }
    .module-check-grid { grid-template-columns: 1fr; }
    .chat-header select { min-width: 0; flex: 1; }
    .chat-header { flex-wrap: wrap; gap: 6px; }
    .page-content { padding: 14px 10px; }
    .table .col-api-key { display: none; }
}

/* Dark mode — inline page modals (false-positives base) */
html[data-theme="dark"] .fp-modal,
html[data-theme="dark"] .fp-modal-header {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}
html[data-theme="dark"] .fp-modal select.form-control,
html[data-theme="dark"] .fp-modal input.form-control {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}
html[data-theme="dark"] .settings-card .form-control {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

.stat-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
}

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

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

.stat-icon.primary {
  background: var(--primary);
  color: #fff;
}

.stat-icon.secondary {
  background: var(--secondary);
  color: #fff;
}

.stat-icon.success {
  background: var(--success);
  color: #fff;
}

.stat-icon.warning {
  background: var(--warning);
  color: #fff;
}

.stat-icon.danger {
  background: var(--danger);
  color: #fff;
}

.stat-icon.neutral {
  background: #64748B;
  color: #fff;
}
html[data-theme="dark"] .stat-icon.neutral {
  background: #475569;
  color: #E2E8F0;
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-change {
  font-size: 0.8rem;
  margin-top: 4px;
  font-weight: 500;
}

.stat-change.up {
  color: var(--success);
}

.stat-change.down {
  color: var(--danger);
}

/* ============================================
   Tables
   ============================================ */

.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table thead th {
  background: var(--bg-light);
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr {
  transition: var(--transition);
}

.table tbody tr:hover {
  background: var(--bg-light);
}

.table tbody tr.row-blocked {
  background: rgba(100, 116, 139, 0.04);
}
.table tbody tr.row-blocked:hover {
  background: rgba(100, 116, 139, 0.08);
}
html[data-theme="dark"] .table tbody tr.row-blocked {
  background: rgba(100, 116, 139, 0.06);
}
html[data-theme="dark"] .table tbody tr.row-blocked:hover {
  background: rgba(100, 116, 139, 0.12);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table .actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

/* ============================================
   Badges
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.4;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: #E65100;
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

.badge-primary {
  background: rgba(26, 35, 126, 0.1);
  color: var(--primary);
}

.badge-light {
  background: var(--bg-light);
  color: var(--text-light);
}

/* Severity badges */
.badge-critical {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-high {
  background: #FFF3E0;
  color: #E65100;
}

.badge-medium {
  background: var(--warning-light);
  color: #E65100;
}

.badge-low {
  background: var(--info-light);
  color: var(--info);
}

/* Blocked WAF status badge */
.badge-blocked {
  background: #E2E8F0;
  color: #475569;
  border: 1px solid #CBD5E1;
}
.badge-blocked i {
  font-size: 0.7rem;
}
html[data-theme="dark"] .badge-blocked {
  background: rgba(100, 116, 139, 0.2);
  color: #94A3B8;
  border-color: rgba(148, 163, 184, 0.25);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-secondary:hover {
  background: var(--secondary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #388E3C;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #D32F2F;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(26, 35, 126, 0.04);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================
   Forms
   ============================================ */

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.12);
}

.form-control::placeholder {
  color: var(--text-muted);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

select.form-control {
   appearance: auto;
   padding-right: 12px;
   cursor: pointer;
}

.form-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 767px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

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

.modal {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px) scale(0.96);
  transition: var(--transition);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-light);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-light);
}

/* ============================================
   Login Page — Split Screen
   ============================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  padding: 0;
  margin: 0;
  background: #fff;
  position: relative;
  overflow: hidden;
}

/* --- Left Panel: Banner --- */
.login-banner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F1B4D 0%, #1E3A8A 50%, #162D6B 100%);
  position: relative;
  overflow: hidden;
  padding: 40px;
}

.login-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.login-banner-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #fff;
}

.login-banner-logo {
  height: 196px;
  width: auto;
  margin-bottom: 24px;
  filter: brightness(0) invert(1);
}

.login-banner-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #fff;
}

.login-banner-subtitle {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 32px;
  line-height: 1.6;
}

.login-banner-features {
  list-style: none;
  padding: 0;
  text-align: left;
  max-width: 320px;
  margin: 0 auto;
}

.login-banner-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
}

.login-banner-features li i {
  color: #38BDF8;
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

/* --- Right Panel: Form --- */
.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: #fff;
  min-height: 100vh;
}

.login-form-wrapper {
  width: 100%;
  max-width: 400px;
}

.login-form-header {
  margin-bottom: 32px;
}

.login-form-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.login-form-header p {
  color: var(--text-light);
  font-size: 0.95rem;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form .form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.login-form .form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: var(--transition);
  background: var(--bg-light);
}

.login-form .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
  background: #fff;
}

.login-form .btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  margin-top: 8px;
}

.login-form .form-footer {
  text-align: center;
  margin-top: 20px;
}

.login-form .form-footer a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.login-form .form-footer a:hover {
  text-decoration: underline;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Alerts --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.9rem;
  display: none;
  align-items: center;
  gap: 10px;
}

.alert.show {
  display: flex;
}

.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(244, 67, 54, 0.2);
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(76, 175, 80, 0.2);
}

/* --- Login Responsive --- */
@media (max-width: 991px) {
  .login-page {
    flex-direction: column;
  }

  .login-banner {
    min-height: auto;
    padding: 40px 24px 32px;
  }

  .login-banner-logo {
    height: 112px;
    margin-bottom: 16px;
  }

  .login-banner-title {
    font-size: 1.5rem;
  }

  .login-banner-subtitle {
    display: none;
  }

  .login-banner-features {
    display: none;
  }

  .login-form-panel {
    min-height: auto;
    padding: 32px 24px;
  }
}

@media (max-width: 576px) {
  .login-banner {
    padding: 24px 16px;
  }

  .login-form-panel {
    padding: 24px 16px;
  }
}

/* ============================================
   Chat Interface
   ============================================ */

.chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height) - 56px);
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-light);
}

.chat-header select {
  min-width: 220px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #FAFBFC;
}

.chat-message {
  display: flex;
  gap: 12px;
  max-width: 80%;
  animation: messageIn 0.3s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  font-weight: 600;
}

.chat-message.user .chat-avatar {
  background: var(--primary);
  color: #fff;
}

.chat-message.bot .chat-avatar {
  background: var(--secondary);
  color: #fff;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-message.user .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.bot .chat-bubble {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-message.bot .chat-bubble pre {
  background: var(--bg-light);
  padding: 10px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-top: 8px;
  font-size: 0.85rem;
}

.chat-message.bot .chat-bubble code {
  background: var(--bg-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: 'Consolas', 'Monaco', monospace;
}

.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-input-area input {
  flex: 1;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h4 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ============================================
   Loading Spinner
   ============================================ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.btn .spinner {
  width: 16px;
  height: 16px;
  border-top-color: currentColor;
}

/* ============================================
   Tabs
   ============================================ */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--primary);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================
   Utilities
   ============================================ */

.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.w-100 { width: 100%; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-dark);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   Charts
   ============================================ */

.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

.chart-card:hover {
  box-shadow: var(--shadow);
}

.chart-card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.chart-card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.chart-card-body {
  padding: 20px 24px;
  min-height: 250px;
  position: relative;
}

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

/* ============================================
   Profile Page
   ============================================ */

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  padding: 0;
}

.profile-card {
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.profile-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profile-card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-card-header h3 i {
  color: var(--primary);
}

.profile-card-body {
  padding: 24px;
}

.profile-card-body .form-group {
  margin-bottom: 16px;
}

.profile-card-body .form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.profile-card-body .form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: var(--transition);
  background: var(--bg-light);
}

.profile-card-body .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
  background: #fff;
}

.profile-card-body .form-control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.profile-card-body .btn {
  margin-top: 8px;
}

/* Avatar Upload */
.avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.avatar-preview {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--border);
  position: relative;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  color: var(--text-muted);
  font-size: 2.5rem;
}

.avatar-actions {
  display: flex;
  gap: 8px;
}

.avatar-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* 2FA */
.two-factor-desc {
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.6;
  margin-bottom: 16px;
}

.two-factor-secret {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.two-factor-secret code {
  background: var(--bg-light);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.qr-code-container {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 16px 0;
}

.qr-code-container img {
  display: block !important;
}

.qr-code-container canvas {
  display: none !important;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-secondary {
  background: var(--bg-light);
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

.toast.show {
  display: flex;
}

.toast-success {
  background: var(--success);
  color: #fff;
}

.toast-error {
  background: var(--danger);
  color: #fff;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Utility helpers */
.d-flex {
  display: flex;
}

.gap-2 {
  gap: 8px;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #d32f2f;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #388e3c;
}

/* Profile responsive */
@media (max-width: 767px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Detail View Styles
   ============================================ */

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 16px;
  margin-bottom: 16px;
}
.detail-grid dt {
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.85rem;
}
.detail-grid dd {
  margin: 0;
}
.detail-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.detail-section h4 {
  margin-bottom: 12px;
  color: var(--primary);
}
.ai-analysis-content {
  background: var(--bg-light);
  padding: 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}
.mini-table {
  width: 100%;
  font-size: 0.85rem;
}
.mini-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.mini-table td {
  padding: 6px 8px;
}

/* Blocked attack banner for log-detail page */
.blocked-banner {
  background: linear-gradient(135deg, #F1F5F9, #E2E8F0);
  border-left: 4px solid #64748B;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #475569;
  font-weight: 500;
  font-size: 0.92rem;
}
.blocked-banner i {
  font-size: 1.3rem;
  color: #64748B;
  flex-shrink: 0;
}
html[data-theme="dark"] .blocked-banner {
  background: linear-gradient(135deg, rgba(100,116,139,0.15), rgba(100,116,139,0.06));
  border-left-color: #64748B;
  color: #94A3B8;
}
html[data-theme="dark"] .blocked-banner i {
  color: #94A3B8;
}

/* ===== Detail Pages ===== */
.detail-page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.detail-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary, #f1f5f9);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    color: var(--text-primary, #1e293b);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.detail-back-btn:hover {
    background: var(--bg-tertiary, #e2e8f0);
}

.detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.detail-card {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.detail-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.detail-info-item {
    padding: 12px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: 8px;
}

.detail-info-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    word-break: break-all;
}

/* Raw Log Display */
.raw-log-content {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* Analysis Badges */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.score-badge.critical { background: linear-gradient(135deg, #dc2626, #991b1b); }
.score-badge.high { background: linear-gradient(135deg, #ea580c, #c2410c); }
.score-badge.medium { background: linear-gradient(135deg, #d97706, #b45309); }
.score-badge.low { background: linear-gradient(135deg, #65a30d, #4d7c0f); }
.score-badge.info { background: linear-gradient(135deg, #0ea5e9, #0284c7); }

/* Agent Analysis Cards */
.agent-results {
    margin-top: 16px;
}

.agent-card {
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.agent-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    background: var(--bg-card, #ffffff);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    transition: background 0.2s;
}

.agent-card-header:hover {
    background: var(--bg-tertiary, #f1f5f9);
}

.agent-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.agent-card-toggle {
    font-size: 12px;
    color: var(--text-muted, #64748b);
    transition: transform 0.2s;
}

.agent-card.collapsed .agent-card-toggle {
    transform: rotate(-90deg);
}

.agent-card-content {
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, #475569);
}

.agent-card.collapsed .agent-card-content {
    display: none;
}

/* IOC Tags */
.ioc-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    margin: 2px 4px 2px 0;
}

.ioc-tag.ip { background: #fef3c7; color: #92400e; }
.ioc-tag.domain { background: #dbeafe; color: #1e40af; }
.ioc-tag.url { background: #fce7f3; color: #9d174d; }
.ioc-tag.hash { background: #e0e7ff; color: #3730a3; }
.ioc-tag.email { background: #d1fae5; color: #065f46; }
.ioc-tag.port { background: #f3e8ff; color: #6b21a8; }
.ioc-tag.default { background: #f1f5f9; color: #475569; }

/* Resolution Section */
.resolution-box {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 16px;
}

.resolution-box .resolution-label {
    font-size: 12px;
    font-weight: 600;
    color: #166534;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.resolution-box .resolution-text {
    font-size: 14px;
    color: #15803d;
    line-height: 1.6;
}

/* Manual Analysis Page */
.analysis-form {
    max-width: 800px;
}

.analysis-textarea {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    min-height: 200px;
    resize: vertical;
}

.analysis-results {
    margin-top: 24px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.result-stat {
    text-align: center;
    padding: 20px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
}

.result-stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.result-stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color, #e2e8f0);
    border-top-color: var(--primary, #1E3A8A);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 14px;
    color: var(--text-muted, #64748b);
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Mini Tables in Detail Pages */
.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.mini-table th {
    background: var(--bg-secondary, #f8fafc);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    border-bottom: 2px solid var(--border-color, #e2e8f0);
}

.mini-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-primary, #1e293b);
}

.mini-table tr {
    cursor: pointer;
    transition: background 0.2s;
}

.mini-table tr:hover {
    background: var(--bg-tertiary, #f1f5f9);
}

/* API Key with Copy Button */
.api-key-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-key-value {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    padding: 6px 10px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: 6px;
    flex: 1;
    word-break: break-all;
}

.copy-btn {
    padding: 6px 12px;
    background: var(--primary, #1E3A8A);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 0.8;
}

/* ============ DARK MODE OVERRIDES ============ */

/* --- Sidebar --- */
html[data-theme="dark"] .sidebar {
  background: #0F172A;
  box-shadow: 2px 0 12px rgba(0,0,0,0.3);
}

html[data-theme="dark"] .sidebar-brand {
  border-bottom-color: rgba(255,255,255,0.06);
}

html[data-theme="dark"] .sidebar-nav a {
  color: rgba(255,255,255,0.65);
}

html[data-theme="dark"] .sidebar-nav a:hover,
html[data-theme="dark"] .sidebar-nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

html[data-theme="dark"] .sidebar-nav a.active {
  background: rgba(37, 99, 235, 0.2);
  box-shadow: inset 3px 0 0 var(--secondary);
}

html[data-theme="dark"] .sidebar-footer {
  border-top-color: rgba(255,255,255,0.06);
  color: #94A3B8;
}

html[data-theme="dark"] .sidebar-footer a {
  color: #94A3B8;
}

/* --- Topbar --- */
html[data-theme="dark"] .topbar {
  background: #1E293B;
  border-bottom-color: #334155;
}

html[data-theme="dark"] .topbar-title {
  color: var(--primary-light);
}

html[data-theme="dark"] .user-menu:hover {
  background: #334155;
}

/* --- Cards --- */
html[data-theme="dark"] .card {
  background: #1E293B;
  border-color: #334155;
}

html[data-theme="dark"] .card-header {
  border-bottom-color: #334155;
}

html[data-theme="dark"] .card-footer {
  border-top-color: #334155;
  background: #0F172A;
}

html[data-theme="dark"] .profile-card {
  background: #1E293B;
  border-color: #334155;
}

html[data-theme="dark"] .profile-card-header {
  border-bottom-color: #334155;
}

html[data-theme="dark"] .profile-card-body .form-control {
  background: #0F172A;
  border-color: #475569;
}

html[data-theme="dark"] .profile-card-body .form-control:focus {
  background: #0F172A;
  border-color: var(--primary);
}

/* --- Stats Grid --- */
html[data-theme="dark"] .stats-grid .stat-card {
  background: #1E293B;
  border-color: #334155;
}

html[data-theme="dark"] .stats-row .stat-card {
  background: #1E293B;
  border-color: #334155;
}

/* --- Tables --- */
html[data-theme="dark"] .table thead th {
  background: #334155;
  color: #94A3B8;
  border-bottom-color: #475569;
}

html[data-theme="dark"] .table tbody td {
  border-bottom-color: #334155;
  color: #F1F5F9;
}

html[data-theme="dark"] .table tbody tr:hover {
  background: #334155;
}

/* --- Forms --- */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #1E293B;
  border-color: #475569;
  color: #F1F5F9;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #64748B;
}

html[data-theme="dark"] select.form-control {
   color-scheme: dark;
}

html[data-theme="dark"] .form-control {
  background: #1E293B;
  border-color: #475569;
  color: #F1F5F9;
}

html[data-theme="dark"] .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* --- Fix select dropdowns in dark mode --- */
html[data-theme="dark"] select option {
  background-color: #1e293b;
  color: #f1f5f9;
}
html[data-theme="dark"] .ti-type-select {
  background: #1e293b;
  color: #f1f5f9;
}
html[data-theme="dark"] .ti-type-select option {
  background: #1e293b;
  color: #f1f5f9;
}

/* --- Modal --- */
html[data-theme="dark"] .modal {
  background: #1E293B;
}

html[data-theme="dark"] .modal-header {
  border-bottom-color: #334155;
}

html[data-theme="dark"] .modal-close:hover {
  background: #334155;
}

html[data-theme="dark"] .modal-footer {
  border-top-color: #334155;
  background: #0F172A;
}

/* --- Login Page --- */
html[data-theme="dark"] .login-page {
  background: #0F172A;
}

html[data-theme="dark"] .login-form-panel {
  background: #1E293B;
}

html[data-theme="dark"] .login-form .form-control {
  background: #0F172A;
  border-color: #475569;
  color: #F1F5F9;
}

html[data-theme="dark"] .login-form .form-control:focus {
  background: #0F172A;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- Alerts --- */
html[data-theme="dark"] .alert-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
}

html[data-theme="dark"] .alert-success {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
}

/* --- Badges --- */
html[data-theme="dark"] .badge-light {
  background: #334155;
  color: #E2E8F0;
}

html[data-theme="dark"] .badge-primary {
  background: rgba(37, 99, 235, 0.2);
  color: #93C5FD;
}

html[data-theme="dark"] .badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #FCD34D;
}

html[data-theme="dark"] .badge-high {
  background: rgba(245, 158, 11, 0.15);
  color: #FCD34D;
}

html[data-theme="dark"] .badge-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #FCD34D;
}

html[data-theme="dark"] .badge-secondary {
  background: #334155;
  color: #94A3B8;
}

/* --- Chat Interface --- */
html[data-theme="dark"] .chat-layout {
  background: #1E293B;
  border-color: #334155;
}

html[data-theme="dark"] .chat-header {
  background: #1E293B;
  border-bottom-color: #334155;
}

html[data-theme="dark"] .chat-messages {
  background: #0F172A;
}

html[data-theme="dark"] .chat-message.bot .chat-bubble {
  background: #1E293B;
  border-color: #334155;
  color: #F1F5F9;
}

html[data-theme="dark"] .chat-message.bot .chat-bubble pre {
  background: #0F172A;
}

html[data-theme="dark"] .chat-message.bot .chat-bubble code {
  background: #0F172A;
}

html[data-theme="dark"] .chat-input-area {
  background: #1E293B;
  border-top-color: #334155;
}

/* --- Code / Pre --- */
html[data-theme="dark"] pre,
html[data-theme="dark"] code {
  background: #0F172A;
  color: #E2E8F0;
}

html[data-theme="dark"] .ai-analysis-content {
  background: #0F172A;
  color: #E2E8F0;
}

html[data-theme="dark"] .two-factor-secret code {
  background: #0F172A;
}

/* --- Toast --- */
html[data-theme="dark"] .toast {
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* --- Empty State --- */
html[data-theme="dark"] .empty-state {
  color: #94A3B8;
}

html[data-theme="dark"] .empty-state h4 {
  color: #F1F5F9;
}

/* --- Detail Pages --- */
html[data-theme="dark"] .detail-page-header {
  border-bottom-color: #334155;
}

html[data-theme="dark"] .detail-back-btn {
  background: #334155;
  border-color: #475569;
  color: #F1F5F9;
}

html[data-theme="dark"] .detail-back-btn:hover {
  background: #475569;
}

html[data-theme="dark"] .detail-title {
  color: #F1F5F9;
}

html[data-theme="dark"] .detail-card {
  background: #1E293B;
  border-color: #334155;
}

html[data-theme="dark"] .detail-card-title {
  color: #F1F5F9;
  border-bottom-color: #334155;
}

html[data-theme="dark"] .detail-info-item {
  background: #0F172A;
}

html[data-theme="dark"] .detail-info-label {
  color: #64748B;
}

html[data-theme="dark"] .detail-info-value {
  color: #F1F5F9;
}

html[data-theme="dark"] .detail-section {
  border-top-color: #334155;
}

/* --- Raw Log --- */
html[data-theme="dark"] .raw-log-content {
  background: #020617;
  border: 1px solid #334155;
}

/* --- Agent Cards --- */
html[data-theme="dark"] .agent-card {
  background: #1E293B;
  border-color: #334155;
}

html[data-theme="dark"] .agent-card-header {
  background: #1E293B;
  border-bottom-color: #334155;
}

html[data-theme="dark"] .agent-card-header:hover {
  background: #334155;
}

html[data-theme="dark"] .agent-card-title {
  color: #F1F5F9;
}

html[data-theme="dark"] .agent-card-content {
  color: #CBD5E1;
}

/* --- IOC Tags --- */
html[data-theme="dark"] .ioc-tag.ip { background: rgba(254, 243, 199, 0.15); color: #FCD34D; }
html[data-theme="dark"] .ioc-tag.domain { background: rgba(219, 234, 254, 0.15); color: #93C5FD; }
html[data-theme="dark"] .ioc-tag.url { background: rgba(252, 231, 243, 0.15); color: #F9A8D4; }
html[data-theme="dark"] .ioc-tag.hash { background: rgba(224, 231, 255, 0.15); color: #C7D2FE; }
html[data-theme="dark"] .ioc-tag.email { background: rgba(209, 250, 229, 0.15); color: #6EE7B7; }
html[data-theme="dark"] .ioc-tag.port { background: rgba(243, 232, 255, 0.15); color: #D8B4FE; }
html[data-theme="dark"] .ioc-tag.default { background: #334155; color: #CBD5E1; }

/* --- Resolution Box --- */
html[data-theme="dark"] .resolution-box {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));
  border-color: rgba(34, 197, 94, 0.3);
}

html[data-theme="dark"] .resolution-box .resolution-label {
  color: #6EE7B7;
}

html[data-theme="dark"] .resolution-box .resolution-text {
  color: #86EFAC;
}

/* --- Score Badges (ensure contrast) --- */
html[data-theme="dark"] .score-badge.critical { background: linear-gradient(135deg, #dc2626, #991b1b); }
html[data-theme="dark"] .score-badge.high { background: linear-gradient(135deg, #ea580c, #c2410c); }
html[data-theme="dark"] .score-badge.medium { background: linear-gradient(135deg, #d97706, #b45309); }
html[data-theme="dark"] .score-badge.low { background: linear-gradient(135deg, #65a30d, #4d7c0f); }
html[data-theme="dark"] .score-badge.info { background: linear-gradient(135deg, #0ea5e9, #0284c7); }

/* --- Analysis Results --- */
html[data-theme="dark"] .analysis-results {
  background: #1E293B;
}

html[data-theme="dark"] .result-stat {
  background: #1E293B;
  border-color: #334155;
}

html[data-theme="dark"] .result-stat-value {
  color: #F1F5F9;
}

html[data-theme="dark"] .manual-analysis-form textarea,
html[data-theme="dark"] .analysis-textarea {
  background: #1E293B;
  border-color: #475569;
  color: #F1F5F9;
}

/* --- Mini Tables --- */
html[data-theme="dark"] .mini-table th {
  background: #334155;
  color: #94A3B8;
  border-bottom-color: #475569;
}

html[data-theme="dark"] .mini-table td {
  border-bottom-color: #334155;
  color: #F1F5F9;
}

html[data-theme="dark"] .mini-table tr:hover {
  background: #334155;
}

/* --- API Key --- */
html[data-theme="dark"] .api-key-container {
  background: #0F172A;
}

html[data-theme="dark"] .api-key-value {
  background: #0F172A;
  color: #E2E8F0;
}

/* --- QR Code Container --- */
html[data-theme="dark"] .qr-code-container {
  background: #fff;
}

/* --- Avatar Placeholder --- */
html[data-theme="dark"] .avatar-placeholder {
  background: #334155;
  color: #64748B;
}

/* --- Chart Cards --- */
html[data-theme="dark"] .chart-card {
  background: #1E293B;
  border-color: #334155;
}

html[data-theme="dark"] .chart-card-header {
  border-bottom-color: #334155;
}

html[data-theme="dark"] .chart-card-body {
  background: transparent;
}

/* --- Scrollbar --- */
html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #1E293B;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #475569;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #64748B;
}

/* --- Profile Page Cards --- */
html[data-theme="dark"] .profile-page .card {
  background: #1E293B;
  border-color: #334155;
}

/* --- Tabs --- */
html[data-theme="dark"] .tabs {
  border-bottom-color: #334155;
}

/* --- Spinner --- */
html[data-theme="dark"] .spinner {
  border-color: #334155;
}

/* --- Loading --- */
html[data-theme="dark"] .loading-text {
  color: #94A3B8;
}

/* --- Buttons adjustments --- */
html[data-theme="dark"] .btn-outline {
  border-color: #475569;
  color: #F1F5F9;
}

html[data-theme="dark"] .btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
}

/* --- General hardcoded color overrides --- */
html[data-theme="dark"] .user-menu .avatar {
  background: var(--primary);
}

html[data-theme="dark"] .stat-icon.primary {
  background: var(--primary);
}

html[data-theme="dark"] .stat-icon.secondary {
  background: var(--secondary);
}

html[data-theme="dark"] .stat-icon.success {
  background: var(--success);
}

html[data-theme="dark"] .stat-icon.warning {
  background: var(--warning);
}

html[data-theme="dark"] .stat-icon.danger {
  background: var(--danger);
}

/* --- Card titles & text --- */
html[data-theme="dark"] .card-title { color: #F1F5F9; }
html[data-theme="dark"] .card-title i { color: var(--secondary); }
html[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
html[data-theme="dark"] .text-info { color: var(--info) !important; }
html[data-theme="dark"] .text-danger { color: var(--danger) !important; }
html[data-theme="dark"] .text-success { color: var(--success) !important; }
html[data-theme="dark"] .text-warning { color: var(--warning) !important; }
html[data-theme="dark"] .text-primary { color: var(--primary-light) !important; }
html[data-theme="dark"] .card-body { color: var(--text); }
html[data-theme="dark"] .card-body p { color: var(--text-light); }
html[data-theme="dark"] .card-body h3,
html[data-theme="dark"] .card-body h4 { color: #F1F5F9; }
html[data-theme="dark"] h3, html[data-theme="dark"] h4 { color: #F1F5F9; }

/* --- Topbar --- */
html[data-theme="dark"] .user-name { color: #F1F5F9; }
html[data-theme="dark"] .user-role { color: #94A3B8; }

/* --- Page content --- */
html[data-theme="dark"] .page-content { color: var(--text); }
html[data-theme="dark"] main { color: var(--text); }

/* --- Links --- */
html[data-theme="dark"] a { color: var(--secondary); }
html[data-theme="dark"] a:hover { color: var(--secondary-dark); }
html[data-theme="dark"] .btn-outline { color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .btn-outline:hover { background: var(--bg-dark); color: #fff; }

/* --- Chart cards --- */
html[data-theme="dark"] .chart-card { background: #1E293B; border: 1px solid #334155; }
html[data-theme="dark"] .chart-card-header { border-bottom-color: #334155; }
html[data-theme="dark"] .chart-card-header h3 { color: #F1F5F9; }

/* --- Grid layouts --- */
html[data-theme="dark"] .grid-2 > * { color: var(--text); }

/* --- Empty states --- */
html[data-theme="dark"] .empty-state { color: var(--text-muted); }
html[data-theme="dark"] .empty-state i { color: var(--text-muted); }

/* --- Toast --- */
html[data-theme="dark"] .toast { background: #334155; color: #F1F5F9; }

/* --- Description lists --- */
html[data-theme="dark"] dt { color: #94A3B8; }
html[data-theme="dark"] dd { color: #F1F5F9; }

/* --- Code blocks --- */
html[data-theme="dark"] code { background: #0F172A; color: #E2E8F0; }

/* --- Badge fixes for dark mode --- */
html[data-theme="dark"] .badge-critical { background: rgba(239,68,68,0.2); color: #FCA5A5; }
html[data-theme="dark"] .badge-high { background: rgba(249,115,22,0.2); color: #FDBA74; }
html[data-theme="dark"] .badge-medium { background: rgba(245,158,11,0.2); color: #FCD34D; }
html[data-theme="dark"] .badge-low { background: rgba(34,197,94,0.2); color: #86EFAC; }
html[data-theme="dark"] .badge-info { background: rgba(59,130,246,0.2); color: #93C5FD; }
html[data-theme="dark"] .badge-success { background: rgba(34,197,94,0.2); color: #86EFAC; }
html[data-theme="dark"] .badge-danger { background: rgba(239,68,68,0.2); color: #FCA5A5; }
html[data-theme="dark"] .badge-warning { background: rgba(245,158,11,0.2); color: #FCD34D; }

/* ============================================
   Toggle Switch
   ============================================ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-dark);
  border-radius: 26px;
  transition: 0.3s;
}
.toggle-slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

/* ============================================
   Settings Page
   ============================================ */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 780px;
}
.settings-card .card-header {
  gap: 12px;
}
.settings-card .card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.settings-card .card-title i {
  font-size: 1.2rem;
  color: var(--primary);
  width: 24px;
  text-align: center;
}
.settings-desc {
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 4px;
}
.settings-toggle-fields {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.settings-checkbox-row {
  padding: 10px 0;
}
.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
}
.settings-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.settings-checkbox-label {
  user-select: none;
}
.settings-save-area {
  padding-top: 8px;
}
.settings-save-area .btn {
  padding: 14px 40px;
  font-size: 1rem;
}

/* ============================================
   Export Dropdown
   ============================================ */
.export-dropdown .export-menu .export-item:hover {
  background: var(--bg-light);
}

/* ============================================
   Timeline Duration
   ============================================ */
.timeline-duration {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.timeline-duration strong {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   Viewer Role — Hide action buttons
   ============================================ */
html body.is-viewer .btn-primary:not(.viewer-allowed),
html body.is-viewer button[onclick*="create" i]:not(.viewer-allowed),
html body.is-viewer button[onclick*="save" i]:not(.viewer-allowed),
html body.is-viewer button[onclick*="delete" i]:not(.viewer-allowed),
html body.is-viewer button[onclick*="remove" i]:not(.viewer-allowed),
html body.is-viewer button[onclick*="excluir"],
html body.is-viewer button[onclick*="salvar"],
html body.is-viewer button[onclick*="criar"],
html body.is-viewer button[onclick*="remover"] {
    display: none !important;
}
html body.is-viewer .theme-toggle,
html body.is-viewer #logoutBtn,
html body.is-viewer #sidebarToggle,
html body.is-viewer .sidebar-toggle {
    display: inline-flex !important;
}

/* ============================================
   Module Checkbox Grid (Team page)
   ============================================ */
.module-check-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    margin-top: 8px;
}
.module-check-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 0;
}
.module-check-grid label.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.module-check-grid input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ============================================
   Dark Mode Toggle Switch
   ============================================ */
html[data-theme="dark"] .toggle-slider {
  background: #475569;
}
html[data-theme="dark"] .toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

html[data-theme="dark"] .settings-checkbox input[type="checkbox"] {
  accent-color: var(--primary);
}

html[data-theme="dark"] .export-dropdown .export-menu {
  background: #1E293B;
  border-color: #334155;
}
html[data-theme="dark"] .export-dropdown .export-menu .export-item {
  color: #F1F5F9;
}
html[data-theme="dark"] .export-dropdown .export-menu .export-item:hover {
  background: #334155;
}

/* --- Specific dashboard dark mode fixes --- */
html[data-theme="dark"] .stat-info .stat-label { color: var(--text-light); }
html[data-theme="dark"] .stat-info .stat-value { color: #F1F5F9; }
html[data-theme="dark"] .sidebar-toggle { color: var(--text-light); }
html[data-theme="dark"] .sidebar-toggle:hover { color: #fff; background: #334155; }

/* --- Tab fixes --- */
html[data-theme="dark"] .tab-btn { color: var(--text-light); }
html[data-theme="dark"] .tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }

/* ============================================================
   MARKDOWN RENDERED CONTENT (marked.js)
   ============================================================ */
.chat-bubble table,
#aiChatMessages table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 0.82rem;
}
.chat-bubble th, .chat-bubble td,
#aiChatMessages th, #aiChatMessages td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.chat-bubble th,
#aiChatMessages th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.78rem;
}
.chat-bubble td,
#aiChatMessages td {
  background: var(--bg-light);
}
.chat-bubble tr:nth-child(even) td,
#aiChatMessages tr:nth-child(even) td {
  background: var(--bg);
}
.chat-bubble code,
#aiChatMessages code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.82rem;
  font-family: 'Courier New', monospace;
  word-break: break-all;
}
.chat-bubble pre,
#aiChatMessages pre {
  background: var(--bg-dark, #1a1a2e);
  color: #e2e8f0;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 8px 0;
}
.chat-bubble pre code,
#aiChatMessages pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.chat-bubble ul, .chat-bubble ol,
#aiChatMessages ul, #aiChatMessages ol {
  margin: 6px 0;
  padding-left: 20px;
}
.chat-bubble li,
#aiChatMessages li {
  margin-bottom: 3px;
  line-height: 1.5;
}
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3, .chat-bubble h4,
#aiChatMessages h1, #aiChatMessages h2, #aiChatMessages h3, #aiChatMessages h4 {
  margin: 10px 0 6px 0;
  font-weight: 700;
  line-height: 1.3;
}
.chat-bubble h1, #aiChatMessages h1 { font-size: 1.2rem; }
.chat-bubble h2, #aiChatMessages h2 { font-size: 1.1rem; }
.chat-bubble h3, #aiChatMessages h3 { font-size: 1rem; }
.chat-bubble h4, #aiChatMessages h4 { font-size: 0.92rem; }
.chat-bubble blockquote,
#aiChatMessages blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-light);
}
.chat-bubble hr,
#aiChatMessages hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.chat-bubble a,
#aiChatMessages a {
  color: var(--secondary);
  text-decoration: none;
}
.chat-bubble a:hover,
#aiChatMessages a:hover {
  text-decoration: underline;
}
.chat-bubble strong,
#aiChatMessages strong {
  font-weight: 700;
}
.chat-bubble em,
#aiChatMessages em {
  font-style: italic;
}
.chat-bubble p,
#aiChatMessages p {
  margin: 4px 0;
}

/* Dark mode overrides for markdown */
html[data-theme="dark"] .chat-bubble pre,
html[data-theme="dark"] #aiChatMessages pre {
  background: #0F172A;
  color: #e2e8f0;
}
html[data-theme="dark"] .chat-bubble code,
html[data-theme="dark"] #aiChatMessages code {
  background: #1E293B;
}
html[data-theme="dark"] .chat-bubble th,
html[data-theme="dark"] #aiChatMessages th {
  background: #1E293B;
}
html[data-theme="dark"] .chat-bubble td,
html[data-theme="dark"] #aiChatMessages td {
  background: #0F172A;
}
html[data-theme="dark"] .chat-bubble tr:nth-child(even) td,
html[data-theme="dark"] #aiChatMessages tr:nth-child(even) td {
  background: #1E293B;
}

/* ============================================
   SOAR Module
   ============================================ */
.soar-tabs { display:flex; gap:4px; margin-bottom:24px; border-bottom:2px solid var(--border); }
.soar-tab { padding:10px 20px; border:none; background:none; cursor:pointer; font-size:0.92rem; color:var(--text-muted); border-bottom:2px solid transparent; margin-bottom:-2px; transition:all 0.2s; }
.soar-tab.active { color:var(--primary); border-bottom-color:var(--primary); font-weight:600; }
.soar-tab:hover { color:var(--text); }
.soar-card { background:var(--bg); border:1px solid var(--border); border-radius:var(--radius); padding:20px; margin-bottom:12px; }
.soar-card.inactive { opacity: 0.45; pointer-events: none; }
.soar-card-header { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:8px; }
.soar-card-title { font-weight:600; font-size:0.95rem; }
.soar-card-meta { font-size:0.78rem; color:var(--text-muted); margin-top:4px; }
.soar-actions { display:flex; gap:6px; margin-top:8px; }
.soar-badge-auto { background:#10B981; color:#fff; font-size:0.7rem; padding:2px 8px; border-radius:4px; }
.soar-badge-manual { background:#F59E0B; color:#fff; font-size:0.7rem; padding:2px 8px; border-radius:4px; }
.soar-condition-rule { display:flex; gap:8px; align-items:center; margin-bottom:6px; }
.soar-condition-rule select, .soar-condition-rule input { font-size:0.82rem; padding:4px 8px; border:1px solid var(--border); border-radius:4px; }
.soar-action-row { display:flex; gap:8px; align-items:center; margin-bottom:8px; padding:8px; background:var(--bg-light); border-radius:6px; }
.soar-pending-card { border-left:4px solid #F59E0B; }
html[data-theme="dark"] .soar-pending-card { border-left-color:#D97706; }
.soar-pending-card .soar-card-header { color:var(--text); }

/* SOAR empty state */
.soar-empty-state { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.soar-empty-state i { font-size: 3.5rem; margin-bottom: 16px; opacity: 0.2; color: var(--primary); }
.soar-empty-state p { font-size: 0.95rem; color: var(--text); margin-top: 8px; }

/* SOAR section titles */
.soar-section-title { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 18px 0 10px 0; padding-bottom: 6px; border-bottom: 1px solid var(--border); }

/* SOAR checkbox grid */
.soar-checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 10px; margin-top: 6px; }
.soar-checkbox-grid label { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; cursor: pointer; padding: 3px 0; color: var(--text); }
.soar-checkbox-grid input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }

/* SOAR simple table */
.soar-simple-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.soar-simple-table thead th { text-align: left; padding: 10px 14px; background: var(--bg); color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.3px; border-bottom: 2px solid var(--border); }
.soar-simple-table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.soar-simple-table tbody tr { transition: background 0.15s; }
.soar-simple-table tbody tr:hover { background: var(--bg-light); }

/* SOAR dark mode */
html[data-theme="dark"] .soar-tabs { border-bottom-color: #475569; }
html[data-theme="dark"] .soar-simple-table thead th { background: var(--bg); border-bottom-color: #475569; color: #cbd5e1; }
html[data-theme="dark"] .soar-simple-table tbody td { border-bottom-color: #334155; }
html[data-theme="dark"] .soar-simple-table tbody tr:hover { background: var(--bg-light); }
html[data-theme="dark"] .soar-card { background: #1e293b; border-color: #475569; }
html[data-theme="dark"] .soar-card-title { color: #f1f5f9; }
html[data-theme="dark"] .soar-card-meta { color: #94a3b8; }
html[data-theme="dark"] .soar-action-row { background: #0f172a; border-color: #334155; }
html[data-theme="dark"] .soar-action-row select,
html[data-theme="dark"] .soar-action-row input,
html[data-theme="dark"] .soar-action-row textarea,
html[data-theme="dark"] .soar-condition-rule select,
html[data-theme="dark"] .soar-condition-rule input { background: #1e293b; border: 1px solid #475569; color: #f1f5f9; }
html[data-theme="dark"] .soar-section-title { color: #e2e8f0; border-bottom-color: #475569; }
html[data-theme="dark"] .soar-checkbox-grid label { color: #cbd5e1; }
