/* Portable estimating module. Every selector lives under .est-app. */
.est-app { --est-border:#dbe2e9; --est-light:#f7f9fc; --est-ink:#203047; --est-blue:#1b5f98; --est-muted:#66778a; font: 14px/1.4 Arial,sans-serif; color:var(--est-ink); max-width:1920px; margin:0 auto }
.est-app *, .est-app *::before, .est-app *::after {box-sizing:border-box}
.est-header {display:flex; justify-content:space-between; align-items:center; gap:20px; margin-bottom:17px; flex-wrap:wrap}
.est-back {font-size:12px; color:var(--est-blue); text-decoration:none; font-weight:700}
.est-heading h1 {font-size:27px; margin:3px 0 1px; line-height:1.15}
.est-heading p {color:var(--est-muted); margin:3px 0 0}
.est-title-row {display:flex; flex-wrap:wrap; gap:11px; align-items:center}
.est-pill {font-size:11px; padding:3px 9px; border-radius:99px; background:#fdf1d6; color:#855b0a; font-weight:700}
.est-top-actions {display:flex; flex-wrap:wrap; align-items:center; gap:7px}
.est-button {display:inline-flex; justify-content:center; align-items:center; gap:6px; border:1px solid var(--est-border); border-radius:7px; min-height:34px; padding:8px 11px; white-space:nowrap; font:700 12px/1 Arial,sans-serif; cursor:pointer; background:#fff; color:var(--est-ink); text-decoration:none}
.est-button:hover:not(:disabled) {background:#edf4fa; border-color:#9eb8cc}
.est-button.primary {background:var(--est-blue); color:#fff; border-color:var(--est-blue)}
.est-button.primary:hover {background:#144a78}
.est-button.ghost {background:#fff}
.est-button.disabled,.est-button:disabled {background:#f0f2f5; color:#929da9; cursor:not-allowed; border-color:#e2e7eb}
.est-button.danger-outline {color:#a63838; border-color:#edc4c4}
.est-button.danger-outline:hover {background:#fff1f1}
.est-summary {display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; margin-bottom:15px}
.est-stat {padding:11px 15px; border:1px solid var(--est-border); border-radius:10px; background:#fff}
.est-stat span {display:block; color:var(--est-muted); font-size:11px; font-weight:700; margin-bottom:4px}
.est-stat strong {font-size:18px}
.est-workspace {display:grid; grid-template-columns:minmax(345px,385px) minmax(0,1fr); align-items:start; gap:14px}
.est-left,.est-right {min-width:0}
.est-left {display:grid;gap:12px}
.est-panel {background:#fff;border:1px solid var(--est-border);border-radius:11px;padding:15px;min-width:0}
.est-panel-heading,.est-layout-heading {display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:11px}
.est-panel-heading h2,.est-layout-heading h2 {font-size:16px;margin:0;color:#233952}
.est-panel-heading>span {font-size:11px;color:var(--est-muted)}
.est-count {display:inline-block;margin-left:3px;vertical-align:2px;background:#edf2f7;border-radius:100px;color:#66788c;font-size:10px;padding:3px 7px}
.est-fields {display:grid;gap:9px;margin:0 0 9px}
.est-fields.two {grid-template-columns:repeat(2,minmax(0,1fr))}
.est-fields.three {grid-template-columns:2fr 2fr 1.1fr}
.est-app label {font-size:11px;font-weight:700;color:#53677d;min-width:0}
.est-input {display:block; width:100%; height:35px; margin-top:4px; border:1px solid #cfdae5; background:#fff; border-radius:7px; padding:6px 8px; color:#203047; font-size:13px; min-width:0}
.est-input:focus {outline:2px solid #c8e2f3; border-color:#3d8fca}
.est-full-field {display:block;margin:0 0 9px}
.est-slab-add-row {grid-template-columns:minmax(0,1fr) auto;align-items:end}
.est-slab-add-row .est-button {min-height:35px}
.est-piece-add-row {display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:9px}
.est-app .est-checkbox {display:inline-flex;gap:6px;align-items:center;cursor:pointer;color:#4d6176;font-size:11px;white-space:nowrap}
.est-checkbox input {margin:0;accent-color:#1b5f98}
.est-item-list {display:flex; flex-direction:column; gap:6px; max-height:285px;overflow:auto}
.est-list-row {display:flex;align-items:center;gap:6px;border:1px solid #e3e9ef;background:#fafbfd;border-radius:8px; min-width:0}
.est-list-select {flex:1;min-width:0;text-align:left;padding:9px 8px;border:0;background:none;cursor:pointer;color:#203047}
.est-list-row.selected {outline:2px solid #7aadd1;background:#eef6fc}
.est-list-row .est-list-title {display:block; font-size:12px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.est-list-row .est-list-detail {display:block; color:#728297;font-size:11px;margin-top:2px}
.est-kind {display:inline-block;border-radius:4px;background:#e5eef8;color:#205b89;font-size:9px;font-weight:700;padding:2px 5px;margin-right:5px;vertical-align:1px}
.est-kind.offcut {background:#f4e9d5;color:#8a6230}
.est-list-remove {margin-right:5px;padding:4px 6px;background:transparent;border:0;border-radius:5px;color:#929cab;cursor:pointer;font-size:16px}
.est-list-remove:hover {background:#fbeaea;color:#a33}
.est-clear {white-space:nowrap}
.est-layout-panel {min-height:580px;padding:18px}
.est-layout-heading {margin-bottom:12px;align-items:start;flex-wrap:wrap}
.est-layout-heading p {margin:4px 0 0;color:var(--est-muted);font-size:12px}
.est-layout-actions {display:flex;align-items:center;gap:11px;flex-wrap:wrap}
.est-workflow-note {border:1px solid #cee0ee;border-radius:8px;background:#f0f7fc;padding:9px 12px;margin-bottom:13px;font-size:12px;color:#425d78}
.est-selected {display:flex;flex-wrap:wrap;align-items:end;gap:9px;padding:10px 12px;background:#f7f9fb;border:1px solid #e0e8ef;border-radius:9px;margin-bottom:12px}
.est-selected[hidden],.est-message[hidden],.est-unplaced[hidden],.est-empty[hidden] {display:none}
.est-selected-name {min-width:155px;flex:1;display:flex;flex-direction:column;gap:3px}
.est-selected-name strong {font-size:13px}
.est-selected-name span {font-size:11px;color:#7a899a}
.est-selected label {width:185px}
.est-selected .est-input {height:34px}
.est-message {padding:10px;margin-bottom:10px;border-radius:7px;background:#e9f5ed;color:#18623d;font-size:12px}
.est-message.error {background:#fff0f0;color:#a52b2b}
.est-unplaced {margin-bottom:14px;border:1px dashed #d7a75d;border-radius:8px;background:#fff9ed;padding:9px 12px;color:#906318;font-size:12px}
.est-slab-stack {display:flex;flex-direction:column;gap:14px}
.est-slab-card {border:1px solid #e0e6ed;border-radius:10px;background:#fff;padding:14px;min-width:0;break-inside:avoid;page-break-inside:avoid}
.est-slab-card-head {display:flex;align-items:start;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:12px}
.est-slab-card-head h3 {font-size:14px;margin:0}
.est-slab-card-head p {font-size:11px;color:var(--est-muted);margin:4px 0 0}
.est-util-bar {min-width:140px;max-width:210px;width:27%}
.est-util-bar>div {height:5px;background:#e8edf3;border-radius:5px;overflow:hidden;margin-top:6px}
.est-util-bar b {display:block;height:100%;background:#2c9b87;border-radius:5px}
.est-util-bar span {font-weight:700;color:#53677b;font-size:11px;display:block;text-align:right}
.est-diagram-wrap {max-width:100%; overflow-x:auto;overflow-y:hidden; background:#f5f7f9;border:1px solid #e4e9ef;border-radius:7px; padding:12px}
.est-slab-svg {display:block;width:100%;height:auto;min-height:0; overflow:visible;touch-action:none;user-select:none}
.est-slab-surface {fill:#e3edf0;stroke:#7897a3;stroke-width:5;vector-effect:non-scaling-stroke}
.est-kerf-perimeter {fill:#d76565;fill-opacity:.26;pointer-events:none}
.est-kerf-boundary {fill:none;stroke:#b55757;stroke-width:2;stroke-dasharray:7 5;vector-effect:non-scaling-stroke;pointer-events:none}
.est-slab-card.offcut .est-slab-surface {fill:#f5ebd9;stroke:#ac9b7e}
.est-piece-rect {stroke:#286b88;stroke-width:3;vector-effect:non-scaling-stroke;cursor:grab}
.est-piece-group {cursor:grab}
.est-piece-group:active {cursor:grabbing}
.est-piece-group.selected .est-piece-rect {stroke:#17548d;stroke-width:5;stroke-dasharray:9 5}
.est-piece-group.locked .est-piece-rect {stroke:#5f6872;stroke-dasharray:7 5}
.est-piece-group.invalid .est-piece-rect {fill:#f59d9d!important;stroke:#c62c2c!important}
.est-piece-text {fill:#1b465e;pointer-events:none;font-weight:700;text-anchor:middle;dominant-baseline:central}
.est-piece-small {font-weight:400}
.est-slab-bottom {display:flex;justify-content:space-between;gap:8px;margin-top:8px;color:#77869a;font-size:11px}
.est-empty {padding:55px 14px;text-align:center;color:#8191a1;border:1px dashed #c9d5e1;border-radius:8px}
.est-footer {text-align:center;padding:18px 8px;color:#8793a0;font-size:11px}
@media(max-width:1150px) {.est-workspace {grid-template-columns:minmax(300px,345px) minmax(0,1fr)}.est-summary {grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:850px) {.est-workspace {grid-template-columns:1fr}.est-left {grid-template-columns:repeat(2,minmax(0,1fr))}.est-left>.est-panel:first-child {grid-column:1/-1}.est-right {grid-row:2}}
@media(max-width:570px) {.est-left {grid-template-columns:1fr}.est-left>.est-panel:first-child{grid-column:auto}.est-summary {grid-template-columns:repeat(2,minmax(0,1fr))}.est-app .est-heading h1 {font-size:21px}.est-slab-card {padding:9px}}
@media print {
  body {background:#fff!important;color:#000!important}
  body .main-content {padding:0!important}
  .est-header {margin:0 0 10px}
  .est-app {max-width:none;font-size:11px}
  .est-back,.est-pill,.est-top-actions,.est-left,.est-layout-actions,.est-workflow-note,.est-selected,.est-unplaced,.est-message,.est-footer {display:none!important}
  .est-workspace{display:block}
  .est-summary{grid-template-columns:repeat(5,1fr);gap:4px;margin-bottom:9px}
  .est-stat{padding:6px;border-color:#999}
  .est-stat strong{font-size:13px}
  .est-layout-panel{padding:0;border:0;min-height:0}
  .est-layout-heading{margin:3px 0 9px}
  .est-layout-heading p{display:none}
  .est-slab-card{break-inside:avoid;border:1px solid #aaa;margin-bottom:10px}
  .est-diagram-wrap{background:#fff;padding:5px;overflow:visible}
  .est-slab-svg{max-height:490px;min-height:0;print-color-adjust:exact;-webkit-print-color-adjust:exact}
  .est-piece-rect{print-color-adjust:exact;-webkit-print-color-adjust:exact}
  @page{size:A4 portrait;margin:11mm}
}

.est-print-meta {display:none}
@media print { .est-print-meta{display:block;font-weight:700;margin-top:4px} }

/* v103 — compact top-row summary + stacked editable lists. */
.est-workspace {
  display:grid;
  grid-template-columns:minmax(340px,390px) minmax(0,1fr);
  grid-template-areas:"details summary" "leftbottom layout";
  align-items:stretch; column-gap:14px;row-gap:13px;
}
.est-details-panel {grid-area:details}
.est-summary-panel {grid-area:summary;display:flex;flex-direction:column;justify-content:space-between}
.est-summary-panel .est-panel-heading {margin-bottom:8px}
.est-summary-panel .est-summary {display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:0;margin:0}
.est-summary-panel .est-stat {border:0;border-right:1px solid #e0e7ee;border-radius:0;padding:8px 12px 3px;background:none}
.est-summary-panel .est-stat:first-child {padding-left:0}
.est-summary-panel .est-stat:last-child {border:0;padding-right:0}
.est-summary-panel .est-stat strong {font-size:20px}
.est-left-lower {grid-area:leftbottom;display:flex;flex-direction:column;gap:12px;align-self:start;min-width:0}
.est-right {grid-area:layout;align-self:start;min-width:0}
.est-details-panel,.est-summary-panel {min-height:163px}
.est-piece-list {max-height:460px;min-height:68px}
.est-slabs-panel .est-item-list {max-height:310px}
.est-panel-heading .est-button {min-height:29px;padding:6px 9px}
.est-help {font-size:11px;line-height:1.5;color:var(--est-muted);margin:0 0 11px}
.est-list-row {background:#fff;transition:border-color .12s ease,background .12s ease}
.est-list-row.est-piece-row.placed {background:#e9f7ed;border-color:#b9e4c7}
.est-list-row.est-piece-row.unplaced {background:#fff0f0;border-color:#efc3c3}
.est-list-row.est-piece-row.selected {outline:2px solid #6ba6da;outline-offset:-1px}
.est-piece-row .est-list-select {touch-action:none;cursor:grab}
.est-piece-row .est-list-select:active {cursor:grabbing}
.est-status-dot {display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:7px;vertical-align:1px;background:#c24c4c}
.est-piece-row.placed .est-status-dot {background:#24824c}
.est-row-action {flex:none;border:0;border-radius:5px;background:transparent;color:#246799;font-weight:700;font-size:11px;padding:6px 4px;cursor:pointer}
.est-row-action:hover {text-decoration:underline;background:#e7eef6}
.est-piece-list.drop-ready {outline:2px dashed #1e9962;outline-offset:4px;background:#ecf9f0;border-radius:6px}
.est-layout-panel {min-height:540px}
.est-slab-svg {touch-action:none}
.est-app .est-modal-backdrop[hidden],.est-app .est-context[hidden],.est-app .est-drag-preview[hidden],.est-app .est-modal-note[hidden],.est-app #est-piece-qty-label[hidden] {display:none!important}
.est-modal-backdrop {position:fixed;inset:0;z-index:2100;display:flex;align-items:center;justify-content:center;background:rgba(16,35,54,.52);padding:20px}
.est-modal {background:#fff;color:var(--est-ink);border-radius:12px;box-shadow:0 18px 55px #0004;width:min(490px,100%);padding:19px 22px 18px;max-height:90vh;overflow:auto}
.est-modal-header {display:flex;justify-content:space-between;align-items:center;gap:14px;padding-bottom:13px;margin-bottom:15px;border-bottom:1px solid var(--est-border)}
.est-modal-header h2 {font-size:18px;margin:0}
.est-modal-close {border:0;background:#f0f3f7;font-size:23px;line-height:1;border-radius:6px;cursor:pointer;padding:4px 9px;color:#566a7e}
.est-modal-note {border-radius:7px;background:#f1f7fc;color:#547087;padding:9px;margin:12px 0;font-size:12px}
.est-modal-actions {display:flex;justify-content:flex-end;gap:9px;margin-top:20px;padding-top:13px;border-top:1px solid #e7edf2}
.est-context {position:fixed;z-index:2400;width:207px;box-shadow:0 12px 35px #15294336;border:1px solid #c9d5e2;border-radius:9px;background:#fff;padding:5px;color:#26394d}
.est-context-title {padding:7px 9px 9px;border-bottom:1px solid #e4e9f0;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.est-context button {display:block;width:100%;border:0;text-align:left;background:transparent;border-radius:5px;cursor:pointer;padding:9px;color:#26394d;font-size:12px}
.est-context button:hover:not(:disabled) {background:#ecf4fa}
.est-context button:disabled {color:#a4acb6;cursor:not-allowed}
.est-context button[data-menu="unplace"] {border-top:1px solid #ecf0f4;border-radius:0}
.est-drag-preview {position:fixed;z-index:2300;pointer-events:none;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;text-align:center;color:#174764;background:#a8d4e5c9;border:2px dashed #21688d;border-radius:3px;box-shadow:0 1px 12px #18314736;overflow:hidden;max-width:none}
.est-drag-preview strong {font-size:11px;line-height:1.1;max-width:100%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}
.est-drag-preview span {font-size:10px}
.est-drag-preview.invalid {background:#f38f8fcf;border-color:#b92f2f;color:#7b1515}
.est-drag-preview.remove-target {background:#c5e9d0;border-color:#319768;color:#246342}
body.est-modal-open {overflow:hidden}
.est-piece-group.locked {cursor:not-allowed}
@media(max-width:1150px){
  .est-workspace {grid-template-columns:minmax(290px,340px) minmax(0,1fr)}
  .est-summary-panel .est-stat {padding:6px 8px}
  .est-summary-panel .est-stat strong {font-size:17px}
}
@media(max-width:900px){
  .est-workspace {grid-template-columns:1fr;grid-template-areas:"details" "summary" "leftbottom" "layout"}
  .est-details-panel,.est-summary-panel {min-height:0}
  .est-summary-panel .est-stat strong {font-size:18px}
}
@media(max-width:570px){
  .est-summary-panel .est-summary {grid-template-columns:repeat(3,minmax(0,1fr));row-gap:8px}
  .est-summary-panel .est-stat:nth-child(3) {border:0}
  .est-summary-panel .est-stat strong {font-size:16px}
  .est-modal {padding:14px}
}
@media print {
  .est-workspace {display:block}
  .est-details-panel,.est-summary-panel .est-panel-heading,.est-left-lower,.est-modal-backdrop,.est-context,.est-drag-preview {display:none!important}
  .est-summary-panel {display:block;min-height:0;border:0;padding:0;margin:5px 0 10px}
  .est-summary-panel .est-summary {grid-template-columns:repeat(5,1fr)}
  .est-summary-panel .est-stat {border:1px solid #bbb!important;padding:7px!important}
  .est-right {display:block}
}
/* v105: full-height layout. The page, not the cutting layout, is the vertical scroll container. */
.est-slab-stack {max-height:none;overflow:visible;padding:2px 5px 5px 1px}

/* v104 — compact single-line Details, slab occupancy, and overlay-only errors. */
.est-details-panel,.est-summary-panel {min-height:118px}
.est-details-panel .est-details-line {
  grid-template-columns:minmax(60px,.75fr) minmax(95px,1.85fr) minmax(78px,.85fr);
  gap:8px;
  margin:0;
  align-items:end;
}
.est-details-line label {font-size:10px;white-space:nowrap}
.est-details-line .est-input {height:34px}
.est-slab-row.occupied {background:#e9f7ed;border-color:#b9e4c7}
.est-slab-row.unused {background:#fff0f0;border-color:#efc3c3}
.est-slab-row .est-list-detail strong {font-weight:700;color:#297349}
.est-slab-row.unused .est-list-detail strong {color:#b94e4e}
.est-slab-row .est-list-select {min-width:0}
/* Only validation errors appear, fixed to viewport to avoid pushing diagrams. */
.est-message.error {
  position:fixed;right:18px;bottom:18px;z-index:2050;
  max-width:min(410px,calc(100vw - 36px));margin:0;
  border:1px solid #eeb3b3;border-radius:9px;
  box-shadow:0 9px 28px #172b402a;
  padding:12px 15px;
}
@media(max-width:900px){.est-details-panel,.est-summary-panel{min-height:0}}
@media(max-width:480px){
  .est-details-panel .est-details-line {grid-template-columns:minmax(58px,.7fr) minmax(86px,1.9fr) minmax(70px,.9fr);gap:5px}
  .est-details-line label{font-size:9px}
}
@media print {.est-message{display:none!important}}

/* v107: an independent right-click menu for slab backgrounds and slab-list rows. */
.est-context-detail {font-size:11px;color:var(--est-muted);padding:0 9px 7px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.est-context button.est-context-danger {color:#b13c3c;border-top:1px solid #ecf0f4;border-radius:0}
.est-context button.est-context-danger:hover {background:#fff0f0}

/* v108 setup UI; v109 engine is a separate browser worker. */
.est-default-chip {display:inline-block;vertical-align:1px;margin-left:5px;padding:2px 6px;border:1px solid #b9d9f0;background:#ecf6fc;color:#186199;border-radius:999px;font-size:9px;font-weight:700}
.est-hint {margin:3px 0 10px;font-size:12px;line-height:1.5;color:#718193;font-weight:400}
.est-optimise-modal {width:min(800px,100%)}
.est-optimise-modal .est-modal-header {align-items:flex-start}
.est-optimise-modal .est-modal-header .est-hint {margin:4px 0 0}
.est-opt-section-head {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin:12px 0 9px}
.est-opt-section-head h3 {margin:0;font-size:15px;color:#263d54}
.est-opt-intro {margin-bottom:12px}
.est-opt-table-wrap {border:1px solid #dee6ee;border-radius:9px;overflow:hidden}
.est-opt-table-head,.est-opt-row {display:grid;grid-template-columns:70px 76px minmax(0,1fr) 103px;column-gap:10px;align-items:center}
.est-opt-table-head {background:#f1f5f9;color:#67798d;text-transform:uppercase;letter-spacing:.04em;font-weight:700;font-size:10px;padding:9px 13px;border-bottom:1px solid #dee6ee}
.est-opt-table-head span:nth-child(2) {text-align:center}
.est-opt-table-head span:last-child {text-align:right}
.est-opt-row {min-height:65px;padding:9px 13px;border-bottom:1px solid #e6edf3;background:#fff}
.est-opt-row:last-child {border-bottom:0}
.est-opt-row:nth-child(even) {background:#fbfcfe}
.est-opt-qty-label .est-input {margin:0;height:36px;text-align:center;font-size:14px;font-weight:700;padding:4px}
.est-opt-default-cell {display:flex;justify-content:center;align-items:center}
.est-opt-default-cell input {width:16px;height:16px;accent-color:#1b5f98;cursor:pointer}
.est-opt-default-cell input:disabled {cursor:not-allowed;opacity:.3}
.est-opt-slab-info {min-width:0}
.est-opt-slab-info strong {display:block;word-break:break-word;font-size:13px}
.est-opt-slab-meta {display:flex;align-items:center;gap:5px;color:#76899c;font-weight:400;font-size:11px;margin-top:4px;flex-wrap:wrap}
.est-opt-actions {display:flex;justify-content:flex-end;align-items:center;gap:5px}
.est-opt-actions .est-button {min-height:32px;padding:7px 9px}
.est-opt-delete {border:0;background:transparent;color:#a64848;border-radius:5px;cursor:pointer;font-size:20px;padding:4px 8px}
.est-opt-delete:hover {background:#fff0f0}
.est-opt-empty {padding:20px;text-align:center;color:#718193;font-size:12px}
.est-opt-warning {border-radius:7px;padding:9px 11px;background:#fff1e6;border:1px solid #f0c89d;color:#8a4d17;font-size:12px;margin:10px 0}
.est-opt-goals-head {margin-top:20px}
.est-opt-goals {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px}
.est-app .est-opt-goal {display:flex;align-items:flex-start;gap:8px;border:1px solid #dbe4ed;padding:12px 10px;border-radius:9px;background:#fff;cursor:pointer;white-space:normal;min-height:98px}
.est-opt-goal input {margin:2px 0 0;flex:none;accent-color:#1b5f98}
.est-opt-goal span {display:block;min-width:0}
.est-opt-goal strong {font-size:12px;line-height:1.3;display:block;color:#2a4259}
.est-opt-goal small {display:block;font-weight:400;font-size:11px;line-height:1.45;color:#6b7b8b;margin-top:5px}
.est-app .est-opt-goal.active {border-color:#3781b6;background:#eef7fd;box-shadow:inset 0 0 0 1px #3781b6}
.est-opt-save-note {margin:14px 0 0}
.est-sr-only {position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.est-opt-warning[hidden] {display:none!important}
@media (max-width:620px) {
 .est-opt-goals {grid-template-columns:1fr}
 .est-app .est-opt-goal {min-height:0}
 .est-opt-table-head,.est-opt-row {grid-template-columns:52px 54px minmax(0,1fr) 72px;gap:5px;padding:8px 6px}
 .est-opt-slab-info strong {font-size:11px}
 .est-opt-actions .est-button {padding:7px 5px}
 .est-opt-delete {padding:3px 5px}
 .est-opt-qty-label .est-input {font-size:12px}
 .est-opt-table-head {font-size:9px}
}
@media print {.est-modal-backdrop {display:none!important}}

/* v109: modal progress overlay, independent of main editor. */
.est-app .est-optimising-backdrop {z-index:3000;background:rgba(13,33,54,.7)}
.est-app .est-optimising-backdrop[hidden] {display:none!important}
.est-optimising-card {width:min(420px,100%);background:white;border-radius:14px;padding:32px 24px;text-align:center;box-shadow:0 18px 60px #0007}
.est-optimising-card h2 {font-size:19px;margin:15px 0 9px;color:#1f3851}
.est-optimising-card p {font-size:13px;font-weight:700;margin:0 0 9px;color:#35607b}
.est-optimising-card small {color:#778b9a;line-height:1.5;font-size:11px}
.est-optimising-spinner {width:42px;height:42px;border:4px solid #e3edf6;border-top-color:#1b5f98;border-radius:50%;animation:est-spin .85s linear infinite;margin:auto}
@keyframes est-spin {to {transform:rotate(360deg)}}
.est-copy-chip {display:inline-block;margin-left:5px;font-size:9px;padding:2px 5px;border:1px solid #d7bfe5;background:#f7edf9;border-radius:6px;color:#70448b}
@media print {.est-optimising-backdrop {display:none!important}}

/* v110: printed sheet contains estimate metadata and layouts, not app chrome. */
@media print {
  .est-title-row {display:none!important}
  .est-heading {min-height:0}
  .est-print-meta {margin:0 0 7px!important}
}

/* v111: compact, printable A4 cutting sheets and slab-header kerf label. */
.est-slab-card-head .est-util-bar {min-width:170px;width:auto;max-width:none}
.est-slab-card-head .est-util-bar span {white-space:nowrap}
@media print {
  /* Compact real print margins on EVERY sheet. Empty page margin boxes
     prevent Chromium from adding its own URL / date / page footers. */
  @page {
    size:A4 portrait;
    margin:6mm 7mm;
    @top-left {content:""}
    @top-right {content:""}
    @bottom-left {content:""}
    @bottom-right {content:""}
  }
  html,body {margin:0!important;min-height:0!important;height:auto!important}
  body {background:#fff!important;padding:0!important}
  body .app-shell {display:block!important;min-height:0!important;width:100%!important}
  body .sidebar,body .page-header {display:none!important}
  body .main-content {display:block!important;width:100%!important;max-width:none!important;margin:0!important;padding:0!important}
  .est-app {max-width:none!important;width:100%!important;font-size:10px!important}
  .est-header {margin:0 0 1mm!important}
  .est-print-meta {font-size:11px!important;margin:0 0 1mm!important;line-height:1.1!important}
  .est-summary-panel {margin:0 0 2mm!important;padding:0!important;min-height:0!important}
  .est-summary-panel .est-summary {gap:0!important}
  .est-summary-panel .est-stat {padding:3px 6px!important}
  .est-summary-panel .est-stat span {font-size:9px!important;line-height:1.1!important;margin:0 0 1px!important}
  .est-summary-panel .est-stat strong {font-size:12px!important;line-height:1.1!important}
  .est-layout-heading {margin:0 0 1.6mm!important}
  .est-layout-heading h2 {font-size:12px!important}
  .est-slab-stack {gap:2mm!important;padding:0!important}
  .est-slab-card {padding:1.6mm!important;margin:0!important;border:1px solid #aab3bc!important;border-radius:1.5mm!important;break-inside:avoid!important;page-break-inside:avoid!important}
  .est-slab-card-head {margin:0 0 1mm!important;gap:1mm!important;flex-wrap:nowrap!important;align-items:start!important}
  .est-slab-card-head h3 {font-size:11px!important;line-height:1.15!important}
  .est-slab-card-head p {font-size:9px!important;line-height:1.2!important;margin:1px 0 0!important}
  .est-slab-card-head .est-util-bar {width:auto!important;min-width:0!important;max-width:none!important}
  .est-slab-card-head .est-util-bar span {font-size:9px!important;line-height:1.15!important;white-space:nowrap!important}
  .est-util-bar>div {display:none!important}
  .est-diagram-wrap {padding:0!important;margin:0!important;border:0!important;border-radius:0!important;overflow:visible!important;background:#fff!important}
  .est-slab-svg {max-height:none!important;min-height:0!important;height:auto!important}
}

/* v112: explicit rotation permission in the list. Distinct from placement lock. */
.est-list-row .est-piece-title {display:flex;align-items:center;gap:7px;max-width:100%;white-space:nowrap}
.est-piece-title-name {flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.est-rotation-chip {display:inline-flex;align-items:center;flex:none;white-space:nowrap;
  font-size:9px;font-weight:700;line-height:1.15;padding:3px 5px;border:1px solid #d5e1eb;
  background:#f0f5f9;color:#4c677e;border-radius:5px}
.est-rotation-chip.fixed {border-color:#eacb95;background:#fff3dd;color:#865b1c}
/* Selection stays visible in the editor, but must never be printed. */
@media print {
  .est-app .est-piece-group.selected .est-piece-rect {
    stroke:#286b88!important;
    stroke-width:3!important;
    stroke-dasharray:none!important;
  }
  .est-app .est-piece-group.locked .est-piece-rect {
    stroke:#5f6872!important;
    stroke-dasharray:none!important;
  }
}

/* v113 — Compact right-side overview and independent cutting-layout scroll. */
@media screen {
  /* Details keeps its original height; Overview is intentionally a shorter strip. */
  .est-summary-panel {
    min-height:0;
    align-self:start;
    display:flex;
    flex-direction:row;
    align-items:center;
    justify-content:flex-start;
    gap:14px;
    padding:10px 14px;
  }
  .est-summary-panel .est-panel-heading {margin:0;flex:0 0 auto;white-space:nowrap}
  .est-summary-panel .est-panel-heading h2 {font-size:14px}
  .est-summary-panel .est-summary {
    display:flex;
    flex:1 1 auto;
    min-width:0;
    flex-wrap:nowrap;
    align-items:center;
    justify-content:space-between;
    gap:0;
    margin:0;
  }
  .est-summary-panel .est-stat {
    display:inline-flex;
    align-items:baseline;
    justify-content:center;
    flex:1 1 auto;
    min-width:0;
    white-space:nowrap;
    gap:5px;
    padding:0 9px;
  }
  .est-summary-panel .est-stat span {display:inline;font-size:10px;margin:0}
  .est-summary-panel .est-stat strong {font-size:13px;line-height:1.25}
  .est-right {min-height:0}
  .est-layout-panel {
    height:clamp(420px, calc(100vh - 280px), 980px);
    height:clamp(420px, calc(100dvh - 280px), 980px);
    min-height:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
  }
  .est-layout-heading {flex:0 0 auto}
  .est-slab-stack {
    flex:1 1 auto;
    min-height:0;
    max-height:none;
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior-y:contain;
    scrollbar-gutter:stable;
    padding:2px 7px 5px 1px;
  }
  .est-slab-title-line {display:flex;flex:1 1 auto;align-items:center;gap:14px;min-width:0;flex-wrap:nowrap}
  .est-slab-title-line h3 {flex:0 0 auto;white-space:nowrap}
  .est-slab-title-line p {flex:1 1 auto;margin:0;white-space:nowrap}
  .est-slab-card-head {align-items:center;flex-wrap:nowrap}
  .est-slab-card-head .est-util-bar {flex:0 0 auto}
  /* Where the right-hand panel narrows, preserve readable labels instead of clipping. */
  @media (max-width:1400px) {
    .est-summary-panel {gap:8px;flex-wrap:wrap}
    .est-summary-panel .est-summary {flex-wrap:wrap;justify-content:flex-start;row-gap:7px}
    .est-summary-panel .est-stat {flex:0 0 auto;padding:0 9px}
    .est-summary-panel .est-stat:first-child {padding-left:0}
    .est-slab-card-head {flex-wrap:wrap}
    .est-slab-title-line {flex-wrap:wrap;gap:4px 10px}
  }
  @media (max-width:900px) {
    .est-summary-panel {gap:8px}
    .est-layout-panel {height:clamp(400px, calc(100dvh - 220px), 880px)}
  }
}
@media print {
  /* Printing must always include every slab, not just the visible scroll area. */
  .est-layout-panel {height:auto!important;max-height:none!important;overflow:visible!important;display:block!important}
  .est-slab-stack {height:auto!important;max-height:none!important;overflow:visible!important;display:block!important}
  .est-slab-title-line {display:flex;align-items:baseline;gap:5px;flex-wrap:nowrap}
  .est-slab-title-line p {margin:0}
}

/* v114 — two independent, top-aligned work zones.
   The right overview no longer shares a grid row with the taller Details card:
   Cutting layout begins directly beneath its own compact overview. */
@media screen {
  .est-app {
    width:100%;
    max-width:none;
    margin:0;
    text-align:left;
  }
  .est-workspace {
    display:grid;
    grid-template-columns:minmax(340px,390px) minmax(0,1fr);
    grid-template-areas:none;
    align-items:start;
    justify-items:stretch;
    justify-content:start;
    column-gap:12px;
    row-gap:12px;
  }
  .est-left-column, .est-right-column {min-width:0;align-self:start}
  .est-left-column {
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:12px;
    padding:10px;
    background:#eaf0f6;
    border:1px solid #d7e1ea;
    border-radius:12px;
  }
  .est-left-column .est-details-panel,
  .est-left-column .est-left-lower,
  .est-right-column .est-summary-panel,
  .est-right-column .est-right {grid-area:auto;width:100%}
  .est-left-column .est-left-lower {display:flex;flex-direction:column;gap:12px;margin:0}
  .est-left-column .est-panel {background:#fafdff;border-color:#d9e3eb}
  .est-right-column {
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:10px;
    padding:0 0 0 13px;
    border-left:3px solid #a2c2da;
    background:#fff;
  }
  .est-right-column .est-summary-panel,
  .est-right-column .est-layout-panel {border-color:#c4d9e8}
  .est-right-column .est-summary-panel {margin:0}
  .est-right-column .est-summary-panel .est-summary {justify-content:flex-start}
  .est-right-column .est-summary-panel .est-stat {justify-content:flex-start;text-align:left}
  .est-right-column .est-summary-panel .est-stat:first-child {padding-left:9px}
  .est-right-column .est-right {align-self:stretch}
  .est-right-column .est-layout-panel {width:100%}
  .est-slab-card-head {justify-content:flex-start}
  .est-slab-card-head .est-util-bar {margin-left:auto}
  @media (max-width:1150px) {
    .est-workspace {grid-template-columns:minmax(290px,340px) minmax(0,1fr)}
    .est-right-column .est-summary-panel .est-stat:first-child {padding-left:0}
  }
  @media (max-width:900px) {
    .est-workspace {grid-template-columns:minmax(0,1fr)}
    .est-left-column {width:100%;max-width:none}
    .est-left-column .est-left-lower {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
    .est-right-column {width:100%;padding:0;border-left:0;border-top:3px solid #a2c2da;padding-top:12px}
  }
  @media (max-width:570px) {
    .est-left-column .est-left-lower {display:flex;flex-direction:column}
  }
}
/* Printed cutting sheets keep the original print layout with all slabs visible. */
@media print {
  .est-workspace {display:block!important}
  .est-left-column {display:none!important}
  .est-right-column {display:block!important;border:0!important;padding:0!important;background:none!important}
}


/* v115 — Viewport-fitted cutting workspace without a double outer frame.
   The JS sizing helper calculates the visible distance from the cutting panel's
   actual top edge to the bottom of the viewport. When JavaScript is unavailable,
   the dvh fallback still scales with 1080p / 1440p / larger displays. */
@media screen {
  .est-right-column {
    border:0;
    padding:0;
    background:transparent;
  }
  .est-right-column .est-layout-panel {
    height:var(--est-layout-height, clamp(420px, calc(100dvh - 170px), 1800px));
    min-height:0;
    border:0;
    border-radius:0;
    box-shadow:none;
    padding:15px 0 0;
    background:transparent;
  }
  /* At narrow widths the two workspace zones stack without a blue rule. */
  @media (max-width:900px) {
    .est-right-column {border:0;padding:0}
  }
}

/* v116 — Database-backed estimates, compact Details controls and modal browser. */
.est-details-actions {display:flex;align-items:center;gap:5px;flex-wrap:nowrap}
.est-details-actions .est-button {min-height:29px;padding:6px 9px}
.est-db-info {min-height:18px;margin:-3px 0 5px;font-size:11px;font-weight:700;color:#187146;white-space:normal}
.est-db-info.error {color:#a52b2b}
.est-saved-modal {width:min(640px,100%)}
.est-saved-count {font-size:11px;color:var(--est-muted);margin:4px 0 7px}
.est-saved-list {border:1px solid #dce5ed;border-radius:8px;min-height:150px;max-height:min(48vh,440px);overflow-y:auto;background:#fafcfe}
.est-saved-row {display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;width:100%;text-align:left;
  padding:11px 12px;border:0;border-bottom:1px solid #e5eaf0;background:#fff;cursor:pointer;color:var(--est-ink)}
.est-saved-row:last-child {border-bottom:0}
.est-saved-row:hover {background:#f0f7fd}
.est-saved-row.selected {background:#e6f2fc;box-shadow:inset 3px 0 #1b5f98}
.est-saved-row strong {display:block;font-size:13px}
.est-saved-row small {display:block;margin-top:3px;color:#64768a;font-size:11px;white-space:normal}
.est-saved-row time {font-size:11px;color:#6e8195;white-space:nowrap}
.est-saved-empty {padding:18px;color:#64768a;font-size:12px;text-align:center}
.est-saved-error {padding:9px;margin-top:8px;border-radius:6px;background:#fff0f0;color:#a52b2b;font-size:12px}
.est-saved-error[hidden] {display:none!important}
.est-saved-actions {align-items:center}
.est-actions-spacer {flex:1}
.est-confirm-message {font-size:13px;line-height:1.5;margin:5px 0}
@media(max-width:480px){.est-details-actions{gap:3px}.est-details-actions .est-button{padding:5px 6px;font-size:11px}.est-saved-row time{display:none}}
@media print {.est-db-info,.est-saved-modal,.est-confirm-dialog{display:none!important}}
