.intake-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .intake-layout { grid-template-columns: 1.4fr 1fr; }
}

.chat-panel {
  border: 1px solid var(--findspo-line);
  border-radius: 12px;
  padding: 16px;
  background: var(--findspo-surface-soft);
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.lab-quota-counter {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid var(--findspo-line);
  background: var(--findspo-surface);
  color: var(--brand-ink);
}

.lab-quota-counter.is-ok {
  border-color: var(--findspo-primary-border, #b8d4f5);
  background: var(--findspo-primary-soft, #eaf3fe);
  color: var(--findspo-primary-dark, #2f7ae2);
}

.lab-quota-counter.is-exhausted {
  border-color: #f5c2c0;
  background: #fdecea;
  color: var(--findspo-error, #d14343);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
  max-height: 360px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--findspo-surface);
  border: 1px solid var(--findspo-line);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--findspo-primary);
  color: #fff;
}

.chat-bubble.current {
  border-color: var(--findspo-primary);
  box-shadow: 0 0 0 2px var(--findspo-primary-soft);
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-reply {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--findspo-primary-border);
  background: var(--findspo-surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.quick-reply:hover { background: var(--findspo-primary-soft); }

.chat-composer {
  display: flex;
  gap: 8px;
}

.chat-composer input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--findspo-line);
  border-radius: 8px;
  font-family: inherit;
}

.config-summary-panel {
  border: 1px solid var(--findspo-line);
  border-radius: 12px;
  padding: 16px;
  background: var(--findspo-surface);
}

.config-summary {
  display: grid;
  gap: 10px;
}

.config-summary-item {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--findspo-line);
}

.config-summary-item dt { color: var(--findspo-muted); margin: 0; }
.config-summary-item dd { margin: 0; font-weight: 600; text-align: right; }

.wizard-file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.advanced-panel { margin-top: 20px; }
.advanced-panel summary { cursor: pointer; font-weight: 600; padding: 8px 0; }

.run-result-panel {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background: #e8f8f3;
  border: 1px solid #a8e6d4;
}

.run-result-panel.hidden { display: none; }

.logical-rules-panel {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--findspo-line);
}

.logical-rules-panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.logical-rules-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
}

.rules-preview-status {
  font-size: 13px;
  color: var(--findspo-muted);
}

.rules-preview-status.is-error { color: #b42318; }
.rules-preview-status.is-ok { color: #027a48; }

.rules-summary-panel {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background: var(--findspo-primary-soft);
  border: 1px solid var(--findspo-primary-border);
}

.rules-summary-panel.hidden { display: none; }

.rules-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 0;
  font-size: 13px;
}

.rules-summary-grid dt {
  margin: 0;
  color: var(--findspo-muted);
}

.rules-summary-grid dd {
  margin: 4px 0 0;
  font-weight: 600;
}

.rules-json-view,
.rules-json-editor {
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  border: 1px solid var(--findspo-line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

.rules-json-view {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.rules-json-editor {
  resize: vertical;
  min-height: 140px;
}

#intake-section {
  position: relative;
}

#intake-section.lab-job-busy .panel-head,
#intake-section.lab-job-busy .intake-layout,
#intake-section.lab-job-busy .advanced-panel,
#intake-section.lab-payment-locked .panel-head,
#intake-section.lab-payment-locked .intake-layout,
#intake-section.lab-payment-locked .advanced-panel {
  pointer-events: none;
  user-select: none;
}

#intake-section .job-busy-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(11, 19, 43, 0.45);
  z-index: 20;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
}

#intake-section .payment-lock-overlay {
  z-index: 25;
  background: rgba(11, 19, 43, 0.62);
}

#intake-section .job-busy-overlay.is-visible {
  display: flex;
}

#intake-section .job-busy-card {
  background: var(--findspo-surface);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 420px;
  text-align: center;
  pointer-events: auto;
}

#intake-section .job-busy-card a {
  color: var(--findspo-primary);
  font-weight: 600;
}

#intake-section .job-busy-card a.btn,
#intake-section .job-busy-card a.btn-primary {
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  .config-summary-panel {
    border-top: 3px solid var(--primary-100);
    margin-top: 4px;
  }

  #launch-run {
    position: sticky;
    bottom: 12px;
    z-index: 5;
  }
}

@media (max-width: 640px) {
  .chat-messages {
    max-height: min(360px, 45vh);
  }

  .chat-composer {
    flex-direction: column;
  }

  .chat-composer input,
  .chat-composer .btn {
    width: 100%;
  }

  .quick-replies {
    flex-direction: column;
  }

  .quick-reply {
    width: 100%;
    text-align: center;
    min-height: 44px;
  }

  #intake-section .job-busy-card {
    margin: 16px;
    padding: 20px;
    max-width: none;
  }

  .rules-json-editor {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .config-summary-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .config-summary-item dd {
    text-align: left;
  }
}
