:root {
  color-scheme: light;
  --forest: #1c3c28;
  --leaf: #2e553b;
  --gold: #a68b53;
  --text: #243328;
  --muted: #546255;
  --paper: #fff;
  --canvas: #f5f5ee;
  --line: #e0e4da;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 290px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, canvas:focus-visible {
  outline: 2px solid #8a6c38;
  outline-offset: 3px;
}
h1, h2, h3, p, dl, dd { margin: 0; }
.muted { color: var(--muted); }
.loading { padding: 2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.preserve-lines { white-space: pre-wrap; overflow-wrap: anywhere; }

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}
.sidebar {
  background: var(--forest);
  color: #fff;
  padding: 1.65rem 1.1rem;
  border-right: 1px solid #27452e;
}
.brand-logo {
  display: block;
  width: 170px;
  height: auto;
  margin: 0 auto 2.3rem;
  border: 1px solid #a48b56;
  border-radius: 3px;
}
.tabs { display: flex; flex-direction: column; gap: 0.35rem; }
.tabs button {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #eaf0e8;
  padding: 0.7rem 0.85rem;
  line-height: 1.2;
  font-weight: 600;
}
.tabs button:hover { background: #2a4b35; }
.tabs button[aria-current="page"] {
  background: #34523b;
  border-color: #527254;
  box-shadow: inset 3px 0 #c2a565;
  color: #fff;
}
.workspace { min-width: 0; }
.workspace-bar {
  min-height: 62px;
  padding: 0.55rem clamp(1.15rem, 3vw, 2.65rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--muted);
  background: #fcfcf8;
}
.sample-label {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid #deceb0;
  background: #f7f0df;
  color: #584321;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 675;
  white-space: nowrap;
}
.text-button {
  padding: 0.5rem 0.25rem;
  border: 0;
  background: transparent;
  color: var(--forest);
  font-size: 0.875rem;
  font-weight: 675;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.mobile-sign-out, .mobile-due-label { display: none; }
.workspace-main { max-width: 1350px; margin: auto; padding: 1.8rem clamp(1.15rem, 3vw, 2.65rem) 2.5rem; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 0.85rem; margin-bottom: 1.25rem; }
h1 {
  font: 500 clamp(1.9rem, 4vw, 2.8rem)/1.07 Georgia, "Times New Roman", serif;
  color: var(--forest);
  letter-spacing: -0.035em;
}
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.58rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 675;
  white-space: nowrap;
}
.primary { background: var(--forest); color: #fff; }
.primary:hover:not(:disabled) { background: var(--leaf); }
.secondary { background: #fff; color: var(--forest); border-color: #d3dacd; }
.secondary:hover:not(:disabled) { background: #eff3ea; }
.small-button { min-height: 34px; padding: 0.35rem 0.65rem; }
.page-heading .primary { padding-inline: 1rem; }
.page-heading .primary span { font-size: 1.2rem; line-height: 0.75; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}
.summary-grid:empty { display: none; }
.summary-card {
  min-width: 0;
  padding: 0.9rem 1.05rem 0.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 2px solid #bab18c;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.summary-card span { font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.summary-card strong { color: var(--forest); font-size: 1.75rem; line-height: 1.15; font-weight: 650; font-variant-numeric: tabular-nums; }
.summary-card.ready-card { background: #eff4eb; border-top-color: #4d7155; }
.register, .price-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.filters {
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.search-label { flex: 1; min-width: 0; }
.filter-label { margin-left: auto; flex: 0 0 12rem; }
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.58rem 0.72rem;
  border: 1px solid #d5dccf;
  border-radius: 7px;
  background-color: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
input::placeholder { color: #647064; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #50674f 50%), linear-gradient(135deg, #50674f 50%, transparent 50%);
  background-position: calc(100% - 15px) center, calc(100% - 10px) center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.6rem;
}
.repair-table { width: 100%; border-collapse: collapse; text-align: left; }
.repair-table th {
  padding: 0.56rem 1.1rem;
  background: #f7f8f3;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}
.repair-table td { padding: 0.72rem 1.1rem; border-top: 1px solid #edf0e9; font-size: 0.9rem; }
.repair-table tr:last-child td { border-bottom: 0; }
.repair-table tbody tr[data-action] { cursor: pointer; }
.repair-table tbody tr[data-action]:hover, .repair-table tbody tr[data-action]:focus-within { background: #f5f7f0; }
.repair-item { min-width: 11rem; overflow-wrap: anywhere; }
.repair-item small { color: var(--muted); font-size: 0.77rem; font-weight: 500; font-variant-numeric: tabular-nums; display: block; margin-top: 0.19rem; }
.repair-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--forest);
  text-align: left;
  font-weight: 700;
}
.repair-link:hover { text-decoration: underline; text-underline-offset: 0.17em; }
.repair-estimate, .repair-due { white-space: nowrap; font-variant-numeric: tabular-nums; }
.repair-estimate small { display: block; color: var(--muted); font-size: 0.76rem; margin-top: 0.15rem; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  color: #34493b;
  background: #eff2eb;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 675;
  line-height: 1.15;
  white-space: nowrap;
}
.status::before { content: ""; width: 0.36rem; height: 0.36rem; border-radius: 50%; background: currentColor; }
.status-waiting_parts, .status-awaiting_approval { background: #f8efdb; color: #664b21; }
.status-ready { background: #dcebdd; color: #265338; }
.status-with_repairer { background: #ecf0e2; color: #43562f; }
.status-collected, .status-returned { background: #f0f1ee; color: #536157; }
.empty-state { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.empty-state .button { margin-top: 0.65rem; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.65rem 1rem; font-size: 0.875rem; }
.pager:empty { display: none; }
.pager .button + .button { margin-left: 0.3rem; }

dialog {
  width: min(590px, calc(100vw - 24px));
  max-height: calc(100dvh - 26px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #e4e6dc;
  border-radius: 13px;
  padding: 0;
  color: var(--text);
  background: var(--paper);
  box-shadow: 0 14px 80px #15271d36;
}
dialog::backdrop { background: #15291a77; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.modal-header h2 { font: 500 1.5rem/1.1 Georgia, "Times New Roman", serif; color: var(--forest); }
.close-button { border: 1px solid var(--line); background: #f8f9f4; color: var(--forest); width: 34px; height: 34px; border-radius: 7px; font-size: 1.35rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.form-grid .wide { grid-column: 1 / -1; }
form label { display: grid; align-content: start; gap: 0.3rem; font-size: 0.875rem; font-weight: 650; min-width: 0; }
form label input, form label select, form label textarea { font-weight: 400; font-size: 1rem; }
#intake-form > .form-grid { padding: 1rem 1.2rem; }
.field-note { color: var(--muted); font-size: 0.82rem; }
.form-grid .field-note { margin-top: -0.45rem; }
.form-error { color: #972e25; font-size: 0.875rem; font-weight: 600; }
#intake-form > .form-error { padding: 0 1.2rem 0.9rem; }
.modal-error { padding: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.55rem; padding: 0.85rem 1.2rem; border-top: 1px solid var(--line); }
.detail-body { padding: 1rem 1.2rem; }
.detail-identity { display: flex; justify-content: space-between; align-items: start; gap: 0.6rem; }
.detail-identity h3 { font-size: 1.15rem; overflow-wrap: anywhere; }
.detail-identity p { margin-top: 0.3rem; color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.detail-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  padding: 0.85rem 0;
  margin: 0.8rem 0;
  border-block: 1px solid var(--line);
}
.detail-facts .wide { grid-column: 1 / -1; }
dt { color: var(--muted); font-size: 0.82rem; }
dd { margin-top: 0.12rem; }
.detail-facts dd { font-size: 0.94rem; font-weight: 600; }
.inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.55rem; margin-top: 0.65rem; }
.saved-feedback { color: #42644b; font-size: 0.82rem; }
#status-form .form-error { margin-top: 0.6rem; }
.draft, .history {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafbf7;
  font-size: 0.875rem;
}
summary { cursor: pointer; font-weight: 675; color: var(--forest); }
.draft textarea { display: block; margin-top: 0.6rem; font-size: 0.875rem; }
.history ul { padding: 0 0 0 1.1rem; margin: 0.45rem 0 0; }
.history li { padding: 0.22rem 0; }
.history time { float: right; color: var(--muted); }

.receipt-dialog { width: min(435px, calc(100vw - 24px)); }
.slip-wrapper { background: #f3f4ed; padding: 1.05rem 0.85rem; }
.receipt {
  width: min(100%, 326px);
  margin: auto;
  padding: 0.75rem 1rem 0.85rem;
  background: #fff;
  border: 1px solid #e3e1d4;
  border-top: 3px solid #a78d55;
  border-bottom: 3px solid var(--forest);
  border-radius: 3px;
  box-shadow: 0 5px 18px #2c382314;
}
.receipt-brand { text-align: center; padding-bottom: 0.62rem; }
.receipt-brand img { display: block; width: 142px; height: auto; margin: 0 auto 0.3rem; }
.receipt-brand p { color: var(--forest); font: 500 1.15rem/1.15 Georgia, "Times New Roman", serif; }
.receipt-number, .receipt-total { display: flex; align-items: center; justify-content: space-between; gap: 0.3rem; }
.receipt-number { font-size: 0.78rem; padding: 0.48rem 0; border-top: 1px dashed #b6a77a; border-bottom: 1px dashed #b6a77a; }
.receipt-number strong, .receipt-total strong { color: var(--forest); font-variant-numeric: tabular-nums; }
.receipt-number time { color: var(--muted); white-space: nowrap; }
.receipt-facts { display: grid; gap: 0.32rem; margin-block: 0.6rem; }
.receipt-facts div { min-width: 0; }
.receipt-facts dt { font-size: 0.75rem; }
.receipt-facts dd { font-size: 0.85rem; line-height: 1.18; font-weight: 550; overflow-wrap: anywhere; }
.receipt-total { border-top: 1px dashed #b6a77a; font-size: 0.84rem; padding-top: 0.45rem; }
.receipt-total + .receipt-total { border-top: 0; padding-top: 0.32rem; }
.receipt-note { color: var(--muted); font-size: 0.75rem; margin-top: 0.35rem; text-align: center; }
.receipt-total + .receipt-note { margin-top: 0.55rem; }
.receipt-share {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--line);
}
.receipt-share .button {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
  white-space: normal;
  text-decoration: none;
}
.receipt-share .button span { font-size: 0.82rem; font-weight: 500; color: var(--muted); overflow-wrap: anywhere; }

.auth-mode { background: #eff1e8; }
.auth-screen { display: grid; min-height: 100dvh; place-items: center; padding: 1.25rem; }
.auth-card {
  width: min(100%, 395px);
  padding: 1.35rem 1.45rem;
  border: 1px solid #e0e3d9;
  border-top: 3px solid var(--gold);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 40px #223a2410;
}
.auth-logo { display: block; width: 156px; height: auto; margin: 0 auto 1rem; }
.auth-card h1 { font-size: 2rem; margin-block: 0.5rem 1.05rem; }
.auth-card form { display: grid; gap: 0.8rem; }
.auth-card .field-note { margin-top: -0.32rem; }
.show-password { display: flex; align-items: center; gap: 0.45rem; }
input[type="checkbox"] { accent-color: var(--forest); }
.auth-card .text-button { margin-top: 0.65rem; }

.market-unit { color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
.market-toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.65rem; margin-bottom: 0.85rem; }
.market-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.price-card { min-width: 0; padding: 0.85rem 0.95rem 0.65rem; }
.price-card h2 { color: var(--forest); font-size: 0.98rem; }
.price-summary { display: flex; align-items: end; justify-content: space-between; gap: 0.45rem; margin: 0.18rem 0 0.45rem; }
.price-summary span { font-size: 0.88rem; color: var(--muted); }
.price-summary strong { color: var(--forest); font-size: clamp(1.65rem, 3vw, 2.2rem); font-variant-numeric: tabular-nums; }
.price-change { font-size: 0.88rem; color: var(--leaf); font-weight: 600; }
.price-change.negative-change { color: #983d35; }
.price-options { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.price-button {
  min-height: 34px;
  background: #f8f9f5;
  padding: 0.32rem 0.63rem;
  border: 1px solid #dfe5da;
  border-radius: 6px;
  color: var(--forest);
  font-weight: 650;
  font-size: 0.85rem;
}
.price-button[aria-pressed="true"] { color: #fff; background: var(--forest); border-color: var(--forest); }
.mobile-metal-tabs { display: none; }
.price-card canvas { display: block; width: 100%; height: clamp(170px, 21vw, 245px); touch-action: pan-y; }
.chart-state { min-height: 5rem; display: grid; place-items: center; color: var(--muted); font-size: 0.875rem; text-align: center; }
.price-point { display: block; min-height: 1.25rem; color: var(--muted); font-size: 0.82rem; text-align: center; margin-top: 0.25rem; }
.custom-dates { font-size: 0.875rem; padding: 0.45rem 0; }
.custom-range { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.custom-range label { width: min(10rem, 46%); }
.custom-range .form-error { width: 100%; }
.market-source { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.65rem; margin-top: 0.75rem; color: var(--muted); font-size: 0.82rem; }
.market-source a { color: var(--forest); text-underline-offset: 0.18em; }
.market-updated { flex-basis: 100%; }
.market-updated:empty { display: none; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 175px minmax(0, 1fr); }
  .brand-logo { width: 142px; }
  .repair-table td, .repair-table th { padding-inline: 0.75rem; }
  .filter-label { flex-basis: 10.1rem; }
}
@media (max-width: 760px) {
  .layout { display: block; min-height: 100dvh; }
  .sidebar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding-block: calc(0.6rem + env(safe-area-inset-top, 0px)) 0.6rem;
    padding-inline: max(1rem, env(safe-area-inset-left, 0px)) max(1rem, env(safe-area-inset-right, 0px));
    border: 0;
  }
  .layout:not(.demo-layout) .workspace-bar { display: none; }
  .mobile-sign-out { display: inline-flex; align-items: center; min-height: 44px; color: #fff; }
  .mobile-sign-out:focus-visible { outline-color: #e5cb8c; }
  .brand-logo { width: 102px; margin: 0; }
  .tabs { flex-direction: row; gap: 0.25rem; width: 100%; order: 2; }
  .tabs button { flex: 1; text-align: center; min-height: 42px; font-size: 0.85rem; padding: 0.55rem 0.6rem; white-space: nowrap; }
  .tabs button[aria-current="page"] { box-shadow: inset 0 -2px #c2a565; }
  .workspace-bar { min-height: 43px; padding-block: 0.12rem; }
  .workspace-main { padding-top: 1.15rem; }
  .summary-card { padding: 0.65rem 0.75rem; }
  .repair-table td, .repair-table th { padding-inline: 0.7rem; }
}
@media (max-width: 590px) {
  .workspace-main, .workspace-bar { padding-inline: 0.9rem; }
  .page-heading { margin-bottom: 0.9rem; }
  .page-heading .primary { padding-inline: 0.65rem; }
  .button, input:not([type="checkbox"]), select, textarea { min-height: 44px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; margin-bottom: 0.8rem; }
  .summary-card { flex-direction: row; align-items: center; justify-content: space-between; min-height: 56px; gap: 0.3rem; padding-inline: 0.6rem; }
  .summary-card span { line-height: 1.15; }
  .summary-card strong { font-size: 1.4rem; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 0.65rem; }
  .filter-label { grid-column: 1 / -1; margin: 0; }
  .repair-table { display: block; }
  .repair-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .repair-table tbody { display: block; }
  .repair-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem 0.55rem;
    align-items: start;
    padding: 0.62rem 0.7rem;
    border-bottom: 1px solid var(--line);
  }
  .repair-table tbody tr:last-child { border-bottom: 0; }
  .repair-table td { padding: 0; border: 0; min-width: 0; }
  .repair-item { grid-area: 1 / 1; }
  .repair-link { display: block; width: 100%; min-height: 44px; overflow-wrap: anywhere; }
  .repair-customer { grid-area: 2 / 1; color: var(--muted); overflow-wrap: anywhere; }
  .repair-status { grid-area: 1 / 2; justify-self: end; }
  .repair-estimate { grid-area: 2 / 2; justify-self: end; }
  .repair-due { grid-area: 3 / 1 / 4 / -1; color: var(--muted); }
  .repair-table .repair-due { font-size: 0.82rem; }
  .repair-due.no-due { display: none; }
  .mobile-due-label { display: inline; }
  dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 0.5rem);
    margin: 0;
    border-radius: 14px 14px 0 0;
    scroll-padding-block: 4.5rem 5.5rem;
  }
  .receipt-dialog { width: 100%; }
  .modal-header, .modal-actions { padding-inline: 0.8rem; }
  .modal-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    flex-wrap: wrap;
    padding-block: 0.65rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    background: var(--paper);
  }
  .modal-actions .button { flex: 1 0 auto; padding-inline: 0.5rem; }
  .close-button { width: 44px; height: 44px; }
  .form-grid .contact-field { grid-column: 1 / -1; }
  .detail-body, #intake-form > .form-grid { padding-inline: 0.8rem; }
  .detail-identity { flex-wrap: wrap; }
  .auth-screen { padding-block: max(1.25rem, env(safe-area-inset-top, 0px)) max(1.25rem, env(safe-area-inset-bottom, 0px)); }
  .market-grid { display: block; }
  .market-grid .price-card[data-active="false"] { display: none; }
  .mobile-metal-tabs { display: flex; margin-bottom: 0.65rem; }
  .mobile-metal-tabs .price-button { flex: 1; min-height: 42px; padding-inline: 0.45rem; }
  .price-card { padding: 0.75rem; }
  .price-card canvas { height: 205px; }
  .price-change { text-align: right; }
}
@media (max-width: 380px) {
  .form-grid { grid-template-columns: 1fr; }
  .page-heading h1 { font-size: 1.68rem; }
}
@page { size: A6 portrait; margin: 8mm; }
@media print {
  html, body { height: auto; min-width: 0; background: #fff; }
  body > * { display: none !important; }
  body > #print-area { display: block !important; }
  dialog::backdrop { display: none; }
  .receipt { width: 100%; max-width: none; margin: 0; padding: 3mm 4mm; box-shadow: none; }
  .receipt-brand, .receipt-number, .receipt-total { break-inside: avoid; }
  .receipt-brand img { width: 34mm; }
}
