:root {
  --srr-red: #d12b2b;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --card: #ffffff;
  --blue: #1f4e79;
  --good: #14794a;
  --warn: #b45309;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid var(--line); padding: 12px 20px;
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.srr {
  font-weight: 800; color: #fff; background: var(--ink); border-radius: 8px;
  padding: 6px 10px; letter-spacing: 1px;
}
.srr::first-letter { color: var(--srr-red); }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-text { font-weight: 600; line-height: 1.15; }
.brand-text small { color: var(--muted); font-weight: 500; }

.wrap { max-width: 860px; margin: 24px auto; padding: 0 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 24px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.card h2 { margin: 0 0 6px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  background: var(--blue); color: #fff; border-radius: 50%; font-size: 14px; font-weight: 700;
}
.muted { color: var(--muted); margin: 4px 0 16px; }
.hidden { display: none !important; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 2px dashed #cbd5e1; border-radius: 12px; padding: 34px; cursor: pointer;
  text-align: center; transition: .15s; background: #fafbfc;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: #f0f6fc; }
.dz-icon { font-size: 34px; }
.dz-main { font-weight: 600; }
.dz-status { color: var(--good); font-size: 14px; min-height: 18px; }
.dz-status.err { color: var(--srr-red); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 680px) {
  .grid { grid-template-columns: 1fr; }
  /* stack the bottom action buttons vertically, full width, so none hang off-screen */
  .actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .actions button { width: 100%; margin-top: 0; text-align: center; }
  /* let the top bar wrap instead of pushing its buttons off the edge */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .wrap { margin: 16px auto; padding: 0 12px; }
  .card { padding: 18px 16px; }
}
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 4px; }
legend { font-weight: 700; color: var(--blue); padding: 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field input[type="number"], .field input[type="text"], .field select {
  width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 15px;
}
.field.checkbox label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.field.checkbox input { width: auto; }
.hint { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }

.primary-btn {
  background: var(--blue); color: #fff; border: 0; border-radius: 9px;
  padding: 11px 18px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 6px;
}
.primary-btn:hover { background: #1a4368; }
.ghost-btn {
  background: #fff; color: var(--ink); border: 1px solid #cbd5e1; border-radius: 9px;
  padding: 9px 14px; font-size: 14px; cursor: pointer;
}
.ghost-btn:hover { background: #f3f4f6; }

.result-head { margin-bottom: 14px; }
.mat-table, .price-table { width: 100%; border-collapse: collapse; }
.mat-table th, .mat-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.mat-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.mat-table .qty { font-weight: 700; white-space: nowrap; }
.mat-table .basis { color: var(--muted); font-size: 13px; }

.price-block { margin-top: 24px; border-top: 2px solid var(--line); padding-top: 14px; }
.price-block h3 { margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.margin-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 12px; background: #f0f6fc; border: 1px solid #cfe3f5; border-radius: 10px; }
.margin-row label { font-weight: 600; font-size: 14px; }
.margin-row input { width: 70px; padding: 7px 9px; border: 1px solid #94b8d8; border-radius: 8px; font-size: 16px; font-weight: 600; }
.margin-row .pct { font-weight: 600; margin-left: -4px; }
.margin-row .hint { flex-basis: 100%; margin: 2px 0 0; }
.warn-pill { background: #fef3c7; color: var(--warn); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.ok-pill { background: #dcfce7; color: var(--good); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.price-note { background: #fff7ed; border: 1px solid #fed7aa; color: var(--warn); font-size: 13px; padding: 8px 10px; border-radius: 8px; margin: 10px 0 0; }
.sqft-guard { font-weight: 600; }
.sqft-guard.guard-ok   { background: #dcfce7; border-color: #86efac; color: var(--good); }
.sqft-guard.guard-bad  { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.sqft-guard.guard-high { background: #fef3c7; border-color: #fcd34d; color: #b45309; }
.quote-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.quote-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.quote-info strong { font-size: 14px; }
.quote-info .muted { font-size: 12px; }
.quote-btns { display: flex; gap: 6px; flex: none; }
.quote-btns .danger { color: #b91c1c; border-color: #fca5a5; }
.quote-btns .danger:hover { background: #fee2e2; }
.quote-btns a.ghost-btn { text-decoration: none; display: inline-flex; align-items: center; }
.sign-result { background: #f0fdf4; border: 1px solid #86efac; border-radius: 10px; padding: 12px 14px; margin-top: 12px; font-size: 14px; }
.sign-result strong { color: #15803d; }
.sign-link-row { display: flex; gap: 8px; margin: 8px 0; }
.sign-link-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.sig-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; align-self: center; }
.sig-badge.sent { background: #fef3c7; color: #b45309; }
.sig-badge.signed { background: #dcfce7; color: #15803d; }
.drawer-sub { font-size: 12px; letter-spacing: .5px; color: var(--muted); margin: 14px 0 8px; text-transform: uppercase; }
.trade-select { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; flex-wrap: wrap; }
.trade-select .trade-label { font-weight: 600; color: var(--muted); font-size: 14px; margin-right: 4px; }
.trade-btn { cursor: pointer; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 8px 18px; font-size: 14px; font-weight: 600; }
.trade-btn:hover { border-color: var(--brand); }
.trade-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
#tradeOpts.show-siding .t-gutters, #tradeOpts.show-gutters .t-siding { display: none; }
.waste-options { margin-top: 8px; }
.wo-label { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.wo-row { display: flex; flex-wrap: wrap; gap: 6px; }
.wo-btn { display: flex; flex-direction: column; align-items: center; line-height: 1.1; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 13px; font-weight: 600; color: var(--ink); }
.wo-btn small { font-weight: 400; font-size: 10px; color: var(--muted); margin-top: 1px; }
.wo-btn:hover { border-color: var(--brand); }
.wo-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.wo-btn.active small { color: #e5e7eb; }
.price-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.price-table .amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.price-table .total td { font-weight: 800; font-size: 17px; border-bottom: 0; border-top: 2px solid var(--ink); }

.scope-toggle { display: flex; gap: 8px; }
.scope-btn { background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; }
.scope-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.siding-sides { grid-column: 1 / -1; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 2px 0 6px; }
.ss-hint { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.ss-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; }
.ss-row input.ss-cb { width: 18px; height: 18px; }
.ss-dir { flex: 0 0 64px; font-weight: 600; }
.ss-row input.ss-area { width: 92px; padding: 6px 8px; border: 1px solid #c7ccd3; border-radius: 7px; font-size: 14px; }
.ss-unit { color: var(--muted); font-size: 13px; }
.ss-total { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 14px; }
.ss-none { font-size: 13px; color: var(--muted); }

.ins-banner { border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; font-size: 14px; line-height: 1.45; }
.ins-banner.ins-stop { background: #fef2f2; border: 1.5px solid #ef4444; color: #7f1d1d; }
.ins-banner.ins-warn { background: #fffbeb; border: 1px solid #f59e0b; color: #78350f; }

.actions { display: flex; gap: 10px; margin-top: 20px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; justify-content: flex-end; z-index: 20; }
.drawer { width: min(440px, 92vw); height: 100%; background: #fff; padding: 22px; overflow-y: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; }
.drawer-actions { display: flex; gap: 10px; margin-top: 16px; }
.logo-uploader h3 { margin: 0 0 4px; }
.logo-preview {
  min-height: 70px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed #cbd5e1; border-radius: 10px; padding: 12px; margin-bottom: 10px;
  background: #fafbfc;
}
.logo-preview img { max-width: 100%; max-height: 120px; }
.file-btn { display: inline-block; margin-right: 8px; }
.drawer-sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

@media print {
  .topbar, #uploadCard, #measureCard, .actions, #settingsBtn { display: none !important; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}
