/* ============================================
   CTO Command Center — Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --primary: #5B8BC9;
  --primary-hover: #4A7AB8;
  --dark-bg: #0F1729;
  --card-bg: #1A2332;
  --card-border: #2A3A4E;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --idle: #6B7280;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  --transition: 150ms ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--dark-bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  transition: background var(--transition), opacity var(--transition);
}
button:active { opacity: 0.85; }

input, textarea, select {
  font-family: var(--font);
  font-size: 0.875rem;
  background: var(--dark-bg);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.625rem 0.75rem;
  outline: none;
  transition: border-color var(--transition);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}

/* ---- Login Page ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card .logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
}

.login-card h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.login-card .form-group {
  text-align: left;
  margin-bottom: 1rem;
}

.login-card label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-card input {
  width: 100%;
}

.login-card .btn-primary {
  width: 100%;
  margin-top: 0.5rem;
}

.login-card .error-msg {
  color: var(--error);
  font-size: 0.8125rem;
  margin-top: 0.75rem;
  min-height: 1.25rem;
}

/* ---- Buttons ---- */
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #0ea371; }

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover { background: #dc3030; }

.btn-warning {
  background: var(--warning);
  color: #000;
}
.btn-warning:hover { background: #e09000; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
}
.btn-ghost:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

/* ---- Dashboard Layout ---- */
.dashboard {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

/* Header */
.header {
  grid-column: 1 / -1;
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-left .logo { width: 32px; height: 32px; }

.header-left h1 {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-right .user-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.header-right .user-label strong {
  color: var(--text-primary);
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1.25rem;
  padding: 0.25rem;
}

/* Sidebar */
.sidebar {
  background: var(--card-bg);
  border-right: 1px solid var(--card-border);
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1.25rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  color: var(--text-primary);
  background: rgba(91, 139, 201, 0.05);
}

.sidebar-nav li a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: rgba(91, 139, 201, 0.1);
}

.sidebar-nav li a .nav-icon {
  font-size: 1.125rem;
  width: 1.25rem;
  text-align: center;
}

/* Main Content */
.main-content {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
}

.section { display: none; }
.section.active { display: block; }

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
}

.section-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.25rem;
  max-width: 720px;
}

.section-desc:empty { display: none; }

/* ---- Overview Section ---- */
.overview-banner {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.overview-banner .org-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.overview-banner .org-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 800px;
}

.overview-roster-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
}

.overview-roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.625rem;
  margin-bottom: 1.5rem;
}

.roster-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
}

.roster-card .roster-icon {
  font-size: 1.25rem;
  margin-top: 0.125rem;
}

.roster-card .roster-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.roster-card .roster-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
  line-height: 1.5;
}

.roster-card .roster-status {
  margin-top: 0.25rem;
}

.overview-guide {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.625rem;
}

.guide-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
}

.guide-card .guide-label {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.guide-card .guide-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Cards ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color var(--transition);
}
.card:hover { border-color: rgba(91, 139, 201, 0.3); }

/* ---- Agent Cards Grid ---- */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.agent-card {
  position: relative;
}

.agent-card .agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.agent-card .agent-name {
  font-size: 1rem;
  font-weight: 700;
}

.agent-card .agent-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

.agent-card .agent-meta {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.agent-card .agent-meta .meta-row {
  display: flex;
  justify-content: space-between;
}

.agent-card .agent-meta .meta-label { color: var(--text-secondary); }
.agent-card .agent-meta .meta-value { color: var(--text-primary); }

.agent-card .agent-actions {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--card-border);
}

/* ---- Status Badge ---- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  text-transform: capitalize;
}

.status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-badge.working { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-badge.working .dot { background: var(--warning); animation: pulse 2s infinite; }
.status-badge.idle { background: rgba(107,114,128,0.15); color: var(--idle); }
.status-badge.idle .dot { background: var(--idle); }
.status-badge.error { background: rgba(239,68,68,0.15); color: var(--error); }
.status-badge.error .dot { background: var(--error); }
.status-badge.offline { background: rgba(239,68,68,0.1); color: #9CA3AF; }
.status-badge.offline .dot { background: #9CA3AF; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Type Badges ---- */
.type-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.type-badge.commit { background: rgba(91,139,201,0.15); color: var(--primary); }
.type-badge.test { background: rgba(16,185,129,0.15); color: var(--success); }
.type-badge.deploy { background: rgba(139,92,246,0.15); color: #8B5CF6; }
.type-badge.scrape { background: rgba(245,158,11,0.15); color: var(--warning); }
.type-badge.idea { background: rgba(236,72,153,0.15); color: #EC4899; }
.type-badge.error { background: rgba(239,68,68,0.15); color: var(--error); }
.type-badge.observe { background: rgba(99,102,241,0.15); color: #6366F1; }
.type-badge.pr { background: rgba(91,139,201,0.15); color: var(--primary); }
.type-badge.escalation { background: rgba(239,68,68,0.15); color: var(--error); }
.type-badge.directive { background: rgba(139,92,246,0.15); color: #8B5CF6; }

/* ---- Activity Feed ---- */
.activity-filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.activity-filters select {
  min-width: 160px;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  animation: fadeIn 0.3s ease;
}

.activity-item .activity-icon {
  font-size: 1rem;
  margin-top: 0.125rem;
}

.activity-item .activity-body { flex: 1; min-width: 0; }

.activity-item .activity-agent {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--primary);
}

.activity-item .activity-msg {
  font-size: 0.8125rem;
  color: var(--text-primary);
  margin-top: 0.125rem;
}

.activity-item .activity-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-top: 0.125rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Decision Cards ---- */
.decisions-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.decisions-tabs button {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
}

.decisions-tabs button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.decisions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.decision-card .decision-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.decision-card .decision-title {
  font-size: 0.9375rem;
  font-weight: 600;
}

.decision-card .decision-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.decision-card .decision-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.decision-card .decision-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.decision-card .decision-resolved {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  margin-top: 0.5rem;
}

.decision-card .decision-resolved.approved { background: rgba(16,185,129,0.1); color: var(--success); }
.decision-card .decision-resolved.rejected { background: rgba(239,68,68,0.1); color: var(--error); }
.decision-card .decision-resolved.deferred { background: rgba(245,158,11,0.1); color: var(--warning); }

/* ---- Health Metrics ---- */
.health-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.health-header input[type="date"] {
  background: var(--card-bg);
}

.health-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.health-stat {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.health-stat .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.health-stat .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.health-agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.health-agent-card .agent-name {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
}

.bar-row .bar-label {
  width: 80px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.bar-row .bar-track {
  flex: 1;
  height: 8px;
  background: var(--dark-bg);
  border-radius: 4px;
  overflow: hidden;
}

.bar-row .bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.bar-fill.green { background: var(--success); }
.bar-fill.amber { background: var(--warning); }
.bar-fill.red { background: var(--error); }

.bar-row .bar-value {
  width: 40px;
  text-align: right;
  font-weight: 600;
  font-size: 0.75rem;
}

/* ---- Observer Reports ---- */
.observer-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.observer-card .observer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.observer-card .observer-date {
  font-weight: 700;
  font-size: 1rem;
}

.observer-card .trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.trend.up { color: var(--success); }
.trend.stable { color: var(--text-secondary); }
.trend.down { color: var(--error); }

.observer-card .observer-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.score-item {
  text-align: center;
  padding: 0.5rem;
  background: var(--dark-bg);
  border-radius: var(--radius);
}

.score-item .score-agent {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.score-item .score-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.score-value.high { color: var(--success); }
.score-value.mid { color: var(--warning); }
.score-value.low { color: var(--error); }

.recommendations {
  margin-top: 0.5rem;
}

.recommendations h4 {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.recommendations ul {
  list-style: none;
  font-size: 0.8125rem;
}

.recommendations li {
  padding: 0.25rem 0;
  padding-left: 1rem;
  position: relative;
  color: var(--text-secondary);
}

.recommendations li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--primary);
}

/* ---- Restore Points ---- */
.restore-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.restore-card .restore-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.restore-card .restore-week {
  font-weight: 700;
  font-size: 1rem;
}

.restore-card .restore-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.restore-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.375rem;
  font-size: 0.8125rem;
}

.restore-details .detail-item {
  display: flex;
  gap: 0.375rem;
}

.restore-details .detail-label {
  color: var(--text-secondary);
}

.restore-details .detail-value {
  color: var(--text-primary);
  font-weight: 500;
  font-family: monospace;
}

.restore-card .restore-notes {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ---- Directive Form ---- */
.directive-form {
  max-width: 600px;
}

.directive-form .form-group {
  margin-bottom: 1rem;
}

.directive-form label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.directive-form select,
.directive-form textarea {
  width: 100%;
}

.directive-form textarea {
  min-height: 120px;
  resize: vertical;
}

.directive-form .form-actions {
  display: flex;
  gap: 0.5rem;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
  max-width: 360px;
}

.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--error); color: #fff; }
.toast.info { background: var(--primary); color: #fff; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ---- Loading ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--card-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Agent Chat ---- */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px - 7rem);
  min-height: 400px;
}

.chat-agent-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.chat-agent-selector label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.chat-agent-selector select {
  min-width: 200px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  background: var(--dark-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 80%;
  animation: fadeIn 0.3s ease;
}

.chat-message.cto {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.agent {
  align-self: flex-start;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.cto-avatar {
  background: var(--primary);
  color: #fff;
}

.agent-avatar {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  font-size: 1rem;
}

.chat-bubble {
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  line-height: 1.6;
  word-break: break-word;
}

.cto-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.agent-bubble {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.agent-bubble code {
  background: rgba(91, 139, 201, 0.15);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.8125rem;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 2rem;
  color: var(--text-secondary);
}

.chat-welcome-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.chat-welcome h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

.chat-welcome p {
  font-size: 0.875rem;
  max-width: 360px;
}

.chat-typing .typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  margin: 0 2px;
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-bar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.chat-input-bar input {
  flex: 1;
}

.chat-input-bar .btn-primary {
  flex-shrink: 0;
}

/* ---- Alerts ---- */
/* Watchdog status bar */
.watchdog-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  color: var(--text-secondary);
}

.watchdog-status.stale {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.2);
}

.watchdog-status strong {
  color: var(--text-primary);
}

.watchdog-detail {
  margin-left: 0.25rem;
}

.watchdog-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.watchdog-dot.healthy {
  background: var(--success);
  box-shadow: 0 0 6px rgba(16,185,129,0.5);
}

.watchdog-dot.stale {
  background: var(--error);
  box-shadow: 0 0 6px rgba(239,68,68,0.5);
}

.watchdog-run-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.watchdog-run-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.alerts-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.alerts-tabs button {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
}

.alerts-tabs button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.alert-card {
  border-left: 4px solid var(--card-border);
}

.alert-card.critical { border-left-color: var(--error); }
.alert-card.high { border-left-color: #F97316; }
.alert-card.medium { border-left-color: var(--warning); }

.alert-card.resolved { opacity: 0.6; }

.alert-card-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.alert-agent {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.alert-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.alert-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.alert-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.btn-fix-it {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.2s ease;
}
.btn-fix-it:hover {
  background: #4a7ab8;
}

.alert-resolved-label,
.alert-ack-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

.severity-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  letter-spacing: 0.05em;
}

.severity-badge.critical { background: rgba(239,68,68,0.15); color: var(--error); }
.severity-badge.high { background: rgba(249,115,22,0.15); color: #F97316; }
.severity-badge.medium { background: rgba(245,158,11,0.15); color: var(--warning); }

.alert-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9999px;
  background: var(--error);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  margin-left: auto;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    border-right: none;
  }

  .sidebar.open {
    display: block;
  }

  .mobile-menu-btn {
    display: block;
  }

  .main-content {
    padding: 1rem;
    max-height: calc(100vh - 56px);
  }

  .agents-grid {
    grid-template-columns: 1fr;
  }

  .health-agents-grid {
    grid-template-columns: 1fr;
  }

  .scores-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
}

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