/* Work orders. Uses the site.css tokens, panels and buttons shared by the other tools. */
.wo-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.work-orders { display: grid; gap: 20px; min-width: 0; padding-bottom: 2rem; }
.work-orders h2 { margin-top: 0; }
.work-orders h3 { font-size: 1.05rem; margin: 0 0 .5rem; }
.wo-status { margin: 0; min-height: 1.6em; overflow-wrap: anywhere; }
.wo-status[data-state=error] { color: var(--err); font-weight: 600; }
.wo-status[data-state=ok] { color: var(--ok); font-weight: 600; }
.wo-hint { color: var(--muted); font-size: .92rem; margin: .25rem 0 .75rem; }
.wo-step + .wo-step { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Start: trade cards and fill-in modes */
.wo-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }
.wo-card-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 96px; padding: 12px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem; font-weight: 600; text-align: center; cursor: pointer; touch-action: manipulation; }
.wo-card-button[aria-pressed=true] { border: 2px solid var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.wo-card-button:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.wo-icon { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wo-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.wo-mode { flex-direction: column; align-items: flex-start; text-align: left; gap: 4px; padding: 14px 16px; min-height: 88px; white-space: normal; }
.wo-mode span { font-weight: 400; font-size: .88rem; opacity: .9; }

/* Fields */
.wo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 4px 16px; }
.wo-field { display: flex; flex-direction: column; gap: 4px; margin-block: 6px; min-width: 0; }
.wo-field label { font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.work-orders input:not([type=checkbox]):not([type=color]):not([type=file]), .work-orders select, .work-orders textarea { width: 100%; max-width: 100%; min-width: 0; min-height: 44px; padding: .5rem .65rem; font: inherit; font-size: 1rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.work-orders textarea { resize: vertical; }
.work-orders input[type=color] { width: 72px; height: 44px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.work-orders input[type=file] { max-width: 100%; font-size: 1rem; }
.work-orders input[type=file]::file-selector-button { min-height: 44px; padding: 8px 12px; margin-right: 8px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; }
.wo-field:has(> input[type=checkbox]) { flex-direction: row-reverse; justify-content: flex-end; align-items: center; flex-wrap: wrap; min-height: 44px; gap: 10px; }
.wo-field:has(> input[type=checkbox]) .wo-hint, .wo-field:has(> input[type=checkbox]) .wo-error { flex-basis: 100%; order: -1; }
.work-orders input[type=checkbox] { width: 24px; height: 24px; margin: 10px; flex: none; accent-color: var(--brand); }
.work-orders [aria-invalid=true] { border-color: var(--err) !important; box-shadow: 0 0 0 2px var(--err-soft); }
.wo-error { color: var(--err); font-size: .9rem; font-weight: 600; margin: 0; }
.wo-error:empty { display: none; }
.work-orders input:focus-visible, .work-orders select:focus-visible, .work-orders textarea:focus-visible, .work-orders summary:focus-visible, .wo-signature:focus-visible, .wo-jump:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.wo-fieldset { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin: 14px 0; }
.wo-fieldset legend { font-weight: 700; padding: 0 6px; }
.wo-inline { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.wo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 12px; }
.wo-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-block: 10px; background: #fbfcfe; min-width: 0; }
.wo-card h3 { margin-bottom: 4px; }
.wo-total-line { font-weight: 700; margin: 6px 0; }
.wo-totals { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; margin: 14px 0 0; padding: 12px; border-radius: var(--radius-sm); background: var(--brand-soft); }
.wo-totals dt { overflow-wrap: anywhere; }
.wo-totals dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.wo-totals dt:last-of-type, .wo-totals dd:last-of-type { font-size: 1.1rem; padding-top: 6px; border-top: 1px solid var(--brand-line); }
.wo-check { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; border-bottom: 1px solid var(--line); padding-block: 6px; }
.wo-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.wo-thumb { display: block; width: 100%; max-height: 180px; object-fit: contain; background: var(--bg); border-radius: 6px; }
.wo-logo-preview { display: block; max-width: 200px; max-height: 80px; object-fit: contain; margin-block: 8px; }
.wo-signature { display: block; width: 100%; max-width: 560px; aspect-ratio: 900 / 280; height: auto; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: #fff; touch-action: none; cursor: crosshair; }
.wo-toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 0 16px; }

/* Sections as steps */
.wo-section { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-block: 10px; background: var(--surface); }
.wo-section > summary { min-height: 48px; display: flex; align-items: center; padding: 10px 14px; font-weight: 700; cursor: pointer; list-style-position: inside; }
.wo-section[open] > summary { border-bottom: 1px solid var(--line); }
.wo-section-body { padding: 4px 14px 12px; min-width: 0; }

/* Workspace: form left, preview right */
.wo-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.wo-toolbar .wo-actions { margin: 0; }
.wo-more { position: relative; }
.wo-more > summary { min-height: 44px; display: inline-flex; align-items: center; padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; list-style: none; }
.wo-more > summary::-webkit-details-marker { display: none; }
.wo-more[open] > .wo-actions { padding: 10px 0 0; }
.wo-layout { display: grid; gap: 20px; align-items: start; margin-top: 16px; }
.wo-form, .wo-preview { min-width: 0; }
.wo-preview-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.wo-pages { display: flex; flex-direction: column; gap: 14px; padding: 10px; background: #e8edf3; border-radius: var(--radius-sm); min-height: 200px; }
.wo-pages canvas { display: block; width: 100%; height: auto; background: #fff; box-shadow: var(--shadow); }
.wo-jump { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.wo-panel { scroll-margin-top: 80px; }
.wo-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; border-bottom: 1px solid var(--line); padding-block: 10px; }
.wo-row p { margin: 0; overflow-wrap: anywhere; min-width: 0; flex: 1 1 260px; }
.wo-row .wo-actions { margin: 0; }
.wo-scroll { overflow-x: auto; max-width: 100%; margin-block: 12px; }
.wo-error-list { color: var(--err); }
.wo-notes { color: var(--muted); font-size: .92rem; }
.wo-notes p { margin: .3rem 0; }
@media (min-width: 1024px) {
    .wo-layout { grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr); }
    .wo-preview { position: sticky; top: 76px; max-height: calc(100vh - 92px); max-height: calc(100dvh - 92px); overflow: auto; }
    .wo-jump { display: none; }
}
@media (max-width: 600px) {
    .work-orders .panel { padding: 14px; }
    .wo-actions .btn { flex: 1 1 140px; white-space: normal; }
    .wo-check { grid-template-columns: auto minmax(0, 1fr); }
    .wo-check .wo-field:nth-child(3) { grid-column: 1 / -1; }
    .wo-inline { grid-template-columns: 1fr; }
}
@media (hover: hover) {
    .wo-card-button:hover { border-color: var(--brand); }
    .wo-more > summary:hover { border-color: var(--brand); }
}

/* Print: only the rendered pages, at the exact sheet size chosen in the order. */
.wo-print { display: none; }
@page wo-a4-portrait { size: A4 portrait; margin: 0; }
@page wo-a4-landscape { size: A4 landscape; margin: 0; }
@page wo-letter-portrait { size: letter portrait; margin: 0; }
@page wo-letter-landscape { size: letter landscape; margin: 0; }
@media print {
    body.wo-printing > *:not(.wo-print) { display: none !important; }
    body.wo-printing .wo-print { display: block; }
    .wo-print img { display: block; break-after: page; page-break-after: always; }
    .wo-print img:last-child { break-after: auto; page-break-after: auto; }
    .wo-print-a4-portrait img { page: wo-a4-portrait; width: 210mm; height: 297mm; }
    .wo-print-a4-landscape img { page: wo-a4-landscape; width: 297mm; height: 210mm; }
    .wo-print-letter-portrait img { page: wo-letter-portrait; width: 8.5in; height: 11in; }
    .wo-print-letter-landscape img { page: wo-letter-landscape; width: 11in; height: 8.5in; }
    .work-orders, [data-work-order-guide] { display: none !important; }
}
