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