/* Sell & Trade: the customer's builder and submissions (/sell-trade) and the staff workspace (/trade-admin).
   Built on the site's tokens (styles.css), so light and dark both work; mobile first. */

[data-trade-root], [data-trade-admin], [data-body], [data-view] { display: grid; gap: 16px; min-width: 0; }
[data-trade-root] > *, [data-trade-admin] > *, [data-body] > *, [data-view] > * { min-width: 0; }
.s-wide { max-width: 1240px; }
.tr-gate { display: grid; gap: 10px; justify-items: start; padding: 22px; }
.tr-gate h3 { margin: 0; font: 700 20px/1.2 var(--font-display); }
.tr-gate p { margin: 0; color: var(--text-2); max-width: 60ch; }
.tr-err { margin: 0; color: var(--bad); font-weight: 600; font-size: 14px; }
.tr-ok { color: var(--good); font-weight: 800; }
.tr-prelim { margin: 0; padding: 10px 12px; border-left: 3px solid var(--warn); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: color-mix(in srgb, var(--warn) 10%, var(--surface)); color: var(--text-2); font-size: 14px; }
.tr-prelim strong { color: var(--text); }
.tr-tabs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tr-h { margin: 0 0 12px; display: flex; align-items: center; gap: 10px; font: 700 18px/1.2 var(--font-display); }
.tr-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-grad); color: var(--accent-ink); font: 800 13px/1 var(--font-display); flex: none; }
.tr-count { color: var(--muted); font: 600 14px/1 Inter, system-ui, sans-serif; }
.tr-step, .tr-sec { display: grid; gap: 12px; align-content: start; grid-template-columns: minmax(0, 1fr); }
.tr-sec > h3 { margin: 0; font: 700 17px/1.2 var(--font-display); }
.tr-sec h4 { margin: 0; font: 700 15px/1.2 var(--font-display); }

/* ---- builder ---- */
.tr-builder { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.tr-main, .tr-side { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 960px) { .tr-builder { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); align-items: start; } .tr-side { position: sticky; top: 88px; } }
.tr-search { display: grid; gap: 6px; }
.tr-row { display: flex; gap: 8px; }
.tr-row input { flex: 1 1 auto; min-width: 0; }
.tr-row3 { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .tr-row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tr-results, .tr-lines, .tr-list, .tr-qlist, .tr-past, .tr-insp { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tr-result { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.tr-result-text { display: grid; gap: 2px; min-width: 0; }
.tr-result-text strong, .tr-line-title strong { overflow-wrap: anywhere; }
.tr-result-text small, .tr-line-title small, .tr-card small, td small { color: var(--muted); font-size: 12px; }
.tr-result-price { font-weight: 700; font-size: 14px; }
.tr-thumb { display: block; width: 44px; height: 60px; border-radius: 4px; overflow: hidden; background: var(--surface-3); flex: none; }
.tr-thumb img, .tr-thumb .thumb-ph { width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; }
.tr-line { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tr-line-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.tr-line-title { display: grid; gap: 2px; min-width: 0; }
.tr-line-value { font-size: 13px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.tr-remove { min-height: 36px; }
.tr-fields { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .tr-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tr-fields label { min-width: 0; }
.tr-fields select, .tr-fields input { width: 100%; }
.tr-line-foot { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; }
.tr-qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.tr-qty button { min-height: 40px; min-width: 40px; padding: 0; border: 0; background: transparent; font-size: 18px; }
.tr-qty span { min-width: 34px; text-align: center; font-weight: 700; }
.tr-photos { display: flex; flex-wrap: wrap; gap: 10px; }
.tr-photo { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border: 1px dashed var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text-2); }
.tr-photo.is-needed { border-color: var(--warn); }
.tr-photo em { color: var(--warn); font-style: normal; font-weight: 700; }
.tr-photo img { border-radius: 4px; object-fit: cover; }
.tr-file { position: relative; display: inline-flex; align-items: center; min-height: 36px; padding: 4px 10px; border: 1px solid var(--accent); border-radius: var(--radius-sm); color: var(--accent-text); font-weight: 700; cursor: pointer; }
.tr-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; font-size: 0; }
.tr-file:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.tr-totals, .tr-facts { display: grid; gap: 6px; margin: 0; }
.tr-totals > div, .tr-facts > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.tr-totals > div.is-picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.tr-totals dt, .tr-facts dt { color: var(--text-2); font-size: 14px; }
.tr-totals dd, .tr-facts dd { margin: 0; font: 700 18px/1.2 var(--font-display); text-align: right; }
.tr-facts dd { font-size: 15px; font-family: Inter, system-ui, sans-serif; }
.tr-totals dd small { display: block; font: 600 12px/1.3 Inter, system-ui, sans-serif; }
.is-down { color: var(--bad); } .is-up { color: var(--good); }
.tr-fs { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.tr-fs legend { padding: 0; margin-bottom: 6px; font-weight: 700; color: var(--text); }
.tr-choice { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; }
.tr-choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.tr-choice input { width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; accent-color: var(--accent); }
.tr-choice small { display: block; color: var(--muted); font-size: 12px; }
.tr-choice strong { font-size: 15px; }
.tr-address { display: grid; gap: 10px; }
.tr-address input, .tr-step textarea, .tr-form textarea, .tr-form input, .tr-form select, .tr-inline input, .tr-inline select { width: 100%; }
textarea { font-size: max(16px, 1em); border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); padding: 10px 12px; font-family: inherit; resize: vertical; }
.tr-submit { width: 100%; min-height: 52px; font: 700 16px/1.1 var(--font-display); }

/* ---- the customer's list and detail ---- */
.tr-card { width: 100%; display: grid; gap: 4px; text-align: left; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tr-card:hover { border-color: var(--accent); }
.tr-card-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; }
.tr-card-mid { color: var(--text-2); font-size: 14px; }
.tr-card-low { color: var(--text); font-size: 14px; font-weight: 600; }
.tr-detail-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tr-detail-h { margin: 0; font: 700 24px/1.1 var(--font-display); letter-spacing: 0.02em; }
.tr-steps { list-style: none; margin: 0; padding: 0 0 4px; display: flex; gap: 4px; overflow-x: auto; max-width: 100%; }
.tr-steps li { flex: 1 0 74px; display: grid; gap: 6px; justify-items: center; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.tr-dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--accent-ink); }
.tr-steps .is-done { color: var(--text-2); }
.tr-steps .is-done .tr-dot { background: var(--accent); border-color: var(--accent); }
.tr-ship-to { padding: 12px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.tr-ship-to address { font-style: normal; margin: 6px 0; line-height: 1.5; }
.tr-timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: grid; gap: 10px; }
.tr-timeline li { position: relative; display: grid; gap: 2px; }
.tr-timeline li::before { content: ''; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.tr-timeline small { color: var(--muted); }
.tr-insp li { display: grid; gap: 4px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.tr-offer { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.tr-offer h4 { margin: 0; font: 700 16px/1.2 var(--font-display); }
.tr-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.tr-actions button { flex: 1 1 200px; white-space: normal; }
.tr-confirm { padding: 12px; border: 1px solid var(--warn); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); display: grid; gap: 10px; }
.tr-confirm p { margin: 0; font-weight: 600; }
.tr-inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.tr-inline label { flex: 1 1 200px; min-width: 0; }
.tr-ro .tr-line { background: var(--surface-2); }

/* ---- staff workspace ---- */
.tr-ops-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tr-ops-tabs { flex-wrap: wrap; }
.tr-queues { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .tr-queues { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .tr-queues { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tr-queue { display: grid; gap: 8px; align-content: start; }
.tr-queue.is-key { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tr-queue h3 { margin: 0; display: flex; justify-content: space-between; gap: 8px; align-items: center; font: 700 16px/1.2 var(--font-display); }
.tr-qrow { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.tr-qrow > span { min-width: 0; overflow-wrap: anywhere; }
.tr-qrow small { display: block; color: var(--muted); }
.tr-qrow button.primary, .tr-qrow button { min-height: 36px; padding: 4px 12px; }
.tr-age { color: var(--muted); font-size: 12px; }
.tr-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tr-table { font-size: 13px; min-width: 560px; }
.tr-table th { text-align: left; padding: 8px 10px; color: var(--muted); font: 700 12px/1 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tr-table th.r, .tr-table td.r { text-align: right; font-variant-numeric: tabular-nums; }
.tr-table td { padding: 8px 10px; }
.tr-table small { display: block; }
.tr-form { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tr-insp-form { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.tr-check { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.tr-check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.tr-two { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 960px) { .tr-two { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.tr-two > div { display: grid; gap: 14px; min-width: 0; align-content: start; }
.tr-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tr-tile { display: grid; gap: 2px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.tr-tile span { color: var(--muted); font: 700 12px/1.2 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; }
.tr-tile strong { font: 700 22px/1.2 var(--font-display); }
.tr-tile small { color: var(--text-2); font-size: 12px; }
.tr-settings { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .tr-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tr-toast { position: fixed; z-index: 60; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: min(92vw, 520px); padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.tr-toast.is-bad { border-color: var(--bad); color: var(--bad); }
.chip.bad, .chip.warn, .chip.good { font-weight: 700; }

/* Every grid in here may shrink below its content, so nothing on a phone can push the page wider. */
.tr-offer, .tr-totals, .tr-facts, .tr-queue, .tr-form, .tr-insp li, .tr-insp-form, .tr-tile, .tr-line, .tr-ship-to, .tr-confirm, .tr-fs, .tr-address, .tr-search { grid-template-columns: minmax(0, 1fr); }
.tr-totals > div, .tr-facts > div { flex-wrap: wrap; }
.tr-totals dt, .tr-totals dd, .tr-facts dt, .tr-facts dd { min-width: 0; overflow-wrap: anywhere; }

/* A chip that holds a sentence (a notice, not a label) wraps like text. */
p.chip { display: block; margin: 0; padding: 8px 10px; border-radius: var(--radius-sm); white-space: normal; font-size: 13px; line-height: 1.4; }
.tr-sec .chip, .tr-offer .chip { overflow-wrap: anywhere; }

/* Trade credit (customer): the balance, what is waiting for approval, and the statement. */
.tr-credit { display: grid; gap: 12px; margin-bottom: 16px; grid-template-columns: minmax(0, 1fr); }
.tr-credit > h3 { margin: 0; font: 700 17px/1.2 var(--font-display); }
.tr-credit-nums { display: grid; gap: 10px; margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tr-credit-nums > div { display: grid; gap: 2px; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.tr-credit-nums > div.is-main { border-color: var(--accent); }
.tr-credit-nums dt { color: var(--muted); font: 700 12px/1.2 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; }
.tr-credit-nums dd { margin: 0; font: 700 26px/1.15 var(--font-display); overflow-wrap: anywhere; }
.tr-credit-pending h4 { margin: 0 0 6px; font: 700 15px/1.2 var(--font-display); }
.tr-credit-pending ul, .tr-stmt ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tr-credit-pending li, .tr-stmt-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tr-credit-pending li > span, .tr-stmt-what { min-width: 0; overflow-wrap: anywhere; }
.tr-stmt summary { cursor: pointer; font-weight: 700; }
.tr-stmt ul { margin-top: 10px; }
.tr-stmt-what, .tr-stmt-amt { display: grid; gap: 2px; }
.tr-stmt-what small, .tr-stmt-amt small { color: var(--muted); font-size: 12px; font-weight: 400; }
.tr-stmt-amt { text-align: right; font: 700 16px/1.2 var(--font-display); white-space: nowrap; }
.tr-stmt-amt.is-pos { color: var(--good); }
.tr-stmt-amt.is-neg { color: var(--bad); }

/* Process tab: slow rows stand out, and the long tables scroll on their own, not the page. */
.tr-table tr.is-slow td { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.tr-bad { color: var(--bad); }
.tr-steps-table { min-width: 720px; }
.tr-sec details { margin-top: 4px; }
.tr-sec summary { cursor: pointer; font-weight: 700; }

/* Customers tab. */
.tr-customers td small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.tr-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tr-tags .chip .link { margin-left: 4px; padding: 0 2px; }
.tr-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tr-note { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tr-note.is-pinned { border-color: var(--accent); }
.tr-note p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.tr-note small { color: var(--muted); }
.tr-note-acts { display: flex; gap: 12px; }
.tr-timeline .tr-qrow > span:first-child { min-width: 0; overflow-wrap: anywhere; }

/* Inventory and Revenue tabs. */
.tr-inventory td small, .tr-table td small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.tr-row-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 190px; }
.tr-row-acts select { max-width: 170px; }
.tr-table tr.is-voided td { opacity: 0.55; }
.tr-actions { display: flex; flex-wrap: wrap; gap: 10px; }
[data-sale-for] { scroll-margin-top: 96px; }

/* Shows tab: a row of fields for each card in a deal, and the form that changes with the kind of deal. */
.tr-dealrow { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); padding: 8px 0; border-bottom: 1px dashed var(--border); }
@media (min-width: 720px) { .tr-dealrow { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1.4fr); } .tr-dealrow-in { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1.2fr); } }
.tr-deal [data-for] { display: grid; gap: 8px; align-content: start; }
.tr-deal[data-kind="sale"] [data-for]:not([data-for~="sale"]), .tr-deal[data-kind="buy"] [data-for]:not([data-for~="buy"]), .tr-deal[data-kind="trade"] [data-for]:not([data-for~="trade"]) { display: none; }
.tr-preview { min-height: 1.4em; font-weight: 700; }
.tr-sku { font-family: var(--font-mono, ui-monospace, monospace); letter-spacing: 0.04em; }
.tr-table tr.is-selected td { background: color-mix(in srgb, var(--accent, #3b82f6) 10%, transparent); }

/* Sales sync tab */
.tr-mapping { display: grid; gap: 8px; }
.tr-mapping select { width: 100%; }
.tr-checks { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.tr-checks li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tr-inline-form { display: inline-flex; gap: 6px; align-items: center; }
.tr-inline-form input { width: 9ch; }
.tr-inline-label { display: inline-flex; gap: 6px; align-items: center; }
.tr-inline-label input { width: 8ch; }
.tr-lines td { vertical-align: top; }

/* Board rows keep their buttons small; the second-factor panel shows its QR code at a size a phone can scan */
.tr-qrow .tr-actions { gap: 8px; }
.tr-qrow .tr-actions button { flex: 0 0 auto; }
.tr-mfa form { width: min(100%, 360px); }
.tr-mfa img { background: #fff; padding: 8px; border-radius: var(--radius-sm); }
.tr-mfa code { overflow-wrap: anywhere; }

/* The case page: whose turn it is, what is in the way, the customer's note, and the merged timeline. */
.tr-case-head { gap: 8px; }
.tr-court, .tr-flags { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tr-blockers { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.tr-blockers li { padding: 8px 10px; border-left: 3px solid var(--warn); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: color-mix(in srgb, var(--warn) 10%, var(--surface)); font-size: 14px; }
.tr-cust-note blockquote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--border); color: var(--text-2); overflow-wrap: anywhere; }
.tr-merged li > .chip { justify-self: start; }
.tr-merged li > span:not(.chip) { color: var(--text-2); overflow-wrap: anywhere; }

/* Custody: the receiving screen, the count form and the moves on a case. */
.tr-scan label { flex: 1 1 280px; }
.tr-scan input { font-size: 18px; letter-spacing: .04em; }
.tr-count .tr-qrow input[type=number] { width: 5.5em; }
.tr-custody-actions { margin-top: 6px; }
.tr-custody-actions summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.tr-custody-actions form { margin-top: 8px; }
