* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f6f7f9;
  color: #1f2937;
  line-height: 1.5;
}

header {
  background: #111827;
  color: #f9fafb;
  padding: 1.5rem 2rem;
  border-bottom: 4px solid #d97706;
}

.hdr-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

header h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: #d1d5db;
  font-size: 0.95rem;
  max-width: 720px;
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.badge {
  background: #374151;
  color: #f9fafb;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
}

.picker {
  background: #ffffff;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 1.5rem;
}

.picker label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.picker select {
  font-size: 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  max-width: 480px;
}

.card {
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 1.5rem;
}

.card.hidden, .hidden { display: none; }

.card h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.2rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
  margin-top: 0.75rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.form-grid input,
.form-grid select {
  padding: 0.5rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #ffffff;
}

.field-group {
  grid-column: 1 / -1;
  padding-top: 0.75rem;
  border-top: 1px solid #f3f4f6;
}

.field-group h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.runs-list, .curves-list, .skus-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.run-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.6rem; align-items: end; }
.curve-row { display: grid; grid-template-columns: 2fr 1fr auto; gap: 0.6rem; align-items: end; }
.sku-row { display: grid; grid-template-columns: 1.5fr 1fr auto; gap: 0.6rem; align-items: end; }

.btn-primary, .btn-secondary {
  font-size: 0.95rem;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 600;
}

.btn-primary { background: #d97706; color: #ffffff; }
.btn-primary:hover { background: #b45309; }

.btn-secondary { background: #ffffff; color: #1f2937; border-color: #d1d5db; }
.btn-secondary:hover { background: #f3f4f6; }
.btn-secondary.danger { color: #991b1b; border-color: #fca5a5; }
.btn-secondary.danger:hover { background: #fee2e2; }

.btn-mini {
  background: transparent;
  border: 1px solid #d1d5db;
  color: #6b7280;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-mini:hover { background: #f3f4f6; color: #1f2937; }
.btn-mini.danger:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.actions-row {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ---------- Cart ---------- */

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.cart-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cart-pill {
  display: inline-block;
  background: #d97706;
  color: #ffffff;
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.cart-pill.empty { background: #e5e7eb; color: #6b7280; }

#groups-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.group-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  overflow: hidden;
}

.group-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.group-title-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-width: 200px;
}

.group-toggle {
  background: transparent;
  border: none;
  font-size: 0.85rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 1.4rem;
  text-align: center;
}

.group-label-input {
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  flex: 1 1 auto;
  min-width: 200px;
}

.group-label-input:hover { background: #f3f4f6; }
.group-label-input:focus { background: #ffffff; border-color: #d97706; outline: none; }

.group-summary {
  font-size: 0.85rem;
  color: #6b7280;
  white-space: nowrap;
}

.group-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.group-body { padding: 0; }
.group-card.collapsed .group-body { display: none; }

#bom-table, #merged-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

#bom-table th, #bom-table td,
#merged-table th, #merged-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: middle;
}

#bom-table th, #merged-table th {
  background: #f3f4f6;
  font-weight: 600;
  color: #374151;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }

.qty-col { width: 90px; text-align: center; }

input.qty-input {
  width: 70px;
  padding: 0.3rem 0.45rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  text-align: center;
  font-size: 0.95rem;
}

input.qty-input.edited { border-color: #d97706; background: #fffbeb; }

.flag-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-right: 0.25rem;
}

.flag-pill.quote { background: #fef3c7; color: #92400e; }
.flag-pill.lead  { background: #dbeafe; color: #1e40af; }

.group-totals-row {
  background: #f9fafb;
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: #4b5563;
  border-top: 1px solid #e5e7eb;
}

.group-totals-row strong { color: #1f2937; }

.grand-totals {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: #111827;
  color: #f9fafb;
  border-radius: 8px;
}

.gt-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.25rem 0;
}

.gt-label { font-size: 0.95rem; color: #d1d5db; }

.gt-value { font-size: 1.25rem; font-weight: 700; color: #ffffff; }

.gt-meta {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #374151;
  font-size: 0.85rem;
  color: #d1d5db;
  gap: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.gt-meta strong { color: #f9fafb; }

#merged-view {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

#merged-view h3 { margin: 0 0 0.3rem; font-size: 1.05rem; }

footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  color: #6b7280;
  font-size: 0.85rem;
}

.bom-note {
  color: #6b7280;
  font-size: 0.9rem;
  margin: 0.25rem 0 1rem;
}

.job-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.job-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #4b5563;
}

.job-field input {
  padding: 0.45rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.95rem;
  background: #ffffff;
}

.print-only { display: none; }

#print-header h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.4rem;
}

#print-meta {
  font-size: 0.9rem;
  color: #4b5563;
}

@media print {
  @page { margin: 0.5in; }
  header, .picker, #sizing-panel, .cart-actions, #form-panel, footer, .cart-header > div:not(:first-child),
  .group-actions, #cart-summary-pill, #cart-empty-msg, .job-meta { display: none !important; }
  .print-only { display: block !important; }
  .card, .group-card { border: 1px solid #d1d5db !important; box-shadow: none; page-break-inside: avoid; }
  .group-card.collapsed .group-body { display: block !important; }
  .group-toggle, input.qty-input { border: none !important; background: transparent !important; }
  input.qty-input { padding: 0 !important; text-align: right; width: auto; font-weight: 600; }
  body { background: #ffffff; }
  main { padding: 0 !important; max-width: none; }
  .grand-totals { background: #ffffff; color: #000000; border: 2px solid #000; }
  .gt-label, .gt-value, .gt-meta { color: #000000 !important; }
  .gt-meta { border-top-color: #000 !important; }
  #bom-table th, #merged-table th { background: #f3f4f6 !important; -webkit-print-color-adjust: exact; }
  .flag-pill { border: 1px solid #999; -webkit-print-color-adjust: exact; }
  h1, h2, h3 { page-break-after: avoid; }
  .group-card { page-break-inside: avoid; margin-bottom: 0.5rem; }
}

/* ---------- Step 1: Sizing panel ---------- */
#sizing-panel { border-left: 4px solid #d97706; }

.sizing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sizing-head h2 { margin: 0; font-size: 1.15rem; display: flex; align-items: center; gap: 0.5rem; }
.sizing-head .badge { background: #fef3c7; color: #92400e; }

#sizing-body.hidden { display: none; }

.sz-result { margin-top: 1rem; }
.sz-result.hidden { display: none; }

.sz-reco {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.sz-reco-box { font-size: 1.05rem; }
.sz-reco-cover { font-size: 0.9rem; color: #4b5563; margin-top: 0.2rem; }
.sz-detail { font-size: 0.82rem; color: #6b7280; }

.conf-pill {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.conf-pill.conf-high { background: #dcfce7; color: #166534; }
.conf-pill.conf-med  { background: #fef3c7; color: #92400e; }
.conf-pill.conf-low  { background: #fee2e2; color: #991b1b; }

.verify-note { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; padding: 0.5rem 0.75rem; border-radius: 6px; margin-top: 0.75rem; }
.danger-text { color: #991b1b; }

/* ---------- Intake questionnaire ---------- */
#intake-panel { border-top: 4px solid #d97706; }
#intake-panel > h2 { margin: 0 0 0.25rem; }

.intake-who { margin-bottom: 1rem; }
.intake-who label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; font-weight: 500; color: #4b5563; }
.intake-who input {
  padding: 0.45rem 0.6rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.95rem; background: #fff;
}

.intake-section {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #d97706;
  border-bottom: 1px solid #f3f4f6;
  padding-bottom: 0.25rem;
}

.intake-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  background: #fcfcfd;
}

.intake-q { margin: 0 0 0.25rem; font-weight: 600; color: #1f2937; }
.intake-expl { margin: 0 0 0.6rem; font-size: 0.85rem; color: #6b7280; }

.intake-options { display: flex; flex-direction: column; gap: 0.35rem; }
.intake-opt {
  display: flex; align-items: flex-start; gap: 0.5rem;
  font-size: 0.92rem; color: #374151; cursor: pointer;
  padding: 0.3rem 0.5rem; border-radius: 6px;
}
.intake-opt:hover { background: #f3f4f6; }
.intake-opt input { margin-top: 0.2rem; }

.intake-text, #intake-notes {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

.intake-notes-label {
  display: block;
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #4b5563;
}

.intake-status { font-size: 0.88rem; color: #166534; align-self: center; }

/* Honeypot: off-screen, not shown to humans */
.intake-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

@media print { #intake-panel { display: none !important; } }
