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

:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --border:    #dde3ec;
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --danger:    #dc2626;
  --success:   #16a34a;
  --text:      #111827;
  --muted:     #6b7280;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem 1rem 4rem;
}

/* ── Layout ── */
.container {
  max-width: 680px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.5px;
}

header .subtitle {
  color: var(--muted);
  margin-top: .35rem;
  font-size: .95rem;
}

/* ── Step indicator ── */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  opacity: .4;
  transition: opacity .25s;
}

.step.active, .step.done { opacity: 1; }

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  transition: background .25s, color .25s;
}

.step.active .step-number {
  background: var(--primary);
  color: #fff;
}

.step.done .step-number {
  background: var(--success);
  color: #fff;
}

.step-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.step.active .step-label { color: var(--primary); }
.step.done  .step-label  { color: var(--success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 40px;
  max-width: 80px;
  margin-bottom: 1.3rem;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 1.5rem;
  transition: opacity .2s;
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.4rem;
  color: var(--text);
}

/* ── Type grid ── */
.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
}

.type-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  text-align: center;
  transition: border-color .18s, background .18s, transform .15s;
  font-family: inherit;
}

.type-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
  transform: translateY(-2px);
}

.type-card.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.type-icon {
  font-size: 1.6rem;
  line-height: 1;
  color: var(--primary);
  letter-spacing: 2px;
}

.type-card strong {
  font-size: .95rem;
  color: var(--text);
}

.type-card small {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.35;
}

/* ── Form fields ── */
.field-group {
  margin-bottom: 1.2rem;
}

.field-group label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--text);
}

.required { color: var(--danger); }
.optional  { color: var(--muted); font-weight: 400; font-size: .8rem; }

.field-group input,
.field-group textarea {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color .18s, box-shadow .18s;
  outline: none;
}

.field-group input:focus,
.field-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
  background: #fff;
}

.field-group input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

.field-group textarea { resize: vertical; min-height: 80px; }

.hint {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .35rem;
}

/* ── Error ── */
.error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 7px;
  color: var(--danger);
  font-size: .85rem;
  padding: .6rem .9rem;
  margin-bottom: 1rem;
}

/* ── Preview area ── */
.preview-area {
  background: var(--bg);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.4rem 0 1.2rem;
  padding: 1.2rem;
  transition: border-color .2s;
  overflow: hidden;
}

.preview-area.has-barcode {
  border-color: var(--primary);
  border-style: solid;
  background: #fff;
}

#barcode-placeholder {
  text-align: center;
  color: var(--muted);
  font-size: .875rem;
}

#barcode-output {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#barcode-svg { max-width: 100%; height: auto; }
#barcode-qr  { line-height: 0; }

/* ── Export preview ── */
.export-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  margin: 1rem 0 1.5rem;
  min-height: 140px;
}

#export-barcode-output {
  display: flex;
  align-items: center;
  justify-content: center;
}

#export-barcode-svg { max-width: 100%; height: auto; }
#export-barcode-qr  { line-height: 0; }

.export-data-text {
  font-size: .85rem;
  color: var(--muted);
  font-family: 'Courier New', monospace;
  word-break: break-all;
  text-align: center;
}

.export-label-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

/* ── Buttons ── */
.btn-row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border-radius: 7px;
  font-size: .9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background .18s, transform .12s, opacity .15s;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-h); }

.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-reset { background: #fef2f2; color: var(--danger); border: 1.5px solid #fca5a5; }
.btn-reset:hover { background: #fee2e2; }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 520px) {
  .type-grid { grid-template-columns: 1fr; }
  .card { padding: 1.4rem 1.1rem; }
  .btn-row { justify-content: stretch; }
  .btn { flex: 1; justify-content: center; }
  .steps { gap: 0; }
  .step-connector { min-width: 20px; }
}
