@font-face{font-family:Inter;src:url('../fonts/InterVariable.woff2') format('woff2');font-weight:100 900;font-display:swap}
:root{--primary:#6B5144;--primary-hover:#533D32;--page:#F8F5F1;--surface:#fff;--soft:#F0EAE4;--text:#2E2622;--muted:#70665F;--error:#B42318;--success:#15803D;--border:#DED5CD;--field-border:#9B948F;--sidebar:#3D2E27;--sidebar-text:#E5D8CC;--selected:#AD8B6D;--selected-text:#2C2018;--bs-body-font-family:Inter,Arial,sans-serif;--bs-body-color:var(--text);--bs-body-bg:var(--page)}
*{box-sizing:border-box}body{margin:0;font:400 16px/24px Inter,Arial,sans-serif;background:var(--page);color:var(--text)}h1,h2,h3{font-weight:600;color:var(--text)}h1{font-size:28px;line-height:36px;letter-spacing:-.6px;margin:0 0 8px}h2{font-size:22px;line-height:28px;letter-spacing:-.35px;margin:0 0 16px}h3{font-size:18px;line-height:24px}p{margin:0 0 16px}a{color:var(--primary);text-underline-offset:4px}a:hover{color:var(--primary-hover)}button,input,textarea,select{font:inherit}button,a,input,textarea,select{touch-action:manipulation}[hidden]{display:none!important}.icon{width:20px;height:20px;flex:0 0 20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.app-shell{display:grid;grid-template-columns:232px minmax(0,1fr);min-height:100vh}.sidebar{background:var(--sidebar);color:var(--sidebar-text);padding:20px 16px;display:flex;flex-direction:column;gap:20px}.brand{display:flex;align-items:center;gap:12px;color:var(--sidebar-text);text-decoration:none;font-size:20px;line-height:25px;font-weight:600;padding:0 12px}.brand:hover{color:#fff}.brand svg{fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.nav-current{display:flex;gap:10px;align-items:center;background:var(--selected);color:var(--selected-text);border-radius:6px;padding:12px;font-size:14px;font-weight:500}.sidebar-note{margin-top:auto;padding:0 12px;font-size:13px;line-height:20px;color:var(--sidebar-text)}.workspace{min-width:0}.topbar{min-height:56px;border-bottom:1px solid var(--border);padding:7px 24px;display:flex;justify-content:space-between;align-items:center;gap:16px;background:var(--surface);font-size:14px;font-weight:500}.quiet-label{color:var(--muted);font-weight:400}main{padding:24px;max-width:1392px;margin:auto;outline:none}.page-heading{display:flex;justify-content:space-between;align-items:flex-start;gap:24px;margin-bottom:16px}.eyebrow{font-size:11px;line-height:16px;letter-spacing:1.1px;font-weight:600;color:var(--muted);margin:0 0 12px}.page-description{color:var(--muted);margin:0}.status-badge{padding:6px 10px;border:1px solid var(--border);border-radius:5px;font-size:12px;white-space:nowrap;background:var(--surface)}.foundation-grid{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:24px;align-items:start;margin-top:24px}.panel{padding:16px;background:var(--surface);border:1px solid var(--border);border-radius:10px;min-width:0}.panel-soft{background:var(--soft)}.section-heading{display:flex;justify-content:space-between;gap:16px}.section-heading h2{margin-bottom:8px}.section-heading>.icon{color:var(--muted);margin-top:4px}.stack{display:grid;gap:16px}.muted,.hint{color:var(--muted)}.hint{font-size:14px;line-height:20px;margin:8px 0 0}.field{margin-top:16px}.field label{display:block;font-size:14px;line-height:20px;font-weight:500;margin-bottom:8px}.field label span{font-weight:400}.form-control{width:100%;border:1px solid var(--field-border);border-radius:6px;min-height:40px;padding:9px 12px;background:var(--surface);color:var(--text);font-size:14px;line-height:20px;transition:border-color 120ms}.form-control::placeholder{color:var(--muted);opacity:1}.form-control:focus{border-color:var(--primary);box-shadow:none;outline:2px solid var(--primary);outline-offset:2px}.form-control[aria-invalid=true]{border-color:var(--error)}.form-control[aria-invalid=true]:focus{outline-color:var(--error)}textarea.form-control{min-height:110px;resize:vertical}.field-error{font-size:14px;line-height:20px;color:var(--error);margin:8px 0 0}.field-error p{margin:0}.actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:16px}.btn{border-radius:6px;font-size:14px;line-height:20px;font-weight:600;padding:10px 16px;min-height:40px;display:inline-flex;justify-content:center;align-items:center;gap:8px;transition:color 120ms,background 120ms,box-shadow 120ms,transform 120ms}.btn-primary{--bs-btn-bg:var(--primary);--bs-btn-border-color:var(--primary);--bs-btn-hover-bg:var(--primary-hover);--bs-btn-hover-border-color:var(--primary-hover);--bs-btn-active-bg:var(--primary-hover);--bs-btn-active-border-color:var(--primary-hover);--bs-btn-color:#fff;--bs-btn-hover-color:#fff;--bs-btn-active-color:#fff}.btn-secondary{--bs-btn-bg:var(--soft);--bs-btn-color:var(--primary);--bs-btn-border-color:var(--selected);--bs-btn-hover-bg:var(--sidebar-text);--bs-btn-hover-color:var(--primary-hover);--bs-btn-hover-border-color:var(--primary);--bs-btn-active-bg:var(--sidebar-text);--bs-btn-active-color:var(--primary-hover);--bs-btn-active-border-color:var(--primary)}.btn-ghost{color:var(--primary);padding:10px 12px;border:1px solid transparent}.btn:hover{transform:translateY(-1px);box-shadow:0 3px 8px rgb(46 38 34 / 12%)}.btn-ghost:hover{background:var(--soft);box-shadow:none}.btn:active{transform:none;box-shadow:none}.btn:disabled{background:var(--page);color:var(--muted);border-color:var(--border);opacity:1;transform:none;box-shadow:none}a:focus-visible,button:focus-visible,summary:focus-visible{outline:2px solid var(--primary);outline-offset:4px;box-shadow:none}.sidebar a:focus-visible{outline-color:var(--sidebar-text)}.notice{display:flex;gap:12px;align-items:flex-start;padding:16px;border:1px solid var(--border);border-radius:6px;font-size:14px;line-height:20px;margin-bottom:16px;overflow-wrap:anywhere}.notice p{margin:4px 0 0}.notice .icon{margin-top:1px}.notice-info{background:var(--soft)}.notice-success{color:var(--success);background:color-mix(in srgb,var(--success) 8%,white);border-color:color-mix(in srgb,var(--success) 25%,white)}.notice-error{color:var(--error);background:color-mix(in srgb,var(--error) 5%,white);border-color:color-mix(in srgb,var(--error) 25%,white)}.text-link{display:inline-flex;gap:8px;font-size:14px;margin-top:16px}.form-feedback{min-height:20px}.amount-list{margin:0}.amount-list>div{display:flex;justify-content:space-between;align-items:baseline;gap:16px;padding:12px 0;border-bottom:1px solid var(--border)}.amount-list dt{font-weight:400;font-size:14px}.amount-list dd{font-weight:600;font-variant-numeric:tabular-nums;text-align:right;margin:0}.page-footer{margin-top:32px;color:var(--muted);font-size:12px}.skip-link{position:absolute;left:16px;top:-100px;z-index:10;background:white;padding:12px}.skip-link:focus{top:8px}dialog{border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--text);padding:24px;max-width:560px;width:calc(100% - 32px);box-shadow:0 16px 60px rgb(46 38 34 / 18%)}dialog::backdrop{background:rgb(46 38 34 / 40%)}dialog[open]{animation:appear 180ms ease-out}.dialog-actions{align-items:stretch}.dialog-actions .btn{flex:1 1 auto}.htmx-indicator{display:none}.htmx-request .htmx-indicator{display:inline}form[aria-busy=true]{cursor:progress}@keyframes appear{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}
@media(max-width:1100px){.app-shell{grid-template-columns:200px minmax(0,1fr)}main{padding:20px}.topbar{padding:7px 20px}.foundation-grid{grid-template-columns:1fr}.stack{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){.app-shell{display:block}.sidebar{padding:16px;gap:16px}.brand{font-size:18px;line-height:22px;padding:0}.brand br{display:none}.brand span{word-spacing:2px}.nav-current{width:fit-content}.sidebar-note{display:none}.topbar{padding:7px 16px;min-height:56px;flex-wrap:wrap;gap:4px}main{padding:16px}.page-heading{flex-direction:column;gap:12px}.stack{grid-template-columns:1fr}.panel{padding:16px}.amount-list>div{flex-wrap:wrap}.amount-list dd{margin-left:auto}.status-badge{align-self:flex-start}}
@media(pointer:coarse){.btn,.form-control{min-height:44px}.form-control{font-size:16px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}.btn:hover{transform:none}}
.auth-page{min-height:100vh;display:grid;place-items:center;padding:48px 24px;background:var(--page)}
.btn:focus-visible{outline:2px solid var(--primary);outline-offset:4px;box-shadow:none}
.app-navigation{display:grid;gap:4px}.app-navigation a{padding:8px 12px;color:var(--sidebar-text);text-decoration:none;font-size:14px;border-radius:6px}.app-navigation a.nav-current{color:var(--selected-text)}.app-navigation a:hover{background:rgb(255 255 255 / 8%)}.app-navigation a.nav-current:hover{background:var(--selected)}
.topbar>[data-company-name]{overflow-wrap:anywhere;min-width:0}.company-layout{display:grid;gap:16px;align-items:start;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr)}.company-group{border-top:1px solid var(--border);margin-top:16px;padding-top:16px}.company-group summary{font-weight:600;cursor:pointer;overflow-wrap:anywhere}.company-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:16px}.company-field{min-width:0;margin-top:16px}.company-grid .company-field{margin-top:0}.company-field label{display:block;font-size:14px;font-weight:500;margin-bottom:8px}.company-field.field-wide{grid-column:1/-1}.company-field textarea{min-height:90px}.company-field input,.company-field select{min-width:0;max-width:100%}.company-layout .actions{align-items:center}.company-layout .form-feedback:empty{display:none}.company-layout .form-feedback{margin-top:16px;overflow-wrap:anywhere}.company-layout .saved-feedback{color:var(--success)}.vat-current{padding:20px;background:var(--soft);border-radius:6px;display:grid;gap:8px;margin:16px 0;overflow-wrap:anywhere}.vat-current strong{font-size:24px;line-height:32px}.vat-current .hint{margin:0}.history-scroll{overflow-x:auto;margin-top:16px}.company-history{width:100%;min-width:690px;table-layout:fixed;font-size:14px;line-height:20px;border-collapse:collapse}.company-history th,.company-history td{text-align:left;vertical-align:top;border-bottom:1px solid var(--border);padding:12px 8px;overflow-wrap:anywhere}.company-history th{font-weight:500}.company-history td{max-width:220px}.company-history .status-badge{display:inline-block;margin-top:8px;white-space:normal}.rate-list{margin:16px 0 24px}.rate-item{display:flex;justify-content:space-between;gap:16px;padding:12px 0;border-bottom:1px solid var(--border);align-items:start}.rate-item>div{min-width:0;overflow-wrap:anywhere}.rate-item .hint{display:block}.rate-item form{max-width:50%;flex-shrink:0}.rate-item button{max-width:100%;white-space:normal}.company-layout fieldset{min-width:0}
/* Share label, control and error rows: wrapped labels cannot lift a neighbour. */
.company-grid{row-gap:8px}
.company-grid .company-field{display:grid;grid-template-rows:subgrid;grid-row:span 3;row-gap:8px;padding-bottom:8px}
.company-grid .company-field label{margin:0;align-self:end}
.company-grid .company-field .form-control{align-self:start}
.company-grid .company-field .field-error{margin:0}
/* Feedback may widen the form, but its button stays against the right edge. */
.rate-item form{display:flex;flex-direction:column;align-items:flex-end}
.rate-item [data-form-feedback]{text-align:right}
@media(max-width:1200px){.company-layout{grid-template-columns:1fr}}@media(max-width:600px){.company-grid{grid-template-columns:1fr}.company-layout .panel{padding:16px}.company-layout .actions .btn{width:100%}.app-navigation{grid-template-columns:repeat(2,minmax(0,1fr));gap:4px}.app-navigation a{width:auto}.topbar-actions{flex-wrap:wrap}.company-history{min-width:690px}}
.auth-brand svg{fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}
.auth-wrap{width:100%;max-width:440px;min-width:0}.auth-brand{display:flex;align-items:center;justify-content:center;gap:12px;margin-bottom:28px;font-size:22px;font-weight:600;color:var(--primary)}
.auth-panel{padding:32px}.auth-panel h1{margin-bottom:8px}.auth-description{margin:0 0 24px}.auth-panel .form-field{margin-top:20px}.auth-panel label{display:block;margin-bottom:8px;font-size:14px;font-weight:500}.password-row{display:flex;align-items:stretch;gap:8px}.password-row input{min-width:0;flex:1}.password-row button{flex-shrink:0}.auth-submit{width:100%;margin-top:24px}.auth-error{display:block;margin:20px 0 0}.auth-error:focus{outline:2px solid var(--error);outline-offset:4px}.auth-status{font-size:14px;min-height:20px;margin:12px 0 0}.auth-panel [data-form-feedback]:empty{display:none}.topbar-actions{display:flex;align-items:center;gap:16px}.topbar-actions form{margin:0}.muted{color:var(--muted)}
@media(max-width:480px){.auth-page{padding:28px 16px;align-items:start}.auth-brand{font-size:20px;margin-top:16px;margin-bottom:24px}.auth-panel{padding:24px}.password-row{gap:6px}.password-row button{padding-left:10px;padding-right:10px}.topbar-actions{gap:8px}}
/* Contracts and reusable customer records. */
.record-card{max-width:960px}.record-search{display:flex;flex-wrap:wrap;align-items:end;gap:16px;margin-bottom:12px}.record-search>div{flex:1 1 230px;min-width:0}.record-search label{display:block;font-size:14px;margin-bottom:8px}.record-search>a{padding:10px 0}.record-table-scroll{overflow-x:auto}.record-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px;min-width:680px}.record-table th,.record-table td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--border);vertical-align:middle}.record-table th{font-weight:500;color:var(--muted)}.record-table .status-badge{white-space:normal;display:inline-block}.record-name{display:block;max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.record-code{white-space:nowrap;font-variant-numeric:tabular-nums}.empty-state{padding:32px 0;color:var(--muted)}.record-details{margin:16px 0 0}.record-details>div{display:grid;grid-template-columns:minmax(150px,1fr) minmax(0,2fr);gap:16px;padding:10px 0;border-bottom:1px solid var(--border)}.record-details dt{font-weight:400;color:var(--muted)}.record-details dd{margin:0;overflow-wrap:anywhere}.long-text,.page-description{overflow-wrap:anywhere}.record-sections{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:16px}.record-delete{margin-top:24px}.record-delete summary{cursor:pointer;font-weight:500}.delete-confirm{display:flex;gap:12px;align-items:center;margin-top:20px}.customer-choice{display:flex;align-items:center;flex-wrap:wrap;gap:12px}.customer-choice>span{overflow-wrap:anywhere;flex:1 1 200px}.record-card .form-feedback:empty{display:none}.record-card .saved-feedback{color:var(--success)}.duplicate-warning{margin-top:24px}.duplicate-warning label{display:block;margin-top:16px}.record-card .section-heading{align-items:center;flex-wrap:wrap;margin-bottom:20px}.record-card .section-heading h2{margin-bottom:0}.record-card input[type=checkbox]{width:18px;height:18px;accent-color:var(--primary)}#customer-picker{outline:none}#customer-picker h1:focus{outline:none}
@media(max-width:760px){.record-details>div{grid-template-columns:1fr;gap:4px}.record-sections{grid-template-columns:1fr}.record-name{max-width:220px}.record-card .actions{flex-wrap:wrap}}

.back-navigation{margin-bottom:16px}.back-navigation a{display:inline-flex;align-items:center;min-height:40px;font-size:14px;font-weight:500}.contract-table{table-layout:fixed;min-width:740px}.contract-table .contract-number{width:15%}.contract-table .contract-date{width:112px}.contract-table .contract-customer{width:21%}.contract-table .contract-status{width:155px}.contract-table .record-name{max-width:100%}.contract-object-name{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;overflow-wrap:anywhere}.contract-table .status-badge{font-size:12px;line-height:18px;padding:4px 8px}.contract-table .status-complete{font-size:12px;line-height:18px;color:var(--muted)}
#customer-picker [data-picker-cancel]{margin-bottom:16px}
.catalog-editor{margin-bottom:16px;max-width:960px}.catalog-editor .form-feedback:empty,[data-selection-feedback]:empty{display:none}.catalog-editor .saved-feedback{color:var(--success)}.catalog-table{table-layout:fixed;min-width:760px}.catalog-type{width:104px}.catalog-unit{width:100px}.catalog-use{width:140px}.catalog-actions-col{width:120px}[data-selection-context] .catalog-actions-col{width:220px}.catalog-name{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}.catalog-unit-value{text-align:center!important;overflow-wrap:anywhere}.catalog-table td{padding-top:8px;padding-bottom:8px}.catalog-row-actions{display:flex;align-items:center;gap:8px}.catalog-icon-action{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;flex:0 0 40px;border:1px solid currentColor;border-radius:6px;text-decoration:none}.catalog-edit{color:var(--success);background:color-mix(in srgb,var(--success) 6%,white)}.catalog-delete{color:var(--error);background:color-mix(in srgb,var(--error) 5%,white)}.catalog-edit:hover{color:var(--success);background:color-mix(in srgb,var(--success) 14%,white)}.catalog-delete:hover{color:var(--error);background:color-mix(in srgb,var(--error) 12%,white)}.catalog-delete-blocked,.catalog-delete-blocked:hover{color:var(--muted);background:var(--soft)}.catalog-editor input[type=checkbox]{width:18px;height:18px;accent-color:var(--primary)}

/* Initial estimate: scoped editor, exact amounts and compact row actions. */
.estimate-header{display:grid;grid-template-columns:minmax(180px,240px) 1fr;gap:16px;margin-bottom:16px}.estimate-header label{font-size:14px;display:block;margin-bottom:8px}.estimate-vat-choice{display:flex!important;gap:8px;align-items:start}.estimate-tools{display:flex;align-items:end;flex-wrap:wrap;gap:8px;margin-bottom:12px}.estimate-tools label{font-size:14px;flex:1 1 180px;max-width:300px}.estimate-tools select{margin-top:8px}.estimate-table{min-width:1180px;table-layout:fixed}.estimate-table td{padding:8px;vertical-align:top}.estimate-table th{padding:12px 8px}.estimate-number{width:45px}.estimate-name{width:auto}.estimate-unit{width:95px}.estimate-quantity{width:120px}.estimate-price{width:145px}.estimate-total{width:155px}.estimate-row-section{width:145px}.estimate-row-action{width:65px}.estimate-row-number,.estimate-centered{text-align:center!important}.estimate-centered input{text-align:center}.estimate-numeric,.estimate-numeric input{text-align:right!important;font-variant-numeric:tabular-nums}.estimate-table textarea{min-height:64px;margin-top:6px}.estimate-table .field-error:empty{display:none}.estimate-table .field-error{overflow-wrap:anywhere;font-size:12px;line-height:18px}.estimate-table .form-control{padding:7px 8px}.estimate-section-heading td{background:var(--soft);padding:12px!important}.estimate-section-heading strong{overflow-wrap:anywhere}.estimate-section-heading span{float:right;font-weight:600;white-space:nowrap;margin-left:16px}.estimate-totals{margin-top:16px;text-align:right;font-variant-numeric:tabular-nums}.estimate-totals>div{margin-top:8px}.estimate-totals strong{font-size:22px;margin-left:24px}.estimate-totals span{margin-left:16px}.estimate-savebar{position:sticky;bottom:0;z-index:2;background:var(--page,#F8F5F1);border:1px solid var(--border);border-radius:8px;padding:16px;margin-top:16px;box-shadow:0 -3px 12px rgb(46 38 34 / 6%)}.estimate-savebar .actions{margin-top:8px;align-items:center}.estimate-feedback{font-size:14px}.estimate-feedback:empty{display:none}.estimate-feedback.saved-feedback{color:var(--success)}.estimate-sections{display:grid;gap:12px;margin:16px 0}.estimate-section-editor{display:flex;align-items:center;gap:16px;padding:12px;background:var(--soft);border-radius:6px}.estimate-section-editor label{flex:1;font-size:14px}.estimate-section-editor textarea{min-height:45px}.estimate-section-actions{display:flex;gap:8px;flex-wrap:wrap}.estimate-catalog{max-width:1200px;width:calc(100% - 32px);height:90vh;max-height:950px}.estimate-catalog .section-heading{align-items:center;margin-bottom:16px;flex-wrap:wrap}.estimate-catalog iframe{border:1px solid var(--border);width:100%;height:calc(100% - 85px);border-radius:6px}.estimate-revision-list{padding:0;list-style:none}.estimate-revision-list li{display:flex;justify-content:space-between;gap:12px;align-items:center;margin:16px 0}body:has([data-selection-context]) .sidebar,body:has([data-selection-context]) .topbar,body:has([data-selection-context]) .back-navigation{display:none}body:has([data-selection-context]) .app-shell{display:block}body:has([data-selection-context]) main{padding:16px}.estimate-header [data-estimate-error]:empty{display:none}
@media(max-width:700px){.estimate-header{grid-template-columns:1fr}.estimate-body{padding:16px}.estimate-section-editor{flex-wrap:wrap}.estimate-section-editor label{flex-basis:100%}.estimate-savebar{position:static}.estimate-catalog{padding:12px;width:calc(100% - 16px);height:94vh}.estimate-catalog h2{font-size:18px}}
/* Separate optional section management from the estimate rows. */
.estimate-section-panel{margin-bottom:24px;padding:18px 24px;border-left:4px solid var(--primary)}
.estimate-section-panel>summary{cursor:pointer;font-weight:600;display:list-item}
.estimate-section-panel>summary [data-section-count]{float:right;font-weight:400;margin-left:16px}
.estimate-section-panel>p{margin:16px 0 12px}
.estimate-section-panel .estimate-sections{gap:8px;margin:12px 0}
.estimate-section-panel .estimate-section-editor{gap:10px;padding:0;background:transparent}
.estimate-section-panel .estimate-section-editor label{margin:0;min-width:0}
.estimate-section-panel .estimate-section-editor textarea{height:40px;min-height:40px;padding:8px 10px;line-height:22px}
.estimate-section-index{width:24px;flex:0 0 24px;text-align:center;color:var(--muted);font-size:14px}
.estimate-section-actions{gap:6px;flex-wrap:nowrap}
.estimate-section-actions .btn{width:40px;height:40px;padding:0}
.estimate-section-panel .actions{margin-top:16px;flex-wrap:wrap}
.estimate-body>h2{margin-bottom:20px}
.estimate-tools{align-items:center;gap:16px;margin-bottom:16px}
.estimate-destination{flex:0 1 350px;min-width:240px;padding:14px 16px;border:1px solid var(--primary);border-radius:8px;background:var(--soft)}
.estimate-destination label{font-weight:600;display:block;max-width:none}
.estimate-destination .hint{margin:8px 0 0;font-size:12px;line-height:18px}
.estimate-add-actions{display:flex;flex-wrap:wrap;gap:8px}
.estimate-section-heading span{white-space:normal;text-align:right}
@media(max-width:700px){.estimate-section-panel{padding:16px}.estimate-section-panel>summary [data-section-count]{float:none;display:block;margin:6px 0 0}.estimate-section-panel .estimate-section-editor{flex-wrap:nowrap}.estimate-section-panel .estimate-section-editor label{flex:1;flex-basis:auto}.estimate-section-index{display:none}.estimate-section-actions{gap:4px}.estimate-section-actions .btn,.estimate-section-actions .catalog-icon-action{width:34px;flex-basis:34px}.estimate-destination{min-width:0;flex-basis:100%}}

/* Compact estimate names: the type remains available without a second field. */
.estimate-name-layout{display:flex;align-items:flex-start;gap:8px}
.estimate-type-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 36px;width:36px;height:40px;padding:6px;color:var(--primary);border:1px solid var(--border);border-radius:6px;background:var(--soft);cursor:pointer}
.estimate-type-icon:hover{border-color:var(--primary)}
.estimate-type-icon .icon,.estimate-type-dialog .icon{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.estimate-table .estimate-line-name{flex:1;min-width:0;min-height:40px;margin:0;padding:8px;line-height:22px;resize:none;overflow:hidden}
.estimate-line-text{flex:1;min-width:0;padding:8px 0;line-height:24px}
.estimate-manual-add{display:inline-block;min-height:40px;padding:8px;background:transparent;border:0;color:var(--primary);text-decoration:underline;text-underline-offset:4px;cursor:pointer;font:inherit}
.estimate-manual-add:hover{color:var(--text)}
.estimate-type-icon:focus-visible,.estimate-manual-add:focus-visible{outline:3px solid var(--primary);outline-offset:3px}
.estimate-type-dialog{width:min(460px,calc(100vw - 32px));padding:24px;border:1px solid var(--border);border-radius:12px;color:var(--text);background:var(--surface)}
.estimate-type-dialog::backdrop{background:rgba(30,23,18,.45)}
.estimate-type-dialog h2{font-size:22px;margin:0 0 16px}
.estimate-type-dialog .actions{margin:20px 0 12px;flex-wrap:wrap}
.estimate-type-dialog .btn{display:inline-flex;gap:8px;align-items:center}
.estimate-revision-tools{display:flex;gap:16px;align-items:end;flex-wrap:wrap;margin-bottom:16px}
.estimate-revision-tools>div{flex:1 1 240px;max-width:480px;min-width:0}
.estimate-revision-tools label,.estimate-price-dialog label{display:block;font-size:14px;margin-bottom:6px}
.estimate-revision-tools .btn{white-space:normal}
.estimate-price-action{display:block;margin:4px 0 0 auto;padding:2px 0;border:0;background:none;color:var(--primary);font:inherit;font-size:12px;text-decoration:underline;cursor:pointer}
.estimate-price-action:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.estimate-price-dialog{width:min(560px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto;padding:20px;border:1px solid var(--border);border-radius:12px;color:var(--text);background:var(--surface)}
.estimate-price-dialog::backdrop{background:rgba(30,23,18,.45)}
.estimate-price-dialog h2{margin:0 0 12px;font-size:22px}
.estimate-price-dialog .actions{flex-wrap:wrap;margin:16px 0}
.estimate-price-summary{font-weight:600}
.estimate-revision-basis{display:block;font-size:14px;color:var(--muted);margin-top:4px;overflow-wrap:anywhere}
.estimate-revision-list li>div{min-width:0}
/* Values align with the input itself; hints/errors below it do not shift totals. */
.estimate-value{min-height:40px;display:flex;align-items:center;justify-content:center;overflow-wrap:anywhere}
.estimate-numeric .estimate-value{justify-content:flex-end}
@media(pointer:coarse){.estimate-value{min-height:44px}}
/* Fit ordinary desktop workspaces without sacrificing readable input sizes. */
.estimate-table{min-width:940px}
.estimate-table .estimate-number{width:36px}
.estimate-table .estimate-unit{width:76px}
.estimate-table .estimate-quantity{width:104px}
.estimate-table .estimate-price{width:128px}
.estimate-table .estimate-total{width:150px}
.estimate-table .estimate-row-section{width:120px}
.estimate-table .estimate-row-action{width:80px}
.estimate-table td,.estimate-table th{padding-left:6px;padding-right:6px}
[data-readonly=true] .estimate-table{min-width:680px}
.contract-amount-summary{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:16px}
.contract-amount-summary h2{font-size:16px;line-height:24px;margin:0}
.contract-amount-summary>div{min-width:0}
.contract-amount-value{font-size:26px;line-height:34px;font-weight:600;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.contract-amount-missing{font-size:14px;line-height:20px;font-weight:400;color:var(--muted)}
.contract-table{min-width:850px}
.contract-table .contract-number{width:12%}
.contract-table .contract-customer{width:17%}
.contract-table .contract-status{width:115px}
.contract-table .contract-amount{width:165px}
.contract-table .contract-amount-cell{text-align:right;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
.contract-amount-cell small{display:block;color:var(--muted);font-size:12px;line-height:18px;margin-top:4px}

.estimate-vat-panel{margin:16px 0}.estimate-vat-panel>p:first-child{margin:0 0 8px}.estimate-vat-panel summary,.estimate-vat-history summary{cursor:pointer;font-weight:600}.estimate-vat-panel .actions{align-items:end}.estimate-vat-panel label{font-size:14px}.estimate-vat-panel select{margin-top:6px}.vat-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:16px}.vat-option{padding:16px;border:1px solid var(--border);border-radius:8px;min-width:0}.vat-option:has(input:checked){border-color:var(--primary);background:var(--soft)}.vat-option>label{display:flex;align-items:start;gap:8px;font-weight:600}.vat-option input{margin-top:4px;flex-shrink:0}.vat-option table{width:100%;font-size:14px;line-height:20px;table-layout:fixed;margin-top:12px}.vat-option th,.vat-option td{padding:6px 3px;overflow-wrap:anywhere;border-bottom:1px solid var(--border);vertical-align:top;text-align:right;font-variant-numeric:tabular-nums}.vat-option th:first-child{text-align:left}.vat-option th{font-weight:500}.vat-option caption{caption-side:top;color:var(--text);font-weight:600}.estimate-vat-history{margin-top:16px}.estimate-vat-history article{padding:12px 0;border-bottom:1px solid var(--border)}.estimate-vat-history article p{margin:0 0 6px}.estimate-vat-history dl{margin:8px 0 0;font-size:14px}.estimate-vat-history dl>div{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap}.estimate-vat-history dt{font-weight:400}.estimate-vat-history dd{margin:0;text-align:right;overflow-wrap:anywhere}.estimate-vat-panel [data-vat-pending] p{margin:12px 0 8px}@media(max-width:1000px){.vat-options{grid-template-columns:1fr}}

@media(max-width:600px){.vat-option{padding:12px}.vat-option thead{display:none}.vat-option tbody tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));margin-bottom:12px}.vat-option tbody th{grid-column:1/-1}.vat-option td::before{content:attr(data-heading);display:block;color:var(--muted);font-size:12px}}

/* Working KS editor: compact quantities with readable inputs. */
.ks-dates{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.ks-check{display:flex;align-items:center;gap:8px;font-size:14px}.ks-check input{width:auto}.ks-requisites{margin-top:12px}.ks-requisites .actions{margin:10px 0}.ks-table-scroll{overflow:auto;max-width:100%}.ks-table{width:100%;min-width:850px;table-layout:fixed;font-size:14px;line-height:20px}.ks-table th,.ks-table td{border-bottom:1px solid var(--border);padding:8px 6px;vertical-align:middle;text-align:right;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.ks-table th{font-weight:500;color:var(--muted);text-align:center}.ks-table th:first-child,.ks-table td:first-child{text-align:left;width:28%}.ks-table th:nth-child(2){width:5%}.ks-table th:nth-child(6){width:12%}.ks-table th:last-child{width:14%}.ks-table .ks-unit{text-align:center}.ks-table input{width:100%;min-width:0;padding:8px;text-align:right}.ks-table .ks-now{background:var(--soft)}.ks-table .ks-now input{border-color:var(--primary)}.ks-table [aria-invalid=true]{border-color:var(--error);background:#fff5f4}.ks-name-heading{display:flex;gap:6px;align-items:center}.ks-name-heading .icon{width:18px;height:18px;flex-shrink:0}.ks-name details{margin-top:4px;font-size:12px}.ks-name summary{color:var(--primary);cursor:pointer}.ks-name details p{margin:6px 0}.ks-name label{display:block}.ks-name details button{font-size:12px;padding:6px}.ks-row-error td{font-size:12px;color:var(--error);padding:4px 8px 8px}.ks-section td{background:var(--soft);padding:10px!important}.ks-section td>span{float:right}.ks-totals{text-align:right;margin:16px 0}.ks-totals p{margin:6px 0}.ks-totals strong{font-size:24px;margin-left:12px}.ks-savebar{position:sticky;bottom:0;background:var(--soft);padding:12px 16px;border:1px solid var(--border);border-radius:8px;z-index:5;margin:16px 0}.ks-savebar p{margin:0 0 8px}.ks-savebar .hint{margin:8px 0 0}.ks-packages .data-table td:nth-last-child(-n+3),.ks-packages .data-table tfoot td{text-align:right;white-space:nowrap}.ks-packages tfoot{border-top:2px solid var(--border)}#ks-issues{padding-left:20px}#ks-issues li{margin:6px 0}#ks-rebase-dialog{max-width:600px;width:calc(100% - 32px)}#ks-rebase-summary{max-height:55vh;overflow:auto}
@media(max-width:750px){.ks-dates{grid-template-columns:1fr}.ks-savebar{padding:10px}.ks-savebar .actions{gap:8px}.ks-savebar .btn{padding:8px 10px}.ks-totals strong{display:block;margin:6px 0}.ks-table{min-width:820px}.ks-packages .section-heading{align-items:flex-start}}

#ks-form>.panel{margin-bottom:16px}.ks-dates label{display:block;font-size:14px;margin-bottom:6px}.ks-table td:not(:first-child):not(:last-child){text-align:center}.ks-table .ks-now input{text-align:center}

/* Document amounts stay in distinct, aligned columns at every workspace width. */
.contract-documents{display:grid;gap:24px;margin-top:20px;min-width:0}
.ks-document-file{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;padding:12px 0;border-bottom:1px solid var(--border)}
.ks-document-file .actions{margin:0}.ks-documents>.actions:empty{display:none}
.pdf-toolbar{display:flex;gap:16px;align-items:center;justify-content:space-between;flex-wrap:wrap;margin-bottom:16px}
.pdf-toolbar .actions{margin:0}.pdf-preview{height:75vh;min-height:400px;border:1px solid var(--border);background:var(--soft);border-radius:6px;overflow:hidden}
.pdf-preview iframe{width:100%;height:100%;border:0}.ks-package-table .document-actions{white-space:normal;text-align:left}
.document-actions a{display:inline-block;margin-right:10px;padding:4px 0}
.contract-documents>.panel{min-width:0;margin:0}
.document-table-scroll{max-width:100%;overflow-x:auto;margin-top:12px}
.document-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}
.document-table th,.document-table td{padding:10px 14px;border-bottom:1px solid var(--border);text-align:left;vertical-align:middle}
.document-table thead th{font-weight:500;color:var(--muted);background:var(--soft)}
.document-table tbody th{font-weight:500}
.document-table td.document-amount,.document-table th.document-amount,.money-table td,.money-table thead th:not(:first-child),.ks-package-table :is(th,td):nth-last-child(-n+3){text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
.document-table .document-amount small{display:block;white-space:normal;color:var(--muted);font-size:12px;line-height:18px;font-weight:400;margin-top:4px;max-width:240px;margin-left:auto}
.estimate-revisions-table{min-width:650px}.estimate-revisions-table td:last-child{font-weight:600}
.ks-package-table{min-width:720px}.ks-package-table tfoot th{text-align:left!important;white-space:normal!important}
.ks-package-table td:last-child,.money-table td:last-child{font-weight:600}
.money-table{min-width:600px}.money-table th:first-child{min-width:170px}
.money-table td{min-width:130px}.money-table tbody tr:last-child{border-bottom:2px solid var(--border)}
.ks-cumulative{margin-top:20px;padding-top:16px;border-top:1px solid var(--border)}
.ks-cumulative summary,.ks-rounding summary{font-weight:500;cursor:pointer}
.ks-rounding h2{font-size:18px;margin-bottom:8px}.ks-rounding>p{margin:0 0 8px}
.ks-rounding-line{padding:16px 0;border-top:1px solid var(--border);margin-top:16px}
.ks-rounding-line h3,.ks-correction-panel h3{font-size:16px;line-height:24px;margin:0 0 8px;overflow-wrap:anywhere}
.ks-rounding-line .btn{margin-top:12px}
.ks-correction-toggle{display:block;border:0;background:none;color:var(--primary);font:inherit;font-size:12px;text-decoration:underline;text-underline-offset:3px;cursor:pointer;padding:6px 0;margin-top:2px;text-align:left}
.ks-correction-toggle:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.ks-table .ks-correction-row>td{padding:0 6px 12px;text-align:left!important}
.ks-correction-panel{padding:16px;background:var(--soft);border:1px solid var(--border);border-radius:6px}
.ks-correction-panel .document-table{background:var(--surface);table-layout:auto}
.ks-correction-panel .document-table :is(th,td){padding:8px 12px;width:auto;text-align:right!important}
.ks-correction-panel .document-table :is(th,td):first-child{text-align:left!important;width:30%}
.ks-correction-panel>label{display:block;max-width:300px;margin:14px 0 8px}
.ks-correction-panel input{margin-top:6px;max-width:200px;text-align:right!important}
.ks-correction-panel>.hint{margin:8px 0 0}
@media(max-width:700px){.contract-documents{gap:20px}.document-table th,.document-table td{padding:8px 10px}.ks-correction-panel{padding:12px}}

/* Stage 17: fixed snapshots and signing action. */
.status-signed{color:var(--success);background:#edf6ef;border-color:#bbddc5;white-space:normal}.ks-sign-actions{border-top:1px solid var(--border);margin-top:16px;padding-top:16px}.ks-sign-actions .hint{margin:8px 0 0}.ks-signed-table{min-width:680px}.ks-signed-table :is(th,td):is(:first-child,:nth-child(3),:nth-child(4)){text-align:center}.ks-signed-table td:nth-child(2){min-width:220px;overflow-wrap:anywhere}.ks-signed-table .ks-section th{text-align:left}.signed-back{margin:16px 0 0}

.signed-sections{display:grid;gap:16px}.signed-sections>.panel,.signed-sections>.notice{margin:0}.signed-heading>div{min-width:0;flex:1}.signed-heading .status-badge{flex-shrink:0;max-width:220px}.signed-notice{display:block}.signed-notice p{margin:0}.signed-notice .hint{margin-top:6px}

/* Signing correction and preserved history. */
#ks-reversal-dialog{width:calc(100% - 32px);max-width:640px;max-height:calc(100vh - 32px);overflow:auto}#ks-reversal-form>label:first-of-type{display:block;margin:16px 0 8px}#ks-reversal-form .ks-check{margin:16px 0}.ks-history td:last-child,.signed-notice p{overflow-wrap:anywhere}.ks-history td:first-child{min-width:160px}.ks-history td:nth-child(2){white-space:nowrap}
