@font-face {
  font-family: Orbitron;
  src: url("/orbitron.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
}
:root {
  color-scheme: light dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  --heading: Orbitron, "Segoe UI", system-ui, sans-serif;
  --canvas: light-dark(#f9fafb, #181a1e);
  --surface: light-dark(#fff, #22252a);
  --field: light-dark(#f3f4f6, #1b1e23);
  --button: light-dark(#fff, #2a2e35);
  --ink: light-dark(#191b20, #f0f1f2);
  --muted: light-dark(#565e69, #afb4bd);
  --line: light-dark(#dfe3e8, #3b4048);
  --edge: light-dark(#e8eaee, #353a42);
  --accent: light-dark(#272c33, #e4e7eb);
  --accent-hover: light-dark(#13171c, #fff);
  --accent-label: light-dark(#fff, #16181b);
  --focus: light-dark(#41688d, #9abbde);
  --danger: light-dark(#a52831, #ffa8ae);
  --brand-ink: light-dark(#222322, #edf0eb);
  --brand-accent: light-dark(#a5b2a1, #b8c7b4);
  --lift: light-dark(rgb(31 41 55 / .065), rgb(0 0 0 / .27));
  --field-inset: light-dark(rgb(27 35 48 / .085), rgb(0 0 0 / .26));
  --highlight: light-dark(rgb(255 255 255 / .75), rgb(255 255 255 / .045));
  --surface-shadow: 0 2px 5px var(--lift), 0 10px 30px -20px var(--lift);
  --button-shadow: 0 1px 2px var(--lift), inset 0 1px 0 var(--highlight);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, select, input, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
button {
  background: var(--button);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .55rem .8rem;
  min-height: 38px;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: var(--button-shadow);
  transition: box-shadow 140ms ease;
}
button:hover { background: var(--field); }
button:disabled { opacity: .52; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-label); box-shadow: 0 2px 4px var(--lift); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost, button.subtle { background: transparent; border-color: transparent; box-shadow: none; }
button.ghost:hover, button.subtle:hover { background: var(--field); }
button.subtle { margin-top: .55rem; padding-inline: .22rem; }
a { color: inherit; text-underline-offset: .16em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
h1, h2, h3, p, figure { margin: 0; }
h1, h2, h3, .connection-form legend { font-family: var(--heading); }
h1 { font-size: clamp(1.55rem, 3.4vw, 2.22rem); font-weight: 900; letter-spacing: -.035em; line-height: 1.18; }
h2 { font-size: 1.06rem; font-weight: 750; letter-spacing: -.018em; line-height: 1.35; }
h3 { font-size: .94rem; font-weight: 680; line-height: 1.4; }
small { font-size: .82rem; color: var(--muted); }
label { font-size: .84rem; font-weight: 600; display: grid; gap: .36rem; min-width: 0; }
input:not([type="checkbox"]), textarea, select {
  min-width: 0;
  width: 100%;
  min-height: 40px;
  padding: .52rem .62rem;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: 5px;
  box-shadow: inset 0 1px 2px var(--field-inset), 0 1px 0 var(--highlight);
  font-size: .94rem;
}
input[readonly] { color: var(--muted); }
input[type="file"] { font-size: .8rem; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
.masthead {
  min-height: 62px;
  display: grid;
  grid-template-columns: 178px 1fr auto;
  align-items: center;
  gap: clamp(.8rem, 4vw, 3rem);
  padding-inline: max(clamp(1rem, 4vw, 3.5rem), calc((100vw - 1380px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; }
.brand-lockup { position: relative; display: block; width: min(100%, 178px); aspect-ratio: 22 / 5; }
.brand-lockup::before, .brand-lockup::after {
  position: absolute;
  inset: 0;
  content: "";
  mask-size: contain;
  mask-repeat: no-repeat;
}
.brand-lockup::before { background: var(--brand-ink); mask-image: url("/cdelabs-letters-mask.png"); }
.brand-lockup::after { background: var(--brand-accent); mask-image: url("/cdelabs-accent-mask.png"); }
.masthead nav { display: flex; flex-wrap: wrap; align-self: stretch; gap: clamp(.6rem, 2.8vw, 2rem); }
.masthead nav a {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding-block: .8rem;
  min-height: 44px;
  font-size: .91rem;
  font-weight: 550;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.masthead nav a:hover, .masthead nav a[aria-current="page"] { color: var(--ink); }
.masthead nav a[aria-current="page"] { border-color: var(--ink); }
#new-badge { font-size: .77rem; font-weight: 700; background: var(--field); padding: .08rem .3rem; }
.masthead button { color: var(--muted); }
main { width: min(100%, 1492px); margin-inline: auto; padding: clamp(1rem, 4vw, 3.1rem) clamp(1rem, 4vw, 3.5rem); min-width: 0; }
.page-header { margin-bottom: 1.75rem; display: flex; justify-content: space-between; gap: .9rem; align-items: center; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.panel { min-width: 0; }
.invoice-paper, .invoice-summary, .search-form, .ai-summary {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 9px;
  box-shadow: var(--surface-shadow);
}
.invoice-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(218px, 265px); align-items: start; gap: clamp(1.4rem, 4vw, 3.3rem); }
.invoice-paper { padding: clamp(.85rem, 2.6vw, 1.75rem); }
.invoice-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.3rem; }
.logo-field, .invoice-identifiers { width: min(46%, 260px); }
.logo-field img { display: block; max-width: 100%; max-height: 78px; object-fit: contain; margin-top: .45rem; }
.logo-field .brand-lockup { margin-top: .55rem; }
.invoice-identifiers { display: grid; gap: .8rem; }
.invoice-identifiers label:first-child input { font-size: 1.13rem; font-weight: 650; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.05rem; margin-block: 1.2rem; align-items: start; }
.metadata { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.invoice-summary { display: grid; gap: .9rem; align-content: start; padding: 1.15rem; }
.input-group { display: flex; gap: .35rem; }
.input-group select { width: 5.05rem; flex: none; }
.total-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; font-size: .92rem; }
.total-row strong, .item-amount { font-variant-numeric: tabular-nums; text-align: right; }
.balance { border-top: 1px solid var(--line); padding-block: .79rem .35rem; font-weight: 650; }
.table-scroll { position: relative; overflow-x: auto; }
.invoice-table { width: 100%; min-width: 420px; border-collapse: collapse; }
.invoice-table thead { color: var(--muted); background: transparent; font-size: .84rem; }
.invoice-table th, .invoice-table td { padding: .52rem .34rem; text-align: left; }
.invoice-table th { border-bottom: 1px solid var(--line); }
.invoice-table th:first-child, .invoice-table td:first-child { padding-left: 0; }
.invoice-table th:nth-child(2) { width: 65px; }
.invoice-table th:nth-child(3) { width: 102px; }
.invoice-table th:nth-child(4), .invoice-table .item-amount { width: 116px; text-align: right; }
.invoice-table th:last-child { width: 32px; }
.invoice-table input { min-height: 35px; }
.icon-button { background: transparent; border: 0; box-shadow: none; padding: .32rem .42rem; font-size: 1.07rem; }
.invoice-foot { margin-top: 1.35rem; margin-bottom: 0; }
.term-controls { display: grid; gap: .6rem; }
.term-controls .actions { font-size: .86rem; }
.photo-section { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.photo-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.photo-header small { display: block; margin-top: .3rem; }
.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 1rem; }
.photo-card { min-width: 0; display: grid; gap: .55rem; margin-top: .9rem; }
.photo-card img { width: 100%; height: 125px; object-fit: contain; background: var(--field); }
.photo-card button { justify-self: start; padding-inline: .14rem; }
.terms-page main { max-width: 880px; }
.terms-header { margin-bottom: 1.4rem; }
.terms-header .brand-lockup { width: min(220px, 100%); margin-bottom: 1rem; }
.terms-copy { line-height: 1.55; }
.terms-copy section { margin-block: 1.25rem; }
.terms-copy h2 { margin-bottom: .35rem; }
.terms-copy p + p { margin-top: .24rem; }
.connection, .form-note, .connection-feedback { color: var(--muted); font-size: .92rem; line-height: 1.45; }
.connection { margin: .7rem 0 1.15rem; }
.repair-layout { display: grid; grid-template-columns: minmax(240px, .68fr) minmax(0, 1.6fr); gap: clamp(1.1rem, 3vw, 2.4rem); align-items: start; }
.inbox-list { padding-right: clamp(1rem, 3vw, 2rem); border-right: 1px solid var(--line); min-height: 235px; }
.inbox-list h2 { margin-bottom: .8rem; }
#repair-list { margin-top: .8rem; max-height: 65vh; overflow: auto; }
.conversation { display: grid; gap: .34rem; width: 100%; text-align: left; background: transparent; box-shadow: none; border: 0; border-bottom: 1px solid var(--line); padding: .7rem .55rem; }
.conversation[aria-current="true"] { background: var(--field); }
.conversation-top { display: flex; justify-content: space-between; gap: .4rem; }
.conversation-top small { white-space: nowrap; }
.snippet { color: var(--muted); font-weight: 400; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head { display: flex; justify-content: space-between; gap: .7rem; align-items: start; margin-bottom: 1rem; }
.thread-head select { width: auto; }
.ai-summary { padding: .9rem; display: grid; gap: .45rem; }
.ai-summary button { justify-self: start; }
.messages { display: flex; flex-direction: column; align-items: start; gap: .55rem; margin: 1rem 0; max-height: 52vh; overflow: auto; }
.message { max-width: 88%; border-left: 2px solid var(--line); padding: .36rem .65rem; }
.message p { white-space: pre-wrap; overflow-wrap: anywhere; }
.message.out { align-self: end; background: var(--field); border-left: 0; }
.compose-reply { display: grid; gap: .55rem; }
.search-form { display: grid; gap: .9rem; max-width: 1020px; padding: clamp(.9rem, 2.5vw, 1.45rem); }
.search-row { display: grid; grid-template-columns: minmax(140px, .32fr) minmax(180px, 1fr) auto; gap: .7rem; align-items: end; }
.search-row button { min-height: 40px; }
.search-options { display: grid; grid-template-columns: minmax(140px, .32fr) minmax(200px, .75fr); gap: .7rem; max-width: 620px; }
#model-context { max-width: 620px; }
.search-filters { border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .65rem; }
.search-filters summary, .source-report summary { width: fit-content; font-size: .9rem; font-weight: 600; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(143px, 1fr)); gap: .65rem; margin-block: .8rem; }
.checkbox { display: flex; gap: .4rem; align-items: center; width: fit-content; }
.filter-checks { gap: 1.3rem; }
input[type="checkbox"] { accent-color: var(--accent); }
.result-group { margin-top: 1.6rem; }
.result-group h2 { margin-bottom: .6rem; }
.part-card { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; align-items: start; gap: 1rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.part-details { min-width: 0; overflow-wrap: anywhere; }
.part-image { position: relative; display: grid; place-items: center; aspect-ratio: 1; background: var(--field); border-radius: 5px; overflow: hidden; text-align: center; }
.part-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
.part-image.loaded img { opacity: 1; }
.part-image small { font-size: .69rem; padding: .3rem; }
.part-card h3 { margin: .24rem 0; font-family: inherit; font-size: 1rem; font-weight: 650; }
.part-card p { color: var(--muted); font-size: .91rem; line-height: 1.4; margin-bottom: .35rem; }
.part-cost { min-width: 168px; text-align: right; }
.part-cost small, .history-row small { display: block; margin-top: .2rem; }
.source-report { margin-top: 1.5rem; color: var(--muted); }
.source-report p { font-size: .86rem; padding-top: .33rem; }
.marketplace-status { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .65rem; margin: -.65rem 0 .75rem; color: var(--muted); font-size: .88rem; }
.marketplace-status button { min-height: 32px; text-decoration: underline; padding-inline: .35rem; }
.empty { color: var(--muted); padding: .7rem 0; }
dialog { width: min(92vw, 720px); max-height: 86vh; color: var(--ink); background: var(--surface); border: 1px solid var(--edge); border-radius: 9px; padding: 1.35rem; box-shadow: var(--surface-shadow); }
dialog::backdrop { background: rgb(5 6 8 / .58); }
.dialog-head, .history-row { display: flex; gap: .5rem; align-items: center; padding-block: .6rem; }
.dialog-head h2, .history-row div { margin-right: auto; }
.history-row { border-top: 1px solid var(--line); }
.connection-form { display: grid; gap: .95rem; }
.setup-preview { background: var(--field); padding: .7rem; font-size: .88rem; margin: .45rem 0 .7rem; color: var(--muted); }
.connection-form fieldset { min-width: 0; margin: .45rem 0 0; padding: .65rem 0 0; border: 0; border-top: 1px solid var(--line); display: grid; gap: .7rem; }
.connection-form legend { padding: 0 .5rem 0 0; font-size: 1rem; font-weight: 650; }
.connection-form fieldset p, .connection-form fieldset a { color: var(--muted); font-size: .9rem; }
.setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.error-text { color: var(--danger); }
#notice { position: fixed; bottom: 1rem; right: 1rem; z-index: 2; visibility: hidden; color: #fff; background: #262b33; padding: .75rem 1rem; max-width: calc(100vw - 2rem); }
#notice.visible { visibility: visible; }
#notice.error { background: #92253a; }
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 920px) {
  .invoice-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 675px) {
  .masthead { grid-template-columns: 1fr auto; padding-top: .45rem; column-gap: .5rem; row-gap: .1rem; }
  .masthead nav { grid-column: 1 / -1; grid-row: 2; }
  .masthead button { grid-column: 2; grid-row: 1; }
  .masthead nav a { padding: .55rem 0; font-size: .86rem; }
  .repair-layout, .search-row { grid-template-columns: minmax(0, 1fr); }
  .inbox-list { padding: 0 0 .6rem; border-right: 0; border-bottom: 1px solid var(--line); min-height: 0; }
  #repair-list { max-height: 32vh; }
  .part-card { grid-template-columns: 72px minmax(0, 1fr); gap: .45rem .65rem; }
  .part-image { grid-row: span 2; }
  .part-cost { grid-column: 2; text-align: left; min-width: 0; }
}
@media (max-width: 430px) {
  .split, .metadata, .setup-grid, .search-options { grid-template-columns: minmax(0, 1fr); }
  .invoice-top { flex-direction: column; }
  .logo-field, .invoice-identifiers { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
