:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --background: #f9fafb;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
}

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

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

h1 {
  font-size: 28px;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 0;
}

.status-indicators {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-indicator,
.schedule-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--background);
  border-radius: 6px;
  min-width: 200px;
}

.status-light {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-light.active {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: pulse-green 2s infinite;
}

.status-light.inactive {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
  animation: pulse-orange 2s infinite;
}

@keyframes pulse-green {
  0%, 100% {
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  }
  50% {
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.9), 0 0 24px rgba(16, 185, 129, 0.4);
  }
}

@keyframes pulse-orange {
  0%, 100% {
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
  }
  50% {
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.9), 0 0 24px rgba(245, 158, 11, 0.4);
  }
}

.status-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.status-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.status-paths {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.schedule-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.controls {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #d1d5db;
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-skip {
  padding: 6px 12px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.btn-skip:hover {
  opacity: 0.9;
}

section {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--text);
}

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

.section-header h2 {
  margin-bottom: 0;
}

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

.hidden {
  display: none !important;
}

.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.progress-bar {
  flex: 1;
  height: 32px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.progress-text {
  font-weight: 600;
  color: var(--text);
  min-width: 80px;
  text-align: right;
}

.file-card {
  background: #f9fafb;
  padding: 16px;
  border-radius: 6px;
  margin-bottom: 12px;
  border-left: 4px solid transparent;
}

.file-card.processing {
  border-left-color: var(--primary);
}

.file-card.completed {
  border-left-color: var(--success);
}

.file-card.error {
  border-left-color: var(--error);
}

.file-card.skipped {
  border-left-color: var(--warning);
}

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

.file-name {
  font-weight: 500;
  word-break: break-all;
}

.engine-status {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
}

.engine-result {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-right: 8px;
  margin-top: 4px;
}

.engine-result.success {
  background: #d1fae5;
  color: #065f46;
}

.engine-result.error {
  background: #fee2e2;
  color: #991b1b;
}

.duration {
  font-size: 12px;
  opacity: 0.7;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--background);
}

th {
  text-align: left;
  padding: 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
}

td {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.status-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.running {
  background: #dbeafe;
  color: #1e40af;
}

.status-badge.completed {
  background: #d1fae5;
  color: #065f46;
}

.status-badge.cancelled {
  background: #fef3c7;
  color: #92400e;
}

.no-data {
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
}

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

.modal-header h3 {
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-close:hover {
  background: var(--border);
  color: var(--text);
}

#customPaths {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: monospace;
  font-size: 14px;
  margin-bottom: 16px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.file-list {
  max-height: 400px;
  overflow-y: auto;
}

.btn-view-logs {
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-view-logs:hover {
  background: var(--primary-dark);
}

.modal-content.logs-modal {
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.logs-content {
  flex: 1;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: 6px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  margin-bottom: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.engine-key {
  background: var(--background);
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.key-title {
  font-weight: 600;
  color: var(--text);
}

.key-item {
  color: var(--text-secondary);
}

.engine-cell {
  text-align: center;
  font-weight: 500;
}

.engine-pass {
  color: #059669;
  font-weight: 600;
}

.engine-fail {
  color: #dc2626;
  font-weight: 600;
}

/* Clickable stats */
.stat-clickable {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.stat-clickable:hover {
  color: var(--primary);
}

.stat-completed {
  color: #059669;
}

.stat-skipped {
  color: #d97706;
}

.stat-failed {
  color: #dc2626;
}

/* File list modal */
.modal-content.file-list-modal {
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.file-list-content {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 16px;
  max-height: 60vh;
}

.file-list-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.file-list-item:last-child {
  border-bottom: none;
}

.file-list-item:nth-child(odd) {
  background: var(--background);
}

.file-list-empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
  font-style: italic;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  header {
    padding: 16px;
  }

  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }

  h1 {
    font-size: 22px;
  }

  .status-indicators {
    width: 100%;
  }

  .status-indicator,
  .schedule-indicator {
    min-width: unset;
    width: 100%;
  }

  .controls {
    flex-wrap: wrap;
  }

  .controls .btn {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }

  section {
    padding: 16px;
  }

  .engine-key {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }

  /* History table: horizontal scroll */
  #historySection {
    overflow: visible;
  }

  #historyTable {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  th, td {
    padding: 8px;
    font-size: 13px;
  }
}