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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

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

.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 6px;
}
.page-header p {
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}

/* Upload */
.upload-section {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  background: white;
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.upload-btn {
  display: inline-block;
  padding: 9px 20px;
  background: #fe8e14;
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s;
  user-select: none;
}
.upload-btn:hover {
  background: #e07a10;
}
#imageInput {
  display: none;
}
#fileName {
  color: #888;
  font-size: 14px;
}

/* Phases */
.phases {
  display: flex;
  background: white;
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
  gap: 4px;
}
.phase {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  padding: 0 8px;
}
.phase:not(:last-child)::after {
  content: "›";
  position: absolute;
  right: -6px;
  top: 10px;
  color: #ccc;
  font-size: 18px;
  font-weight: 300;
}
.phase-icon {
  font-size: 22px;
  line-height: 1;
}
.phase-label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  text-align: center;
}
.phase-sublabel {
  font-size: 11px;
  color: #999;
  text-align: center;
  min-height: 14px;
}

.phase-pending .phase-icon::before {
  content: "○";
  color: #ccc;
}
.phase-running .phase-icon::before {
  content: "⏳";
}
.phase-done .phase-icon::before {
  content: "✅";
}
.phase-error .phase-icon::before {
  content: "❌";
}

/* Progress strip */
.progress-strip {
  display: none;
  align-items: center;
  gap: 14px;
  background: white;
  border-radius: 8px;
  padding: 10px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 8px;
}
.progress-strip.active {
  display: flex;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #fe8e14, #ffb347);
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
}
.progress-fill.animating::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}
.progress-strip.done .progress-fill {
  background: linear-gradient(90deg, #28a745, #5bd778);
}
.progress-strip.error .progress-fill {
  background: linear-gradient(90deg, #dc3545, #e8606d);
}
.progress-elapsed {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #888;
  white-space: nowrap;
  min-width: 48px;
  text-align: right;
}

/* Canvas area */
.canvas-wrapper {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
  overflow: auto;
  text-align: center;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas-placeholder {
  color: #bbb;
  font-size: 14px;
}
#canvas {
  max-width: 100%;
  border: 1px solid #eee;
  display: none;
}

/* Log */
#logSection {
  background: #0f1117;
  color: #8be08b;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
  max-height: 180px;
  overflow-y: auto;
  font-family: "Courier New", monospace;
  font-size: 13px;
  display: none;
}
.log-entry {
  margin-bottom: 3px;
  line-height: 1.4;
}
.log-entry.log-result {
  color: #fff;
  font-weight: 700;
  background: rgba(91, 187, 255, 0.15);
  border-left: 3px solid #5bf;
  padding: 3px 8px;
  margin-left: -8px;
  margin-right: -8px;
  border-radius: 0 4px 4px 0;
}

/* Results */
#resultsSection {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  display: none;
}
#resultsSection h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1a1a2e;
}
.summary-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  flex: 1;
  background: #f8f9fa;
  border-radius: 6px;
  padding: 14px 10px;
  text-align: center;
}
.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 12px;
  color: #888;
}
.stat.decoded .stat-value {
  color: #28a745;
}
.stat.failed .stat-value {
  color: #dc3545;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.results-table th {
  background: #f8f9fa;
  padding: 9px 14px;
  text-align: left;
  border-bottom: 2px solid #e9ecef;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: #555;
  letter-spacing: 0.5px;
}
.results-table td {
  padding: 7px 14px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.results-table tr:last-child td {
  border-bottom: none;
}
.results-table tr:hover td {
  background: #fafafa;
}
.status-decoded {
  color: #28a745;
  font-weight: 600;
}
.status-deep-decoded {
  color: #3399ff;
  font-weight: 600;
}
.status-failed {
  color: #dc3545;
  font-weight: 600;
}
.text-cell {
  font-family: "Courier New", monospace;
  font-size: 12px;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-num {
  color: #888;
  font-variant-numeric: tabular-nums;
}
