:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #27323c;
  background: #f4f5f7;
  --accent: #79253e;
  --accent-soft: #f8edf1;
  --line: #e1e5ea;
  --muted: #6b7784;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #ba718a; outline-offset: 2px; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 3vw, 2rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.65rem); letter-spacing: -.025em; }
h3 { font-size: .96rem; }
a { color: var(--accent); }

.topbar { min-height: 4.6rem; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem max(1.2rem, calc((100vw - 91rem) / 2)); }
.brand { display: flex; align-items: center; gap: .7rem; color: #29353e; font-weight: 750; font-size: 1rem; text-decoration: none; }
.brand-mark { width: 2.5rem; height: 2.5rem; display: grid; place-items: center; background: var(--accent); color: #fff; border-radius: .65rem; font-size: 1.7rem; font-weight: 600; }
.brand small { display: block; color: var(--muted); font-size: .65rem; font-weight: 450; margin-top: .12rem; }
.account { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; font-size: .83rem; }
.role-badge { color: var(--accent); background: var(--accent-soft); border-radius: 1rem; padding: .3rem .6rem; font-size: .7rem; font-weight: 650; }
main { max-width: 93.4rem; padding: 1.6rem 1.2rem 3rem; margin: auto; }
.page-heading, .heading-actions, .section-heading, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-heading { margin-bottom: 1.3rem; }
.heading-actions { gap: .5rem; }
.eyebrow { display: block; color: #8c6876; font-size: .64rem; font-weight: 750; letter-spacing: .1em; margin-bottom: .3rem; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 2.3rem; border: 1px solid transparent; border-radius: .45rem; padding: .5rem .8rem; font-size: .8rem; font-weight: 650; line-height: 1.35; text-decoration: none; }
.primary { color: #fff; background: var(--accent); }
.primary:hover:enabled { background: #642036; }
.secondary { color: #4e5f6e; background: #fff; border-color: #d7dee5; }
.secondary:hover:enabled { background: #f5f7fa; }
.quiet { background: transparent; color: #65727f; }
.small { min-height: 1.9rem; padding: .3rem .55rem; font-size: .72rem; }
.muted { color: var(--muted); font-size: .78rem; line-height: 1.5; }
.error { color: #a32646; font-size: .84rem; line-height: 1.5; }
.error:empty, .page-status:empty { display: none; }
.page-error { margin-bottom: .8rem; padding: .75rem; border: 1px solid #edc4d0; background: #fff3f6; border-radius: .5rem; }
.page-status { margin-bottom: .8rem; color: #795b2e; background: #fff7e9; border: 1px solid #eadab8; padding: .7rem .85rem; border-radius: .5rem; font-size: .8rem; }
.loading { color: var(--muted); margin-top: 3rem; text-align: center; }
.pending-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; margin-bottom: 1rem; border: 1px solid #debd8b; border-radius: .55rem; background: #fff6e5; color: #795326; font-size: .85rem; }
.pending-status p { margin-top: .25rem; }
.pending-status .button { flex-shrink: 0; }

.workspace { display: grid; grid-template-columns: 17rem minmax(0, 1fr); align-items: start; gap: 1rem; }
.workspace.client-workspace { display: block; max-width: 67rem; margin: auto; }
.order-sidebar { background: #fff; border: 1px solid var(--line); border-radius: .7rem; padding: .85rem; }
.search-label, .filter-label { display: grid; gap: .3rem; color: #64717e; font-size: .71rem; }
.search-label input, .filter-label select { width: 100%; min-width: 0; padding: .55rem .65rem; border: 1px solid #d7dfe7; border-radius: .4rem; background: #fff; color: #344654; }
.filter-label { margin-top: .6rem; }
.order-list { display: grid; gap: .5rem; margin-top: .85rem; }
.order-card { width: 100%; text-align: left; border: 1px solid #e4e9ee; border-radius: .5rem; background: #fff; padding: .7rem; color: inherit; }
.order-card.selected { border-color: #a65c76; background: #fffbfc; box-shadow: inset 3px 0 0 var(--accent); }
.order-top, .order-bottom { display: flex; align-items: start; justify-content: space-between; gap: .3rem; }
.order-top > strong { font-size: .74rem; }
.order-bike { display: block; font-size: .83rem; font-weight: 650; margin: .6rem 0 .7rem; overflow-wrap: anywhere; }
.order-bottom { color: #6b7784; font-size: .75rem; }
.stage { display: inline-block; border-radius: .35rem; padding: .25rem .4rem; background: #edf1f5; color: #697684; font-size: .65rem; line-height: 1.3; font-weight: 550; }
.stage-diagnostics { color: #9a4564; background: #faedf2; }
.stage-approval, .stage-waiting_parts { color: #8b6c36; background: #fff4dd; }
.stage-in_progress, .stage-quality_control { color: #3f6586; background: #ecf4fc; }
.stage-ready_for_pickup { color: #3c7c65; background: #eaf5ee; }
.order-detail { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: .7rem; overflow: clip; }
.detail-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; padding: 1.2rem; }
.detail-heading .stage { margin-top: .55rem; }
.customer-line { margin-top: .4rem; color: var(--muted); font-size: .76rem; }
.order-identifier { display: flex; align-items: center; gap: .45rem; margin: -.3rem 1.2rem .7rem; color: #87939d; font-size: .65rem; }
.order-identifier input { min-width: 0; width: min(26rem, 65%); border: 0; background: transparent; color: #87939d; font: inherit; }
.order-total { display: grid; gap: .22rem; justify-items: end; flex-shrink: 0; }
.order-total > strong { font-size: 1.4rem; letter-spacing: -.035em; }
.order-total small { color: var(--muted); font-size: .66rem; }
.earnings { color: #517861; font-size: .73rem; margin-top: .35rem; }
.next-step { padding: .8rem 1.2rem; color: #6d4c5a; background: #fbf3f6; border-left: 3px solid #a05973; font-size: .8rem; line-height: 1.5; }
.complaint { margin: .8rem 1.2rem; font-size: .77rem; color: #697581; line-height: 1.5; white-space: pre-wrap; }
.complaint strong { margin-right: .4rem; color: #4e5e6c; }
.detail-tabs { display: flex; gap: 1.25rem; overflow-x: auto; padding: 0 1.2rem; border-top: 1px solid #edf0f3; border-bottom: 1px solid var(--line); }
.detail-tabs button { white-space: nowrap; padding: .85rem 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #74818d; font-size: .8rem; font-weight: 600; }
.detail-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.detail-body { padding: 1.05rem 1.2rem 1.2rem; container-name: order; container-type: inline-size; }
.empty-state { text-align: center; color: var(--muted); font-size: .86rem; padding: 3.8rem 1rem; }
.empty-state p { margin-top: .5rem; }
.empty-list { padding: 1rem .3rem; color: var(--muted); font-size: .8rem; text-align: center; }

.form-stack { display: grid; gap: .8rem; }
.form-stack label { display: grid; gap: .35rem; color: #5e6c79; font-size: .78rem; }
.form-stack input, .form-stack select, .form-stack textarea { width: 100%; min-width: 0; border: 1px solid #d2dbe4; border-radius: .4rem; padding: .6rem .65rem; color: #304656; background: #fff; font: inherit; }
textarea { resize: vertical; }
.form-stack > .button { justify-self: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; align-items: end; }
.login-card { max-width: 25rem; margin: 4rem auto; background: #fff; padding: 2rem; border: 1px solid var(--line); border-radius: .85rem; box-shadow: 0 10px 35px #28364406; }
.login-card .muted { margin: .65rem 0 1.4rem; }
.login-card form > .button { justify-self: stretch; }
.section-heading { margin-bottom: .9rem; }
.section-heading .muted { margin-top: .35rem; }
.diagnostic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; align-items: start; }
.diagnostic-node { border: 1px solid #e0e6ec; border-radius: .45rem; padding: .65rem; }
.diagnostic-node h3 { margin-bottom: .55rem; padding-bottom: .4rem; border-bottom: 1px solid #e7ebf0; font-size: .76rem; color: #52687b; }
.diagnostic-mark { display: flex; gap: .45rem; align-items: start; padding: .22rem 0; font-size: .73rem; line-height: 1.45; color: #596d7c; }
.diagnostic-mark input { margin: .15rem 0 0; accent-color: var(--accent); }
.healthy-mark { margin-top: .3rem; color: #47755f; }
.reading-row { display: flex; align-items: end; gap: .3rem; padding: .3rem 0; }
.reading-row label { display: grid; gap: .25rem; font-size: .67rem; color: #6e7b86; min-width: 0; }
.reading-row input { width: 100%; min-width: 0; border: 1px solid #d7dfe7; border-radius: .3rem; padding: .35rem; font-size: .75rem; }
.reading-row.is-dirty input, .torque-row.is-dirty { background: #fff8e8; }

.work-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.work-layout.with-faults { grid-template-columns: minmax(0, 1fr) 14rem; }
.work-main { min-width: 0; }
.table-scroll { overflow-x: auto; border: 1px solid #dce3ea; border-radius: .45rem; }
.works-table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.works-table th { background: #f7f8fa; color: #7b8792; font-weight: 550; text-align: left; padding: .6rem .55rem; border-bottom: 1px solid #dce3ea; }
.works-table th:first-child { width: 2rem; }
.works-table td { border-top: 1px solid #e9edf1; padding: .65rem .55rem; vertical-align: top; }
.works-table td:nth-child(2) { min-width: 11rem; }
.works-table td:first-child { color: #a8b1b9; text-align: center; }
.works-table strong { font-weight: 600; color: #425769; }
.works-table select { width: 8.5rem; border: 1px solid #d5dfe8; border-radius: .3rem; padding: .3rem; color: #556b7c; background: #fff; font: inherit; }
.work-reason { color: #7b8792; font-size: .7rem; line-height: 1.5; margin-top: .35rem; overflow-wrap: anywhere; }
.quantity { color: #8a96a0; font-size: .7rem; }
.money { white-space: nowrap; }
.work-pending { background: #fffdf4; }
.work-refused, .work-deferred { color: #8f99a3; background: #fafbfc; }
.work-complete { width: 1.4rem; height: 1.4rem; border: 1px solid #c9d5df; border-radius: .25rem; background: #fff; color: #8a9ba8; }
.completed { color: #4e8972; }
.empty-cell { text-align: center; color: var(--muted); padding: 1.5rem !important; }
.work-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.add-work { margin-top: 1.3rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.add-work h3 { margin-bottom: .85rem; }
.work-picker { grid-template-columns: minmax(0, 1fr) 5.5rem; }
#catalog-search { margin-bottom: .15rem; }
.stock-picker { margin-top: 1rem; border: 1px solid var(--line); border-radius: .45rem; padding: .8rem; }
.stock-picker summary { cursor: pointer; font-size: .8rem; color: #63788a; }
.stock-picker[open] summary { margin-bottom: .8rem; }
.fault-panel { border: 1px solid #d7e3ef; border-radius: .45rem; background: #f8fbff; }
.fault-panel > h3 { font-size: .75rem; padding: .7rem; color: #57728b; border-bottom: 1px solid #dce7f2; }
.fault-panel section { padding: .7rem; overflow-wrap: anywhere; }
.fault-panel section + section { border-top: 1px solid #dce7f2; }
.fault-panel h4 { font-size: .73rem; color: #587085; }
.fault-panel ul { margin: .4rem 0 0; padding-left: .95rem; color: #748798; font-size: .73rem; line-height: 1.5; }
.fault-panel > .muted { padding: .7rem; font-size: .73rem; }
.ready-actions { margin-top: 1.3rem; border: 1px solid #d5e8dc; background: #f7fcf8; border-radius: .5rem; padding: .9rem; }
.ready-actions h3 { color: #51816a; }

.torque-list { display: grid; border: 1px solid #dbe3eb; border-radius: .45rem; overflow: hidden; }
.torque-row { display: grid; grid-template-columns: minmax(9rem, 1fr) 5rem 5rem 5.5rem auto; gap: .6rem; align-items: center; padding: .6rem; border-top: 1px solid #e4e9ee; font-size: .73rem; }
.torque-row:first-child { border-top: 0; }
.torque-row > strong { font-weight: 550; color: #576e80; }
.torque-row label:not(.check-label) { display: flex; align-items: center; gap: .3rem; color: var(--muted); }
.torque-row input:not([type="checkbox"]) { width: 3.1rem; border: 1px solid #d3dde5; border-radius: .3rem; padding: .35rem; color: #405e74; font: inherit; }
.check-label { display: flex; gap: .25rem; align-items: center; color: #6f8090; }
.check-label input { accent-color: var(--accent); }
.test-ride { margin-top: 1.3rem; padding-top: 1rem; border-top: 1px solid var(--line); max-width: 34rem; }
.control-note { margin-top: .9rem; }
.thread-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.thread-active { background: var(--accent-soft); color: var(--accent); border-color: #c794a8; }
.communication > .muted { margin-top: .3rem; }
.messages { list-style: none; height: 22rem; overflow-y: auto; border: 1px solid #e0e6ec; border-radius: .5rem; background: #fafbfc; margin: 1rem 0; padding: .8rem; }
.messages li:not(.empty-list) { max-width: 38rem; border: 1px solid #e1e7ed; border-radius: .55rem; background: #fff; padding: .65rem .8rem; margin-bottom: .6rem; }
.message-meta { display: flex; align-items: center; justify-content: space-between; gap: .7rem; font-size: .72rem; color: #6b4d5b; }
.message-meta time { color: #9ca5ae; font-size: .65rem; }
.messages p { margin-top: .35rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .81rem; line-height: 1.5; }
.invoice-link { display: inline-block; margin-top: .6rem; border: 1px solid #d1dce6; border-radius: .35rem; padding: .4rem .6rem; font-size: .76rem; font-weight: 600; text-decoration: none; }
.quick-replies { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .7rem; }
dialog { width: min(36rem, calc(100% - 1.6rem)); max-height: calc(100% - 2rem); border: 1px solid var(--line); border-radius: .75rem; padding: 1.3rem; color: inherit; box-shadow: 0 20px 80px #15212e33; }
dialog::backdrop { background: #17233270; }
.dialog-heading { margin-bottom: 1.2rem; }
.dialog-heading h2 { font-size: 1.2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }
#missing-dialog > p, #missing-dialog ul { font-size: .86rem; line-height: 1.6; color: #657585; }
.toast { position: fixed; bottom: 1.3rem; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 2rem); border: 1px solid #d7dfe7; border-radius: .5rem; padding: .75rem 1rem; background: #fff; box-shadow: 0 4px 25px #24364618; color: #536d80; font-size: .8rem; z-index: 10; }

@container order (max-width: 750px) {
  .work-layout.with-faults { grid-template-columns: 1fr; }
  .fault-panel { order: -1; }
  .diagnostic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .torque-row { grid-template-columns: minmax(7rem, 1fr) 4.5rem auto; }
  .torque-row .check-label { grid-row: 2; }
}
@media (max-width: 750px) {
  main { padding: 1rem .7rem 2rem; }
  .topbar { padding: .7rem; }
  .brand small { display: none; }
  .account { gap: .3rem; font-size: .7rem; }
  .account .role-badge { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .order-sidebar { padding: .65rem; }
  .order-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 13rem; overflow-y: auto; }
  .order-top { display: block; }
  .order-top .stage { margin-top: .3rem; }
  .order-bike { font-size: .77rem; }
  .filter-label { display: none; }
  .page-heading { gap: .6rem; }
  .heading-actions { gap: .3rem; }
  .heading-actions .button { font-size: .72rem; padding: .45rem .55rem; }
  .detail-heading, .detail-body { padding: .9rem; }
  .order-total > strong { font-size: 1.1rem; }
  .detail-tabs { padding-inline: .9rem; gap: 1rem; }
  .next-step { padding-inline: .9rem; }
  .section-heading { align-items: start; }
  .pending-status { align-items: start; flex-direction: column; }
}
@media (max-width: 430px) {
  .brand { font-size: .88rem; gap: .45rem; }
  .brand-mark { width: 2rem; height: 2rem; font-size: 1.45rem; }
  .account #account-name { max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .form-grid { grid-template-columns: 1fr; }
  .work-picker { grid-template-columns: minmax(0, 1fr) 4.5rem; }
  .detail-heading { gap: .6rem; }
  .diagnostic-grid { grid-template-columns: 1fr; }
  .login-card { padding: 1.5rem; margin: 2rem auto; }
}
