:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F4F5F7;
  --border: #E5E4EC;
  --ink: #111111;
  --ink-soft: #6B6B76;
  --violet: #6D4AFF;
  --violet-dark: #5636CC;
  --violet-tint: rgba(109,74,255,0.10);
  --ok: #1F9D66;
  --warn: #B36B00;
  --danger: #D64545;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(17,17,17,0.06);
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, 'Inter', Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--ink);
}
header {
  background: var(--bg);
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--violet) 0%, var(--violet-dark) 100%);
  color: white;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 17px;
}
.brand-name { color: var(--ink); font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand-dim { color: var(--ink-soft); font-weight: 500; }

main {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 24px 72px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
section.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
section.card h2 {
  margin-top: 0;
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.hint { color: var(--ink-soft); font-size: 13px; margin-top: -8px; margin-bottom: 16px; line-height: 1.4; }
.step-badge {
  background: var(--violet-tint);
  color: var(--violet);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.ref-grid { display: flex; flex-direction: column; gap: 8px; }
.ref-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  flex-wrap: wrap;
}
.ref-info { display: flex; flex-direction: column; gap: 4px; min-width: 220px; flex: 1; }
.ref-label { font-weight: 700; font-size: 14px; color: var(--ink); }
.ref-hint { font-weight: 400; font-size: 12px; color: var(--ink-soft); }
.ref-status { font-size: 12px; color: var(--ink-soft); }
.ref-status.loaded { color: var(--ok); }

.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: end; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
label { color: var(--ink-soft); font-weight: 500; }
input, select {
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}
input[type="file"] { color: var(--ink-soft); max-width: 260px; background: var(--surface-2); }
input:focus, select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-tint); }
button {
  font-size: 14px;
  font-weight: 700;
  padding: 12px 22px;
  border: none;
  border-radius: 10px;
  background: var(--violet);
  color: white;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
button:hover { background: var(--violet-dark); box-shadow: var(--shadow); }
button:disabled { background: #D5D2E0; cursor: default; box-shadow: none; }
button.secondary { background: white; color: var(--violet); border: 1px solid var(--violet); }
button.secondary:hover { background: var(--violet-tint); }

.pill-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--violet-tint);
  color: var(--violet);
  font-size: 12px;
  font-weight: 700;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 16px; }
th, td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; }
th { background: var(--surface-2); color: var(--ink-soft); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; position: sticky; top: 0; }
td { color: var(--ink); }
td input, td select {
  width: 100%; padding: 6px 8px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: white; color: var(--ink);
}
.status-auto_matched { color: var(--ok); font-weight: 700; }
.status-needs_review { color: var(--warn); font-weight: 700; }
.status-confirmed { color: var(--violet); font-weight: 700; }
.summary { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.table-wrap { max-height: 480px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.msg { font-size: 13px; margin-top: 12px; font-weight: 600; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }
