* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 2rem;
  color: #1a1a1a;
  background: #f5f5f5;
}

.view { max-width: 480px; margin: 0 auto; }
.view.wide { max-width: 960px; }
.hidden { display: none; }
.muted { color: #6b7280; font-size: 0.9rem; }

h1 { font-size: 1.5rem; }

form {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #ddd;
  margin-top: 1rem;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

button {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: none;
  border-radius: 4px;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
}

button:hover { background: #1d4ed8; }

button.secondary { background: #6b7280; }
button.secondary:hover { background: #4b5563; }

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

.dashboard-nav { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

/* Add / Edit material form layout */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
.form-grid label { margin-bottom: 0.75rem; }
.form-grid .span-2 { grid-column: 1 / -1; }

/* Materials table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.875rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #eee;
}
.data-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table .row-actions { white-space: nowrap; text-align: right; }

.link-btn {
  background: none;
  color: #2563eb;
  padding: 0.2rem 0.4rem;
  font-size: 0.85rem;
}
.link-btn:hover { background: #eff6ff; }
.link-btn.danger { color: #dc2626; }
.link-btn.danger:hover { background: #fef2f2; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

#new-project-btn { margin-top: 0.5rem; }

.share-totals { margin-top: 1rem; }

/* Supplemental quote cards (per-location + optional) — owner Step 4 + manager share */
.supp-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  margin-top: 1rem;
  overflow: hidden;
}
.supp-head {
  background: #f9fafb;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  border-bottom: 1px solid #eee;
}
.supp-head .num { color: #6b7280; margin-right: 0.25rem; }
.supp-card .config-panel { padding: 0.75rem 0.9rem 1rem; }
.supp-config-row { display: flex; flex-wrap: wrap; gap: 1rem; }
.supp-markup {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.75rem 0 0.25rem;
  padding: 0.6rem 0.75rem;
  background: #f9fafb;
  border-radius: 6px;
}
.supp-markup input { width: 5.5rem; }
.supp-total { margin-top: 1rem; font-size: 1.05rem; }

/* Editable project rates (labour rate + markup %) — owner Step 4 + manager share */
.rates-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border: 1px solid #eee;
  border-radius: 8px;
}
.rates-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  font-size: 0.8rem;
}
.rates-panel input { width: 7rem; margin-top: 0; }

.error { color: #dc2626; font-size: 0.875rem; }
.msg { color: #16a34a; font-size: 0.875rem; }
.msg.error { color: #dc2626; }

/* Project workspace — Step 1 (PDF upload) */
.step-card {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #ddd;
  margin-top: 1rem;
}
.step-card h2 { margin-top: 0; }

.upload-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.75rem 0;
}
.upload-row input[type="file"] {
  flex: 1;
  min-width: 200px;
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
.upload-row button { white-space: nowrap; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Analysis progress bar */
.progress {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.progress > div {
  height: 100%;
  width: 0%;
  background: #2563eb;
  transition: width 0.2s ease;
}

/* Detected-issue flags */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.per-location { background: #fef3c7; color: #92400e; }
.badge.optional { background: #e0e7ff; color: #3730a3; }
.badge.warn { background: #fee2e2; color: #991b1b; }

/* Editable review table (Session 4) */
.review-table th.center, .review-table td.center { text-align: center; }
.review-table td input {
  display: inline-block;
  margin-top: 0;
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
}
.review-table input.desc-input { width: 100%; min-width: 13rem; }
.review-table input.notes-input { width: 100%; min-width: 8rem; }
.review-table input.count-input { width: 4.5rem; text-align: right; }
.review-table input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  cursor: pointer;
}

.add-issue-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.add-issue-row input { margin-top: 0; }
.add-issue-row input[type="number"] { width: 6rem; }
.add-issue-row input[type="text"] { flex: 1; min-width: 12rem; }

.badge.ok { background: #dcfce7; color: #166534; }
.warn-text { color: #b45309; font-weight: 600; }

/* Per-project issue config panel (Session 5) */
.review-table tr.issue-row.open > td { border-bottom: none; }
.review-table tr.config-row > td { background: #f9fafb; padding-top: 0; }

.config-panel { padding: 0.5rem 0 1rem; }
.config-note { margin: 0 0 0.75rem; color: #92400e; }

.hours-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.hours-label input {
  display: inline-block;
  width: 6rem;
  margin-top: 0;
  text-align: right;
}

.materials-mini { margin-top: 0; }
.materials-mini input.cov-input { width: 7rem; text-align: right; margin-top: 0; }
.materials-mini input.unit-input { width: 5rem; margin-top: 0; }

.add-material-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.add-material-row select { width: auto; min-width: 14rem; margin-top: 0; }
.add-material-row input.mat-coverage { width: 11rem; margin-top: 0; }

.pages-detail { margin-top: 1rem; font-size: 0.875rem; }
.pages-detail summary { cursor: pointer; color: #2563eb; }

.vision-errors { margin-top: 1rem; font-size: 0.875rem; }
.vision-errors ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }

/* Step 4 — calculation / estimate view */
.estimate-table { margin-top: 0.5rem; margin-bottom: 1.25rem; }
.estimate-table tfoot td { border-top: 2px solid #d1d5db; }
.estimate-table .setup-row td { font-style: italic; }
.summary-table { width: auto; min-width: 18rem; margin-top: 0.5rem; }
.summary-table .subtotal-row td { border-top: 2px solid #111827; font-size: 1.05rem; }
.summary-table .total-row td { border-top: 2px solid #111827; }
.summary-preview { margin-top: 1rem; font-size: 0.9rem; }
.summary-preview summary { cursor: pointer; color: #2563eb; }
