/* ============================================
   Dashboard Layout
   ============================================ */
.dashboard-body { background: var(--bg); }

.dash-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.dash-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
}
.dash-nav-center { flex: 1; text-align: center; }
.dash-app-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.dash-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dash-tier {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(99,102,241,0.1);
  color: var(--primary-light);
}

.dash-layout {
  display: flex;
  padding-top: 56px;
  min-height: 100vh;
}

/* Sidebar */
.dash-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-light);
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
}
.dash-sidebar-nav { padding: 12px 8px; }
.dash-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
  margin-bottom: 2px;
}
.dash-nav-item:hover {
  color: var(--text);
  background: var(--bg-card);
}
.dash-nav-item.active {
  color: var(--primary-light);
  background: rgba(99,102,241,0.08);
}
.dash-nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}
.dash-nav-item.active svg { opacity: 1; }

/* Main Content */
.dash-main {
  flex: 1;
  margin-left: 220px;
  padding: 24px 32px;
  max-width: 1200px;
}
.dash-section { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.dash-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.dash-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Form Elements */
.dash-select, .dash-input, .dash-textarea {
  font-family: var(--font);
  font-size: 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.dash-select:focus, .dash-input:focus, .dash-textarea:focus {
  border-color: var(--primary);
}
.dash-textarea { width: 100%; resize: vertical; }
.dash-color {
  width: 48px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 2px;
}
.form-group {
  margin-bottom: 16px;
  flex: 1;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-group .dash-input,
.form-group .dash-select {
  width: 100%;
}
.form-row {
  display: flex;
  gap: 16px;
}

/* Metric Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.metric-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.metric-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--primary);
  transition: width 0.5s ease;
}

/* Panels */
.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}
.panel-body {
  padding: 16px 20px;
}

/* Tables */
.dash-table {
  width: 100%;
  border-collapse: collapse;
}
.dash-table th, .dash-table td {
  padding: 10px 12px;
  text-align: left;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-light);
}
.dash-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dash-table td { color: var(--text-secondary); }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr:hover td { background: rgba(99,102,241,0.03); }

/* Status Badges */
.status-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-active { background: rgba(16,185,129,0.1); color: #10b981; }
.status-resolved { background: rgba(99,102,241,0.1); color: #818cf8; }
.status-escalated { background: rgba(245,158,11,0.1); color: #f59e0b; }
.status-abandoned { background: rgba(107,114,128,0.1); color: #6b7280; }
.status-new { background: rgba(59,130,246,0.1); color: #3b82f6; }
.status-contacted { background: rgba(245,158,11,0.1); color: #f59e0b; }
.status-qualified { background: rgba(16,185,129,0.1); color: #10b981; }
.status-converted { background: rgba(99,102,241,0.1); color: #818cf8; }
.status-lost { background: rgba(239,68,68,0.1); color: #ef4444; }
.status-open { background: rgba(59,130,246,0.1); color: #3b82f6; }
.status-pending { background: rgba(245,158,11,0.1); color: #f59e0b; }
.status-delivered { background: rgba(16,185,129,0.1); color: #10b981; }
.status-failed { background: rgba(239,68,68,0.1); color: #ef4444; }
.status-dead_letter { background: rgba(239,68,68,0.2); color: #ef4444; }

.priority-low { color: #6b7280; }
.priority-medium { color: #f59e0b; }
.priority-high { color: #ef4444; }
.priority-critical { color: #ef4444; font-weight: 700; }

/* Login */
.login-card {
  max-width: 400px;
  margin: 80px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
}
.login-card h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.login-card > p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.login-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 16px;
}
.login-note a { color: var(--primary-light); }
.login-error {
  margin-top: 12px;
  padding: 10px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 6px;
  color: #ef4444;
  font-size: 0.85rem;
}

/* Integrations */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.integration-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.integration-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-light);
  margin-bottom: 12px;
}
.integration-card h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; }
.integration-card p { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 20px; }

.loading {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Code block override for dashboard */
.dash-panel .code-block {
  margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .dash-sidebar { display: none; }
  .dash-main { margin-left: 0; padding: 16px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; gap: 0; }
}
