#desk-detail {
  container: order-card / inline-size;
}

#desk-detail .desk-detail-header {
  padding-bottom: 15px;
  border: 0;
}

#desk-detail .desk-detail-meta {
  gap: 8px;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

#desk-detail .desk-detail-header h2 {
  font-size: clamp(1.3rem, 3.7cqi, 1.85rem);
  line-height: 1.15;
  text-wrap: pretty;
}

#desk-detail .case-byline {
  margin-top: 5px;
}

#desk-detail .desk-detail-header {
  display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;
  column-gap:20px;row-gap:14px;padding-bottom:18px;
}
#desk-detail .desk-detail-meta {
  grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;
  gap:8px 12px;margin:0;color:var(--desk-muted);font-size:.8rem;
}
#desk-detail .desk-detail-meta .desk-back {
  display:inline-flex;min-height:32px;margin:0 3px 0 0;padding:0 13px 0 0;border-radius:0;
  border-right:1px solid var(--desk-line);
}
#desk-detail .case-subject {grid-column:1 / -1;display:flex;align-items:center;gap:15px;min-width:0;}
#desk-detail .case-identity {min-width:0;overflow-wrap:anywhere;}
#desk-detail .case-car-photo {width:84px;height:64px;flex:none;object-fit:cover;border-radius:9px;background:#f4f3f4;}
#desk-detail .case-car-link {display:inline-block;margin-top:5px;color:var(--desk-red);font-size:.81rem;font-weight:650;text-underline-offset:3px;}
#desk-detail .case-vin {display:inline-block;margin-left:12px;color:var(--desk-muted);font-size:.76rem;overflow-wrap:anywhere;}
#desk-detail .case-facts {
  grid-column:1 / -1;display:flex;gap:10px 28px;flex-wrap:wrap;margin:0;
  border-top:1px solid var(--desk-line);padding:13px 0 0;
}
#desk-detail .case-facts div {min-width:0;max-width:100%;}
#desk-detail .case-facts dt {font-size:.72rem;color:var(--desk-muted);}
#desk-detail .case-facts dd {margin:2px 0 0;font-size:.85rem;font-weight:620;overflow-wrap:anywhere;}
#desk-detail .case-contact {display:block;color:var(--desk-muted);font-size:.74rem;font-weight:450;}
#desk-detail .desk-detail-header .case-actions {grid-column:1 / -1;margin-top:0;}
#desk-detail .case-chat-heading {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px 15px;}
#desk-detail .case-chat-heading .case-car-link {margin:0;}
#desk-detail .case-chat-count {display:inline-block;min-width:1.3em;margin-left:.4em;padding:.12em .3em;color:white;background:var(--desk-red);border-radius:1em;font-size:.82em;}
.vehicle-chat-picker {display:grid;gap:5px;max-width:100%;min-width:0;}
.vehicle-chat-picker select {max-width:100%;min-width:0;width:100%;}
@container order-card (min-width: 900px) {
  #desk-detail .case-subject {grid-column:1;grid-row:2;}
  #desk-detail .desk-detail-header .case-actions {grid-column:2;grid-row:2;align-self:center;justify-content:flex-end;}
}
@container order-card (max-width: 560px) {
  #desk-detail .desk-detail-header {row-gap:10px;}
  #desk-detail .case-car-photo {width:62px;height:52px;}
  #desk-detail .case-subject {gap:10px;}
  #desk-detail .case-facts {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 12px;padding-top:10px;}
}

#desk-detail .case-actions,
#desk-detail .case-utility,
#desk-detail .case-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

#desk-detail .case-actions {
  position: relative;
  width: fit-content;
  min-width: min(15rem,100%);
  max-width: 100%;
  margin-top: 12px;
}

#desk-detail .case-action,
#desk-detail .case-tools > summary,
#desk-detail .case-shipment > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  max-width: 100%;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--desk-line);
  border-radius: 9px;
  background: white;
  color: var(--desk-ink);
  font: inherit;
  font-size: .83rem;
  font-weight: 650;
  line-height: 1.25;
  cursor: pointer;
}

#desk-detail .case-action.primary {
  border-color: var(--desk-red);
  background: var(--desk-red);
  color: white;
}

#desk-detail .case-tools > summary {
  list-style: none;
}

#desk-detail .case-tools > summary::-webkit-details-marker {
  display: none;
}

#desk-detail .case-tools > summary::after {
  content: '';
  width: 6px;
  height: 6px;
  margin: -3px 0 0 3px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

#desk-detail .case-tools[open] > summary::after {
  transform: rotate(225deg);
  margin-top: 3px;
}

#desk-detail .case-utility {
  position: absolute;
  z-index: 5;
  inset-block-start: calc(100% + 4px);
  inset-inline-end: 0;
  display: grid;
  width: min(15rem,100cqi);
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--desk-line);
  border-radius: 10px;
  background: white;
  box-shadow: 0 8px 24px #25212a20;
}

#desk-detail .case-utility :is(.desk-permalink,.desk-link) {
  display: block;
  padding: 9px 10px;
  text-align: start;
  border-radius: 5px;
  margin: 0;
  color: var(--desk-ink);
  font-size: .83rem;
}
#desk-detail .case-utility :is(a,button):hover { background:#f3f4f6; }

#desk-detail .case-utility .form-status:empty,
#desk-detail .desk-action-form .form-status:empty {
  display: none;
}

#desk-detail .case-tabs {
  padding: 4px;
  gap: 2px;
  border: 1px solid #e1e1e5;
  border-radius: 11px;
  background: #f3f4f6;
}

#desk-detail .case-tab {
  flex: 1 1 auto;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #54545e;
  font-size: .82rem;
  line-height: 1.25;
}

#desk-detail .case-tab:hover {
  color: var(--desk-ink);
  background: #e9eaec;
}

#desk-detail .case-tab[aria-selected="true"] {
  background: white;
  color: var(--desk-red);
  border-color: #dddce0;
  box-shadow: 0 1px 3px #22202a12;
}

#desk-detail .case-equipment-tab {
  color:#226045;
  background:#e7f4ec;
  border-color:#bfdfca;
}
#desk-detail .case-equipment-tab:hover { color:#194e37; background:#d9edde; }
#desk-detail .case-equipment-tab[aria-selected="true"] {
  color:#164c33;
  background:#d6ecde;
  border-color:#77a88b;
  box-shadow:inset 0 -2px #397a53;
}
#desk-detail .case-equipment-note {
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  width:100%;
  align-self:start;
  align-items:center;
  gap:12px;
  padding:10px 13px;
  color:#212c26;
  background:white;
  border:1px solid #d5e4da;
  border-radius:10px;
  text-align:start;
}
#desk-detail .case-equipment-note:hover { background:#f7fbf8; border-color:#a4c8b1; filter:none; }
#desk-detail .case-equipment-note:focus-visible { outline:2px solid #34784c; outline-offset:2px; }
#desk-detail .case-equipment-note svg {
  box-sizing:border-box;
  width:34px; height:34px; padding:7px;
  color:#34684c; background:#e8f3eb; border-radius:9px;
  fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round;
}
#desk-detail .case-equipment-copy { display:grid; gap:2px; }
#desk-detail .case-equipment-copy strong { font-size:.92rem; line-height:1.25; }
#desk-detail .case-equipment-copy > span { color:#536158; font-size:.83rem; font-weight:400; line-height:1.35; }
#desk-detail .case-equipment-go {
  display:inline-flex; align-items:center; gap:8px;
  color:#265f3f; font-size:.83rem; font-weight:650;
}
#desk-detail .case-equipment-go::after {
  content:''; width:7px; height:7px; margin-inline-end:3px;
  border:solid currentColor; border-width:1.6px 1.6px 0 0; transform:rotate(45deg);
}
@container order-card (max-width:32rem) {
  #desk-detail .case-equipment-note { gap:9px; padding:10px; }
  #desk-detail .case-equipment-go > span { display:none; }
}

#desk-detail :is(.case-tab, .case-panel, summary):focus-visible {
  outline: 2px solid var(--desk-red);
  outline-offset: 2px;
}

#desk-detail .case-panel {
  padding-top: 14px;
  min-width: 0;
}

#desk-detail .desk-detail-body {
  padding-top: 0;
  gap: 12px;
}

#desk-detail .case-progress {
  display: grid;
  gap: 7px;
}

#desk-detail .deal-work {
  display:grid;
  gap:12px;
  min-width:0;
  padding:clamp(14px,3cqi,22px);
  border:1px solid #e5c6cb;
  border-inline-start:4px solid var(--desk-red);
  border-radius:12px;
  background:#fffafb;
}
#desk-detail .deal-work[data-finished=true] { background:#f7f8f9; border-color:var(--desk-line); }
#desk-detail .deal-work-heading { display:grid; gap:5px; }
#desk-detail .deal-work-heading small { color:#823141; font-size:.76rem; font-weight:700; }
#desk-detail .deal-work-heading h3 { margin:0; font-size:clamp(1.08rem,3.4cqi,1.42rem); line-height:1.2; }
#desk-detail .deal-work-heading p { margin:0; max-width:66ch; color:var(--desk-muted); font-size:.87rem; line-height:1.45; }
#desk-detail .deal-work-actions,#desk-detail .deal-editor-actions { display:flex; align-items:center; flex-wrap:wrap; gap:7px 12px; }
#desk-detail .deal-work-actions button,#desk-detail .deal-editor-actions button { min-height:42px; }
.deal-invoice-figures { display:grid; width:100%; grid-template-columns:repeat(auto-fit,minmax(min(100%,7.5rem),1fr)); gap:8px; margin:0; }
.deal-invoice-figures div { padding:8px 10px; background:white; border:1px solid var(--desk-line,#e2dfe2); border-radius:8px; }
.deal-invoice-figures dt { color:var(--desk-muted,#685f64); font-size:.77rem; }
.deal-invoice-figures dd { margin:3px 0 0; font-size:.96rem; font-weight:700; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
#desk-detail .deal-stage-editor { padding:12px 0 0; border:0; border-top:1px solid #e7d9db; border-radius:0; background:transparent; }
#desk-detail .deal-work .form-status:empty,#desk-detail .shipment-editor .form-status:empty { display:none; }
#desk-detail .shipment-editor { display:grid; gap:14px; }
#desk-detail .shipment-editor fieldset { min-width:0; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:end; gap:10px; border:0; margin:0; padding:0; }
#desk-detail .shipment-editor legend { margin-bottom:6px; padding:0; font-size:.8rem; font-weight:700; color:var(--desk-muted); }
#desk-detail .shipment-editor label { min-width:0; font-size:.83rem; }
#desk-detail .deal-editor-actions .desk-link { padding:7px 12px; border:1px solid var(--desk-line); border-radius:8px; background:white; color:var(--desk-muted); }
@container order-card (max-width: 24rem) {
  #desk-detail .shipment-editor fieldset { grid-template-columns:1fr; }
}

#desk-detail .desk-route {
  padding: 14px 16px;
  border: 1px solid #e9d8dc;
  border-radius: 12px;
  background: #fbf7f8;
}

#desk-detail .desk-route h3 {
  color: #695e64;
  font-weight: 600;
  font-size: .78rem;
  margin-bottom: 3px;
}

#desk-detail .desk-route-progress {
  margin-bottom: 11px;
}

#desk-detail .desk-route-progress strong {
  font-size: 1.08rem;
  color: var(--desk-ink);
}

#desk-detail .booking-guide { display:grid; justify-items:start; gap:6px; }
#desk-detail .booking-guide-meta {
  display:flex; justify-content:space-between; flex-wrap:wrap; gap:4px 14px; width:100%;
  color:var(--desk-muted); font-size:.76rem;
}
#desk-detail .booking-guide-meta span:first-child { color:#823141; font-weight:700; }
#desk-detail .booking-guide h3 { margin:0; color:var(--desk-ink); font-size:clamp(1.05rem,3cqi,1.28rem); font-weight:700; line-height:1.25; }
#desk-detail .booking-guide p { margin:0; max-width:74ch; color:var(--desk-muted); font-size:.88rem; line-height:1.45; }
#desk-detail .booking-guide .desk-link { min-height:40px; padding:6px 0; color:var(--desk-red); text-decoration:underline; text-underline-offset:3px; }
#desk-detail .booking-guide + ol { padding-top:13px; margin-top:12px; border-top:1px solid #e9d8dc; }
#desk-detail .booking-invoice-download { display:inline-flex; align-items:center; min-height:42px; padding:0 14px; border-radius:8px; background:var(--desk-red); color:#fff; font-weight:700; text-decoration:none; }
#desk-detail .booking-invoice-download:focus-visible { outline:2px solid var(--desk-ink); outline-offset:3px; }
#desk-detail .booking-payment-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:stretch; margin-top:4px; }
#desk-detail .booking-payment-actions .booking-invoice-download { border:1px solid var(--desk-line); background:white; color:var(--desk-ink); }
#desk-detail .booking-invoice-document:not([hidden]) { display:flex; align-items:center; flex-wrap:wrap; justify-content:space-between; gap:12px; margin-bottom:12px; padding:12px 15px; border:1px solid var(--desk-line); border-radius:12px; }

#desk-detail .case-route-name {
  color: var(--desk-muted);
  font-size: .82rem;
}

#desk-detail .case-shipment,
#desk-detail .case-status,
#desk-detail .desk-personal,
#desk-detail .installation-jobs {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--desk-line);
  border-radius: 12px;
  background: white;
  padding: 12px 15px;
}

#desk-detail .case-shipment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

#desk-detail .case-shipment > h3 {
  margin: 0;
}

#desk-detail .case-shipment > button {
  grid-column: 2;
  grid-row: 1;
  color: var(--desk-red);
}

#desk-detail .case-shipment > :is(dl, form, p) {
  grid-column: 1 / -1;
}

#desk-detail .shipment-facts {
  margin: 4px 0 0;
  gap: 12px 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#desk-detail .shipment-facts dd {
  color: var(--desk-ink);
  font-size: .91rem;
}

#desk-detail .case-status > summary,
#desk-detail .desk-personal > summary,
#desk-detail .installation-jobs > summary {
  cursor: pointer;
  font-size: .9rem;
  font-weight: 650;
}

#desk-detail .case-status > .desk-action-form {
  margin-top: 12px;
  padding: 0;
  background: transparent;
  border: 0;
}

#desk-detail .service-overview { --service-accent:#782139; --service-tint:#fcf2f5; display:grid; min-width:0; border:1px solid var(--desk-line); border-radius:14px; background:white; }
#desk-detail .service-overview[data-tone="ready"] { --service-accent:#245941; --service-tint:#eef6f1; }
#desk-detail .service-overview[data-tone="stopped"] { --service-accent:#6c505b; --service-tint:#f6f2f4; }
#desk-detail .service-overview-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px 18px; padding:16px 18px; border-radius:13px 13px 0 0; background:var(--service-tint); }
#desk-detail .service-overview-label { display:block; margin-bottom:4px; color:var(--service-accent); font-size:.8rem; font-weight:700; }
#desk-detail .service-overview-head h3 { margin:0 0 5px; font-size:clamp(1.1rem,2vw,1.4rem); }
#desk-detail .service-overview-head p { margin:0; color:#62565d; max-width:64ch; font-size:.86rem; }
#desk-detail .service-primary { min-height:40px; background:var(--service-accent); color:white; font-size:.84rem; }
#desk-detail .service-overview-steps { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; margin:0; padding:14px 18px 4px; list-style:none; }
#desk-detail .service-overview-steps li { border-top:3px solid #e9e2e6; padding-top:7px; color:#685c63; font-size:.77rem; }
#desk-detail .service-overview-steps .is-past { border-color:#b691a1; }
#desk-detail .service-overview-steps .is-current { border-color:var(--service-accent); color:var(--service-accent); font-weight:700; }
#desk-detail .service-overview-facts { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr)); gap:8px; margin:0; padding:12px 18px; }
#desk-detail .service-overview-facts > div { min-width:0; padding:9px 11px; border:1px solid #ede8ec; border-radius:8px; background:#fbfafb; }
#desk-detail .service-overview-facts dt { color:#675a62; font-size:.76rem; }
#desk-detail .service-overview-facts dd { margin:4px 0 0; font-size:.86rem; font-weight:650; overflow-wrap:anywhere; }
#desk-detail .service-overview-facts dd > small { display:block; margin-top:4px; font-weight:400; }
#desk-detail .service-overview-outcome { padding:8px 18px 12px; }
#desk-detail .service-overview-outcome .service-overview-facts { padding:8px 0 0; }
#desk-detail .service-overview-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; margin:0 18px 12px; }
#desk-detail .service-overview-extra { min-width:0; border:1px solid #ede8ec; border-radius:8px; }
#desk-detail .service-overview-extra[open] { grid-column:1/-1; }
#desk-detail .service-overview-extra > summary { padding:9px 11px; cursor:pointer; color:#5f414e; font-weight:650; font-size:.83rem; }
#desk-detail .service-overview-extra > :is(.stack,form) { margin:0 10px 10px; }
#desk-detail .service-overview > .service-overview-extra { margin:0 18px 14px; }
#desk-detail .service-overview-extra .service-overview-facts { padding:0 10px 10px; }
#desk-detail .service-overview-stage .desk-action-form { grid-template-columns:repeat(2,minmax(0,1fr)); }
#desk-detail .service-overview-stage .desk-action-form > :is(button,.form-status) { grid-column:1/-1; }
#desk-detail .service-overview-stage textarea { min-height:66px; }
#desk-detail .service-overview-exception > summary { color:#8b2840; }
#desk-detail .service-overview [hidden],#desk-detail .service-request:empty { display:none; }
#desk-detail .service-request > .desk-request-text { margin-block-end:9px; padding:12px 15px; border:1px solid var(--desk-line); border-radius:12px; background:white; }
#desk-detail .service-request > .service-result { border-inline-start:3px solid #427659; }
@media(max-width:640px) {
  #desk-detail .service-overview-actions,#desk-detail .service-overview-stage .desk-action-form { grid-template-columns:1fr; }
  #desk-detail .service-overview-head,#desk-detail .service-overview-facts,#desk-detail .service-overview-steps { padding-inline:11px; }
  #desk-detail .service-overview-actions,#desk-detail .service-overview > .service-overview-extra { margin-inline:11px; }
}

#desk-detail .case-history { display:grid; gap:1.2rem; min-width:0; }
#desk-detail .case-history > h3 { margin:0; font-size:1.18rem; line-height:1.3; }
#desk-detail .case-panel:has(> .case-history):focus { outline:none; }
#desk-detail .case-panel:focus-visible > .case-history > h3 {
  outline:2px solid var(--desk-red); outline-offset:3px; border-radius:3px; justify-self:start;
}
.history-crew {
  display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,16rem),1fr));
  margin:0; background:#faf8f8; border:1px solid #e9e2e4; border-radius:12px; overflow:hidden;
}
.history-member {
  position:relative; display:grid; grid-template-columns:2.5rem minmax(0,1fr); align-content:center;
  align-items:center; column-gap:.75rem; row-gap:.12rem; padding:.85rem 1.05rem;
}
.history-member + .history-member { border-inline-start:1px solid #e9e2e4; }
.history-member dt { grid-column:2; color:#6b6065; font-size:.78rem; line-height:1.4; }
.history-person { grid-column:2; display:grid; justify-items:start; gap:.12rem; min-width:0; margin:0; overflow-wrap:anywhere; }
.history-person strong { color:var(--desk-ink); font-size:1rem; line-height:1.32; }
.history-person small,.history-author small { font-size:.77rem; line-height:1.4; color:#69616a; }
.history-avatar {
  position:absolute; inset-inline-start:1.05rem; top:50%; transform:translateY(-50%); display:grid; place-items:center; width:2.5rem; height:2.5rem;
  border-radius:50%; overflow:hidden; color:#8a253e; background:#f2e4e8; font-size:.85rem; font-weight:700;
}
.history-avatar img { display:block; width:100%; height:100%; object-fit:cover; }
.history-member + .history-member .history-avatar { color:#375679; background:#e4ecf4; }
.history-member.unassigned { grid-template-columns:1fr; }
.history-member.unassigned :is(dt,dd) { grid-column:1; }
.history-member.unassigned strong { font-weight:500; color:var(--desk-muted); }
.history-days,.history-day { display:grid; min-width:0; }
.history-days { gap:1.15rem; }
#desk-detail .history-day > h4 {
  display:flex; align-items:center; gap:.75rem; margin:0 0 .3rem;
  font-size:.82rem; line-height:1.45; font-weight:650; color:#655a60;
}
.history-day > h4::after { content:''; flex:1; height:1px; background:var(--desk-line); }
.history-entries { padding:0; margin:0; list-style:none; }
.history-entry {
  position:relative; display:grid; grid-template-columns:3.45rem minmax(0,1fr) minmax(8rem,24%);
  gap:.35rem 1.4rem; padding:.8rem 0; align-items:start;
}
.history-entry::before,.history-entry::after { content:''; position:absolute; left:3.95rem; }
.history-entry::before { width:1px; top:0; bottom:0; background:var(--desk-line); }
.history-entry:first-child::before { top:1.4rem; }
.history-entry:last-child::before { bottom:calc(100% - 1.4rem); }
.history-entry::after {
  top:1.32rem; width:7px; height:7px; box-sizing:border-box; transform:translate(-3px,-1px);
  border-radius:50%; background:#ada1a7; box-shadow:0 0 0 3px white;
}
.history-day:first-child .history-entry:first-child::after { background:var(--desk-red); }
.history-time { color:#70666d; font-size:.82rem; font-variant-numeric:tabular-nums; line-height:1.65; white-space:nowrap; }
.history-action,.history-author { min-width:0; overflow-wrap:anywhere; }
.history-action strong { color:var(--desk-ink); font-size:.94rem; line-height:1.4; }
#desk-detail .history-action p { margin:.22rem 0 0; font-size:.87rem; line-height:1.5; color:#50484e; white-space:pre-line; }
.history-author { display:grid; justify-items:start; gap:.08rem; }
.history-author .person-name { color:#534a51; font-size:.84rem; line-height:1.5; font-weight:600; }
.history-author.is-company-lead .person-name { color:#86283e; }
.history-author.is-executor .person-name { color:#375679; }
@container order-card (max-width:39rem) {
  .history-crew { grid-template-columns:1fr; }
  .history-member + .history-member { border-inline-start:0; border-top:1px solid #e9e2e4; }
  .history-member { padding:.7rem .85rem; }
  .history-avatar { inset-inline-start:.85rem; }
  .history-entry { grid-template-columns:2.55rem minmax(0,1fr); column-gap:1.25rem; }
  .history-entry::before,.history-entry::after { left:2.95rem; }
  .history-author { grid-column:2; display:flex; align-items:baseline; flex-wrap:wrap; column-gap:.5rem; }
}

#desk-detail .desk-info {
  gap: 9px;
}

#desk-detail .case-panel :is(input, textarea, select, form, img, button) {
  min-width: 0;
  max-width: 100%;
}

@container order-card (min-width: 32rem) {
  #desk-detail .desk-route ol {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

@container order-card (max-width: 31.99rem) {
  #desk-detail .case-actions { width:100%; }
  #desk-detail .case-utility { inset-inline:0; width:auto; }
  #desk-detail .case-actions,
  #desk-detail .case-tabs {
    align-items: stretch;
  }

  #desk-detail .case-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.25rem), 1fr));
  }

  #desk-detail .desk-route ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 10px;
  }

  #desk-detail .desk-route li {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 16px;
    font-size: .73rem;
  }

  #desk-detail .desk-route li::before {
    flex: 0 0 9px;
    width: 9px;
    height: 9px;
  }

  #desk-detail .desk-route li::after {
    display: none;
  }
}

@media (pointer: coarse) {
  #desk-detail :is(.case-tab, .case-action, .case-tools > summary, .case-shipment > button) {
    min-height: 44px;
  }
}

.invoice-customer-contacts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 12px;
}
.invoice-pricing { display:grid; gap:10px; min-width:0; padding:14px; border:1px solid #e2dfe2; border-radius:10px; }
.invoice-pricing h3 { margin:0; font-size:1rem; }
.invoice-pricing output { font-weight:650; font-variant-numeric:tabular-nums; }

.invoice-customer-page {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #e2dfe2;
  border-radius: 10px;
}

.invoice-customer-page input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.invoice-customer-page a { justify-self: start; }

.invoice-passport-mode {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.invoice-passport-mode legend { margin-bottom: 8px; font-weight: 650; }
#dialog .invoice-passport-mode label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 5px;
  min-height: 42px;
  border: 1px solid #dedbde;
  border-radius: 9px;
  cursor: pointer;
}
#dialog .invoice-passport-mode label:has(:checked) { border-color: #aa1c39; color: #89152b; background: #fcf1f3; }
#dialog .invoice-passport-mode input {
  appearance: auto;
  width: 1rem;
  height: 1rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: #aa1c39;
}

#desk-detail .transit-broker-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 14px 16px;
  border: 1px solid #d1dce6;
  border-inline-start: 3px solid #477299;
  border-radius: 11px;
  background: #f6f9fc;
}
#desk-detail .transit-broker-panel[data-sent=true] {
  border-color: #cee2d8;
  border-inline-start-color: #488268;
  background: #f6faf8;
}
#desk-detail .transit-broker-panel > div {
  flex: 1 1 21rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
#desk-detail .transit-broker-panel h3 { margin: 0; font-size: 1rem; }
#desk-detail .transit-broker-panel strong { display: block; margin-top: 5px; }
#desk-detail .transit-broker-panel p { margin: 4px 0 0; color: var(--desk-muted); font-size: .87rem; }
#brokers .broker-secondary, #dialog .broker-secondary {
  color: #333441;
  border: 1px solid #dadce2;
  background: white;
  border-radius: 9px;
  padding: 8px 12px;
}
.broker-modal { min-width: 0; }
.broker-modal > button, .broker-modal form > button { justify-self: start; }
.broker-document-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.broker-modal small:empty { display: none; }
.broker-modal :is(input, select, textarea) { max-width: 100%; }
.broker-recipient { font-size: 1.08rem; overflow-wrap: anywhere; }
#dialog .broker-back {
  justify-self: start;
  color: #8c1c35;
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  padding: 3px 0;
}
.broker-chat {
  justify-self: start;
  padding: 9px 14px;
  border-radius: 8px;
  background: #24384c;
  color: white;
  text-decoration: none;
  font-weight: 650;
}
#dialog .broker-check { display: flex; align-items: center; gap: 8px; }
#dialog .broker-check input { flex: 0 0 1.05rem; width: 1.05rem; height: 1.05rem; margin: 0; accent-color: #a61c39; }
.broker-references { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .86rem; overflow-wrap: anywhere; }
.broker-references:empty { display: none; }
#brokers { width: min(100%, 1200px); margin-inline: auto; }
#brokers .heading { align-items: center; }
#brokers .heading h1 { margin-bottom: .35rem; }
#brokers .heading p { margin: 0; }
#brokers > .form-status:empty { display: none; }
.broker-companies-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,25rem),1fr)); gap: 16px; }
.broker-company { display: flex; flex-direction: column; gap: 17px; min-width: 0; padding: clamp(17px,2vw,25px); border: 1px solid #dfe2e6; border-radius: 15px; background: white; overflow-wrap: anywhere; }
.broker-company.partner { border-color: #c4dcbf; }
.broker-company h2 { margin: 0; font-size: 1.24rem; line-height: 1.25; }
.broker-company header p { margin: 5px 0 0; font-size: .9rem; }
.broker-badge { display: inline-block; margin: 0 6px 9px 0; border-radius: 5px; background: #e5f2e9; color: #255b39; padding: 4px 8px; font-size: .75rem; font-weight: 650; }
.broker-badge.muted { background: #f2f2f3; color: #555b64; }
.broker-company-facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-block: 12px; border-block: 1px solid #eceef0; }
.broker-company-facts dt, .broker-benefits h3 { color: #59626f; font-size: .8rem; margin: 0 0 4px; font-weight: 650; }
.broker-company-facts dd, .broker-benefits p { margin: 0; font-size: .93rem; line-height: 1.5; white-space: pre-line; }
.broker-offer, #dialog .broker-modal .broker-offer { padding: 10px 13px; border-radius: 8px; background: #edf6ef; color: #245537; font-weight: 650; margin: 0; font-size: .92rem; }
.broker-company footer { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.broker-company footer a { color: #773244; font-size: .86rem; }
#brokers .broker-secondary { font-size: .83rem; }
.chat-compose-actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.desk-compose .chat-attach { position:relative; display:inline-flex; align-items:center; margin:0; padding:9px 13px; border:1px solid #d9c8ce; border-radius:8px; background:white; color:#7c233d; font-size:.85rem; font-weight:650; cursor:pointer; }
.chat-attach:focus-within { outline:2px solid var(--desk-red); outline-offset:2px; }
.chat-attach input { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.chat-file-hint,.chat-upload-list small { color:var(--desk-muted); font-size:.76rem; }
.chat-upload-list { display:grid; gap:5px; padding:0; margin:0; list-style:none; }
.chat-upload-list[hidden] { display:none; }
.chat-upload-list li { display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:center; gap:10px; padding:6px 10px; background:#f7f5f6; border-radius:8px; font-size:.84rem; }
.chat-upload-list li span,.chat-filename { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.desk-compose .chat-remove { padding:5px; background:transparent; color:#86253f; font-size:.77rem; }
.desk-bubble:has(.chat-media-grid) { width:min(28rem,90%); min-width:0; }
.chat-media-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,11.5rem),1fr)); gap:8px; margin-top:8px; }
.chat-medium { min-width:0; display:grid; gap:3px; align-content:start; border-radius:8px; background:white; padding:5px; }
.chat-medium img,.chat-medium video { display:block; width:100%; aspect-ratio:16/10; border-radius:5px; background:#231f22; object-fit:contain; }
.chat-filename,.chat-download { padding:1px 4px; font-size:.78rem; }
.chat-download { color:#86253f; justify-self:start; }
.person-signature,.case-file .person-signature {
  display:inline-flex; flex-wrap:wrap; align-items:baseline; gap:.22rem .45rem;
  max-width:100%; min-width:0; vertical-align:baseline; white-space:normal;
}
.person-signature .person-name { font-weight:650; overflow-wrap:anywhere; }
.person-signature .person-company { font-size:.96em; font-weight:450; color:#635d65; overflow-wrap:anywhere; }
.person-role,.case-file .person-role {
  display:inline-block; width:fit-content; max-width:100%; box-sizing:border-box;
  padding:.15em .65em; border-radius:999px; background:#e9edf2; color:#344354;
  font-size:.72rem; line-height:1.45; font-weight:700; white-space:normal;
}
.person-role[data-role^="Администратор"] { background:#f8e1e8; color:#8a193b; }
.person-role[data-role="Ответственный логист"] { background:#dfecfa; color:#244f81; }
.person-role[data-role="Владелец"],.person-role[data-role="Руководитель"] { background:#dcf0e6; color:#225840; }
.chat-byline { display:flex; align-items:baseline; flex-wrap:wrap; gap:.18rem .8rem; color:#37303a; font-size:.82rem; }
.chat-byline time { color:#675f66; font-size:.72rem; white-space:nowrap; font-variant-numeric:tabular-nums; }
.desk-row-author:has(.person-signature) { white-space:normal; }
@media (max-width: 560px) {
  #brokers .heading { align-items: flex-start; }
  .broker-company-facts { grid-template-columns: 1fr; gap: 10px; }
}
