/* Forms share one spacing scale and a consistent action area. */
.form-shell { max-width: 880px; margin-bottom: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 26px 30px 0; }
.form-section { padding: 0; margin: 0 0 26px; min-width: 0; border: 0; }
.form-section > legend { margin-bottom: 14px; padding: 0; font-size: .94rem; color: var(--ink); font-weight: 650; }
.form-section > .body-copy { margin-bottom: 12px; }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px 17px; }
.form-grid > * { min-width: 0; }
.form-grid .address-row, .form-grid > details { grid-column: 1 / -1; }
.address-row { display: grid; grid-template-columns: .7fr 2fr .6fr; gap: 12px; }
.form-disclosure { border: 0; }
.form-disclosure > summary { color: var(--muted); font-size: .84rem; cursor: pointer; font-weight: 560; }
.form-disclosure[open] > summary { color: var(--ink); margin-bottom: 13px; }
.form-disclosure > .body-copy { margin-bottom: 12px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 9px; border-top: 1px solid var(--line); padding: 16px 0; margin-top: 20px; }
.form-actions > .body-copy { margin-right: auto; }
.form-actions .text { margin-right: auto; }
.form-shell .form-actions { margin-bottom: 0; }
.form-section .check + .check { margin-top: 12px; }
.form-section:has(> label + .check) .check { margin-top: 16px; }
.form-grid > label:only-child { grid-column: 1 / -1; }
.form-grid input[type=color] { padding: 4px; min-width: 48px; }
button[aria-busy=true] { cursor: progress; }
.preformatted { white-space: pre-line; }
.number-settings { max-width: 880px; margin-top: 24px; }
.number-settings .table-card { margin-top: 16px; }
.document-preview { width: 100%; height: 940px; border: 1px solid var(--line); border-radius: 10px; background: #eeece6; }
.document-preview-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 15px 0; }
.document-secondary { margin-top: 15px; }
.drawer-dialog { width: min(100%,560px); height: 100dvh; max-height: 100dvh; max-width: 100vw; margin: 0 0 0 auto; padding: 0; background: var(--surface); color: var(--ink); border: 0; border-left: 1px solid var(--line-strong); }
.drawer-dialog::backdrop { background: #30251e55; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 20px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.drawer-header h2 { font-size: 1.35rem; margin-top: 2px; }
.drawer-header small { font-size: .76rem; }
.drawer-form, .drawer-content { padding: 24px; }
.drawer-note { margin: 18px 24px 0; }
.drawer-form { padding-bottom: 0; }
.drawer-dialog .form-actions { position: sticky; bottom: 0; z-index: 2; background: var(--surface); margin-bottom: 0; padding: 16px 24px; }
.drawer-form > .form-actions { margin-inline: -24px; }
.drawer-dialog .form-grid { gap: 12px; }
.drawer-dialog > .form-actions { margin-top: 0; }
.drawer-dialog .address-row { grid-template-columns: .7fr 1.6fr .6fr; gap: 8px; }

[data-page=editor] .main, [data-page=quote-editor] .main { max-width: 1120px; }
[data-page=editor] h1, [data-page=quote-editor] h1, [data-page=design] h1 { font-family: Geist, sans-serif; font-size: clamp(1.8rem,3vw,2.45rem); font-weight: 650; letter-spacing: -.06em; line-height: 1.15; }
[data-page=editor] .head, [data-page=quote-editor] .head { margin-top: 12px; margin-bottom: 20px; align-items: center; }
.document-composer { min-width: 0; }
.composer-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #efece5; border: 1px solid var(--line); border-radius: 11px 11px 0 0; font-size: .76rem; color: var(--muted); }
.composer-toolbar > button { margin-left: auto; min-height: 34px; }
.draft-indicator { font-weight: 660; color: #5f5749; }
.compose-paper { padding: 28px 30px 22px; background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 11px 11px; min-width: 0; }
.compose-top { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(180px,.7fr); gap: 45px; align-items: start; }
.recipient { position: relative; min-width: 0; }
.recipient-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.recipient-heading h2 { font-size: 1.03rem; }
.recipient-heading .text { font-size: .8rem; min-height: 34px; }
.recipient-results { position: absolute; top: 100%; z-index: 3; width: 100%; padding: 5px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; max-height: 290px; overflow: auto; box-shadow: 0 8px 20px #30251a10; }
.recipient-option { display: flex; justify-content: space-between; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 4px; gap: 10px; white-space: normal; }
.recipient-option small { font-size: .73rem; font-weight: 450; }
.recipient-option strong { font-weight: 590; }
.recipient-results p { padding: 10px; }
.selected-recipient { border: 1px solid var(--line); border-radius: 8px; background: #f7f5ef; padding: 13px 14px; }
.selected-recipient > div:first-child strong { font-size: 1.02rem; }
.selected-recipient .body-copy { margin-top: 3px; }
.selected-recipient .actions { margin-top: 5px; margin-left: -6px; gap: 5px; }
.selected-recipient .text { font-size: .78rem; min-height: 32px; }
#recipient-status:empty { display: none; }
.document-dates { display: grid; gap: 10px; padding-top: 7px; }
.document-dates > p { font-size: .74rem; }
.quote-subject { margin-top: 20px; }
.compose-lines { margin-top: 28px; padding-top: 23px; border-top: 1px solid var(--line); min-width: 0; }
.compose-lines > .section-heading { margin-bottom: 16px; }
.compose-lines h2 { font-size: 1.03rem; }
.compose-columns, .compose-line-main { display: grid; grid-template-columns: minmax(0,1fr) 76px 132px 126px 78px; gap: 10px; align-items: start; }
.compose-columns { font-size: .72rem; color: var(--muted); padding: 0 0 8px; }
.compose-columns span:nth-child(4) { text-align: right; }
.compose-line { padding: 10px 0; border-top: 1px solid var(--line); }
.compose-line-main > label:not(.description-cell) { font-size: 0; gap: 0; }
.compose-line-main input { text-align: right; }
.compose-line textarea { resize: vertical; min-height: 42px; max-height: 180px; line-height: 1.4; }
.line-amount { text-align: right; padding-top: 11px; white-space: nowrap; font-size: .91rem; font-weight: 630; font-variant-numeric: tabular-nums; }
.line-tools { display: flex; justify-content: flex-end; gap: 2px; }
.line-tools .icon-button { min-width: 35px; padding: 6px; border-color: transparent; }
.line-extra { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 12px; padding: 13px; background: #f5f2eb; border-radius: 7px; margin-top: 10px; }
.compose-add { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 6px; }
.compose-add > label { min-width: 240px; }
.compose-add > .text { padding-left: 0; }
.compose-bottom { display: grid; grid-template-columns: minmax(0,1fr) minmax(230px,.72fr); gap: 60px; padding-top: 24px; border-top: 1px solid var(--line); margin-top: 20px; align-items: start; }
.compose-payment h2, .compose-totals h2 { font-size: 1rem; margin-bottom: 13px; }
.compose-payment > label { margin-bottom: 12px; }
.compose-totals dl { margin: 0; }
.compose-totals dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: .83rem; }
.compose-totals dt { color: var(--muted); }
.compose-totals dd { margin: 0; font-variant-numeric: tabular-nums; }
#document-total { font-size: 2rem; font-weight: 650; letter-spacing: -.065em; font-variant-numeric: tabular-nums; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 9px; }
#calculation-status { margin-top: 5px; font-size: .75rem; }
.compose-payment .rates { grid-template-columns: 1fr 1fr; padding: 10px; }
.composer-actions { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; background: var(--paper); padding: 15px 0 12px; z-index: 2; }
.composer-actions .body-copy { font-size: .77rem; }
#editor > .error { margin-top: 12px; }
.compose-line-main .field-error { font-size: .73rem; }
.document-composer .drawer-content { overflow: visible; }

.design-workspace { display: grid; grid-template-columns: 335px minmax(0,1fr); gap: 28px; align-items: start; }
.design-controls { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 20px 20px 0; }
.design-controls .form-section { margin-bottom: 23px; }
.design-controls .form-grid { grid-template-columns: 1fr; }
.template-list { display: grid; gap: 8px; }
.template-option { display: grid; grid-template-columns: auto 42px minmax(0,1fr); align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.template-option:has(input:checked) { border-color: var(--accent); background: #f7eee6; }
.template-option input { width: 14px !important; min-height: 14px !important; accent-color: var(--accent); margin: 0; }
.template-option small { font-size: .72rem; line-height: 1.4; margin-top: 3px; font-weight: 440; }
.template-glyph { background: white; border: 1px solid #e2dacd; width: 38px; height: 48px; padding: 8px 5px; }
.template-glyph i { display: block; height: 2px; margin-bottom: 6px; background: #a13d2d; }
.template-glyph i:nth-child(2) { width: 70%; background: #b7afa4; height: 1px; }
.template-glyph i:nth-child(3) { width: 90%; background: #b7afa4; height: 1px; }
.template-glyph.modern { padding-top: 4px; border-top: 5px solid #a13d2d; }
.template-glyph.minimal i:first-child { height: 1px; }
.color-control { display: grid; grid-template-columns: 48px minmax(0,1fr); gap: 9px; }
.logo-input { margin-top: 15px; }
#logo-current { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
#logo-current img { max-width: 100px; max-height: 65px; object-fit: contain; }
.design-preview { position: sticky; top: 10px; min-width: 0; }
.design-preview .document-preview-toolbar { margin-top: 0; }
.design-preview > p { font-size: .76rem; margin-top: 10px; }
.design-preview .document-preview { height: 920px; }
@media (max-width:1000px) {
  .compose-columns,.compose-line-main { grid-template-columns: minmax(0,1fr) 68px 108px 108px 68px; gap: 7px; }
  .line-tools .icon-button { min-width: 32px; }
  .design-workspace { grid-template-columns: 290px minmax(0,1fr); gap: 18px; }
}
@media (max-width:760px) {
  .form-shell { padding: 20px 20px 0; }
  .compose-top { gap: 20px; grid-template-columns: minmax(0,1fr) minmax(160px,.65fr); }
  .compose-paper { padding: 22px 20px; }
  .compose-columns { display: none; }
  .compose-line-main { grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: 9px; }
  .compose-line-main .description-cell { grid-column: 1 / -1; }
  .compose-line-main > label:not(.description-cell) { font-size: .76rem; gap: 4px; }
  .compose-line-main input { text-align: left; }
  .line-amount { grid-column: 1 / 3; padding-top: 0; text-align: left; }
  .line-tools { grid-area: 2 / 3 / 4 / 4; flex-direction: column; align-self: end; }
  .compose-line { padding-block: 14px; }
  .compose-bottom { gap: 24px; grid-template-columns: 1fr 1fr; }
  .compose-add { align-items: flex-start; flex-direction: column; gap: 6px; }
  .design-workspace { grid-template-columns: minmax(0,1fr); }
  .design-preview { position: static; }
  .design-controls { padding: 20px; }
  .design-controls .form-grid { grid-template-columns: 1fr 1fr; }
  .template-list { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .template-option { grid-template-columns: auto minmax(0,1fr); gap: 5px; }
  .template-glyph { display: none; }
}
@media (max-width:570px) {
  .form-shell { padding: 18px 15px 0; }
  .form-grid { gap: 12px; }
  .form-grid > label { grid-column: 1 / -1; }
  .address-row { grid-template-columns: .8fr 1.6fr; gap: 10px; }
  .address-row > label:last-child { max-width: 100px; }
  .drawer-content, .drawer-form { padding: 20px 17px; }
  .drawer-header { padding: 16px 17px; }
  .drawer-form { padding-bottom: 0; }
  .drawer-form > .form-actions { margin-inline: -17px; }
  .drawer-dialog .form-actions { padding-inline: 17px; }
  .compose-top { grid-template-columns: minmax(0,1fr); gap: 19px; }
  .document-dates { grid-template-columns: 1fr 1fr; }
  .document-dates > p { align-self: end; padding-bottom: 10px; }
  .compose-paper { padding: 17px 14px; }
  .composer-toolbar { gap: 6px; padding-inline: 10px; }
  .composer-toolbar > #save-description { display: none; }
  .composer-toolbar button { font-size: .77rem; }
  .recipient-heading { gap: 5px; }
  .recipient-heading h2 { font-size: .95rem; }
  .recipient-heading .text { padding-inline: 3px; font-size: .78rem; }
  .compose-bottom { grid-template-columns: minmax(0,1fr); gap: 20px; margin-top: 16px; }
  .compose-totals { border-top: 1px solid var(--line); padding-top: 17px; }
  .compose-payment .form-grid > label { grid-column: auto; }
  .compose-add > label { width: 100%; min-width: 0; }
  .line-extra { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 10px; gap: 8px; }
  .line-extra > label:last-child { grid-column: 1 / -1; }
  .document-composer { padding-bottom: 74px; }
  .composer-actions { position: fixed; inset: auto 0 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line-strong); }
  .composer-actions > span { display: none; }
  .composer-actions > .actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 6px; }
  .composer-actions button { padding-inline: 7px; font-size: .79rem; min-height: 44px; }
  .document-preview { height: 760px; }
  .template-list { grid-template-columns: 1fr; }
  .template-glyph { display: inline-block; }
  .template-option { grid-template-columns: auto 42px minmax(0,1fr); gap: 10px; }
  .design-controls .form-grid { grid-template-columns: minmax(0,1fr); }
}

