:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9e1e8;
  --accent: #1f8a70;
  --accent-dark: #146356;
  --pale-green: #d8f1e8;
  --pale-blue: #edf6ff;
  --pale-red: #fff1f1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #eef3f6;
}

.portal-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.portal-card {
  width: min(540px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(16, 42, 67, .12);
  overflow: hidden;
}

.portal-card.workspace-active { width: min(1120px, 100%); }

.portal-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.portal-brand img { width: 92px; max-height: 58px; object-fit: contain; }
.portal-brand span { color: var(--muted); font-size: 13px; font-weight: 700; }
h1 { margin: 3px 0 0; font-size: 27px; letter-spacing: 0; }
h2 { margin: 0 0 7px; font-size: 21px; letter-spacing: 0; }
p { margin: 0; color: var(--muted); line-height: 1.45; }

.portal-state {
  display: grid;
  gap: 18px;
  padding: 24px;
}

label { display: grid; gap: 6px; color: #344054; font-size: 13px; font-weight: 700; }
input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  font: inherit;
}
textarea { resize: vertical; }
input:focus,
select:focus,
textarea:focus { outline: 2px solid #b7d5f0; border-color: #6ca7d5; }
#portalCode { font-size: 22px; letter-spacing: 6px; text-align: center; }

button {
  width: fit-content;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #7cc7ad;
  border-radius: 6px;
  background: var(--pale-green);
  color: #0f5f4d;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { cursor: wait; opacity: .7; }
.portal-utility { border-color: #b7d5f0; background: var(--pale-blue); color: #234d73; }
.portal-danger { border-color: #efb4b4; background: var(--pale-red); color: #8f2b2b; }
.portal-code-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.portal-check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.portal-check input { width: 16px; min-height: 16px; }

.portal-message { margin: 0 24px 24px; padding: 11px 13px; border: 1px solid #efb4b4; border-radius: 6px; background: var(--pale-red); color: #8f2b2b; }
.portal-message.success { border-color: #b9dccd; background: #eef8f3; color: #1f5d4d; }
.portal-status { width: fit-content; padding: 5px 9px; border: 1px solid #b9dccd; border-radius: 999px; background: #eef8f3; color: #1f5d4d; font-size: 12px; font-weight: 700; }

dl { display: grid; gap: 8px; margin: 0; }
dl div { display: grid; grid-template-columns: 90px 1fr; gap: 12px; }
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.portal-notice { display: grid; gap: 4px; padding: 14px; border: 1px solid #b7d5f0; border-radius: 6px; background: var(--pale-blue); }
.portal-notice span { color: #475467; }

.portal-userbar,
.portal-section-heading,
.estimate-actions,
.estimate-card-heading,
.estimate-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.portal-userbar { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.portal-userbar h2 { margin-top: 8px; }
.portal-userbar p { margin-top: 3px; }
.portal-section-heading { align-items: flex-start; }
.portal-section-heading h2 { margin-bottom: 4px; }
.estimate-header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.estimate-workspace,
.estimate-editor { display: grid; gap: 16px; }
.estimate-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 10px;
}
.estimate-search-summary { min-height: 16px; color: var(--muted); font-size: 12px; }
.estimate-list { display: grid; gap: 9px; }
.estimate-card {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.estimate-card-ready { border-color: #93cdb4; background: #f0faf5; }
.estimate-card h3 { margin: 0; font-size: 16px; }
.estimate-card-meta { color: var(--muted); font-size: 13px; }
.estimate-card-title,
.estimate-card-tools { display: flex; align-items: center; gap: 10px; min-width: 0; }
.estimate-card-heading,
.estimate-card-tools { flex-wrap: wrap; }
.estimate-card-title h3 { overflow-wrap: anywhere; }
.estimate-card-tools { justify-content: flex-end; margin-left: auto; }
.estimate-card-updated { color: var(--muted); font-size: 12px; white-space: nowrap; }
.estimate-card-actions { justify-content: flex-end; flex-wrap: wrap; }
.estimate-card-actions button { min-height: 32px; padding: 0 10px; }
.estimate-quote-number { color: #1f5d4d; font-size: 12px; font-weight: 700; white-space: nowrap; }
.estimate-status {
  display: inline-block;
  margin-bottom: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf6ff;
  color: #234d73;
  font-size: 12px;
  font-weight: 700;
}
.estimate-status-ready { background: #d8f1e8; color: #0f5f4d; }
.estimate-ready-note { color: #1f5d4d; font-size: 13px; font-weight: 700; }
.estimate-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.estimate-fields label:nth-child(-n+2) { grid-column: span 2; }
.estimate-project { grid-column: span 2; }
.estimate-fields input:required:invalid:not(:disabled) { border-color: #e4a1aa; background: #fff0f2; }
.estimate-fields input:required:valid:not(:disabled) { background: #fff; }
.estimate-fields input:required:invalid:not(:disabled):focus { border-color: #c84f60; outline-color: #f1b6be; }
.portal-shipping-fields input:required:invalid:not(:disabled) { border-color: #e4a1aa; background: #fff0f2; }
.portal-shipping-fields input:required:valid:not(:disabled) { background: #fff; }
.portal-shipping-fields input:required:invalid:not(:disabled):focus { border-color: #c84f60; outline-color: #f1b6be; }
.estimate-notes { grid-column: 1 / -1; }
.portal-estimate-details { display: grid; grid-template-columns: 1.35fr .65fr; gap: 12px; }
.portal-address-stack { display: grid; gap: 12px; }
.portal-pricing-level { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 17px; border: 2px solid #d59a12; border-radius: 7px; background: #fff7d6; }
.portal-pricing-level > div:first-child { display: grid; gap: 5px; }
.portal-pricing-level p { margin: 0; color: #694c0a; font-size: 12px; }
.portal-pricing-badge { justify-self: start; padding: 5px 9px; border-radius: 999px; background: #9a5700; color: #fff; font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.portal-pricing-badge.is-wholesale { background: #155f91; }
.portal-pricing-toggle { display: grid; gap: 5px; min-width: 230px; }
.portal-pricing-toggle > span { color: #526b7a; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.portal-pricing-toggle > div { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.portal-pricing-toggle button { background: #fff; color: #315164; }
.portal-pricing-toggle button.active { border-color: #0d755d; background: #0d755d; color: #fff; }
.portal-detail-card { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfd; }
.portal-detail-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.portal-detail-heading h3 { margin: 0; font-size: 16px; }
.portal-detail-heading span { color: var(--muted); font-size: 12px; font-weight: 700; }
.portal-address-toggle { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.portal-address-toggle input { width: 18px; height: 18px; margin: 0; }
.portal-shipping-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.portal-shipping-fields label:nth-child(1), .portal-shipping-fields label:nth-child(2) { grid-column: span 3; }
.portal-shipping-fields label:nth-child(3) { grid-column: span 3; }
.portal-shipping-fields label:nth-child(4) { grid-column: span 1; }
.portal-shipping-fields label:nth-child(5) { grid-column: span 2; }
.portal-freight-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: end; }
.portal-freight-fields output { display: flex; align-items: center; min-height: 42px; padding: 0 10px; border: 1px solid #b9ccda; border-radius: 4px; background: #eef6fb; color: #174c3f; font-size: 17px; font-weight: 800; }
.portal-structures {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.portal-structures-heading,
.portal-structure-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.portal-structures-heading h3 { margin: 0 0 4px; font-size: 18px; }
.portal-structure-lines { display: grid; gap: 10px; }
.portal-structure-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}
.portal-structure-card-heading > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.portal-structure-card-heading span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.portal-structure-card-heading button { min-height: 32px; padding: 0 10px; }
.portal-structure-fields {
  display: grid;
  grid-template-columns: minmax(150px, 1.6fr) repeat(5, minmax(76px, .62fr)) minmax(95px, .7fr) minmax(90px, .8fr);
  gap: 8px;
  align-items: end;
}
.portal-umbrella-fields {
  grid-template-columns: minmax(250px, 1.7fr) 72px minmax(190px, 1.3fr) minmax(105px, .75fr) minmax(115px, .8fr) minmax(125px, .9fr);
}
.portal-fabric-sail-fields {
  grid-template-columns: minmax(250px, 1.7fr) 72px minmax(150px, 1fr) repeat(3, minmax(105px, .75fr));
}
.portal-fabric-sail-options { justify-content: flex-end; }
@media (max-width: 1080px) and (min-width: 761px) {
  .portal-umbrella-fields {
    grid-template-columns: minmax(235px, 1.55fr) 72px minmax(185px, 1.2fr) minmax(105px, .75fr);
  }
  .portal-umbrella-fields .portal-structure-footing { grid-column: auto; }
}
.portal-roof-options {
  display: flex;
  align-items: end;
  gap: 16px;
  padding: 8px 10px;
  border: 1px solid #d7e5ef;
  border-radius: 5px;
  background: #f8fbfd;
}
.portal-roof-options > label:first-child { width: min(310px, 100%); }
.portal-roof-options > span { color: var(--muted); font-size: 12px; font-weight: 700; padding-bottom: 12px; }
.portal-pitch-control { display: flex; align-items: flex-end; gap: 10px; }
.portal-pitch-control > label { width: 112px; }
.portal-pitch-control input { width: 100%; }
.portal-pitch-run { display: grid; gap: 4px; padding-bottom: 7px; }
.portal-pitch-run span { color: var(--muted); font-size: 12px; font-weight: 700; }
.portal-pitch-run strong { color: #173f5f; font-size: 21px; line-height: 1; white-space: nowrap; }
.portal-calculated-field input {
  background: #eef6fb;
  color: #24445c;
  font-weight: 700;
}
.portal-structure-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid #cbdce8;
  border-radius: 5px;
  background: #f4f9fc;
}
.portal-option-choices { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.portal-option-choices label { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.portal-option-choices input { width: 16px; height: 16px; margin: 0; }
.portal-bay-direction { display: flex; align-items: stretch; gap: 10px; margin: 12px 0 0; padding: 10px; border: 1px solid #ccdce6; border-radius: 6px; background: #f7fafc; }
.portal-bay-direction legend { padding: 0 5px; color: #274c61; font-size: 12px; font-weight: 800; }
.portal-bay-direction label { display: flex; align-items: center; gap: 8px; min-width: 180px; padding: 9px 12px; border: 1px solid #cbd8e1; border-radius: 6px; background: #fff; cursor: pointer; }
.portal-bay-direction label:has(input:checked) { border-color: #168666; background: #eaf8f3; box-shadow: inset 0 0 0 1px #168666; }
.portal-bay-direction input { width: 17px; height: 17px; margin: 0; accent-color: #168666; }
.portal-bay-direction span { display: grid; gap: 2px; }
.portal-bay-direction small { color: var(--muted); font-size: 11px; font-weight: 400; }
.portal-option-disabled { color: #8a96a3; }
.portal-estimated-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
  white-space: nowrap;
}
.portal-estimated-price span { color: var(--muted); font-size: 12px; font-weight: 700; }
.portal-estimated-price strong { color: #0f5f4d; font-size: 17px; }
.portal-estimated-price.is-pending strong { color: #5d7388; font-size: 13px; }
.portal-estimated-footing { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.portal-estimated-footing span { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.portal-estimated-footing strong { overflow-wrap: anywhere; }
.portal-guardrail-note { color: var(--muted); font-size: 12px; }
.portal-structure-error {
  padding: 8px 10px;
  border: 1px solid #efb4b4;
  border-radius: 5px;
  background: var(--pale-red);
  color: #8f2b2b;
  font-size: 13px;
}
.portal-structure-empty {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px dashed #aac3d8;
  border-radius: 6px;
  background: #f7fbff;
  color: #475467;
}
.portal-live-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #acd8c7;
  border-radius: 6px;
  background: #edf8f3;
  color: #174c3f;
}
.portal-live-total span { font-size: 13px; font-weight: 700; }
.portal-live-total strong { font-size: 22px; }
.portal-live-total small { color: #4e6d64; font-size: 12px; font-weight: 700; }
.estimate-actions { justify-content: flex-start; flex-wrap: wrap; }
.estimate-empty { padding: 24px; border: 1px dashed var(--line); border-radius: 6px; text-align: center; }
.estimate-empty strong { display: block; margin-bottom: 5px; }

.estimate-preview-dialog {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid #aebdca;
  border-radius: 8px;
  background: #eef3f6;
  box-shadow: 0 24px 60px rgba(15, 42, 67, .28);
}
.estimate-preview-dialog::backdrop { background: rgba(24, 39, 55, .62); }
.portal-send-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid #aebdca; border-radius: 9px; background: #fff; box-shadow: 0 24px 60px rgba(15, 42, 67, .28); }
.portal-send-dialog::backdrop { background: rgba(24, 39, 55, .62); }
.portal-send-shell { display: grid; gap: 12px; padding: 20px; overflow: auto; }
.portal-send-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.portal-send-heading span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.portal-send-heading h2 { margin: 3px 0 0; }
.portal-send-from { margin: 0; padding: 10px 12px; border: 1px solid #cfe1eb; border-radius: 6px; background: #f4f9fb; color: #36586c; font-size: 13px; }
.portal-send-shell > label { display: grid; gap: 5px; font-size: 12px; font-weight: 700; }
.portal-send-shell > small { margin-top: -8px; color: var(--muted); }
.portal-send-shell input, .portal-send-shell textarea { width: 100%; }
.portal-send-attachments { display: grid; gap: 8px; margin: 2px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 7px; }
.portal-send-attachments legend { padding: 0 5px; font-weight: 800; }
.portal-send-attachments > div { display: grid; gap: 7px; }
.portal-send-attachment { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px; padding: 8px 9px; border: 1px solid #dce5eb; border-radius: 6px; background: #fff; }
.portal-send-attachment.required { background: #edf8f3; border-color: #acd8c7; }
.portal-send-attachment input { width: auto; }
.portal-send-attachment span { display: grid; gap: 2px; min-width: 0; }
.portal-send-attachment strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-send-attachment small { color: var(--muted); }
.portal-email-size-warning { color: #9d2424 !important; font-weight: 800; }
.portal-send-actions { display: flex; gap: 9px; justify-content: flex-end; }
.portal-contract-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid #aebdca;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 42, 67, .28);
}
.portal-contract-dialog::backdrop { background: rgba(24, 39, 55, .62); }
.portal-contract-shell { display: grid; gap: 13px; padding: 20px; overflow: auto; }
.portal-contract-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.portal-contract-heading span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.portal-contract-heading h2 { margin: 3px 0 0; }
.portal-contract-note { margin: 0; padding: 10px 12px; border: 1px solid #cfe1eb; border-radius: 6px; background: #f4f9fb; color: #36586c; }
.portal-contract-shell > label { display: grid; gap: 5px; font-size: 12px; font-weight: 700; }
.portal-contract-shell > small { margin-top: -8px; color: var(--muted); }
.portal-contract-shell textarea { width: 100%; min-height: 145px; resize: vertical; overflow-y: hidden; }
.portal-contract-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.portal-contract-summary div { min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: #f8fafb; }
.portal-contract-summary span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.portal-contract-summary strong { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.portal-contract-locations { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #f8fbfd; }
.portal-contract-locations h3 { margin: 0; }
.portal-contract-locations > label:not(.portal-address-toggle) { display: grid; gap: 5px; font-size: 12px; font-weight: 700; }
.portal-contract-table-wrap { overflow-x: auto; }
.portal-contract-table-wrap h3 { margin: 0 0 7px; }
.portal-contract-table { width: 100%; min-width: 850px; border-collapse: collapse; font-size: 12px; }
.portal-contract-table th, .portal-contract-table td { padding: 7px 6px; border: 1px solid #b9c8d4; white-space: nowrap; text-align: left; }
.portal-contract-table thead th { color: #fff; background: #24466f; }
.portal-contract-table th:nth-child(3), .portal-contract-table td:nth-child(3),
.portal-contract-table th:nth-child(4), .portal-contract-table td:nth-child(4),
.portal-contract-table th:nth-child(5), .portal-contract-table td:nth-child(5),
.portal-contract-table th:nth-child(7), .portal-contract-table td:nth-child(7) { text-align: center; }
.portal-contract-table th:last-child, .portal-contract-table td:last-child { text-align: right; }
.portal-contract-table tfoot th { background: #edf3f7; }
.portal-contract-actions { display: flex; gap: 9px; justify-content: flex-end; }
.estimate-preview-shell { display: grid; gap: 14px; padding: 16px; }
.estimate-preview-heading,
.estimate-preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.estimate-preview-heading span { color: var(--muted); font-size: 12px; font-weight: 700; }
.estimate-preview-heading h2 { margin: 3px 0 0; }
.estimate-preview-actions { justify-content: flex-end; }
.estimate-preview-dialog .quote-preview-content {
  overflow: auto;
  max-height: calc(100vh - 130px);
  padding: 22px;
  border: 1px solid var(--line);
  background: #dfe6eb;
}
.estimate-preview-dialog .customer-quote {
  width: min(816px, 100%);
  min-height: 1056px;
  margin: 0 auto;
  padding: 34px 38px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(17, 36, 54, .14);
}

.portal-spinner { width: 28px; height: 28px; border: 3px solid #d9e1e8; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .portal-page { padding: 12px; }
  .portal-brand, .portal-state { padding: 18px; }
  .portal-brand img { width: 72px; }
  .portal-userbar,
  .portal-section-heading { align-items: stretch; flex-direction: column; }
  .estimate-header-actions { justify-content: flex-start; }
  .estimate-search { grid-template-columns: 1fr 1fr; }
  .estimate-search label { grid-column: 1 / -1; }
  .estimate-card-heading,
  .estimate-card-tools { align-items: flex-start; flex-direction: column; }
  .estimate-card-tools { margin-left: 0; }
  .estimate-fields { grid-template-columns: 1fr; }
  .portal-structures-heading,
  .portal-structure-card-heading { align-items: stretch; flex-direction: column; }
  .portal-structure-card-heading > div { align-items: flex-start; flex-direction: column; gap: 3px; }
  .portal-structure-options { align-items: flex-start; flex-direction: column; }
  .portal-estimated-price { margin-left: 0; }
  .portal-live-total { align-items: flex-end; flex-direction: column; gap: 2px; }
  .portal-structure-fields { grid-template-columns: 1fr 1fr; }
  .portal-structure-options { align-items: stretch; flex-direction: column; }
  .portal-roof-options { align-items: stretch; flex-direction: column; gap: 8px; }
  .portal-roof-options > label:first-child { width: 100%; }
  .portal-roof-options > span { padding-bottom: 0; }
  .portal-estimated-footing { align-items: flex-start; flex-direction: column; gap: 2px; }
  .portal-structure-type,
  .portal-structure-footing { grid-column: 1 / -1; }
  .estimate-fields label:nth-child(-n+2),
  .estimate-project,
  .estimate-notes { grid-column: auto; }
  .estimate-preview-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .portal-send-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .portal-contract-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .portal-contract-summary { grid-template-columns: 1fr; }
  .estimate-preview-shell { padding: 10px; }
  .estimate-preview-heading { align-items: stretch; flex-direction: column; }
  .estimate-preview-actions { justify-content: flex-start; flex-wrap: wrap; }
  .estimate-preview-dialog .quote-preview-content { padding: 8px; max-height: calc(100vh - 160px); }
  .estimate-preview-dialog .customer-quote { min-width: 720px; padding: 28px 32px; }
}

/* Full-page authenticated Customer Portal */
body.portal-authenticated { background: #f3f6f8; }
body.portal-authenticated .portal-page { display: block; min-height: 100vh; padding: 0; }
.portal-card.workspace-active {
  width: 100%;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.portal-card.workspace-active > .portal-brand { display: none; }
.portal-card.workspace-active > .portal-message {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 18px;
  max-width: min(520px, calc(100vw - 44px));
  margin: 0;
  box-shadow: 0 8px 28px rgba(16, 42, 67, .18);
}
.portal-app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
  padding: 0;
}
.portal-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  color: #fff;
  background: #12344f;
}
.portal-sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 5px 20px; border-bottom: 1px solid rgba(255,255,255,.15); }
.portal-sidebar-brand img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; }
.portal-sidebar-brand div { display: grid; gap: 2px; }
.portal-sidebar-brand strong { font-size: 15px; }
.portal-sidebar-brand span { color: #bad0df; font-size: 11px; }
.portal-navigation { display: grid; gap: 5px; margin-top: 20px; }
.portal-nav-button {
  display: grid;
  grid-template-columns: 25px 1fr;
  align-items: center;
  width: 100%;
  min-height: 43px;
  padding: 0 11px;
  border-color: transparent;
  color: #e7f0f6;
  background: transparent;
  text-align: left;
}
.portal-nav-button span { color: #91b6cc; font-size: 18px; text-align: center; }
.portal-nav-button:hover, .portal-nav-button.active { border-color: #557990; background: #214b69; color: #fff; }
.portal-sidebar-user { display: grid; gap: 4px; margin-top: auto; padding: 14px 10px 2px; border-top: 1px solid rgba(255,255,255,.15); overflow-wrap: anywhere; }
.portal-sidebar-user > span { color: #bad0df; font-size: 11px; }
.portal-sidebar-user strong { font-size: 14px; }
.portal-sidebar-user b { margin-top: 3px; color: #dce9f1; font-size: 12px; }
.portal-signout { min-height: 34px; margin-top: 9px; border-color: #87a5b9; background: #f1f7fa; color: #173f5b; }
.portal-main { min-width: 0; padding: 30px clamp(24px, 3.5vw, 58px) 50px; }
.portal-dashboard, .portal-help { display: grid; gap: 24px; max-width: 1320px; margin: 0 auto; }
.portal-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.portal-page-header h2 { margin: 5px 0; font-size: clamp(25px, 2.3vw, 34px); }
.estimate-identity-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.estimate-quote-identity { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border: 1px solid #9ab6ca; border-radius: 999px; background: #eef6fb; color: #183f5d; font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.portal-eyebrow { color: #59758b; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.portal-dashboard-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.portal-dashboard-actions button { display: grid; gap: 7px; width: 100%; min-height: 120px; padding: 18px; border-color: #c8d8e4; background: #fff; color: var(--ink); text-align: left; box-shadow: 0 4px 14px rgba(30, 61, 82, .06); }
.portal-dashboard-actions button:first-child { border-color: #79c4a9; background: #edf9f4; }
.portal-dashboard-actions strong { font-size: 16px; }
.portal-dashboard-actions span { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.45; }
.portal-recent-panel, .portal-help-card { padding: 20px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.portal-recent-estimate { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 10px 12px; border: 0; border-bottom: 1px solid #e5ebf0; border-radius: 0; background: #fff; color: var(--ink); text-align: left; }
.portal-recent-estimate:hover { background: #f7fafc; }
.portal-recent-estimate > span:nth-child(2) { display: grid; gap: 3px; }
.portal-recent-estimate small, .portal-recent-estimate time { color: var(--muted); font-size: 12px; }
.estimate-workspace, .estimate-editor { max-width: 1420px; margin: 0 auto; }
.portal-builder-layout { display: grid; grid-template-columns: minmax(250px, 310px) minmax(0, 1fr); align-items: start; gap: 18px; }
.portal-builder-workspace { display: grid; gap: 16px; min-width: 0; }
.portal-files { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.portal-files-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.portal-files-heading h3 { margin: 0 0 4px; }
.portal-files-heading p { margin: 0; }
.portal-files-heading > span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.portal-file-drop-zone { display: grid; place-items: center; gap: 5px; min-height: 126px; margin-top: 14px; padding: 16px; border: 2px dashed #a9bdca; border-radius: 8px; background: #f7fafc; text-align: center; }
.portal-file-drop-zone.is-dragging { border-color: #168b67; background: #eaf8f3; }
.portal-file-drop-zone.is-locked { min-height: 64px; border-style: solid; background: #f3f5f7; }
.portal-file-drop-zone > span { color: var(--muted); font-size: 12px; }
.portal-file-drop-zone .portal-file-note { margin-top: 3px; color: #7a5a16; }
.portal-file-drop-zone button { margin-top: 7px; }
.portal-file-list { display: grid; gap: 8px; margin-top: 12px; }
.portal-file-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px; border: 1px solid #d8e2e9; border-radius: 7px; background: #fff; }
.portal-file-icon, .portal-file-thumbnail-wrap { display: grid; place-items: center; width: 48px; height: 42px; overflow: hidden; border-radius: 5px; background: #eaf1f5; color: #31566d; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.portal-file-thumbnail-wrap { position: relative; }
.portal-file-thumbnail { width: 100%; height: 100%; object-fit: contain; }
.portal-file-thumbnail-badge { position: absolute; right: 2px; bottom: 2px; padding: 1px 3px; border-radius: 2px; background: #9d2424; color: #fff; font-size: 8px; line-height: 1.2; }
.portal-file-main { display: grid; gap: 3px; min-width: 0; }
.portal-file-main strong, .portal-file-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-file-main span { color: var(--muted); font-size: 11px; }
.portal-file-actions { display: flex; align-items: center; gap: 6px; }
.portal-file-actions a,
.portal-file-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #b7d5f0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.portal-file-actions button.portal-danger { border-color: #efb4b4; }
.portal-file-empty { margin: 0; padding: 10px 0 2px; color: var(--muted); font-size: 12px; }
.portal-structure-catalog { position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow: auto; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.portal-catalog-heading { display: grid; gap: 4px; margin-bottom: 16px; }
.portal-catalog-heading > span { color: #59758b; font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.portal-catalog-heading h3 { margin: 0; font-size: 19px; }
.portal-catalog-heading p { font-size: 12px; }
.portal-catalog-cancel { min-height: 31px; margin-top: 6px; padding: 0 9px; }
.portal-catalog-group { margin-top: 18px; }
.portal-catalog-group h4 { margin: 0 0 8px; color: #49687d; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.portal-product-grid { display: grid; gap: 8px; }
.portal-product-card { display: grid; grid-template-columns: 74px minmax(0, 1fr); align-items: center; gap: 10px; width: 100%; min-height: 76px; padding: 7px; border-color: #d4dee6; background: #fff; color: var(--ink); text-align: left; }
.portal-product-card:hover { border-color: #7bbba5; background: #f3faf7; }
.portal-product-image, .portal-selected-structure-image { display: grid; place-items: center; overflow: hidden; border-radius: 5px; background: #eef3f6; }
.portal-product-image { width: 74px; height: 60px; }
.portal-product-image img, .portal-selected-structure-image img { width: 100%; height: 100%; object-fit: contain; }
.portal-product-placeholder { color: #7890a0; font-size: 12px; font-weight: 800; }
.portal-product-copy { display: grid; gap: 4px; }
.portal-product-copy strong { font-size: 13px; }
.portal-product-copy small { color: var(--muted); font-size: 10px; font-weight: 400; line-height: 1.35; }
.portal-selected-structure { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 16px; padding: 12px; border: 1px solid #d6e2ea; border-radius: 6px; background: #f7fafc; }
.portal-selected-structure-image { width: 150px; height: 100px; }
.portal-selected-structure > div { display: grid; gap: 3px; }
.portal-selected-structure > div > span { color: #59758b; font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.portal-selected-structure h3 { margin: 0; font-size: 19px; }
.portal-selected-structure p { font-size: 13px; }
.portal-selected-structure .portal-selected-post-count { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 5px; color: #274c61; font-size: 13px; }
.portal-structure-heading-actions { display: flex; gap: 7px; }
.portal-structure-fields { grid-template-columns: 76px repeat(6, minmax(92px, 1fr)); }
.portal-help-card { max-width: 760px; }
.portal-help-card h3 { margin-top: 0; }

@media (max-width: 1080px) {
  .portal-estimate-details { grid-template-columns: 1fr; }
  .portal-dashboard-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-builder-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .portal-product-card { grid-template-columns: 60px minmax(0, 1fr); }
  .portal-product-image { width: 60px; height: 52px; }
  .portal-structure-fields { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
}

@media (max-width: 760px) {
  .portal-bay-direction { flex-direction: column; }
  .portal-pricing-level { align-items: stretch; flex-direction: column; }
  .portal-pricing-toggle { min-width: 0; }
  .portal-shipping-fields, .portal-freight-fields { grid-template-columns: 1fr; }
  .portal-shipping-fields label:nth-child(n) { grid-column: auto; }
  .portal-app { grid-template-columns: 1fr; }
  .portal-sidebar { position: static; height: auto; padding: 12px; }
  .portal-sidebar-brand { padding-bottom: 10px; }
  .portal-navigation { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 10px; }
  .portal-nav-button { grid-template-columns: 1fr; gap: 2px; height: auto; min-height: 51px; padding: 5px; font-size: 11px; text-align: center; }
  .portal-nav-button span { font-size: 15px; }
  .portal-sidebar-user { display: none; }
  .portal-main { padding: 20px 14px 36px; }
  .portal-dashboard-actions { grid-template-columns: 1fr; }
  .portal-builder-layout { grid-template-columns: 1fr; }
  .portal-structure-catalog { position: static; max-height: none; }
  .portal-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-selected-structure { grid-template-columns: 105px minmax(0, 1fr); }
  .portal-selected-structure-image { width: 105px; height: 82px; }
  .portal-recent-estimate { grid-template-columns: auto minmax(0, 1fr); }
  .portal-recent-estimate time { grid-column: 2; }
}

@media (max-width: 480px) {
  .portal-navigation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-product-grid { grid-template-columns: 1fr; }
  .portal-page-header { flex-direction: column; }
  .portal-selected-structure { grid-template-columns: 1fr; }
}
.estimate-card-total {
  margin-top: 6px;
  font-weight: 700;
  color: #17324d;
}

.estimate-card-message,
.estimate-review-message {
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px solid #efb4b4;
  background: #fff0f0;
  color: #7a2525;
}

/* Fabric Umbrellas uses actual per-top dimensions and the internal component calculators. */
.portal-fabric-umbrella-fields { grid-template-columns:70px minmax(190px,1.8fr) repeat(3,minmax(85px,.8fr)) minmax(120px,1fr); }
.portal-umbrella-style { color:#0f5f4d; font-weight:700; }
.portal-umbrella-style select { border:2px solid #1f8a70; background:#edf9f5; color:#123b33; font-weight:700; }
.portal-legacy-umbrella-note { display:flex; align-items:center; flex-wrap:wrap; gap:10px; padding:10px; background:#fff4d8; border:1px solid #dfb76c; border-radius:5px; }
@media(max-width:1100px) { .portal-fabric-umbrella-fields { grid-template-columns:repeat(3,minmax(0,1fr)); } .portal-fabric-umbrella-fields .portal-umbrella-style { grid-column:span 2; } }
@media(max-width:600px) { .portal-fabric-umbrella-fields { grid-template-columns:repeat(2,minmax(0,1fr)); } .portal-fabric-umbrella-fields .portal-umbrella-style { grid-column:span 1; } }
