/* ============================================================
   Asset Generator Web UI — Matches Joyia Web Testing UI theme
   Uses oklch-equivalent hex values from packages/web dark mode
   ============================================================ */

:root {
  /* Color palette — matched to packages/web dark theme */
  --bg-primary: #09090b;         /* oklch(0.145 0 0) — page background */
  --bg-secondary: #18181b;       /* slightly lighter for sections */
  --bg-tertiary: #27272a;        /* oklch(0.269 0 0) — muted bg */
  --bg-card: #1c1c1f;            /* oklch(0.205 0 0) — card surface */
  --bg-card-hover: #242428;      /* card hover */
  --bg-input: #111113;           /* input fields */
  --bg-glass: rgba(28, 28, 31, 0.8);

  --border-primary: rgba(255, 255, 255, 0.1);   /* oklch(1 0 0 / 10%) */
  --border-secondary: rgba(255, 255, 255, 0.15);
  --border-focus: #a78bfa;       /* violet-400 */

  --text-primary: #fafafa;       /* oklch(0.985 0 0) */
  --text-secondary: #a1a1aa;     /* oklch(0.708 0 0) — muted-foreground */
  --text-muted: #71717a;         /* zinc-500 */
  --text-accent: #a78bfa;        /* violet-400 */

  --accent-primary: #8b5cf6;     /* violet-500 — matches testing pages */
  --accent-secondary: #a78bfa;   /* violet-400 */
  --accent-glow: rgba(139, 92, 246, 0.15);

  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.08);
  --info: #14b8a6;               /* teal-500 — matches testing pages */
  --info-bg: rgba(20, 184, 166, 0.08);

  /* Spacing — matched to shadcn defaults */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ── Reset & Base ──────────────────────────────────────── */

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────── */

.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

/* ── Header ────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(99, 102, 241, 0.05), rgba(59, 130, 246, 0.05));
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.app-title .logo-box {
  padding: 8px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(99, 102, 241, 0.15));
  border-radius: var(--radius-md);
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.app-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ── Tab Navigation ────────────────────────────────────── */

.tab-nav {
  display: flex;
  gap: 2px;
  background: var(--bg-secondary);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 200ms ease;
}

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

/* ── Cards ─────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 0 rgba(255, 255, 255, 0.03);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  border-color: var(--border-secondary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 16px;
}

/* ── Form Elements ─────────────────────────────────────── */

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.5;
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Chip Selectors ────────────────────────────────────── */

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--border-primary);
  border-radius: 20px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.chip:hover {
  border-color: var(--border-secondary);
  color: var(--text-primary);
}

.chip.selected {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* ── Toggle Switch ─────────────────────────────────────── */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.toggle-label {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle.active::after {
  transform: translateX(20px);
}

/* ── Buttons ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--text-secondary);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}

.btn-secondary:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-secondary);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ── Spec Preview ──────────────────────────────────────── */

.spec-preview {
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent-secondary);
  word-break: break-all;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.spec-preview .placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-family: inherit;
}

/* ── Number Input ──────────────────────────────────────── */

.number-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.number-input .form-input {
  width: 80px;
  text-align: center;
}

/* ── Inline Grid ───────────────────────────────────────── */

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ── Spec List ─────────────────────────────────────────── */

.spec-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
}

.spec-item code {
  flex: 1;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent-secondary);
}

.spec-item .btn-remove {
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
}

.spec-item .btn-remove:hover {
  color: var(--error);
}

/* ── Progress Stream ───────────────────────────────────── */

.progress-container {
  display: none;
  margin-bottom: 20px;
}

.progress-container.visible {
  display: block;
  animation: fadeIn 200ms ease;
}

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

.progress-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.progress-timer {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all var(--transition-fast);
}

.progress-step .step-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.progress-step .step-text {
  flex: 1;
  color: var(--text-secondary);
}

.progress-step .step-status {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-step.pending .step-icon { color: var(--text-muted); }
.progress-step.active .step-icon { color: var(--accent-primary); }
.progress-step.active .step-text { color: var(--text-primary); }
.progress-step.active { background: var(--accent-glow); }
.progress-step.completed .step-icon { color: var(--success); }
.progress-step.completed .step-text { color: var(--text-secondary); }
.progress-step.failed .step-icon { color: var(--error); }
.progress-step.failed .step-text { color: var(--error); }

/* Pulsing animation for active step */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.progress-step.active .step-icon {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ── Results ───────────────────────────────────────────── */

.results-container {
  display: none;
}

.results-container.visible {
  display: block;
  animation: fadeIn 200ms ease;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  transition: border-color var(--transition-normal);
}

.result-card.success {
  border-left: 3px solid var(--success);
}

.result-card.error {
  border-left: 3px solid var(--error);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.result-header:hover {
  background: var(--bg-card-hover);
}

.result-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-status {
  font-size: 16px;
}

.result-spec {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-primary);
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-badge.success {
  background: var(--success-bg);
  color: var(--success);
}

.result-badge.error {
  background: var(--error-bg);
  color: var(--error);
}

.result-badge.deleted {
  background: rgba(100, 116, 139, 0.1);
  color: var(--text-muted);
}

.result-badge.unpublished {
  background: var(--warning-bg);
  color: var(--warning);
}

.result-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border-primary);
}

.result-card.expanded .result-body {
  display: block;
}

.result-expand-icon {
  transition: transform var(--transition-fast);
  color: var(--text-muted);
}

.result-card.expanded .result-expand-icon {
  transform: rotate(180deg);
}

/* External ID rows */
.ext-id-group {
  margin-bottom: 16px;
}

.ext-id-group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 16px;
}

.ext-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.ext-id-value {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ext-id-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.ext-id-actions .btn-sm {
  padding: 4px 8px;
  font-size: 11px;
  text-decoration: none;
}

/* ── Badges / Pills ────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ── Help Panel ────────────────────────────────────────── */

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.help-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.help-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-primary);
  z-index: 101;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  overflow-y: auto;
  padding: 24px;
}

.help-panel.visible {
  transform: translateX(0);
}

.help-panel h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.help-panel h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-secondary);
  margin: 20px 0 8px;
}

.help-panel p,
.help-panel li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.help-panel ul {
  padding-left: 18px;
  margin-bottom: 12px;
}

.help-panel code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent-secondary);
}

.help-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* ── Mode Toggle ───────────────────────────────────────── */

.mode-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin-bottom: 16px;
}

.mode-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ── Toast / Notification ──────────────────────────────── */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  animation: slideIn 300ms ease, fadeOut 300ms ease 2700ms forwards;
  min-width: 200px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* ── DMS Connection Status ─────────────────────────────── */

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

.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--error); }
.status-dot.checking { background: var(--warning); animation: pulse 1s infinite; }

/* ── Confirmation Dialog ───────────────────────────────── */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.dialog-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
}

.dialog h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.dialog p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-container {
    padding: 16px;
  }

  .tab-nav {
    flex-wrap: wrap;
  }

  .tab-btn {
    flex: none;
    min-width: 100px;
  }

  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }

  .help-panel {
    width: 100%;
  }
}

/* ── Scrollbar ─────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Error Message ─────────────────────────────────────── */

.error-message {
  padding: 12px 16px;
  background: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
}

.error-message .error-detail {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-secondary);
  word-break: break-all;
}

/* ── Dry Run Banner ────────────────────────────────────── */

.dry-run-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--warning);
  margin-bottom: 16px;
}

/* ── External ID Input List ────────────────────────────── */

.id-input-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

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

.id-input-row .form-input {
  flex: 1;
}

/* ── Summary Bar ───────────────────────────────────────── */

.summary-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.summary-stat {
  text-align: center;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.03);
  transition: all var(--transition-fast);
  flex: 1;
}

.summary-stat:hover {
  border-color: var(--border-secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}

.summary-stat.active {
  border-color: var(--accent-primary);
  background: var(--accent-glow);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.15);
}

.summary-stat .stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-stat .stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-stat.success { background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(16, 185, 129, 0.12)); border-color: rgba(34, 197, 94, 0.2); }
.summary-stat.success .stat-value { color: var(--success); }
.summary-stat.failed { background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(244, 63, 94, 0.12)); border-color: rgba(239, 68, 68, 0.2); }
.summary-stat.failed .stat-value { color: var(--error); }
.summary-stat.deleted .stat-value { color: var(--text-muted); }
.summary-stat.unpublished { background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(249, 115, 22, 0.12)); border-color: rgba(245, 158, 11, 0.2); }
.summary-stat.unpublished .stat-value { color: var(--warning); }

/* ── History Dashboard ────────────────────────────────── */

.history-unavailable-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--info-bg);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--info);
  margin-bottom: 16px;
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.history-filters .form-select {
  width: auto;
  min-width: 120px;
  padding: 6px 30px 6px 10px;
  font-size: 12px;
  background-color: var(--bg-card);
  border-color: var(--border-primary);
  border-radius: var(--radius-sm);
}

.history-export {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.history-table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.03);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th,
.history-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.history-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 1;
  user-select: none;
}

.history-table th[data-sort] {
  cursor: pointer;
}

.history-table th[data-sort]:hover {
  color: var(--text-primary);
}

.history-table th[data-sort]::after {
  content: ' \2195';
  color: var(--text-muted);
  font-size: 10px;
}

.history-table th.sort-asc::after {
  content: ' \2191';
  color: var(--accent-secondary);
}

.history-table th.sort-desc::after {
  content: ' \2193';
  color: var(--accent-secondary);
}

.history-table tbody tr {
  transition: background var(--transition-fast);
}

.history-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-table tbody tr.deleted-row td {
  opacity: 0.5;
  text-decoration: line-through;
}

.history-table tbody tr.deleted-row td:last-child,
.history-table tbody tr.deleted-row td:nth-last-child(2) {
  text-decoration: none;
}

.history-table tbody tr.unpublished-row td {
  opacity: 0.7;
}

.history-table tbody tr.unpublished-row td:nth-child(4) .result-badge {
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.spec-cell {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--accent-secondary);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon-compact {
  padding: 4px 6px !important;
  font-size: 14px;
  line-height: 1;
}

.history-date-cell {
  color: var(--text-secondary);
  font-size: 12px;
}

.history-actions-cell {
  display: flex;
  gap: 2px;
}

.history-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.history-empty .empty-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 12px;
}

.history-pagination {
  display: none;
  justify-content: center;
  margin-bottom: 16px;
}

/* ── History Detail Modal ─────────────────────────────── */

.dialog-lg {
  max-width: 680px;
  max-height: 80vh;
  overflow-y: auto;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-primary);
}

.dialog-header h3 {
  margin-bottom: 0;
}

.history-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.detail-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.detail-prompt {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

/* ── Availability Polling Status ─────────────────────── */

.avail-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border-primary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.avail-link-pending {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
  position: relative;
}

.avail-link-ready {
  opacity: 1;
  pointer-events: auto;
  transition: opacity var(--transition-fast);
}

.avail-link-na {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
  text-decoration: line-through;
}
