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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif;
  background: #f5f4ee;
  color: #2b2a27;
  height: 100vh;
  overflow: hidden;
}

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

/* Sidebar */
.sidebar {
  width: 240px;
  background: #fafaf8;
  border-right: 1px solid #d9d6cc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px 14px 14px;
  border-bottom: 1px solid #d9d6cc;
}

.sidebar-header h1 {
  font-size: 15px;
  color: #2b2a27;
  font-weight: 700;
}

.back-link {
  color: #83827d;
  font-size: 11px;
  text-decoration: none;
  margin-top: 2px;
  display: block;
}

.back-link:hover { color: #c96442; }

.sidebar-nav { padding: 8px; }

.nav-item, .channel-item {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: #83827d;
  margin-bottom: 1px;
}

.nav-item:hover, .channel-item:hover {
  background: #ece8df;
  color: #2b2a27;
}

.nav-item.active, .channel-item.active {
  background: #c96442;
  color: #fff;
}

.sidebar-section { padding: 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.channel-item { position: relative; display: flex; align-items: center; justify-content: space-between; }
.channel-item.has-unread { color: #2b2a27; font-weight: 600; }

.unread-badge {
  background: #c96442; color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; margin-left: auto;
}

.section-label {
  color: #83827d;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 10px 6px;
}

/* Model selector (pinned to the bottom of the sidebar) */
.sidebar-footer { margin-top: auto; padding: 10px 12px; border-top: 1px solid #e6e2d9; }
.model-label {
  display: block; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: #83827d; margin-bottom: 5px;
}
.model-select {
  width: 100%; background: #fff; border: 1px solid #e6e2d9; border-radius: 6px;
  padding: 6px 8px; font-size: 12px; color: #2b2a27; font-family: inherit; cursor: pointer;
}
.model-select:hover { border-color: #c96442; }
.model-select:focus { outline: none; border-color: #c96442; }
.model-select:disabled { opacity: 0.5; cursor: progress; }

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #f5f4ee;
}

.main-header {
  padding: 13px 18px;
  border-bottom: 1px solid #d9d6cc;
  background: #fafaf8;
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-header h2 { font-size: 14px; color: #2b2a27; font-weight: 600; }
.main-header .desc { color: #83827d; font-size: 12px; }

.main-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Messages */
.message { display: flex; gap: 10px; margin-bottom: 14px; }

.message-avatar {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; color: #fff; font-weight: 700;
}

.message-avatar.agent { background: #c96442; }
.message-avatar.human { background: #27ae60; }

.message-meta { margin-bottom: 3px; }
.message-author { font-size: 13px; font-weight: 600; }
.message-author.agent { color: #c96442; }
.message-author.human { color: #27ae60; }
.message-time { color: #83827d; font-size: 11px; margin-left: 6px; }
.message-text { font-size: 12px; line-height: 1.5; color: #2b2a27; }
.load-earlier {
  text-align: center; padding: 10px; color: #c96442; font-size: 13px;
  cursor: pointer; font-weight: 500; border-bottom: 1px solid #e6e2d9; margin-bottom: 8px;
}
.load-earlier:hover { background: #f5f4ee; }

.stop-btn {
  background: #fde8e8; color: #c0392b; border: 1px solid #f5c6c6; border-radius: 4px;
  padding: 2px 8px; font-size: 11px; font-weight: 600; cursor: pointer; margin-left: 8px;
}
.stop-btn:hover { background: #c0392b; color: #fff; }

/* Trace / Debug View */
.trace-list { display: flex; flex-direction: column; gap: 2px; }
.trace-event { border: 1px solid #e6e2d9; border-radius: 6px; cursor: pointer; }
.trace-event:hover { border-color: #c96442; }
.trace-header {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12px;
}
.trace-seq { color: #b0b0b8; font-size: 10px; font-weight: 600; min-width: 28px; }
.trace-type { font-weight: 600; font-size: 11px; min-width: 70px; }
.trace-name { color: #2b2a27; font-weight: 500; font-family: monospace; font-size: 12px; }
.trace-detail { display: none; padding: 0 10px 8px; }
.trace-detail.open { display: block; }
.trace-section { margin-top: 6px; }
.trace-label { font-size: 10px; color: #83827d; text-transform: uppercase; font-weight: 600; margin-bottom: 2px; }
.trace-detail pre {
  background: #f5f4ee; border: 1px solid #e6e2d9; border-radius: 4px; padding: 8px;
  font-size: 11px; line-height: 1.4; overflow-x: auto; max-height: 300px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}

.date-divider { text-align: center; margin: 8px 0 16px; position: relative; }
.date-divider span { background: #f5f4ee; padding: 0 10px; color: #83827d; font-size: 11px; position: relative; z-index: 1; }
.date-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: #e6e2d9; }

/* Input */
.input-area { padding: 12px 16px; border-top: 1px solid #e6e2d9; background: #fff; }

.input-box {
  background: #fff; border: 1px solid #d9d6cc; border-radius: 10px;
  padding: 12px 14px; display: flex; align-items: center; gap: 8px;
}

.input-box input { flex: 1; background: transparent; border: none; color: #2b2a27; font-size: 13px; outline: none; }
.input-box button { background: #c96442; border: none; border-radius: 6px; padding: 6px 14px; color: white; font-size: 12px; font-weight: 600; cursor: pointer; }
.input-box button:hover { background: #a84d2f; }
.input-box button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Persistent quick-command chips above the composer */
.quick-commands {
  display: flex; gap: 8px; margin-bottom: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.quick-commands::-webkit-scrollbar { display: none; }
.quick-commands:empty { display: none; }
.quick-cmd-btn {
  flex: 0 0 auto; white-space: nowrap;
  background: #fff; border: 1px solid #e6e2d9; border-radius: 16px;
  padding: 6px 12px; font-size: 12px; font-weight: 500; color: #2b2a27; cursor: pointer;
}
.quick-cmd-btn:hover { border-color: #c96442; background: #faf1ec; }
.quick-cmd-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tables */
.task-table, .run-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.task-table th, .run-table th {
  text-align: left; padding: 8px; color: #83827d; border-bottom: 1px solid #e6e2d9; background: #f7f5f0;
}

.task-table td { padding: 8px; border-bottom: 1px solid #ece8df; cursor: pointer; }
.run-table td { padding: 8px; border-bottom: 1px solid #ece8df; color: #2b2a27; }
.task-table tr:hover td { background: #f5f4ee; }
.task-title { color: #c96442; font-weight: 500; }

.task-day-header {
  font-size: 13px; font-weight: 600; color: #2b2a27;
  padding: 12px 0 6px; margin-top: 8px;
  border-bottom: 1px solid #e6e2d9;
}

.task-day-header:first-child { margin-top: 0; }

.task-day-count {
  background: #ece8df; color: #83827d; font-size: 11px;
  padding: 1px 6px; border-radius: 8px; margin-left: 6px; font-weight: 500;
}

/* Badges */
.badge { padding: 2px 6px; border-radius: 10px; font-size: 10px; font-weight: 600; display: inline-block; }
.badge-critical { background: #fde8e8; color: #c0392b; }
.badge-high { background: #fef3e2; color: #d35400; }
.badge-medium { background: #eef2ff; color: #5b6abf; }
.badge-low { background: #ece8df; color: #83827d; }
.badge-open { background: #e8f8ef; color: #27ae60; }
.badge-in_progress { background: #f4e7e0; color: #2980b9; }
.badge-done { background: #eef2ff; color: #5b6abf; }
.badge-verified { background: #e8f8ef; color: #1e8449; }
.badge-failed { background: #fde8e8; color: #c0392b; }
.badge-role { background: #eef2ff; color: #5b6abf; padding: 2px 6px; border-radius: 4px; font-size: 10px; }

/* Filters */
.filters { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.filters select { background: #fff; border: 1px solid #e6e2d9; border-radius: 6px; padding: 6px 10px; color: #2b2a27; font-size: 12px; }

/* Task/Agent detail panel */
.task-detail-overlay {
  display: none; position: fixed; top: 0; right: 0; bottom: 0; width: 420px;
  background: #fff; border-left: 1px solid #e6e2d9; z-index: 100;
  flex-direction: column; overflow-y: auto; padding: 20px;
  box-shadow: -4px 0 12px rgba(0,0,0,0.08);
}

.task-detail-overlay.open { display: flex; }
.task-detail-overlay h3 { color: #2b2a27; font-size: 15px; margin-bottom: 16px; }

.task-field { margin-bottom: 12px; }
.task-field label { display: block; color: #83827d; font-size: 11px; margin-bottom: 4px; text-transform: uppercase; }
.task-field .value { color: #2b2a27; font-size: 13px; }

.task-field select, .task-field textarea, .task-field input[type="text"] {
  width: 100%; background: #f5f4ee; border: 1px solid #e6e2d9; border-radius: 6px;
  padding: 8px; color: #2b2a27; font-size: 13px; font-family: inherit;
}

.task-field textarea { min-height: 80px; resize: vertical; }

.btn-save { background: #c96442; border: none; border-radius: 6px; padding: 8px 16px; color: white; font-size: 13px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.btn-save:hover { background: #a84d2f; }
.btn-close { position: absolute; top: 16px; right: 16px; background: none; border: none; color: #83827d; font-size: 18px; cursor: pointer; }

/* Cards */
.brief-card {
  background: #fff; border-radius: 8px; padding: 14px; margin-bottom: 10px;
  border-left: 3px solid; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.brief-card.critical { border-color: #c0392b; }
.brief-card.warning { border-color: #d35400; }
.brief-card.healthy { border-color: #27ae60; }
.brief-card h4 { font-size: 13px; color: #2b2a27; margin-bottom: 4px; }
.brief-card p { font-size: 12px; color: #83827d; }

.loading { color: #83827d; font-size: 13px; padding: 20px; text-align: center; }

/* Daily Reports */
.report-card {
  background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); border: 1px solid #e6e2d9;
}

.report-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.report-header h3 { font-size: 15px; color: #2b2a27; margin: 0; }

.report-stats { display: flex; gap: 20px; margin-bottom: 18px; padding: 12px 0; border-bottom: 1px solid #ece8df; }
.report-stat { text-align: center; }
.report-stat-value { font-size: 22px; font-weight: 700; color: #2b2a27; }
.report-stat-label { font-size: 11px; color: #83827d; text-transform: uppercase; margin-top: 2px; }

.report-section { margin-bottom: 14px; }
.report-section-title { font-size: 11px; color: #83827d; text-transform: uppercase; font-weight: 600; margin-bottom: 6px; }

.report-agent-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }

.report-task-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.report-bar { flex: 1; height: 8px; border-radius: 4px; background: #ece8df; display: flex; overflow: hidden; }
.report-bar-done { background: #27ae60; }
.report-bar-ip { background: #3498db; }
.report-bar-open { background: #e6e2d9; }

.report-channel {
  background: #ece8df; padding: 3px 8px; border-radius: 4px; font-size: 12px; color: #2b2a27;
}

/* Task Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}

.modal-content {
  background: #fff; border-radius: 12px; width: 560px; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* Agent editor modal — full screen */
.modal-content.agent-editor {
  width: 95vw; max-width: 1400px; height: 90vh; max-height: 90vh;
}

/* Agent list */
.agent-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px;
}
.agent-card {
  background: #fff; border: 1px solid #e6e2d9; border-radius: 8px; padding: 12px 14px;
  cursor: pointer; transition: all 0.15s;
}
.agent-card:hover { border-color: #c96442; box-shadow: 0 2px 8px rgba(201,100,66,0.14); }
.agent-card.disabled { opacity: 0.5; }
.agent-card-header { display: flex; align-items: center; gap: 10px; }
.agent-card-icon {
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-size: 16px; flex-shrink: 0; color: #fff;
}
.agent-card-name { font-size: 13px; font-weight: 600; color: #2b2a27; }
.agent-card-meta { font-size: 11px; color: #83827d; margin-top: 2px; }
.agent-group-header {
  font-size: 12px; font-weight: 700; text-transform: uppercase; color: #83827d;
  padding: 6px 4px 4px; letter-spacing: 0.5px; grid-column: 1 / -1;
  border-bottom: 1px solid #e6e2d9; margin-top: 6px;
}
.agent-group-header .count { font-weight: 400; color: #b0b0b8; margin-left: 4px; }

/* Agent editor tabs */
.editor-tabs {
  display: flex; gap: 0; border-bottom: 1px solid #e6e2d9; padding: 0 24px;
}
.editor-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 500; color: #83827d;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.editor-tab:hover { color: #2b2a27; }
.editor-tab.active { color: #c96442; border-bottom-color: #c96442; }
.editor-tab-content { display: none; }
.editor-tab-content.active { display: flex; flex: 1; overflow: hidden; }

/* Tool list in editor */
.tool-category {
  margin-bottom: 12px;
}
.tool-category-header {
  font-size: 11px; font-weight: 700; color: #83827d; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid #ece8df;
  display: flex; align-items: center; gap: 8px;
}
.tool-category-header .cat-count {
  font-weight: 400; font-size: 10px; color: #b0b0b8;
}
.tool-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 5px 4px; border-radius: 4px;
}
.tool-item:hover { background: #ece8df; }
.tool-item input[type="checkbox"] { margin-top: 2px; accent-color: #c96442; flex-shrink: 0; }
.tool-item-info { flex: 1; min-width: 0; }
.tool-item-name { font-size: 12px; font-weight: 500; color: #2b2a27; }
.tool-item-desc { font-size: 11px; color: #83827d; margin-top: 1px; line-height: 1.3; }

/* Daily Digest */
.digest-stat-card {
  background: #fff; border: 1px solid #e6e2d9; border-radius: 10px; padding: 14px 18px;
  min-width: 140px;
}
.digest-stat-label { font-size: 11px; color: #83827d; text-transform: uppercase; font-weight: 600; }
.digest-stat-value { font-size: 22px; font-weight: 700; color: #2b2a27; margin-top: 4px; }

.digest-alerts { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.digest-alert {
  padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 500;
}
.digest-alert.critical { background: #fde8e8; color: #c0392b; border: 1px solid #f5c6c6; }
.digest-alert.warning { background: #fef9e7; color: #b7791f; border: 1px solid #f9e79f; }

.digest-apps { display: flex; flex-direction: column; gap: 14px; }
.digest-app-card {
  background: #fff; border: 1px solid #e6e2d9; border-radius: 10px; padding: 16px 20px;
}
.digest-app-card.has-alerts { border-left: 3px solid #e67e22; }
.digest-app-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}

.digest-metrics {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px;
}
.digest-metric {
  background: #f7f5f0; border-radius: 6px; padding: 8px 10px;
}
.digest-metric-label { font-size: 10px; color: #83827d; text-transform: uppercase; font-weight: 600; }
.digest-metric-value { font-size: 16px; font-weight: 700; color: #2b2a27; margin-top: 2px; }
.digest-metric-compare { display: flex; align-items: center; gap: 6px; margin-top: 4px; }

.digest-avg-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: #ece8df; color: #83827d; font-weight: 500;
}
.digest-badge-bad { background: #fde8e8; color: #c0392b; }
.digest-badge-good { background: #e8f8e8; color: #27ae60; }

.badge-critical { background: #fde8e8; color: #c0392b; }

.digest-drilldowns {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid #ece8df;
}
.digest-dd-section { margin-bottom: 8px; }
.digest-dd-title {
  font-size: 12px; font-weight: 600; color: #c0392b; text-transform: capitalize; margin-bottom: 4px;
}
.digest-dd-dim {
  font-size: 10px; color: #83827d; text-transform: uppercase; font-weight: 600; margin: 4px 0 2px;
}

.digest-tests {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid #ece8df;
}

.modal-header {
  padding: 20px 24px; border-bottom: 1px solid #e6e2d9;
  display: flex; justify-content: space-between; align-items: flex-start;
}

.modal-header h3 { color: #2b2a27; font-size: 16px; margin: 0; }

.modal-body {
  padding: 20px 24px; overflow-y: auto; flex: 1;
}

.modal-section { margin-bottom: 16px; }
.modal-section > label { display: block; color: #83827d; font-size: 11px; text-transform: uppercase; font-weight: 600; }
.modal-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.modal-row label { color: #83827d; font-size: 12px; }
.modal-row span { color: #2b2a27; }

.modal-section select {
  width: 100%; background: #f5f4ee; border: 1px solid #e6e2d9; border-radius: 6px;
  padding: 8px; color: #2b2a27; font-size: 13px;
}

.modal-footer {
  padding: 16px 24px; border-top: 1px solid #e6e2d9;
  display: flex; gap: 10px; justify-content: flex-end;
}

/* Message data tables */
.msg-table {
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0;
  background: #fff;
  border: 1px solid #e6e2d9;
  border-radius: 6px;
  overflow: hidden;
  width: auto;
  min-width: 300px;
}

.msg-table th {
  background: #f7f5f0;
  padding: 6px 12px;
  text-align: left;
  font-weight: 600;
  color: #2b2a27;
  border-bottom: 1px solid #e6e2d9;
  white-space: nowrap;
}

.msg-table td {
  padding: 5px 12px;
  border-bottom: 1px solid #ece8df;
  white-space: nowrap;
}

.msg-table tr:last-child td { border-bottom: none; }
.msg-table tr:hover td { background: #f7f5f0; }

.cell-positive { color: #1e8449; font-weight: 600; }
.cell-negative { color: #c0392b; font-weight: 600; }
.cell-number { color: #2b2a27; font-variant-numeric: tabular-nums; }

/* Expandable artifact rows (Test Campaign Mapping daily breakdown) */
.msg-table tr.art-row-toggle { cursor: pointer; }
.msg-table tr.art-row-toggle:hover td { background: #faf1ec; }
.art-daily-caret { color: #c96442; font-size: 10px; }
.art-daily-badge {
  margin-left: 6px;
  padding: 1px 7px;
  background: #f7e9e2;
  border-radius: 4px;
  font-size: 10px;
  color: #c96442;
  font-weight: 500;
}
.msg-table tr.art-daily-row td { background: #f7f5f0; color: #666; font-size: 11px; }
.msg-table tr.art-daily-row:hover td { background: #f4f6f8; }
.art-daily-date { padding-left: 24px !important; color: #666; }

/* Thinking block */
.thinking-block {
  margin: 8px 0; padding: 8px 12px;
  background: #f7f5f0; border: 1px solid #e6e2d9; border-radius: 8px;
  font-size: 12px;
}

.thinking-header {
  cursor: pointer; color: #83827d; display: flex; align-items: center; gap: 6px;
}

.thinking-header strong { color: #c96442; }

.thinking-toggle { font-size: 8px; transition: transform 0.2s; }
.thinking-block.expanded .thinking-toggle { transform: rotate(90deg); }

.thinking-content {
  display: none; margin-top: 6px; padding-top: 6px; border-top: 1px solid #e6e2d9;
  color: #83827d; font-size: 12px; line-height: 1.5; white-space: pre-wrap;
}

.thinking-block.expanded .thinking-content { display: block; }

/* Thread cards */
.thread-card {
  background: #fff; border: 1px solid #d9d6cc; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 8px; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.thread-card:hover { border-color: #c96442; box-shadow: 0 2px 6px rgba(201,100,66,0.1); }
.thread-date { font-size: 13px; font-weight: 600; color: #2b2a27; }
.thread-preview { font-size: 13px; color: #83827d; margin-top: 6px; line-height: 1.4; }
.thread-meta { font-size: 11px; color: #b0b0b8; margin-top: 5px; }

/* Partial message */
.partial-text { opacity: 0.7; }

/* Typing indicator */
.typing-indicator {
  padding: 8px 12px;
  color: #83827d;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-indicator strong {
  color: #c96442;
  margin-left: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #83827d;
  border-radius: 50%;
  display: inline-block;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* @mention autocomplete */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e6e2d9;
  border-radius: 8px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
  max-height: 240px;
  overflow-y: auto;
  display: none;
  z-index: 50;
  margin-bottom: 4px;
}

.mention-dropdown.open { display: block; }

.mention-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mention-item:hover, .mention-item.selected {
  background: #ece8df;
}

.mention-item .mention-name {
  color: #c96442;
  font-weight: 600;
}

.mention-item .mention-desc {
  color: #83827d;
  font-size: 11px;
}

/* ============================================================
   Campaign Analyzer — composer, artifacts, decisions
   ============================================================ */
.decisions-btn, .back-btn {
  background: #fff; border: 1px solid #e6e2d9; border-radius: 6px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; color: #c96442; cursor: pointer;
}
.decisions-btn:hover, .back-btn:hover { background: #faf1ec; border-color: #f0d9cd; }

/* Artifacts (tables & charts emitted by the agent) */
.artifact {
  border: 1px solid #e6e2d9; border-radius: 10px; padding: 12px 14px;
  margin: 8px 0; background: #f8f6f0;
}
.artifact-title { font-size: 13px; font-weight: 700; color: #2b2a27; margin-bottom: 8px; }
.artifact-caption { font-size: 12px; color: #83827d; margin-top: 8px; font-style: italic; }
.artifact-scroll { overflow-x: auto; }
.chart-wrap { position: relative; height: 280px; }

/* Decision cards */
.decision-card {
  border: 1px solid #e6e2d9; border-left: 3px solid #6b7280; border-radius: 10px;
  padding: 12px 14px; margin: 8px 0; background: #fff;
}
.decision-card.status-proposed { border-left-color: #6b7280; }
.decision-card.status-approved { border-left-color: #2563eb; }
.decision-card.status-executed { border-left-color: #059669; }
.decision-card.status-rejected { border-left-color: #dc2626; }
.decision-card.status-superseded { border-left-color: #9ca3af; opacity: 0.7; }
.decision-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.decision-type { font-size: 13px; font-weight: 700; color: #2b2a27; text-transform: capitalize; }
.decision-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; text-transform: capitalize; }
.decision-rationale { font-size: 13px; color: #2b2a27; }
.decision-impact { font-size: 12px; color: #444; margin-top: 6px; }
.decision-metrics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.metric-chip { font-size: 11px; background: #ece8df; color: #444; padding: 2px 8px; border-radius: 10px; }
.decision-actions { display: flex; gap: 8px; margin-top: 10px; }
.dec-btn { border: none; border-radius: 6px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.dec-approve { background: #2563eb; color: #fff; }
.dec-approve:hover { background: #1d4ed8; }
.dec-execute { background: #059669; color: #fff; }
.dec-execute:hover { background: #047857; }
.dec-reject { background: #fff; color: #dc2626; border: 1px solid #f0c8c8; }
.dec-reject:hover { background: #fef2f2; }
.decision-decided { font-size: 12px; color: #83827d; margin-top: 8px; }

/* Decisions ledger filters */
.decision-filters { display: flex; gap: 6px; }
.filter-chip {
  background: #fff; border: 1px solid #e6e2d9; border-radius: 14px;
  padding: 4px 12px; font-size: 12px; color: #444; cursor: pointer; text-transform: capitalize;
}
.filter-chip.active { background: #c96442; color: #fff; border-color: #c96442; }

/* ============================================================
   Data review drawer (cached Campaign / Ad Mapping tables)
   ============================================================ */
/* Workspace column to the right of the sidebar: stacks the Data drawer
   (top) above #main-content. The drawer lives here — outside #main-content —
   so it survives the innerHTML rewrites that every view change does. */
.workspace {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Top drawer: spans the full workspace width (the wide Campaign/Ad mapping
   tables need the room — a right rail was too narrow). Collapsed until opened. */
.data-pane {
  display: none;
  flex-direction: column;
  background: #fff;
  border-bottom: 1px solid #e6e2d9;
  min-height: 0;
}
.data-pane.open { display: flex; flex: 0 0 auto; height: 48vh; }

.data-pane-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e6e2d9;
  flex-shrink: 0;
}
.data-pane-tabrow { display: flex; align-items: center; gap: 8px; }
.data-pane-tabs { display: flex; gap: 4px; }
.dp-tab {
  background: #f5f4ee; border: 1px solid #e6e2d9; border-radius: 6px;
  padding: 5px 14px; font-size: 12px; font-weight: 600; color: #83827d;
  cursor: pointer; font-family: inherit;
}
.dp-tab:hover { color: #2b2a27; border-color: #c96442; }
.dp-tab.active { background: #c96442; color: #fff; border-color: #c96442; }

/* All / Active / Paused segmented status filter. */
.dp-status { display: flex; margin-left: 6px; }
.dp-status-btn {
  background: #f5f4ee; border: 1px solid #e6e2d9; color: #83827d;
  padding: 4px 10px; font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.dp-status-btn:first-child { border-radius: 6px 0 0 6px; }
.dp-status-btn:last-child { border-radius: 0 6px 6px 0; }
.dp-status-btn + .dp-status-btn { border-left: none; }
.dp-status-btn:hover { color: #2b2a27; }
.dp-status-btn.active { background: #c96442; color: #fff; border-color: #c96442; }

.dp-expand {
  margin-left: auto;
  background: none; border: none; color: #83827d; font-size: 13px; line-height: 1;
  cursor: pointer; padding: 2px 8px; border-radius: 4px;
}
.dp-expand:hover { background: #ece8df; color: #2b2a27; }
.dp-expand.active { background: #c96442; color: #fff; }
.dp-expand.active:hover { background: #a84d2f; color: #fff; }

.dp-collapse {
  background: none; border: none; color: #83827d; font-size: 13px; line-height: 1;
  cursor: pointer; padding: 2px 8px; border-radius: 4px;
}
.dp-collapse:hover { background: #ece8df; color: #2b2a27; }

.dp-close {
  background: none; border: none; color: #83827d; font-size: 18px; line-height: 1;
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.dp-close:hover { background: #ece8df; color: #2b2a27; }

/* Collapsed = table hidden, only the header bar remains docked at the top. */
.data-pane.collapsed { height: auto; }
.data-pane.collapsed .data-pane-body { display: none; }

/* Expanded = the drawer takes the whole workspace height and the AI analysis
   pane (#main-content, the .main sibling below) is hidden, so more table rows
   fit on screen. Toggled by the ⛶ header button; mutually exclusive with
   .collapsed (the JS clears one when the other is set — :not() is a safety
   net so a stale combination never blanks the workspace). */
.data-pane.open.expanded:not(.collapsed) { height: auto; flex: 1; }
.data-pane.open.expanded:not(.collapsed) ~ .main { display: none; }
/* Time-range row: preset buttons (Today / Yesterday / 7d / 30d, within the
   cached window) on the left, freshness on the right. */
.data-pane-subrow { display: flex; align-items: center; gap: 10px; margin-top: 7px; flex-wrap: wrap; }
.dp-range { display: flex; }
.dp-range-btn {
  background: #f5f4ee; border: 1px solid #e6e2d9; color: #83827d;
  padding: 3px 9px; font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.dp-range-btn:first-child { border-radius: 6px 0 0 6px; }
.dp-range-btn:last-child { border-radius: 0 6px 6px 0; }
.dp-range-btn + .dp-range-btn { border-left: none; }
.dp-range-btn:hover { color: #2b2a27; }
.dp-range-btn.active { background: #c96442; color: #fff; border-color: #c96442; }
.dp-range-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.data-pane-fresh { font-size: 11px; color: #83827d; margin-left: auto; }

.data-pane-body {
  flex: 1; min-height: 0; overflow: auto; padding: 12px 14px;
}
.data-pane-body .loading { padding: 40px 20px; }

/* Read-only Memory viewer (per-app notebook). */
.dp-memory { display: flex; flex-direction: column; gap: 12px; }
.dp-mem-file { border: 1px solid #e6e2d9; border-radius: 8px; padding: 10px 12px; background: #fff; }
.dp-mem-path { font-size: 11px; font-weight: 700; color: #c96442; font-family: ui-monospace, monospace; margin-bottom: 6px; }
.dp-mem-when { color: #b0b0b8; font-weight: 400; }
.dp-mem-pre {
  background: #f7f5f0; border: 1px solid #ece8df; border-radius: 6px; padding: 8px;
  font-size: 11px; line-height: 1.4; overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 0;
}
.dp-retry {
  display: inline-block; margin-top: 10px;
  background: #c96442; border: none; border-radius: 6px;
  padding: 6px 14px; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
}
.dp-retry:hover { background: #a84d2f; }

/* Cached tables: dense, smaller-than-dashboard fonts, single-line rows; the
   .art-* toggle classes drive the per-day reveal. Font size + padding live
   here (out of the inline cell styles) so density is one knob. */
.dp-table { font-variant-numeric: tabular-nums; font-size: 11px; }
.dp-table th { padding: 6px 9px; font-size: 10px; }
.dp-table td { padding: 6px 9px; }
.dp-table tr.art-row-toggle { cursor: pointer; }
.dp-table tr.art-row-toggle:hover > td { background: #faf1ec; }
.dp-table tr.art-daily-row td { padding: 4px 9px; font-size: 10px; }

/* Name cell: caret + status dot + the FULL name on ONE line + day badge. The
   name is never wrapped or cropped — the column sizes to the longest name and
   the table scrolls horizontally (.data-pane-body overflow:auto) when the whole
   thing doesn't fit. The first column stays frozen so the name stays visible. */
.dp-name { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.dp-name-text { flex: 0 0 auto; font-size: 10px; line-height: 1.3; white-space: nowrap; }
.dp-name .art-daily-caret { flex-shrink: 0; }
.dp-daybadge { flex-shrink: 0; }

/* Freeze the first (Campaign/Ad name) column while the metrics scroll
   sideways — like a frozen column in a spreadsheet. The box-shadow is a right
   divider that travels with the column (border-collapse borders don't stay
   put under position:sticky); each sticky cell needs an opaque background so
   scrolled cells don't bleed through it. */
.dp-table td.dp-sticky, .dp-table th.dp-sticky {
  position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 #e6e2d9;
}
.dp-table tbody td.dp-sticky { background: #fff; }
.dp-table tbody tr.art-row-toggle:hover td.dp-sticky { background: #faf1ec; }
.dp-table tr.art-daily-row td.dp-sticky { background: #fafbfc; }
.dp-table tr.dp-total td.dp-sticky { background: #1f2937; }
.dp-table thead th.dp-sticky { background: #fafafa; z-index: 3; }

/* Header toggle button in the channel/thread header. */
.dp-toggle-btn {
  background: #fff; border: 1px solid #e6e2d9; border-radius: 6px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; color: #c96442;
  cursor: pointer; font-family: inherit;
}
.dp-toggle-btn:hover { background: #faf1ec; border-color: #f0d9cd; }
.dp-toggle-btn.open { background: #c96442; color: #fff; border-color: #c96442; }

/* ============================================================
   Mobile responsiveness
   ============================================================ */
/* Hamburger toggle + drawer overlay (hidden on desktop) */
.menu-toggle { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
  body { overflow: hidden; }

  /* Off-canvas slide-in sidebar */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 78%; max-width: 300px; z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.35);
    z-index: 900; opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
  }
  .app.sidebar-open .sidebar-overlay { display: block; opacity: 1; pointer-events: auto; }

  /* Hamburger button, fixed top-left */
  .menu-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 8px; left: 8px; z-index: 1100;
    width: 38px; height: 38px; border: 1px solid #e6e2d9; border-radius: 8px;
    background: #fff; color: #2b2a27; font-size: 18px; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  }

  /* Main takes full width; header clears the fixed toggle */
  .main { width: 100%; }
  .main-header { padding-left: 56px; flex-wrap: wrap; row-gap: 6px; min-height: 52px; }
  .main-header h2 { font-size: 15px; }
  .main-body { padding: 12px; }

  /* Wider tap targets + no iOS zoom on focus */
  .channel-item, .nav-item { padding: 9px 12px; font-size: 14px; }
  .input-area { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .input-box input { font-size: 16px; }
  .input-box button { padding: 8px 14px; }

  /* Keep wide tables/charts from breaking layout */
  .message-text { overflow-x: auto; }
  .msg-table { font-size: 12px; }
  .chart-wrap { height: 240px; }
  .message-avatar { width: 28px; height: 28px; font-size: 12px; }

  /* Top data drawer takes a bit more height on short, stacked screens. */
  .data-pane.open { height: 60vh; }
}

@media (max-width: 420px) {
  .chart-wrap { height: 200px; }
  .main-header .desc { display: none; }
}

/* ============================================================
   App picker — welcome screen grid
   ============================================================ */
.app-picker {
  padding: 40px 32px;
  max-width: 760px;
}
.app-picker-eyebrow {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.6px; color: #b0b0b8; margin-bottom: 10px;
}
.app-picker-heading {
  font-size: 20px; font-weight: 700; color: #2b2a27; margin-bottom: 4px;
}
.app-picker-sub {
  font-size: 13px; color: #83827d; margin-bottom: 28px;
}
.app-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.app-picker-card {
  background: #fff; border: 1px solid #d9d6cc; border-radius: 10px;
  padding: 16px 18px; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.app-picker-card:hover {
  border-color: #c96442;
  box-shadow: 0 3px 10px rgba(201,100,66,0.12);
  transform: translateY(-1px);
}
.app-picker-card-name {
  font-size: 14px; font-weight: 700; color: #2b2a27; margin-bottom: 3px;
}
.app-picker-card-meta {
  font-size: 11px; color: #b0b0b8;
}

/* ============================================================
   Sidebar — app context header + session list
   ============================================================ */
.sidebar-app-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid #d9d6cc;
}
.sidebar-back-apps {
  background: none; border: none; cursor: pointer; color: #b0b0b8;
  font-size: 13px; padding: 2px 4px; border-radius: 4px; line-height: 1;
}
.sidebar-back-apps:hover { color: #c96442; background: #faf1ec; }
.sidebar-app-name {
  font-size: 13px; font-weight: 700; color: #2b2a27; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-new-btn {
  background: none; border: none; cursor: pointer; color: #83827d;
  font-size: 18px; padding: 0 4px; line-height: 1; border-radius: 4px;
}
.sidebar-new-btn:hover { color: #c96442; background: #faf1ec; }

.sidebar-sessions-list { padding: 6px 0; }
.sidebar-session-item {
  padding: 9px 14px; cursor: pointer; border-radius: 0;
  transition: background 0.1s;
}
.sidebar-session-item:hover { background: #ece8df; }
.sidebar-session-item.active { background: #f7ede6; border-right: 2px solid #c96442; }
.sidebar-session-date {
  font-size: 12px; font-weight: 600; color: #2b2a27; margin-bottom: 2px;
}
.sidebar-session-preview {
  font-size: 11px; color: #83827d; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.sidebar-session-item.active .sidebar-session-date { color: #c96442; }

.sidebar-no-sessions {
  padding: 16px 14px; color: #b0b0b8; font-size: 12px; text-align: center;
}

/* App picker empty state in main area */
.app-empty-state {
  display: flex; align-items: center; justify-content: center;
  flex: 1; padding: 40px;
}
.app-empty-inner { text-align: center; color: #83827d; }
.app-empty-icon { font-size: 36px; margin-bottom: 14px; opacity: 0.5; }
.app-empty-title { font-size: 15px; font-weight: 600; color: #2b2a27; margin-bottom: 6px; }
.app-empty-hint { font-size: 13px; color: #b0b0b8; }
