:root {
  --primary: #0e6efd;
  --primary-hover: #0b5ed7;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --border: #e2e5ea;
  --error: #d63031;
  --success: #00b894;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.status-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
}
.status-pill.connected { background: #d1fae5; color: #065f46; }
.status-pill.error { background: #fee2e2; color: #991b1b; }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.q-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.q-num {
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  min-width: 28px;
  text-align: center;
}
.q-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}

.field {
  margin-bottom: 14px;
}
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* prevents iOS zoom on focus */
  font-family: inherit;
  background: white;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.762L10.825 4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,110,253,0.15);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
@media (min-width: 480px) {
  .checkbox-grid { grid-template-columns: 1fr 1fr; }
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.checkbox-item:hover { background: #f5f6f8; }
.checkbox-item.checked { background: #eaf3ff; border-color: #cce0ff; }
.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}
.checkbox-item label {
  margin: 0;
  font-weight: 400;
  font-size: 15px;
  cursor: pointer;
  flex: 1;
}

.pricing-fields {
  margin-top: 12px;
}
.pricing-field {
  background: #f8f9fb;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 3px solid var(--primary);
}
.pricing-field label {
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.help-text {
  font-size: 13px;
  color: var(--text-muted);
  margin: 6px 0 0 0;
}

.search-wrapper {
  position: relative;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 280px;
  overflow-y: auto;
  list-style: none;
  padding: 0;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.search-results li {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover, .search-results li.active { background: #f5f6f8; }
.search-results li .result-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.search-results li .empty {
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

.deal-summary {
  background: #f8f9fb;
  padding: 12px;
  border-radius: 8px;
  margin-top: 8px;
}
.deal-summary-name {
  font-weight: 600;
  margin-bottom: 6px;
}
.deal-summary-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.badge {
  background: #e2e8f0;
  color: #475569;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

.submit-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 12px 0 20px 0;
  margin-top: 8px;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-message {
  padding: 14px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 14px;
}
.status-message.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.status-message.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.hidden { display: none !important; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
