/* ── Upload phase ────────────────────────────────────────────────────── */
#phase-upload {
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.upload-card {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 48px 56px;
  text-align: center;
  max-width: 520px;
  width: 100%;
  transition: border-color .2s, background .2s;
}
.upload-card.drag-over {
  border-color: var(--accent);
  background: var(--accent-lo);
}
.upload-icon {
  font-size: 40px;
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1;
}
.upload-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.upload-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.6;
}
.upload-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-primary {
  padding: 9px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.btn-secondary {
  padding: 9px 20px;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: #e2e8f0; }
.upload-limit {
  margin-top: 16px;
  font-size: 11px;
  color: var(--muted);
}
.upload-error {
  margin-top: 14px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 7px;
  color: #b91c1c;
  font-size: 12px;
  display: none;
}
#file-input { display: none; }

/* ── Mapping phase ───────────────────────────────────────────────────── */
.mapping-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.mapping-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.mapping-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px 8px;
}
.mapping-table td {
  padding: 4px 8px;
  vertical-align: middle;
}
.mapping-table tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}
.col-name {
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  padding: 3px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.col-arrow { color: var(--muted); text-align: center; width: 24px; }
.mapping-table select {
  width: 100%;
  max-width: 180px;
}
.test-name-input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font: inherit;
  font-size: 12px;
  color: var(--text);
  width: 120px;
  outline: none;
  transition: border-color .15s;
}
.test-name-input:focus { border-color: var(--accent); }
.mapping-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.pass-bin-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.pass-bin-input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font: inherit;
  font-size: 12px;
  color: var(--text);
  width: 80px;
  outline: none;
  transition: border-color .15s;
}
.pass-bin-input:focus { border-color: var(--accent); }
.mapping-file-info {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

/* ── Mapping table extras ────────────────────────────────────────────── */
.split-cell { width: 180px; }
.split-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.split-label input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.cardinality-hint {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

/* ── Maps phase ──────────────────────────────────────────────────────── */
.maps-bar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.maps-data-strip {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
}
.maps-gallery {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.truncation-banner {
  padding: 8px 16px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  font-size: 12px;
  color: #92400e;
  flex-shrink: 0;
}
/* ── Lot info bar ────────────────────────────────────────────────────── */
.lot-info-bar {
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-2);
}
.lot-info-item { display: flex; gap: 5px; }
.lot-info-label { color: var(--muted); }

/* ── Help popout ─────────────────────────────────────────────────────── */
.help-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.help-btn:hover { background: #e2e8f0; color: var(--text); }
.help-popout {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 24px 28px;
  z-index: 1000;
  width: 480px;
  max-width: 95vw;
  max-height: 80vh;
  overflow-y: auto;
  display: none;
}
.help-popout.open { display: block; }
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 999;
  display: none;
}
.help-overlay.open { display: block; }
.help-heading {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}
.help-close {
  float: right;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.help-section { margin-bottom: 18px; }
.help-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.help-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.help-row:last-child { border-bottom: none; }
.help-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.help-row-text strong { display: block; color: var(--text); font-size: 12px; margin-bottom: 1px; }

/* ── Loading overlay ─────────────────────────────────────────────────── */
.maps-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.maps-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}
.maps-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Long-format modal ───────────────────────────────────────────────── */
#longfmt-modal { width: 520px; }
#longfmt-body { font-size: 13px; color: var(--text-2); line-height: 1.6; }
#longfmt-body p { margin: 0 0 10px; }
#longfmt-body ul { margin: 0 0 10px; padding-left: 20px; }
#longfmt-body li { margin-bottom: 4px; }
#longfmt-body code {
  font-family: monospace;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
}

/* ── Phase host + visibility ─────────────────────────────────────────── */
.phase-host { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.phase { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.phase.active { display: flex; }
#phase-upload.active { overflow-y: auto; }

/* ── Demo scenario selector ───────────────────────────────────────────── */
.demo-scenario-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.scenario-pill {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.scenario-pill:hover {
  background: var(--accent-lo);
  border-color: var(--accent);
  color: var(--accent);
}
.scenario-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.scenario-pill-own {
  margin-left: auto;
  border-style: dashed;
}
.scenario-pill-own.active {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
  border-style: dashed;
}

/* ── Scenario description banner ─────────────────────────────────────── */
.scenario-banner {
  flex-shrink: 0;
  padding: 8px 18px;
  background: var(--accent-lo);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  display: none;
}
.scenario-banner strong { color: var(--text); }
.scenario-banner em { font-style: italic; }

/* ── Upload section (moved below gallery) ────────────────────────────── */
.upload-section-heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 20px 24px 4px;
  text-align: center;
}
#phase-upload { align-items: center; justify-content: flex-start; padding: 0 32px 40px; }

/* ── Feature tour ────────────────────────────────────────────────────── */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1100;
}
#tour-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1101;
}
.tour-ring {
  position: fixed;
  border: 2px solid #fff;
  border-radius: 6px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.45);
  pointer-events: none;
  z-index: 1102;
}
.tour-tip {
  position: fixed;
  transform: translateX(-50%);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  padding: 10px 14px;
  border-radius: 8px;
  width: 220px;
  text-align: center;
  line-height: 1.45;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  pointer-events: none;
  z-index: 1103;
}
.tour-tip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: var(--arrow-left, 50%);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top: none;
  border-bottom-color: #fff;
}
.tour-tip[data-above="1"] {
  transform: translateX(-50%) translateY(-100%);
}
.tour-tip[data-above="1"]::before {
  top: auto;
  bottom: -6px;
  border-bottom: none;
  border-top: 6px solid #fff;
}
.tour-nav {
  position: fixed;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  justify-content: center;
  z-index: 1103;
  pointer-events: all;
}
.tour-skip {
  padding: 6px 14px;
  background: transparent;
  color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 20px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tour-skip:hover { color: #fff; border-color: rgba(255,255,255,.8); }
.tour-next {
  padding: 6px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  transition: opacity .15s;
}
.tour-next:hover { opacity: .88; }
