/* ==========================================================================
   Matrix Intelligence Copilot — Professional Light Theme
   UP Police Law Enforcement Intelligence Operations UI
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --bg-hover: #f3f4f6;
  --surface: #ffffff;
  --surface-raised: #ffffff;

  --border: #e5e7eb;
  --border-strong: #d7dae2;

  --accent: #3b82f6;
  --accent-hover: #2f6fe0;
  --accent-soft: rgba(59, 130, 246, 0.08);
  --accent-soft-strong: rgba(59, 130, 246, 0.15);
  --accent-ink: #1d4ed8;
  --accent-glow: rgba(59, 130, 246, 0.15);

  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  --success: #1a9c6e;
  --success-soft: #e7f7f0;
  --warning: #b9791a;
  --warning-soft: #fbf1de;
  --danger: #d1364f;
  --danger-soft: #fceaee;

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(20, 22, 31, 0.04), 0 1px 1px rgba(20, 22, 31, 0.03);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 12px 32px rgba(20, 22, 31, 0.10), 0 2px 8px rgba(20, 22, 31, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body.matrix-light-theme {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d7dae2; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b9bec9; }

/* ==========================================================================
   Header
   ========================================================================== */

.ml-header {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.ml-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.ml-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.ml-brand-text h1 {
  font-size: 14.5px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.1px;
  line-height: 1.2;
}

.ml-brand-text p {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.ml-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ml-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--success);
  background: var(--success-soft);
  padding: 5px 11px;
  border-radius: var(--radius-full);
}

.ml-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.ml-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ml-btn:hover {
  background: var(--bg-hover);
  border-color: #c5c9d3;
  color: var(--text-primary);
}
.ml-btn.ml-btn-accent {
  color: var(--accent-ink);
  border-color: var(--accent-soft-strong);
  background: var(--accent-soft);
}
.ml-btn.ml-btn-accent:hover {
  background: var(--accent-soft-strong);
  border-color: var(--accent);
}

/* ==========================================================================
   Context Bar
   ========================================================================== */

#entity-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 11.5px;
  color: var(--text-muted);
  overflow-x: auto;
  white-space: nowrap;
}

.entity-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ==========================================================================
   Main Chat Area
   ========================================================================== */

.ml-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.ml-glow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 30%, rgba(59, 130, 246, 0.08) 0%, transparent 65%);
  z-index: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.ml-glow.faded { opacity: 0; }

.ml-chat-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.ml-chat-inner {
  width: 100%;
  max-width: 780px;
  padding: 28px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

/* Welcome / empty state */
.ml-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
  padding: 40px 20px;
}

.ml-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #6b9bff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: var(--shadow-lg);
}

.ml-welcome h2 {
  font-size: 34px;
  font-weight: 400;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  background: linear-gradient(90deg, #1f2937, #4b5563);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ml-welcome p {
  font-size: 14.5px;
  color: var(--text-secondary);
  max-width: 480px;
  line-height: 1.55;
}

.ml-welcome[hidden] { display: none; }

/* Chat message bubbles */
.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}
.chat-msg.user {
  align-self: flex-end;
  max-width: 82%;
}
.chat-msg.assistant {
  align-self: stretch;
  max-width: 100%;
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: 22px;
  font-size: 15px;
  line-height: 1.6;
}

.chat-msg.user .msg-bubble {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant .msg-bubble {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
}

/* Tool execution trace — low-key, collapsible */
.tool-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 2px 0 8px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  overflow: hidden;
}
.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 7px 11px;
}
.tool-header:hover { color: var(--text-primary); }
.tool-details {
  padding: 0 11px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  border-top: 1px solid var(--border);
}
.tool-details.show {
  display: block;
  padding: 9px 11px;
}

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: ml-pulse 1.1s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes ml-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Suggestion / quick-prompt chips */
.suggestions, .quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  padding: 6px 13px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft-strong);
  color: var(--accent-ink);
}

/* Download / report links */
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary) !important;
  font-weight: 600;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none !important;
  margin: 6px 6px 0 0;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}
.download-btn:hover {
  border-color: var(--accent);
  color: var(--accent-ink) !important;
  background: var(--accent-soft);
}

/* Markdown rendering inside bubbles */
.msg-bubble h2, .msg-bubble h3, .msg-bubble h4 {
  color: var(--text-primary);
  margin: 12px 0 6px;
  font-weight: 650;
}
.msg-bubble h2:first-child, .msg-bubble h3:first-child, .msg-bubble h4:first-child { margin-top: 0; }
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 6px 0 10px 18px; }
.msg-bubble li { margin-bottom: 5px; }
.msg-bubble strong { font-weight: 650; }
.msg-bubble code {
  background: var(--bg-subtle);
  color: var(--accent-ink);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  border: 1px solid var(--border);
}
.msg-bubble pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg-bubble pre code { background: transparent; border: none; padding: 0; color: var(--text-primary); }
.msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 12.5px;
}
.msg-bubble th, .msg-bubble td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
}
.msg-bubble th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 650;
}

/* ==========================================================================
   Input Bar
   ========================================================================== */

.ml-input-area {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 14px 20px 20px;
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
}

.ml-input-wrap {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 8px 8px 8px 20px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chat-input-wrapper:focus-within {
  border-color: #bfdbfe;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 16px;
  color: var(--text-primary);
  padding: 10px 0;
  max-height: 140px;
  line-height: 1.5;
}
.chat-input::placeholder { color: var(--text-muted); }

.chat-mic-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.chat-mic-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
  transform: scale(1.05);
}
.chat-mic-btn.recording {
  background: #ef4444 !important;
  color: #fff !important;
  border-color: #dc2626 !important;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
  animation: micPulseLight 1.3s infinite ease-in-out;
}
@keyframes micPulseLight {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.chat-send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--text-primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chat-send-btn:hover:not(:disabled) {
  background: #000;
  transform: scale(1.04);
}
.chat-send-btn:disabled {
  background: var(--border-strong);
  cursor: default;
}

.ml-input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .ml-header {
    padding: 8px 12px !important;
    height: auto !important;
    min-height: 52px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .ml-brand {
    gap: 8px !important;
  }
  .ml-brand-mark {
    width: 28px !important;
    height: 28px !important;
    font-size: 13px !important;
    border-radius: 7px !important;
  }
  .ml-brand-text h1 {
    font-size: 13.5px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
  }
  .ml-brand-text p {
    display: none !important;
  }
  .ml-status-pill {
    display: none !important;
  }

  .ml-header-right {
    gap: 6px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
  }
  .ml-header-right .ml-btn {
    padding: 5px 10px !important;
    font-size: 11px !important;
    min-height: 32px !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
  }
  .desk-only-text {
    display: none !important;
  }

  #entity-bar {
    padding: 6px 12px !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  #entity-bar::-webkit-scrollbar {
    display: none !important;
  }

  .ml-chat-scroll {
    width: 100% !important;
    max-width: 100vw !important;
  }

  .ml-chat-inner {
    padding: 14px 12px 10px !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  .ml-welcome {
    padding: 24px 10px 14px !important;
    gap: 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .ml-welcome h2 {
    font-size: 22px !important;
    margin: 0 !important;
  }
  .ml-welcome p {
    font-size: 13px !important;
    line-height: 1.45 !important;
    padding: 0 8px !important;
    margin: 0 !important;
  }
  .ml-welcome-icon {
    width: 48px !important;
    height: 48px !important;
    font-size: 22px !important;
    border-radius: 12px !important;
  }

  /* CRITICAL: Prompt chips must align left so first chip is never clipped on left */
  .quick-prompts {
    display: flex !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100vw !important;
    justify-content: flex-start !important;
    padding: 6px 12px 10px !important;
    box-sizing: border-box !important;
    gap: 8px !important;
    scrollbar-width: none !important;
  }
  .quick-prompts::-webkit-scrollbar {
    display: none !important;
  }
  .quick-prompts .chip {
    flex-shrink: 0 !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
    min-height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  .chat-msg.user {
    max-width: 92% !important;
  }

  .ml-input-area {
    padding: 8px 12px max(12px, env(safe-area-inset-bottom, 12px)) !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
  .chat-input-wrapper {
    padding: 6px 6px 6px 14px !important;
  }
  .chat-input {
    font-size: 14px !important;
    padding: 8px 0 !important;
  }
  .ml-input-hint {
    font-size: 10.5px !important;
    padding: 0 4px !important;
  }
}

/* ==========================================================================
   Enhanced Intelligence Chat UI — Avatars, Tables & Workflow Tracer
   ========================================================================== */

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.chat-msg.user .msg-meta {
  justify-content: flex-end;
}

.msg-avatar {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.user-avatar {
  background: #3b82f6;
  color: #fff;
}

.bot-avatar {
  background: #1e293b;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
}

.msg-author {
  font-weight: 600;
  color: var(--text-primary);
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #059669;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
}

.engine-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  animation: ml-pulse 1.4s ease-in-out infinite;
}

/* User Message Bubble Enhancement */
.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #ffffff !important;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
  font-size: 14.5px;
}

/* Assistant Message Bubble Enhancement */
.chat-msg.assistant .msg-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  border-radius: 16px;
  padding: 18px 22px;
}

/* ==========================================================================
   Workflow Decision Tracer (Django Chat Style)
   ========================================================================== */

.trace-decision-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.trace-decision-card:hover {
  border-color: #cbd5e1;
}

.trace-decision-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  background: #f1f5f9;
  font-size: 12px;
  font-family: var(--font-mono);
  user-select: none;
}

.trace-decision-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-weight: 600;
}

.trace-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #0284c7;
  box-shadow: 0 0 6px #0284c7;
}

.trace-step-pill {
  background: #e2e8f0;
  color: #475569;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.trace-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trace-drawer-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0284c7;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.trace-drawer-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.trace-chevron {
  font-size: 10px;
  color: #64748b;
  transition: transform 0.2s ease;
}

.trace-decision-card.expanded .trace-chevron {
  transform: rotate(180deg);
}

.trace-decision-body {
  display: none;
  padding: 10px 14px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
}

.trace-decision-card.expanded .trace-decision-body {
  display: block;
}

.trace-step-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed #e2e8f0;
  font-size: 12px;
}

.trace-step-item:last-child {
  border-bottom: none;
}

.trace-step-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

.trace-step-details {
  flex: 1;
  min-width: 0;
}

.trace-step-title {
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.trace-step-time {
  font-size: 10px;
  color: #059669;
  background: #ecfdf5;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
}

.trace-step-desc {
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
  line-height: 1.4;
}

.trace-step-code {
  background: #0f172a;
  color: #38bdf8;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  margin-top: 5px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ==========================================================================
   Full Markdown Data Table Enhancements
   ========================================================================== */

.table-card-wrapper {
  margin: 14px 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.table-card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  gap: 10px;
}

.table-search-input {
  flex: 1;
  max-width: 320px;
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 11.5px;
  outline: none;
  font-family: var(--font-sans);
}

.table-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

.table-action-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.table-action-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.table-responsive-container {
  max-height: 480px;
  overflow-y: auto;
  overflow-x: auto;
}

.intelligence-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.intelligence-data-table th {
  position: sticky;
  top: 0;
  background: #0f172a;
  color: #f8fafc;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.3px;
  border-bottom: 2px solid #334155;
  white-space: nowrap;
  z-index: 2;
}

.intelligence-data-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.intelligence-data-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.intelligence-data-table tbody tr:hover {
  background: #eff6ff;
}

.intelligence-data-table td.num-cell {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: #0f172a;
}

.table-card-footer {
  padding: 6px 12px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 10.5px;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Badges for status in table cells */
.status-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.status-pill.negative { background: #fee2e2; color: #b91c1c; }
.status-pill.positive { background: #dcfce7; color: #15803d; }
.status-pill.neutral { background: #f1f5f9; color: #475569; }
.status-pill.submitted { background: #e0f2fe; color: #0369a1; }
.status-pill.pending { background: #fef3c7; color: #b45309; }

/* =========================================================================
   Multimodal Media Upload & Inspection UI
   ========================================================================= */

.chat-attach-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.chat-attach-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
  transform: scale(1.05);
}
.chat-attach-btn.has-file {
  background: #eff6ff;
  border-color: var(--accent);
  color: var(--accent);
}

.staged-media-container {
  display: none;
  margin-bottom: 8px;
  animation: fadeInMedia 0.2s ease;
}
.staged-media-container.active {
  display: block;
}

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

.staged-media-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.staged-media-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #e2e8f0;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

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

.staged-media-filename {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.staged-media-meta {
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.staged-media-badge {
  display: inline-block;
  padding: 1px 6px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

.staged-media-remove {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: #e2e8f0;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.staged-media-remove:hover {
  background: #fee2e2;
  color: #dc2626;
  transform: scale(1.1);
}

/* User Message Attachment Preview */
.user-media-attachment {
  margin-bottom: 8px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 320px;
}

.user-media-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
  transition: transform 0.15s ease;
  border: 1px solid rgba(0, 0, 0, 0.1);
}
.user-media-img:hover {
  transform: scale(1.02);
}

.user-media-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #0f172a;
}
.user-media-doc a {
  color: #0284c7;
  font-weight: 600;
  text-decoration: underline;
  word-break: break-all;
}

/* Lightbox Fullview Modal */
.media-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.media-lightbox.open {
  display: flex;
}
.media-lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.media-lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.media-lightbox-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  color: #0f172a;
  border: none;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.media-lightbox-close:hover {
  transform: scale(1.1);
}


