/* Blackwell Case Command Center — Investigator Style */

:root {
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #252540;
  --sidebar-active: #2e2e50;
  --sidebar-text: #c8c8d8;
  --sidebar-muted: #6e6e8a;
  --accent: #4a9eff;
  --accent-hover: #3180e8;
  --bg: #f4f4f6;
  --panel-bg: #ffffff;
  --border: #d8d8e0;
  --text: #1a1a2e;
  --text-muted: #6a6a7a;
  --ok: #065f46;
  --warning: #e85c3a;
  --success: #3aaa5a;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #2a2a40;
}

#sidebar-footer {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
#sidebar-cjis-link,
#sidebar-setup-link {
  font-size: 11px;
  color: var(--sidebar-muted);
  text-decoration: none;
  display: block;
  padding: 4px 0;
}
#sidebar-cjis-link:hover,
#sidebar-setup-link:hover { color: var(--accent); }

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px;
  border-bottom: 1px solid #2a2a40;
}

#app-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.agency-sidebar-logo-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid #c9a84c;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.agency-sidebar-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
}
.agency-sidebar-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}
.agency-powered-by {
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.5px;
  color: var(--sidebar-muted);
  text-transform: none;
}

#btn-new-case {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

#btn-new-case:hover { background: var(--accent-hover); }

#sidebar-search {
  position: relative;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
#sidebar-search-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input, #1e2025);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
}
#sidebar-search-input:focus { border-color: var(--accent); }
#sidebar-search-results {
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(100% - 6px);
  z-index: 100;
  background: var(--sidebar-bg, #1a1d22);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.search-result-item {
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--sidebar-hover); }
.search-result-case { font-weight: 600; color: var(--accent); }
.search-result-file { color: var(--muted); font-size: 11px; margin-left: 4px; }
.search-result-snippet { color: var(--text-dim, #888); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#case-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.case-item {
  padding: 10px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 13px;
}

.case-item:hover { background: var(--sidebar-hover); }
.case-item.active {
  background: var(--sidebar-active);
  border-left-color: var(--accent);
}

.case-item-name {
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-item-status {
  font-size: 11px;
  color: var(--sidebar-muted);
  margin-top: 2px;
}

.bw-case-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.bw-case-card-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--sidebar-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.bw-case-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.bw-health-dot--lg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}
.bw-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.bw-status-badge--active   { background: rgba(16,185,129,.15); color: #10b981; }
.bw-status-badge--closed   { background: rgba(156,163,175,.15); color: #9ca3af; }
.bw-status-badge--archived { background: rgba(156,163,175,.12); color: #9ca3af; }
.bw-status-badge--pending  { background: rgba(245,158,11,.15); color: #f59e0b; }
.bw-status-badge--unknown  { background: rgba(99,102,241,.12); color: #818cf8; }
.bw-case-leads-chip {
  font-size: 10.5px;
  font-weight: 600;
  color: #f59e0b;
  background: rgba(245,158,11,.12);
  border-radius: 99px;
  padding: 1px 7px;
}

.empty-hint {
  padding: 12px;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-style: italic;
}

/* ─── Main ─────────────────────────────────────────────────────── */
#main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#no-case-selected {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ─── Case View ───────────────────────────────────────────────── */
#case-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;   /* flex scroll fix: allow shrinking below content size */
  overflow: hidden;
}

/* ─── Case Overview ───────────────────────────────────────────── */
#case-overview {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#overview-id-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

#overview-desc { font-weight: normal; color: var(--text-muted); }

#overview-stats-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
}

.overview-stat { color: var(--text); }
.overview-good { color: var(--ok); font-weight: 600; }
.overview-warn { color: #92400e; font-weight: 600; }
.overview-sep { color: var(--border); }

#overview-status {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.status-open       { background: #dbeafe; color: #1e40af; }
.status-closed     { background: #d1fae5; color: var(--ok); }
.status-unknown    { background: var(--bg); color: var(--text-muted); }

/* ─── Case Actions Panel ─────────────────────────────────── */
#case-actions-panel {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

#actions-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  margin-right: 4px;
}

/* Smaller accent button for action bar */
.action-btn.accent-sm {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
}
.action-btn.accent-sm:hover { background: #6d28d9; }
.action-btn.accent-sm:disabled { background: #a78bfa; cursor: not-allowed; }

/* Smaller secondary button */
.action-btn.secondary-sm {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
}
.action-btn.secondary-sm:hover { border-color: var(--accent); color: var(--accent); }
.action-btn.secondary-sm:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Analysis Status ───────────────────────────────────────────── */
#analysis-status {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.analysis-status-label { color: var(--text-muted); font-weight: 600; }

.analysis-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid;
}

.status-idle      { background: var(--bg); color: var(--text-muted); border-color: var(--border); }
.status-queued  { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.status-stuck  { background: #f3e8ff; color: #6b21a8; border-color: #a855f7; }
.status-running { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.status-completed { background: #d1fae5; color: var(--ok); border-color: #6ee7b7; }
.status-failed { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Pulsing dot for running state */
.status-running .status-dot {
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.analysis-when { color: var(--text-muted); }
.analysis-msg { color: var(--text); }
.analysis-msg.muted { color: var(--text-muted); }
.analysis-summary {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 3px;
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
  max-width: 600px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Case Header ─────────────────────────────────────────────── */
#case-header {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

#case-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.bw-case-header-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.bw-case-header-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 480px;
}
.bw-case-type-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: rgba(99,102,241,.15);
  color: var(--accent);
  border-radius: 5px;
  padding: 2px 8px;
  white-space: nowrap;
}
.bw-case-header-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bw-case-id-sub {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}
.bw-case-investigator {
  font-size: 12px;
  color: var(--text-muted);
}
.bw-case-desc-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

#case-id-display {
  font-weight: 700;
  font-size: 14px;
  font-family: var(--mono);
  color: var(--accent);
}

#case-desc-display {
  font-size: 13px;
  color: var(--text-muted);
}

#case-status-display {
  font-size: 11px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 2px 8px;
  border-radius: 10px;
}

#case-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ─── Tabs ─────────────────────────────────────────────────────── */
#tab-bar {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 20px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ─── Tab Content ─────────────────────────────────────────────── */
#tab-content {
  flex: 1;
  min-height: 0;   /* critical: lets flex child shrink so overflow-y can scroll */
  overflow-y: auto;
  background: var(--bg);
}

.tab-pane {
  display: none;
  padding: 20px;
  /* no height: 100% — let content define height within the scrolling #tab-content */
}

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

.pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.bw-analysis-toolbar {
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}
.bw-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.bw-toolbar-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding-right: 4px;
  white-space: nowrap;
}
.bw-toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.pane-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--panel-bg);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 16px;
}

/* ─── File Lists ──────────────────────────────────────────────── */
.file-list {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  gap: 8px;
}

.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg); }

.file-icon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
  display: inline-block;
}

.file-icon.pdf { background: #e85c3a; }
.file-icon.txt { background: #4a9eff; }
.file-icon.jpg, .file-icon.jpeg, .file-icon.png { background: #3aaa5a; }
.file-icon.mp4, .file-icon.ogg, .file-icon.wav { background: #9a3aaa; }
.file-icon.default { background: #888; }

.file-name { flex: 1; font-family: var(--mono); font-size: 12px; }
.file-size { font-size: 11px; color: var(--text-muted); }

.file-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

.file-badge.mismatch {
  background: var(--warning);
  color: #fff;
}

.file-badge.ok {
  background: var(--success);
  color: #fff;
}

/* ─── INPUT_INDEX block ────────────────────────────────────────── */
#input-index-block {
  margin-bottom: 20px;
}

#input-index-content {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

/* ─── Markdown rendering ───────────────────────────────────────── */
.markdown-body {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  overflow-y: auto;
  height: calc(100vh - 320px);
}

.markdown-body h1 { font-size: 18px; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.markdown-body h2 { font-size: 15px; margin-top: 20px; margin-bottom: 8px; }
.markdown-body p { margin-bottom: 10px; }
.markdown-body table { border-collapse: collapse; width: 100%; margin-bottom: 16px; font-size: 13px; }
.markdown-body th { background: var(--bg); border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.markdown-body td { border: 1px solid var(--border); padding: 6px 10px; }
.markdown-body code { background: var(--bg); padding: 1px 5px; border-radius: 3px; font-family: var(--mono); font-size: 12px; }
.markdown-body pre { background: var(--bg); padding: 12px; border-radius: 6px; overflow-x: auto; margin-bottom: 12px; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin-bottom: 12px; }
.markdown-body li { margin-bottom: 4px; }

/* ─── Memory editor ────────────────────────────────────────────── */
#memory-editor {
  width: 100%;
  height: calc(100vh - 280px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
}

/* ─── Chat panel ──────────────────────────────────────────────── */
#chat-panel {
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}

#chat-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

#chat-instructions {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

#chat-messages {
  max-height: 80px;
  overflow-y: auto;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

#chat-input-row {
  display: flex;
  gap: 8px;
}

#chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
}

#btn-chat-send {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
}

#btn-chat-send:hover { background: var(--accent-hover); }

/* ─── Buttons ──────────────────────────────────────────────────── */
.action-btn {
  padding: 6px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text);
}

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

.action-btn.accent {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}
.action-btn.accent:hover { background: #6d28d9; }

#transcribe-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  margin-top: 6px;
}
#transcribe-status.ok { background: #d1fae5; color: #065f46; }
#transcribe-status.err { background: #fee2e2; color: #991b1b; }
#transcribe-status.loading { background: #fef3c7; color: #92400e; }

/* ─── Modal ────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--panel-bg);
  border-radius: 10px;
  padding: 24px;
  width: 400px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-content.wide { width: 800px; }

.modal-content h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.modal-content label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--text-muted);
  gap: 4px;
}

.modal-content input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: var(--font);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

#modal-file-content {
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  max-height: 60vh;
  overflow-y: auto;
}

#modal-file-content img {
  max-width: 100%;
  border-radius: 6px;
}

#prep-output {
  background: var(--bg);
  padding: 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

/* ─── Evidence Register ───────────────────────────────────────── */
.reg-section {
  margin-bottom: 8px;
}

.reg-section-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reg-count {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
  letter-spacing: 0;
  text-transform: none;
}

.reg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
}

.reg-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-bottom: 2px solid var(--border);
  background: var(--panel-bg);
  white-space: nowrap;
}

.reg-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  max-width: 320px;
  word-break: break-all;
}

.reg-source-row td {
  border-left: 3px solid var(--accent);
}

.reg-deriv-row td {
  border-left: 3px solid transparent;
  color: var(--text-muted);
}

.reg-deriv-row:hover td {
  background: #f8f9fa;
  color: var(--text);
}

.reg-id { color: var(--accent); font-weight: 600; white-space: nowrap; }
.reg-path { font-size: 11px; }
.reg-file-link {
  color: var(--text);
  text-decoration: none;
  font-size: 11px;
  font-family: var(--mono);
}
.reg-file-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.reg-source-row:hover td, .reg-deriv-row:hover td {
  background: #f0f4ff;
}
.reg-type { white-space: nowrap; font-size: 11px; }
.reg-rel { font-size: 11px; white-space: nowrap; }

/* Parent badge on derivative rows */
.parent-badge {
  display: inline-block;
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #a78bfa;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.parent-badge.muted { background: var(--bg); color: var(--text-muted); border-color: var(--border); }
.reg-warn { white-space: nowrap; }

/* ─── Warning Badges ───────────────────────────────────────────── */
.warn-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: var(--font);
  cursor: help;
  white-space: nowrap;
}

/* ─── Audit Log ────────────────────────────────────────────────── */
#audit-filter {
  font-size: 12px;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--mono);
}

.audit-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-bottom: 2px solid var(--border);
  background: var(--panel-bg);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.audit-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  max-width: 280px;
  word-break: break-word;
}

.audit-id { white-space: nowrap; color: var(--accent); font-weight: 600; }
.audit-time { white-space: nowrap; color: var(--text-muted); font-size: 10px; }
.audit-session { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.audit-action { white-space: nowrap; font-weight: 600; font-size: 10px; }
.audit-evid { white-space: nowrap; font-size: 10px; color: var(--text-muted); }
.audit-detail { font-size: 10px; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 4px; }

.audit-detail-row td { padding: 0 8px 6px 8px !important; border-bottom: 2px solid var(--border) !important; background: #f8f9fa; }
.audit-detail-expanded { font-size: 11px; font-family: var(--mono); color: var(--text); white-space: pre-wrap; word-break: break-word; padding: 4px 0; line-height: 1.5; }

.detail-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 9px;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
}

/* Result color coding */
.audit-row-ok td { background: #d1fae5; }
.audit-row-skipped td { background: #fef3c7; }
.audit-row-reconciled td { background: #dbeafe; }
.audit-row-error td { background: #fee2e2; }
.audit-row-flagged td { background: #f3e8ff; }
.audit-row- td { background: transparent; }

/* Result badges */
.result-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: var(--font);
  font-weight: 600;
  white-space: nowrap;
}
.result-ok    { background: #065f46; color: #fff; }
.result-skipped { background: #92400e; color: #fff; }
.result-reconciled { background: #1e40af; color: #fff; }
.result-error { background: #991b1b; color: #fff; }
.result-flagged { background: #6b21a8; color: #fff; }
.result- { background: var(--border); color: var(--text); }

/* ─── Timeline ────────────────────────────────────────────────── */
.bw-timeline {
  position: relative;
  padding: 6px 0 6px 28px;
  max-width: 780px;
}

.bw-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: var(--border);
}

.bw-tl-event {
  position: relative;
  margin-bottom: 22px;
}

.bw-tl-event:last-child {
  margin-bottom: 0;
}

.bw-tl-event::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel-bg);
  box-shadow: 0 0 0 1px var(--border);
}

.bw-tl-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 3px;
}

.bw-tl-date {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
  white-space: nowrap;
}

.bw-tl-source {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.7;
  white-space: nowrap;
}

.bw-tl-source-mem {
  color: #7c5cbf;
  opacity: 1;
}

.bw-tl-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}

/* ─── Missed Leads ────────────────────────────────────────────── */
.bw-ml-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 18px;
  overflow: hidden;
}

.bw-ml-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.bw-ml-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.bw-ml-count {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(232, 92, 58, 0.1);
  color: var(--warning);
  border-radius: 10px;
  padding: 1px 8px;
  font-weight: 600;
}

.bw-ml-count-clear {
  background: rgba(58, 170, 90, 0.1);
  color: var(--success);
}

.bw-ml-rows {
  display: flex;
  flex-direction: column;
}

.bw-ml-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.bw-ml-row:last-child {
  border-bottom: none;
}

.bw-ml-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  min-width: 52px;
  text-align: center;
}

.bw-ml-badge-high   { background: #fee2e2; color: #991b1b; }
.bw-ml-badge-medium { background: #fef3c7; color: #92400e; }
.bw-ml-badge-low    { background: #dbeafe; color: #1e40af; }

.bw-ml-category {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  min-width: 160px;
}

.bw-ml-desc {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.bw-ml-empty {
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

.bw-ml-loading,
.bw-ml-error {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
}

.bw-ml-error { color: var(--warning); }

/* ─── Working Notes / Input Index Editor ─────────────────────── */
.bw-index-editor {
  width: 100%;
  min-height: 320px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  box-sizing: border-box;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.bw-index-editor:focus {
  border-color: var(--accent);
}

.bw-working-divider {
  margin: 20px 0 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ─── Working File Cards ──────────────────────────────────────── */
.bw-wf-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}
.bw-wf-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.bw-wf-card-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bw-wf-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.bw-wf-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.bw-wf-expand-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  cursor: pointer;
  transition: background .12s;
}
.bw-wf-expand-btn:hover { background: rgba(99,102,241,.1); }
.bw-wf-preview {
  padding: 0 14px 10px;
  border-top: 1px solid var(--border);
}
.bw-wf-preview-text {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 0;
  max-height: 72px;
  overflow: hidden;
}
.bw-wf-full-pre {
  max-height: 480px;
  overflow-y: auto;
}
.bw-wf-full {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
}
.bw-wf-full-md { padding: 0; }
.bw-wf-preview-loading { font-size: 11.5px; color: var(--text-muted); font-style: italic; display: block; padding: 8px 0; }

/* ─── Case Health Dot & Popover ───────────────────────────────── */
.bw-health-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  cursor: default;
}

.bw-health-dot--strong      { background: #10b981; }
.bw-health-dot--ready       { background: #10b981; }
.bw-health-dot--developing  { background: #6366f1; }
.bw-health-dot--caution     { background: #f59e0b; }
.bw-health-dot--needs_work  { background: #f97316; }
.bw-health-dot--critical    { background: #ef4444; }
.bw-health-dot--not_started { background: #9ca3af; }
.bw-health-dot--unknown     { background: #9ca3af; }

.bw-health-popover {
  position: fixed;
  z-index: 9999;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  min-width: 210px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  display: none;
  pointer-events: none;
}

.bw-health-popover.bw-hp-visible { display: block; }

.bw-hp-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.bw-hp-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text);
  padding: 2px 0;
}

.bw-hp-row span { color: var(--text-muted); }

.bw-hp-date {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

/* ─── Entity Cross-Reference Badges ──────────────────────────── */
.bw-xref-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--accent);
  background: rgba(74, 158, 255, 0.08);
  border: 1px solid rgba(74, 158, 255, 0.2);
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 600;
  cursor: default;
  margin-left: auto;
  margin-right: 6px;
  white-space: nowrap;
}

.bw-xref-badge em {
  font-style: normal;
  color: var(--text-muted);
  font-weight: 500;
}

.bw-xref-flag {
  color: var(--warning);
  font-size: 10px;
}

/* ─── Prosecution Readiness ───────────────────────────────────── */
.bw-pr-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 18px;
  overflow: hidden;
}

.bw-pr-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.bw-pr-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  flex: 1;
}

.bw-pr-score-label {
  font-size: 12px;
  color: var(--text-muted);
}

.bw-pr-badge {
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 9px;
}

.bw-pr-ready     { background: #d1fae5; color: #065f46; }
.bw-pr-caution   { background: #fef3c7; color: #92400e; }
.bw-pr-not-ready { background: #fee2e2; color: #991b1b; }

.bw-pr-bar-track {
  height: 4px;
  background: var(--border);
}

.bw-pr-bar-fill {
  height: 100%;
  transition: width 0.4s ease;
}

.bw-pr-bar-fill.bw-pr-ready     { background: #10b981; }
.bw-pr-bar-fill.bw-pr-caution   { background: #f59e0b; }
.bw-pr-bar-fill.bw-pr-not-ready { background: #ef4444; }

.bw-pr-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.bw-pr-row:last-child { border-bottom: none; }

.bw-pr-icon {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  width: 16px;
  text-align: center;
}

.bw-pr-icon-ok   { color: #10b981; }
.bw-pr-icon-miss { color: #ef4444; }
.bw-pr-icon-flag { color: #f59e0b; }

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }


/* ─── CASE STATUS PANEL ───────────────────────────────────────── */

.case-status-shell {
  margin: 18px 0 8px 0;
}

.case-status-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.case-status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.case-status-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.case-status-summary {
  margin-bottom: 12px;
}

.case-status-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.case-count-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  opacity: 0.9;
}

.case-status-panel {
  display: grid;
  gap: 10px;
}

.case-asset-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.015);
}

.case-asset-main {
  min-width: 0;
}

.case-asset-title {
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
}

.case-asset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  opacity: 0.75;
  word-break: break-word;
}

.case-asset-side {
  display: flex;
  align-items: flex-start;
}

.case-asset-extra {
  grid-column: 1 / -1;
}

.case-output-block {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.case-output-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: start;
}

.case-output-key {
  font-size: 12px;
  opacity: 0.75;
}

.case-output-empty,
.case-status-empty {
  font-size: 13px;
  opacity: 0.75;
}

.case-asset-error {
  margin-top: 8px;
  color: #ffb3b3;
  font-size: 12px;
  white-space: pre-wrap;
}

.case-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: lowercase;
  border: 1px solid rgba(255,255,255,0.12);
}

.case-status-badge--good {
  background: rgba(80, 200, 120, 0.16);
  border-color: rgba(80, 200, 120, 0.35);
}

.case-status-badge--work {
  background: rgba(255, 196, 0, 0.16);
  border-color: rgba(255, 196, 0, 0.35);
}

.case-status-badge--bad {
  background: rgba(255, 90, 90, 0.16);
  border-color: rgba(255, 90, 90, 0.35);
}

.case-status-badge--unknown {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}



/* ─── CASE READINESS GATE ─────────────────────────────────────── */

.case-readiness-shell {
  margin: 10px 0 14px 0;
}

.case-readiness-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.case-readiness-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.case-readiness-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.case-readiness-ready {
  font-weight: 700;
  margin-bottom: 6px;
}

.case-readiness-blocked {
  font-weight: 700;
  margin-bottom: 6px;
}

.case-readiness-meta {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 8px;
}

.case-readiness-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}



/* ─── CASE STATUS ROW ACTIONS ─────────────────────────────────── */

.case-asset-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 10px 0;
}

.case-asset-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: inherit;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.case-asset-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.09);
}

.case-asset-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.case-asset-action-note {
  font-size: 12px;
  opacity: 0.65;
}



/* ─── RELIABLE HEADER / SIDEBAR STATUS BADGES ─────────────────── */

.blackwell-reliable-status-badge {
  margin-left: 8px;
  vertical-align: middle;
}

.blackwell-sidebar-status-badge {
  margin-left: 0;
  margin-top: 6px;
  min-width: 62px;
}



/* ─── HARD HEADER BADGE FIX ───────────────────────────────────── */

.blackwell-hard-header-badge {
  margin-right: 10px;
  margin-left: 8px;
}



/* ─── STRUCTURED OUTPUTS UI ───────────────────────────────────── */

.blackwell-build-outputs-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: inherit;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
}

.blackwell-build-outputs-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.09);
}

.blackwell-build-outputs-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.structured-outputs-shell {
  margin: 10px 0 14px 0;
}

.structured-outputs-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.structured-outputs-head {
  margin-bottom: 10px;
}

.structured-outputs-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.structured-outputs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.structured-outputs-list {
  display: grid;
  gap: 8px;
}

.structured-output-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px;
  align-items: start;
}

.structured-output-key {
  font-size: 12px;
  opacity: 0.75;
}

.structured-outputs-empty {
  font-size: 13px;
  opacity: 0.75;
}



/* ===== ONE-PIECE PREP OVERVIEW FIX ===== */

.blackwell-prep-overview-shell {
  margin: 10px 0 16px 0;
}

.blackwell-prep-overview-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.blackwell-prep-overview-head {
  margin-bottom: 12px;
}

.blackwell-prep-overview-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.blackwell-prep-overview-body {
  display: grid;
  gap: 12px;
}

.blackwell-prep-grid {
  display: grid;
  gap: 12px;
}

.blackwell-prep-section-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.blackwell-prep-status-row,
.blackwell-prep-meta,
.blackwell-prep-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.blackwell-prep-files {
  display: grid;
  gap: 8px;
}

.blackwell-prep-file-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 10px;
  align-items: start;
}

.blackwell-prep-file-key {
  font-size: 12px;
  opacity: 0.75;
}

.blackwell-prep-empty {
  font-size: 13px;
  opacity: 0.75;
}


/* ===== STABLE PREP OVERVIEW DOCK ===== */

.bw-prep-overview-dock {
  margin: 10px 0 12px 0;
}

.bw-prep-overview-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.bw-prep-overview-head {
  margin-bottom: 12px;
}

.bw-prep-overview-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.bw-prep-overview-body,
.bw-prep-grid {
  display: grid;
  gap: 12px;
}

.bw-prep-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.bw-prep-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.bw-prep-files {
  display: grid;
  gap: 8px;
}

.bw-prep-file-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 10px;
  align-items: start;
}

.bw-prep-file-key {
  font-size: 12px;
  opacity: 0.75;
}

.bw-prep-empty {
  font-size: 13px;
  opacity: 0.75;
}


/* ===== STRUCTURED OUTPUTS VIEWER ===== */

.bw-structured-outputs-viewer-shell {
  margin: 10px 0 14px 0;
}

.bw-structured-outputs-viewer-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.bw-structured-outputs-viewer-head {
  margin-bottom: 12px;
}

.bw-structured-outputs-viewer-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.bw-structured-outputs-viewer-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
}

.bw-structured-outputs-file-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.bw-structured-output-file-btn {
  appearance: none;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: inherit;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
}

.bw-structured-output-file-btn:hover {
  background: rgba(255,255,255,0.08);
}

.bw-structured-output-file-btn-key {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.bw-structured-output-file-btn-path {
  display: block;
  font-size: 12px;
  opacity: 0.7;
  word-break: break-word;
}

.bw-structured-outputs-preview-wrap {
  min-width: 0;
}

.bw-structured-outputs-preview-meta {
  margin-bottom: 8px;
  font-size: 13px;
}

.bw-structured-outputs-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  max-height: 520px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
}

.bw-structured-outputs-empty {
  font-size: 13px;
  opacity: 0.75;
}

@media (max-width: 1100px) {
  .bw-structured-outputs-viewer-body {
    grid-template-columns: 1fr;
  }
}


/* ===== FINAL ANALYSIS RUNNER + VIEWER ===== */

.bw-build-final-analysis-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: inherit;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
}

.bw-build-final-analysis-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.09);
}

.bw-build-final-analysis-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.bw-final-analysis-viewer-shell {
  margin: 10px 0 14px 0;
}

.bw-final-analysis-viewer-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.bw-final-analysis-viewer-head {
  margin-bottom: 12px;
}

.bw-final-analysis-viewer-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.bw-final-analysis-viewer-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
}

.bw-final-analysis-file-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.bw-final-analysis-file-btn {
  appearance: none;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: inherit;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
}

.bw-final-analysis-file-btn:hover {
  background: rgba(255,255,255,0.08);
}

.bw-final-analysis-file-btn-key {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.bw-final-analysis-file-btn-path {
  display: block;
  font-size: 12px;
  opacity: 0.7;
  word-break: break-word;
}

.bw-final-analysis-preview-wrap {
  min-width: 0;
}

.bw-final-analysis-preview-meta {
  margin-bottom: 8px;
  font-size: 13px;
}

.bw-final-analysis-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  max-height: 520px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
}

.bw-final-analysis-empty {
  font-size: 13px;
  opacity: 0.75;
}

@media (max-width: 1100px) {
  .bw-final-analysis-viewer-body {
    grid-template-columns: 1fr;
  }
}


/* ===== WORKSPACE CLEANUP CONTROLS ===== */

.bw-cleanup-controls {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 8px;
}

.bw-cleanup-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: inherit;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bw-cleanup-btn:hover {
  background: rgba(255,255,255,0.09);
}


/* ===== HARD PAGE SCROLL FIX ===== */

html, body {
  height: auto !important;
  min-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

main,
.main-content,
.content,
.container,
.app-shell,
.app-main,
.case-layout,
.case-detail,
.case-detail-view,
.case-content,
.case-pane,
.tab-panel,
.tab-content {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

#bw-prep-overview-dock,
#bw-structured-outputs-viewer-shell,
#bw-final-analysis-viewer-shell {
  overflow: visible !important;
}

.bw-structured-outputs-preview,
.bw-final-analysis-preview {
  max-height: 420px !important;
  overflow: auto !important;
}


/* ===== VIEWER READABILITY UPGRADE ===== */

.bw-structured-output-file-btn.is-active,
.bw-final-analysis-file-btn.is-active {
  border-color: rgba(80, 200, 120, 0.45);
  background: rgba(80, 200, 120, 0.10);
  box-shadow: inset 0 0 0 1px rgba(80, 200, 120, 0.15);
}

.bw-structured-outputs-viewer-body,
.bw-final-analysis-viewer-body {
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: start;
}

.bw-structured-outputs-preview,
.bw-final-analysis-preview {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  padding: 16px;
  max-height: 680px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.55;
}

.bw-code-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.bw-md-preview h1,
.bw-md-preview h2,
.bw-md-preview h3 {
  margin: 0 0 10px 0;
  line-height: 1.25;
}

.bw-md-preview h1 {
  font-size: 22px;
}

.bw-md-preview h2 {
  font-size: 18px;
  margin-top: 16px;
}

.bw-md-preview h3 {
  font-size: 15px;
  margin-top: 14px;
}

.bw-md-preview p {
  margin: 0 0 10px 0;
}

.bw-md-preview ul {
  margin: 0 0 12px 20px;
  padding: 0;
}

.bw-md-preview li {
  margin: 0 0 6px 0;
}

.bw-md-spacer {
  height: 6px;
}

@media (max-width: 1200px) {
  .bw-structured-outputs-viewer-body,
  .bw-final-analysis-viewer-body {
    grid-template-columns: 1fr;
  }
}


/* ===== LEAD BOARD ===== */

.bw-lead-board-shell {
  margin: 10px 0 14px 0;
}

.bw-lead-board-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.bw-lead-board-head {
  margin-bottom: 10px;
}

.bw-lead-board-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.bw-lead-board-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

.bw-lead-board-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.bw-lead-column {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  min-width: 0;
}

.bw-lead-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.bw-lead-column-title {
  font-weight: 700;
}

.bw-lead-column-count {
  font-size: 12px;
  opacity: 0.75;
}

.bw-lead-column-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.bw-lead-card {
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
}

.bw-lead-card--high {
  border-color: rgba(220, 80, 80, 0.35);
}

.bw-lead-card--medium {
  border-color: rgba(220, 180, 80, 0.35);
}

.bw-lead-card--low {
  border-color: rgba(100, 160, 255, 0.25);
}

.bw-lead-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.bw-lead-card-value {
  font-weight: 700;
  word-break: break-word;
}

.bw-lead-card-score {
  font-size: 12px;
  opacity: 0.75;
  white-space: nowrap;
}

.bw-lead-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.bw-lead-card-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  opacity: 0.9;
}

.bw-lead-card-section {
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 8px;
}

.bw-lead-card-section:last-child {
  margin-bottom: 0;
}

.bw-lead-board-empty {
  font-size: 13px;
  opacity: 0.75;
}

@media (max-width: 1200px) {
  .bw-lead-board-columns {
    grid-template-columns: 1fr;
  }
}


/* ===== CONFIRMED ENTITIES EDITOR ===== */

.bw-confirmed-entities-shell {
  margin: 10px 0 14px 0;
}

.bw-confirmed-entities-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.bw-confirmed-entities-head {
  margin-bottom: 10px;
}

.bw-confirmed-entities-sub {
  margin: 4px 0 0 0;
  opacity: 0.7;
  font-size: 12px;
}

.bw-confirmed-entities-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

.bw-confirmed-entities-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.bw-confirmed-entities-group {
  display: grid;
  gap: 6px;
}

.bw-confirmed-entities-label {
  font-weight: 700;
  font-size: 13px;
}

.bw-confirmed-entities-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  color: inherit;
  font: inherit;
  line-height: 1.4;
}

.bw-confirmed-entities-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.bw-confirmed-entities-btn {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  color: inherit;
  cursor: pointer;
}

.bw-confirmed-entities-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.bw-confirmed-entities-note {
  font-size: 12px;
  opacity: 0.8;
}

@media (max-width: 1200px) {
  .bw-confirmed-entities-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== HARD STABLE TOP-PANELS LAYOUT OVERRIDE ===== */

.bw-top-panels-host {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: 100%;
  margin: 12px 0 18px 0;
  position: relative;
  z-index: 0;
}

#bw-prep-overview-shell,
#bw-confirmed-entities-shell,
#bw-lead-board-shell,
#bw-final-analysis-viewer-shell {
  width: 100%;
  max-width: 100%;
  position: relative;
  z-index: 0;
  clear: both;
  box-sizing: border-box;
}

.bw-confirmed-entities-card,
.bw-lead-board-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.bw-confirmed-entities-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
  width: 100%;
}

.bw-confirmed-entities-group {
  min-width: 0;
}

.bw-confirmed-entities-textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  box-sizing: border-box;
}

.bw-lead-board-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
  align-items: start;
}

.bw-lead-column,
.bw-lead-card {
  min-width: 0;
  box-sizing: border-box;
}

@media (max-width: 1200px) {
  .bw-confirmed-entities-grid,
  .bw-lead-board-columns {
    grid-template-columns: 1fr;
  }
}


/* ===== PROMOTE AUTO LEAD TO CONFIRMED ===== */

.bw-lead-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.bw-lead-promote-btn {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 9px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.04);
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.bw-lead-promote-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.bw-lead-promoted-label {
  font-size: 12px;
  opacity: 0.8;
  font-weight: 600;
}


/* ===== UNCONFIRM BUTTON ===== */

.bw-lead-unconfirm-btn {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 9px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.03);
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.bw-lead-unconfirm-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}


/* ===== CONFIRMED ENTITIES EDITOR V2 ===== */

.bw-confirmed-entities-card-v2 {
  padding: 16px;
}

.bw-ce-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 16px;
  width: 100%;
}

.bw-ce-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.bw-ce-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bw-ce-section-title {
  font-size: 13px;
  font-weight: 700;
}

.bw-ce-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.bw-ce-input {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  color: inherit;
  font: inherit;
  box-sizing: border-box;
}

.bw-ce-add-btn {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.bw-ce-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.bw-ce-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  box-sizing: border-box;
}

.bw-ce-chip-text {
  font-size: 12px;
  line-height: 1.2;
  word-break: break-word;
}

.bw-ce-chip-remove {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.85;
  padding: 0;
}

.bw-ce-empty {
  font-size: 12px;
  opacity: 0.65;
}

@media (max-width: 1200px) {
  .bw-ce-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== STRUCTURED CONFIRMED ENTITY FORMS ===== */

.bw-ce-structured-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 18px;
  margin-top: 18px;
  width: 100%;
}

.bw-ce-structured-section {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  min-width: 0;
  box-sizing: border-box;
}

.bw-ce-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bw-ce-input-span-2 {
  grid-column: span 2;
}

.bw-ce-structured-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bw-ce-record-list {
  display: grid;
  gap: 10px;
}

.bw-ce-record-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  box-sizing: border-box;
}

.bw-ce-record-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bw-ce-record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  font-size: 12px;
}

@media (max-width: 1400px) {
  .bw-ce-structured-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .bw-ce-record-grid,
  .bw-ce-form-grid {
    grid-template-columns: 1fr;
  }

  .bw-ce-input-span-2 {
    grid-column: span 1;
  }
}


/* ===== STRUCTURED ENTITIES UX CLEANUP ===== */

.bw-confirmed-entities-card-v3 {
  padding: 18px;
}

.bw-ce-grid-simple {
  margin-bottom: 18px;
}

.bw-ce-structured-section-v2 {
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  background: rgba(255,255,255,0.025);
}

.bw-ce-subblock {
  display: grid;
  gap: 8px;
}

.bw-ce-subtitle {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.9;
}

.bw-ce-input-strong {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.05);
  min-height: 40px;
}

.bw-ce-action-btn,
.bw-ce-save-btn {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  font-weight: 700;
  min-height: 38px;
}

.bw-confirmed-entities-actions-bar {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.bw-ce-record-card {
  padding: 12px;
}

.bw-ce-record-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .bw-ce-record-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== RECORD-AWARE LEAD BOARD ===== */

.bw-lead-structured-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.bw-lead-structured-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  opacity: 0.9;
}

.bw-lead-structured-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

.bw-lead-detail-row {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.bw-lead-detail-label {
  font-size: 11px;
  opacity: 0.65;
  font-weight: 600;
}

.bw-lead-detail-value {
  font-size: 12px;
  word-break: break-word;
}

@media (max-width: 900px) {
  .bw-lead-structured-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== CONTROLLED REBUILD PHASE 1: DOCKING CLEANUP ===== */

#bw-confirmed-entities-shell.bw-ce-docked {
  width: 100%;
  max-width: 100%;
  margin: 12px 0 16px 0;
  box-sizing: border-box;
  clear: both;
}

#bw-confirmed-entities-shell.bw-ce-docked .bw-confirmed-entities-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#bw-confirmed-entities-shell.bw-ce-docked .bw-ce-grid,
#bw-confirmed-entities-shell.bw-ce-docked .bw-ce-structured-grid {
  width: 100%;
  box-sizing: border-box;
}

#bw-confirmed-entities-shell.bw-ce-docked .bw-ce-section,
#bw-confirmed-entities-shell.bw-ce-docked .bw-ce-structured-section {
  min-width: 0;
  box-sizing: border-box;
}

#bw-confirmed-entities-shell.bw-ce-docked .bw-ce-input,
#bw-confirmed-entities-shell.bw-ce-docked .bw-ce-input-strong {
  width: 100%;
  box-sizing: border-box;
}


/* ===== CONFIRMED ENTITIES VISUAL POLISH ===== */

#bw-confirmed-entities-shell {
  margin: 14px 0 18px 0;
}

#bw-confirmed-entities-shell .bw-confirmed-entities-card,
#bw-confirmed-entities-shell .bw-confirmed-entities-card-v2,
#bw-confirmed-entities-shell .bw-confirmed-entities-card-v3 {
  width: 100%;
  box-sizing: border-box;
  padding: 18px 18px 16px 18px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

#bw-confirmed-entities-shell .bw-confirmed-entities-head {
  margin-bottom: 10px;
}

#bw-confirmed-entities-shell .section-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
}

#bw-confirmed-entities-shell .bw-confirmed-entities-sub {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.68);
}

#bw-confirmed-entities-shell .bw-confirmed-entities-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.035);
  font-size: 12px;
  color: rgba(15, 23, 42, 0.86);
}

#bw-confirmed-entities-shell .bw-ce-grid,
#bw-confirmed-entities-shell .bw-ce-grid-simple,
#bw-confirmed-entities-shell .bw-ce-structured-grid {
  width: 100%;
  box-sizing: border-box;
  align-items: start;
}

#bw-confirmed-entities-shell .bw-ce-grid,
#bw-confirmed-entities-shell .bw-ce-grid-simple {
  gap: 16px;
  margin-bottom: 18px;
}

#bw-confirmed-entities-shell .bw-ce-structured-grid {
  gap: 18px;
  margin-top: 4px;
}

#bw-confirmed-entities-shell .bw-ce-section,
#bw-confirmed-entities-shell .bw-ce-structured-section,
#bw-confirmed-entities-shell .bw-ce-structured-section-v2 {
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.95);
  padding: 14px;
}

#bw-confirmed-entities-shell .bw-ce-section-head {
  margin-bottom: 8px;
}

#bw-confirmed-entities-shell .bw-ce-section-title {
  font-size: 13px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.95);
}

#bw-confirmed-entities-shell .bw-ce-subblock {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

#bw-confirmed-entities-shell .bw-ce-subtitle {
  font-size: 12px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.82);
}

#bw-confirmed-entities-shell .bw-ce-add-row,
#bw-confirmed-entities-shell .bw-ce-form-grid {
  width: 100%;
  box-sizing: border-box;
}

#bw-confirmed-entities-shell .bw-ce-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

#bw-confirmed-entities-shell .bw-ce-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#bw-confirmed-entities-shell .bw-ce-input,
#bw-confirmed-entities-shell .bw-ce-input-strong,
#bw-confirmed-entities-shell .bw-confirmed-entities-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 10px;
  background: #ffffff;
  color: rgba(15, 23, 42, 0.95);
  font: inherit;
  line-height: 1.35;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

#bw-confirmed-entities-shell .bw-ce-input::placeholder,
#bw-confirmed-entities-shell .bw-ce-input-strong::placeholder,
#bw-confirmed-entities-shell .bw-confirmed-entities-textarea::placeholder {
  color: rgba(15, 23, 42, 0.42);
}

#bw-confirmed-entities-shell .bw-ce-input:focus,
#bw-confirmed-entities-shell .bw-ce-input-strong:focus,
#bw-confirmed-entities-shell .bw-confirmed-entities-textarea:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

#bw-confirmed-entities-shell .bw-ce-input-span-2 {
  grid-column: span 2;
}

#bw-confirmed-entities-shell .bw-ce-structured-actions,
#bw-confirmed-entities-shell .bw-confirmed-entities-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#bw-confirmed-entities-shell .bw-ce-structured-actions {
  margin-top: 2px;
}

#bw-confirmed-entities-shell .bw-confirmed-entities-actions-bar {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

#bw-confirmed-entities-shell .bw-ce-add-btn,
#bw-confirmed-entities-shell .bw-ce-action-btn,
#bw-confirmed-entities-shell .bw-confirmed-entities-btn,
#bw-confirmed-entities-shell .bw-ce-save-btn {
  appearance: none;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.10), rgba(37, 99, 235, 0.06));
  color: rgba(15, 23, 42, 0.96);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 9px 12px;
  min-height: 38px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

#bw-confirmed-entities-shell .bw-ce-save-btn {
  padding-left: 14px;
  padding-right: 14px;
}

#bw-confirmed-entities-shell .bw-ce-add-btn:hover,
#bw-confirmed-entities-shell .bw-ce-action-btn:hover,
#bw-confirmed-entities-shell .bw-confirmed-entities-btn:hover,
#bw-confirmed-entities-shell .bw-ce-save-btn:hover {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.14), rgba(37, 99, 235, 0.09));
}

#bw-confirmed-entities-shell .bw-ce-add-btn:disabled,
#bw-confirmed-entities-shell .bw-ce-action-btn:disabled,
#bw-confirmed-entities-shell .bw-confirmed-entities-btn:disabled,
#bw-confirmed-entities-shell .bw-ce-save-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

#bw-confirmed-entities-shell .bw-confirmed-entities-note {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.72);
}

#bw-confirmed-entities-shell .bw-ce-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

#bw-confirmed-entities-shell .bw-ce-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(248, 250, 252, 1);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

#bw-confirmed-entities-shell .bw-ce-chip-text {
  font-size: 12px;
  line-height: 1.2;
  color: rgba(15, 23, 42, 0.92);
  word-break: break-word;
}

#bw-confirmed-entities-shell .bw-ce-chip-remove {
  border: none;
  background: transparent;
  color: rgba(15, 23, 42, 0.68);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

#bw-confirmed-entities-shell .bw-ce-empty {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.55);
}

#bw-confirmed-entities-shell .bw-ce-record-list {
  display: grid;
  gap: 10px;
}

#bw-confirmed-entities-shell .bw-ce-record-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

#bw-confirmed-entities-shell .bw-ce-record-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#bw-confirmed-entities-shell .bw-ce-record-top strong {
  font-size: 13px;
  color: rgba(15, 23, 42, 0.96);
}

#bw-confirmed-entities-shell .bw-ce-record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.9);
}

#bw-confirmed-entities-shell .bw-ce-record-grid strong {
  color: rgba(15, 23, 42, 0.95);
}

@media (max-width: 1200px) {
  #bw-confirmed-entities-shell .bw-ce-grid,
  #bw-confirmed-entities-shell .bw-ce-grid-simple,
  #bw-confirmed-entities-shell .bw-ce-structured-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  #bw-confirmed-entities-shell .bw-ce-form-grid,
  #bw-confirmed-entities-shell .bw-ce-record-grid {
    grid-template-columns: 1fr;
  }

  #bw-confirmed-entities-shell .bw-ce-input-span-2 {
    grid-column: span 1;
  }
}


/* ===== CONFIRMED ENTITIES: SUGGESTED BY AI ===== */

#bw-confirmed-entities-shell .bw-ce-suggested-section {
  margin-top: 18px;
  padding: 14px 18px 16px;
  border-top: 1px dashed rgba(15, 23, 42, 0.18);
  background: rgba(15, 23, 42, 0.025);
  border-radius: 0 0 10px 10px;
}

#bw-confirmed-entities-shell .bw-ce-sugg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

#bw-confirmed-entities-shell .bw-ce-sugg-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(15, 23, 42, 0.45);
}

#bw-confirmed-entities-shell .bw-ce-sugg-badge {
  font-size: 10px;
  color: rgba(15, 23, 42, 0.4);
  background: rgba(15, 23, 42, 0.05);
  border: 1px dashed rgba(15, 23, 42, 0.18);
  border-radius: 4px;
  padding: 2px 7px;
}

#bw-confirmed-entities-shell .bw-ce-sugg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

#bw-confirmed-entities-shell .bw-ce-sugg-col-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(15, 23, 42, 0.38);
  margin-bottom: 5px;
}

#bw-confirmed-entities-shell .bw-ce-sugg-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#bw-confirmed-entities-shell .bw-ce-sugg-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px dashed rgba(15, 23, 42, 0.16);
  border-radius: 5px;
}

#bw-confirmed-entities-shell .bw-ce-sugg-chip-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.6);
}

#bw-confirmed-entities-shell .bw-ce-sugg-promote-btn {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.5);
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}

#bw-confirmed-entities-shell .bw-ce-sugg-promote-btn:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.12);
  color: rgba(15, 23, 42, 0.8);
}

#bw-confirmed-entities-shell .bw-ce-sugg-promote-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

@media (max-width: 900px) {
  #bw-confirmed-entities-shell .bw-ce-sugg-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  #bw-confirmed-entities-shell .bw-ce-sugg-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== CONTROLLED REBUILD PHASE 2: LEAD BOARD ===== */

#bw-lead-board-shell {
  margin: 14px 0 18px 0;
}

#bw-lead-board-shell .bw-lead-board-card,
#bw-lead-board-shell .bw-lead-board-card-phase2 {
  width: 100%;
  box-sizing: border-box;
  padding: 18px 18px 16px 18px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

#bw-lead-board-shell .bw-lead-board-head {
  margin-bottom: 10px;
}

#bw-lead-board-shell .bw-lead-board-sub {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.68);
}

#bw-lead-board-shell .bw-lead-board-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.035);
  font-size: 12px;
  color: rgba(15, 23, 42, 0.86);
}

#bw-lead-board-shell .bw-lead-board-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}

#bw-lead-board-shell .bw-lead-column {
  min-width: 0;
}

#bw-lead-board-shell .bw-lead-column-head {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
  color: rgba(15, 23, 42, 0.96);
}

#bw-lead-board-shell .bw-lead-board-empty {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.55);
  padding: 10px 0;
}

#bw-lead-board-shell .bw-lead-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  margin-bottom: 12px;
}

#bw-lead-board-shell .bw-lead-card--high {
  border-color: rgba(220, 38, 38, 0.28);
}

#bw-lead-board-shell .bw-lead-card--medium {
  border-color: rgba(217, 119, 6, 0.26);
}

#bw-lead-board-shell .bw-lead-card--low {
  border-color: rgba(37, 99, 235, 0.22);
}

#bw-lead-board-shell .bw-lead-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

#bw-lead-board-shell .bw-lead-card-value {
  font-size: 13px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.96);
  word-break: break-word;
}

#bw-lead-board-shell .bw-lead-card-score {
  font-size: 11px;
  color: rgba(15, 23, 42, 0.62);
  white-space: nowrap;
}

#bw-lead-board-shell .bw-lead-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#bw-lead-board-shell .bw-lead-card-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(248, 250, 252, 1);
  font-size: 10px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.76);
}

#bw-lead-board-shell .bw-lead-card-section {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.90);
}

#bw-lead-board-shell .bw-lead-card-section strong {
  color: rgba(15, 23, 42, 0.96);
}

#bw-lead-board-shell .bw-lead-structured-block {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

#bw-lead-board-shell .bw-lead-detail-row {
  display: grid;
  gap: 2px;
}

#bw-lead-board-shell .bw-lead-detail-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.62);
}

#bw-lead-board-shell .bw-lead-detail-value {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.92);
  word-break: break-word;
}

#bw-lead-board-shell .bw-lead-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#bw-lead-board-shell .bw-lead-promote-btn,
#bw-lead-board-shell .bw-lead-unconfirm-btn {
  appearance: none;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.10), rgba(37, 99, 235, 0.06));
  color: rgba(15, 23, 42, 0.96);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
  min-height: 34px;
  cursor: pointer;
}

#bw-lead-board-shell .bw-lead-promote-btn:hover,
#bw-lead-board-shell .bw-lead-unconfirm-btn:hover {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.14), rgba(37, 99, 235, 0.09));
}

#bw-lead-board-shell .bw-lead-promote-btn:disabled,
#bw-lead-board-shell .bw-lead-unconfirm-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

@media (max-width: 1200px) {
  #bw-lead-board-shell .bw-lead-board-columns {
    grid-template-columns: 1fr;
  }
}


/* ===== CONTROLLED REBUILD PHASE 2: LEAD BOARD ===== */

#bw-lead-board-shell {
  margin: 14px 0 18px 0;
}

#bw-lead-board-shell .bw-lead-board-card,
#bw-lead-board-shell .bw-lead-board-card-phase2 {
  width: 100%;
  box-sizing: border-box;
  padding: 18px 18px 16px 18px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

#bw-lead-board-shell .bw-lead-board-head {
  margin-bottom: 10px;
}

#bw-lead-board-shell .bw-lead-board-sub {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.68);
}

#bw-lead-board-shell .bw-lead-board-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.035);
  font-size: 12px;
  color: rgba(15, 23, 42, 0.86);
}

#bw-lead-board-shell .bw-lead-board-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}

#bw-lead-board-shell .bw-lead-column {
  min-width: 0;
}

#bw-lead-board-shell .bw-lead-column-head {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
  color: rgba(15, 23, 42, 0.96);
}

#bw-lead-board-shell .bw-lead-board-empty {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.55);
  padding: 10px 0;
}

#bw-lead-board-shell .bw-lead-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  margin-bottom: 12px;
}

#bw-lead-board-shell .bw-lead-card--high {
  border-color: rgba(220, 38, 38, 0.28);
}

#bw-lead-board-shell .bw-lead-card--medium {
  border-color: rgba(217, 119, 6, 0.26);
}

#bw-lead-board-shell .bw-lead-card--low {
  border-color: rgba(37, 99, 235, 0.22);
}

#bw-lead-board-shell .bw-lead-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

#bw-lead-board-shell .bw-lead-card-value {
  font-size: 13px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.96);
  word-break: break-word;
}

#bw-lead-board-shell .bw-lead-card-score {
  font-size: 11px;
  color: rgba(15, 23, 42, 0.62);
  white-space: nowrap;
}

#bw-lead-board-shell .bw-lead-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#bw-lead-board-shell .bw-lead-card-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(248, 250, 252, 1);
  font-size: 10px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.76);
}

#bw-lead-board-shell .bw-lead-card-section {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.90);
}

#bw-lead-board-shell .bw-lead-card-section strong {
  color: rgba(15, 23, 42, 0.96);
}

#bw-lead-board-shell .bw-lead-structured-block {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

#bw-lead-board-shell .bw-lead-detail-row {
  display: grid;
  gap: 2px;
}

#bw-lead-board-shell .bw-lead-detail-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.62);
}

#bw-lead-board-shell .bw-lead-detail-value {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.92);
  word-break: break-word;
}

#bw-lead-board-shell .bw-lead-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#bw-lead-board-shell .bw-lead-promote-btn,
#bw-lead-board-shell .bw-lead-unconfirm-btn {
  appearance: none;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.10), rgba(37, 99, 235, 0.06));
  color: rgba(15, 23, 42, 0.96);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
  min-height: 34px;
  cursor: pointer;
}

#bw-lead-board-shell .bw-lead-promote-btn:hover,
#bw-lead-board-shell .bw-lead-unconfirm-btn:hover {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.14), rgba(37, 99, 235, 0.09));
}

#bw-lead-board-shell .bw-lead-promote-btn:disabled,
#bw-lead-board-shell .bw-lead-unconfirm-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

@media (max-width: 1200px) {
  #bw-lead-board-shell .bw-lead-board-columns {
    grid-template-columns: 1fr;
  }
}


/* ===== CONTROLLED REBUILD PHASE 2A: LEAD DEBUG STRIP ===== */

#bw-lead-debug-shell {
  margin: 14px 0 18px 0;
}

#bw-lead-debug-shell .bw-lead-debug-card {
  width: 100%;
  box-sizing: border-box;
  padding: 16px 18px 14px 18px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

#bw-lead-debug-shell .bw-lead-debug-head {
  margin-bottom: 10px;
}

#bw-lead-debug-shell .bw-lead-debug-sub {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.68);
}

#bw-lead-debug-shell .bw-lead-debug-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.035);
  font-size: 12px;
  color: rgba(15, 23, 42, 0.86);
}


/* ===== CONTROLLED REBUILD PHASE 2B: RAW PAYLOAD INSPECTOR ===== */

#bw-lead-debug-shell .bw-lead-debug-raw {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.045);
  border: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
  color: rgba(15, 23, 42, 0.88);
}


/* ===== CONTROLLED REBUILD PHASE 2C: SPACING CLEANUP ===== */

#bw-lead-debug-shell {
  margin: 10px 0 12px 0;
}

#bw-lead-debug-shell .bw-lead-debug-card {
  padding: 14px 16px 12px 16px;
}

#bw-lead-debug-shell .bw-lead-debug-head {
  margin-bottom: 8px;
}

#bw-lead-debug-shell .bw-lead-debug-meta {
  gap: 6px 12px;
  margin-bottom: 10px;
}

#bw-lead-debug-shell .bw-lead-debug-raw {
  margin-top: 8px;
  max-height: 240px;
}

#bw-confirmed-entities-shell {
  margin-top: 10px;
}

/* ─── Chat Pane Layout ───────────────────────────────────────────── */
#pane-chat.active {
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.bw-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.bw-chat-input-area {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.bw-chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

/* Sidebar case list: keep health dot visible outside the truncating name */
.case-item-row {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}
.case-item-row .case-item-name {
  flex: 1;
  min-width: 0;
}
.case-item-row .bw-health-dot {
  flex-shrink: 0;
  margin-left: 6px;
}

/* ── Chat UI polish ───────────────────────────────────────────────── */

/* Starter questions — vertical stack */
.bw-chat-starters { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bw-chat-starters-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bw-chat-starter {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.bw-chat-starter:hover { background: var(--sidebar-hover); border-color: var(--accent); }

/* Message layout with avatar */
.bw-chat-msg { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-start; }
.bw-chat-msg.user { flex-direction: row-reverse; }
.bw-chat-body { flex: 1; min-width: 0; }

/* BW avatar */
.bw-chat-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

/* Chat bubbles */
.bw-chat-bubble {
  display: inline-block;
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.bw-chat-msg.user .bw-chat-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
  margin-left: auto;
}
.bw-chat-msg.assistant .bw-chat-bubble {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Timestamp and save button */
.bw-chat-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 0 2px; }
.bw-chat-msg.user .bw-chat-meta { justify-content: flex-end; }
.bw-chat-ts { font-size: 10px; color: var(--muted); }
.bw-chat-save-btn {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim, var(--muted));
  cursor: pointer;
}
.bw-chat-save-btn:hover { background: var(--sidebar-hover); }

/* Thinking / streaming indicator */
.bw-chat-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
}
.bw-chat-dots { display: inline-flex; gap: 4px; }
.bw-chat-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: bwDotPulse 1.2s infinite ease-in-out;
}
.bw-chat-dots span:nth-child(2) { animation-delay: 0.2s; }
.bw-chat-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bwDotPulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Vision analysis buttons + result panels ───────────────────── */
.file-item-wrap { display: flex; flex-direction: column; }
.file-item { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.bw-analyze-btn {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
.bw-analyze-btn:hover { background: var(--accent); color: #fff; }
.bw-analyze-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.bw-vision-result {
  margin: 4px 0 8px 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  overflow: hidden;
}
.bw-vision-result.hidden { display: none; }
.bw-vision-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  font-size: 12px;
}
.bw-vision-label { font-weight: 600; color: var(--accent); }
.bw-vision-saved { color: var(--muted); font-size: 11px; flex: 1; }
.bw-vision-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
}
.bw-vision-close:hover { color: var(--text); }
.bw-vision-body { padding: 12px; font-size: 13px; max-height: 400px; overflow-y: auto; }
.bw-vision-loading { padding: 12px; color: var(--muted); font-style: italic; font-size: 13px; }
.bw-vision-error { padding: 12px; color: #ef4444; font-size: 13px; }

/* ── Warrant modal ────────────────────────────────────────────────── */
.bw-warrant-form-modal { max-width: 540px; background: #ffffff !important; color: #1f2937 !important; }
.bw-warrant-form-modal h3 { color: #1f2937; }
.bw-warrant-form-modal .bw-warrant-disclaimer { margin-bottom: 0; }
#modal-warrant .wizard-field { color: #1f2937; }
#modal-warrant .wizard-field input,
#modal-warrant .wizard-field select,
#modal-warrant .wizard-field textarea {
  background-color: #f8fafc; color: #1f2937; border: 1px solid #d1d5db;
}
#modal-warrant .wizard-field input::placeholder,
#modal-warrant .wizard-field textarea::placeholder { color: #9ca3af; }
#modal-warrant .wizard-field input:focus,
#modal-warrant .wizard-field select:focus,
#modal-warrant .wizard-field textarea:focus { border-color: #6366f1; outline: none; }

/* Smart warrant target inputs */
.warrant-target-section { display: flex; flex-direction: column; gap: 8px; }
.warrant-target-label { font-size: 13px; font-weight: 600; color: #374151; }
.warrant-items-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.warrant-person-select {
  background-color: #f8fafc; color: #1f2937; border: 1px solid #d1d5db;
  border-radius: 4px; padding: 7px 10px; font-size: 13px; width: 100%;
}
.warrant-person-select:focus { border-color: #6366f1; outline: none; }
.warrant-divider-text {
  font-size: 11px; color: #9ca3af; text-align: center;
  border-top: 1px solid #e5e7eb; padding-top: 8px; margin-top: 2px;
}
.warrant-identifier-row {
  display: flex; gap: 8px;
}
.warrant-identifier-row input {
  flex: 1; background-color: #f8fafc; color: #1f2937;
  border: 1px solid #d1d5db; border-radius: 4px;
  padding: 7px 10px; font-size: 13px;
}
.warrant-identifier-row input.warrant-id-wide { flex: 1 1 100%; }
.warrant-identifier-row input:focus { border-color: #6366f1; outline: none; }
.warrant-identifier-row input::placeholder { color: #9ca3af; }
.warrant-identifier-row.hidden { display: none; }
.warrant-lookup-banner {
  border-radius: 4px; padding: 8px 12px; font-size: 12px; font-weight: 600;
}
.warrant-lookup-banner.hidden { display: none; }
.warrant-lookup-banner--found {
  background: #f0fdf4; border: 1px solid #86efac; color: #166534;
}
.warrant-lookup-banner--notfound {
  background: #fefce8; border: 1px solid #fde047; color: #854d0e;
}
.warrant-source-row { display: flex; flex-direction: column; gap: 4px; }
.warrant-source-row.hidden { display: none; }
.warrant-source-label { font-size: 12px; font-weight: 600; color: #374151; }
.warrant-source-row input {
  background-color: #fefce8; color: #1f2937; border: 1px solid #fde047;
  border-radius: 4px; padding: 7px 10px; font-size: 13px;
}
.warrant-source-row input:focus { border-color: #ca8a04; outline: none; }
.warrant-source-row input::placeholder { color: #a16207; }
.warrant-autogen-row { display: flex; gap: 8px; align-items: flex-start; }
.warrant-autogen-row textarea { flex: 1; }
.warrant-autogen-btn {
  flex-shrink: 0; background: #ede9fe; color: #5b21b6;
  border: 1px solid #c4b5fd; border-radius: 6px;
  padding: 7px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap; align-self: flex-start; margin-top: 0;
}
.warrant-autogen-btn:hover { background: #ddd6fe; }
.warrant-autogen-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.bw-warrant-saved-label {
  font-size: 12px; color: #10b981; font-weight: 600; align-self: center;
}
.bw-warrant-saved-label.hidden { display: none; }
.bw-warrant-no-profile-warn {
  background: #fef2f2; border: 1px solid #fca5a5; border-radius: 4px;
  padding: 8px 12px; font-size: 12px; font-weight: 600; color: #991b1b;
  margin-bottom: 8px;
}
.bw-warrant-no-profile-warn a { color: #7c3aed; }
.bw-warrant-profile-badge {
  background: #f0fdf4; border: 1px solid #86efac; border-radius: 4px;
  padding: 6px 12px; font-size: 12px; color: #166534; font-weight: 600;
  margin-bottom: 8px;
}
.bw-warrant-t3-warn {
  background: #1a0a0a; border: 2px solid #dc2626; border-radius: 4px;
  padding: 10px 14px; font-size: 12px; color: #fca5a5;
  margin-bottom: 10px; line-height: 1.6;
}
.bw-warrant-t3-warn strong { color: #ef4444; }
.bw-warrant-disclaimer {
  background: #fff3cd; border: 1px solid #f59e0b; border-radius: 4px;
  padding: 8px 12px; font-size: 11px; font-weight: 600; color: #92400e;
  margin-bottom: 12px;
}

/* ── Warrant full-screen review panel ────────────────────────────── */
.bw-warrant-panel {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--bg); display: flex; flex-direction: column;
}
.bw-warrant-panel.hidden { display: none; }

.bw-warrant-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg); flex-shrink: 0;
}
.bw-warrant-panel-title { display: flex; align-items: center; gap: 10px; }
.bw-warrant-panel-title span:first-child { font-size: 16px; font-weight: 700; }
.bw-warrant-ai-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  background: #f59e0b; color: #000; padding: 2px 6px; border-radius: 3px;
}
.bw-warrant-panel-actions { display: flex; gap: 8px; }

.bw-warrant-disclaimer-banner {
  background: #7f1d1d; color: #fca5a5;
  font-size: 12px; font-weight: 700; text-align: center;
  padding: 8px; flex-shrink: 0; letter-spacing: 0.03em;
}

.bw-warrant-panel-body {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}

.bw-warrant-draft-col {
  flex: 1; min-width: 0; overflow-y: auto; padding: 24px 32px;
  border-right: 1px solid var(--border);
}
.bw-warrant-pre {
  font-family: "Courier New", Courier, monospace;
  font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; color: var(--text);
  background: none; border: none; padding: 0; margin: 0;
}
.bw-warrant-redflag {
  display: block; background: rgba(239, 68, 68, 0.12);
  border-left: 3px solid #ef4444; padding-left: 8px;
  color: #ef4444; font-weight: 600;
}
.bw-warrant-disclaimer-line {
  display: block; background: rgba(245, 158, 11, 0.15);
  border-left: 3px solid #f59e0b; padding-left: 8px;
  color: #d97706; font-weight: 700;
}
.bw-warrant-loading {
  padding: 20px; color: var(--muted); font-style: italic; font-size: 13px;
}

/* ── Suppression risk sidebar ─────────────────────────────────────── */
.bw-warrant-sidebar-col {
  width: 320px; flex-shrink: 0; overflow-y: auto;
  padding: 16px; background: var(--sidebar-bg);
}
.bw-warrant-sidebar-card { display: flex; flex-direction: column; gap: 12px; }
.bw-warrant-sidebar-title {
  font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

.bw-risk-overall {
  font-size: 13px; font-weight: 700; padding: 8px 12px;
  border-radius: 6px; text-align: center; margin-bottom: 8px;
}
.bw-risk-overall--low { background: rgba(16, 185, 129, 0.15); color: #059669; }
.bw-risk-overall--medium { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.bw-risk-overall--high { background: rgba(249, 115, 22, 0.15); color: #ea580c; }
.bw-risk-overall--critical { background: rgba(239, 68, 68, 0.15); color: #dc2626; }

.bw-risk-scores { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.bw-risk-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.bw-risk-label { color: var(--text); font-weight: 600; }
.bw-risk-score {
  font-size: 12px; font-weight: 700; padding: 2px 7px;
  border-radius: 4px; min-width: 36px; text-align: center;
}
.bw-risk-strong { background: rgba(16, 185, 129, 0.2); color: #059669; }
.bw-risk-medium { background: rgba(245, 158, 11, 0.2); color: #d97706; }
.bw-risk-critical { background: rgba(239, 68, 68, 0.2); color: #dc2626; }
.bw-risk-note { font-size: 11px; color: var(--muted); padding: 0 2px 6px; line-height: 1.5; }

.bw-risk-section { margin-top: 8px; }
.bw-risk-section-title { font-size: 11px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.bw-risk-list { margin: 0; padding-left: 16px; font-size: 11.5px; color: var(--text); line-height: 1.6; }
.bw-risk-list li { margin-bottom: 3px; }
.bw-risk-list--muted li { color: var(--muted); }

/* ── Drop-folder ingestion banner ────────────────────────────────── */
.bw-ingestion-banner {
  position: fixed; bottom: 24px; right: 24px; z-index: 12000;
  display: flex; align-items: center; gap: 12px;
  background: var(--panel-bg, #1e2030); border: 1px solid var(--accent);
  border-radius: 10px; padding: 14px 16px; max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  transform: translateY(20px); opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
}
.bw-ingestion-banner--visible { transform: translateY(0); opacity: 1; }
.bw-ingestion-icon { font-size: 22px; flex-shrink: 0; }
.bw-ingestion-msg { flex: 1; font-size: 13px; line-height: 1.45; }
.bw-ingestion-open {
  flex-shrink: 0; font-size: 12px; padding: 5px 12px;
  border: 1px solid var(--accent); border-radius: 5px;
  background: var(--accent); color: #fff; cursor: pointer; white-space: nowrap;
}
.bw-ingestion-open:hover { opacity: .85; }
.bw-ingestion-dismiss {
  flex-shrink: 0; background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 0 2px;
}
.bw-ingestion-dismiss:hover { color: var(--text); }

/* ── Drag-and-drop upload zone ───────────────────────────────────── */
.bw-dropzone {
  border: 2px dashed var(--border, #3a3f55);
  border-radius: 10px;
  padding: 0;
  transition: border-color .2s, background .2s;
  background: transparent;
}
.bw-dropzone--active {
  border-color: var(--accent);
  background: rgba(99,102,241,.07);
}
.bw-dropzone-inner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 20px; gap: 6px; text-align: center; pointer-events: none;
}
.bw-dropzone-inner > button { pointer-events: auto; }
.bw-dropzone-icon { font-size: 32px; line-height: 1; }
.bw-dropzone-label { font-size: 14px; font-weight: 600; color: var(--text); }
.bw-dropzone-sub { font-size: 11.5px; color: var(--muted); }

/* Upload progress list */
.bw-upload-progress { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.bw-upload-row {
  display: grid;
  grid-template-columns: 1fr auto 120px auto;
  align-items: center; gap: 8px;
  font-size: 12px;
}
.bw-upload-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bw-upload-size { color: var(--muted); white-space: nowrap; }
.bw-upload-bar-wrap { background: var(--border); border-radius: 4px; height: 5px; overflow: hidden; }
.bw-upload-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width .15s ease; }
.bw-upload-bar--done { background: #22c55e; }
.bw-upload-status { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bw-upload-status--ok { color: #22c55e; font-weight: 700; }
.bw-upload-status--err { color: var(--warning, #f97316); }
.bw-upload-summary {
  font-size: 12px; font-weight: 600; color: var(--accent);
  text-align: center; padding: 4px 0 2px;
  border-top: 1px solid var(--border); margin-top: 2px;
}

/* ── New-case wizard modal ───────────────────────────────────────── */
.wizard-modal { max-width: 520px; width: 100%; }
.wizard-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px;
  margin: 16px 0;
}
.wizard-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
.wizard-field--full { grid-column: 1 / -1; }
.wizard-field input,
.wizard-field select,
.wizard-field textarea {
  font-size: 13px; font-weight: 400; color: var(--text);
  background: var(--input-bg, #0f1117); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; width: 100%; box-sizing: border-box;
  text-transform: none; letter-spacing: 0;
  font-family: inherit;
}
.wizard-field textarea { resize: vertical; min-height: 72px; }
.wizard-field input:focus,
.wizard-field select:focus,
.wizard-field textarea:focus { outline: none; border-color: var(--accent); }

/* New-case modal: white background, dark text so inputs are readable */
#modal-new-case .modal-content {
  background: #ffffff;
  color: #1f2937;
}
#modal-new-case h3 { color: #1f2937; }
#modal-new-case .wizard-field { color: #1f2937; }
#modal-new-case .wizard-field input,
#modal-new-case .wizard-field select,
#modal-new-case .wizard-field textarea {
  background-color: #f8fafc;
  color: #1f2937;
  border: 1px solid #d1d5db;
}
#modal-new-case .wizard-field input::placeholder,
#modal-new-case .wizard-field textarea::placeholder { color: #9ca3af; }
#modal-new-case .wizard-field input:focus,
#modal-new-case .wizard-field select:focus,
#modal-new-case .wizard-field textarea:focus { border-color: #6366f1; outline: none; }
.wizard-error {
  font-size: 12px; color: var(--warning, #f97316);
  background: rgba(249,115,22,.08); border: 1px solid rgba(249,115,22,.3);
  border-radius: 6px; padding: 8px 12px; margin-bottom: 4px;
}

/* ── Lead Register ───────────────────────────────────────────────── */
.leads-pane-toolbar { flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
#leads-filter-bar { display: flex; gap: 4px; }
.leads-filter-btn {
  font-size: 11px; padding: 3px 10px; border-radius: 99px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.leads-filter-btn.active, .leads-filter-btn:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.leads-summary-bar {
  display: flex; gap: 16px; padding: 8px 4px; flex-wrap: wrap;
  font-size: 12px; margin-top: 4px;
}
.leads-stat { color: var(--muted); }
.leads-stat strong { color: var(--text); }
.leads-stat-open strong { color: #3b82f6; }
.leads-stat-inprog strong { color: #f59e0b; }
.leads-stat-done strong { color: #10b981; }
.leads-stat-overdue strong { color: #ef4444; }

.leads-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.leads-table th {
  text-align: left; padding: 7px 10px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.leads-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.lead-row { cursor: pointer; transition: background .1s; }
.lead-row:hover { background: rgba(255,255,255,.04); }
.lead-row-overdue td { background: rgba(239,68,68,.06); }
.lead-desc-cell { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-type-cell { text-transform: capitalize; color: var(--muted); font-size: 11.5px; }

.lead-pri-badge, .lead-status-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.lead-pri-high { background: rgba(239,68,68,.15); color: #ef4444; }
.lead-pri-med  { background: rgba(245,158,11,.15); color: #f59e0b; }
.lead-pri-low  { background: rgba(107,114,128,.15); color: #9ca3af; }
.lead-st-open     { background: rgba(59,130,246,.15); color: #3b82f6; }
.lead-st-inprog   { background: rgba(245,158,11,.15); color: #f59e0b; }
.lead-st-done     { background: rgba(16,185,129,.15); color: #10b981; }
.lead-st-declined { background: rgba(107,114,128,.12); color: #6b7280; }

.lead-bw-badge {
  font-size: 9px; background: var(--accent); color: #fff;
  border-radius: 3px; padding: 1px 4px; margin-left: 4px;
  vertical-align: middle; font-weight: 700;
}

/* Lead detail panel */
.lead-detail-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 380px;
  background: var(--panel-bg, #1e2030);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100; box-shadow: -4px 0 24px rgba(0,0,0,.4);
}
#pane-leads { position: relative; overflow: hidden; }
#leads-content { margin-top: 8px; }
.lead-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}
.lead-detail-num { font-size: 14px; font-weight: 700; color: var(--accent); }
.lead-detail-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.lead-detail-field { display: flex; flex-direction: column; gap: 4px; }
.lead-detail-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.lead-detail-field input,
.lead-detail-field select,
.lead-detail-field textarea {
  font-size: 13px; background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: 5px; padding: 6px 8px; color: var(--text); font-family: inherit;
}
.lead-detail-field textarea { resize: vertical; }
.lead-detail-field input:focus,
.lead-detail-field select:focus,
.lead-detail-field textarea:focus { outline: none; border-color: var(--accent); }
.lead-detail-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lead-detail-desc-text { font-size: 13px; color: var(--text); line-height: 1.5; }
.lead-detail-meta { font-size: 11px; color: var(--muted); padding-top: 4px; }
.lead-detail-actions { display: flex; gap: 8px; padding-top: 4px; border-top: 1px solid var(--border); }

/* ── Morning Brief ───────────────────────────────────────────────── */
.bw-brief-banner {
  position: fixed; bottom: 60px; left: 0; right: 0;
  background: #1e2440; border-top: 2px solid #f59e0b;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; z-index: 5000; font-size: 13px;
}
.bw-brief-banner.bw-brief-critical { border-color: #ef4444; background: #2a1a1a; }
.bw-brief-view-btn {
  background: var(--accent); border: none; border-radius: 5px;
  color: #fff; font-size: 12px; font-weight: 600; padding: 4px 12px; cursor: pointer;
}
.bw-brief-dismiss {
  margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px;
}
.bw-brief-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 500px;
  background: var(--panel-bg, #1e2030); border-left: 1px solid var(--border);
  z-index: 6000; display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.5);
}
.bw-brief-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}
.bw-brief-panel-title { font-size: 15px; font-weight: 700; }
#bw-brief-panel-body { flex: 1; overflow-y: auto; padding: 16px; }
.brief-summary { font-size: 13px; color: var(--muted); margin-bottom: 16px; line-height: 1.55; }
.brief-case-group { margin-bottom: 20px; }
.brief-case-title { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.brief-alert-row { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: 6px; margin-bottom: 6px; }
.brief-sev-critical { background: rgba(239,68,68,.1); border-left: 3px solid #ef4444; }
.brief-sev-warning  { background: rgba(245,158,11,.08); border-left: 3px solid #f59e0b; }
.brief-sev-info     { background: rgba(59,130,246,.06); border-left: 3px solid #3b82f6; }
.brief-sev-badge { font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.brief-msg { font-size: 13px; color: var(--text); }
.brief-action { font-size: 11.5px; color: var(--muted); }

/* ── Brady / Giglio ──────────────────────────────────────────────── */
.bw-brady-card { background: var(--panel-bg, #1e2030); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.bw-brady-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: rgba(239,68,68,.06);
}
.bw-brady-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #ef4444; }
.bw-brady-warning {
  margin: 10px 14px; padding: 8px 12px;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  border-radius: 6px; font-size: 12.5px; color: var(--text);
}
.brady-rows { display: flex; flex-direction: column; }
.brady-row {
  display: grid; grid-template-columns: 70px 1fr 120px 120px 120px auto;
  align-items: center; gap: 8px; padding: 8px 14px;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.brady-row:last-child { border-bottom: none; }
.brady-type-badge { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 3px; text-align: center; text-transform: uppercase; }
.brady-type-brady  { background: rgba(239,68,68,.15); color: #ef4444; }
.brady-type-giglio { background: rgba(245,158,11,.15); color: #f59e0b; }
.brady-desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.brady-source, .brady-flagged-by { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brady-disc-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.brady-disc-ok  { background: rgba(16,185,129,.15); color: #10b981; }
.brady-disc-no  { background: rgba(239,68,68,.12);  color: #ef4444; }
.brady-mark-btn { font-size: 10.5px; padding: 2px 8px; white-space: nowrap; }

/* ── Link Chart Overlay ──────────────────────────────────────────── */
.link-chart-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: #0a0c12;
  display: flex; flex-direction: column;
}
.link-chart-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: #111320;
}
.link-chart-title { font-size: 15px; font-weight: 700; color: var(--text); }
.link-chart-actions { display: flex; gap: 8px; }
.link-chart-status { padding: 6px 20px; font-size: 12px; color: var(--muted); background: #0c0e14; border-bottom: 1px solid var(--border); }
.link-chart-container { flex: 1; position: relative; overflow: hidden; }
.link-chart-hint { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: var(--muted); font-size: 14px; text-align: center; }
#link-chart-svg { width: 100%; height: 100%; }
.link-chart-tooltip {
  position: absolute; background: #f8f9fa; border: 1px solid #d1d5db;
  border-radius: 6px; padding: 8px 12px; font-size: 12px; color: #1f2937;
  pointer-events: none; max-width: 240px; z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.link-chart-legend {
  display: flex; gap: 16px; padding: 10px 20px;
  background: #111320; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.lc-leg { font-size: 11px; display: flex; align-items: center; gap: 5px; color: var(--muted); }
.lc-leg::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.lc-person::before   { background: #3b82f6; }
.lc-flagged::before  { background: #ef4444; }
.lc-location::before { background: #10b981; border-radius: 2px; }
.lc-vehicle::before  { background: #f97316; transform: rotate(45deg); border-radius: 0; }
.lc-phone::before    { background: #a855f7; }
.lc-org::before      { background: #f59e0b; border-radius: 2px; }

/* ── Interview Prep Panel ────────────────────────────────────────── */
.interview-prep-panel {
  position: fixed; inset: 0; z-index: 9000;
  background: #0f1117;
  display: flex; flex-direction: column;
}
.interview-prep-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 1px solid var(--border);
  background: #111320;
}
.interview-prep-title { font-size: 16px; font-weight: 700; color: var(--text); margin-right: 10px; }
.interview-prep-ai-badge {
  font-size: 9px; font-weight: 700; background: #f59e0b; color: #000;
  border-radius: 3px; padding: 2px 6px; letter-spacing: .06em;
}
.interview-prep-actions { display: flex; gap: 8px; }
.interview-prep-disclaimer {
  padding: 8px 24px; font-size: 11.5px; font-weight: 700;
  background: rgba(239,68,68,.12); color: #ef4444;
  border-bottom: 1px solid rgba(239,68,68,.2);
}
.interview-prep-content {
  flex: 1; overflow-y: auto; padding: 24px 40px; max-width: 900px; margin: 0 auto; width: 100%;
}

/* ── Contradictions ──────────────────────────────────────────────── */
.bw-contra-card { background: var(--panel-bg,#1e2030); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.bw-contra-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); background: rgba(239,68,68,.05); }
.bw-contra-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text); }
.bw-contra-loading, .bw-contra-error { padding: 14px; font-size: 13px; color: var(--muted); }
.bw-contra-error { color: var(--warning,#f97316); }
.contra-count-row { display: flex; gap: 6px; }
.contra-count-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 3px; text-transform: uppercase; }
.contra-high { background: rgba(239,68,68,.15); color: #ef4444; }
.contra-med  { background: rgba(245,158,11,.15); color: #f59e0b; }
.contra-low  { background: rgba(107,114,128,.12); color: #9ca3af; }
.contra-rows { display: flex; flex-direction: column; }
.contra-row { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.contra-row:last-child { border-bottom: none; }
.contra-row-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.contra-sev-badge { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 3px; text-transform: uppercase; white-space: nowrap; }
.contra-sev-high { background: rgba(239,68,68,.15); color: #ef4444; }
.contra-sev-med  { background: rgba(245,158,11,.15); color: #f59e0b; }
.contra-sev-low  { background: rgba(107,114,128,.12); color: #9ca3af; }
.contra-type-badge { font-size: 9.5px; background: rgba(99,102,241,.12); color: var(--accent); border-radius: 3px; padding: 2px 7px; font-weight: 700; white-space: nowrap; }
.contra-desc { color: var(--text); flex: 1; }
.contra-sources { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
.contra-source-block { font-size: 11.5px; color: var(--muted); background: rgba(255,255,255,.03); border-radius: 4px; padding: 5px 8px; }
.contra-source-b { border-left: 2px solid #ef4444; }
.contra-src-label { font-weight: 700; color: var(--text); }
.contra-action { font-size: 11.5px; color: var(--text); margin-top: 4px; }

/* ── Elements Analysis ───────────────────────────────────────────── */
.bw-elements-card { background: var(--panel-bg,#1e2030); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.bw-elements-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bw-elements-title { font-size: 13px; font-weight: 700; color: var(--text); flex: 1; }
.bw-elements-cite { font-size: 11px; color: var(--accent); }
.bw-elements-loading, .bw-elements-error { padding: 14px; font-size: 13px; color: var(--muted); }
.elements-rec-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 5px; white-space: nowrap; }
.elements-rec-proceed       { background: rgba(16,185,129,.15); color: #10b981; }
.elements-rec-strengthen    { background: rgba(245,158,11,.15); color: #f59e0b; }
.elements-rec-insufficient  { background: rgba(239,68,68,.12);  color: #ef4444; }
.elements-assessment { font-size: 13px; color: var(--text); padding: 10px 14px; border-bottom: 1px solid var(--border); line-height: 1.5; }
.elem-rows { display: flex; flex-direction: column; }
.elem-row { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.elem-row:last-child { border-bottom: none; }
.elem-row-header { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.elem-strength-badge { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 3px; text-transform: uppercase; white-space: nowrap; }
.elem-strong   { background: rgba(16,185,129,.15); color: #10b981; }
.elem-moderate { background: rgba(245,158,11,.15); color: #f59e0b; }
.elem-weak     { background: rgba(249,115,22,.12); color: #f97316; }
.elem-missing  { background: rgba(239,68,68,.12);  color: #ef4444; }
.elem-label { font-weight: 600; color: var(--text); }
.elem-notes { font-size: 11.5px; color: var(--muted); margin: 3px 0 5px; }
.elem-evidence, .elem-gaps { font-size: 11.5px; margin-top: 4px; }
.elem-evidence ul, .elem-gaps ul { margin: 2px 0 4px 16px; }
.elem-evidence { color: var(--text); }
.elem-gaps { color: var(--warning,#f97316); }

/* ── Activity Timeline section ───────────────────────────────────── */
.activity-timeline-header {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 16px 4px 8px; border-top: 2px solid var(--border);
  margin-top: 20px;
}
.activity-row {
  display: grid; grid-template-columns: 24px 160px 120px 1fr;
  align-items: center; gap: 10px; padding: 6px 4px;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.activity-row:last-child { border-bottom: none; }
.activity-icon { text-align: center; font-size: 14px; }
.activity-date { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.activity-type-badge {
  font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 3px;
  background: rgba(99,102,241,.1); color: var(--accent); white-space: nowrap; text-align: center;
}
.activity-desc { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== TASK 1: Geographic Case Map ===== */
.case-map-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 1200;
  display: flex; flex-direction: column;
}
.case-map-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.case-map-title { font-size: 15px; font-weight: 700; }
.case-map-loc-count { font-size: 12px; color: var(--muted); margin-left: 10px; }
.case-map-actions { display: flex; gap: 8px; }
.case-map-body { flex: 1; display: flex; min-height: 0; }
.case-map-leaflet { flex: 1; min-height: 0; }
.case-map-list {
  width: 280px; overflow-y: auto; border-left: 1px solid var(--border);
  background: var(--panel); padding: 12px;
}
.case-map-loc-item {
  padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.case-map-loc-item:last-child { border-bottom: none; }
.case-map-loc-item:hover { color: var(--accent); }
.case-map-loc-name { font-size: 13px; font-weight: 600; }
.case-map-loc-type { font-size: 11px; color: var(--muted); }
.case-map-loc-desc { font-size: 12px; color: var(--text-secondary, var(--muted)); margin-top: 2px; }

/* ===== TASK 2: Sergeant Review ===== */
.sergeant-review-panel {
  position: fixed; top: 0; right: 0; width: 520px; height: 100vh;
  background: var(--panel); border-left: 1px solid var(--border);
  z-index: 1100; display: flex; flex-direction: column; overflow: hidden;
}
.sergeant-review-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sergeant-review-title { font-size: 15px; font-weight: 700; }
.sergeant-review-badge {
  display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: .07em;
  padding: 2px 7px; border-radius: 3px; background: rgba(245,158,11,.15); color: var(--warning, #f59e0b);
  margin-left: 8px;
}
.sergeant-review-disclaimer {
  background: rgba(239,68,68,.08); border-bottom: 1px solid rgba(239,68,68,.2);
  padding: 8px 18px; font-size: 12px; color: var(--red, #ef4444); flex-shrink: 0;
}
.sergeant-review-content { flex: 1; overflow-y: auto; padding: 16px 18px; }
.sergeant-score-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  padding: 14px; background: var(--bg); border-radius: 8px; border: 1px solid var(--border);
}
.sergeant-score-number { font-size: 36px; font-weight: 800; line-height: 1; }
.sergeant-score-label { font-size: 12px; color: var(--muted); }
.sergeant-section { margin-bottom: 14px; }
.sergeant-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: 6px;
}
.sergeant-flag { display: flex; gap: 8px; padding: 7px 10px; border-radius: 5px; margin-bottom: 5px; font-size: 13px; }
.sergeant-flag--legal { background: rgba(239,68,68,.08); border-left: 3px solid var(--red, #ef4444); }
.sergeant-flag--missing { background: rgba(245,158,11,.08); border-left: 3px solid var(--warning, #f59e0b); }
.sergeant-flag--commend { background: rgba(16,185,129,.08); border-left: 3px solid var(--green, #10b981); }

/* ===== TASK 3: Persons tab ===== */
.persons-pane-toolbar { flex-wrap: wrap; gap: 6px; }
.person-cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; padding: 14px;
}
.person-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px;
  padding: 14px; cursor: pointer; transition: border-color .15s;
}
.person-card:hover { border-color: var(--accent); }
.person-card-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.person-card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.person-role-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 99px; text-transform: uppercase;
}
.person-role-badge--witness  { background: rgba(99,102,241,.15); color: var(--accent); }
.person-role-badge--suspect  { background: rgba(239,68,68,.12); color: var(--red, #ef4444); }
.person-role-badge--victim   { background: rgba(245,158,11,.12); color: var(--warning, #f59e0b); }
.person-role-badge--poi      { background: rgba(139,92,246,.15); color: #8b5cf6; }
.person-role-badge--officer  { background: rgba(16,185,129,.12); color: var(--green, #10b981); }
.person-role-badge--other    { background: rgba(148,163,184,.1); color: var(--muted); }
.person-interview-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
}
.person-interview-badge--interviewed   { background: rgba(16,185,129,.12); color: var(--green, #10b981); }
.person-interview-badge--not_interviewed { background: rgba(245,158,11,.12); color: var(--warning, #f59e0b); }
.person-interview-badge--scheduled     { background: rgba(99,102,241,.12); color: var(--accent); }
.person-interview-badge--refused       { background: rgba(239,68,68,.12); color: var(--red, #ef4444); }
.person-card-notes { font-size: 12px; color: var(--muted); line-height: 1.4; }
.person-card-physical {
  font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.5;
}
.person-card-footer {
  display: flex; justify-content: flex-end; margin-top: 8px;
}
.person-card-edit-btn {
  font-size: 11px; padding: 2px 10px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  transition: color .15s, border-color .15s;
}
.person-card-edit-btn:hover { color: var(--accent); border-color: var(--accent); }
.person-flagged-banner {
  font-size: 10px; font-weight: 700; color: var(--red, #ef4444);
  letter-spacing: .04em; margin-bottom: 4px;
}

/* Person profile modal */
.person-profile-modal {
  max-width: 720px; width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.person-profile-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.person-profile-title-row { display: flex; align-items: center; gap: 10px; }
.person-profile-title-row h3 { margin: 0; font-size: 16px; }
.person-flagged-badge {
  font-size: 10px; font-weight: 700; color: #fff; background: var(--red, #ef4444);
  padding: 2px 8px; border-radius: 99px; letter-spacing: .04em;
}
.person-profile-body {
  flex: 1; overflow-y: auto; padding: 16px 20px;
}
.person-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 8px; border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.person-section-label:first-child { margin-top: 0; }
.person-profile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px;
}
.person-field {
  display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted);
}
.person-field input, .person-field select, .person-field textarea {
  font-size: 13px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s;
}
.person-field input:focus, .person-field select:focus, .person-field textarea:focus {
  border-color: var(--accent);
}
.person-field--wide { grid-column: span 2; }
.person-field--full { grid-column: 1 / -1; }
.person-field--narrow { grid-column: span 1; min-width: 80px; }
.person-field .req { color: var(--warning, #f59e0b); }
.person-inv-notes-area { margin-top: 4px; }
.person-inv-notes-list { margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.person-inv-note {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 12px;
}
.person-inv-note-meta {
  font-size: 10px; color: var(--muted); margin-bottom: 3px;
}
.person-inv-note-text { line-height: 1.5; color: var(--text); }
.person-inv-note-add { display: flex; flex-direction: column; }
.person-profile-footer {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ===== TASK 4: Quick Notes ===== */
.quick-note-fab {
  position: fixed; bottom: 28px; right: 28px; width: 52px; height: 52px;
  border-radius: 50%; border: none; font-size: 22px; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.4);
  z-index: 1050; transition: transform .15s, box-shadow .15s; display: none;
  align-items: center; justify-content: center;
}
.quick-note-fab:hover { transform: scale(1.08); box-shadow: 0 6px 18px rgba(0,0,0,.5); }
.quick-note-popup {
  position: fixed; bottom: 90px; right: 28px; width: 320px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; z-index: 1000; box-shadow: 0 8px 28px rgba(0,0,0,.5);
}
.quick-note-popup-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-size: 13px; font-weight: 700;
}
.quick-note-close-btn {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px;
}
.quick-notes-list { padding: 0 14px 14px; }
.quick-note-item {
  padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border);
  margin-bottom: 8px; font-size: 12.5px; line-height: 1.5;
}
.quick-note-item-date { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

/* ===== TASK 5: Health dot tooltip ===== */
.health-dot-wrap { position: relative; display: inline-flex; }
.health-dot-tooltip {
  display: none; position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px;
  padding: 10px 12px; min-width: 220px; z-index: 500; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  pointer-events: none; white-space: nowrap;
}
.health-dot-wrap:hover .health-dot-tooltip { display: block; }
.health-tooltip-row { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; padding: 2px 0; }
.health-tooltip-label { color: var(--muted); }
.health-tooltip-value { font-weight: 600; }

/* ===== TASK 6: Enhanced search dropdown ===== */
#sidebar-search-results.grouped-results { padding: 6px 0; }
.search-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 6px 12px 3px;
}
.search-group-item {
  padding: 7px 12px; cursor: pointer; border-radius: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.search-group-item:hover { background: var(--hover-bg, rgba(255,255,255,.04)); }
.search-result-caseid { font-size: 10px; color: var(--accent); font-weight: 600; }
.search-result-label { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.search-result-snippet { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.tab-badge {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 9px; font-weight: 700; border-radius: 99px; padding: 1px 5px; margin-left: 4px;
}

/* ===== Charging Suggestions Panel ===== */
.charging-panel {
  position: fixed; inset: 0; background: var(--bg); z-index: 1300;
  display: flex; flex-direction: column; overflow: hidden;
}
.charging-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  flex-shrink: 0; flex-wrap: wrap; gap: 8px;
}
.charging-panel-title-group { display: flex; align-items: center; gap: 10px; }
.charging-panel-title { font-size: 16px; font-weight: 800; }
.charging-ai-badge {
  font-size: 9.5px; font-weight: 800; letter-spacing: .07em;
  padding: 2px 8px; border-radius: 3px;
  background: rgba(245,158,11,.15); color: var(--warning, #f59e0b);
}
.charging-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.charging-disclaimer {
  background: rgba(239,68,68,.1); border-bottom: 2px solid rgba(239,68,68,.3);
  padding: 10px 20px; font-size: 12px; font-weight: 700;
  color: var(--red, #ef4444); flex-shrink: 0;
}
.charging-panel-body {
  flex: 1; overflow-y: auto; padding: 20px 24px; max-width: 960px;
}
.charging-case-summary {
  font-size: 15px; color: var(--muted); line-height: 1.6;
  border-left: 3px solid var(--accent); padding-left: 14px; margin-bottom: 20px;
  font-style: italic;
}
.charging-section-title {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 20px 0 10px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
/* Primary charge card */
.charging-primary-card {
  background: var(--panel); border: 2px solid var(--accent);
  border-radius: 10px; padding: 18px; margin-bottom: 16px;
}
.charging-charge-name { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.charging-ocga { font-size: 12px; color: var(--muted); margin-bottom: 10px; font-family: "SF Mono", monospace; }
.charging-strength-badge {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  padding: 3px 12px; border-radius: 99px; margin-bottom: 12px;
}
.charging-strength-charge_now      { background: rgba(16,185,129,.15); color: #10b981; }
.charging-strength-strengthen_first { background: rgba(245,158,11,.15); color: #f59e0b; }
.charging-strength-not_yet          { background: rgba(239,68,68,.12); color: #ef4444; }
/* Elements grid */
.charging-elements-grid { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.charging-element-row {
  display: grid; grid-template-columns: 28px 1fr 1fr; gap: 8px;
  align-items: flex-start; font-size: 13px; padding: 6px 8px;
  border-radius: 5px; border: 1px solid var(--border);
}
.charging-element-row--met     { background: rgba(16,185,129,.05); border-color: rgba(16,185,129,.2); }
.charging-element-row--missing { background: rgba(239,68,68,.05); border-color: rgba(239,68,68,.2); }
.charging-element-icon { font-size: 14px; text-align: center; }
.charging-element-name { font-weight: 600; }
.charging-element-source { color: var(--muted); font-size: 12px; }
.charging-notes { font-size: 12.5px; color: var(--muted); font-style: italic; margin-top: 8px; }
/* Additional charge card (collapsible) */
.charging-additional-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 10px; overflow: hidden;
}
.charging-additional-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer;
}
.charging-additional-header:hover { background: rgba(255,255,255,.03); }
.charging-additional-body { padding: 0 16px 14px; display: none; }
.charging-additional-body.expanded { display: block; }
/* Lesser included */
.charging-lesser-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.charging-lesser-row:last-child { border-bottom: none; }
/* Do not charge */
.charging-dnc-card {
  border: 1px solid rgba(239,68,68,.3); border-radius: 7px;
  padding: 10px 14px; margin-bottom: 8px;
  background: rgba(239,68,68,.04);
}
.charging-dnc-name { font-size: 13px; font-weight: 700; color: var(--red, #ef4444); }
.charging-dnc-reason { font-size: 12px; color: var(--muted); margin-top: 3px; }
/* Immediate actions */
.charging-actions-callout {
  background: rgba(245,158,11,.07); border: 1px solid rgba(245,158,11,.3);
  border-radius: 8px; padding: 14px 16px;
}
.charging-action-item {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; padding: 5px 0; line-height: 1.5;
}
.charging-action-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--warning, #f59e0b); color: #000; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
/* Timestamp line */
.charging-timestamp-line {
  font-size: 11.5px; color: var(--muted); padding: 4px 14px 0;
}

/* FIX 1 (reinforced): Legacy analysis shells — permanently hidden unless toggled.
   !important defeats the inline display:block set by ensureStructuredOutputsPanel()
   and related functions. JS suppressor also runs every 800ms as belt-and-suspenders. */
#bw-prep-overview-dock,
#structured-outputs-shell,
#bw-structured-outputs-viewer-shell,
#bw-final-analysis-viewer-shell,
#bw-lead-board-shell,
#bw-lead-debug-shell,
#case-status-shell {
  display: none !important;
}
/* Allow JS toggle to override via data attribute */
#bw-prep-overview-dock[data-bw-visible="1"],
#structured-outputs-shell[data-bw-visible="1"],
#bw-structured-outputs-viewer-shell[data-bw-visible="1"],
#bw-final-analysis-viewer-shell[data-bw-visible="1"],
#bw-lead-board-shell[data-bw-visible="1"],
#case-status-shell[data-bw-visible="1"] {
  display: block !important;
}

/* ═══════════════════════════════════════════════════════════════════
   CASE OVERVIEW TAB
   ═══════════════════════════════════════════════════════════════════ */

#pane-overview {
  padding: 16px 20px 20px;
  overflow-y: auto;
  height: 100%;
}

/* ── Loading skeleton ──────────────────────────────────────────── */
.ov-loading { padding: 20px 0; }
.ov-skeleton-row { display: flex; gap: 14px; }
.ov-skeleton-card {
  flex: 1;
  height: 110px;
  background: linear-gradient(90deg, var(--border) 25%, #e8e8f0 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: ov-shimmer 1.4s infinite;
  border-radius: 10px;
}
@keyframes ov-shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Empty / no-analysis state ─────────────────────────────────── */
.ov-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  gap: 10px;
  text-align: center;
}
.ov-empty-icon { font-size: 52px; line-height: 1; }
.ov-empty-title { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 4px; }
.ov-empty-body  { font-size: 14px; color: var(--text-muted); max-width: 380px; line-height: 1.6; }
.ov-empty-cta {
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.ov-empty-cta:hover { background: var(--accent-hover); }

/* ── Stat card row ─────────────────────────────────────────────── */
.ov-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 6px;
}
.ov-stat-card {
  background: var(--panel-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  border-top: 4px solid #94a3b8;
  padding: 16px 18px 14px;
  cursor: pointer;
  transition: box-shadow .15s, transform .12s;
}
.ov-stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.10); transform: translateY(-2px); }
.ov-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.ov-stat-number {
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  margin-bottom: 6px;
}
.ov-stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Score card specifics */
.ov-score-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0 6px;
}
.ov-score-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  transition: width .7s cubic-bezier(.4,0,.2,1);
}
.ov-score-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(148,163,184,.15);
  color: #64748b;
}
.ov-badge-ready        { background: rgba(22,163,74,.12);  color: #16a34a; }
.ov-badge-caution      { background: rgba(217,119,6,.12);  color: #d97706; }
.ov-badge-critical     { background: rgba(220,38,38,.12);  color: #dc2626; }
.ov-badge-not_analyzed { background: rgba(148,163,184,.12); color: #64748b; }

/* ── Refresh timestamp ─────────────────────────────────────────── */
.ov-refresh-line {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  margin-bottom: 12px;
}

/* ── Three-panel row ───────────────────────────────────────────── */
.ov-panels-row {
  display: grid;
  grid-template-columns: 1fr 1fr 220px;
  gap: 14px;
  margin-bottom: 14px;
}
.ov-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ov-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.ov-panel-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.ov-panel-count {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.ov-panel-body {
  flex: 1;
  padding: 10px 12px;
  overflow: hidden;
}
.ov-panel-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.ov-panel-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.ov-panel-link:hover { text-decoration: underline; }
.ov-panel-empty { font-size: 12.5px; color: var(--text-muted); font-style: italic; padding: 6px 0; }

/* ── Missed leads panel ────────────────────────────────────────── */
.ov-lead-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.ov-lead-row:last-child { border-bottom: none; }
.ov-lead-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 1px;
}
.ov-lead-high   { background: rgba(220,38,38,.12);  color: #dc2626; }
.ov-lead-medium { background: rgba(217,119,6,.12);  color: #d97706; }
.ov-lead-low    { background: rgba(100,116,139,.10); color: #64748b; }
.ov-lead-desc   { color: var(--text); line-height: 1.4; }

/* ── Prosecution elements panel ────────────────────────────────── */
.ov-el-bar-wrap { margin: 0; }
.ov-el-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 5px;
  font-size: 12.5px;
}
.ov-el-alt { background: rgba(0,0,0,.025); }
.ov-el-icon { flex-shrink: 0; font-size: 13px; }
.ov-el-met     { color: #16a34a; }
.ov-el-partial { color: #d97706; }
.ov-el-missing { color: #dc2626; }
.ov-el-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Quick Actions panel ───────────────────────────────────────── */
.ov-actions-body { display: flex; flex-direction: column; gap: 4px; }
.ov-action-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.ov-action-btn:hover { background: rgba(74,158,255,.08); border-color: var(--accent); color: var(--accent); }

/* ── Activity strip ────────────────────────────────────────────── */
.ov-activity-strip {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}
.ov-activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.ov-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.ov-activity-list { padding: 4px 0; }
.ov-activity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.ov-activity-row:last-child { border-bottom: none; }
.ov-activity-type { color: var(--text); font-weight: 500; }
.ov-activity-ts {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.ov-activity-empty { padding: 10px 14px; font-size: 12.5px; color: var(--text-muted); font-style: italic; }

/* ── Case Vitals bar ───────────────────────────────────────────── */
.ov-vitals {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.ov-vital {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 9px;
  font-size: 11px;
  white-space: nowrap;
}
.ov-vital-sep { color: var(--border); font-size: 13px; }


/* ─── Command Center Homepage ────────────────────────────────────── */

.bwh-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f0f2f5;
}

/* Top bar */
.bwh-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--sidebar-bg);
  color: #fff;
  flex-shrink: 0;
}
.bwh-topbar-brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.bwh-logo-mark { font-size: 15px; opacity: 0.8; }
.bwh-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bwh-refresh-ts { font-size: 11px; color: #6e6e8a; }

/* Stat bar */
.bwh-stat-bar {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.bwh-stat-tile {
  flex: 1;
  padding: 14px 20px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  transition: background 0.15s;
}
.bwh-stat-tile:last-child { border-right: none; }
.bwh-stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.bwh-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.bwh-stat-tile--warning .bwh-stat-num { color: #d97706; }
.bwh-stat-tile--danger .bwh-stat-num { color: #dc2626; }
.bwh-stat-tile--success .bwh-stat-num { color: #059669; }
.bwh-stat-tile--muted .bwh-stat-num { color: var(--text-muted); }

/* Body: two-column layout */
.bwh-body {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
  gap: 0;
}

/* Left: cases panel */
.bwh-cases-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  position: relative;
}
.bwh-filter-bar {
  display: flex;
  gap: 4px;
  padding: 10px 8px 10px 12px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bwh-filter-tab {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.bwh-filter-tab:hover { background: var(--bg); color: var(--text); }
.bwh-filter-tab.active {
  background: var(--sidebar-bg);
  color: #fff;
  border-color: var(--sidebar-bg);
}

/* Cards grid */
.bwh-cards-grid {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 16px 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  align-content: start;
  gap: 14px;
  position: relative;
}
.bwh-cards-grid--archived { opacity: 0.75; }
.bwh-cards-empty, .bwh-dash-loading {
  grid-column: 1 / -1;
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Case cards */
.bwh-case-card {
  background: var(--panel-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.25s ease;
}
.bwh-case-card.bwh-card--visible {
  opacity: 1;
  transform: translateY(0);
}
.bwh-case-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.bwh-card--ready { border-left-color: #10b981; }
.bwh-card--caution { border-left-color: #f59e0b; }
.bwh-card--critical { border-left-color: #ef4444; }
.bwh-card--na { border-left-color: #d1d5db; }
.bwh-card--archived { border-left-color: #9ca3af; opacity: 0.7; }
.bwh-card--archived:hover { opacity: 0.9; }

.bwh-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 14px 8px;
  gap: 8px;
}
.bwh-card-info { flex: 1; min-width: 0; }
.bwh-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bwh-card-id-line {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.bwh-card-ring { flex-shrink: 0; }

.bwh-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 14px 10px;
  align-items: center;
}
.bwh-card-type-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: #ede9fe;
  color: #6d28d9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.bwh-card-lifecycle {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.bwh-lifecycle-active { background: #d1fae5; color: #065f46; }
.bwh-lifecycle-closed { background: #f3f4f6; color: #6b7280; }
.bwh-lifecycle-archived { background: #e5e7eb; color: #9ca3af; }
.bwh-card-brady-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #fef2f2;
  color: #dc2626;
}

/* Action items in card */
.bwh-card-actions-list {
  padding: 0 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.bwh-card-action-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11.5px;
  line-height: 1.4;
}
.bwh-card-priority {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 1px;
  letter-spacing: 0.4px;
}
.bwh-priority-high { background: #fef2f2; color: #dc2626; }
.bwh-priority-critical { background: #fef2f2; color: #991b1b; }
.bwh-priority-medium { background: #fffbeb; color: #92400e; }
.bwh-priority-low { background: #f0fdf4; color: #166534; }
.bwh-card-action-text { color: var(--text-muted); }
.bwh-card-no-actions { font-size: 11.5px; color: #d1d5db; font-style: italic; }

/* Card footer */
.bwh-card-footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid #f3f4f6;
  font-size: 11px;
  color: var(--text-muted);
}

/* Archived section */
.bwh-archived-section {
  flex-shrink: 0;
  padding: 0 0 8px;
  border-top: 1px solid var(--border);
  background: var(--panel-bg);
}
.bwh-archived-summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.bwh-archived-summary:hover { color: var(--text); }
.bwh-archived-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 99px;
  padding: 1px 7px;
  margin-left: 4px;
}

/* ─── Hot Board ───────────────────────────────────────────────────── */
.bwh-hot-board {
  width: 340px;
  min-width: 340px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-left: 1px solid #2a2a40;
  overflow: hidden;
  margin-right: 0;
}
/* Watermark badge behind cards */
.bwh-badge-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 420px;
  height: 420px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}
.bwh-cards-grid > :not(.bwh-badge-watermark) { position: relative; z-index: 1; }
.bwh-hb-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #2a2a40;
  flex-shrink: 0;
}
.bwh-hb-title {
  font-size: 12px;
  font-weight: 700;
  color: #e2b84f;
  letter-spacing: 1px;
}
.bwh-hb-subtitle {
  font-size: 10px;
  color: var(--sidebar-muted);
  margin-top: 2px;
}
.bwh-hb-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.bwh-hb-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--sidebar-muted);
  font-size: 12px;
}
.bwh-hb-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #252540;
  cursor: pointer;
  transition: background 0.1s;
}
.bwh-hb-item:hover { background: #252540; }
.bwh-hb-item--brady { border-left: 3px solid #ef4444; }
.bwh-hb-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--sidebar-muted);
  min-width: 24px;
  padding-top: 1px;
}
.bwh-hb-item-body { flex: 1; min-width: 0; }
.bwh-hb-case-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.bwh-hb-desc {
  font-size: 11.5px;
  color: var(--sidebar-text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bwh-hb-badges {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
  flex-shrink: 0;
}
.bwh-hb-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}
.bwh-badge-brady { background: #7f1d1d; color: #fca5a5; }
.bwh-badge-ts { background: #78350f; color: #fde68a; font-size: 11px; }

/* Hot board footer stats */
.bwh-hb-footer {
  display: flex;
  padding: 10px 0;
  border-top: 1px solid #2a2a40;
  flex-shrink: 0;
}
.bwh-hb-foot-stat {
  flex: 1;
  text-align: center;
  border-right: 1px solid #2a2a40;
}
.bwh-hb-foot-stat:last-child { border-right: none; }
.bwh-hb-foot-num {
  font-size: 20px;
  font-weight: 700;
  color: #c8c8d8;
  line-height: 1;
}
.bwh-hb-foot-label {
  font-size: 9px;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

/* ─── Lifecycle status dropdown in case header ──────────────────── */
.bw-lifecycle-select {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  margin-left: 8px;
}

/* ─── Archived case banner ──────────────────────────────────────── */
.bw-archived-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: #fef3c7;
  border-bottom: 1px solid #f59e0b;
  font-size: 12px;
  font-weight: 500;
  color: #78350f;
  flex-shrink: 0;
}

/* ─── Sidebar archived section ──────────────────────────────────── */
.sidebar-archived {
  border-top: 1px solid #2a2a40;
  margin-top: auto;
}
.sidebar-archived-summary {
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-muted);
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-archived-summary:hover { color: var(--sidebar-text); }
.sidebar-archived-badge {
  background: #2a2a40;
  color: var(--sidebar-muted);
  border-radius: 99px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
}

/* ─── Lead disposition: inline status select ─────────────────────── */
.lead-status-cell { white-space: nowrap; vertical-align: middle; }

.lead-status-select {
  font-size: 11.5px;
  padding: 2px 4px 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  max-width: 130px;
}
.lead-status-select:focus { outline: 1px solid var(--accent); }

.lead-st-sel-open          { border-color: var(--accent); color: var(--accent); }
.lead-st-sel-in_progress   { border-color: #f59e0b;       color: #f59e0b; }
.lead-st-sel-completed     { border-color: var(--green);  color: var(--green); }
.lead-st-sel-dismissed     { border-color: var(--muted);  color: var(--muted); opacity: 0.75; }
.lead-st-sel-escalated     { border-color: #ef4444;       color: #ef4444; }
.lead-st-sel-declined      { border-color: var(--muted);  color: var(--muted); opacity: 0.75; }

/* Existing disposition note shown under status */
.lead-note-inline {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Lead note row (shown after status change to final state) ────── */
.lead-note-row td {
  padding: 2px 12px 8px !important;
  background: var(--sidebar-bg);
}
.lead-note-row-inner {
  display: flex;
  gap: 8px;
  align-items: center;
}
.lead-note-row-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.lead-note-input {
  flex: 1;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}
.lead-note-input:focus { outline: 1px solid var(--accent); }

/* ─── Lead summary bar: dismissed stat ──────────────────────────── */
.leads-stat-dismissed { color: var(--muted); }

/* ─── Dismissed toggle button ───────────────────────────────────── */
.leads-dismissed-toggle { opacity: 0.55; }
.leads-dismissed-toggle--active {
  opacity: 1;
  background: #2a2a3a;
  color: var(--muted);
}

/* ─── Saved Warrants button + dropdown ──────────────────────────── */
.saved-warrants-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 200;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  min-width: 340px;
  max-width: 520px;
  margin-top: 4px;
  overflow: hidden;
}
.saved-warrants-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border);
}
.saved-warrants-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--text);
  text-decoration: none;
  gap: 12px;
}
.saved-warrants-item:hover { background: var(--bg); }
.saved-warrants-name { font-family: var(--mono, monospace); font-size: 11.5px; }
.saved-warrants-date { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Warrant link in evidence register */
.ev-warrant-link { color: var(--accent); text-decoration: none; font-family: var(--mono, monospace); font-size: 12px; }
.ev-warrant-link:hover { text-decoration: underline; }

/* ─── Dismissed toggle: more visible when items exist ────────────── */
.leads-dismissed-toggle--has-items { opacity: 0.8; }

/* ─── Logo click → back to homepage ─────────────────────────────── */
.bw-logo-clickable {
  cursor: pointer;
  transition: opacity 0.15s;
}
.bw-logo-clickable:hover { opacity: 0.75; }

/* ─── Case header breadcrumb ─────────────────────────────────────── */
.bw-case-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px 0;
  font-size: 11.5px;
  color: var(--muted);
}
.bw-breadcrumb-home {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  padding: 0;
  letter-spacing: 0.04em;
}
.bw-breadcrumb-home:hover { opacity: 0.75; text-decoration: underline; }
.bw-breadcrumb-sep { color: var(--muted); font-size: 12px; }
.bw-breadcrumb-case { color: var(--text); font-weight: 500; }

/* ─── Case Notes / Working Journal ──────────────────────────────── */
.notes-search-input {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 200px;
  margin-left: auto;
}
.notes-search-input:focus { outline: 1px solid var(--accent); }

.notes-quick-entry {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}
.notes-quick-entry textarea {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 52px;
  font-family: var(--mono, monospace);
  box-sizing: border-box;
}
.notes-quick-entry textarea:focus { outline: 1px solid var(--accent); }

.notes-templates {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.notes-tmpl-btn {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.notes-tmpl-btn:hover { color: var(--text); border-color: var(--accent); }

/* Notes list */
.notes-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notes-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.notes-item--pinned {
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
}
.notes-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.notes-item-date { font-size: 11px; color: var(--muted); }
.notes-item-actions { display: flex; gap: 4px; }

.notes-pin-btn, .notes-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0.5;
}
.notes-pin-btn:hover, .notes-edit-btn:hover { opacity: 1; background: var(--sidebar-bg); }
.notes-pin-btn--pinned { opacity: 1; }

.notes-item-content {
  font-size: 13px;
  font-family: var(--mono, monospace);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.notes-edit-textarea {
  width: 100%;
  font-size: 13px;
  font-family: var(--mono, monospace);
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 80px;
  box-sizing: border-box;
}
.notes-edit-textarea:focus { outline: 1px solid var(--accent); }

.notes-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
