/* Bestillinger og armering: oversikt først, med skiftplanmenyen som visuell fasit. */
:is(#ordersView,#rebarView) .upload-btn.camera > span{display:inline-flex;align-items:center;gap:8px}
:is(#ordersView,#rebarView) .upload-btn.camera svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
@media(min-width:768px){:is(#ordersView,#rebarView) .upload-btn.camera{display:none}}
.delivery-edit-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 22px;border-bottom:1px solid #dbe3e9;background:#f6f9fa}
.delivery-edit-toolbar p{margin:0;color:#536b79;font:14px/1.5 var(--bs-font-family)}
.delivery-edit-toolbar button{flex-shrink:0;min-height:44px;font:600 15px var(--bs-font-family)}
.module-detail-dialog .delivery-read-value{display:block;min-height:24px;padding:6px 0;color:#182f3d;font:500 16px/1.5 var(--bs-font-family);white-space:pre-wrap;overflow-wrap:anywhere;letter-spacing:normal;text-transform:none}
.module-detail-dialog .delivery-read-value.is-empty{color:#6b7d87;font-weight:400}
.module-detail-dialog [hidden]{display:none!important}
.delivery-read-mode .unit-input{display:flex;align-items:baseline;border:0;background:transparent;padding:0;justify-content:flex-start;gap:6px}
#rebarDetail.delivery-read-mode .unit-input > span{position:static;transform:none;inset:auto}
.delivery-read-mode .rebar-issue-text[readonly]{border-color:transparent;background:transparent}
@media(max-width:760px){
  #ordersView #orderList{height:auto;max-height:none;overflow:visible}
  #ordersView .order-register-card{overflow:visible}
  .delivery-edit-toolbar{padding:12px 16px;flex-wrap:wrap;gap:8px}
  .delivery-edit-toolbar p{flex:1 1 170px}
}

#ordersView .view-heading,
#rebarView .view-heading {
  align-items: flex-end;
  margin-bottom: 18px;
}

#ordersView .primary-order-btn,
#rebarView .primary-order-btn {
  min-height: 46px;
  padding: 0 19px;
  border-radius: 7px;
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-15);
  font-weight: 500;
}

.module-register-layout {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.module-filter-menu {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 18px;
  width: 100%;
  padding: 12px;
  border: 1px solid #dbe3e9;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(18, 38, 56, .04);
}

.module-filter-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.module-filter-group-separated {
  padding-top: 15px;
  border-top: 1px solid #dbe3e9;
}

.module-filter-title {
  margin: 0;
  padding: 0 10px;
  color: #657582;
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-12-5);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.module-filter-items {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.module-filter-items > button,
.module-filter-parent > button:first-child {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  width: 100%;
  margin: 0;
  padding: 8px 12px 8px 9px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #304352;
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-15);
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.module-filter-items > button:hover,
.module-filter-parent > button:first-child:hover,
.module-filter-children > button:hover {
  background: #f3f7f6;
  color: #18394d;
}

.module-filter-items > button:hover,
.module-filter-parent > button:first-child:hover {
  border-left-color: #c1d9cf;
}

.module-filter-items > button.active,
.module-filter-parent > button:first-child.active {
  border-left-color: #2d8f68;
  background: #eaf5f0;
  color: #173d4e;
  font-weight: 700;
}

.module-filter-items > button:focus-visible,
.module-filter-parent > button:focus-visible,
.module-filter-children > button:focus-visible {
  outline: 3px solid rgba(42, 143, 102, .28);
  outline-offset: 2px;
}

.module-filter-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: #667986;
}

.module-filter-icon svg,
.module-filter-toggle svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.module-filter-items > button.active .module-filter-icon,
.module-filter-parent > button:first-child.active .module-filter-icon {
  color: #287d5e;
}

.module-filter-items small,
.module-filter-children small {
  justify-self: end;
  color: #657582;
  font: inherit;
  font-weight: 600;
}

.module-filter-items > button.active small,
.module-filter-parent > button:first-child.active small {
  color: #173d4e;
  font-weight: 700;
}

.module-filter-fact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  margin-top: 5px;
  padding: 8px 12px;
  border-top: 1px solid #dbe3e9;
  color: #526772;
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-14);
}

.module-filter-fact strong {
  color: #304352;
  font-size: inherit;
}

.module-filter-parent {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
}

.module-filter-parent > button:first-child {
  grid-template-columns: 22px minmax(0, 1fr) auto;
}

.module-filter-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #667986;
  cursor: pointer;
}

.module-filter-toggle:hover {
  background: #f0f4f5;
}

.module-filter-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.module-filter-children {
  position: relative;
  display: grid;
  gap: 3px;
  margin-left: 30px;
  padding-left: 13px;
}

.module-filter-children[hidden] {
  display: none;
}

.module-filter-children::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 1px;
  background: #dbe3e9;
}

.module-filter-children > button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  width: 100%;
  padding: 8px 8px 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #304352;
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-15);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.module-filter-children > button.active {
  background: #eaf5f0;
  color: #173d4e;
  font-weight: 700;
}

.module-register-card,
.rebar-overview {
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
}

.module-register-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 18px 18px 13px;
}

.module-register-toolbar p {
  margin: 0;
  color: #657582;
  font-size: var(--bs-text-14);
}

.module-register-search input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 44px;
  border: 1px solid #cbd6da;
  border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23526772' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") no-repeat 15px center;
  color: var(--ink);
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-15);
}

.module-register-search input:focus,
.rebar-building-control select:focus {
  outline: 3px solid rgba(42, 143, 102, .2);
  border-color: #6ca88e;
}

.order-list-head,
.order-register-list .order-item {
  display: grid;
  grid-template-columns: minmax(250px, 2.2fr) minmax(150px, 1.15fr) minmax(145px, .9fr) minmax(115px, .65fr) 24px;
  align-items: center;
  gap: 14px;
}

.order-list-head {
  min-height: 43px;
  padding: 0 18px;
  border-top: 1px solid #dbe3e9;
  border-bottom: 1px solid #dbe3e9;
  background: #f4f7f8;
  color: #536772;
  font-size: var(--bs-text-13);
  font-weight: 700;
}

.order-register-list .order-item {
  min-height: 84px;
  padding: 13px 18px;
  border: 0;
  border-bottom: 1px solid #e1e8ea;
  border-left: 3px solid transparent;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.order-register-list .order-item:last-child {
  border-bottom: 0;
}

.order-register-list .order-item:hover {
  border-left-color: #c1d9cf;
  background: #f7faf9;
}

.order-register-list .order-cell-main,
.order-register-list .order-cell-date {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.order-register-list .order-cell-main strong {
  overflow: hidden;
  color: #182f3d;
  font-size: var(--bs-text-15);
  font-weight: 600;
  text-overflow: ellipsis;
}

.order-register-list .order-cell-main small,
.order-register-list .order-cell-date small {
  color: #687b85;
  font-size: var(--bs-text-13);
}

.order-register-list .order-cell-supplier,
.order-register-list .order-cell-date {
  color: #304352;
  font-size: var(--bs-text-14);
}

.order-register-list .late-label {
  color: #a96900;
  font-size: var(--bs-text-13);
  font-weight: 600;
}

.module-row-chevron {
  justify-self: end;
  color: #48616e;
  font-size: var(--bs-text-20);
  line-height: 1;
}

.order-status {
  justify-self: start;
  min-height: 30px;
  padding: 6px 11px;
  align-items: center;
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-14);
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.rebar-register-toolbar {
  grid-template-columns: minmax(280px, 1fr) 190px;
  align-items: end;
}

.rebar-register-toolbar > p {
  grid-column: 1 / -1;
}

.rebar-building-control {
  display: grid;
  gap: 6px;
}

.rebar-building-control > span {
  color: #405762;
  font-size: var(--bs-text-13);
  font-weight: 700;
}

.rebar-building-control select {
  width: 100%;
  height: 46px;
  padding: 0 11px;
  border: 1px solid #cbd6da;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: var(--bs-text-14);
}

.rebar-register-table {
  width: 100%;
  min-width: 1040px;
  table-layout: fixed;
  border-collapse: collapse;
}

.rebar-register-table th:nth-child(1) { width: 25%; }
.rebar-register-table th:nth-child(2) { width: 14%; }
.rebar-register-table th:nth-child(3) { width: 16%; }
.rebar-register-table th:nth-child(4) { width: 18%; }
.rebar-register-table th:nth-child(5) { width: 10%; }
.rebar-register-table th:nth-child(6) { width: 14%; }
.rebar-register-table th:nth-child(7) { width: 3%; }


.rebar-register-table th {
  padding: 12px 13px;
  border-bottom: 1px solid #dbe3e9;
  background: #f4f7f8;
  color: #536772;
  font-size: var(--bs-text-13);
  font-weight: 700;
  text-align: left;
}

.rebar-register-table td {
  height: 82px;
  padding: 12px 13px;
  border-bottom: 1px solid #e1e8ea;
  color: #304352;
  font-size: var(--bs-text-14);
  vertical-align: middle;
}

.rebar-register-table tbody tr {
  cursor: pointer;
}

.rebar-register-table tbody tr:hover td {
  background: #f7faf9;
}

.rebar-register-table td strong,
.rebar-register-table td small {
  display: block;
}

.rebar-register-table td strong {
  color: #182f3d;
  font-size: var(--bs-text-14);
  font-weight: 600;
}

.rebar-register-table td small {
  margin-top: 5px;
  color: #687b85;
  font-size: var(--bs-text-13);
}

.rebar-register-table .rebar-number {
  text-align: right;
  white-space: nowrap;
}

.rebar-register-table th:nth-child(5),
.rebar-register-table td:nth-child(5) {
  text-align: center;
}

.rebar-status-cell .order-status {
  display: inline-flex;
}

.rebar-status-cell small {
  white-space: nowrap;
}

.rebar-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 18px 16px;
  border: 1px solid #dbe3e9;
  border-radius: 9px;
  background: #fbfcfc;
}

.rebar-summary-strip > span {
  display: grid;
  gap: 3px;
  padding: 12px 18px;
  border-right: 1px solid #dbe3e9;
}

.rebar-summary-strip > span:last-child {
  border-right: 0;
}

.rebar-summary-strip small {
  color: #657582;
  font-size: var(--bs-text-12);
}

.rebar-summary-strip strong,
.rebar-summary-strip b {
  color: #182f3d;
  font-size: var(--bs-text-17);
  font-weight: 700;
}

.module-detail-dialog {
  width: min(1120px, calc(100vw - 40px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(8, 25, 34, .34);
  overflow: auto;
}

.module-detail-dialog::backdrop {
  background: rgba(12, 31, 42, .55);
  backdrop-filter: blur(2px);
}

.module-detail-dialog[open] {
  animation: module-detail-enter .16s ease-out;
}

.module-detail-dialog > .order-detail,
.module-detail-dialog > .rebar-detail {
  width: 100%;
  margin: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: none;
}

.module-detail-dialog .order-detail-head,
.module-detail-dialog .rebar-detail-head {
  position: sticky;
  top: 0;
  z-index: 3;
}

.module-detail-heading {
  display: grid;
  justify-items: start;
}

.module-dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 82px;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid #c7d3d8;
  border-radius: 8px;
  background: #fff;
  color: #304352;
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-14);
  font-weight: 600;
  cursor: pointer;
}

.module-dialog-close > span:first-child {
  font-size: var(--bs-text-20);
  font-weight: 400;
  line-height: 1;
}

.module-dialog-close:hover {
  border-color: #8fa6b0;
  background: #f3f7f8;
}

.module-detail-dialog .status-control {
  width: min(100%, 300px);
}

.module-detail-dialog .status-control > span {
  color: #263f4d;
  font-size: var(--bs-text-14);
  font-weight: 800;
}

.module-detail-dialog .status-control select {
  width: 100%;
  height: 48px;
  border: 2px solid #9eb2bb;
  border-radius: 8px;
  background-color: #f8fafb;
  color: #152f3e;
  font-family: var(--bs-font-family);
  font-size: var(--bs-text-16);
  font-weight: 750;
}

@keyframes module-detail-enter {
  from { opacity: 0; transform: translateY(8px) scale(.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .module-detail-dialog[open] { animation: none; }
}

@media (max-width: 1050px) {
  .module-register-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .module-filter-menu {
    position: static;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    overflow-x: auto;
  }

  .module-filter-group {
    flex: 0 0 205px;
  }

  .module-filter-group-separated {
    padding: 0 0 0 12px;
    border-top: 0;
    border-left: 1px solid #dbe3e9;
  }
}

@media (max-width: 760px) {
  #ordersView .view-heading,
  #rebarView .view-heading {
    align-items: stretch;
  }

  .rebar-heading-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .order-list-head {
    display: none;
  }

  .order-register-list .order-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 15px;
  }

  .order-register-list .order-cell-main {
    grid-column: 1;
  }

  .order-register-list .order-cell-supplier,
  .order-register-list .order-cell-date {
    grid-column: 1;
  }

  .order-register-list .order-status-cell {
    grid-column: 2;
    grid-row: 1;
  }

  .order-register-list .module-row-chevron {
    grid-column: 2;
    grid-row: 2 / 4;
    align-self: center;
  }

  .rebar-register-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .rebar-register-toolbar > p {
    grid-column: auto;
  }

  .rebar-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-detail-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 10px;
  }

  .module-detail-dialog .order-detail-head,
  .module-detail-dialog .rebar-detail-head {
    flex-direction: row;
    align-items: flex-start;
  }

  .module-detail-dialog .rebar-detail-actions {
    width: auto;
    flex-direction: row;
    align-items: center;
  }

  .module-dialog-close {
    min-width: 42px;
    width: 42px;
    padding: 0;
  }

  .module-dialog-close > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .rebar-summary-strip > span:nth-child(2) {
    border-right: 0;
  }

  .rebar-summary-strip > span:nth-child(-n + 2) {
    border-bottom: 1px solid #dbe3e9;
  }
}

@media (max-width: 520px) {
  .module-filter-menu {
    display: grid;
    overflow: visible;
  }

  .module-filter-group {
    width: 100%;
  }

  .module-filter-group-separated {
    padding: 15px 0 0;
    border-top: 1px solid #dbe3e9;
    border-left: 0;
  }

  .module-register-toolbar {
    padding: 14px;
  }

  .rebar-summary-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .rebar-summary-strip > span {
    border-right: 0;
    border-bottom: 1px solid #dbe3e9;
  }

  .rebar-summary-strip > span:last-child {
    border-bottom: 0;
  }
}

/* Key information for the current reinforcement delivery selection. */
:is(#rebarView,#pourView) .rebar-key-cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;padding:0 18px 20px}
:is(#rebarView,#pourView) .rebar-key-card{display:flex;align-items:center;gap:14px;background:linear-gradient(135deg,#f8fafb,#f1f5f8);border:1px solid #dce5eb;border-radius:12px;padding:18px 20px;min-width:0;box-shadow:0 2px 4px #152e3e03}
:is(#rebarView,#pourView) .rebar-key-card small{display:block;font-size:14px;color:#607688;line-height:1.45;margin-bottom:5px}:is(#rebarView,#pourView) .rebar-key-card strong{display:block;font-size:23px;color:#162e3d;line-height:1.2;font-weight:650}:is(#rebarView,#pourView) .rebar-key-card b{font-weight:inherit}
:is(#rebarView,#pourView) .rebar-key-icon{display:grid;place-items:center;flex:0 0 42px;height:42px;border-radius:10px;background:#e4edf3;color:#34576b;font-size:23px;font-weight:500}:is(#rebarView,#pourView) .rebar-key-icon.weight{background:#e5f1eb;color:#35745c}:is(#rebarView,#pourView) .rebar-key-icon.issues{background:#f9efe0;color:#946828;font-size:22px}
#rebarView .rebar-status-cell{white-space:normal}
@media(max-width:800px){:is(#rebarView,#pourView) .rebar-key-cards{gap:8px;padding:0 12px 14px}:is(#rebarView,#pourView) .rebar-key-card{padding:14px 10px;gap:10px}:is(#rebarView,#pourView) .rebar-key-icon{flex-basis:32px;height:32px;font-size:20px}:is(#rebarView,#pourView) .rebar-key-card strong{font-size:19px}:is(#rebarView,#pourView) .rebar-key-card small{font-size:12px}}
@media(max-width:520px){:is(#rebarView,#pourView) .rebar-key-cards{grid-template-columns:1fr}:is(#rebarView,#pourView) .rebar-key-card{padding:12px 16px}:is(#rebarView,#pourView) .rebar-key-card strong{font-size:21px}}

.rebar-register-table th,.rebar-register-table td{padding-inline:18px}.rebar-register-table th:last-child,.rebar-register-table td:last-child{padding-inline:4px}


/* Match the pour dialog's bottom action placement. */
.delivery-dialog-footer{display:flex;align-items:center;gap:16px;flex-wrap:wrap;border-top:1px solid #dbe3e9;padding:18px 0 0;margin-top:24px;background:#fff;font-family:var(--bs-font-family)}
.delivery-dialog-footer>span{color:#607688;font-size:14px}
.delivery-finish-actions{display:flex;align-items:center;justify-content:flex-end;gap:12px;margin-left:auto}
.delivery-finish-actions[hidden]{display:none!important}
.delivery-finish-actions button{min-height:44px;font-family:var(--bs-font-family);font-size:14px}
@media(max-width:520px){.delivery-finish-actions{width:100%}}

.module-detail-dialog [hidden]{display:none!important}
.delivery-dialog-footer>.primary-order-btn{margin-left:auto}
.delivery-pending-files{font:14px/1.5 var(--bs-font-family);color:#607688}
.module-detail-dialog .delivery-dialog-footer{flex-direction:row;justify-content:space-between;text-align:left}
.module-detail-dialog .delivery-dialog-footer>.danger-text{margin:0;padding:10px 0;min-height:44px;font:500 14px/1.5 var(--bs-font-family);text-align:left}
.delivery-dialog-footer>span:empty{display:none}

/* Shared readability and empty-register standard. Screen-only, preserving print layouts. */
@media screen {
  :is(#orderDetail,#rebarDetail) .module-detail-heading h2 { font:600 24px/1.3 var(--bs-font-family); margin:4px 0 6px; }
  :is(#orderDetail,#rebarDetail) .module-detail-heading p,
  :is(#orderDetail,#rebarDetail) .order-number { font-size:14px; line-height:1.5; }
  :is(#orderDetail,#rebarDetail) .delivery-edit-toolbar p { font-size:16px; line-height:1.5; }
  :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid) { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px 28px; padding:20px 24px; }
  :is(#orderDetail,#rebarDetail) .delivery-form-heading { grid-column:1/-1; margin:8px 0 0; padding-top:20px; border-top:1px solid #d8e2e7; color:#203b49; font:600 18px/1.4 var(--bs-font-family); }
  :is(#orderDetail,#rebarDetail) .delivery-form-heading:first-child { margin:0; padding:0; border:0; }
  :is(#orderDetail,#rebarDetail) :is(.wide,.span-two,.status-control) { grid-column:1/-1; }
  :is(#orderDetail,#rebarDetail) .status-control { max-width:280px; }
  :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label { min-width:0; gap:6px; font-family:var(--bs-font-family); }
  :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label>span:not(.delivery-read-value) { color:#556b78; font:600 14px/1.5 var(--bs-font-family); }
  :is(#orderDetail,#rebarDetail) :is(input:not([type=file]),select,textarea,.delivery-read-value) { font-family:var(--bs-font-family); font-size:16px; line-height:1.5; }
  :is(#orderDetail,#rebarDetail) .delivery-read-value.is-empty { color:#556b78; }
  :is(#orderDetail,#rebarDetail) .unit-input>span { color:#556b78; font:400 16px/1.5 var(--bs-font-family); }
  :is(#orderDetail,#rebarDetail) :is(.attachments-section,.rebar-files,.rebar-issues) { padding:20px 24px; }
  :is(#orderDetail,#rebarDetail) .section-head h3 { font:600 18px/1.4 var(--bs-font-family); }
  :is(#orderDetail,#rebarDetail) :is(.section-head p,.drop-zone strong,.drop-zone>span,.empty-attachments) { color:#556b78; font:400 16px/1.5 var(--bs-font-family); }
  :is(#orderDetail,#rebarDetail) .drop-zone { padding:18px; border-radius:7px; background:#f5f8fa; }
  :is(#orderDetail,#rebarDetail) .drop-zone strong { color:#203b49; font-weight:600; }
  :is(#orderDetail,#rebarDetail) :is(.upload-btn,.upload-btn>span,.count,.module-dialog-close) { font-family:var(--bs-font-family); font-size:14px; line-height:1.5; }
  :is(#orderDetail,#rebarDetail) .upload-btn { min-height:44px; }
  #rebarDetail .rebar-detail-columns { grid-template-columns:minmax(0,1fr); }
  #rebarDetail .rebar-files { border-left:0; border-top:1px solid #d8e2e7; }
  :is(#orderDetail,#rebarDetail) .empty-attachments { margin:12px 0 0; padding:16px 18px; border:1px solid #d8e2e7; border-radius:7px; background:#f5f8fa; }
  .module-empty-state { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; min-height:210px; padding:32px 24px; text-align:center; background:#fff; color:#203b49; font-family:var(--bs-font-family); }
  .module-empty-state>svg { width:26px; height:26px; fill:none; stroke:#556b78; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
  .module-empty-state h3 { margin:0; font:600 18px/1.4 var(--bs-font-family); }
  .module-empty-state p { max-width:440px; margin:0; color:#556b78; font:400 16px/1.5 var(--bs-font-family); }
  .module-empty-state .module-empty-action { min-height:44px; margin-top:8px; padding:10px 16px; font:600 14px/1.5 var(--bs-font-family); }
  .module-empty-state [hidden] { display:none!important; }
}
@media screen and (max-width:600px) {
  :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid) { grid-template-columns:minmax(0,1fr); padding:18px 16px; gap:18px; }
  :is(#orderDetail,#rebarDetail) :is(.attachments-section,.rebar-files,.rebar-issues) { padding:18px 16px; }
  :is(#orderDetail,#rebarDetail) .section-head { flex-wrap:wrap; gap:10px; }
  .module-empty-state { padding:26px 16px; }
}

/* Order summaries follow the reinforcement register's compact key cards. */
#ordersView .order-key-cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;padding:0 18px 20px}
#ordersView .order-key-card{display:flex;align-items:center;gap:14px;min-width:0;padding:18px 20px;border:1px solid #dce5eb;border-radius:12px;background:linear-gradient(135deg,#f8fafb,#f1f5f8);color:#162e3d;text-align:left;font-family:var(--bs-font-family);cursor:pointer}
#ordersView .order-key-label{display:block;font-size:14px;line-height:1.45;color:#607688;margin-bottom:5px}
#ordersView .order-key-card strong{display:block;font-size:23px;line-height:1.2;font-weight:650;font-variant-numeric:tabular-nums}
#ordersView .order-key-icon{display:grid;place-items:center;flex:0 0 42px;height:42px;border-radius:10px;background:#e4edf3;color:#34576b}
#ordersView .order-key-icon svg,#rebarView .rebar-key-icon svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
#ordersView [data-order-summary="Forsinket"] .order-key-icon{background:#fcece9;color:#bd352f}
#ordersView [data-order-summary="Forsinket"] strong{color:#bd352f}
#ordersView .order-key-card:hover{border-color:#93a8b7}
#ordersView .order-key-card[aria-pressed="true"]{border-color:#d33e36;box-shadow:inset 0 -3px #d33e36}
@media(max-width:800px){#ordersView .order-key-cards{gap:8px;padding:0 12px 14px}#ordersView .order-key-card{padding:14px 10px;gap:10px}#ordersView .order-key-icon{flex-basis:32px;height:32px}}
@media(max-width:620px){#ordersView .order-key-cards{grid-template-columns:1fr}#ordersView .order-key-card{padding:12px 16px}}

/* Compact delivery workspace: all sections stay open. Extra content remains scrollable. */
@media screen and (min-width:1001px){
 /* Same width as the diary editor: page (1480px, 60px padding), sidebar (248px), gap (18px). */
 :is(#orderDetailDialog,#rebarDetailDialog){width:calc(min(1480px,100vw) - 326px);max-width:1154px;max-height:calc(100dvh - 24px);padding:0}
 :is(#orderDetailDialog,#rebarDetailDialog)>:is(#orderDetail,#rebarDetail){display:grid;grid-template-columns:minmax(0,1fr) 340px;padding:0;margin:0;border:0;gap:0;align-items:start}
 :is(#orderDetail,#rebarDetail)>:is(.order-detail-head,.rebar-detail-head){grid-column:1/-1;padding:14px 22px;min-height:0;margin:0}
 :is(#orderDetail,#rebarDetail) .module-detail-heading h2{font-size:22px;margin:2px 0}
 :is(#orderDetail,#rebarDetail) .module-detail-heading p{margin:0}
 :is(#orderDetail,#rebarDetail)>.delivery-edit-toolbar{grid-column:1/-1;padding:8px 22px;margin:0;min-height:0}
 :is(#orderDetail,#rebarDetail) .delivery-edit-toolbar p{margin:0}
 :is(#orderDetail,#rebarDetail)>:is(.order-form-grid,.rebar-form-grid){grid-column:1;grid-row:3;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px 16px;padding:16px 22px;align-content:start}
 :is(#orderDetail,#rebarDetail) .delivery-form-heading{grid-column:1/-1;border:0;padding:0;margin:0;font-size:16px}
 :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label{grid-column:auto;max-width:none;gap:4px}
 #orderDetail .field-orderName,#orderDetail .field-orderDescription,#rebarDetail .rebar-form-grid>label.field-rebarList{grid-column:span 2}
 #orderDetail .field-orderSupplier{grid-column:auto}
 #rebarDetail .rebar-form-grid>label.field-rebarNotes{grid-column:1/-1}
 :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label :is(input:not([type=file]),.bs-select-trigger){height:40px;min-height:40px;padding-top:7px;padding-bottom:7px;font-size:16px}
 :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label textarea{height:76px;min-height:76px;padding:9px 11px;resize:vertical}
 :is(#orderDetail,#rebarDetail) .delivery-read-value{min-height:32px;padding:4px 0;white-space:pre-wrap;overflow-wrap:anywhere}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-detail-columns){grid-column:2;grid-row:3;margin:0;display:flex;flex-direction:column;border-left:1px solid #d8e2e7;background:#f7f9fa;align-self:stretch;min-width:0}
 #orderDetail>.attachments-section{padding:16px}
 #rebarDetail :is(.rebar-files,.rebar-issues){padding:16px;border:0;min-width:0}
 #rebarDetail .rebar-files{order:0}
 #rebarDetail .rebar-issues{order:1;border-top:1px solid #d8e2e7}
 :is(#orderDetail,#rebarDetail) .section-head{margin:0 0 12px;gap:8px;align-items:start;flex-wrap:wrap}
 :is(#orderDetail,#rebarDetail) .section-head h3{font-size:16px;margin:0 0 4px}
 :is(#orderDetail,#rebarDetail) .section-head p{margin:0;font-size:16px;line-height:1.4}
 :is(#orderDetail,#rebarDetail) .upload-actions{margin:0 0 8px;gap:8px;flex-wrap:wrap}
 :is(#orderDetail,#rebarDetail) .upload-btn{background:transparent;border:0;border-radius:7px;min-height:40px;padding:0;cursor:pointer}
 :is(#orderDetail,#rebarDetail) .upload-btn>span{display:inline-flex;align-items:center;gap:8px;min-height:40px;padding:8px 12px;border:1px solid #cbd8df;border-radius:7px;background:#fff;color:#203b49;font:600 14px/1.4 var(--bs-font-family)}
 :is(#orderDetail,#rebarDetail) .drop-zone{padding:12px;margin:0 0 10px;min-height:0;border:1px dashed #a9becb;background:#eef4f7;text-align:center}
 :is(#orderDetail,#rebarDetail) .drop-zone>span{display:block;font-size:16px}
 :is(#orderDetail,#rebarDetail) .attachment-list{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;margin:0}
 :is(#orderDetail,#rebarDetail) .attachment-item{display:flex;align-items:center;border:1px solid #d8e2e7;border-radius:8px;background:#fff;padding:8px;min-width:0}
 :is(#orderDetail,#rebarDetail) .attachment-open{display:flex;align-items:center;gap:10px;min-width:0;flex:1;padding:0;text-align:left}
 :is(#orderDetail,#rebarDetail) .attachment-thumb{width:38px;height:44px;flex:0 0 38px;border-radius:5px;background:#edf3f7;color:#365a70;font:600 14px var(--bs-font-family);display:grid;place-items:center;overflow:hidden}
 :is(#orderDetail,#rebarDetail) .attachment-thumb img{width:100%;height:100%;object-fit:cover}
 :is(#orderDetail,#rebarDetail) .attachment-info{min-width:0}
 :is(#orderDetail,#rebarDetail) .attachment-info strong{white-space:normal;overflow-wrap:anywhere;font-size:14px}
 :is(#orderDetail,#rebarDetail) .attachment-info>span{font-size:14px;color:#556b78}
 :is(#orderDetail,#rebarDetail) .attachment-remove{flex:none;width:32px;min-height:36px}
 :is(#orderDetail,#rebarDetail) .empty-attachments{padding:0;border:0;background:none;margin:8px 0;font-size:16px}
 :is(#orderDetail,#rebarDetail)>.delivery-dialog-footer{grid-column:1/-1;margin:0;padding:10px 22px;min-height:64px}
 :is(#orderDetail,#rebarDetail) .delivery-pending-files{margin:8px 0;display:grid;gap:6px}
 .delivery-queued-file{padding:8px 10px;border:1px solid #d8e2e7;border-radius:7px;background:#fff;overflow-wrap:anywhere}
 .delivery-queued-file strong{display:block;font:600 14px/1.4 var(--bs-font-family)}
 .delivery-queued-file span{font:400 16px/1.4 var(--bs-font-family);color:#556b78}
 .delivery-upload-status{display:flex;align-items:center;gap:8px;padding:10px 12px;margin:8px 0;background:#eaf3fa;border-radius:7px;color:#203b49;font:400 16px/1.4 var(--bs-font-family);overflow-wrap:anywhere}
 .delivery-upload-status[data-state=error]{background:#fff0ec;color:#a63229}
 .delivery-upload-status[data-state=complete]{background:#eaf5ef;color:#25634d}
 .delivery-upload-status[data-state=uploading]::before{content:'';flex:0 0 16px;height:16px;border:2px solid #b5c9d7;border-top-color:#355d76;border-radius:50%;animation:delivery-upload-spin .8s linear infinite}
 @keyframes delivery-upload-spin{to{transform:rotate(360deg)}}
 @media(prefers-reduced-motion:reduce){.delivery-upload-status[data-state=uploading]::before{animation:none}}
}

/* Clear read-only values; decorative date controls are absent in read mode. */
:is(#orderDetail,#rebarDetail).delivery-read-mode .bs-date-toggle{display:none}
:is(#orderDetail,#rebarDetail) input[type=date]{box-sizing:border-box;min-width:0;line-height:normal}
:is(#orderDetail,#rebarDetail) input[type=date]::-webkit-date-and-time-value{min-height:1.4em;text-align:left;margin:0}
:is(#orderDetail,#rebarDetail) input[type=date]::-webkit-datetime-edit{padding:0;line-height:normal}
@media screen and (min-width:1001px){
 #orderDetail .order-form-grid>label.field-orderName{grid-column:1/-1}
 #orderDetail .order-form-grid>label.field-orderDescription{grid-column:span 2}
 #orderDetail .field-orderNotes{grid-column:auto}
 #rebarDetail .rebar-form-grid>label.field-rebarList{grid-column:span 2}
 :is(#orderDetail,#rebarDetail) .delivery-form-heading[data-secondary]{display:none}
 :is(#orderDetail,#rebarDetail).delivery-read-mode :is(.order-form-grid,.rebar-form-grid)>label{padding:10px 12px;background:#f5f8fa;border:1px solid #e0e7ec;border-radius:7px;gap:4px;align-content:start}
 :is(#orderDetail,#rebarDetail).delivery-read-mode .delivery-read-value{padding:0;min-height:24px;line-height:1.5;font-weight:500}
 :is(#orderDetail,#rebarDetail).delivery-read-mode .field-orderName .delivery-read-value,
 :is(#orderDetail,#rebarDetail).delivery-read-mode .field-rebarList .delivery-read-value{font-size:18px;font-weight:600}
 :is(#orderDetail,#rebarDetail).delivery-read-mode :is(.order-form-grid,.rebar-form-grid)>label>span:first-child{font-size:14px;color:#617481}
}
@media screen and (max-width:1000px){
 :is(#orderDetail,#rebarDetail) input[type=date]{height:44px;min-height:44px;padding:10px 12px;font-size:16px}
 :is(#orderDetail,#rebarDetail) .bs-date-input{padding-right:42px}
 .delivery-upload-status{padding:10px 12px;background:#edf4f8;font:400 16px/1.4 var(--bs-font-family);border-radius:7px}
 .delivery-queued-file{padding:8px 0;font-family:var(--bs-font-family)}
 .delivery-queued-file strong,.delivery-queued-file span{display:block;overflow-wrap:anywhere}
}

/* Alternative 3: delivery dates lead, status stays in the reading flow. */
@media screen and (min-width:1001px){
 :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label.status-control{grid-column:1/-1;display:flex;align-items:center;gap:14px;max-width:none;padding:0 0 4px;border:0;background:transparent}
 :is(#orderDetail,#rebarDetail) .status-control>.bs-select-shell{width:220px;flex:none}
 :is(#orderDetail,#rebarDetail) .status-control>span:first-child{font-size:16px;color:#203b49}
 :is(#orderDetail,#rebarDetail).delivery-read-mode :is(.order-form-grid,.rebar-form-grid)>label{background:transparent;border:0;border-radius:0;padding:0;gap:4px}
 :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label.delivery-date-focus{padding:12px 14px;background:#f2f6f8;border-left:2px solid #d5e0e7;border-radius:0;align-self:stretch}
 :is(#orderDetail,#rebarDetail) :is(.field-expectedDate,.field-rebarExpected).delivery-date-focus{border-left-color:#df4036}
 :is(#orderDetail,#rebarDetail) .delivery-date-focus .delivery-read-value{font-size:18px;font-weight:600}
 :is(#orderDetail,#rebarDetail) .delivery-form-heading{padding-top:8px;margin-top:2px}
 #orderDetail.delivery-read-mode .order-form-grid>label.field-orderName,
 #rebarDetail.delivery-read-mode .rebar-form-grid>label.field-rebarList{display:none}
 #orderDetail .order-form-grid>label.field-orderDescription{grid-column:1/-1;padding-top:12px;border-top:1px solid #dbe4e9}
 #orderDetail .order-form-grid>label.field-orderNotes{grid-column:1/-1}
 #rebarDetail .rebar-form-grid>label.field-rebarNotes{padding-top:12px;border-top:1px solid #dbe4e9}
}
@media screen and (min-width:1001px){
 :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label.status-control{flex-direction:row;justify-content:flex-start;text-align:left}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) .delivery-form-heading{order:-1}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) :is(.order-form-grid,.rebar-form-grid)>label{order:1}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) :is(.order-form-grid,.rebar-form-grid)>label.status-control{grid-column:auto;display:grid;order:0;gap:4px;align-content:start;padding:0}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) .status-control>.bs-select-shell{width:100%}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) :is(.order-form-grid,.rebar-form-grid)>label.delivery-date-focus{order:3;padding:0;border:0;background:transparent}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label.field-orderName,#rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.field-rebarList{grid-column:span 2;order:0}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label.field-orderSupplier{grid-column:span 2}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label.field-orderDescription{grid-column:span 2;order:4;border:0;padding:0}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label.field-orderNotes{grid-column:auto;order:4}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.field-rebarNotes{order:4;border:0;padding:0}
}

/* Approved sketch: colored status in header and a low attachment strip. */
@media screen and (min-width:1001px){
 :is(#orderDetailDialog,#rebarDetailDialog)>:is(#orderDetail,#rebarDetail){grid-template-columns:minmax(0,1fr)}
 :is(#orderDetail,#rebarDetail)>:is(.order-detail-head,.rebar-detail-head){display:flex;align-items:center;gap:20px}
 :is(#orderDetail,#rebarDetail) .module-detail-heading{flex:1;min-width:0}
 :is(#orderDetail,#rebarDetail)>:is(.order-detail-head,.rebar-detail-head)>.status-control{display:grid;gap:5px;flex:0 0 200px;max-width:200px;margin:0;background:none;padding:0;border:0;text-align:left}
 :is(#orderDetail,#rebarDetail) .status-control>span:first-child{font:600 14px/1.4 var(--bs-font-family);color:#556b78}
 :is(#orderDetail,#rebarDetail) .status-control>.bs-select-shell{width:100%}
 :is(#orderDetail,#rebarDetail) .status-control .bs-select-trigger{min-height:44px;border-radius:24px;border:1px solid #afbdc8;background:#eef2f5;color:#324d5f;font:700 16px/1.4 var(--bs-font-family)}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Bestilt"] .status-control .bs-select-trigger{background:#dceaff;border-color:#8aacda;color:#204f88}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Mottatt"] .status-control .bs-select-trigger{background:#daf0e4;border-color:#7eb49a;color:#206744}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Delvis mottatt"] .status-control .bs-select-trigger{background:#fff0cf;border-color:#d6b46c;color:#805715}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Avvik"] .status-control .bs-select-trigger{background:#ffdfdb;border-color:#e44238;color:#a62a24}
 :is(#orderDetail,#rebarDetail) :is(.order-form-grid,.rebar-form-grid)>label.delivery-date-focus:is(.field-expectedDate,.field-rebarExpected){border-left:3px solid #e44238}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files){grid-column:1;grid-row:4;display:grid;grid-template-columns:minmax(210px,1fr) minmax(240px,1.5fr) auto;gap:8px 16px;align-items:center;padding:12px 22px;border:0;border-top:1px solid #d8e2e7;background:#f5f8fa}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .section-head{grid-column:1;grid-row:1;display:flex;align-items:center;flex-wrap:nowrap;margin:0}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .section-head p{display:none}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .section-head h3{margin:0}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .upload-actions{grid-column:3;grid-row:1;margin:0}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .drop-zone{grid-column:2;grid-row:1;padding:8px 12px;margin:0;min-height:40px}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .drop-zone>span{display:none}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) :is(.attachment-list,.delivery-pending-files,.delivery-upload-status){grid-column:1/-1;margin:0}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .attachment-list{display:flex;flex-wrap:wrap;gap:8px}
 :is(#orderDetail,#rebarDetail) .attachment-item{flex:0 1 330px;max-width:100%}
 :is(#orderDetail,#rebarDetail) .empty-attachments{font-size:14px;margin:0}
 #rebarDetail>.rebar-detail-columns{display:none}
 #rebarDetail .rebar-form-grid>.rebar-issues{grid-column:1/-1;order:5;padding:8px 0 0;margin:0;border-top:1px solid #d8e2e7}
 #rebarDetail .rebar-issues .section-head{margin:0;align-items:center}
 #rebarDetail .rebar-issues .section-head p{display:none}
 #rebarDetail .rebar-issue-list>p{margin:4px 0 0;font-size:16px}
 :is(#orderDetail,#rebarDetail)>.delivery-dialog-footer{grid-row:5}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label.field-orderName{grid-column:1/-1}
}
@media screen and (min-width:1001px){
 #rebarDetail:not(.delivery-read-mode)>.rebar-form-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px 16px;padding-top:10px;padding-bottom:10px}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.field-rebarDrawing,
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.field-rebarBuilding{order:0}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.field-rebarNotes{grid-column:1/-1}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid textarea{height:56px;min-height:56px}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>.rebar-issues{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
 #rebarDetail:not(.delivery-read-mode) .rebar-issues .section-head{flex:1}
 #rebarDetail:not(.delivery-read-mode) .rebar-issue-list>p{margin:0}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .attachment-list:has(>.empty-attachments){display:none}
}

/* Balanced editing fields within the diary-width dialog. Mobile keeps its existing layout. */
@media screen and (min-width:1001px){
 #orderDetail:not(.delivery-read-mode)>.order-form-grid{grid-template-columns:repeat(6,minmax(0,1fr));gap:12px 16px}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label:is(.field-orderSupplier,.field-orderBy,.field-invoiceNumber,.field-invoiceAmount,.field-orderDescription,.field-orderNotes){grid-column:span 3}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label.delivery-date-focus{grid-column:span 2}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) :is(.order-form-grid,.rebar-form-grid)>label.delivery-date-focus{padding:8px 10px;background:#f2f6f8;border-left:3px solid #d5e0e7;gap:6px}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) :is(.order-form-grid,.rebar-form-grid)>label.delivery-date-focus:is(.field-expectedDate,.field-rebarExpected){border-left-color:#e44238}
 #rebarDetail:not(.delivery-read-mode)>.rebar-form-grid{grid-template-columns:repeat(12,minmax(0,1fr));gap:10px 14px}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label{grid-column:span 3}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.field-rebarList{grid-column:span 6}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.delivery-date-focus{grid-column:span 4}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.field-rebarNotes{grid-column:1/-1}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files){grid-template-columns:minmax(190px,1fr) minmax(130px,1fr) auto;gap:8px 12px}
 :is(#orderDetail,#rebarDetail)>:is(.attachments-section,.rebar-files) .section-head{flex-wrap:wrap;gap:4px 10px}
}
@media screen and (min-width:1001px) and (max-width:1150px){
 /* The diary sidebar becomes 236px with a 14px gap at this breakpoint. */
 :is(#orderDetailDialog,#rebarDetailDialog){width:calc(100vw - 310px)}
}

/* Narrower, growing forms: long notes stay visible instead of scrolling inside a field. */
@media screen and (min-width:1001px){
 :is(#orderDetailDialog,#rebarDetailDialog){width:min(920px,calc(100vw - 80px));max-width:920px}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label:is(.field-orderDescription,.field-orderNotes){grid-column:1/-1}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) :is(.order-form-grid,.rebar-form-grid)>label textarea{height:auto;min-height:56px;max-height:none;overflow:hidden;resize:none;line-height:1.5;overflow-wrap:anywhere}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label.field-orderNotes textarea{min-height:44px}
 :is(#orderDetail,#rebarDetail)>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#203e50;color:#fff;border:2px solid #203e50;box-shadow:0 0 0 3px #fff,0 0 0 5px #d7e1e7;font-weight:700}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Bestilt"]>.order-detail-head>.status-control .bs-select-trigger,
 #rebarDetail[data-delivery-status="Bestilt"]>.rebar-detail-head>.status-control .bs-select-trigger{background:#285b91;border-color:#285b91}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Mottatt"] .status-control .bs-select-trigger{background:#226b4a;border-color:#226b4a;color:#fff}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Avvik"] .status-control .bs-select-trigger{background:#b8322c;border-color:#b8322c;color:#fff}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Delvis mottatt"] .status-control .bs-select-trigger{background:#815d16;border-color:#815d16;color:#fff}
}
@media screen and (min-width:1001px){
 #orderDetail:not(.delivery-read-mode)>.order-form-grid{gap:8px 16px;padding-block:12px}
 :is(#orderDetail,#rebarDetail):not(.delivery-read-mode) .delivery-form-heading{padding:0;margin:0}
 #orderDetail:not(.delivery-read-mode) .order-form-grid>label textarea{min-height:44px}
 :is(#orderDetail,#rebarDetail)>:is(.order-detail-head,.rebar-detail-head)>:is(.order-detail-actions,.rebar-detail-actions){align-self:flex-end;align-items:center;margin:0;padding:0}
 :is(#orderDetail,#rebarDetail) .module-dialog-close{height:44px;min-height:44px;padding:0 16px;gap:9px;border:1px solid #bacbd5;border-radius:24px;background:#fff;color:#203e50;font-weight:600;box-shadow:0 2px 5px #203e5010;transition:background .15s,transform .12s}
 :is(#orderDetail,#rebarDetail) .module-dialog-close>span:first-child{font-size:22px;line-height:1}
 :is(#orderDetail,#rebarDetail) .module-dialog-close:hover{background:#e7eef3;border-color:#7c96a6}
 :is(#orderDetail,#rebarDetail) .module-dialog-close:active{transform:scale(.97)}
 :is(#orderDetail,#rebarDetail) .module-dialog-close:focus-visible{outline:3px solid #345f7a;outline-offset:3px}
}
@media(prefers-reduced-motion:reduce){:is(#orderDetail,#rebarDetail) .module-dialog-close{transition:none}}
/* Wrapping issue text and centered weight units in both desktop and mobile layouts. */
#rebarDetail .rebar-issue-list{min-width:0;width:100%}
#rebarDetail .rebar-issue{min-width:0;align-items:start}
#rebarDetail .rebar-issue-text{box-sizing:border-box;width:100%;min-width:0;min-height:40px;height:auto;max-height:none;resize:none;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere;font:400 16px/1.5 var(--bs-font-family);padding:8px 10px}
#invoiceAmount::placeholder{color:#7c8d98;opacity:1}
#rebarWeight,#invoiceAmount{appearance:textfield;-moz-appearance:textfield}
#rebarWeight::-webkit-inner-spin-button,#rebarWeight::-webkit-outer-spin-button,
#invoiceAmount::-webkit-inner-spin-button,#invoiceAmount::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
#rebarDetail:not(.delivery-read-mode) .field-rebarWeight .unit-input{position:relative}
#rebarDetail:not(.delivery-read-mode) .field-rebarWeight .unit-input>span{position:absolute;top:50%;right:12px;bottom:auto;transform:translateY(-50%);line-height:1.5;pointer-events:none}
#rebarWeight{padding-right:42px}
@media screen and (min-width:1001px){
 #orderDetail>.order-detail-head>.module-dialog-close{align-self:flex-end}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Mottatt"]>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#226b4a;border-color:#226b4a}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Avvik"]>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#b8322c;border-color:#b8322c}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Delvis mottatt"]>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#815d16;border-color:#815d16}
}
@media screen and (min-width:1001px){
 :is(#orderDetail,#rebarDetail)>:is(.order-detail-head,.rebar-detail-head){align-items:flex-end}
 :is(#orderDetail,#rebarDetail) .status-control>.bs-select-shell{display:block;line-height:0}
 :is(#orderDetail,#rebarDetail) .status-control .bs-select-trigger{box-sizing:border-box;height:44px}
}
/* Delivery review refinements. */
:is(#orderDetail,#rebarDetail).delivery-read-mode>.delivery-edit-toolbar{display:none}
:is(#orderDetail,#rebarDetail) .delivery-editor-name{font:400 14px/1.5 var(--bs-font-family);color:#556b78;margin:2px 0 0}
@media screen and (min-width:1001px){
 :is(#orderDetail,#rebarDetail) .status-control>span:first-child{text-align:center;width:100%;font-size:14px}
 :is(#orderDetail,#rebarDetail)>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#eaf0f4;border-color:#b5c6d1;color:#29485a;box-shadow:none}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Bestilt"]>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#e6eef9;border-color:#aac2e2;color:#315d8e}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Mottatt"]>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#e6f3eb;border-color:#a6cdb6;color:#286848}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Avvik"]>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#fce9e6;border-color:#eab4ad;color:#a9362f}
 :is(#orderDetail,#rebarDetail)[data-delivery-status="Delvis mottatt"]>:is(.order-detail-head,.rebar-detail-head)>.status-control .bs-select-trigger{background:#fcf1dc;border-color:#ddc799;color:#795a22}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label:is(.field-rebarDrawing,.field-rebarBuilding,.field-rebarInvoice,.field-rebarSupplier,.field-rebarWeight,.field-rebarInvoiceAmount){grid-column:span 4;order:1}
 #rebarDetail:not(.delivery-read-mode) .rebar-form-grid>label.field-rebarList{grid-column:1/-1}
}

/* Weight values use the same dark text as other recorded values. */
#rebarDetail .unit-input>#rebarWeightReadValue:not(.is-empty){color:#182f3d;font-weight:500}


/* Invoice placement: preserve the existing order-dialog symmetry. */
#invoiceAmount{appearance:textfield;-moz-appearance:textfield}
#invoiceAmount::-webkit-inner-spin-button,
#invoiceAmount::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
@media screen and (min-width:1001px){
  #orderDetail:not(.delivery-read-mode)>.order-form-grid{grid-template-columns:repeat(6,minmax(0,1fr))}
  #orderDetail:not(.delivery-read-mode) .field-orderSupplier{grid-column:1/span 3;order:1}
  #orderDetail:not(.delivery-read-mode) .field-orderBy{grid-column:4/span 3;order:1}
  #orderDetail:not(.delivery-read-mode) .field-invoiceNumber{grid-column:1/span 3;order:2}
  #orderDetail:not(.delivery-read-mode) .field-invoiceAmount{grid-column:4/span 3;order:2}
  #orderDetail:not(.delivery-read-mode) .field-orderDate{grid-column:1/span 2;order:3}
  #orderDetail:not(.delivery-read-mode) .field-expectedDate{grid-column:3/span 2;order:3}
  #orderDetail:not(.delivery-read-mode) .field-receivedDate{grid-column:5/span 2;order:3}
  #orderDetail:not(.delivery-read-mode) .field-orderDescription,
  #orderDetail:not(.delivery-read-mode) .field-orderNotes{grid-column:1/-1;order:4}
}
