/* Stone: one small stylesheet. Plain, dense and readable; it's a work tool. */
:root {
  --bg: #f6f5f2; --surface: #fff; --text: #1d1d1b; --muted: #6b6a66; --line: #e3e1db;
  --accent: #e8714a; --accent-ink: #fff; --ok: #2f7d4f; --warn: #a86a00; --bad: #b03a2e;
  --radius: 10px; --gap: 16px;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 var(--gap); }
h2 { font-size: 1rem; margin: 0 0 12px; }

.topbar { display: flex; align-items: center; gap: var(--gap); padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .02em; text-decoration: none; }
.brand::before { content: ""; display: inline-block; width: .7em; height: .7em; border-radius: 50%;
  background: var(--accent); margin-right: .45em; vertical-align: -.02em; }
.nav { display: flex; gap: 12px; }
.search { flex: 1; min-width: 200px; max-width: 460px; }
.search input { width: 100%; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font: inherit; }
.user { display: flex; align-items: center; gap: 12px; margin-left: auto; color: var(--muted); font-size: .9rem; }
.user form { margin: 0; }

.page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px; }
.page.page-wide { max-width: 1480px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--gap); }
.eyebrow { margin: 0; color: var(--muted); font-size: .85rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: var(--gap); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); align-items: start; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; }
.table td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

.stats { display: flex; gap: var(--gap); flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; min-width: 180px; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .9rem; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--gap); margin: 0 0 var(--gap); }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 0; font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .85rem; padding-top: 1px; }
.note { margin: 4px 0 0; white-space: normal; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.badge.at_customer, .badge.closed, .badge.shipped { color: var(--ok); }
.badge.back_for_repair, .badge.received, .badge.in_repair, .badge.open { color: var(--warn); }
.badge.scrapped { color: var(--bad); }

.button { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font: inherit; font-weight: 600; cursor: pointer; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.wide { width: 100%; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-decoration-color: var(--line); cursor: pointer; }

.signin { max-width: 380px; margin: 12vh auto 0; text-align: center; padding: 32px; }
.messages { list-style: none; padding: 0; margin: 0 0 var(--gap); }
.messages li { padding: 10px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.messages li.error { border-color: var(--bad); color: var(--bad); }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .page { padding: 16px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}

/* Navigation, tabs, forms, workflow steps */
.nav a { text-decoration: none; color: var(--muted); padding: 4px 2px; }
.nav a[aria-current="page"], .nav a:hover { color: var(--text); box-shadow: inset 0 -2px var(--accent); }
.tabs { display: flex; gap: 14px; margin: 0 0 12px; }
.tabs a { text-decoration: none; color: var(--muted); padding-bottom: 4px; }
.tabs a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px var(--accent); }
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.actions-row { display: flex; gap: 8px; align-items: center; }
.button.danger { color: var(--bad); }
.form { display: grid; gap: 14px; max-width: 640px; }
.field { display: grid; gap: 4px; }
.field-label { font-weight: 600; font-size: .9rem; }
.field-help { color: var(--muted); font-size: .82rem; }
.field-error { color: var(--bad); font-size: .85rem; }
input:not([type=search]):not([type=checkbox]):not([type=radio]), select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); width: 100%; }

/* Sign-in and 2FA pages, including allauth's own markup */
.auth-page { max-width: 440px; margin: 10vh auto 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 32px; }
.auth-page h1 { font-size: 1.4rem; }
.auth-page form { display: grid; gap: 12px; }
.auth-page button { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.auth-page button.link { background: none; border: 0; color: inherit; padding: 0; font-weight: 400; }
.auth-page img, .auth-page svg { max-width: 220px; height: auto; display: block; margin: 8px auto; }
.auth-page label { font-weight: 600; font-size: .9rem; display: grid; gap: 4px; }
.auth-page code, .auth-page input[readonly] { font-family: ui-monospace, monospace; font-size: .85rem; }
.auth-page ul.errorlist { color: var(--bad); padding-left: 18px; margin: 0; }

/* Returns workflow */
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 120px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--gap); }
.step { border-left: 3px solid var(--line); padding-left: 12px; }
.step.current { border-color: var(--accent); }
.step.done { border-color: var(--ok); }
.step p { margin: 4px 0 8px; }
.step form { margin: 0; }
.stack dt { color: var(--muted); font-size: .8rem; margin-top: 8px; }
.stack dd { margin: 0; }
.messages li.success { border-color: var(--ok); color: var(--ok); }
@media (min-width: 900px) { .columns:has(.wide-col) { grid-template-columns: 2fr 1fr; } }

/* Home screen apps */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap); }
.app { display: flex; flex-direction: column; gap: 4px; min-height: 130px; padding: 18px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
a.app:hover { border-color: var(--accent); }
.app-name { font-weight: 700; font-size: 1.05rem; }
.app-count { font-size: 1.8rem; font-weight: 700; margin-top: auto; }
.app-note { color: var(--muted); font-size: .85rem; }
.app.soon { background: transparent; border-style: dashed; }
.app.soon .app-note { margin-top: auto; }

/* Documents */
.tabs-row { display: flex; gap: var(--gap); align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: var(--gap); }
.filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter input, .filter select { width: auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.num { text-align: right; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; }
.totals td { border-bottom: 0; }
.totals td:first-child { text-align: right; color: var(--muted); }
.lines-edit td { padding: 4px; }
.lines-edit input, .lines-edit select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--surface); }
.lines-edit .narrow { width: 90px; }
.lines-edit input[type=checkbox] { width: auto; }
.badge.draft, .badge.created, .badge.sent, .badge.issued { color: var(--warn); }
.badge.accepted, .badge.complete, .badge.sent_to_odoo, .badge.posted, .badge.paid { color: var(--ok); }
.badge.declined { color: var(--bad); }
.warning-text { color: var(--bad); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.choices { display: flex; gap: 20px; flex-wrap: wrap; }
.choices label { display: inline-flex; align-items: center; gap: 6px; }
.choices input { width: auto; margin: 0; }
.badge.planned, .badge.in_progress { color: var(--warn); }
.badge.done { color: var(--ok); }
.badge.cancelled { color: var(--muted); }

/* Returns: condition colours, overview bar, lookups */
[hidden] { display: none !important; }
.lookup input[type=search] { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); width: 100%; }
:root { --grey: #a3a19b; --green: #2f9a5a; --yellow: #e2b100; --red: #c8382b; --black: #1d1d1b; }
.dot { display: inline-block; width: .8em; height: .8em; border-radius: 50%; background: var(--grey); vertical-align: -.05em; }
.dot.big { width: .7em; height: .7em; }
.dot.green, .condbar .green { background: var(--green); }
.dot.yellow, .condbar .yellow { background: var(--yellow); }
.dot.red, .condbar .red { background: var(--red); }
.dot.black, .condbar .black { background: var(--black); }
.condbar .grey { background: var(--grey); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.overview { padding: 12px 18px; display: flex; flex-direction: column; gap: 12px; }
.ov-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.overview .count { min-width: 2.6em; padding: 5px 12px; text-align: center; font-size: 1rem; }
.overview .count.zero { background: var(--bg); color: var(--muted); }
.overview .count.current { outline: 2px solid var(--accent); outline-offset: 2px; }
.ov-of { color: var(--muted); font-weight: 600; margin: 0 10px 0 2px; }
.pill-cal { padding: 5px 14px; border-radius: 999px; font-weight: 700; background: var(--bg); color: var(--muted); }
.pill-cal.done { background: #e6f4ea; color: var(--ok); }
.type-chip { padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; background: var(--surface); }
.type-chip b { color: var(--muted); margin-left: 4px; }
.type-chip.current { background: #1f3354; border-color: #1f3354; color: #fff; }
.type-chip.current b { color: #fff; }
.returns-table td:first-child { width: 1%; white-space: nowrap; }
.returns-table tr.closed td { color: var(--muted); }
.jobs .job { white-space: nowrap; }
.jobs form.inline { margin-left: 2px; }
.remove-job { text-decoration: none; padding: 0 4px; }
.add-repair { margin-top: 4px; }
details.add-repair[open] > summary { margin-bottom: 6px; }
.repair-form { display: flex; flex-direction: column; gap: 6px; max-width: 280px; margin: 0; }
.repair-add { display: flex; gap: 6px; }
.repair-add input { flex: 1; }
.overview-table { border-collapse: collapse; width: 100%; }
.overview-table th, .overview-table td { padding: 4px 8px; text-align: center; white-space: nowrap; }
.overview-table tbody th { text-align: left; font-weight: 600; }
.overview-table tbody tr.current th a { box-shadow: inset 0 -2px var(--accent); text-decoration: none; }
.overview-table .totals-row th, .overview-table .totals-row td { border-top: 1px solid var(--line); }
.overview-table .bar-col { width: 40%; }
.count { display: inline-block; min-width: 2em; padding: 1px 8px; border-radius: 999px; font-weight: 700; text-decoration: none;
  background: var(--grey); color: #fff; }
.count.green { background: var(--green); }
.count.yellow { background: var(--yellow); color: var(--black); }
.count.red { background: var(--red); }
.count.black { background: var(--black); }
.count.zero { background: none; color: var(--line); }
.condbar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--bg); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 0; }
.button.small { padding: 5px 10px; font-size: .85rem; }
.lookup { position: relative; flex: 2; min-width: 200px; }
.lookup-results { position: absolute; z-index: 2; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.08); max-height: 320px; overflow: auto; }
.lookup-results li { padding: 7px 12px; cursor: pointer; }
.lookup-results li[aria-selected="true"] { background: var(--bg); box-shadow: inset 3px 0 var(--accent); }
.lookup-results li.none { color: var(--muted); cursor: default; }
.lookup-message:empty { display: none; }
.lookup-results li.group { padding: 8px 12px 2px; color: var(--muted); font-size: .78rem; cursor: default; }
.product-pick { min-width: 280px; }
.product-pick > .part-number { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); margin: 0; pointer-events: none; }
.chosen { display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; background: var(--bg); border-radius: 8px; }
.wide-form { max-width: 980px; }
.form-section { display: grid; gap: 10px; }
.form-section h2 { margin: 0; font-size: 1.1rem; }
.form-section p { margin: 0; }
.badge.warn { color: var(--warn); }
.inline-form .narrow { max-width: 90px; min-width: 70px; flex: 0; }
.inline-form .picked { flex-basis: 100%; margin: 0; }
.inline-form .picked:empty { display: none; }
.readings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.items-table td:first-child { width: 1%; }
@media (max-width: 640px) { .overview-table .bar-col { display: none; } }
.facts dd { margin: 2px 0 0; }
.facts .span-2 { grid-column: span 2; }
.inline-form.tight { margin: 0; }
@media (max-width: 640px) { .facts .span-2 { grid-column: auto; } }
.facts .span-2 dd { font-weight: 400; }
.facts:last-child { margin-bottom: 0; }
.new-contact { margin: 0 0 12px; }
.new-contact summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.other-products { margin: 12px 0; }
.other-products summary { cursor: pointer; font-weight: 600; padding: 8px 0; }

/* Returns: colour dots you click, fixes as chips, retained items */
.dots { display: flex; gap: 8px; margin: 0; padding: 2px 4px; }
.dot-btn { display: inline-block; width: 22px; height: 22px; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--surface); border: 3px solid var(--grey); }
.dot-btn.green { border-color: var(--green); }
.dot-btn.yellow { border-color: var(--yellow); }
.dot-btn.red { border-color: var(--red); }
.dot-btn.black { border-color: var(--black); }
.dot-btn:hover, .dot-btn:focus-visible { transform: scale(1.15); }
.dot-btn[aria-pressed="true"], .dot-choices input:checked + .dot-btn { background: var(--grey); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.dot-btn.green[aria-pressed="true"], .dot-choices input:checked + .dot-btn.green { background: var(--green); }
.dot-btn.yellow[aria-pressed="true"], .dot-choices input:checked + .dot-btn.yellow { background: var(--yellow); }
.dot-btn.red[aria-pressed="true"], .dot-choices input:checked + .dot-btn.red { background: var(--red); }
.dot-btn.black[aria-pressed="true"], .dot-choices input:checked + .dot-btn.black { background: var(--black); }
.dots.busy { opacity: .5; pointer-events: none; }
.dot-choices { display: flex; gap: 8px; align-items: center; }
.dot-choices label { display: inline-flex; cursor: pointer; }
.dot-choices input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dot-choices input:focus-visible + .dot-btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.dot-choices .dot-btn { width: 28px; height: 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips form { margin: 0; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font: inherit; font-size: .9rem; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.add-fix { display: grid; gap: 8px; margin-bottom: 8px; }
.history-entry { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.history-entry form { margin: 0; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: .9rem; }
.check input { width: auto; margin: 0; }
.badge.retained { color: var(--text); }
.items-table tr.retained td { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.retain-form { margin: 4px 0 0; }
.retain-form .link { color: var(--muted); font-size: .85rem; }
.items-table td:first-child { white-space: nowrap; }

/* Mail */
.tag-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.tag-chip { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
a.tag-chip { color: inherit; text-decoration: none; }
a.tag-chip:hover { border-color: var(--accent); }
.snippet { color: var(--muted); }
.how p { margin: 0; }
.email { padding: 14px 18px; }
.email.out { border-left: 3px solid var(--accent); }
.email-head { display: flex; justify-content: space-between; gap: var(--gap); margin-bottom: 10px; }
.email-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.email-frame { width: 100%; min-height: 320px; height: 420px; border: 0; resize: vertical; overflow: auto; }
.quoted { margin-top: 8px; }
.quoted .email-text { color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; }
.attachments { list-style: none; padding: 8px 0 0; margin: 8px 0 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 12px; }
.unknown + .unknown, .list + .unknown { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.unknown .form { gap: 8px; }
.ignore { margin-top: 6px; }
.form-row { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 12px; }
.link-search input { flex: 1; min-width: 160px; }
.tag-form { margin-top: 8px; }
.mail-table td:first-child { width: 55%; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } .email-head { flex-direction: column; } }

/* Inventory: product name first, part number after it, smaller */
.product-name { font-weight: 600; }
.part-number { color: var(--muted); font-size: .8em; font-weight: 400; margin-left: 6px; }
h1 .part-number { font-size: .6em; }
.stock-table td:last-child { width: 1%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
form[data-ajax].busy { opacity: .5; pointer-events: none; }

/* Quote progress: one row of stages, then the single next action */
.stages { display: flex; gap: 0; list-style: none; margin: 0 0 var(--gap); padding: 0; }
.stages li { flex: 1; padding: 10px 12px; border-bottom: 3px solid var(--line); color: var(--muted); font-weight: 600; }
.stages li.done { border-color: var(--ok); color: var(--text); }
.stages li.done::before { content: "✓ "; color: var(--ok); }
.stages li.current { border-color: var(--accent); color: var(--text); }
.stages li.stopped { border-color: var(--bad); color: var(--bad); }
.next-step .inline-form { margin: 0; }
.next-step .secondary { margin-top: 10px; gap: 16px; }
.next-step .inline-form input { flex: 0 1 260px; }
.next-step .file-pick input { flex: 0 1 220px; font-size: .85rem; }
.next-step .close-order summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.next-step .close-order .inline-form { margin-top: 8px; }
.next-step .changed { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.next-step .proforma-pick { display: inline-flex; gap: 6px; align-items: center; }
.next-step .proforma-pick input { flex: 0 0 70px; width: 70px; min-width: 0; padding: 4px 6px; }
.lines-edit .hs { width: 130px; }

/* Returns: to-do list, costs and warranty */
.job.done { color: var(--muted); }
.todo-table tr.done td:nth-child(2) { color: var(--muted); }
.todo-table input[name=price] { width: 90px; max-width: 90px; text-align: right; }
.todo-table td:first-child, .todo-table td:last-child { width: 1%; }
.costs-table td:first-child { width: 55%; }
.costs-table tfoot th, .costs-table tfoot td { border-top: 2px solid var(--line); }
.labour-form { margin-top: 12px; }
.labour-form input.narrow { flex: 0 0 80px; min-width: 60px; }
.inspection-form textarea { flex: 1; min-width: 220px; }
#todo .add-fix { margin-top: 12px; }

/* Customers: journal on the left, details on the right */
.customer-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--gap); align-items: start; }
.customer-layout .side .card .page-head { margin-bottom: 0; }
.journal .tabs-row { margin-bottom: 4px; }
.journal .tabs { margin: 0; flex-wrap: wrap; }
.month { font-size: .85rem; color: var(--muted); font-weight: 600; margin: 18px 0 4px; }
.journal-lines { list-style: none; margin: 0; padding: 0; }
.jl { display: grid; grid-template-columns: 82px 70px minmax(0, 1fr) auto; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.jl:last-child { border-bottom: 0; }
.jl .when { font-size: .85rem; white-space: nowrap; }
.jl .kind { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.jl.email .kind { color: #3b6ea8; }
.jl.quote .kind, .jl.invoice .kind, .jl.delivery .kind { color: var(--ok); }
.jl.return .kind { color: var(--warn); }
.jl .what .badge { margin-left: 4px; font-size: .72rem; padding: 0 7px; }
.jl .who { white-space: nowrap; }
details > summary { list-style: none; cursor: pointer; display: inline-block; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 12px; }
summary.link { text-decoration: underline; text-decoration-color: var(--line); }
.add-note { margin: 8px 0 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.contacts { list-style: none; margin: 0 0 12px; padding: 0; }
.contact { padding: 10px 0; border-bottom: 1px solid var(--line); }
.contact-name { font-size: 1.05rem; margin-right: 6px; }
form.inline { display: inline; margin-left: 6px; }
.side .form { max-width: none; }
.customer-parts td { white-space: nowrap; }
.customer-parts td:first-child { white-space: normal; width: 100%; }
@media (max-width: 860px) {
  .customer-layout { grid-template-columns: 1fr; }
  .jl { grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; }
  .jl .what, .jl .who { grid-column: 1 / -1; }
  .field-row { grid-template-columns: 1fr; }
}

/* Inventory: where stock is heading */
.outlook { display: block; width: 100%; height: auto; overflow: visible; }
.outlook.small { width: 120px; height: 28px; }
.outlook .line { fill: none; stroke-width: 2; }
.outlook.small .line { stroke-width: 1.5; }
.outlook .firm { stroke: var(--ok); }
.outlook .firm.below { stroke: var(--bad); }
.outlook .quoted { stroke: var(--muted); stroke-dasharray: 5 4; }
.outlook .zero { stroke: var(--line); }
.outlook .reorder { stroke: var(--warn); stroke-dasharray: 2 3; }
.outlook circle { fill: var(--ok); }
.outlook circle.below { fill: var(--bad); }
.outlook .axis, .outlook .step { font-size: 11px; fill: var(--muted); }
.outlook .step { fill: var(--text); font-weight: 600; }
.legend { margin: 6px 0 0; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.legend .key { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--ok); margin-right: 6px; vertical-align: middle; }
.legend .key.quoted { border-top: 2px dashed var(--muted); }
.legend .key.reorder { border-top: 2px dotted var(--warn); }

/* Return page: one line per item, with more opening underneath */
.items-list { border-top: 1px solid var(--line); margin-bottom: 12px; }
.item-row { border-bottom: 1px solid var(--line); }
.item-row.is-red > .item-line { background: color-mix(in srgb, var(--red) 6%, transparent); }
.item-row.retained > .item-line { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.item-line { display: grid; grid-template-columns: 24px 64px minmax(180px, 1.2fr) 150px 214px minmax(300px, 2fr) 76px 120px 24px;
  align-items: center; gap: 8px; padding: 8px 4px; }
.item-line input:not([type=checkbox]), .item-line select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); min-width: 0; }
.chev { width: 24px; height: 24px; border: 0; background: none; cursor: pointer; padding: 0; color: var(--muted); }
.chev::before { content: ""; display: inline-block; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .15s; }
.chev[aria-expanded="true"]::before { transform: rotate(45deg); }
.item-serial { font-size: 1.1rem; text-decoration: none; }
.item-name .code { color: var(--muted); font-size: .85rem; }
.item-name .add-repair { margin-top: 4px; }
.item-name summary.chip { display: inline-block; list-style: none; padding: 1px 10px; font-size: .85rem; color: var(--accent); border-color: var(--accent); background: none; }
.item-name summary.chip::-webkit-details-marker { display: none; }
.item-dots .dots { padding: 0; }
.readings { display: flex; gap: 6px; margin: 0; }
.readings .strokes { width: 104px; }
.status-pair { display: flex; align-items: center; gap: 2px; }
.status-pair input { width: 44px; text-align: center; }
.item-jobs { display: flex; flex-direction: column; gap: 4px; }
.job-line { display: grid; grid-template-columns: 18px 1fr 70px 90px 16px; align-items: center; gap: 6px; margin: 0; }
.job-line .job-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-line.done .job-name { color: var(--muted); text-decoration: line-through; }
.job-price { width: 70px; text-align: right; }
.item-cal .pill-cal { padding: 2px 10px; font-size: .85rem; white-space: nowrap; }
.item-state { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; font-size: .85rem; }
.item-state form { margin: 0; }
.item-del form { margin: 0; }
.bin { padding: 2px; line-height: 0; }
.item-note { margin: -4px 0 8px 98px; color: var(--muted); font-size: .9rem; }
.item-more { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); padding: 14px 18px 16px 98px; border-top: 1px solid var(--line); }
.more-grid { display: grid; grid-template-columns: 140px minmax(0, 640px); gap: 12px; align-items: start; }
.more-label { font-weight: 600; padding-top: 6px; }
.more-notes { margin: 0; }
.more-notes textarea { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.more-head { margin: 16px 0 6px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.more-table { background: var(--surface); }
.more-table tr.this-visit td { background: color-mix(in srgb, var(--yellow) 10%, transparent); }
.tag-now { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .75rem; font-weight: 700; text-transform: uppercase; }
.legacy-log { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }
.legacy-log li { padding: 6px 10px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.legacy-log li:first-child { border-top: 0; }
.legacy-log span { color: var(--muted); margin-right: 8px; }
.nowrap { white-space: nowrap; }
@media (max-width: 1240px) {
  .item-line { grid-template-columns: 24px 64px 1fr; }
  .item-line > :nth-child(n+4) { grid-column: 3; }
  .item-note { margin-left: 98px; }
  .item-more { padding-left: 18px; }
  .more-grid { grid-template-columns: 1fr; }
}
/* Priority picker: a pill that is also a dropdown, shared by returns and quotes. */
.priority-form { margin: 0; display: inline-block; }
.priority-form.busy { opacity: .5; pointer-events: none; }
select.priority { appearance: none; -webkit-appearance: none; font: inherit; font-size: .8rem; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); cursor: pointer;
  color: var(--muted); }
select.priority.low { color: var(--muted); font-weight: 400; }
select.priority.high { color: var(--warn); border-color: currentColor; }
select.priority.urgent { color: #fff; background: var(--bad); border-color: var(--bad); }
select.priority option { color: var(--text); background: var(--surface); font-weight: 400; }

/* Conversations panel: a conversation opened in place, and writing from the panel */
.conversations li.open > .snippet, .conversations li.open > br { display: none; }
.inline-thread { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.inline-messages { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.inline-email { padding: 8px 10px; border-radius: 8px; background: var(--bg); }
.inline-email.out { border-left: 3px solid var(--accent); }
.inline-email .email-head { margin-bottom: 4px; }
.inline-email .email-text { font-size: .9rem; }
.inline-reply, .panel-compose { margin-top: 8px; }
.panel-compose { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.inline-compose { gap: 8px; max-width: none; }
.inline-compose textarea { min-height: 10em; }
.sent-note { color: var(--ok); margin: 6px 0 0; }
/* While reading or writing an email, the panel docks to the right of the screen and the page moves left, so everything else stays in view */
@media (min-width: 900px) {
  body.mail-docked main.page { margin-right: calc(min(36vw, 560px) + 8px); max-width: none; }
  body.mail-docked #conversations { position: fixed; top: var(--topbar-h, 59px); right: 0; bottom: 0; width: min(36vw, 560px);
    margin: 0; border-radius: 0; border-width: 0 0 0 1px; overflow-y: auto; z-index: 5; box-shadow: -4px 0 16px rgba(0, 0, 0, .06); }
  body.mail-docked .inline-messages { max-height: none; overflow: visible; }
  body.mail-docked .customer-layout { grid-template-columns: minmax(0, 1fr); }
}
.dock-close { display: none; }
@media (min-width: 900px) { body.mail-docked .dock-close { display: inline-block; } }
