:root {
  /* color tokens */
  --bg: #111111;
  --surface: #1A1A1D;
  --surface-2: #232326;
  --border: rgba(244,245,247,0.10);
  --ink: #FFFFFF;
  --ink-soft: rgba(255,255,255,0.55);
  --violet: #6D4AFF;
  --violet-hover: #593BE0;
  --violet-tint: rgba(109,74,255,0.18);
  --focus-ring: rgba(109,74,255,0.4);
  --light-grey: #F4F5F7;
  --ok: #35D48A;
  --warn: #FFB020;
  --danger: #FF5C5C;
  --radius: 20px;

  /* 8px spacing scale */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;

  /* typography scale */
  --text-h1: 48px;
  --text-h2: 32px;
  --text-h3: 24px;
  --text-h4: 18px;
  --text-body: 16px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: -apple-system, 'Inter', Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--ink);
  font-size: var(--text-body);
  line-height: 1.5;
}
header {
  background: var(--bg);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--space-1); }
.brand-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--violet) 0%, var(--violet-hover) 100%);
  color: white;
  border-radius: var(--space-1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 17px;
}
.brand-name { color: var(--light-grey); font-weight: 800; font-size: var(--text-h4); letter-spacing: -0.02em; }
.brand-dim { color: var(--ink-soft); font-weight: 500; }

main {
  max-width: 1200px;
  margin: var(--space-4) auto;
  padding: 0 var(--space-2) 70px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
section.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
}
section.card h2 {
  margin-top: 0;
  font-size: var(--text-h3);
  font-weight: 800;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--light-grey);
  letter-spacing: -0.01em;
}
.hint { color: var(--ink-soft); font-size: 13px; margin-top: -6px; margin-bottom: var(--space-2); 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: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-2);
}
.ref-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: var(--space-2);
  flex-wrap: wrap;
}
.ref-info { display: flex; flex-direction: column; gap: 3px; min-width: 220px; flex: 1; }
.ref-label { font-weight: 700; font-size: 14px; color: var(--light-grey); }
.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: var(--space-2); flex-wrap: wrap; align-items: end; margin-top: var(--space-1); }
.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: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--light-grey);
}
input[type="file"] { color: var(--ink-soft); max-width: 260px; }
input:focus, select:focus, button:focus-visible {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 2px var(--focus-ring);
}
button {
  font-size: 14px;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  background: var(--violet);
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}
button:hover { background: var(--violet-hover); }
button:disabled { background: #34343C; cursor: default; }
button.secondary { background: var(--surface-2); color: var(--violet); border: 1px solid var(--violet); }

.pill-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px var(--space-2);
  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: var(--space-2); }
th, td { border-bottom: 1px solid var(--border); padding: 9px 11px; 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(--light-grey); }
td input, td select {
  width: 100%; padding: 6px 8px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--light-grey);
}
.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: 14px; }
.msg { font-size: 13px; margin-top: var(--space-2); font-weight: 600; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }
