:root {
  color-scheme: light;
  --ink: #272324;
  --muted: #645d5f;
  --line: #e3dddb;
  --surface: #fff;
  --background: #f7f5f3;
  --accent: #742c39;
  --accent-dark: #57202a;
  --tint: #f7eff0;
  --focus: #8a4552;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead-inner {
  max-width: 1240px;
  min-height: 66px;
  padding-inline: 28px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 42px;
}
.identity { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.identity strong { font-size: .85rem; letter-spacing: .08em; }
.identity span { color: var(--muted); }
.identity b { font: bold 1.2rem Georgia, serif; color: var(--accent); }
nav { display: flex; align-self: stretch; gap: 18px; }
.nav {
  padding: 0 6px;
  background: transparent;
  border: 0;
  border-block: 2px solid transparent;
  color: var(--muted);
  font-size: .94rem;
}
.nav[aria-current="page"] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 650; }
.nav:hover { color: var(--accent); }
.demo-label { margin-left: auto; color: var(--muted); font-size: .875rem; white-space: nowrap; }

main { max-width: 1240px; margin-inline: auto; padding: 30px 28px 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 23px; }
h1 { margin: 0; font: 400 clamp(1.9rem, 4vw, 2.65rem)/1.12 Georgia, "Times New Roman", serif; letter-spacing: -.022em; }
h2 { margin: 0 0 15px; font-size: 1.14rem; line-height: 1.3; }
h3, legend { margin: 0; font-size: .875rem; font-weight: 650; }
p { margin: 0; }
.head p, .muted, .hint, .reference { color: var(--muted); }
.head p { margin-top: 6px; }
.hint, .reference { font-size: .8125rem; }
.hint:empty, .error:empty { display: none; }
.hint:not(:empty) { margin-top: 11px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.layout > * { min-width: 0; }
.stack { display: grid; gap: 18px; }
.card, .quote-paper { min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 21px 22px; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; column-gap: 16px; flex-wrap: wrap; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #d6ccca;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: .875rem;
  font-weight: 650;
}
.btn:not(:disabled):hover { background: #f4eeec; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:not(:disabled):hover { background: var(--accent-dark); }

.fields, .measurements, .checkgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.measurements { grid-template-columns: minmax(0, 3fr) minmax(90px, 1fr); align-items: end; margin-top: 17px; }
.measurements h3 { margin-bottom: 5px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: .875rem; font-weight: 600; }
.measurements .three .field > span { font-size: .8125rem; color: var(--muted); font-weight: 500; }
input:not([type="checkbox"]), select, textarea {
  min-width: 0;
  min-height: 42px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d7cdcb;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}
select {
  appearance: none;
  padding-right: 32px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='m3 5 4 4 4-4' fill='none' stroke='%23645d5f' stroke-width='1.4'/%3E%3C/svg%3E") right 10px center / 14px no-repeat;
}
textarea { resize: vertical; }
fieldset { margin: 16px 0; min-width: 0; border: 0; padding: 0; }
legend { margin-bottom: 5px; padding: 0; }
.checkgrid { gap: 3px 12px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 35px; font-size: .875rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 17px; height: 17px; flex: none; margin: 0; }

.summary h2 { margin-bottom: 4px; }
.summary-spec { color: var(--muted); font-size: .875rem; margin-bottom: 15px; overflow-wrap: anywhere; }
.calc-row { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; padding: 5px 0; font-size: .875rem; }
.calc-row span { color: var(--muted); }
.calc-row strong, .amount, .pricebig, .record-sum { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cost-subtotal { border-top: 1px solid var(--line); margin-top: 5px; padding-top: 4px; }
.margin-row { padding: 11px 0 7px; display: flex; gap: 12px; justify-content: space-between; align-items: center; font-size: .875rem; font-weight: 650; }
.margin-row input { width: 92px; }
.total { display: grid; gap: 2px; margin-top: 9px; border-top: 2px solid var(--accent); padding: 11px 13px; background: var(--tint); font-size: .875rem; }
.amount { font-size: clamp(1.3rem, 4.8vw, 2.05rem); line-height: 1.16; color: var(--accent); white-space: normal; overflow-wrap: anywhere; }
.unit-price { color: var(--muted); }
.summary-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.summary-actions .primary { flex: 1; }
.error { color: #9e243c; font-size: .875rem; padding-top: 8px; }

.quote-layout { grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); }
.quote-layout .actions { margin-top: 18px; }
.quote-paper { padding: 23px; overflow-wrap: anywhere; }
.quote-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; border-bottom: 2px solid var(--accent); padding-bottom: 13px; margin-bottom: 17px; font-size: .8125rem; }
.quote-head .hint { margin-top: 3px; }
.document-brand { color: var(--accent); font: bold 1.15rem Georgia, serif; }
.quote-paper h2 { margin-bottom: 8px; }
.quote-paper dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 6px 12px; margin: 9px 0 0; font-size: .875rem; }
.quote-paper dt { color: var(--muted); }
.quote-paper dd { margin: 0; white-space: pre-wrap; }
.pricebig { color: var(--accent); font-size: 1.7rem; font-weight: 750; white-space: normal; overflow-wrap: anywhere; }
.rule { border-top: 1px solid var(--line); margin-block: 13px; }

.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(145px, 200px); gap: 10px; margin-bottom: 15px; }
table { border-collapse: collapse; width: 100%; font-size: .875rem; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px; overflow-wrap: anywhere; }
th { color: var(--muted); background: var(--background); font-weight: 600; }
td small { display: block; color: var(--muted); margin-top: 2px; }
td .btn { min-height: 36px; }
.record-open { text-align: right; }
.status { color: var(--muted); white-space: nowrap; }
.status.sent { color: #765117; }
.status.accepted { color: #325a43; }
.status.rejected { color: var(--accent); }
.empty { color: var(--muted); padding: 20px 0 12px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.rate-label { display: grid; grid-template-columns: minmax(0, 1fr) minmax(75px, 125px); align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 7px 0; font-size: .875rem; }
.rate-label small { color: var(--muted); margin-left: 6px; }
.note { background: var(--tint); padding: 12px; margin: 13px 0; font-size: .875rem; }
footer { display: flex; justify-content: space-between; gap: 12px; padding: 18px 0; margin-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8125rem; }
footer a { color: var(--muted); text-underline-offset: 3px; }
#toast { position: fixed; bottom: 16px; right: 16px; z-index: 2; max-width: calc(100% - 32px); padding: 9px 14px; background: var(--ink); color: white; border-radius: 4px; opacity: 0; pointer-events: none; font-size: .875rem; }
#toast.show { opacity: 1; }

@media (max-width: 780px) {
  .masthead-inner { gap: 18px; }
  .layout, .quote-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .stack { gap: 14px; }
  table, tbody { display: block; }
  thead { display: none; }
  tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; padding: 12px 0; border-top: 1px solid var(--line); }
  td { padding: 0; border: 0; }
  .record-ref, .record-customer { grid-column: 1 / -1; }
  .record-sum { text-align: right; }
  .record-status { align-self: center; }
}
@media (max-width: 530px) {
  .masthead-inner { flex-wrap: wrap; gap: 0; padding: 10px 15px 0; }
  .demo-label { order: 0; font-size: .8125rem; }
  nav { order: 1; width: 100%; gap: 20px; margin-top: 5px; }
  .nav { min-height: 42px; }
  main { padding: 20px 14px 0; }
  .head { align-items: flex-start; gap: 11px; flex-wrap: wrap; margin-bottom: 15px; }
  .card, .quote-paper { padding: 15px; }
  .fields:not(.three), .measurements { grid-template-columns: minmax(0, 1fr); }
  .check { min-height: 42px; }
  .filters { grid-template-columns: minmax(0, 1fr); }
}
