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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1a2e;
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: #555;
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.tab.active {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

.upload-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
  .upload-section {
    grid-template-columns: 1fr;
  }
}

.upload-card {
  background: #fff;
  border: 2px dashed #c5c9d4;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.upload-card label {
  font-weight: 600;
  font-size: 0.9rem;
}

.file-name {
  font-size: 0.8rem;
  color: #777;
  word-break: break-all;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}

.btn.small {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

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

.btn.primary { background: #4f46e5; color: #fff; }
.btn.success { background: #16a34a; color: #fff; }
.btn.secondary { background: #64748b; color: #fff; }
.btn.danger { background: #dc2626; color: #fff; }
.btn:not(:disabled):hover { opacity: 0.88; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.status {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.status.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.status.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.hidden { display: none !important; }

.results { margin-top: 2rem; }

.edit-hint {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.summary {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.summary .stat strong {
  font-size: 1.25rem;
  display: block;
}

.summary .stat.warn strong { color: #dc2626; }

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

th {
  background: #f9fafb;
  font-weight: 600;
  white-space: nowrap;
}

.cell-input {
  width: 100%;
  min-width: 70px;
  padding: 0.35rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
}

.qty-input { max-width: 70px; }

.page-select { min-width: 180px; max-width: 280px; }

.page-text-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #64748b;
}

tr.unmatched { background: #fef2f2; }
tr.low-confidence { background: #fffbeb; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.high { background: #dcfce7; color: #166534; }
.badge.low { background: #fef9c3; color: #854d0e; }
.badge.unmatched { background: #fee2e2; color: #991b1b; }
.badge.manual { background: #e0e7ff; color: #3730a3; }

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.archive-card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.archive-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.archive-date {
  font-size: 0.8rem;
  color: #94a3b8;
  white-space: nowrap;
}

.archive-meta {
  font-size: 0.85rem;
  color: #64748b;
}

.archive-meta .warn { color: #dc2626; }

.archive-notes {
  font-size: 0.85rem;
  color: #475569;
  margin-top: 0.35rem;
}

.archive-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.muted {
  color: #94a3b8;
  font-size: 0.9rem;
}

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.job-card {
  margin-top: 1.5rem;
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #e2e8f0;
}

.job-header h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #334155;
}

.suggestion-hint {
  font-size: 0.75rem;
  color: #b45309;
  margin-top: 0.2rem;
}

.archive-form {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.archive-form.is-open {
  display: block;
}

.archive-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.archive-form label:first-child {
  margin-top: 0;
}

.archive-form input,
.archive-form textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.archive-form .action-row {
  margin-top: 0.75rem;
}

.archive-form .archive-cancel-btn {
  background: #e2e8f0;
  color: #1e293b;
}
