dialog { color: inherit; }
.drawer { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(760px, 100%); max-width: 100%; padding: 0; border: 0; border-left: 1px solid var(--ctl); background: var(--surface); }
.drawer::backdrop { background: var(--shade); }
.drawer__panel { display: flex; flex-direction: column; height: 100%; }
.drawer__head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--head); }
.drawer__head > div { flex: 1; min-width: 0; }
.drawer__head h2 { font-size: 19px; }
.drawer__head p { margin: 2px 0 0; }
.order-retailer { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--head); }
.order-retailer[hidden] { display: none; }
.order-retailer a { white-space: nowrap; }
.order-tiles { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.order-tiles:not(:has(.order-tile:not([hidden]))) { display: none; }
.order-tile { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--ctl); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.order-tile:hover { background: var(--panel); color: var(--ink); }
.order-tile[hidden] { display: none; }
.order-tile svg { flex: none; width: 28px; height: 28px; fill: none; stroke: var(--link); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.order-tile b { display: block; font-size: 16px; }
.order-tile small { display: block; color: var(--muted); font-size: 13px; }
.drawer__tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.drawer__tools .doc { padding: 0; font-size: 14px; margin-right: 14px; }
.doc-group { display: inline-flex; flex-wrap: wrap; align-items: center; min-height: 24px; }
.doc--share { border: 0; }
a.btn { text-decoration: none; }
.drawer__body { flex: 1; overflow: auto; padding: 14px 16px 24px; min-height: 0; position: relative; overscroll-behavior: contain; }
.drawer__foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.panel { position: sticky; top: var(--top-h, 60px); height: calc(100vh - var(--top-h, 60px)); border-left: 1px solid var(--line); background: var(--surface); min-width: 0; z-index: 5; }
.panel .drawer__head h2 { font-size: 17px; }
.panel #d-title:focus:not(:focus-visible) { outline: none; }
.panel .drawer__tools { gap: 6px 8px; }
.panel .drawer__tools .doc-group { flex-basis: 100%; }
.panel .line-items th, .panel .line-items td { padding: 5px 5px; }
.panel .li-qty input { width: 44px; }
.panel .li-more, .panel .li-color .muted { display: none; }
.panel .drawer__body { padding: 12px 12px 24px; }
@media (max-width: 1180px) {
  .panel { position: fixed; right: 0; bottom: 0; height: auto; width: min(420px, 100%); box-shadow: -4px 0 16px rgba(0, 0, 0, .18); }
}
.fits-sec { border: 1px solid var(--line); background: var(--panel); padding: 10px 12px; }
.drawings { display: grid; gap: 12px; }
.drawing { margin: 0; }
.drawing img { display: block; width: 100%; height: auto; border: 1px solid var(--line); background: #fff; }
.drawing figcaption { margin-top: 3px; font-size: 12px; color: var(--muted); }
.drawing__note { display: block; color: var(--ink-2); }
.fits-sec h3 { font-size: 14px; margin-bottom: 2px; }
.fits__note { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.fits__list { list-style: none; margin: 0 0 10px; padding: 0; border-top: 1px solid var(--line); }
.fit { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 6px 2px; cursor: pointer; }
.fit:hover { background: var(--hover); }
.fit b { color: var(--link); display: block; }
.fit span { font-size: 12px; color: var(--muted); }

.section { margin-bottom: 18px; }
.section h3 { font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 3px; margin-bottom: 8px; }
.order-scroll { overflow-x: auto; position: relative; }
.line-items { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.line-items th, .line-items td { padding: 5px 8px; text-align: left; white-space: nowrap; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.line-items thead th { font-weight: 400; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--ink-2); vertical-align: bottom; }
.line-items .li-group th { background: var(--head); font-weight: 700; font-size: 13px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.line-items tbody + tbody .li-group th { border-top: 10px solid var(--surface); }
.line-items tr[data-img-color] { cursor: pointer; }
.line-items tr[data-img-color]:hover td { background: var(--hover); }
.li-qty, .li-add { width: 1%; }
.line-items thead .li-qty { text-align: right; }
.li-qty input { width: 52px; height: 26px; }
.line-items .add { height: 26px; padding: 0 10px; }
.pick { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; align-items: center; max-width: 560px; }
.pick label { color: var(--muted); }
.pick select { height: 32px; border: 1px solid var(--ctl); background: var(--surface); padding: 0 6px; min-width: 0; width: 100%; }
.pick__out { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--line); background: var(--sub); padding: 8px 10px; }
.pick__out b { font-size: 16px; font-variant-numeric: tabular-nums; }
.specs { width: 100%; border-collapse: collapse; }
.specs th, .specs td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.specs th { font-weight: 400; color: var(--muted); width: 40%; }
.bullets { margin: 0; padding-left: 18px; }
.bullets li { margin-bottom: 2px; }
.note { margin: 0 0 4px; }
.p-img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); background: #fff; }
.img-cap { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.img-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.img-pick__sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.img-btn { display: inline-flex; align-items: center; height: 28px; padding: 0 9px; border: 1px solid var(--ctl); background: var(--surface); cursor: pointer; font-size: 12px; }
.img-btn:hover { background: var(--panel); }
.img-btn[aria-pressed="true"] { border-color: var(--link); background: var(--sel); font-weight: 700; }

.drawer--order { width: min(760px, 100%); }
.order-meta { padding: 4px 16px 12px; border-bottom: 1px solid var(--line); }
.order-meta p { margin: 0 0 6px; }
.order-meta__row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.order-meta__row label { color: var(--muted); }
.order-meta__row input { height: 32px; border: 1px solid var(--ctl); background: var(--surface); padding: 0 8px; min-width: 160px; flex: 1; }
.olist { width: 100%; border-collapse: collapse; }
.olist th { text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); }
.olist td { padding: 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.olist input { width: 60px; height: 30px; border: 1px solid var(--ctl); padding: 0 6px; }
.olist .desc small { display: block; color: var(--muted); font-size: 12px; }
.olist tr.fits-row td { background: var(--panel); padding: 6px 6px 8px 24px; }
.switch { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; font-size: 12px; color: var(--link); white-space: nowrap; margin-top: 4px; }
.switch__track { width: 26px; height: 14px; border-radius: 7px; background: var(--ctl); position: relative; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); transition: left .12s; }
.switch[aria-checked="true"] .switch__track { background: var(--link); }
.switch[aria-checked="true"] .switch__track::after { left: 14px; }
.mini-fits { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mini-fits button { background: none; border: 0; padding: 1px 0; cursor: pointer; color: var(--link); text-align: left; }
.mini-fits button:hover { text-decoration: underline; }
.mini-fits span { color: var(--muted); font-size: 12px; }

.confirm { border: 1px solid var(--ctl); padding: 16px 18px; width: min(440px, calc(100% - 32px)); background: var(--surface); }
.confirm::backdrop { background: var(--shade); }
.confirm h2 { font-size: 16px; margin-bottom: 8px; }
.confirm p { margin: 0 0 8px; }
.confirm__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.viewer { width: 92vw; height: 90vh; max-width: none; max-height: none; margin: auto; padding: 0; border: 1px solid var(--ctl); background: var(--surface); }
.viewer::backdrop { background: rgba(0, 0, 0, .8); }
.viewer[open] { display: flex; }
.viewer__panel { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; }
.viewer__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--head); }
.viewer__title { flex: 1 1 200px; min-width: 0; margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.viewer__bar a.btn { text-decoration: none; }
.viewer__body { flex: 1; min-height: 0; display: flex; overflow: auto; background: var(--panel); overscroll-behavior: contain; }
.viewer__img { display: block; margin: auto; width: 100%; height: 100%; object-fit: contain; background: #fff; cursor: zoom-in; }
.viewer__img.is-zoom { width: auto; height: auto; max-width: none; object-fit: none; cursor: zoom-out; }
.viewer__frame { flex: 1; width: 100%; height: 100%; border: 0; background: #fff; }
.viewer__img[hidden], .viewer__frame[hidden] { display: none; }
.p-img-link { display: block; cursor: zoom-in; }
.drawing a { cursor: zoom-in; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 100; max-width: calc(100% - 32px); }
.toast.is-on { opacity: 1; }

@media (max-width: 860px) {
  .panel { top: 0; bottom: auto; width: 100%; height: 100vh; height: 100dvh; z-index: 20; border-left: 0; box-shadow: none; }
  html:has(.layout.has-panel), html:has(dialog[open]) { overflow: hidden; }
  .viewer { width: 100vw; height: 100vh; height: 100dvh; border: 0; }
  .drawer__head { padding: 8px 12px; }
  .drawer__body { padding: 12px 12px 20px; }
  .drawer__tools { padding: 6px 12px; }
  .drawer__foot { padding: 8px 12px; }
  .section h3 { font-size: 15px; }
  .line-items th, .line-items td, .panel .line-items th, .panel .line-items td { padding: 2px 4px; font-size: 14px; }
  .line-items thead th { padding: 4px; font-size: 12px; }
  .line-items .li-group th { padding: 4px; font-size: 14px; }
  .line-items .li-qty input { width: 56px; height: 44px; }
  .line-items .add { height: 44px; padding: 0 12px; }
  .line-items .copy { min-width: 36px; padding: 0 11px; }
  .doc-group { min-height: 44px; }
  .drawer__tools .doc { min-height: 44px; padding-right: 10px; display: inline-flex; align-items: center; }
  .drawer__tools .btn { min-height: 44px; }
  .pick select { height: 44px; }
  .img-btn { min-height: 44px; font-size: 14px; }
  .fit { min-height: 44px; padding: 8px 2px; }
  .fit span, .fits__note, .drawing figcaption, .img-cap, .olist .desc small, .mini-fits span { font-size: 13px; }
  .switch { min-height: 44px; font-size: 14px; margin-top: 0; }
  .mini-fits button { min-height: 44px; padding: 0; }
  .order-meta { padding: 4px 12px 12px; }
  .order-meta__row input { height: 44px; }
  .olist input { width: 72px; height: 44px; }
}

@media (max-width: 600px) {
  .order-tiles { padding: 10px 12px; gap: 8px; }
  .order-tile { padding: 10px; gap: 8px; }
  .order-tile small { display: none; }
  .order-retailer a { display: inline-flex; align-items: center; min-height: 44px; }
  .order-meta__row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .order-meta__row label { margin-top: 8px; }
  .order-meta__row label:first-child { margin-top: 0; }
  .order-meta__row input { width: 100%; min-width: 0; }
  .olist, .olist tbody, .olist tr, .olist td { display: block; }
  .olist thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .olist tr:not(.fits-row) { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
  .olist td { padding: 0; border: 0; }
  .olist tr:not(.fits-row) > td:first-child { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  .olist tr:not(.fits-row) > td:first-child::before { content: "Qty"; display: block; font-size: 12px; line-height: 1.3; color: var(--muted); }
  .olist .part { grid-column: 2; grid-row: 1; font-weight: 700; overflow-wrap: anywhere; }
  .olist tr:not(.fits-row) > td:last-child { grid-column: 3; grid-row: 1; }
  .olist .desc { grid-column: 2 / -1; grid-row: 2; }
  .olist tr.fits-row { border-bottom: 1px solid var(--line-soft); }
  .olist tr.fits-row td { padding: 6px 8px 8px 12px; }
  .line-items thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .line-items, .line-items tbody { display: block; }
  .line-items tr { display: flex; flex-wrap: wrap; align-items: center; padding: 2px 0; border-bottom: 1px solid var(--line-soft); }
  .line-items th, .line-items td, .panel .line-items th, .panel .line-items td { display: block; border: 0; padding: 0 8px 0 4px; }
  .line-items .li-group { padding: 0; border-bottom: 0; }
  .line-items .li-group th { flex: 1 1 100%; padding: 4px; }
  .line-items .li-color { order: 0; flex: 1 1 100%; min-width: 0; }
  .line-items .li-part { order: 1; flex: 1 1 0; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .line-items .li-qty { order: 2; width: auto; padding-right: 8px; }
  .line-items .li-add { order: 3; width: auto; padding-right: 0; }
  .line-items tr[data-img-color]:hover { background: var(--hover); }
  .line-items tr[data-img-color]:hover td { background: none; }
}

@media print {
  @page { size: letter; margin: 0.5in; }
  html.printing-order body > *:not(.print-order) { display: none !important; }
  html.printing-order .print-order { display: block; color: #000; font: 11pt/1.4 var(--font); }
  .print-order table { width: 100%; border-collapse: collapse; }
  .print-order th, .print-order td { border: 1px solid #888; padding: 4px 6px; text-align: left; }
  .bom-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
  .bom-head img { width: 44px; height: auto; }
  .bom-head h1 { font-size: 16pt; margin: 0; }
  .bom-meta { margin: 2px 0 0; font-size: 9pt; color: #333; }
  .bom-table { margin-bottom: 14px; }
  .bom-table th, .bom-table td { font-size: 9.5pt; }
  .pblock { border: 1px solid #888; padding: 8px 10px; margin-bottom: 10px; break-inside: avoid; page-break-inside: avoid; }
  .pblock h3 { font-size: 11pt; margin: 0 0 6px; }
  .pblock__specs { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
  .pblock__specs th { width: 30%; color: #333; font-weight: 400; }
  .pblock__specs th, .pblock__specs td { border: 1px solid #ccc; padding: 3px 6px; }
  .pblock__features { margin: 4px 0 0; padding-left: 16px; font-size: 9pt; }
  .bom-foot { margin-top: 10px; font-size: 8.5pt; color: #333; }
  html:not(.printing-order) dialog[open] { display: none !important; }
  html:not(.printing-order) .toast,
  html:not(.printing-order) .stale,
  html:not(.printing-order) .theme-btn,
  html:not(.printing-order) .order-btn,
  html:not(.printing-order) .help-link,
  html:not(.printing-order) .filters-btn { display: none !important; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.drawer { transform: translateX(48px); opacity: 0;
    transition: transform 240ms cubic-bezier(.2, .7, .2, 1), opacity 200ms cubic-bezier(.2, .7, .2, 1),
      overlay 240ms allow-discrete, display 240ms allow-discrete; }
  dialog.drawer[open] { transform: none; opacity: 1; }
  @starting-style { dialog.drawer[open] { transform: translateX(48px); opacity: 0; } }
  dialog.drawer::backdrop { background-color: transparent;
    transition: background-color 240ms, overlay 240ms allow-discrete, display 240ms allow-discrete; }
  dialog.drawer[open]::backdrop { background-color: var(--shade); }
  @starting-style { dialog.drawer[open]::backdrop { background-color: transparent; } }
  dialog.viewer, dialog.confirm { opacity: 0; transform: scale(.98);
    transition: transform 200ms cubic-bezier(.2, .7, .2, 1), opacity 200ms,
      overlay 200ms allow-discrete, display 200ms allow-discrete; }
  dialog.viewer[open], dialog.confirm[open] { opacity: 1; transform: none; }
  @starting-style { dialog.viewer[open], dialog.confirm[open] { opacity: 0; transform: scale(.98); } }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
