@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/barlow-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/barlow-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('/fonts/source-sans-3-latin.woff2') format('woff2');
}

:root {
  --ink: #171a1d;
  --ink-soft: #2b3035;
  --paper: #f6f4ef;
  --surface: #ffffff;
  --red: #c8102e;
  --red-dark: #8e0b20;
  --red-soft: #fbe9ec;
  --steel: #5f6872;
  --line: #d8d3ca;
  --line-strong: #b9b2a7;
  --ok: #1f7a4d;
  --ok-soft: #e7f6ee;
  --warn: #b54708;
  --warn-soft: #fff4e5;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(23, 26, 29, 0.05);
  --font-display: 'Barlow', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink);
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.65rem, 5vw, 2.1rem); line-height: 1.1; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; line-height: 1.2; margin: 1.5rem 0 0.6rem; }
h2:first-of-type { margin-top: 0; }
p { margin: 0.5rem 0; }
a { color: var(--red); text-underline-offset: 0.15em; }
a:hover { color: var(--red-dark); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: #eee9e1;
}
:focus-visible { outline: 3px solid rgba(200, 16, 46, 0.35); outline-offset: 2px; }

.test-banner {
  background: var(--red);
  color: #fff;
  text-align: center;
  padding: 0.45rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 1rem; }
.wide { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
  margin-bottom: 1.25rem;
}
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand-logo { display: inline-flex; align-items: center; }
.brand-logo img { display: block; height: 48px; width: auto; }
.top-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; color: var(--steel); font-size: 0.82rem; text-align: right; }
.top-kicker { color: var(--red); font-family: var(--font-display); font-weight: 600; font-size: 0.78rem; }

main.card { width: min(820px, calc(100% - 2rem)); margin: 1.25rem auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card.intro {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0 0 1rem;
}
.card.intro h1 { margin-bottom: 0.35rem; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.75rem 0 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.section-head:first-of-type { margin-top: 0.25rem; padding-top: 0; border-top: 0; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; }

.steps {
  counter-reset: step;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  color: var(--steel);
  font-size: 0.82rem;
}
.steps li { display: flex; align-items: center; gap: 0.4rem; }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--steel);
}
.steps li.is-active { color: var(--ink); font-weight: 600; }
.steps li.is-active::before { background: var(--red); border-color: var(--red); color: #fff; }
.steps li.is-done::before { background: var(--ink); border-color: var(--ink); color: #fff; }

.muted { color: var(--steel); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); }
.ok { color: var(--ok); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1rem;
}
.grid .span2 { grid-column: span 2; }

label { display: block; font-weight: 600; font-size: 0.9rem; color: var(--ink-soft); }
label input, label select, label textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 0.3rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
  background: #fff;
  color: var(--ink);
}
label textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(200, 16, 46, 0.14);
  outline-offset: 0;
  border-color: var(--red);
}

.search { margin-bottom: 0.5rem; }
.search input { padding-right: 2.5rem; }

.results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  max-height: min(780px, 80vh);
  overflow: auto;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf9f6;
}
.results-empty,
.results-loading {
  grid-column: 1 / -1;
  padding: 1rem 0.5rem;
  color: var(--steel);
  text-align: center;
}
.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 160ms ease, transform 160ms ease;
}
.product-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.product-card-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.product-card-main:focus-visible {
  outline: 3px solid rgba(200, 16, 46, 0.35);
  outline-offset: -3px;
}
.product-card-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #f7f4ef;
  border-bottom: 1px solid var(--line);
}
.product-card-media img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0.5rem;
  object-fit: contain;
}
.product-card-media-fallback svg {
  width: 44%;
  height: 44%;
  max-width: 60px;
  max-height: 60px;
  color: var(--steel);
}
.product-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.7rem 0.75rem 0.8rem;
}
.product-card-name {
  display: -webkit-box;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.product-card-meta {
  color: var(--steel);
  font-size: 0.78rem;
}
.product-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.2rem 0.5rem;
  margin-top: auto;
  padding-top: 0.35rem;
}
.product-card-price {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.product-card-add {
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.product-card.is-added {
  border-color: var(--ok);
}
.product-card.is-added .product-card-add {
  color: var(--ok);
}
.product-card-sheet {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--steel);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}
.product-card-sheet:hover {
  color: var(--red);
  border-color: var(--line-strong);
  background: #fff;
}
.product-card-sheet:focus-visible {
  outline: 3px solid rgba(200, 16, 46, 0.35);
  outline-offset: 2px;
}
.product-card-sheet svg {
  width: 1rem;
  height: 1rem;
}

.lines { margin: 0.75rem 0 1rem; border-top: 1px solid var(--line); }
.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 120px 110px 44px;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.line-head { padding: 0.5rem 0; color: var(--steel); font-size: 0.78rem; }
.line-product { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.line-thumb {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.line-info { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.line-name { font-weight: 600; line-height: 1.25; }
.line-meta { color: var(--steel); font-size: 0.82rem; }
.datasheet-link { color: var(--steel); font-size: 0.8rem; text-decoration: underline; }
.datasheet-link:hover { color: var(--red); }
.line-price, .line-total { font-variant-numeric: tabular-nums; }
.line-price { color: var(--steel); }
.line-total { font-family: var(--font-display); font-weight: 700; }
.line-qty { display: flex; align-items: center; justify-content: flex-end; gap: 0.25rem; }
.qty-btn {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.qty-btn:hover { border-color: var(--red); color: var(--red); }
.line-qty input {
  width: 3.5rem;
  min-height: 2rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  text-align: center;
}
.line-actions { display: flex; justify-content: flex-end; }
.line-actions .button { padding: 0.4rem 0.6rem; font-size: 0.8rem; }
.empty-state { padding: 1.25rem 0; color: var(--steel); }
.lines-body { display: block; }

.totals { margin: 1rem 0; border-top: 1px solid var(--line); padding-top: 0.75rem; }
.totals > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; }
.totals .grand { margin-top: 0.35rem; padding-top: 0.5rem; border-top: 1px solid var(--line); font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }

.form-step[hidden] { display: none; }
.step-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.step-actions-end { justify-content: flex-end; }
.step-actions .button { min-width: 7rem; }

.cart-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.cart-summary span { color: var(--steel); font-size: 0.9rem; }
.cart-summary strong { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }

.review-summary { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.review-block {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.4rem; }
.review-head h3 { margin: 0; font-size: 1rem; }
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--red);
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}
.link-button:hover { color: var(--red-dark); }
.review-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.2rem 0.75rem; margin: 0; }
.review-list dt { color: var(--steel); font-size: 0.85rem; }
.review-list dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.review-products { list-style: none; margin: 0; padding: 0; }
.review-products li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--line);
}
.review-products li:first-child { border-top: 0; }
.review-products li span { color: var(--ink-soft); }
.review-products li strong { white-space: nowrap; font-variant-numeric: tabular-nums; }

.checkout { margin-top: 1rem; }
.checkout .button { width: 100%; }
.checkout-actions { display: flex; gap: 0.5rem; }
.checkout-actions .button { width: auto; flex: 1; }
.checkout-actions .button.ghost { flex: 0 0 auto; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--red);
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.button:disabled { opacity: 0.6; cursor: not-allowed; }
.button.ghost { background: #fff; color: var(--red); border-color: var(--line-strong); }
.button.ghost:hover { background: var(--red-soft); border-color: var(--red); color: var(--red-dark); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.danger:hover { background: #8f1d13; border-color: #8f1d13; color: #fff; }

.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.turnstile { margin: 0.75rem 0; min-height: 1px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #eee9e1;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}
.status::before { content: ''; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; opacity: 0.8; }
.status-pending { background: var(--warn-soft); color: var(--warn); }
.status-approved { background: var(--red-soft); color: var(--red-dark); }
.status-issued { background: var(--ok-soft); color: var(--ok); }
.status-rejected { background: var(--danger-soft); color: var(--danger); }
.status-failed { background: var(--danger-soft); color: var(--danger); }

table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1rem; }
th, td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--steel); font-size: 0.78rem; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.kv th { width: 170px; color: var(--steel); font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.toolbar .button { min-height: 40px; padding: 0.45rem 0.8rem; font-size: 0.9rem; }
.toolbar .button.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .meta { margin: 0; color: var(--steel); font-size: 0.85rem; }

.payment-info {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.payment-info p { margin: 0.2rem 0; }

.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.inline-form input, .inline-form select {
  min-height: 44px;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-start; margin-top: 1rem; }
.actions form { margin: 0; }

footer { padding: 1rem 1rem 2rem; }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .grid .span2 { grid-column: span 1; }
  .top { margin-bottom: 0.75rem; }
  .brand-logo img { height: 40px; }
  .top-kicker { display: none; }
  .card { padding: 1rem; }
  main.card { width: calc(100% - 1.5rem); }
  .section-head { align-items: flex-start; flex-direction: column; gap: 0.15rem; }
  .steps { gap: 0.35rem 0.75rem; }
  .results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    padding: 0.6rem;
    max-height: 60vh;
  }
  .product-card-body { padding: 0.6rem 0.6rem 0.7rem; }
  .product-card-name { font-size: 0.92rem; }
  .product-card-footer { flex-direction: column; align-items: flex-start; gap: 0.1rem; }
  .product-card-price { font-size: 0.98rem; }
  .product-card-add { font-size: 0.74rem; }
  .product-card-sheet { width: 2.5rem; height: 2.5rem; }
  .line-head { display: none; }
  .line {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'product product'
      'price qty'
      'total actions';
    gap: 0.5rem 0.75rem;
    padding: 0.9rem 0;
  }
  .line-product { grid-area: product; }
  .line-price { grid-area: price; align-self: center; }
  .line-price::before { content: attr(data-label); margin-right: 0.25rem; color: var(--steel); font-size: 0.8rem; }
  .line-qty { grid-area: qty; justify-self: end; }
  .line-total { grid-area: total; align-self: center; }
  .line-total::before { content: attr(data-label); margin-right: 0.25rem; color: var(--steel); font-family: var(--font-body); font-size: 0.8rem; font-weight: 400; }
  .line-actions { grid-area: actions; justify-self: end; }
  .checkout.has-items {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 1rem -1rem 0;
    padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .checkout.has-items .totals {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.1rem 1rem;
    margin: 0 0 0.5rem;
    padding-top: 0;
    border-top: 0;
  }
  .checkout.has-items .totals > div { padding: 0; }
  .checkout.has-items .totals .grand {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
    padding-top: 0.3rem;
    border-top: 1px solid var(--line);
    font-size: 1.1rem;
  }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive thead { display: none; }
  table.responsive tr {
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
  }
  table.responsive td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.3rem 0;
    border: 0;
    text-align: right;
  }
  table.responsive td::before { content: attr(data-label); color: var(--steel); font-weight: 600; text-align: left; }
  table.kv, table.kv tbody, table.kv tr, table.kv th, table.kv td { display: block; width: 100%; }
  table.kv tr { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
  table.kv th { padding-bottom: 0; border-bottom: 0; }
  table.kv td { padding-top: 0.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
