/* ── Brand Tokens ─────────────────────────────────────────────────────────── */
:root {
  --gb-yellow:  rgb(243, 189, 59);
  --gb-black:   #111111;
  --gb-white:   #ffffff;
  --gb-muted:   #6b7280;
  --gb-border:  #e5e7eb;
  --gb-surface: #f9fafb;
  --gb-cream:   #fffde7;

  /* Portal font stack — system fonts that match Avenir Next LT Pro */
  --f-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

  --radius:     4px;
  --radius-lg:  6px;
  --transition: 150ms ease;
}

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

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
  font-family: var(--f-ui);
  font-weight: 400;
  font-size: 13px;
  background: #f7f7f7;
  color: var(--gb-black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Page Header (hidden in embedded mode) ────────────────────────────────── */
.page-header {
  background: var(--gb-yellow);
  color: var(--gb-black);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 32px;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo    { height: 40px; width: auto; flex-shrink: 0; }
.header-text    { display: flex; flex-direction: column; gap: 2px; }

.header-title {
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 1.1rem;
}

.header-tagline {
  font-family: var(--f-ui);
  font-weight: 400;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

/* ── Main Container ───────────────────────────────────────────────────────── */
.container {
  max-width: 960px;
  width: 100%;
  margin: 24px auto;
  background: var(--gb-white);
  border: 1px solid var(--gb-border);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  flex: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.container--wide {
  max-width: min(95vw, 1300px);
  padding-left: 24px;
  padding-right: 24px;
}

/* ── Wizard (hidden in embedded mode) ────────────────────────────────────── */
.wizard {
  display: flex;
  align-items: center;
  margin-bottom: 36px;
}

.wizard-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wizard-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--gb-border);
  background: var(--gb-white);
  color: var(--gb-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.85rem;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.wizard-label {
  font-family: var(--f-ui);
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--gb-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.wizard-track {
  flex: 1;
  height: 1px;
  background: var(--gb-border);
  margin: 0 8px;
  margin-bottom: 20px;
}

.wizard-item.active .wizard-circle {
  background: var(--gb-yellow);
  border-color: rgba(0,0,0,0.15);
  color: #111;
}

.wizard-item.active .wizard-label { color: var(--gb-black); font-weight: 700; }

.wizard-item.done .wizard-circle {
  background: #374151;
  border-color: #374151;
  color: var(--gb-yellow);
}

.wizard-item.done ~ .wizard-track { background: #374151; }
.wizard-item.done .wizard-label { color: var(--gb-black); }

/* ── Step Content ─────────────────────────────────────────────────────────── */
.step-content { display: none; }
.step-content.active { display: block; }
.hidden { display: none !important; }

/* ── Section Labels ───────────────────────────────────────────────────────── */
.section-block { margin-bottom: 24px; }

.section-label {
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gb-muted);
  margin-bottom: 8px;
  display: block;
}

/* ── Step 1 Layout ────────────────────────────────────────────────────────── */
.step1-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.step1-upload {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step1-search { flex: 1; min-width: 0; }
.step1-actions { display: flex; flex-direction: column; gap: 8px; }
.step1-actions button { width: 100%; justify-content: center; }

/* ── Drop Zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 1px dashed var(--gb-border);
  background: var(--gb-surface);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: #9ca3af;
  background: #f3f4f6;
}

.drop-zone.has-file {
  border-style: solid;
  border-color: #9ca3af;
  background: #f3f4f6;
}

.drop-icon { width: 32px; height: 32px; color: var(--gb-muted); margin: 0 auto 10px; display: block; }

.drop-primary {
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--gb-black);
  margin-bottom: 3px;
}

.drop-secondary {
  font-family: var(--f-ui);
  font-size: 0.78rem;
  color: var(--gb-muted);
}

.drop-link {
  color: var(--gb-black);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--gb-yellow);
  text-underline-offset: 2px;
}

.drop-file-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  background: var(--gb-yellow);
  border: 1px solid rgba(0,0,0,0.15);
  padding: 4px 10px;
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.82rem;
  color: #111;
  border-radius: var(--radius);
}

/* ── Customer Search ──────────────────────────────────────────────────────── */
.search-field-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.customer-search-input {
  flex: 1;
  padding: 8px 12px;
  font-family: var(--f-ui);
  font-size: 0.9rem;
  border: 1px solid var(--gb-border);
  border-radius: var(--radius);
  background: var(--gb-white);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.customer-search-input:focus {
  border-color: #9ca3af;
  box-shadow: 0 0 0 3px rgba(156,163,175,0.15);
}

.search-hint {
  font-family: var(--f-ui);
  font-size: 0.8rem;
  color: var(--gb-muted);
  margin: 0 0 8px;
}

#customer-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--gb-border);
  border-radius: var(--radius);
}

#customer-table { width: 100%; border-collapse: collapse; }

#customer-table th {
  background: var(--gb-surface);
  color: var(--gb-muted);
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gb-border);
  position: sticky;
  top: 0;
  z-index: 1;
}

#customer-table td {
  padding: 8px 12px;
  font-family: var(--f-ui);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--gb-border);
  transition: background var(--transition);
}

#customer-table tbody tr { cursor: pointer; }
#customer-table tbody tr:last-child td { border-bottom: none; }
#customer-table tbody tr:hover td { background: var(--gb-surface); }
#customer-table tbody tr.selected td { background: var(--gb-cream); }

#csv-table-wrapper {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--gb-border);
  border-radius: var(--radius);
}

#csv-table { width: 100%; border-collapse: collapse; }

#csv-table th {
  background: var(--gb-surface);
  color: var(--gb-muted);
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gb-border);
  position: sticky;
  top: 0;
  z-index: 1;
}

#csv-table td {
  padding: 8px 12px;
  font-family: var(--f-ui);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--gb-border);
}

#csv-table tbody tr { cursor: pointer; }
#csv-table tbody tr:last-child td { border-bottom: none; }
#csv-table tbody tr:hover td { background: var(--gb-surface); }
#csv-table tbody tr.selected td { background: var(--gb-cream); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--gb-border);
  background: var(--gb-white);
  color: var(--gb-black);
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}

/* Primary (continue, preview, export) */
button:not(.btn-ghost):not(.btn-active):hover:not(:disabled) {
  background: var(--gb-surface);
  border-color: #9ca3af;
}

/* The Generate Preview / Continue buttons get the brand yellow */
#preview-btn,
#continue-btn {
  background: var(--gb-yellow);
  border-color: rgba(0,0,0,0.12);
  color: #111;
  font-weight: 700;
}

#preview-btn:hover:not(:disabled),
#continue-btn:hover:not(:disabled) {
  background: #e8b830;
  border-color: rgba(0,0,0,0.2);
}

button:active:not(:disabled) { opacity: 0.85; }

button:disabled {
  background: var(--gb-surface);
  border-color: var(--gb-border);
  color: #9ca3af;
  cursor: not-allowed;
}

button.btn-ghost {
  background: transparent;
  border-color: var(--gb-border);
  color: var(--gb-muted);
  font-weight: 500;
}

button.btn-ghost:hover:not(:disabled) {
  background: var(--gb-surface);
  border-color: #9ca3af;
  color: var(--gb-black);
}

button.btn-active {
  background: #374151;
  border-color: #374151;
  color: var(--gb-yellow);
}

button.btn-active:hover:not(:disabled) {
  background: var(--gb-yellow);
  border-color: rgba(0,0,0,0.15);
  color: #111;
}

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--gb-border);
  border-top-color: #6b7280;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ────────────────────────────────────────────────────────────────── */
.error {
  font-family: var(--f-ui);
  font-weight: 500;
  font-size: 0.82rem;
  color: #dc2626;
}

/* ── Warnings ─────────────────────────────────────────────────────────────── */
.warnings {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 3px solid var(--gb-yellow);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-family: var(--f-ui);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #78350f;
}

/* ── Canvas ───────────────────────────────────────────────────────────────── */
.canvas-wrapper {
  overflow: auto;
  border: 1px solid var(--gb-border);
  max-width: 100%;
  border-radius: var(--radius);
  max-height: 80vh;
}

#preview-canvas { display: block; }

.field-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-family: var(--f-ui);
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--gb-muted);
}

/* ── Output Preview ───────────────────────────────────────────────────────── */
.output-preview-pages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.output-preview-page {
  border: 1px solid var(--gb-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.output-preview-page-label {
  background: var(--gb-surface);
  color: var(--gb-muted);
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-bottom: 1px solid var(--gb-border);
}

.output-preview-page img { display: block; max-width: 100%; height: auto; }

/* ── Step 2 two-column layout ─────────────────────────────────────────────── */
.step2-layout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step2-panel {
  width: 172px;
  flex-shrink: 0;
  border: 1px solid var(--gb-border);
  border-radius: var(--radius-lg);
  background: var(--gb-white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.panel-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 8px;
}

.panel-section-label {
  display: block;
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gb-muted);
  margin-bottom: 4px;
  padding: 0 2px;
}

.panel-divider {
  height: 1px;
  background: var(--gb-border);
}

.step2-panel button {
  width: 100%;
  justify-content: flex-start;
  padding: 6px 8px;
  font-size: 0.78rem;
  line-height: 1.3;
  border-radius: var(--radius);
}

.step2-main { flex: 1; min-width: 0; }

/* ── Panel Format Selector ────────────────────────────────────────────────── */
.panel-format {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 2px 2px;
}

.panel-format-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-ui);
  font-size: 0.78rem;
  color: var(--gb-muted);
  cursor: pointer;
  padding: 3px 2px;
  user-select: none;
}

.panel-format-option input[type="radio"] {
  accent-color: #374151;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  cursor: pointer;
}

.panel-format-option:has(input:checked) {
  color: var(--gb-black);
  font-weight: 600;
}

/* ── Panel Info ───────────────────────────────────────────────────────────── */
.panel-info {
  font-family: var(--f-ui);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--gb-muted);
}

.panel-info strong { color: var(--gb-black); font-weight: 600; }

/* ── Step 2 Tab Bar ───────────────────────────────────────────────────────── */
.step2-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--gb-border);
  margin-bottom: 10px;
}

.step2-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--gb-muted);
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: -1px;
  transition: background var(--transition), color var(--transition);
}

.step2-tab:hover:not(:disabled) {
  background: var(--gb-surface);
  color: var(--gb-black);
  transform: none;
}

.step2-tab.step2-tab--active,
.step2-tab.step2-tab--active:hover:not(:disabled) {
  background: var(--gb-white);
  color: var(--gb-black);
  border-color: var(--gb-border);
  border-bottom-color: var(--gb-white);
  transform: none;
}

/* ── Customer Data Tab Content ────────────────────────────────────────────── */
.customer-data-content { padding: 4px 0 20px; }

.cd-sections { display: flex; flex-direction: column; gap: 12px; }

.cd-section {
  border: 1px solid var(--gb-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cd-section-title {
  background: var(--gb-surface);
  color: var(--gb-muted);
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-bottom: 1px solid var(--gb-border);
}

.cd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.cd-field {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-right: 1px solid var(--gb-border);
  border-bottom: 1px solid var(--gb-border);
}

.cd-field:nth-child(even) { border-right: none; }

.cd-label {
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gb-muted);
  margin-bottom: 2px;
}

.cd-value {
  font-family: var(--f-ui);
  font-size: 0.85rem;
  color: var(--gb-black);
  word-break: break-all;
}

.cd-empty {
  padding: 12px;
  font-family: var(--f-ui);
  font-size: 0.82rem;
  color: var(--gb-muted);
  font-style: italic;
}

.cd-table-wrapper { overflow-x: auto; }

.cd-table { width: 100%; border-collapse: collapse; }

.cd-table th {
  background: var(--gb-surface);
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gb-muted);
  padding: 7px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gb-border);
}

.cd-table td {
  padding: 7px 12px;
  font-family: var(--f-ui);
  font-size: 0.85rem;
  color: var(--gb-black);
  border-bottom: 1px solid var(--gb-border);
}

.cd-table tbody tr:last-child td { border-bottom: none; }
.cd-table tbody tr:hover td { background: var(--gb-surface); }

/* ── Footer (hidden in embedded mode) ────────────────────────────────────── */
.page-footer {
  max-width: 960px;
  width: 100%;
  margin: 0 auto 24px;
  padding: 10px 36px;
  border-top: 1px solid var(--gb-border);
  font-family: var(--f-ui);
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--gb-muted);
}

/* ── Summary / Export info ────────────────────────────────────────────────── */
.summary {
  background: var(--gb-surface);
  border: 1px solid var(--gb-border);
  border-left: 3px solid var(--gb-yellow);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-family: var(--f-ui);
  font-size: 0.85rem;
  line-height: 1.7;
}

/* ── Format Selector ──────────────────────────────────────────────────────── */
.format-selector { display: flex; gap: 10px; margin-bottom: 20px; }
.format-option { cursor: pointer; }
.format-option input[type="radio"] { display: none; }

.format-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border: 1px solid var(--gb-border);
  background: var(--gb-white);
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gb-muted);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  user-select: none;
}

.format-option input[type="radio"]:checked + .format-box {
  border-color: rgba(0,0,0,0.15);
  background: var(--gb-yellow);
  color: #111;
}

.format-box:hover {
  border-color: #9ca3af;
  background: var(--gb-surface);
  color: var(--gb-black);
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gb-surface); }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
