/* ═══════════════════════════════════════════════════════════
   SENTINEL — Intelligence Platform
   Professional Split Theme: Navy Sidebar + Clean Light Content
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Content area ──────────────────────────────────────── */
  --bg-base:       #f0f4f8;
  --bg-card:       #ffffff;
  --bg-elevated:   #f8fafc;
  --bg-hover:      #f1f5f9;
  --border:        #e2e8f0;
  --border-bright: #cbd5e1;
  --text-primary:  #0f172a;
  --text-secondary:#475569;
  --text-muted:    #94a3b8;

  /* ── Brand accent ──────────────────────────────────────── */
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-dim:    rgba(37,99,235,.08);

  /* ── Semantic colours ──────────────────────────────────── */
  --success:       #059669;
  --danger:        #dc2626;
  --warning:       #d97706;
  --orange:        #ea580c;
  --amber:         #d97706;

  /* ── Threat levels ─────────────────────────────────────── */
  --critical:      #dc2626;
  --high:          #ea580c;
  --medium:        #d97706;
  --low:           #2563eb;
  --clear:         #059669;

  /* ── Sidebar (dark navy) ───────────────────────────────── */
  --sb-bg:         #1e2d4a;
  --sb-bg-deep:    #162036;
  --sb-border:     rgba(255,255,255,.07);
  --sb-text:       #94a8c8;
  --sb-text-hover: #e2eaf8;
  --sb-active-bg:  rgba(37,99,235,.22);
  --sb-active-text:#93b8ff;
  --sb-hover-bg:   rgba(255,255,255,.06);

  /* ── Shape & motion ────────────────────────────────────── */
  --radius:        6px;
  --radius-lg:     10px;
  --shadow:        0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);
  --font-mono:     'Courier New', Courier, monospace;
  --transition:    .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 14px; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ─── App Shell ─────────────────────────────────────────── */
.app-body { display: flex; min-height: 100vh; }
.app-main  { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.page-content { flex: 1; padding: 28px 32px; overflow-y: auto; max-width: 1400px; width: 100%; }

/* ─── Sidebar / Drawer ──────────────────────────────────── */
.drawer {
  width: 230px;
  min-height: 100vh;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  border-right: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--sb-border);
}

.brand-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-icon svg { width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name    { font-size: 14px; font-weight: 700; color: #ffffff; letter-spacing: .4px; }
.brand-tagline { font-size: 9px; color: var(--sb-text); letter-spacing: 1.2px; text-transform: uppercase; margin-top: 1px; }

.drawer-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: rgba(148,168,200,.45);
  padding: 10px 8px 5px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--sb-text); font-size: 13px; font-weight: 500;
  transition: all var(--transition); text-decoration: none;
}
.nav-item:hover { background: var(--sb-hover-bg); color: var(--sb-text-hover); }
.nav-item.active { background: var(--sb-active-bg); color: var(--sb-active-text); }
.nav-item.active svg { stroke: var(--sb-active-text); }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.nav-divider { height: 1px; background: var(--sb-border); margin: 6px 8px; }

.logout-button {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; width: 100%;
  background: none; border: none;
  border-top: 1px solid var(--sb-border);
  color: var(--sb-text); font-size: 13px; cursor: pointer;
  transition: all var(--transition);
}
.logout-button:hover { color: #fca5a5; background: rgba(220,38,38,.12); }
.logout-button svg { width: 15px; height: 15px; }

/* ─── Header bar ────────────────────────────────────────── */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 0 var(--border);
}

.header-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.header-user  { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; background: var(--bg-elevated);
  border-radius: 20px; border: 1px solid var(--border);
}
.user-chip-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
}
.user-chip-name { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.user-chip-role {
  font-size: 10px; padding: 1px 7px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent);
  font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}

/* ─── Page layout ───────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title    { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.page-subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 3px; }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* ─── Stats cards ───────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--accent);
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 5px; }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 14px; height: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-card); color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--border-bright); color: var(--text-primary); background: var(--bg-elevated); }

.btn-danger  { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-accent  { background: var(--accent-dim); color: var(--accent); border-color: rgba(37,99,235,.2); }
.btn-accent:hover:not(:disabled) { background: var(--accent); color: #fff; }

.btn-ghost   { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-sm  { padding: 4px 10px; font-size: 12px; }
.btn-lg  { padding: 10px 20px; font-size: 14px; }

/* ─── Tables ────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--bg-elevated);
  color: var(--text-muted); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 16px; text-align: left; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-elevated); }

/* ─── Status badges ─────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.status-badge[data-status="sent"]       { background: #dcfce7; color: #15803d; }
.status-badge[data-status="queued"]     { background: #fef3c7; color: #92400e; }
.status-badge[data-status="pending"]    { background: #f1f5f9; color: #64748b; }
.status-badge[data-status="processing"] { background: #dbeafe; color: #1e40af; }
.status-badge[data-status="failed"]     { background: #fee2e2; color: #b91c1c; }

/* ─── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 9px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-admin { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }
.badge-user  { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }

/* ─── Threat badges ─────────────────────────────────────── */
.threat-badge {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 4px; font-size: 10px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase; flex-shrink: 0;
}
.threat-badge.critical, .threat-badge.CRITICAL { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.threat-badge.high,     .threat-badge.HIGH     { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.threat-badge.medium,   .threat-badge.MEDIUM   { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.threat-badge.low,      .threat-badge.LOW      { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.threat-badge.clear,    .threat-badge.CLEAR    { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }

/* ─── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
  letter-spacing: .2px;
}
.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 13px; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

/* ─── Auth pages ────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e2d4a 0%, #162036 50%, #0f172a 100%);
  padding: 24px;
}

.auth-card {
  width: 100%; max-width: 400px;
  background: #ffffff; border-radius: 12px;
  padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

.auth-logo {
  display: flex; flex-direction: column;
  align-items: center; margin-bottom: 28px;
}
.auth-logo-icon {
  width: 68px; height: 68px;
  display: flex;
  align-items: center; justify-content: center; margin-bottom: 12px;
}
.auth-logo-icon svg { width: 68px; height: 68px; }
.auth-brand    { font-size: 20px; font-weight: 800; color: #0f172a; letter-spacing: .6px; }
.auth-tagline  { font-size: 10px; color: #94a3b8; letter-spacing: 1.5px; text-transform: uppercase; margin-top: 3px; }
.auth-title    { font-size: 18px; font-weight: 700; color: #0f172a; margin-bottom: 4px; }
.auth-subtitle { font-size: 13px; color: #64748b; margin-bottom: 24px; }

.auth-error {
  background: #fef2f2; border: 1px solid #fecaca;
  color: #dc2626; padding: 10px 14px;
  border-radius: var(--radius); font-size: 13px;
  margin-bottom: 16px; display: none;
}

.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: #64748b; }
.auth-footer a { color: var(--accent); font-weight: 500; }

/* ─── Filter bar ────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.search-wrap {
  position: relative; flex: 1; min-width: 200px; max-width: 360px;
}
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; stroke: var(--text-muted);
  pointer-events: none; flex-shrink: 0;
}
.search-input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--text-primary);
  font-size: 13px; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.pill-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.pill {
  padding: 5px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── Loading / Empty states ────────────────────────────── */
.loading-state, .empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 48px 24px;
  color: var(--text-muted); font-size: 14px; text-align: center;
}
.empty-state svg { width: 40px; height: 40px; stroke: var(--text-muted); opacity: .4; }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Pagination ────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center;
  gap: 8px; padding: 16px 0; justify-content: center;
}
.page-info { font-size: 13px; color: var(--text-secondary); padding: 0 8px; }

/* ─── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; z-index: 9999;
  animation: slideUp .2s ease; max-width: 320px;
  box-shadow: var(--shadow-lg);
}
.toast-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.toast-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.toast-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── User avatar (admin users table) ───────────────────── */
.user-avatar {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: var(--accent-dim); border: 1px solid rgba(37,99,235,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent);
  letter-spacing: .03em;
}

/* ─── WA status badges ───────────────────────────────────── */
.wa-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.wa-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.wa-connected    { background: #dcfce7; color: #15803d; }
.wa-connected::before { background: #15803d; }
.wa-auth         { background: #fef9c3; color: #854d0e; }
.wa-auth::before { background: #ca8a04; }
.wa-qr           { background: #dbeafe; color: #1e40af; }
.wa-qr::before   { background: #3b82f6; }
.wa-init         { background: var(--bg-elevated); color: var(--text-muted); }
.wa-init::before { background: var(--text-muted); }
.wa-disconnected { background: #fee2e2; color: #b91c1c; }
.wa-disconnected::before { background: #ef4444; }
.wa-failed       { background: #fee2e2; color: #991b1b; }
.wa-failed::before { background: #dc2626; }
.wa-none         { background: var(--bg-elevated); color: var(--text-muted); border: 1px dashed var(--border-bright); }
.wa-none::before { display: none; }

/* ─── Groups link (admin users table) ───────────────────── */
.groups-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 24px; padding: 0 8px;
  background: var(--accent-dim); color: var(--accent);
  border-radius: var(--radius); font-size: 12px; font-weight: 700;
  text-decoration: none; border: 1px solid rgba(37,99,235,.15);
  transition: all var(--transition);
}
.groups-link:hover { background: var(--accent); color: #fff; }

/* ─── Info action button (table "i" button) ─────────────── */
.info-action {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-dim); border: 1px solid rgba(37,99,235,.2);
  color: var(--accent); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all var(--transition);
  display: inline-flex; align-items: center; justify-content: center;
}
.info-action:hover { background: var(--accent); color: #fff; }

/* ─── Utilities ─────────────────────────────────────────── */
.mono { font-family: var(--font-mono); font-size: 12px; }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.fw-bold { font-weight: 700; }
.mb-16   { margin-bottom: 16px; }
.mb-24   { margin-bottom: 24px; }
.flex    { display: flex; }
.flex-center { display: flex; align-items: center; }
.justify-between { justify-content: space-between; }
.pulse   { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ─── Details modal ─────────────────────────────────────── */
#details-modal {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(15,23,42,.6); overflow-y: auto; backdrop-filter: blur(2px);
}
#details-modal > div {
  max-width: 700px; margin: 40px auto; padding: 20px;
}

/* ─── QR wrap ───────────────────────────────────────────── */
.qr-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px; padding: 24px;
}
.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ─── SSE live indicator ─────────────────────────────────── */
.sse-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--border); font-size: 11px; font-weight: 600;
  color: var(--text-muted); background: var(--bg-card);
}
.sse-indicator.connected { color: var(--success); border-color: #86efac; background: #f0fdf4; }
.sse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0;
}
.sse-indicator.connected .sse-dot {
  background: var(--success);
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
  0%,100% { box-shadow: 0 0 0 2px rgba(5,150,105,.2); }
  50%      { box-shadow: 0 0 0 5px rgba(5,150,105,.06); }
}

/* ─── Threat filter pills ────────────────────────────────── */
.threat-filter-pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.threat-pill {
  padding: 5px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all var(--transition); letter-spacing: .03em;
}
.threat-pill:hover { border-color: var(--border-bright); color: var(--text-primary); }
.threat-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.threat-pill.critical.active, .threat-pill.critical:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.threat-pill.high.active,     .threat-pill.high:hover     { background: #ea580c; border-color: #ea580c; color: #fff; }
.threat-pill.medium.active,   .threat-pill.medium:hover   { background: #d97706; border-color: #d97706; color: #fff; }
.threat-pill.low.active,      .threat-pill.low:hover      { background: #2563eb; border-color: #2563eb; color: #fff; }
.threat-pill.clear.active,    .threat-pill.clear:hover    { background: #059669; border-color: #059669; color: #fff; }

/* ─── Groups grid ────────────────────────────────────────── */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px; margin-bottom: 16px;
}
.group-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}
.group-card:hover { border-color: var(--border-bright); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.group-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.group-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-dim); border: 1px solid rgba(37,99,235,.15);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: var(--accent); flex-shrink: 0;
}
.group-name   { font-weight: 600; color: var(--text-primary); font-size: 14px; line-height: 1.3; }
.group-id     { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.group-stats  {
  display: flex; gap: 24px; margin-bottom: 10px;
  padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.group-stat        { text-align: center; }
.group-stat-val    { font-size: 18px; font-weight: 700; color: var(--accent); display: block; }
.group-stat-label  { font-size: 10px; color: var(--text-muted); display: block; }
.group-last-activity { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; margin: 8px 0; }
.group-card-actions { display: flex; gap: 8px; margin-top: 12px; }
.group-card-actions .btn { flex: 1; justify-content: center; font-size: 12px; }
.group-live-indicator { margin-top: 8px; font-size: 11px; color: var(--success); display: flex; align-items: center; gap: 5px; }

/* ─── Chat timeline (WhatsApp-style) ─────────────────────── */
.chat-window {
  background: #ede8dc;
  background-image: radial-gradient(rgba(0,0,0,.045) 1px, transparent 1px);
  background-size: 18px 18px;
  padding: 16px 20px;
  min-height: 300px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
  scroll-behavior: smooth;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Sender groups */
.msg-group { margin-bottom: 14px; }

.msg-sender-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 5px;
}

.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
  flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  text-transform: uppercase;
}

.msg-sender-name { font-size: 12px; font-weight: 700; }
.msg-phone-tag {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
  background: rgba(0,0,0,.07); padding: 1px 6px; border-radius: 3px; margin-left: 4px;
}

/* Bubbles */
.msg-bubbles { padding-left: 38px; display: flex; flex-direction: column; gap: 2px; }

.msg-bubble {
  background: #fff; border-radius: 0 10px 10px 10px;
  padding: 7px 11px 5px; max-width: 82%;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  align-self: flex-start; position: relative;
}
.msg-bubble + .msg-bubble { border-radius: 5px 10px 10px 5px; }

.msg-text {
  font-size: 13.5px; line-height: 1.45; color: #1a1a1a;
  word-break: break-word; white-space: pre-wrap;
}

.msg-meta {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 5px; margin-top: 3px;
}
.msg-time { font-size: 10px; color: #8e9eab; white-space: nowrap; }
.msg-tag-hist {
  font-size: 9px; color: var(--text-muted);
  background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px;
}

/* Deleted */
.msg-deleted { color: #b0b8c1; font-size: 13px; font-style: italic; }

/* Media */
.msg-media-box {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.04); border-radius: 8px; padding: 8px 12px; min-width: 150px;
}
.msg-media-icon { font-size: 24px; line-height: 1; }
.msg-media-label { flex: 1; }
.msg-media-type { font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; display: block; }
.msg-dl-link { font-size: 11px; font-weight: 600; color: var(--accent); text-decoration: none; display: block; margin-top: 2px; }
.msg-media-status { font-size: 10px; color: var(--text-muted); display: block; margin-top: 2px; }
.msg-caption { margin-top: 5px; font-size: 13px; color: #333; }

/* Date separator */
.date-sep {
  display: flex; align-items: center; justify-content: center; margin: 16px 0 10px;
}
.date-sep span {
  background: rgba(255,255,255,.75); border: 1px solid rgba(0,0,0,.07);
  color: var(--text-secondary); font-size: 11px; font-weight: 600;
  padding: 3px 14px; border-radius: 12px; letter-spacing: .3px;
  backdrop-filter: blur(2px);
}

/* Load-earlier inside chat window */
.load-earlier-wrap {
  text-align: center; padding: 8px 0 12px;
}

/* ─── Evidence bubbles ───────────────────────────────────── */
.evidence-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px;
}
.evidence-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.evidence-body { margin-top: 4px; font-size: 13px; color: var(--text-primary); line-height: 1.5; }

/* ─── Incident cards ─────────────────────────────────────── */
.incident-card { border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 12px; overflow: hidden; }
.incident-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; cursor: pointer; background: var(--bg-elevated);
  transition: background var(--transition);
}
.incident-header:hover { background: var(--bg-hover); }
.incident-category { font-size: 12px; font-weight: 700; color: var(--text-primary); display: block; }
.incident-severity { font-size: 11px; font-weight: 700; }
.incident-body { display: none; padding: 14px; border-top: 1px solid var(--border); background: var(--bg-card); }
.incident-card.open .incident-body   { display: block; }
.incident-card.open .rpt-chevron { transform: rotate(180deg); }

/* ─── Report sections ────────────────────────────────────── */
.rpt-section { overflow: hidden; }
.rpt-section-toggle {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: none; border: none;
  cursor: pointer; color: var(--text-primary); transition: background var(--transition);
}
.rpt-section-toggle:hover { background: var(--bg-elevated); }
.rpt-section-title { font-size: 14px; font-weight: 600; }
.rpt-section-body  { display: none; padding: 0 16px 16px; border-top: 1px solid var(--border); }
.rpt-section-body.open { display: block; }
.rpt-chevron { transition: transform var(--transition); flex-shrink: 0; color: var(--text-muted); }
.rpt-chevron.rotated { transform: rotate(180deg); }

/* ─── Report metadata ────────────────────────────────────── */
.rpt-meta-cell {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.rpt-meta-cell:last-child { border-right: none; }
.rpt-meta-label { display: block; font-size: 10px; color: var(--text-muted); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 4px; }
.rpt-meta-value { display: block; font-size: 13px; color: var(--text-primary); font-weight: 500; }

/* ─── Threat banner ──────────────────────────────────────── */
.threat-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 20px; border-radius: var(--radius-lg); border: 1px solid;
  font-size: 14px; font-weight: 700; letter-spacing: .06em;
  text-align: center;
}

/* ─── Confidential banner ────────────────────────────────── */
.confidential-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #fef2f2; border: 1px solid #fecaca;
  color: #b91c1c; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  padding: 8px 16px; border-radius: var(--radius); margin-bottom: 20px;
  text-align: center;
}

/* ─── Control Room — widget grid ─────────────────────────── */
.cr-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-flow: dense;
  grid-auto-rows: 90px;
  gap: 16px;
  margin-top: 8px;
}
.cr-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  grid-column: span var(--w, 6);
  grid-row: span var(--h, 3);
  transition: transform .15s ease, box-shadow .15s ease;
}
.cr-widget.dragging { opacity: .55; }
.cr-widget.customize-on { cursor: grab; }
.cr-widget.customize-on:hover { box-shadow: var(--shadow-lg); }
.cr-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.cr-widget-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-secondary);
}
.cr-widget-actions { display: flex; gap: 4px; }
.cr-widget-actions .cr-hide-btn {
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  display: none;
}
.cr-widget-actions .cr-hide-btn:hover { color: var(--danger); background: var(--bg-hover); }
.cr-grid.customize-on .cr-hide-btn { display: block; }
.cr-widget-body {
  padding: 14px 16px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.cr-chart-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.cr-chart-body canvas { flex: 1; min-height: 0; max-height: 100%; }
.cr-chart-body.cr-doughnut { align-items: center; justify-content: center; }
.cr-chart-body.cr-doughnut .cr-doughnut-wrap { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.cr-chart-body.cr-doughnut canvas { flex: none; max-width: 100%; max-height: 100%; aspect-ratio: 1 / 1; }
.cr-chart-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 11px; color: var(--text-secondary); justify-content: center; flex-shrink: 0; }
.cr-chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* ── KPI tiles ────────────────────────────────────────── */
.kpi-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; height: 100%; }
.kpi-tile { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.kpi-num { font-size: 26px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kpi-lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }

/* ── Lists / tables in widgets ────────────────────────── */
.cr-list { display: flex; flex-direction: column; gap: 6px; }
.cr-list-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: var(--radius); background: var(--bg-elevated); text-decoration: none; color: inherit; transition: background .15s; }
.cr-list-item:hover { background: var(--bg-hover); }
.cr-list-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cr-list-name { font-weight: 600; font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-list-sub { font-size: 11px; color: var(--text-muted); }
.cr-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #fff; }
.cr-badge.critical { background: var(--critical); }
.cr-badge.high     { background: var(--high); }
.cr-badge.medium   { background: var(--medium); }
.cr-badge.low      { background: var(--low); }
.cr-badge.clear    { background: var(--clear); }
.cr-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 20px 0; }

.cr-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cr-table th, .cr-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.cr-table th { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; background: var(--bg-elevated); position: sticky; top: 0; }
.cr-table td.cr-num, .cr-table th.cr-num { text-align: right; font-variant-numeric: tabular-nums; }
.cr-table td .sender-link { font-family: var(--font-mono); font-size: 11px; }

/* ── Live activity feed ───────────────────────────────── */
.cr-feed { display: flex; flex-direction: column; gap: 6px; }
.cr-feed-item { padding: 8px 10px; border-radius: var(--radius); background: var(--bg-elevated); font-size: 12px; display: flex; gap: 8px; align-items: baseline; animation: crFeedIn .3s ease-out; }
.cr-feed-item .cr-feed-time { color: var(--text-muted); font-size: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cr-feed-item .cr-feed-text { color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cr-feed-item .cr-feed-text strong { color: var(--text-primary); }
@keyframes crFeedIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── Category-distribution widget ─────────────────────── */
.cr-cat-body { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 20px; height: 100%; align-items: center; }
.cr-cat-chart { position: relative; width: 100%; height: 100%; min-height: 180px; max-height: 260px; display: flex; align-items: center; justify-content: center; }
.cr-cat-chart canvas { max-width: 100%; max-height: 100%; aspect-ratio: 1 / 1; }
.cr-cat-list { display: flex; flex-direction: column; gap: 8px; overflow: auto; max-height: 100%; }
.cr-cat-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; font-size: 12px; padding: 6px 8px; border-radius: var(--radius); background: var(--bg-elevated); }
.cr-cat-swatch { width: 12px; height: 12px; border-radius: 3px; }
.cr-cat-name { color: var(--text-primary); font-weight: 600; text-transform: capitalize; }
.cr-cat-count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cr-cat-pct { color: var(--text-secondary); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
@media (max-width: 900px) { .cr-cat-body { grid-template-columns: 1fr; } }

/* ── Trend window picker & hidden-tray ────────────────── */
.trend-window-picker { display: inline-flex; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.trend-btn { border: 0; background: transparent; padding: 6px 12px; font-size: 12px; color: var(--text-secondary); cursor: pointer; font-weight: 600; }
.trend-btn:hover { background: var(--bg-hover); }
.trend-btn.active { background: var(--accent); color: #fff; }
.cr-tray { margin-top: 16px; padding: 12px 16px; background: var(--bg-card); border: 1px dashed var(--border-bright); border-radius: var(--radius); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cr-tray-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.cr-tray-items { display: flex; gap: 6px; flex-wrap: wrap; }
.cr-tray-item { padding: 4px 10px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; font-size: 12px; cursor: pointer; color: var(--text-secondary); transition: background .15s; }
.cr-tray-item:hover { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ── Clickable sender-link deep-linking (used in reports too) ── */
.sender-link { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); padding-bottom: 1px; font-family: var(--font-mono); }
.sender-link:hover { color: var(--accent-hover); border-bottom-style: solid; }

/* ── Message-bubble highlight when deep-linked ───────── */
@keyframes msgFlash {
  0%   { box-shadow: 0 0 0 3px rgba(37,99,235,.55); background-color: rgba(37,99,235,.10); }
  100% { box-shadow: 0 0 0 0 transparent; background-color: transparent; }
}
.msg-highlight { animation: msgFlash 1.6s ease-out; border-radius: var(--radius); }

/* ─── Responsive CR grid ─────────────────────────────── */
@media (max-width: 1100px) {
  .cr-grid { grid-template-columns: repeat(6, 1fr); }
  .cr-widget { grid-column: span min(var(--w, 6), 6); }
  .kpi-tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .cr-grid { grid-template-columns: 1fr; }
  .cr-widget { grid-column: 1 / -1; }
}

/* ─── Progress / live bars ───────────────────────────────── */
.progress-bar-wrap { background: var(--bg-elevated); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #6366f1); border-radius: 4px; transition: width .4s ease; }

/* ─── Misc status badge (sendMessage page) ──────────────── */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; }
.live-dot.disconnected { background: #94a3b8; }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  .drawer { width: 64px; }
  .brand-text, .nav-item span, .nav-section-label, .logout-button span { display: none; }
  .brand { justify-content: center; padding: 16px 0; }
  .nav-item { justify-content: center; padding: 12px; }
  .logout-button { justify-content: center; padding: 12px; }
  .page-content { padding: 20px 16px; }
}
@media (max-width: 640px) {
  .groups-grid { grid-template-columns: 1fr; }
  .stats-row   { grid-template-columns: repeat(2, 1fr); }
  .rpt-meta-cell { border-right: none; }
  .auth-card { padding: 28px 20px; }
}
