.sales-documents-heading,
.sales-builder-heading,
.sales-document-show-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 42px 22px 24px;
}

.sales-documents-heading h1,
.sales-builder-heading h1,
.sales-document-show-heading h1 {
    margin: 4px 0 7px;
    font-size: clamp(2.35rem, 5vw, 4.8rem);
    line-height: .94;
}

.sales-documents-heading p,
.sales-builder-heading p,
.sales-document-show-heading p {
    max-width: 720px;
    margin: 0;
}

.sales-heading-actions,
.finance-heading-actions,
.event-sales-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.sales-documents-library,
.sales-document-preview-panel {
    max-width: 1136px;
    margin: 0 auto 32px;
}

.sales-empty {
    display: grid;
    justify-items: center;
    gap: 7px;
    padding: 52px 24px;
    text-align: center;
}

.sales-empty > span {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--app-gold, #b58c3c) 55%, transparent);
    border-radius: 18px;
    color: var(--app-gold, #9c742a);
    background: linear-gradient(145deg, #fff, color-mix(in srgb, var(--app-gold-light, #efe2bd) 45%, #fff));
    box-shadow: 0 10px 24px rgba(30, 42, 60, .12);
    font-size: 1.6rem;
}

.sales-empty h3,
.sales-empty p { margin: 0; }
.sales-empty .button { margin-top: 10px; }

.sales-document-list { display: grid; }

.sales-document-list > a {
    display: grid;
    grid-template-columns: 48px minmax(220px, 1.6fr) minmax(170px, 1fr) 130px 20px;
    align-items: center;
    gap: 16px;
    min-height: 78px;
    padding: 14px 20px;
    border-top: 1px solid rgba(32, 45, 64, .11);
    color: var(--app-ink, #1f2d42);
    text-decoration: none;
    transition: transform .2s ease, background-color .2s ease, box-shadow .2s ease;
}

.sales-document-list > a:first-child { border-top: 0; }
.sales-document-list > a:hover,
.sales-document-list > a:focus-visible {
    z-index: 1;
    transform: translateY(-2px);
    background: color-mix(in srgb, var(--tenant-surface, #fff) 80%, var(--app-gold-light, #f2e4bb));
    box-shadow: 0 12px 28px rgba(21, 33, 49, .12);
}

.sales-document-type {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid rgba(169, 128, 45, .32);
    border-radius: 14px;
    color: var(--app-navy, #243247);
    background: linear-gradient(145deg, #fff, #f3ead4);
    box-shadow: 0 8px 18px rgba(34, 47, 65, .12);
    font-weight: 900;
}

.sales-document-type.is-quote {
    color: #fff;
    background: linear-gradient(145deg, var(--tenant-primary, #31425b), #172437);
}

.sales-document-primary,
.sales-document-event { display: grid; gap: 3px; }
.sales-document-primary small,
.sales-document-event small { color: #596579; }
.sales-document-total { text-align: right; font-size: 1.05rem; }
.sales-document-arrow { color: var(--app-gold, #9c742a); font-size: 1.7rem; }

.sales-builder {
    display: grid;
    gap: 18px;
    max-width: 1136px;
    margin: 0 auto 48px;
    padding: 0 0 8px;
}

.sales-builder-card {
    position: relative;
    overflow: hidden;
    margin: 0;
    padding: clamp(22px, 4vw, 36px);
    border: 1px solid rgba(37, 48, 65, .14);
    border-radius: 25px;
    background:
        radial-gradient(circle at 100% 0, color-mix(in srgb, var(--app-gold-light, #f1e2bb) 32%, transparent), transparent 33%),
        linear-gradient(145deg, rgba(255, 255, 255, .98), color-mix(in srgb, var(--tenant-surface, #fff) 92%, var(--app-gold-light, #f2e6c5)));
    box-shadow: 0 18px 42px rgba(25, 38, 55, .12), 0 2px 6px rgba(25, 38, 55, .08), inset 0 1px rgba(255, 255, 255, .9);
}

.sales-builder-card::before {
    position: absolute;
    top: 0;
    left: 6%;
    width: 88%;
    height: 2px;
    content: "";
    background: linear-gradient(90deg, transparent, var(--app-gold, #b38a3b), transparent);
    opacity: .7;
}

.sales-step {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 22px;
}

.sales-step > span {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--app-gold, #b38a3b) 42%, transparent);
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(145deg, var(--tenant-primary, #30415a), #172437);
    box-shadow: 0 9px 20px rgba(26, 39, 58, .2), inset 0 1px rgba(255, 255, 255, .2);
    font-weight: 900;
}

.sales-step h2 { margin: 1px 0 4px; font-size: clamp(1.45rem, 3vw, 2rem); }
.sales-step p { max-width: 760px; margin: 0; }
.sales-step .eyebrow { margin-bottom: 2px; }

.sales-type-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 760px;
}

.sales-type-options label { cursor: pointer; }
.sales-type-options input { position: absolute; opacity: 0; pointer-events: none; }
.sales-type-options label > span {
    position: relative;
    display: grid;
    min-height: 92px;
    align-content: center;
    gap: 4px;
    padding: 18px 20px 18px 58px;
    border: 1px solid rgba(41, 54, 71, .17);
    border-radius: 18px;
    background: rgba(255, 255, 255, .72);
    box-shadow: 0 9px 22px rgba(27, 39, 57, .08), inset 0 1px #fff;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.sales-type-options label > span::before {
    position: absolute;
    top: 50%;
    left: 20px;
    width: 22px;
    height: 22px;
    border: 2px solid #a6adba;
    border-radius: 50%;
    content: "";
    background: #fff;
    box-shadow: inset 0 0 0 5px #fff;
    transform: translateY(-50%);
}

.sales-type-options label:hover > span { transform: translateY(-2px); border-color: rgba(174, 133, 50, .52); }
.sales-type-options input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--app-gold, #b38a3b) 35%, transparent); outline-offset: 3px; }
.sales-type-options input:checked + span {
    border-color: var(--app-gold, #b38a3b);
    background: linear-gradient(145deg, #fff, color-mix(in srgb, var(--app-gold-light, #f1e3bd) 62%, #fff));
    box-shadow: 0 12px 28px rgba(36, 48, 66, .13), inset 0 1px #fff;
}
.sales-type-options input:checked + span::before { border-color: var(--app-gold, #b38a3b); background: var(--app-gold, #b38a3b); }
.sales-type-options small { color: #566277; }

.sales-date-grid,
.sales-prefill-grid,
.sales-contact-grid,
.sales-event-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.sales-date-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 920px; }
.sales-contact-grid .wide,
.sales-event-grid .wide { grid-column: 1 / -1; }
[data-invoice-date][hidden],
[data-quote-date][hidden] { display: none; }

.sales-builder label {
    display: grid;
    align-content: start;
    gap: 7px;
    color: var(--app-ink, #243247);
    font-weight: 800;
}

.sales-builder .optional { color: #6c7686; font-weight: 500; }
.sales-prefill-card { background: linear-gradient(145deg, rgba(247, 242, 229, .98), rgba(255, 255, 255, .96)); }

.sales-add-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 20px;
}

.sales-add-tools > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
    padding: 15px;
    border: 1px solid rgba(34, 47, 66, .13);
    border-radius: 18px;
    background: rgba(255, 255, 255, .72);
    box-shadow: 0 8px 20px rgba(30, 43, 61, .07), inset 0 1px #fff;
}

.sales-add-tools > div:nth-child(2) { grid-template-columns: minmax(0, 1fr) 125px auto; }
.sales-custom-add { grid-column: 1 / -1; min-height: 50px; border-style: dashed !important; }

.sales-line-items { display: grid; gap: 12px; }
.sales-line {
    display: grid;
    grid-template-columns: minmax(200px, 1.6fr) 88px 130px 122px auto;
    align-items: end;
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(38, 51, 69, .13);
    border-radius: 18px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 8px 20px rgba(28, 41, 59, .07), inset 0 1px #fff;
}

.sales-line-description { grid-column: 1; }
.sales-line-details { grid-column: 1; }
.sales-line-details textarea { min-height: 58px; }
.sales-line > label:nth-of-type(3) { grid-column: 2; grid-row: 1 / span 2; }
.sales-line > label:nth-of-type(4) { grid-column: 3; grid-row: 1 / span 2; }
.sales-line-total { grid-column: 4; grid-row: 1 / span 2; display: grid; gap: 5px; align-self: center; text-align: right; }
.sales-line-total small { color: #647084; }
.sales-line-total strong { color: var(--app-ink, #1f2d42); font-size: 1.12rem; }
.sales-line-remove { grid-column: 5; grid-row: 1 / span 2; align-self: center; min-width: 78px; }
.sales-line input[readonly],
.sales-line textarea[readonly] { color: #3d485b; background: #f2efe7 !important; cursor: default; }

.sales-builder-total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 28px;
    margin-top: 18px;
    padding: 20px 24px;
    border-radius: 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--tenant-primary, #30415a), #18263a);
    box-shadow: 0 14px 30px rgba(28, 42, 62, .2), inset 0 1px rgba(255, 255, 255, .18);
}
.sales-builder-total span { color: #e8d9b2; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.sales-builder-total strong { color: #fff; font-size: clamp(1.7rem, 4vw, 2.5rem); }

.sales-generate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-top: 20px;
    padding: 20px;
    border: 1px solid rgba(36, 50, 68, .12);
    border-radius: 18px;
    background: rgba(255, 255, 255, .75);
}
.sales-generate p { max-width: 680px; margin: 5px 0 0; }
.sales-builder-boundary { margin: 16px 0 0; color: #5f6b7d; font-size: .92rem; }

.sales-document-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    max-width: 1136px;
    margin: 0 auto 18px;
}
.sales-document-summary article {
    display: grid;
    align-content: start;
    gap: 5px;
    min-height: 112px;
    padding: 18px;
    border: 1px solid rgba(37, 50, 68, .14);
    border-radius: 19px;
    background: linear-gradient(145deg, #fff, color-mix(in srgb, var(--tenant-surface, #fff) 90%, var(--app-gold-light, #f2e5c1)));
    box-shadow: 0 13px 28px rgba(27, 40, 58, .1), inset 0 1px #fff;
}
.sales-document-summary article > span { color: #6c7584; font-size: .76rem; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.sales-document-summary article > strong { color: var(--app-ink, #1f2d42); font-size: 1.08rem; }
.sales-document-summary article > small { color: #596579; }
.sales-document-preview-panel iframe { width: 100%; height: 780px; border: 1px solid rgba(31, 44, 62, .18); border-radius: 18px; background: #e7e9ed; }

.event-sales-documents { display: grid; gap: 16px; }
.event-sales-actions { margin: 0; }
.event-sales-list { display: grid; border-top: 1px solid rgba(35, 48, 65, .12); }
.event-sales-list > a { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 2px; border-bottom: 1px solid rgba(35, 48, 65, .1); color: inherit; text-decoration: none; }
.event-sales-list > a:hover strong { color: var(--app-gold, #9c742a); }
.event-sales-list span { display: grid; gap: 2px; }
.event-sales-list small { color: #647084; }

@media (max-width: 900px) {
    .sales-documents-heading,
    .sales-builder-heading,
    .sales-document-show-heading { align-items: stretch; flex-direction: column; padding-top: 30px; }
    .sales-heading-actions .button { flex: 1 1 180px; text-align: center; }
    .sales-add-tools { grid-template-columns: 1fr; }
    .sales-custom-add { grid-column: 1; }
    .sales-line { grid-template-columns: minmax(180px, 1fr) 92px 128px; }
    .sales-line-description,
    .sales-line-details { grid-column: 1 / -1; }
    .sales-line > label:nth-of-type(3) { grid-column: 1; grid-row: auto; }
    .sales-line > label:nth-of-type(4) { grid-column: 2; grid-row: auto; }
    .sales-line-total { grid-column: 3; grid-row: auto; }
    .sales-line-remove { grid-column: 1 / -1; grid-row: auto; justify-self: end; }
    .sales-document-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sales-document-list > a { grid-template-columns: 44px minmax(0, 1fr) 110px 16px; }
    .sales-document-event { display: none; }
}

@media (max-width: 640px) {
    .sales-documents-heading,
    .sales-builder-heading,
    .sales-document-show-heading { padding: 25px 17px 18px; }
    .sales-documents-heading h1,
    .sales-builder-heading h1,
    .sales-document-show-heading h1 { font-size: clamp(2.25rem, 12vw, 3.2rem); }
    .sales-builder { gap: 14px; padding: 0 14px; }
    .sales-builder-card { padding: 21px 17px; border-radius: 21px; }
    .sales-step { gap: 11px; margin-bottom: 18px; }
    .sales-step > span { flex-basis: 38px; width: 38px; height: 38px; border-radius: 12px; }
    .sales-type-options,
    .sales-date-grid,
    .sales-prefill-grid,
    .sales-contact-grid,
    .sales-event-grid { grid-template-columns: 1fr; gap: 13px; }
    .sales-type-options label > span { min-height: 78px; padding: 14px 16px 14px 52px; }
    .sales-contact-grid .wide,
    .sales-event-grid .wide { grid-column: auto; }
    .sales-add-tools > div,
    .sales-add-tools > div:nth-child(2) { grid-template-columns: 1fr; align-items: stretch; }
    .sales-add-tools .button { width: 100%; }
    .sales-line { grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
    .sales-line > label:nth-of-type(3) { grid-column: 1; }
    .sales-line > label:nth-of-type(4) { grid-column: 2; }
    .sales-line-total { grid-column: 1; justify-self: start; text-align: left; }
    .sales-line-remove { grid-column: 2; justify-self: stretch; }
    .sales-builder-total { justify-content: space-between; gap: 12px; padding: 17px; }
    .sales-generate { align-items: stretch; flex-direction: column; padding: 17px; }
    .sales-generate .button { width: 100%; }
    .sales-documents-library,
    .sales-document-preview-panel { margin: 0 14px 26px; }
    .sales-document-list > a { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 11px; padding: 13px; }
    .sales-document-list .sales-document-total { grid-column: 2; text-align: left; }
    .sales-document-arrow { grid-column: 3; grid-row: 1 / span 2; }
    .sales-document-summary { grid-template-columns: 1fr 1fr; margin: 0 14px 16px; }
    .sales-document-summary article { min-height: 100px; padding: 15px; }
    .sales-document-preview-panel iframe { height: 570px; border-radius: 14px; }
    .finance-heading-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .finance-heading-actions .button:last-child { grid-column: 1 / -1; }
}

@media (max-width: 390px) {
    .sales-document-summary { grid-template-columns: 1fr; }
    .sales-builder-total { align-items: flex-end; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    .sales-document-list > a,
    .sales-type-options label > span { transition: none; }
}
