:root {
  --bg-black: #05070a;
  --bg-panel: #0b0f15;
  --surface-dark: #111720;
  --surface-elevated: #17202c;
  --border-grey: #232f3e;
  --border-light: #34465c;
  --text-primary: #e8eef5;
  --text-muted: #8b9bb0;
  --tactical-blue: #00f0ff;
  --success-green: #00ff66;
  --warning-amber: #f0a500;
  --alert-red: #ff3344;
  --mono: 'Consolas', 'Courier New', monospace;
  --sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-black);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14px;
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg-black); }
::-webkit-scrollbar-thumb { background: var(--border-grey); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

a { color: var(--tactical-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted-text { color: var(--text-muted); font-size: 12px; }

/* Inputs & Buttons */
input[type="text"], input[type="password"], input[type="url"], select, textarea {
  width: 100%;
  background: var(--bg-black);
  color: var(--text-primary);
  border: 1px solid var(--border-grey);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--tactical-blue);
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.25);
}

button, .btn-primary, .btn-secondary, .btn-danger, .btn-success {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  background: var(--surface-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
button:hover, a.btn-secondary:hover {
  border-color: var(--tactical-blue);
  background: #1d2838;
  text-decoration: none;
}

.btn-primary {
  background: rgba(0, 240, 255, 0.14);
  border-color: var(--tactical-blue);
  color: var(--tactical-blue);
}
.btn-primary:hover {
  background: var(--tactical-blue);
  color: #05070a;
}

.btn-success {
  background: rgba(0, 255, 102, 0.14);
  border-color: var(--success-green);
  color: var(--success-green);
}
.btn-success:hover {
  background: var(--success-green);
  color: #05070a;
}

.btn-danger, .active-danger {
  background: rgba(255, 51, 68, 0.16);
  border-color: var(--alert-red);
  color: var(--alert-red);
}
.btn-danger:hover, .active-danger:hover {
  background: var(--alert-red);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
}
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-xs { padding: 4px 9px; font-size: 10px; }
.full-width { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.field-group { margin-bottom: 12px; }
.field-group label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: 0.05em;
}

/* Badges */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.badge-admin { background: var(--warning-amber); color: #05070a; }
.badge-n2 { background: var(--tactical-blue); color: #05070a; }

/* Login Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, #0d1824 0%, #05070a 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-dark);
  border: 1px solid var(--border-light);
  border-top: 3px solid var(--tactical-blue);
  border-radius: 6px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}
.login-kicker {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--tactical-blue);
  margin-bottom: 6px;
}
.login-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin: 6px 0 20px;
}
.login-status {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
  color: var(--text-muted);
}

/* Main App Shell */
.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border-grey);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.brand-block {
  padding: 16px;
  border-bottom: 1px solid var(--border-grey);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.brand-title {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--tactical-blue);
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.sidebar-section { margin-bottom: 20px; }
.section-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.channel-list, .online-list, .voice-participants {
  list-style: none;
  margin: 0;
  padding: 0;
}
.channel-item {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 3px;
  border-left: 3px solid transparent;
}
.channel-item:hover { background: var(--surface-dark); color: var(--text-primary); }
.channel-item.active {
  background: rgba(0, 240, 255, 0.1);
  color: var(--tactical-blue);
  border-left-color: var(--tactical-blue);
  font-weight: 700;
}

/* Voice Rooms */
.voice-room-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-grey);
  border-radius: 5px;
  margin-bottom: 8px;
  overflow: hidden;
}
.voice-room-card.connected {
  border-color: var(--success-green);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.12);
}
.voice-room-header {
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.voice-room-header:hover { background: var(--surface-elevated); }
.voice-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.voice-participants {
  padding: 4px 10px 8px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.voice-peer {
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  border-left: 2px solid transparent;
}
.voice-peer.speaking {
  color: var(--success-green);
  background: rgba(0, 255, 102, 0.1);
  border-left-color: var(--success-green);
  font-weight: 600;
}

.voice-controls {
  padding: 12px;
  background: var(--surface-dark);
  border-top: 1px solid var(--success-green);
}
.voice-connected-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--success-green);
  margin-bottom: 8px;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success-green);
  box-shadow: 0 0 8px var(--success-green);
}
.voice-btn-row { display: flex; gap: 6px; }
.voice-btn-row button { flex: 1; }

/* Online Roster */
.online-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  font-size: 12px;
}
.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success-green);
}

/* Workspace */
.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-black);
}
.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-grey);
}
.tab-group { display: flex; gap: 8px; }
.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 7px 14px;
}
.tab-btn.active {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--tactical-blue);
  color: var(--tactical-blue);
}
.conn-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--tactical-blue);
}

.view {
  flex: 1;
  overflow: hidden;
}

/* Comms View */
.view-comms {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.channel-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-grey);
  background: var(--surface-dark);
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg {
  background: var(--surface-dark);
  border: 1px solid var(--border-grey);
  border-radius: 6px;
  padding: 10px 14px;
}
.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}
.chat-author { color: var(--text-primary); font-size: 13px; }
.chat-time { color: var(--text-muted); font-size: 11px; font-family: var(--mono); }
.chat-msg-body { color: var(--text-primary); line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

.case-ref-pill {
  padding: 2px 8px;
  font-size: 10px;
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid var(--tactical-blue);
  color: var(--tactical-blue);
}

.chat-input-bar {
  padding: 12px 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-grey);
  display: flex;
  gap: 10px;
}
.chat-input-bar select { width: 210px; flex-shrink: 0; }
.chat-input-bar input { flex: 1; }

/* Dossiers View */
.view-dossiers { height: 100%; }
.dossier-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  height: 100%;
}
.dossier-sidebar {
  border-right: 1px solid var(--border-grey);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dossier-sidebar-tools {
  padding: 12px;
  border-bottom: 1px solid var(--border-grey);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.case-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.case-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-grey);
  border-radius: 5px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.case-card:hover { border-color: var(--border-light); }
.case-card.active {
  border-color: var(--tactical-blue);
  background: rgba(0, 240, 255, 0.06);
}
.case-card-top, .case-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.case-id { font-family: var(--mono); font-size: 11px; color: var(--tactical-blue); }
.case-handle { font-weight: 700; font-size: 14px; margin: 5px 0; }

.risk-pill, .status-pill {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.risk-LOW { background: rgba(0, 255, 102, 0.15); color: var(--success-green); }
.risk-MEDIUM { background: rgba(240, 165, 0, 0.2); color: var(--warning-amber); }
.risk-HIGH { background: rgba(255, 102, 0, 0.22); color: #ff8833; }
.risk-CRITICAL { background: rgba(255, 51, 68, 0.25); color: var(--alert-red); }
.status-pill { background: var(--surface-elevated); color: var(--text-primary); border: 1px solid var(--border-light); }
.status-CLEARED { border-color: var(--success-green); color: var(--success-green); }
.status-FLAGGED, .status-REJECTED { border-color: var(--alert-red); color: var(--alert-red); }

.dossier-detail {
  overflow-y: auto;
  padding: 20px 24px;
}
.empty-state {
  max-width: 460px;
  margin: 80px auto;
  text-align: center;
  color: var(--text-muted);
}
.dossier-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-grey);
  margin-bottom: 18px;
}
.dossier-kicker { font-family: var(--mono); font-size: 11px; color: var(--tactical-blue); margin-bottom: 4px; }
.osint-links { display: flex; gap: 8px; flex-wrap: wrap; }

.dossier-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.dossier-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-grey);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}
.dossier-card h4 {
  font-size: 12px;
  color: var(--tactical-blue);
  margin-bottom: 12px;
}
.dossier-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.guild-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.guild-tag {
  background: var(--surface-elevated);
  border: 1px solid var(--border-grey);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
}
.guild-tag-match {
  border-color: var(--accent-cyan, #38bdf8);
  background: rgba(56, 189, 248, 0.12);
}
.guild-tag-yellow {
  border-color: var(--warning-amber);
  background: rgba(245, 158, 11, 0.16);
  color: var(--warning-amber);
}
.guild-tag-red {
  border-color: var(--alert-red);
  background: rgba(239, 68, 68, 0.18);
  color: var(--alert-red);
}
.discord-sentry-results {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-grey);
}
.discord-sentry-row {
  padding: 5px 8px;
  margin-top: 5px;
  border-radius: 4px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-grey);
  font-size: 12px;
}

/* SENTRY Citizen & Org Intelligence */
.sentry-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sentry-toolbar input {
  flex: 1;
}
.sentry-notice {
  padding: 10px 12px;
  background: rgba(255, 193, 7, 0.08);
  border: 1px solid rgba(255, 193, 7, 0.35);
  border-radius: 4px;
  font-size: 12px;
}
.sentry-profile-grid {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-grey);
  border-radius: 4px;
  margin-bottom: 12px;
}
.sentry-avatar {
  width: 64px;
  height: 64px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-grey);
  flex-shrink: 0;
}
.sentry-profile-meta { flex: 1; min-width: 0; }
.sentry-profile-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.sentry-profile-facts {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.sentry-bio {
  font-size: 12px;
  color: var(--text-primary);
  white-space: pre-wrap;
  border-top: 1px solid var(--border-grey);
  padding-top: 6px;
  margin-top: 6px;
}
.sentry-section { margin-top: 12px; }
.sentry-org-list, .sentry-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.sentry-org-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-grey);
  border-radius: 4px;
}
.sentry-org-restricted {
  border-color: rgba(255, 193, 7, 0.35);
}
.sentry-org-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-grey);
  flex-shrink: 0;
}
.sentry-org-info { flex: 1; min-width: 0; }
.sentry-org-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}
.sentry-org-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.sentry-history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-grey);
  border-radius: 4px;
  font-size: 12px;
}
.sentry-badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-grey);
  color: var(--text-primary);
}
.sentry-badge-main {
  border-color: var(--tactical-blue);
  color: var(--tactical-blue);
}
.sentry-badge-warn {
  border-color: rgba(255, 193, 7, 0.6);
  color: #ffd166;
}
.sentry-badge-danger {
  border-color: rgba(255, 71, 87, 0.7);
  color: #ff6b81;
}

/* Checklist */
.checklist-wrap { display: flex; flex-direction: column; gap: 8px; }
.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-grey);
  border-radius: 4px;
  cursor: pointer;
}
.checklist-item.checked {
  border-color: rgba(0, 255, 102, 0.35);
  background: rgba(0, 255, 102, 0.05);
}
.checklist-item.checked .checklist-text {
  text-decoration: line-through;
  color: var(--text-muted);
}
.checklist-meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--success-green);
}

/* Notes & Evidence */
.note-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-grey);
}
.note-composer-row {
  display: grid;
  grid-template-columns: 160px 1fr 200px;
  gap: 8px;
}
.notes-timeline { display: flex; flex-direction: column; gap: 10px; }
.note-item {
  background: var(--bg-panel);
  border: 1px solid var(--border-grey);
  border-left: 3px solid var(--border-light);
  border-radius: 4px;
  padding: 10px 12px;
}
.note-EVIDENCE { border-left-color: var(--tactical-blue); }
.note-RED_FLAG { border-left-color: var(--alert-red); background: rgba(255, 51, 68, 0.06); }
.note-SYSTEM { border-left-color: var(--border-grey); opacity: 0.78; font-size: 12px; padding: 7px 10px; }
.note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 12px;
}
.note-cat {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface-elevated);
}
.note-content { white-space: pre-wrap; line-height: 1.45; }
.note-link { margin-top: 6px; font-size: 12px; word-break: break-all; }
.note-attach img {
  margin-top: 8px;
  max-width: 320px;
  max-height: 220px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
}

/* Queue View */
.view-queue {
  padding: 20px 24px;
  overflow-y: auto;
  height: 100%;
}
.queue-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.queue-controls { display: flex; gap: 10px; align-items: center; }
.queue-controls select { width: 220px; }

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-dark);
  border: 1px solid var(--border-grey);
}
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-grey);
}
.data-table th {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--tactical-blue);
  background: var(--bg-panel);
  text-transform: uppercase;
}
.data-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1200;
}
.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface-dark);
  border: 1px solid var(--border-light);
  border-top: 3px solid var(--tactical-blue);
  border-radius: 6px;
  padding: 22px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 220px 1fr; }
  .dossier-layout { grid-template-columns: 1fr; }
  .note-composer-row { grid-template-columns: 1fr; }
}

/* Connection Map View */
.view-map {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-grey);
}

.map-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-toolbar-group label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.map-toolbar-group select {
  width: auto;
  min-width: 120px;
  padding: 5px 8px;
  font-size: 12px;
}

.map-focus-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.map-focus-wrap input[type="text"] {
  width: 210px;
  padding: 5px 24px 5px 8px;
  font-size: 12px;
}

.map-focus-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
  cursor: pointer;
}

.map-focus-clear:hover {
  color: var(--text-primary);
}

.map-focus-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 300px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface-dark);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  z-index: 40;
}

.map-focus-group-label {
  padding: 6px 10px 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-grey);
}

.map-focus-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
}

.map-focus-option:hover,
.map-focus-option.active {
  background: var(--surface-elevated);
}

.map-focus-option-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.map-focus-tag-red {
  color: #ff8892;
  font-weight: 700;
}

.map-focus-tag-yellow {
  color: #fde68a;
  font-weight: 700;
}

.map-search-group input {
  width: 190px;
  padding: 5px 9px;
  font-size: 12px;
}

.map-check-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.map-toolbar-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.map-alert-banner {
  background: rgba(255, 51, 68, 0.12);
  border-bottom: 1px solid rgba(255, 51, 68, 0.55);
  padding: 8px 14px;
}

.map-alert-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.map-alert-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ff9aa3;
  font-size: 13px;
}

.alert-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--alert-red);
  box-shadow: 0 0 8px var(--alert-red);
  flex-shrink: 0;
}

.map-alert-actions {
  display: flex;
  gap: 6px;
}

.map-alert-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 51, 68, 0.25);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.map-alert-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.map-alert-org {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.map-alert-citizens {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.alert-citizen-chip {
  padding: 2px 8px;
  font-size: 11px;
  text-transform: none;
  background: rgba(255, 51, 68, 0.18);
  border-color: rgba(255, 51, 68, 0.45);
}

.map-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 310px;
}

.map-canvas-wrap {
  position: relative;
  min-height: 0;
  background: radial-gradient(circle at center, #0d141f 0%, #05070a 100%);
  overflow: hidden;
}

#connectionMapCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(11, 15, 21, 0.95);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 12px;
  max-width: 240px;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.tip-red { color: #ff6b78; font-weight: 700; margin-top: 3px; }
.tip-yellow { color: #fbbf24; font-weight: 700; margin-top: 3px; }

.map-zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
}

.map-legend {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 7px 12px;
  background: rgba(11, 15, 21, 0.88);
  border-top: 1px solid var(--border-grey);
  font-size: 11px;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.swatch-red { background: var(--alert-red); box-shadow: 0 0 6px var(--alert-red); }
.swatch-yellow { background: #fbbf24; }
.swatch-neutral { background: #7b8da3; }

.legend-line {
  width: 16px;
  height: 0;
  border-top: 2px solid #8b9bb0;
  display: inline-block;
}

.legend-dashed { border-top-style: dashed; }

.map-inspector {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-grey);
  padding: 14px;
  overflow-y: auto;
}

.inspector-header h3 { margin: 4px 0 6px; font-size: 16px; }
.inspector-header-row { display: flex; align-items: flex-start; gap: 10px; }
.inspector-header-meta { flex: 1; min-width: 0; }
.inspector-avatar {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-grey);
  flex-shrink: 0;
  background: var(--surface-dark);
}
.inspector-avatar-round { border-radius: 50%; }
.inspector-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.inspector-actions { display: flex; gap: 6px; margin-top: 10px; }

.inspector-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.inspector-conn-row {
  padding: 7px 9px;
  background: var(--surface-dark);
  border: 1px solid var(--border-grey);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.inspector-conn-row:hover {
  border-color: var(--tactical-blue);
}

@media (max-width: 900px) {
  .map-stage { grid-template-columns: 1fr; grid-template-rows: 1fr 220px; }
  .map-inspector { border-left: none; border-top: 1px solid var(--border-grey); }
}

/* Dossier Threat Flags (Red: Piracy/Infiltration/Syndicate, Yellow: Smuggling) */
.case-card.case-flag-red {
  border-left: 4px solid var(--alert-red);
  background: rgba(255, 51, 68, 0.08);
}
.case-card.case-flag-yellow {
  border-left: 4px solid var(--warning-amber);
  background: rgba(240, 165, 0, 0.08);
}
.case-card.case-flag-red.active {
  border-color: var(--tactical-blue);
  border-left: 4px solid var(--alert-red);
  background: rgba(255, 51, 68, 0.14);
}
.case-card.case-flag-yellow.active {
  border-color: var(--tactical-blue);
  border-left: 4px solid var(--warning-amber);
  background: rgba(240, 165, 0, 0.14);
}
.case-flag-row {
  margin: 0 0 6px;
}
.case-flag-pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.4px;
}
.case-flag-pill-red {
  background: rgba(255, 51, 68, 0.22);
  color: var(--alert-red);
  border: 1px solid rgba(255, 51, 68, 0.5);
}
.case-flag-pill-yellow {
  background: rgba(240, 165, 0, 0.2);
  color: var(--warning-amber);
  border: 1px solid rgba(240, 165, 0, 0.5);
}

.dossier-threat-banner {
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.dossier-threat-banner.threat-red {
  background: rgba(255, 51, 68, 0.12);
  border: 1px solid rgba(255, 51, 68, 0.55);
  border-left: 4px solid var(--alert-red);
}
.dossier-threat-banner.threat-yellow {
  background: rgba(240, 165, 0, 0.12);
  border: 1px solid rgba(240, 165, 0, 0.55);
  border-left: 4px solid var(--warning-amber);
}
.dossier-threat-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.dossier-threat-banner.threat-red .dossier-threat-title { color: var(--alert-red); }
.dossier-threat-banner.threat-yellow .dossier-threat-title { color: var(--warning-amber); }
.dossier-threat-orgs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.threat-org-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(5, 7, 10, 0.55);
}
.threat-org-chip-red {
  border: 1px solid rgba(255, 51, 68, 0.45);
  color: #ffd5d9;
}
.threat-org-chip-yellow {
  border: 1px solid rgba(240, 165, 0, 0.45);
  color: #ffe8b3;
}

.sentry-org-item.sentry-org-threat-red {
  border-left: 3px solid var(--alert-red);
  background: rgba(255, 51, 68, 0.06);
}
.sentry-org-item.sentry-org-threat-yellow {
  border-left: 3px solid var(--warning-amber);
  background: rgba(240, 165, 0, 0.06);
}
.sentry-history-row.sentry-history-threat-red {
  border-left: 3px solid var(--alert-red);
  padding-left: 8px;
  background: rgba(255, 51, 68, 0.05);
}
.sentry-history-row.sentry-history-threat-yellow {
  border-left: 3px solid var(--warning-amber);
  padding-left: 8px;
  background: rgba(240, 165, 0, 0.05);
}
