*{box-sizing:border-box}body{margin:0;background:#f4f3ef;color:#24342b;font:15px system-ui,sans-serif}header{background:#253e32;color:white;padding:24px 5%;display:flex;justify-content:space-between;align-items:center}header h1{font:28px Georgia;margin:0;letter-spacing:3px}header small{color:#ded6be}main{max-width:1100px;margin:28px auto;padding:0 18px}.panel{background:white;border:1px solid #e0dfd8;border-radius:12px;padding:22px;margin-bottom:18px}h2{font-size:18px;margin:0 0 18px}h3{font-size:14px;color:#6d735e;margin:0 0 8px}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px}label{display:block;font-size:12px;font-weight:650;color:#525d51}input,select{width:100%;margin-top:6px;padding:11px;border:1px solid #c9cec4;border-radius:6px;background:white;color:#203329;font:inherit}button{border:0;border-radius:7px;padding:12px 18px;background:#345642;color:white;font-weight:650;cursor:pointer}button.secondary{background:#eeeae0;color:#3c493c}button.danger{background:transparent;color:#a03b37;padding:6px}.actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}.muted{color:#6d756c;font-size:13px}.notice{background:#fff6e1;color:#76521b;padding:12px;border-radius:6px;font-size:13px;margin:12px 0}.scroll{overflow-x:auto}table{width:100%;border-collapse:collapse}th,td{text-align:left;border-bottom:1px solid #e3e5de;padding:12px 8px;vertical-align:top}th{font-size:12px;color:#667063}td.num,th.num{text-align:right;white-space:nowrap}.total{font-size:28px;font-weight:700;color:#284b36}.summary{display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap}#preview{display:none}#preview.show{display:block}.invoice-head{border-bottom:2px solid #8c7952;padding-bottom:18px;display:flex;justify-content:space-between;gap:15px}.invoice-head h1{font:27px Georgia;color:#81704d;letter-spacing:2px}.invoice-head p{margin:4px 0}.totals{margin-left:auto;max-width:350px}.totals div{display:flex;justify-content:space-between;padding:8px;border-bottom:1px solid #eee}.error{color:#a02c25;font-weight:600} [hidden]{display:none!important}@media print{body{background:white;color:black}header,#editor,#ratesPanel,#historyPanel,#backupPanel,.no-print{display:none!important}main{margin:0;padding:0;max-width:none}#preview{display:block!important;border:0;padding:0}tr{break-inside:avoid}thead{display:table-header-group}@page{margin:15mm;size:A4}}

.llpage{font-family:"Times New Roman",serif;color:#000;background:white;max-width:194mm;margin:auto;font-size:11pt;line-height:1.16}.llhead{display:flex;justify-content:space-between;gap:10px;font-family:Arial,sans-serif;font-size:8pt;line-height:1.65;padding:0 3mm}.llhead b{font-size:11pt;display:block}.llhead small{display:block;font-size:7pt;font-weight:bold}.llhead span{color:blue;font-size:9pt}.lltitle{font:bold 12pt "Times New Roman",serif;text-align:center;margin:7mm 0 1mm}.llmeta{display:flex;justify-content:space-between;align-items:center;margin:1mm 0 5mm}.lltable{width:100%;table-layout:fixed;border-collapse:collapse;font:inherit}.lltable th,.lltable td{border:0.7pt solid black;color:black;padding:1.1px 2px;font:inherit;vertical-align:middle}.lltable th{font-weight:bold;text-align:center;vertical-align:top;padding:3px 1px}.lltable td:nth-child(2){text-align:right;overflow-wrap:anywhere}.lltable td:nth-child(3),.lltable td:nth-child(4){text-align:center}.lltable td:nth-child(5),.lltable td:nth-child(6){text-align:right;white-space:nowrap}.lltable .group td{font-weight:bold;text-align:left}.lltable .sum td{font-weight:bold}.lltable .complimentary{text-align:center!important}.llfoot{display:flex;justify-content:space-between;margin-top:5mm;font-size:10pt}.llpage p{margin:4mm 0;font-size:10pt}.llbank{font-weight:bold;margin-top:9mm;font-size:11pt}.termPage{max-width:210mm;margin:12px auto;border:1px solid #ddd}.termPage img{display:block;width:100%;height:auto}.llpage+ .termPage{margin-top:20px}@media print{@page{size:letter;margin:0}body{margin:0}nav,#storageNotice{display:none!important}.llpage{max-width:none;width:100%;padding:4mm 14mm 3mm 3.6mm;min-height:278mm;break-after:page;font-size:10.6pt}.lltable th,.lltable td{padding:1px 2px}.termPage,.llpage+ .termPage{margin:0;border:0;width:215.9mm;max-width:none;break-before:auto;break-after:page}.termPage:has(+ .actions){break-after:auto}.termPage img{width:215.9mm;height:279.4mm;object-fit:contain}#preview{margin:0!important;background:white} .lltable thead{display:table-header-group}}
 .overall-box{margin-top:18px;border:1px solid #dce0d8;border-radius:8px;padding:14px;background:#fafaf7}.overall-box summary{cursor:pointer;font-weight:650}.overall-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;align-items:start;margin:12px 0}.discount-controls{min-width:155px;display:grid;gap:4px}.discount-controls select,.discount-controls input{margin:0;padding:7px;font-size:12px}.discount-controls small{font-size:11px;color:#536454}.discount-controls button{padding:6px;font-size:12px}.discount-controls .error{color:#a03b37}@media(max-width:600px){.overall-grid{grid-template-columns:1fr}}  .ref-field{display:flex;align-items:center;border:1px solid #c9cec4;border-radius:6px;margin-top:6px;background:white;overflow:hidden}.ref-field span{padding:0 8px;white-space:nowrap;color:#24342b;font-size:13px}.ref-field input{margin:0;border:0;border-left:1px solid #ddd;border-radius:0;min-width:0;padding:11px 6px;text-transform:uppercase}.llhead .llrc{display:block;font:700 9pt/1.4 Arial,sans-serif;white-space:nowrap;overflow:visible;margin:2mm 0 1mm;color:black}.llhead>div{min-width:0}.llhead>div:first-child{flex:1}.llhead>div:last-child{flex:0 0 34%}.llhead b{line-height:1.3}.llmeta>div:last-child{white-space:nowrap}.lltable th,.lltable td{border:0.75pt solid #000}.termPage[hidden]{display:none!important}@media print{.llpage{box-shadow:none;min-height:0;break-after:page}.llhead,.llmeta,.llfoot,.llbank{break-inside:avoid}.termPage{break-inside:avoid;break-after:page}.termPage.last-visible{break-after:auto}.llpage,.lltable{-webkit-print-color-adjust:exact;print-color-adjust:exact}#preview{box-shadow:none}.termPage img{image-rendering:auto;height:279mm;max-height:279mm}} 
#preview{padding:0;border:0;background:transparent;box-shadow:none;overflow-x:auto}
#preview .llpage,#preview .termPage{box-sizing:border-box;width:215.9mm;max-width:none;margin:0 auto 12px;background:white;border:0;box-shadow:none}
#preview .llpage{padding:4mm 14mm 3mm 3.6mm;min-height:279.4mm;font-size:10.6pt;line-height:1.16}
#preview .lltable th,#preview .lltable td{padding:1px 2px}
#preview .termPage img{display:block;width:215.9mm;height:279.4mm;max-height:none;object-fit:contain}
#preview .llpage,#preview .termPage{print-color-adjust:exact;-webkit-print-color-adjust:exact}
@media screen{#preview .llpage,#preview .termPage{outline:1px solid #ddd}}
@media print{@page{size:letter;margin:0}html,body,main{width:215.9mm;margin:0!important;padding:0!important;max-width:none!important}#preview{width:215.9mm;overflow:visible;margin:0!important;padding:0!important}#preview .llpage,#preview .termPage{margin:0;outline:0;break-after:page}#preview .llpage{min-height:0}#preview .termPage.last-visible{break-after:auto}#preview .termPage img{height:279.3mm}#preview .actions{display:none!important}}

/* V6.9: identical letterhead in preview and print */
#preview .llhead{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,42%);align-items:start;gap:4mm;padding:0;width:100%;margin:0 0 3mm;line-height:1.4}
#preview .llhead>div:first-child{text-align:left;min-width:0}
#preview .llhead>div.llcontact{text-align:right;min-width:0;line-height:1.4;display:flex;flex-direction:column;align-items:flex-end;gap:1mm;font-size:8pt}
#preview .llhead .llrc{margin:1mm 0;white-space:nowrap;line-height:1.4}
#preview .llhead b{line-height:1.4;margin:0}
#preview .llhead span{display:block;line-height:1.4}
.llhead .llrc{display:block!important;white-space:nowrap!important;overflow:visible!important;height:auto!important;line-height:1.35!important;margin:4px 0!important}.llhead>div{overflow:visible!important}.llhead{align-items:start!important}.llcontact{text-align:right!important}
/* V6.9: native, consistent letterhead and selectable terms */
.complimentaryPicker{border:1px solid #dce0d8;border-radius:8px;padding:14px;margin:0 0 22px;background:#fafaf7}.compButton{align-self:end}.complimentaryPicker p{margin:8px 0 0}
#preview .llhead{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,42%);align-items:start!important;gap:4mm;padding:0!important;width:100%;margin:0 0 3mm!important;line-height:1.4;overflow:visible!important;font-family:Arial,sans-serif}
#preview .llhead .llrc{font:700 9pt/1.5 Arial,sans-serif!important;display:block!important;white-space:nowrap!important;overflow:visible!important;height:auto!important;min-height:14pt;margin:1mm 0!important;color:#000!important}
#preview .llhead b{font:700 11pt/1.4 Arial,sans-serif!important;display:block!important;margin:0!important}
#preview .llhead span{display:block!important;font:9pt/1.4 Arial,sans-serif!important;color:#00f!important}
#preview .llhead .llcontact{font:8pt/1.4 Arial,sans-serif!important;text-align:right!important;display:flex!important;flex-direction:column;align-items:flex-end!important;gap:1mm}
#preview .nativeTerms{position:relative;width:215.9mm;height:279.4mm;min-height:279.4mm;padding:4mm 14mm 3mm 3.6mm;overflow:visible;background:#fff;color:#000}
#preview .nativeTerms .termsBody{position:absolute;inset:0;pointer-events:auto;font-family:"Times New Roman",serif;line-height:1}
#preview .termText{position:absolute;display:block;white-space:pre;line-height:1;transform-origin:left top;color:#000;font-family:"Times New Roman",serif}
#preview .lltable th,#preview .lltable td{border:0.75pt solid #000!important}
@media print{#preview .nativeTerms{margin:0!important;break-inside:avoid;break-after:page;height:279.3mm;min-height:279.3mm}#preview .nativeTerms.last-visible{break-after:auto}#preview .llpage{min-height:279.3mm}#preview .llhead{break-inside:avoid}#preview .nativeTerms .termsBody{overflow:visible}}

#preview .previewActions{width:215.9mm;max-width:none;margin:12px auto 0;padding:0;justify-content:flex-start;align-items:center}
#preview .paymentHeading{position:absolute;left:40.44pt;top:78pt;font:700 10pt/1.1 "Times New Roman",serif}
#preview .signatureBlock{position:absolute;left:72pt;right:55pt;top:593pt;display:grid;grid-template-columns:1fr 1fr;gap:24pt;font:10pt/1.2 "Times New Roman",serif}
#preview .signatureBlock strong{font-size:10pt;white-space:nowrap}
#preview .signRow,#preview .nameRow{display:flex;align-items:baseline;gap:5pt;margin-top:16pt}
#preview .signRow{margin-top:35pt}
#preview .signatureBlock i{flex:1;border-bottom:0.65pt solid #000;height:12pt}
@media print{#preview .previewActions{display:none!important}}

/* V6.9: explicit single-stroke grid, identical in preview and PDF. */
#preview .lltable { border-collapse: separate !important; border-spacing: 0 !important; border: 0 !important; empty-cells: show !important; }
#preview .lltable tr > th, #preview .lltable tr > td { border: 0 !important; border-right: 1px solid #000 !important; border-bottom: 1px solid #000 !important; background-clip: padding-box; }
#preview .lltable tr > :first-child { border-left: 1px solid #000 !important; }
#preview .lltable thead tr:first-child > th { border-top: 1px solid #000 !important; }
@media print {
 #preview .lltable, #preview .lltable th, #preview .lltable td { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }
 #preview .lltable { overflow: visible !important; }
 #preview .lltable tr { break-inside: avoid; page-break-inside: avoid; }
}
nav.actions.no-print{width:100%;max-width:100%;margin:0 0 18px!important;padding:0;justify-content:flex-start;}
 .line-edit-panel{padding:14px;background:#f4f2ec;border:1px solid #d5d2c8}.line-edit-panel .grid{grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px}.line-edit-panel label{display:block}.line-edit-panel input,.line-edit-panel select{width:100%}#lines td:last-child button{margin:2px;padding:6px 9px} 
/* Equal-size item controls; scoped to the editor, not the printable invoice. */
#lines tr:has(> .line-action-cell) > td {vertical-align:middle;}
#lines .line-action-cell {width:1%;white-space:nowrap;}
#lines .line-item-actions {display:flex;align-items:center;justify-content:flex-start;gap:6px;flex-wrap:nowrap;}
#lines .line-item-actions button {margin:0;padding:0 8px;height:34px;display:inline-flex;align-items:center;justify-content:center;line-height:1;white-space:nowrap;}
#lines .line-item-actions button.secondary {width:88px;flex:0 0 88px;}
#lines .line-item-actions button.danger {flex:0 0 auto;}

#preview .lltable th:first-child,#preview .lltable td:first-child{white-space:nowrap;text-align:center;vertical-align:middle}#preview .lltable th:first-child{font-weight:bold;padding:1px 0!important}#itemAddedToast{position:fixed;bottom:24px;right:24px;z-index:9999;background:#345642;color:#fff;padding:10px 16px;border-radius:8px;box-shadow:0 3px 12px #0002;font:600 14px Arial,sans-serif;max-width:calc(100vw - 48px)}#itemAddedToast[hidden]{display:none!important}@media print{#itemAddedToast{display:none!important}}

#itemEditDialog{width:min(760px,calc(100vw - 32px));max-height:calc(100dvh - 48px);padding:0;border:1px solid #d5d2c8;border-radius:14px;background:white;color:#24342b;box-shadow:0 18px 65px #0004;overflow:auto;margin:auto}#itemEditDialog::backdrop{background:#172a22a0}#itemEditDialog .line-edit-panel{padding:24px;background:white;border:0}#itemEditDialog .edit-modal-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}#itemEditDialog h2{margin:0}#itemEditDialog .edit-close{font-size:22px;padding:2px 12px;line-height:1.4}#itemEditDialog .actions{justify-content:flex-end}#itemEditDialog .grid{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}@media print{#itemEditDialog{display:none!important}}

#rateForm{width:min(760px,calc(100vw - 32px));max-height:calc(100dvh - 48px);padding:0;border:1px solid #d5d2c8;border-radius:14px;background:white;color:#24342b;box-shadow:0 18px 65px #0004;overflow:auto;margin:auto;box-sizing:border-box}#rateForm::backdrop{background:#172a22a0}#rateForm .rate-modal-body{padding:24px}#rateForm .edit-modal-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}#rateForm h2{margin:0}#rateForm .edit-close{font-size:22px;padding:2px 12px;line-height:1.4}#rateForm .actions{justify-content:flex-end}#rateForm .grid{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}#rateRows td{vertical-align:middle!important}#rateRows td:last-child{text-align:right;white-space:nowrap;width:100px}#rateRows .rate-edit-button{display:inline-flex;align-items:center;justify-content:center;width:80px;height:34px;box-sizing:border-box;padding:0 12px;line-height:1;margin:0;vertical-align:middle}@media print{#rateForm{display:none!important}}

/* Preview navigation follows the paper, while all other screens follow the form. */
@media screen { main:has(> #preview.show) > nav.actions.no-print { width:215.9mm; max-width:100%; margin:0 auto 18px!important; } }

#categoryDiscountRows:not(:empty){display:grid;gap:10px;margin-top:14px}
.category-discount-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.6fr);gap:12px 20px;align-items:center;padding:14px;border:1px solid #dce0d8;border-radius:8px;background:#fff}
.category-discount-heading{display:grid;gap:4px;overflow-wrap:anywhere}
.category-discount-heading small,.category-discount-status{color:#536454}
.category-discount-fields{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr) auto;gap:10px;align-items:end}
.category-discount-fields input,.category-discount-fields select{min-width:0;margin:4px 0 0}
.category-discount-fields button{white-space:nowrap;min-height:44px}
.category-discount-status{grid-column:1/-1;font-size:.875rem;border-top:1px solid #e5e8e1;padding-top:9px}
.category-discount-status.error{color:#a02c25}
@media(max-width:760px){.category-discount-row{grid-template-columns:minmax(0,1fr)}}
@media(max-width:480px){.category-discount-fields{grid-template-columns:minmax(0,1fr)}.category-discount-fields button{justify-self:start}}
