/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple: #3D1C6E;
  --purple-dark: #2C1250;
  --purple-light: #EDE8F5;
  --gold: #C9A84C;
  --grey: #555;
  --border: #D0C8E0;
  --white: #fff;
  --bg: #F4F1F9;
  --error: #C0392B;
  --error-bg: #FDF0EF;
  --success: #1E7E34;
  --success-bg: #EAF6EC;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: #222;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--purple); }
.ko { color: var(--grey); font-size: 0.875em; }

/* ── Header ───────────────────────────────────────────── */
.site-header {
  background: var(--purple);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
}
.header-logo { height: 52px; width: auto; }
.header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.header-title-en { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.02em; }
.header-title-ko { font-size: 0.8rem; opacity: 0.85; }
.header-sub { font-size: 0.75rem; color: var(--gold); font-weight: 600; margin-top: 2px; }

/* ── Main & footer ────────────────────────────────────── */
main { flex: 1; padding: 28px 16px; max-width: 860px; margin: 0 auto; width: 100%; }
footer {
  background: var(--purple);
  color: rgba(255,255,255,0.75);
  text-align: center;
  font-size: 0.78rem;
  padding: 12px;
}

/* ── Card ─────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(61,28,110,0.10);
  padding: 32px 28px;
}

/* ── Passcode card ────────────────────────────────────── */
.passcode-card { max-width: 460px; margin: 0 auto; }
.passcode-card h2 { color: var(--purple); margin-bottom: 12px; font-size: 1.3rem; }
.passcode-card p { margin-bottom: 8px; font-size: 0.93rem; color: var(--grey); }

/* ── Alerts ───────────────────────────────────────────── */
.alert {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #F1A9A4; }
.alert-error div + div { margin-top: 4px; }

/* ── Steps indicator ──────────────────────────────────── */
.steps {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--grey);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.2s;
}
.step.active .step-num { background: var(--purple); color: var(--white); }
.step.done .step-num { background: var(--gold); color: var(--white); }
.step-label { font-size: 0.7rem; text-align: center; color: var(--grey); line-height: 1.3; }
.step.active .step-label { color: var(--purple); font-weight: 600; }
.step-connector { flex: 1; height: 2px; background: var(--border); margin: 0 6px; margin-bottom: 18px; }

/* ── Form sections ────────────────────────────────────── */
.form-step { animation: fadeIn 0.2s ease; }
.form-step.hidden { display: none; }

.step-title {
  font-size: 1.1rem;
  color: var(--purple);
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gold);
}

.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.field-full { grid-column: 1 / -1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--purple);
}
.hint { font-size: 0.75rem; color: var(--grey); }
.hint-inline { font-weight: 400; color: var(--grey); font-size: 0.8rem; }
.req { color: var(--error); }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.95rem;
  font-family: var(--font);
  width: 100%;
  transition: border-color 0.15s;
  background: var(--white);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(61,28,110,0.12);
}

/* ── Consent blocks ───────────────────────────────────── */
.consent-block {
  background: var(--purple-light);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.consent-block h4 {
  font-size: 0.9rem;
  color: var(--purple);
  margin-bottom: 10px;
}
.consent-details {
  font-size: 0.82rem;
  color: var(--grey);
  margin-bottom: 12px;
  line-height: 1.6;
}
.consent-details p { margin-bottom: 3px; }
.ko-note { font-style: italic; margin-top: 4px; }
.consent-radios {
  display: flex;
  gap: 24px;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--white);
  transition: all 0.15s;
}
.radio-label input { accent-color: var(--purple); width: 16px; height: 16px; }
.yes-label:has(input:checked) { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.no-label:has(input:checked) { border-color: var(--error); background: var(--error-bg); color: var(--error); }

/* ── Rules box ────────────────────────────────────────── */
.rules-box {
  background: #FFF8E7;
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.84rem;
  color: #5A4000;
  margin-bottom: 20px;
}
.rules-box ul { padding-left: 18px; margin-top: 6px; }
.rules-box li { margin-bottom: 3px; }

/* ── Purchase table ───────────────────────────────────── */
.table-wrapper { overflow-x: auto; margin-bottom: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  background: var(--purple);
  color: var(--white);
  padding: 9px 10px;
  text-align: left;
  font-size: 0.8rem;
  white-space: nowrap;
}
tbody tr:nth-child(even) { background: var(--purple-light); }
tbody td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.subtotal-cell { text-align: right; white-space: nowrap; font-weight: 600; }

.total-row td { padding: 8px 10px; background: #F0EAF8; }
.total-row td b { color: var(--purple); }
.reimb-row td { padding: 6px 10px; background: #FFF3CD; font-size: 0.83rem; }
.reimb-value { color: var(--gold); }

.input-full { width: 100%; min-width: 120px; }
.input-num { width: 80px; }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--grey);
  cursor: pointer;
  padding: 3px 7px;
  font-size: 0.8rem;
}
.btn-icon:hover { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.remove-row, .remove-receipt { margin-left: 6px; }

/* ── Signature preview ────────────────────────────────── */
.sig-preview {
  background: var(--purple-light);
  border: 1px dashed var(--purple);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 20px 0;
}
.sig-label { font-size: 0.78rem; color: var(--grey); margin-bottom: 6px; font-weight: 600; }
.sig-value { font-size: 1.1rem; font-weight: 700; color: var(--purple); font-style: italic; }
.sig-email { font-size: 0.85rem; color: var(--grey); margin-top: 2px; }
.sig-date { font-size: 0.82rem; color: var(--grey); margin-top: 4px; }

/* ── File uploads ─────────────────────────────────────── */
.upload-section { margin-bottom: 24px; }
.upload-section h4 { font-size: 0.9rem; color: var(--purple); margin-bottom: 12px; }

.file-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.file-label {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--purple-light);
  border: 1.5px dashed var(--purple);
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
  flex: 1;
  font-size: 0.88rem;
  transition: background 0.15s;
}
.file-label:hover { background: #DDD5F0; }
.file-icon { font-size: 1.2rem; }
.file-text { color: var(--purple); font-weight: 600; }
.file-name { color: var(--grey); font-size: 0.8rem; margin-left: auto; word-break: break-all; }
input[type="file"] { display: none; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  font-family: var(--font);
  text-decoration: none;
}
.btn-primary {
  background: var(--purple);
  color: var(--white);
  border-color: var(--purple);
}
.btn-primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); }
.btn-secondary {
  background: var(--white);
  color: var(--purple);
  border-color: var(--purple);
}
.btn-secondary:hover { background: var(--purple-light); }
.btn-outline {
  background: var(--white);
  color: var(--purple);
  border-color: var(--border);
  font-size: 0.85rem;
  padding: 7px 16px;
}
.btn-outline:hover { border-color: var(--purple); background: var(--purple-light); }
.btn-submit {
  background: var(--gold);
  color: var(--white);
  border-color: var(--gold);
  font-size: 1rem;
  padding: 12px 28px;
}
.btn-submit:hover { background: #A8872D; border-color: #A8872D; }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.add-row-btn { margin-bottom: 4px; }

.step-nav {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Spinner overlay ──────────────────────────────────── */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61,28,110,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.spinner-overlay.hidden { display: none; }
.spinner-box {
  background: var(--white);
  border-radius: 12px;
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--purple-light);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
.spinner-box p { color: var(--purple); font-weight: 600; line-height: 1.6; }

/* ── Success card ─────────────────────────────────────── */
.success-card { max-width: 580px; margin: 0 auto; text-align: center; }
.success-icon {
  width: 64px;
  height: 64px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 50%;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-weight: 700;
}
.success-card h2 { color: var(--purple); margin-bottom: 16px; }
.success-card p { margin-bottom: 10px; color: var(--grey); font-size: 0.95rem; }
.info-box {
  background: var(--purple-light);
  border-radius: 8px;
  padding: 18px 22px;
  text-align: left;
  margin: 20px 0;
  font-size: 0.88rem;
}
.info-box h3 { color: var(--purple); margin-bottom: 10px; font-size: 0.95rem; }
.info-box ul { padding-left: 18px; }
.info-box li { margin-bottom: 6px; line-height: 1.5; }

/* ── Animations ───────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 620px) {
  .card { padding: 20px 14px; }
  .fields-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: 1; }
  .step-label { display: none; }
  .consent-radios { flex-direction: column; gap: 10px; }
  .step-nav { flex-direction: column-reverse; }
  .btn { width: 100%; text-align: center; }
  thead th:nth-child(5), tbody td:nth-child(5) { display: none; } /* hide Seller on mobile */
}
