/* =============================================
   FSB Showcase - Dashboard Styles
   All classes prefixed with dash- to avoid conflicts
   ============================================= */

/* --- Login Section --- */
.dash-login-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height) - 200px);
  padding-top: calc(var(--nav-height) + 40px);
}

.dash-login-card {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
}

.dash-login-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 107, 53, 0.1);
  border-radius: 50%;
  font-size: 1.5rem;
  color: var(--primary);
}

.dash-login-card h2 {
  margin-bottom: 12px;
}

.dash-login-card > p {
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.dash-login-form {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.dash-input:focus {
  border-color: var(--primary);
}

.dash-input::placeholder {
  color: var(--text-muted);
}

.dash-login-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dash-login-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 8px;
}

/* --- Dashboard Content --- */
.dash-content-section {
  padding-top: calc(var(--nav-height) + 24px);
  min-height: 100vh;
}

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.dash-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dash-header-left h2 {
  margin: 0;
}

.dash-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(255, 107, 53, 0.1);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.dash-sse-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.dash-sse-connected {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.dash-sse-disconnected {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.dash-sse-reconnecting {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

/* --- Stats Bar --- */
.dash-stats-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.dash-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.dash-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.dash-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

/* --- Agent Grid --- */
.dash-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dash-agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition-base);
}

.dash-agent-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.dash-agent-card.selected {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.dash-agent-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-agent-task {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dash-agent-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 12px;
}

.dash-agent-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dash-agent-schedule {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
}

.dash-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.dash-status-enabled {
  background: #22c55e;
}

.dash-status-disabled {
  background: #64748b;
}

.dash-replay-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

/* --- Runs Panel --- */
.dash-runs-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}

.dash-runs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.dash-runs-header h3 {
  margin: 0;
  font-size: 1rem;
}

.dash-runs-close {
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.dash-runs-close:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.dash-runs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-run-entry {
  display: grid;
  grid-template-columns: 140px 80px 90px 1fr 80px 80px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.dash-run-time {
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
  font-size: 0.78rem;
}

.dash-run-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.dash-run-status-success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.dash-run-status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.dash-run-status-unknown {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.dash-mode-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.72rem;
}

.dash-mode-replay {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.dash-mode-ai {
  background: rgba(255, 107, 53, 0.1);
  color: var(--primary);
}

.dash-mode-fallback {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

.dash-run-result {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-run-duration {
  color: var(--text-muted);
  text-align: right;
  font-family: 'SF Mono', monospace;
  font-size: 0.78rem;
}

.dash-run-cost {
  color: var(--text-muted);
  text-align: right;
  font-family: 'SF Mono', monospace;
  font-size: 0.78rem;
}

.dash-runs-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.dash-runs-pagination button {
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dash-runs-pagination button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.dash-runs-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Empty State --- */
.dash-empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.dash-empty i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.dash-empty p {
  font-size: 0.95rem;
}

/* --- Loading spinner --- */
.dash-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: dash-spin 0.6s linear infinite;
}

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

/* --- Task Control Area --- */
.dash-task-area {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.dash-task-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dash-task-input {
  flex: 1;
  padding: 8px 16px;
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.dash-task-input:focus {
  border-color: var(--primary);
}

.dash-task-input::placeholder {
  color: var(--text-muted);
}

.dash-task-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dash-task-submit {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: 1rem;
  padding: 0;
}

.dash-task-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Progress view */
.dash-task-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 8px;
}

.dash-task-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.dash-task-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.dash-task-bar-fill {
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  min-width: 0;
  transition: width 300ms ease, background 300ms ease;
}

.dash-task-bar-fill.dash-task-bar-success {
  background: #22c55e;
}

.dash-task-bar-fill.dash-task-bar-failed {
  background: #ef4444;
}

.dash-task-percent {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  min-width: 36px;
  text-align: right;
}

.dash-task-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.dash-task-phase {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
}

.dash-task-eta,
.dash-task-elapsed {
  font-size: 12px;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  color: var(--text-muted);
}

.dash-task-action {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-task-action::before {
  content: '> ';
  color: var(--primary);
  font-weight: 600;
}

.dash-task-stop-btn {
  margin-top: 12px;
  padding: 6px 16px;
  border: 1px solid var(--danger, #ef4444);
  color: var(--danger, #ef4444);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.dash-task-stop-btn:hover {
  background: var(--danger, #ef4444);
  color: #fff;
}

/* Success state */
.dash-task-status {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.dash-task-status-success {
  color: #22c55e;
}

.dash-task-status-failed {
  color: #ef4444;
}

.dash-task-result {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.dash-task-error {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.dash-task-retry-row {
  margin-top: 12px;
}

.dash-task-retry:hover {
  color: #ef4444;
  border-color: #ef4444;
}

.dash-task-input-again {
  margin-top: 16px;
}

/* Offline state */
.dash-task-offline .dash-task-input {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Transition animations */
.dash-task-progress,
.dash-task-result-view {
  animation: dashTaskFadeIn 200ms ease;
}

@keyframes dashTaskFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Toggle Switch --- */
.dash-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #64748b;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 150ms ease;
  flex-shrink: 0;
}

.dash-toggle[aria-checked="true"] {
  background: var(--primary);
}

.dash-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 150ms ease;
}

.dash-toggle[aria-checked="true"]::after {
  transform: translateX(16px);
}

/* --- Enhanced Agent Card --- */
.dash-agent-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.dash-agent-card.dash-agent-disabled {
  opacity: 0.5;
}

.dash-agent-card-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.dash-agent-success-rate {
  font-size: 0.8rem;
  font-weight: 600;
}

.dash-agent-cost-saved {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

.dash-agent-last-run {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dash-agent-card-highlight {
  animation: dashCardHighlight 1000ms ease-out;
}

@keyframes dashCardHighlight {
  from { border-color: var(--primary); }
  to { border-color: var(--border-color); }
}

.dash-agent-running-icon {
  margin-left: 4px;
}

/* --- Agent Container (Grid + Detail) --- */
.dash-agent-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.dash-agent-container.dash-detail-open {
  grid-template-columns: 1fr 420px;
}

/* --- Agent Detail Panel --- */
.dash-agent-detail {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

.dash-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.dash-detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.dash-detail-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.dash-detail-actions {
  display: flex;
  gap: 8px;
}

.dash-detail-close {
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dash-detail-close:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.dash-detail-section {
  padding: 16px 0;
  border-top: 1px solid var(--border-color);
}

.dash-detail-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 12px 0;
}

.dash-detail-config {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dash-detail-value {
  font-size: 0.9rem;
  color: var(--text-secondary);
  word-break: break-word;
}

.dash-detail-mono {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.82rem;
}

/* Cost Savings Grid */
.dash-detail-cost-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dash-detail-cost-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.dash-detail-cost-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.dash-detail-cost-highlight {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  color: #22c55e;
}

.dash-detail-cost-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

/* Run Now Progress */
.dash-detail-run-progress {
  padding: 12px 0;
}

.dash-detail-run-action {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 8px;
  display: block;
}

/* Run History in Detail Panel */
.dash-detail-runs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Recorded Script */
.dash-detail-script-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.dash-detail-script-toggle i {
  transition: transform 200ms ease;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dash-detail-script-toggle.expanded i {
  transform: rotate(90deg);
}

.dash-detail-script-content {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.dash-detail-script-list {
  margin: 0;
  padding-left: 24px;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Delete Button */
.dash-detail-footer {
  padding: 16px 0 0;
  border-top: 1px solid var(--border-color);
}

.dash-btn-delete {
  width: 100%;
  color: #ef4444;
  border-color: #ef4444;
}

.dash-btn-delete:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* --- Modal --- */
.dash-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: dashModalFadeIn 200ms ease;
}

@keyframes dashModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dash-agent-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.dash-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.dash-modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.dash-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-modal-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.dash-textarea {
  resize: vertical;
  min-height: 72px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.dash-input-mono {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

.dash-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.dash-modal-field .dash-field-error {
  font-size: 0.8rem;
  color: #ef4444;
  margin-top: 4px;
}

.dash-modal-field .dash-input.dash-input-error {
  border-color: #ef4444;
}

/* --- Schedule Configuration --- */
.dash-schedule-type-row {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.dash-schedule-pill {
  flex: 1;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all 150ms ease;
}

.dash-schedule-pill:not(:last-child) {
  border-right: 1px solid var(--border-color);
}

.dash-schedule-pill.active {
  background: var(--primary);
  color: white;
}

.dash-schedule-config {
  margin-top: 12px;
}

.dash-schedule-interval-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-schedule-interval-input {
  width: 80px;
  text-align: center;
}

.dash-schedule-interval-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dash-schedule-snap-msg {
  font-size: 0.8rem;
  color: #eab308;
  margin-top: 4px;
  transition: opacity 2000ms ease;
}

.dash-day-pills {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.dash-day-pill {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all 150ms ease;
}

.dash-day-pill[aria-checked="true"] {
  background: var(--primary);
  color: white;
}

/* --- Delete Confirmation --- */
.dash-delete-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.dash-delete-dialog h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.dash-delete-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.dash-delete-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.dash-btn-delete-confirm {
  background: #ef4444;
  color: white;
  border: 1px solid #ef4444;
}

.dash-btn-delete-confirm:hover {
  background: #dc2626;
}

/* --- Post-Task Save as Agent --- */
.dash-task-save-agent {
  border-top: 1px solid var(--border-color);
  margin-top: 16px;
  padding-top: 12px;
}

.dash-save-agent-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 0;
  transition: color var(--transition-fast);
}

.dash-save-agent-trigger:hover {
  color: var(--text-secondary);
}

.dash-save-agent-trigger i {
  font-size: 0.7rem;
  transition: transform 200ms ease;
}

.dash-save-agent-trigger.expanded i {
  transform: rotate(180deg);
}

.dash-save-agent-fields {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 200ms ease;
}

.dash-save-agent-fields.dash-save-expanded {
  max-height: 400px;
  display: flex;
}

.dash-save-agent-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.dash-save-agent-actions {
  display: flex;
  justify-content: flex-end;
}

/* --- New Agent Button --- */
.dash-new-agent-btn {
  margin-left: 8px;
}

/* --- Screen Reader Only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .dash-stats-bar {
    grid-template-columns: repeat(3, 1fr);
  }

  .dash-agent-container.dash-detail-open {
    grid-template-columns: 1fr;
  }

  .dash-agent-detail {
    position: fixed;
    right: 0;
    top: var(--nav-height, 64px);
    height: calc(100vh - var(--nav-height, 64px));
    width: 420px;
    max-height: none;
    z-index: 100;
    border-radius: 0;
    border-left: 1px solid var(--border-color);
    animation: dashDetailSlideIn 250ms ease;
  }

  @keyframes dashDetailSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
  }
}

@media (max-width: 768px) {
  .dash-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-agent-grid {
    grid-template-columns: 1fr;
  }

  .dash-run-entry {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .dash-login-form {
    flex-direction: column;
  }

  .dash-login-card {
    padding: 32px 24px;
  }

  .dash-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dash-task-meta {
    flex-wrap: wrap;
  }

  .dash-agent-detail {
    width: 100%;
  }

  .dash-agent-modal {
    max-width: none;
    margin: 16px;
    border-radius: var(--radius-lg);
  }

  .dash-day-pill {
    width: 28px;
    height: 28px;
  }

  .dash-detail-cost-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dash-qr-reader {
    width: 100%;
    max-width: 280px;
    height: auto;
    aspect-ratio: 1;
  }

  .dash-login-form .btn {
    width: 100%;
  }

  .dash-tab {
    padding: 8px 16px;
  }

  .dash-header-left {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dash-disconnect-label {
    display: none;
  }

  .dash-disconnect-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }

  .dash-login-section {
    min-height: auto;
    padding-top: calc(var(--nav-height) + 24px);
    padding-bottom: 40px;
  }
}

@media (max-width: 480px) {
  .dash-stats-bar {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .dash-stat-card {
    padding: 12px;
  }

  .dash-stat-value {
    font-size: 1.2rem;
  }

  .dash-task-area {
    padding: 16px;
  }

  .dash-agent-grid {
    grid-template-columns: 1fr;
  }

  .dash-login-card {
    padding: 24px 16px;
  }

  .dash-tab {
    padding: 6px 12px;
    font-size: 11px;
  }

  .dash-stat-label {
    font-size: 0.7rem;
  }

  .dash-login-icon {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }

  .dash-header-left h2 {
    font-size: 1.25rem;
  }

  .dash-badge,
  .dash-sse-badge,
  .dash-paired-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
  }
}

/* --- Tabbed Login Card --- */
.dash-login-tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.dash-tab {
  padding: 8px 24px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}

.dash-tab:hover {
  color: var(--text-secondary);
}

.dash-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--primary);
}

.dash-tab-content {
  min-height: 280px;
}

/* QR Reader / Camera Viewfinder */
.dash-qr-reader {
  width: 250px;
  height: 250px;
  margin: 16px auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px dashed var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-scan-instruction {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.dash-scan-error {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* Paired Badge */
.dash-paired-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  border-radius: 999px;
  white-space: nowrap;
}

/* Disconnect button hover → destructive red */
.dash-disconnect-btn:hover {
  color: #ef4444 !important;
  border-color: #ef4444 !important;
}

/* Login message (session expired, connection errors) */
.dash-login-message {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.dash-login-message.expired {
  color: var(--text-secondary);
}

/* Transition animations */
.dash-login-section {
  transition: opacity 400ms ease;
}

.dash-content-section {
  transition: opacity 400ms ease;
}

.dash-login-section.fade-out {
  opacity: 0;
  pointer-events: none;
}

.dash-content-section.fade-in {
  opacity: 1;
}

.dash-content-section.fade-dim {
  opacity: 0.5;
  pointer-events: none;
}

/* --- Live DOM Preview --- */
.dash-preview {
  position: relative;
  width: 100%;
  min-height: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  animation: dashTaskFadeIn 200ms ease;
  transition: box-shadow 300ms ease, border-color 300ms ease;
}

.dash-preview-automating {
  border-color: rgba(255, 140, 0, 0.6);
  box-shadow: 0 0 12px rgba(255, 140, 0, 0.4), 0 0 24px rgba(255, 140, 0, 0.2);
  animation: dashPreviewAutomate 2s ease-in-out infinite;
}

@keyframes dashPreviewAutomate {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 140, 0, 0.4), 0 0 24px rgba(255, 140, 0, 0.2); border-color: rgba(255, 140, 0, 0.5); }
  50% { box-shadow: 0 0 20px rgba(255, 140, 0, 0.6), 0 0 40px rgba(255, 140, 0, 0.3); border-color: rgba(255, 140, 0, 0.8); }
}

.dash-preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
  background: white;
  transform-origin: top left;
}

.dash-preview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  z-index: 2;
}

.dash-preview-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 5;
  display: none;
  flex-shrink: 0;
}

.dash-preview-status-streaming {
  background: #22c55e;
  display: block;
  animation: dashPreviewPulse 2000ms ease-in-out infinite;
}

.dash-preview-status-buffering {
  background: #eab308;
  display: block;
  animation: dashPreviewPulse 1000ms ease-in-out infinite;
}

.dash-preview-status-disconnected {
  background: #ef4444;
  display: block;
}

.dash-preview-status-paused {
  background: #6b7280;
  display: block;
}

@keyframes dashPreviewPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.dash-preview-glow {
  position: absolute;
  border: 3px solid #FF8C00;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(255, 140, 0, 0.6);
  background: transparent;
  pointer-events: none;
  z-index: 3;
  transition: top 100ms ease, left 100ms ease, width 100ms ease, height 100ms ease;
}

.dash-preview-progress {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: var(--radius-md);
  padding: 8px 8px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  pointer-events: none;
  z-index: 4;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dash-preview-disconnected {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-primary);
  font-size: 14px;
  z-index: 6;
}

.dash-preview-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 2;
}

.dash-preview-error i {
  font-size: 24px;
  color: var(--text-muted);
}

.dash-preview-error p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.dash-preview-error span {
  font-size: 12px;
  color: var(--text-muted);
}

.dash-preview-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  z-index: 10;
  pointer-events: none;
}

.dash-preview-status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.dash-preview-tooltip {
  display: none !important;
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.75);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dash-preview-status-wrap:hover .dash-preview-tooltip {
  display: block !important;
}

.dash-preview-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
}

.dash-preview-btn,
.dash-preview-toggle {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: var(--text-primary);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  opacity: 0;
  transition: opacity 150ms ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dash-preview:hover .dash-preview-btn,
.dash-preview:hover .dash-preview-toggle {
  opacity: 1;
}

.dash-preview-btn:hover,
.dash-preview-toggle:hover {
  background: rgba(0, 0, 0, 0.7);
}

/* Responsive: mobile */
@media (max-width: 768px) {
  .dash-preview {
    min-height: 200px;
  }
}

@media (max-width: 480px) {
  .dash-preview {
    min-height: 200px;
  }
  .dash-preview-progress {
    display: none;
  }
}

/* --- Layout Mode: Maximized --- */
.dash-preview-maximized {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100 !important;
  min-height: 100vh !important;
  border-radius: 0 !important;
  margin: 0 !important;
  border: none !important;
}

.dash-preview-maximized .dash-preview-btn {
  opacity: 1;
}

.dash-preview-maximized ~ .dash-task-progress,
.dash-preview-maximized ~ .dash-stats-bar {
  display: none;
}

body.dash-layout-maximized #dash-task-progress {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  border-radius: 0;
}

/* --- Layout Mode: PiP (stub for Plan 02) --- */
.dash-preview-pip {
  position: fixed !important;
  bottom: 16px !important;
  right: 16px !important;
  width: 400px !important;
  min-height: auto !important;
  z-index: 50 !important;
  border-radius: var(--radius-lg) !important;
  resize: both !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
}

.dash-preview-pip .dash-preview-btn {
  opacity: 1;
}

.dash-preview-pip .dash-preview-header {
  cursor: grab;
}

/* --- Layout Mode: Fullscreen --- */
.dash-preview:fullscreen {
  background: #000;
}
.dash-preview:fullscreen .dash-preview-iframe {
  transform-origin: center center;
}
.dash-preview:fullscreen .dash-preview-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
}

/* --- Fullscreen Exit Overlay --- */
.dash-preview-fs-exit {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: auto;
}

.dash-preview:fullscreen .dash-preview-fs-exit {
  display: block;
}

.dash-preview-fs-exit-btn {
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dash-preview-fs-exit-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

