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

:root {
  --primary: #2e7d32;
  --primary-dark: #1b5e20;
  --primary-light: #e8f5e9;
  --success: #2e7d32;
  --success-dark: #1b5e20;
  --danger: #dc2626;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────── */
.header {
  background: #fff;
  color: var(--gray-800);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-lg);
  border-bottom: 3px solid var(--primary);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-logo { height: 55px; width: auto; }
.tagline { font-size: 0.95rem; margin-top: 0.15rem; color: var(--gray-600); }

/* ── Main ────────────────────────────────────────────────────────── */
.main-content { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 1.5rem;
}
.card h2 { font-size: 1.4rem; margin-bottom: 0.5rem; color: var(--gray-900); }
.hint { color: var(--gray-500); font-size: 0.9rem; margin-bottom: 1.25rem; }

/* ── LOB Grid ────────────────────────────────────────────────────── */
.lob-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.lob-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.lob-card:hover { border-color: var(--primary); background: var(--primary-light); }
.lob-card.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(26,86,219,0.2); }
.lob-card .lob-icon { font-size: 2rem; margin-bottom: 0.35rem; }
.lob-card .lob-name { font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }

/* ── LOB Tabs ────────────────────────────────────────────────────── */
.lob-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--gray-200);
  padding-bottom: 0.5rem;
}
.lob-tab {
  padding: 0.4rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--gray-50);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
}
.lob-tab:hover { background: var(--primary-light); }
.lob-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Progress ────────────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  margin-bottom: 0.35rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.progress-text { font-size: 0.8rem; color: var(--gray-500); margin-bottom: 1rem; }

/* ── Section Nav ─────────────────────────────────────────────────── */
.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}
.section-nav-btn {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--gray-50);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--gray-600);
}
.section-nav-btn:hover { background: var(--primary-light); }
.section-nav-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.section-nav-btn.completed { background: #dcfce7; border-color: var(--success); color: var(--success); }

/* ── Form Sections ───────────────────────────────────────────────── */
.form-section { display: none; }
.form-section.active { display: block; }
.form-section h3 {
  font-size: 1.15rem;
  color: var(--primary-dark);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

/* ── Form Fields ─────────────────────────────────────────────────── */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.field-group {
  display: flex;
  flex-direction: column;
}
.field-group.full-width { grid-column: 1 / -1; }
.field-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.3rem;
}
.field-group label .required { color: var(--danger); margin-left: 2px; }

.field-group input,
.field-group select,
.field-group textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.15);
}
.field-group input.invalid,
.field-group select.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}
.field-group textarea { min-height: 80px; resize: vertical; }
.field-group .field-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 0.2rem;
  display: none;
}
.field-group input.invalid + .field-error,
.field-group select.invalid + .field-error { display: block; }

/* Currency input wrapper */
.currency-wrapper {
  position: relative;
}
.currency-wrapper::before {
  content: '$';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
  font-weight: 600;
}
.currency-wrapper input { padding-left: 1.5rem; }

/* ── Checkbox ────────────────────────────────────────────────────── */
.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.checkbox-group label { margin-bottom: 0; cursor: pointer; }

/* ── Repeater ────────────────────────────────────────────────────── */
.repeater-container {
  grid-column: 1 / -1;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--gray-50);
}
.repeater-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.repeater-header h4 {
  font-size: 1rem;
  color: var(--gray-700);
}
.repeater-item {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  position: relative;
}
.repeater-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-100);
}
.repeater-item-header span { font-weight: 600; font-size: 0.9rem; color: var(--gray-600); }
.btn-remove-item {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}
.btn-remove-item:hover { background: var(--danger); color: #fff; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-dark); }
.btn-outline {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.82rem; }
.btn-add {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px dashed var(--primary);
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-add:hover { background: var(--primary); color: #fff; }
.repeater-container > .btn-add { margin-top: 0.75rem; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}
.form-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.form-header h2 { margin-bottom: 0; }

/* ── Confirmation ────────────────────────────────────────────────── */
.confirmation-content { text-align: center; }
.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #dcfce7;
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem;
}
#confirmation-details {
  text-align: left;
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
#confirmation-details p { margin-bottom: 0.3rem; }

/* ── Loading ─────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  color: #fff;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ──────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--gray-500);
  font-size: 0.8rem;
}

/* ── Policy Upload ──────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--gray-50);
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.upload-text { font-size: 0.95rem; color: var(--gray-700); margin-bottom: 0.3rem; }
.upload-link {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.upload-hint { font-size: 0.8rem; color: var(--gray-400); }

.upload-status {
  padding: 1.5rem;
  text-align: center;
}
.upload-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--gray-600);
}
.spinner-small {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.upload-result {
  padding: 1rem;
  background: #dcfce7;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}
.upload-success {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.success-badge {
  background: var(--success);
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
#upload-result-text { font-size: 0.85rem; color: var(--gray-700); }

.upload-error {
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.upload-skip {
  text-align: center;
  margin-top: 1rem;
}

/* Inline policy upload (within form flow) */
.policy-upload-inline {
  margin: 1.5rem 0;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.policy-upload-card {
  border: 2px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--primary-light) 100%);
}
.policy-upload-card h3 {
  font-size: 1.05rem;
  color: var(--primary-dark);
  margin-bottom: 0.35rem;
  border-bottom: none;
  padding-bottom: 0;
}
.policy-upload-card .hint {
  margin-bottom: 1rem;
}
.policy-upload-card .upload-area {
  padding: 1.5rem 1rem;
  background: #fff;
}
.policy-upload-actions {
  text-align: center;
  margin-top: 1rem;
}

.optional-badge {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--gray-400);
  background: var(--gray-100);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.35rem;
}

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

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .lob-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .form-header { flex-direction: column; align-items: flex-start; }
}
