:root {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f2f5;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --purple: #9333ea;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Header ─────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 20px; font-weight: 600; }
.header-left .logo { font-size: 24px; display: flex; align-items: center; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 16px; }
.health-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.health-dot.good { background: var(--green); box-shadow: 0 0 8px var(--green); }
.health-dot.warning { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.health-dot.critical { background: var(--red); box-shadow: 0 0 8px var(--red); }
.refresh-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.refresh-btn:hover { opacity: 0.85; }
.last-update { font-size: 12px; color: var(--text-muted); }

/* ── Navigation ─────────────────────── */
.nav {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.nav-tab {
  padding: 12px 20px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Main Content ───────────────────── */
.content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Cards Grid ─────────────────────── */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.card-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.card-value.green { color: var(--green); }
.card-value.amber { color: var(--amber); }
.card-value.red { color: var(--red); }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Charts ─────────────────────────── */
.chart-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.chart-box h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
.chart-container { position: relative; width: 100%; }
.chart-container canvas { width: 100% !important; }

/* ── Tables ─────────────────────────── */
.table-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
}
.table-box h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
tbody tr:hover { background: var(--bg-card-hover); }

/* ── Labels / Badges ────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-error { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--accent); }
.badge-purple { background: rgba(168,85,247,0.15); color: var(--purple); }

/* ── Department Sections ───────────────── */
.dept-section { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dept-header { display: flex; align-items: center; gap: 10px; padding: 14px 20px; background: var(--bg-card); cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.dept-header:hover { background: var(--bg); }
.dept-header h3 { font-size: 15px; font-weight: 600; margin: 0; flex: 1; }
.dept-icon { display: flex; align-items: center; color: var(--text-muted); }
.dept-count { font-size: 12px; color: var(--text-muted); }
.dept-toggle { font-size: 12px; color: var(--text-muted); transition: transform 0.2s; }
.dept-section.collapsed .dept-toggle { transform: rotate(-90deg); }
.dept-section.collapsed .dept-body { display: none; }
.dept-section.collapsed .dept-header { border-bottom: none; }
.dept-body { padding: 0; }
.dept-body .workflow-grid { padding: 16px; }
.dept-body .table-box { border: none; border-radius: 0; margin: 0; }

/* ── Workflow Cards ──────────────────── */
.workflow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.workflow-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.workflow-card h4 { font-size: 15px; margin-bottom: 0; }
.workflow-card .schedule { font-size: 13px; color: var(--text-muted); }
.workflow-card .status { margin-top: 12px; }
.workflow-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.workflow-run-btn {
  padding: 4px 12px; font-size: 12px; font-weight: 500; border: none; border-radius: 6px;
  background: var(--accent); color: white; cursor: pointer; white-space: nowrap; transition: opacity 0.2s;
}
.workflow-run-btn:hover { opacity: 0.85; }
.workflow-desc { font-size: 13px; color: var(--text-muted); margin: 4px 0 8px; line-height: 1.4; }
.workflow-last-run { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.workflow-result {
  margin-top: 10px; background: var(--bg); border-radius: 8px;
  border: 1px solid var(--border); font-size: 12px; overflow: hidden;
}
.workflow-result-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; cursor: pointer; user-select: none; font-size: 12px; color: var(--accent);
}
.workflow-result-header:hover { background: var(--border); }
.workflow-result-body {
  display: none; padding: 12px; border-top: 1px solid var(--border);
  line-height: 1.6; color: var(--text); max-height: 400px; overflow-y: auto;
}
.workflow-result.expanded .workflow-result-body { display: block; }
.workflow-result-meta { font-size: 11px; color: var(--text-muted); }
.workflow-execute-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 9px 12px; margin-top: 0;
  font-size: 12px; font-weight: 500; letter-spacing: 0.3px;
  border: none; border-top: 1px solid var(--border);
  background: var(--bg-card); color: var(--accent);
  cursor: pointer; transition: background 0.2s, color 0.2s;
  border-radius: 0 0 8px 8px;
}
.workflow-execute-btn:hover { background: var(--accent); color: white; }
.workflow-execute-btn svg { flex-shrink: 0; }
.action-item {
  padding: 10px; margin-bottom: 8px; background: var(--bg);
  border-radius: 8px; border: 1px solid var(--border); transition: opacity 0.3s;
}
.action-item.action-done { opacity: 0.5; }
.action-item.action-done strong { text-decoration: line-through; color: var(--text-muted); }
.action-item-header { display: flex; justify-content: space-between; align-items: start; }
.action-item-left { display: flex; gap: 8px; align-items: start; }
.action-item-reason { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.action-item-assigned { margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.action-item .workflow-run-btn { margin-top: 6px; }
.action-done-btn { background: var(--green) !important; opacity: 0.7; cursor: default; }
.action-check { flex-shrink: 0; line-height: 1; display: flex; align-items: center; }
.workflow-agents { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.workflow-agent-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  font-size: 11px; color: var(--text-muted);
}
.workflow-agent-badge .agent-icon-sm { width: 14px; height: 14px; }
.workflow-agent-none { font-style: italic; opacity: 0.7; }
.schedule-row { display: flex; align-items: center; gap: 6px; position: relative; }
.schedule-edit-btn {
  background: none; border: none; cursor: pointer; font-size: 13px; padding: 2px 4px;
  opacity: 0.5; transition: opacity 0.2s; line-height: 1;
}
.schedule-edit-btn:hover { opacity: 1; }
.schedule-dropdown {
  display: none; position: absolute; top: 100%; left: 0; z-index: 10;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); padding: 4px 0; margin-top: 4px; min-width: 180px;
}
.schedule-dropdown.open { display: block; }
.schedule-option {
  display: block; width: 100%; text-align: left; padding: 8px 14px; border: none;
  background: none; font-size: 13px; color: var(--text); cursor: pointer; transition: background 0.15s;
}
.schedule-option:hover { background: var(--bg); }

/* ── Filter bar ─────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}
.filter-bar select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
}

/* ── GitHub summary cards ───────────── */
.gh-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

/* ── Empty state ────────────────────── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── Loading ────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
}
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Briefing ───────────────────────── */
.briefing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.briefing-card h3 { font-size: 16px; margin-bottom: 12px; }
.briefing-health {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
}
.briefing-text {
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text);
}
.briefing-issues { margin-top: 16px; }
.briefing-issue {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.briefing-issue:last-child { border-bottom: none; }
.briefing-actions { margin-top: 16px; }
.briefing-action {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.briefing-action:last-child { border-bottom: none; }

/* ── Alerts Banner ──────────────────── */
#alerts-banner {
  margin-bottom: 16px;
}
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item.critical {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--red);
}
.alert-item.warning {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  color: var(--amber);
}
.alert-item.info {
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.3);
  color: var(--accent);
}
.alert-left { display: flex; align-items: center; gap: 10px; }
.alert-icon { font-size: 16px; }
.alert-time { font-size: 11px; opacity: 0.7; margin-left: 8px; }
.alert-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  color: inherit;
}
.alert-dismiss:hover { opacity: 1; }

/* ── Quick Actions ──────────────────── */
.quick-actions {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}
.qa-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.qa-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.qa-btn:hover { background: var(--bg-card-hover); border-color: var(--accent); }
.qa-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.qa-icon { font-size: 24px; display: flex; align-items: center; justify-content: center; color: var(--text); }
.qa-label { font-size: 13px; font-weight: 600; color: var(--text); }
.qa-cost { font-size: 11px; color: var(--text-muted); }
.qa-btn.running { opacity: 0.6; pointer-events: none; border-color: var(--accent); }
.qa-btn.running .qa-label::after { content: '...'; animation: dots 1.2s infinite; }
@keyframes dots { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '...'; } }

/* ── Analysis Result Boxes ──────────── */
.analysis-result-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 16px;
}
.analysis-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.analysis-result-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
}
.analysis-result-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Modal ─────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.modal-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}

/* ── Agent Cell with Icon + Desc ──── */
.agent-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.agent-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.agent-icon svg {
  width: 22px;
  height: 22px;
}
.agent-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}
.agent-icon-sm {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 6px;
}
.agent-icon-sm svg {
  width: 18px;
  height: 18px;
}

/* ── Agent Run Button ──────────────── */
.run-btn {
  background: var(--green);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.run-btn:hover { opacity: 0.85; }
.run-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.badge-sonnet { background: rgba(59,130,246,0.15); color: var(--accent); }
.badge-opus { background: rgba(168,85,247,0.15); color: var(--purple); }

/* ── Schedule Badges ─────────────────── */
.schedule-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin: 1px 0;
  white-space: nowrap;
}
.schedule-scheduled {
  background: rgba(34,197,94,0.12);
  color: var(--green);
}
.schedule-webhook {
  background: rgba(245,158,11,0.12);
  color: var(--amber);
}
.schedule-ondemand {
  background: rgba(100,116,139,0.1);
  color: var(--text-muted);
}
.schedule-badge.schedule-inactive {
  opacity: 0.5;
  text-decoration: line-through;
}

/* ── Instructions Editor ───────────── */
.instructions-editor {
  width: 100%;
  min-height: 200px;
  max-height: 400px;
  padding: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
.instructions-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.instructions-editor::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}
.instructions-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.instructions-badge.has-instructions {
  background: rgba(59,130,246,0.15);
  color: var(--accent);
}
.instructions-badge.has-instructions:hover {
  background: rgba(59,130,246,0.25);
}
.instructions-badge.no-instructions {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px dashed var(--border);
}
.instructions-badge.no-instructions:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Prompt Viewer ────────────────── */
.prompt-section {
  margin-bottom: 8px;
}
.prompt-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s;
  user-select: none;
}
.prompt-section-header:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}
.prompt-section-header.active {
  border-color: var(--accent);
  background: rgba(59,130,246,0.05);
}
.prompt-toggle {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
  width: 14px;
  text-align: center;
}
.prompt-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(100,116,139,0.1);
  color: var(--text-muted);
}
.prompt-badge.editable {
  background: rgba(59,130,246,0.12);
  color: var(--accent);
}
.prompt-section-content {
  margin-top: 4px;
  animation: slideDown 0.2s ease-out;
}
.prompt-viewer {
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  padding: 14px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── AI Builder Form ───────────────── */
.ab-mode-toggle { display: flex; gap: 0; margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ab-mode-btn { flex: 1; padding: 10px; border: none; background: var(--bg); color: var(--text-muted); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.ab-mode-btn.active { background: var(--accent); color: white; }
.ab-mode-btn:hover:not(.active) { background: var(--border); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 13px; font-family: inherit;
  transition: border-color 0.15s; box-sizing: border-box;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-group textarea { resize: vertical; line-height: 1.5; }
.ab-labels { display: flex; flex-wrap: wrap; gap: 10px; }
.ab-label-check { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.ab-label-check input { accent-color: var(--accent); }
.modal-btn-primary {
  padding: 10px 20px; border: none; border-radius: var(--radius);
  background: var(--accent); color: white; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: opacity 0.15s; display: inline-flex; align-items: center; gap: 6px;
}
.modal-btn-primary:hover { opacity: 0.85; }
.modal-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.modal-btn-secondary {
  padding: 10px 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
}
.modal-btn-secondary:hover { background: var(--bg); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }
.ab-success { text-align: center; padding: 32px 24px; }
.ab-success-icon { color: var(--green); margin-bottom: 12px; }
.ab-success h3 { margin: 0 0 4px; }
.ab-links { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.ab-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--accent); font-size: 13px; text-decoration: none; transition: background 0.15s;
}
.ab-link:hover { background: var(--bg); }
/* ── AI Builder Tab ──────────────────── */
.builder-container {
  max-width: 650px; margin: 0 auto;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 32px;
}
.builder-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
.builder-icon { color: var(--accent); flex-shrink: 0; }
.builder-actions { margin-top: 24px; display: flex; justify-content: flex-end; }

/* ── Ticket Badges ────────────────────── */
.ticket-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.ticket-status-open { background: #dbeafe; color: #1d4ed8; }
.ticket-status-in_progress { background: #fef3c7; color: #92400e; }
.ticket-status-waiting_customer { background: #e0e7ff; color: #3730a3; }
.ticket-status-resolved { background: #dcfce7; color: #166534; }
.ticket-status-closed { background: #f1f5f9; color: #64748b; }

.ticket-priority {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.ticket-priority-critical { background: #fecaca; color: #991b1b; }
.ticket-priority-high { background: #fed7aa; color: #9a3412; }
.ticket-priority-medium { background: #fef9c3; color: #854d0e; }
.ticket-priority-low { background: #f1f5f9; color: #64748b; }

.ticket-product {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: #f0f0f0;
  color: #444;
}
.ticket-product-datook-web { background: #dbeafe; color: #1e40af; }
.ticket-product-inpulso { background: #fce7f3; color: #9d174d; }
.ticket-product-bingwa { background: #d1fae5; color: #065f46; }
.ticket-product-dyagnosys { background: #ede9fe; color: #5b21b6; }

/* ── Ticket Conversation ─────────────── */
.ticket-conversation {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding: 8px 0;
}
.ticket-msg {
  padding: 10px 14px;
  border-radius: 10px;
  max-width: 85%;
  font-size: 13px;
  line-height: 1.5;
}
.ticket-msg-customer {
  background: #f1f5f9;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.ticket-msg-ai {
  background: #dbeafe;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.ticket-msg-agent {
  background: #dcfce7;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.ticket-msg-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.ticket-msg-sender {
  font-weight: 600;
  color: var(--text);
}
.ticket-msg-time { font-size: 10px; }
.ticket-msg-body { word-break: break-word; }

/* ── Responsive ─────────────────────── */
@media (max-width: 1024px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr; }
  .workflow-grid { grid-template-columns: repeat(2, 1fr); }
  .gh-cards { grid-template-columns: repeat(2, 1fr); }
  .qa-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .cards { grid-template-columns: 1fr; }
  .workflow-grid { grid-template-columns: 1fr; }
  .gh-cards { grid-template-columns: 1fr; }
  .qa-grid { grid-template-columns: repeat(2, 1fr); }
  .header { flex-direction: column; gap: 12px; }
  .nav-tab { padding: 10px 14px; font-size: 13px; }
  .content { padding: 16px; }
  .modal-box { width: 95%; max-height: 90vh; }
  .filter-bar { flex-wrap: wrap; }
}
