*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --blue-mid: #dbeafe;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --red: #dc2626;
  --red-light: #fef2f2;
  --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;
  --white: #ffffff;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.logo-mark {
  width: 32px; height: 32px;
  background: var(--blue);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.3px;
}

.nav-section {
  padding: 12px 8px;
  flex: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-400);
  padding: 0 12px;
  margin-bottom: 4px;
  margin-top: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-600);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.12s;
  text-decoration: none;
}

.nav-item:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-item.active { background: var(--blue-light); color: var(--blue); }

.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active .nav-icon { opacity: 1; }

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.step-nav {
  display: flex;
  align-items: center;
  gap: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-400);
  font-weight: 500;
}

.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.step.done .step-num { background: var(--green); color: white; }
.step.active .step-num { background: var(--blue); color: white; }
.step.active { color: var(--blue); font-weight: 600; }

.step-connector {
  width: 32px;
  height: 1px;
  background: var(--gray-200);
  margin: 0 4px;
}
.step.done + .step-connector { background: var(--green); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: white;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-ghost {
  background: transparent;
  color: var(--blue);
  padding: 5px 10px;
  font-size: 12.5px;
}
.btn-ghost:hover { background: var(--blue-light); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ── Content area ── */
.content {
  padding: 24px 28px;
  max-width: 1100px;
  width: 100%;
}

/* ── Project Card ── */
.project-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.project-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.3px;
}

.project-meta {
  font-size: 12.5px;
  color: var(--gray-500);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-chip {
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
}

.total-display {
  text-align: right;
}

.total-amount {
  font-size: 26px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -1px;
  line-height: 1;
}

.total-label {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.project-inputs {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--gray-100);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.styled-select {
  appearance: none;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: 6px;
  padding: 7px 30px 7px 11px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-800);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.12s;
  min-width: 160px;
}

.styled-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.styled-select.required { border-color: var(--amber); background-color: var(--amber-light); }
.styled-select.required:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,0.15); }

.required-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--amber);
  background: #fef3c7;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

.project-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ── Issue Cards (compact) ── */
.issue-cards-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.issue-card {
  flex: 1;
  min-width: 180px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s;
  box-shadow: var(--shadow-sm);
  border-left-width: 3px;
}

.issue-card:hover { box-shadow: var(--shadow-md); }

.issue-card.sev-critical { border-left-color: var(--red); }
.issue-card.sev-review   { border-left-color: var(--amber); }
.issue-card.sev-optional { border-left-color: var(--gray-300); }

.issue-card-top { display: flex; flex-direction: column; gap: 3px; }

.issue-sev-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 4px;
  width: fit-content;
  margin-bottom: 2px;
}

.issue-sev-badge.sev-critical { background: #fee2e2; color: var(--red); }
.issue-sev-badge.sev-review   { background: #fef3c7; color: var(--amber); }
.issue-sev-badge.sev-optional { background: var(--gray-100); color: var(--gray-500); }

.issue-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.3;
}

.issue-card-summary {
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.4;
}

.issue-card-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  font-size: 12.5px;
  color: var(--gray-600);
  line-height: 1.5;
}

.issue-card.expanded { background: var(--gray-50); }

.issues-resolved {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-light);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--green);
  margin-bottom: 16px;
}

/* ── Cost Summary Tiles ── */
.cost-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.cost-tile {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

.cost-tile-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.5px;
  line-height: 1;
}

.cost-tile-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
  font-weight: 500;
}

.cost-tile.highlight .cost-tile-value { color: var(--blue); }

/* ── Category Cards ── */
.category-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.category-header-new {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}

.category-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cat-stats-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.cat-stat-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 100px;
  background: var(--gray-100);
  color: var(--gray-500);
}

.cat-stat-pill.pill-ai       { background: #e0f2fe; color: #0369a1; }
.cat-stat-pill.pill-modified { background: #ede9fe; color: #7c3aed; }
.cat-stat-pill.pill-review   { background: #fef3c7; color: var(--amber); }

.cat-btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.category-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.icon-frame { background: #ede9fe; }
.icon-roof { background: #dcfce7; }
.icon-clad { background: #dbeafe; }
.icon-labour { background: #fef3c7; }

.category-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--gray-900);
}

.category-desc {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 1px;
}

.category-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.category-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  text-align: right;
}

.category-total-label {
  font-size: 11px;
  color: var(--gray-400);
  text-align: right;
}

.evidence-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--blue);
  border-radius: 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  background: var(--white);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.evidence-btn:hover { background: var(--blue-light); }

/* ── Line Items Table ── */
.line-items {
  display: none;
  border-top: 1px solid var(--gray-100);
}

.line-items.open { display: block; }

.line-items-header {
  display: grid;
  grid-template-columns: 1fr 70px 70px 100px;
  gap: 12px;
  padding: 8px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}

.lh-cell {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lh-cell:not(:first-child) { text-align: right; }

.line-item {
  display: grid;
  grid-template-columns: 1fr 70px 70px 100px;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--gray-100);
  align-items: center;
  transition: background 0.1s;
}

.line-item:last-child { border-bottom: none; }
.line-item:hover { background: var(--gray-50); }

.line-item-name {
  font-size: 13.5px;
  color: var(--gray-800);
  font-weight: 500;
}

.line-item-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  background: var(--gray-100);
  color: var(--gray-500);
}

.tag-inferred { background: #e0f2fe; color: #0369a1; }

.line-item-cell {
  font-size: 13px;
  color: var(--gray-600);
  text-align: right;
}

.line-item-total {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-900);
  text-align: right;
}

.category-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
  gap: 8px;
}

.footer-subtotal {
  font-size: 13px;
  color: var(--gray-600);
}

.footer-subtotal strong {
  color: var(--gray-900);
  font-weight: 700;
}

/* ── Quote Summary Panel ── */
.quote-panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
}

.quote-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.quote-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
}

.quote-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.quote-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13.5px;
  color: var(--gray-600);
}

.quote-row:last-child { border-bottom: none; }

.quote-row.subtotal {
  color: var(--gray-800);
  font-weight: 500;
}

.quote-row.separator {
  padding: 4px 0;
  border-bottom: none;
}

.quote-row.total {
  border-top: 2px solid var(--gray-200);
  margin-top: 4px;
  padding-top: 12px;
  font-size: 16px;
  font-weight: 800;
  color: var(--blue);
  border-bottom: none;
}

.quote-row-label { color: inherit; }
.quote-row-value { font-weight: 600; color: var(--gray-900); }
.quote-row.total .quote-row-value { color: var(--blue); font-size: 18px; }

.quote-row.muted { color: var(--gray-400); font-size: 12.5px; }

/* ── Evidence Drawer ── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  background: var(--white);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
}

.drawer-subtitle {
  font-size: 12.5px;
  color: var(--gray-500);
  margin-top: 3px;
}

.drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  transition: color 0.1s;
}

.drawer-close:hover { color: var(--gray-700); background: var(--gray-100); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.evidence-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.evidence-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.evidence-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}

.evidence-field {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.evidence-field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
}

.evidence-field-value {
  font-size: 13px;
  color: var(--gray-800);
  font-weight: 500;
}

.evidence-calc {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-200);
  font-size: 12px;
  color: var(--gray-500);
}

.evidence-calc strong { color: var(--gray-800); }

.evidence-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e0f2fe;
  color: #0369a1;
  margin-left: 4px;
}

.drawer-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 8px;
  background: var(--gray-50);
}

/* ── Update Banner ── */
.update-banner {
  background: var(--blue-light);
  border: 1px solid var(--blue-mid);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--blue);
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.update-banner.show { display: flex; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ── Editable Line Items ── */
.editable-header {
  grid-template-columns: 2fr 130px 130px 120px 90px 36px !important;
}

.editable-row {
  grid-template-columns: 2fr 130px 130px 120px 90px 36px !important;
  align-items: center;
  gap: 10px !important;
}

.edit-product-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.edit-select {
  appearance: none;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 5px;
  padding: 5px 24px 5px 8px;
  font-size: 12.5px;
  color: var(--gray-800);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  max-width: 100%;
  min-width: 0;
  flex: 1;
  transition: border-color 0.12s;
}

.edit-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }

.edit-plain-name {
  font-size: 13px;
  color: var(--gray-700);
  font-weight: 500;
}

.edit-qty-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
}

.edit-cost-cell {
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: flex-end;
}

.edit-dollar {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 600;
}

.edit-unit {
  font-size: 11px;
  color: var(--gray-400);
  white-space: nowrap;
}

.edit-input {
  border: 1.5px solid var(--gray-200);
  border-radius: 5px;
  padding: 5px 7px;
  font-size: 13px;
  color: var(--gray-800);
  font-weight: 500;
  text-align: right;
  background: var(--white);
  transition: border-color 0.12s;
}

.edit-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
.edit-input:hover { border-color: var(--gray-300); }

.edit-qty  { width: 60px; }
.edit-cost { width: 80px; }

.edit-badge-cell {
  display: flex;
  justify-content: center;
}

/* ── Source Badges ── */
.source-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.badge-ai       { background: #e0f2fe; color: #0369a1; }
.badge-modified { background: #ede9fe; color: #7c3aed; }
.badge-custom   { background: #fef3c7; color: #b45309; }
.badge-added    { background: #f0fdf4; color: #16a34a; }

/* ── Delete button ── */
.edit-delete-cell {
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}

.btn-remove:hover {
  background: var(--red-light);
  border-color: #fca5a5;
  color: var(--red);
}

.cat-stat-pill.pill-added { background: #f0fdf4; color: #16a34a; }

/* ── Quote Screen ── */

@media print {
  .quote-toolbar, .quote-doc-footer { display: none !important; }
  .quote-screen { background: white !important; padding: 0 !important; }
  .quote-doc { box-shadow: none !important; border-radius: 0 !important; }
  .qa-actions { display: none !important; }
}

.quote-screen {
  min-height: 100vh;
  background: var(--gray-100);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 60px;
}

.quote-toolbar {
  width: 100%;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.quote-toolbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qt-logo-mark {
  width: 28px; height: 28px;
  background: var(--blue);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 12px;
}

.qt-logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
}

.quote-toolbar-right {
  display: flex;
  gap: 8px;
}

.quote-doc {
  width: 100%;
  max-width: 860px;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 20px;
}

/* ── Quote Hero ── */

.quote-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
  border-radius: 12px;
  padding: 28px 32px 24px;
  color: white;
  box-shadow: 0 4px 24px rgba(37,99,235,0.25);
}

.quote-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.quote-hero-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qh-logo-mark {
  width: 42px; height: 42px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.qh-logo-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  opacity: 0.98;
}

.qh-logo-sub {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 1px;
  font-weight: 500;
}

.quote-hero-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: right;
}

.qh-meta-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  font-size: 12.5px;
}

.qh-meta-label { opacity: 0.65; }
.qh-meta-val   { font-weight: 600; opacity: 0.95; }

.quote-hero-divider {
  height: 1px;
  background: rgba(255,255,255,0.15);
  margin: 4px 0 20px;
}

.quote-hero-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.qh-project-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin-bottom: 5px;
}

.qh-project-sub {
  font-size: 13px;
  opacity: 0.7;
  margin-bottom: 10px;
}

.qh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qh-chip {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
}

.qh-total-block {
  text-align: right;
  flex-shrink: 0;
  margin-left: 24px;
}

.qh-total-amount {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.qh-total-label {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.qh-total-sub {
  font-size: 11.5px;
  opacity: 0.55;
  margin-top: 3px;
}

/* ── Section Cards ── */

.quote-section-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.qsc-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--gray-100);
}

.qsc-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.2px;
}

.qsc-subtitle {
  font-size: 12.5px;
  color: var(--gray-500);
  margin-top: 3px;
}

/* ── Project Specs ── */

.quote-specs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 4px 0;
}

.quote-spec {
  padding: 12px 24px;
  border-bottom: 1px solid var(--gray-100);
  border-right: 1px solid var(--gray-100);
}

.quote-spec:nth-child(3n) { border-right: none; }
.quote-spec:nth-last-child(-n+3) { border-bottom: none; }

.qs-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  margin-bottom: 3px;
}

.qs-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-800);
}

/* ── Scope Sections ── */

.quote-scope-section {
  padding: 18px 24px;
}

.qss-bordered {
  border-bottom: 1px solid var(--gray-100);
}

.qss-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.qss-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.qss-icon {
  font-size: 20px;
  line-height: 1;
  margin-top: 1px;
  flex-shrink: 0;
}

.qss-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 3px;
}

.qss-desc {
  font-size: 12.5px;
  color: var(--gray-500);
  max-width: 520px;
  line-height: 1.5;
}

.qss-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  flex-shrink: 0;
  margin-left: 24px;
}

.qss-items {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 24px;
  margin-left: 32px;
}

.qss-item {
  font-size: 12.5px;
  color: var(--gray-600);
  display: flex;
  align-items: flex-start;
  gap: 7px;
  line-height: 1.5;
}

.qss-tick {
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Add-ons ── */

.addon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px 24px;
}

.addon-card {
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
  position: relative;
}

.addon-card:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.addon-selected {
  border-color: var(--blue);
  background: var(--blue-light);
}

.addon-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.addon-icon { font-size: 22px; }

.addon-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-300);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-400);
  transition: all 0.15s;
  flex-shrink: 0;
}

.addon-check-on {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.addon-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.addon-desc {
  font-size: 11.5px;
  color: var(--gray-500);
  line-height: 1.4;
  margin-bottom: 10px;
}

.addon-price {
  font-size: 15px;
  font-weight: 800;
  color: var(--blue);
}

.addon-price-gst {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-400);
}

.addon-selected-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--blue-light);
  border-top: 1px solid var(--blue-mid);
  font-size: 13px;
  color: var(--blue);
}

.addon-selected-total strong {
  font-size: 15px;
  font-weight: 700;
}

/* ── Price Summary ── */

.qsc-price { }

.qps-rows {
  padding: 8px 24px 20px;
}

.qps-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13.5px;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-100);
}

.qps-row:last-child { border-bottom: none; }
.qps-row span:last-child { font-weight: 600; color: var(--gray-800); }
.qps-addons span:first-child { color: var(--blue); font-weight: 500; }
.qps-addons span:last-child  { color: var(--blue); }

.qps-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 6px 0;
}

.qps-sub span:first-child { font-weight: 600; color: var(--gray-800); }
.qps-sub span:last-child  { font-size: 15px; font-weight: 700; color: var(--gray-900); }

.qps-gst { color: var(--gray-400) !important; font-size: 12.5px !important; }
.qps-gst span:last-child { color: var(--gray-500) !important; font-weight: 500 !important; font-size: 12.5px !important; }

.qps-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 4px;
  margin-top: 4px;
  border-top: 2px solid var(--gray-200);
  font-size: 17px;
  font-weight: 800;
  color: var(--blue);
}

/* ── Assumptions ── */

.qa-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 4px 0;
}

.qa-col {
  padding: 16px 24px;
}

.qa-col:first-child { border-right: 1px solid var(--gray-100); }

.qa-col-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  margin-bottom: 10px;
}

.qa-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.qa-list li {
  font-size: 12.5px;
  color: var(--gray-600);
  line-height: 1.5;
  padding-left: 14px;
  position: relative;
}

.qa-list li::before { content: "·"; position: absolute; left: 2px; color: var(--gray-400); }

.qa-exclusions li::before { content: "×"; color: #fca5a5; font-weight: 700; }
.qa-exclusions li { color: var(--gray-500); }

.qa-note {
  padding: 12px 24px;
  border-top: 1px solid var(--gray-100);
  font-size: 11.5px;
  color: var(--gray-400);
  line-height: 1.5;
  font-style: italic;
}

/* ── Approval ── */

.qsc-approval {
  border-color: var(--blue-mid);
}

.qa-total-confirm {
  text-align: center;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--gray-100);
}

.qa-total-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  margin-bottom: 6px;
}

.qa-total-amount {
  font-size: 32px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 6px;
}

.qa-total-ref {
  font-size: 12px;
  color: var(--gray-400);
}

.qa-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 20px 24px;
}

.qa-btn-accept {
  background: var(--blue);
  color: white;
  padding: 12px 28px;
  font-size: 14px;
  border-radius: 8px;
}

.qa-btn-accept:hover { background: #1d4ed8; }

.qa-btn-changes {
  background: var(--white);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 8px;
}

.qa-btn-changes:hover { background: var(--gray-50); border-color: var(--gray-400); }

.qa-btn-pdf {
  background: var(--white);
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 8px;
}

.qa-btn-pdf:hover { background: var(--gray-50); }

.qa-footer-note {
  text-align: center;
  padding: 0 24px 18px;
  font-size: 11.5px;
  color: var(--gray-400);
  line-height: 1.5;
}

/* ── Quote Accepted state ── */

.qsc-accepted {
  text-align: center;
  padding: 48px 32px;
  border-color: #bbf7d0;
  background: var(--green-light);
}

.qa-success-icon {
  width: 56px; height: 56px;
  background: var(--green);
  border-radius: 50%;
  color: white;
  font-size: 26px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

.qa-success-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 8px;
}

.qa-success-msg {
  font-size: 14px;
  color: #166534;
  margin-bottom: 6px;
  line-height: 1.5;
}

.qa-success-ref {
  font-size: 12px;
  color: #4ade80;
  font-weight: 500;
}

/* ── Quote Doc Footer ── */

.quote-doc-footer {
  max-width: 860px;
  width: 100%;
  padding: 20px 20px 0;
  text-align: center;
}

.quote-doc-footer p {
  font-size: 11.5px;
  color: var(--gray-400);
  line-height: 1.8;
}

/* ── Add Item Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.12s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.08);
  width: 740px;
  max-width: 96vw;
  height: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.15s ease;
}

@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.2px;
}

.modal-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 15px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.modal-close-btn:hover { background: var(--gray-100); color: var(--gray-700); }

.modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.modal-fam-col {
  width: 172px;
  flex-shrink: 0;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  padding: 6px 0;
  background: var(--gray-50);
}

.modal-fam-btn {
  display: block;
  width: 100%;
  padding: 8px 14px;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: normal;
  line-height: 1.4;
}

.modal-fam-btn:hover { background: var(--gray-100); color: var(--gray-900); }

.modal-fam-btn.mfb-on {
  border-left-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
  font-weight: 600;
}

.modal-prod-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.modal-search-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  background: var(--white);
}

.modal-search-inp {
  width: 100%;
  padding: 7px 11px;
  font-size: 13px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  outline: none;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-search-inp:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.modal-prod-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 0;
}

.modal-empty {
  padding: 36px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--gray-400);
}

.modal-prod-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
}

.modal-prod-row:last-child { border-bottom: none; }
.modal-prod-row:hover { background: var(--gray-50); }

.modal-prod-info {
  flex: 1;
  min-width: 0;
}

.modal-prod-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-prod-sku {
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 1px;
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-prod-price-wrap {
  flex-shrink: 0;
  text-align: right;
  min-width: 72px;
}

.modal-prod-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
}

.modal-prod-unit {
  font-size: 11px;
  color: var(--gray-400);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .cost-summary { grid-template-columns: 1fr 1fr; }
  .drawer { width: 100%; }
  .issue-cards-row { flex-direction: column; }
  .editable-header, .editable-row { grid-template-columns: 1fr 80px 90px 90px 70px 32px !important; }
  .quote-hero-top { flex-direction: column; gap: 16px; }
  .quote-hero-meta { text-align: left; }
  .qh-meta-row { justify-content: flex-start; }
  .quote-hero-bottom { flex-direction: column; gap: 16px; }
  .qh-total-block { text-align: left; margin-left: 0; }
  .quote-specs-grid { grid-template-columns: 1fr 1fr; }
  .qss-items { grid-template-columns: 1fr; }
  .addon-grid { grid-template-columns: 1fr 1fr; }
  .qa-cols { grid-template-columns: 1fr; }
  .qa-col:first-child { border-right: none; border-bottom: 1px solid var(--gray-100); }
  .qa-actions { flex-direction: column; align-items: center; }
}
