:root {
  color-scheme: light;
  --ink: #142631;
  --deep: #111e29;
  --panel: #182c39;
  --paper: #f7f5ef;
  --white: #fffefa;
  --mint: #bdebd8;
  --emerald: #235c48;
  --muted: #54615c;
  --line: #d9ddd4;
  --control-line: #808d82;
  --error: #a42d36;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  font: 15px/1.55 var(--sans);
  color: var(--ink);
  background: var(--deep);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { color: inherit; font: inherit; }
button { cursor: pointer; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #327b63; outline-offset: 3px; }
.masthead :focus-visible, .summary :focus-visible, .footer :focus-visible { outline-color: var(--mint); }
button, a, input, select { transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
[hidden] { display: none !important; }
.wrap { max-width: 1304px; padding-inline: 32px; margin-inline: auto; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: absolute; z-index: 5; top: 10px; left: 10px; padding: 12px 18px; border-radius: 5px; background: var(--mint); }
#calculator { scroll-margin-top: 12px; }

.masthead, .footer { color: #f9f7ef; }
.masthead { border-bottom: 1px solid #30404a; }
.masthead-inner { min-height: 75px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; min-height: 44px; align-items: center; gap: 11px; font-size: 1.31rem; font-weight: 700; letter-spacing: -.065em; }
.brand-mark { width: 30px; height: 30px; display: grid; flex: none; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); gap: 2px; padding: 5px; border-radius: 8px; background: var(--mint); }
.brand-mark i { background: #173c35; border-radius: 1px; }
.brand-mark i:nth-child(2) { border-radius: 1px 5px 1px 1px; opacity: .6; }
.brand-mark i:nth-child(3) { opacity: .8; }
nav { display: flex; align-items: center; gap: 26px; font-size: .86rem; font-weight: 600; }
nav a { display: inline-flex; min-height: 44px; align-items: center; gap: 10px; }
nav a:hover { color: var(--mint); }
.eyebrow { font-size: .72rem; font-weight: 750; line-height: 1.35; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, #unit-cost, #target-price { font-family: var(--serif); font-weight: 400; }
h1 { margin-block: 19px 20px; font-size: clamp(2.9rem, 5vw, 4.8rem); line-height: 1.04; letter-spacing: -.055em; }
h1 em { color: var(--mint); font-weight: 400; }
.primary-button { display: inline-flex; min-height: 49px; align-items: center; gap: 25px; margin-top: 27px; padding: 0 17px; border-radius: 7px; background: var(--mint); color: #18362e; font-size: .88rem; font-weight: 750; }
.primary-button:hover { background: #d8f6e8; }
.primary-button span { font-size: 1.12rem; font-weight: 500; }
.cost-bar { display: flex; height: 9px; gap: 3px; margin-block: 15px 15px; border-radius: 5px; overflow: hidden; }
.mat { background: #bdebd8; }.pack { background: #dfc69e; }.lab { background: #a9bfe7; }.over { background: #ad9bc8; }

.calculator { padding-block: 56px 70px; background: var(--paper); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px 36px; margin-bottom: 25px; }
h2 { font-size: clamp(2.55rem, 5vw, 4.25rem); letter-spacing: -.045em; line-height: 1.01; }
.section-head p { margin-top: 9px; color: var(--muted); }
.currency-field { display: grid; gap: 4px; width: 242px; flex: none; }
.currency-field label, .field label { font-size: .8rem; font-weight: 700; }
.currency-field small, .field small { color: var(--muted); font-size: .75rem; line-height: 1.4; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1.93fr) minmax(285px, 1fr); align-items: start; gap: 24px; }
.form-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; min-height: 45px; margin-bottom: 10px; }
.form-toolbar p { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.form-toolbar p span { width: 7px; height: 7px; border-radius: 50%; background: #538d73; flex: none; }
.form-toolbar > div { display: flex; flex-wrap: wrap; gap: 0 10px; }
.text-button { min-height: 44px; padding: 0 5px; border: 0; background: transparent; color: var(--emerald); font-size: .8rem; font-weight: 700; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-button:disabled { color: var(--muted); text-decoration: none; cursor: default; opacity: .75; }
.new-batch-button { min-height: 44px; padding: 0 12px; border: 1px solid var(--emerald); border-radius: 7px; background: var(--emerald); color: var(--white); font-size: .8rem; font-weight: 750; }
.new-batch-button:hover { background: #173c31; }
.draft-panel { margin-bottom: 12px; padding: 10px 13px; border: 1px solid #dbddd4; border-radius: 9px; background: var(--white); }
.draft-panel h2 { font: 750 .87rem/1.4 var(--sans); letter-spacing: normal; }
.draft-panel p { color: var(--muted); font-size: .8rem; }
.draft-actions { display: flex; flex-wrap: wrap; gap: 0 8px; }
#draft-status { font-weight: 650; }
.muted-button { color: var(--muted); }
#batch-form { display: grid; gap: 14px; }
.card { padding: clamp(14px, 2vw, 24px); border: 1px solid #dbddd4; border-radius: 13px; background: var(--white); box-shadow: 0 2px 3px #28332908; }
.card-heading { display: flex; align-items: start; gap: 12px; margin-bottom: 20px; }
.section-icon { display: grid; flex: none; width: 38px; height: 38px; place-items: center; color: var(--emerald); border-radius: 8px; background: #e8f4eb; }
.section-icon svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.card-heading h2, .summary-head h2 { font-family: var(--sans); font-size: 1.16rem; font-weight: 720; letter-spacing: -.035em; line-height: 1.25; }
.card-heading p { margin-top: 4px; color: var(--muted); font-size: .83rem; line-height: 1.48; }
.material-head, .material-fields { display: grid; grid-template-columns: minmax(115px, 1.7fr) minmax(47px, .64fr) minmax(59px, .75fr) minmax(76px, .98fr) minmax(71px, 1fr) 44px; align-items: center; gap: 8px; }
.material-head { margin-bottom: 5px; color: var(--muted); font-size: .73rem; font-weight: 700; }
.material-head span:nth-child(5) { text-align: right; }
.material-row + .material-row { margin-top: 8px; }
.material-fields label, .line-cost span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 15px; }
.field { display: grid; align-content: start; gap: 5px; min-width: 0; }
input, select { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid var(--control-line); border-radius: 6px; background: #fffefa; font-size: .87rem; }
input::placeholder { color: #6a756e; opacity: 1; }
input:hover, select:hover { border-color: #637c6d; }
input[aria-invalid="true"] { border-color: var(--error); background: #fff7f5; }
.joined { display: grid; grid-template-columns: minmax(0, 1fr) minmax(94px, 38%); }
.joined input { border-radius: 6px 0 0 6px; }
.joined select { padding-inline: 6px; border-radius: 0 6px 6px 0; border-left-width: 0; background: #f1f5ee; }
.joined :focus-visible { z-index: 1; }
.with-suffix { position: relative; }
.with-suffix input { padding-right: 30px; }
.with-suffix span { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.optional { margin-left: 3px; color: var(--muted); font-size: .69rem; font-weight: 450; }
.line-cost { text-align: right; color: #344f44; overflow-wrap: anywhere; font-size: .83rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.remove-material { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #5d6a62; }
.remove-material:hover { color: var(--error); background: #f9ece8; }
.remove-material svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.card-tail { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; padding-top: 11px; border-top: 1px solid #e0e3db; }
.add-button { display: inline-flex; flex: none; align-items: center; gap: 7px; min-height: 44px; padding: 0 10px; border: 1px solid #c8dacf; border-radius: 6px; color: var(--emerald); background: #f0f7f1; font-size: .81rem; font-weight: 750; }
.add-button:hover { background: #e0f0e6; }
.add-button span { font-size: 1.13rem; font-weight: 500; line-height: 1; }
.subtotal { display: flex; flex-wrap: wrap; justify-content: end; gap: 1px 10px; color: var(--muted); font-size: .77rem; text-align: right; }
.subtotal strong { color: var(--ink); overflow-wrap: anywhere; font-size: .87rem; }
.error-message { margin-top: 3px; color: var(--error) !important; font-size: .76rem; font-weight: 650; }
.conversion-note { grid-column: 1 / -1; padding: 7px 10px; border-left: 2px solid #719784; color: var(--emerald); background: #eef6ef; font-size: .8rem; line-height: 1.45; }
.conversion-note:empty { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
.noscript { padding: 12px; border: 1px solid var(--line); }
.mobile-result-link, .price-preview { display: none; }
dialog { max-width: min(420px, calc(100% - 30px)); padding: 22px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--white); box-shadow: 0 12px 50px #0c17234d; }
dialog::backdrop { background: #111e29a6; }
dialog h2 { margin-bottom: 8px; font-size: 2rem; }
dialog p { color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; margin-top: 20px; }
.dialog-actions button { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); font-size: .83rem; font-weight: 700; }
.dialog-actions button:hover { border-color: #81998a; }
.dialog-actions .confirm-button { background: var(--mint); color: #18362e; }

.summary { position: sticky; top: 18px; margin-top: 55px; padding: clamp(17px, 2.1vw, 27px); border: 1px solid #223a46; border-radius: 14px; color: #f8f5ea; background: var(--panel); box-shadow: 0 10px 22px #28363719; font-variant-numeric: tabular-nums; }
.summary-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.summary-head span { padding: 4px 7px; border: 1px solid #4d6768; border-radius: 5px; color: #d1e7dd; font-size: .68rem; font-weight: 700; letter-spacing: .09em; }
.key-result { margin-top: 17px; padding-top: 14px; border-top: 1px solid #3f535b; }
.key-result p, .price-result p { font-size: .83rem; font-weight: 650; }
#unit-cost { display: block; margin: 3px 0 0; color: var(--mint); font-size: clamp(3.5rem, 5vw, 5rem); line-height: 1.04; letter-spacing: -.045em; }
#unit-cost, #target-price, .summary dd { overflow-wrap: anywhere; }
.summary small, #proposed-context { display: block; color: #bfcecd; font-size: .75rem; line-height: 1.45; }
.summary .pricing-scope { margin-top: 9px; }
.price-result { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-top: 17px; padding: 11px 12px; border: 1px solid #4d696a; border-radius: 8px; background: #263f49; }
#target-price { flex-shrink: 0; max-width: 48%; text-align: right; color: var(--mint); font-size: clamp(1.5rem, 2.6vw, 2.5rem); line-height: 1; letter-spacing: -.03em; }
.summary dl > div { display: flex; justify-content: space-between; gap: 10px; padding-block: 4px; }
.summary dd { max-width: 60%; font-weight: 700; text-align: right; }
.summary-totals { margin-block: 12px 8px; font-size: .85rem; }
.result-detail { border-top: 1px solid #3f535b; }
summary { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 10px; list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ""; width: 8px; height: 8px; flex: none; margin-right: 4px; transform: rotate(45deg); border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; }
details[open] > summary::after { transform: rotate(225deg); }
.result-detail summary { font-size: .79rem; font-weight: 700; color: #e6f1eb; }
.result-detail summary:hover { color: var(--mint); }
.result-detail dl { padding-bottom: 8px; font-size: .78rem; color: #d8e3de; }
.result-detail dt i { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 2px; vertical-align: 1px; }
#proposed-context:empty { display: none; }
#proposed-context { margin-bottom: 11px; }
#yield-context:empty { display: none; }
#yield-context { margin-bottom: 8px; }
.summary [data-negative] { color: #ffbcba; }

.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px 30px; padding-block: 30px 34px; }
.footer p { margin-top: 3px; color: #bfcac8; font-size: .83rem; }
.footer nav { flex-wrap: wrap; }

@media (max-width: 1080px) {
  .tool-grid { gap: 17px; }
  .material-head, .material-fields { grid-template-columns: minmax(85px, 1.55fr) minmax(43px, .65fr) minmax(55px, .75fr) minmax(69px, 1fr) minmax(56px, .85fr) 44px; gap: 6px; }
}
@media (max-width: 850px) {
  .wrap { padding-inline: 24px; }
  h1 { font-size: clamp(2.3rem, 5vw, 3.45rem); }
  .tool-grid { grid-template-columns: 1fr; gap: 15px; }
  .summary { position: static; margin-top: 0; }
  .mobile-result-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--emerald); font-size: .81rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
  .summary > .mobile-result-link { color: var(--mint); }
  .price-preview { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 56px; margin-bottom: 12px; padding: 5px 8px 5px 12px; border: 1px solid #384c53; border-radius: 9px; background: var(--panel); color: #f8f5ea; }
  .price-preview dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .price-preview dt { color: #bfcecd; font-size: .75rem; font-weight: 650; }
  .price-preview dd { color: var(--mint); font-size: .96rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
  .price-preview a { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; gap: 4px; padding: 0 6px; border: 1px solid #668184; border-radius: 6px; color: var(--mint); font-size: .72rem; font-weight: 700; white-space: nowrap; }
  .price-preview a:hover { background: #263f49; }
  .price-preview a:focus-visible { outline-color: var(--mint); }
}
@media (max-width: 850px) and (min-height: 540px) {
  .price-preview:not(.long-prices) { position: sticky; top: 6px; z-index: 2; }
  #batch-form :is(input, select, button) { scroll-margin-block: 82px 12px; }
}
@media (max-width: 735px) {
  .material-head { display: none; }
  .material-row { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: #f7f8f2; }
  .material-row + .material-row { margin-top: 10px; }
  .material-fields { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px; align-items: end; }
  .material-fields > .field:nth-child(1) { grid-column: span 4; }
  .material-fields > .field:nth-child(2) { grid-column: span 2; }
  .material-fields > .field:nth-child(3), .material-fields > .field:nth-child(4) { grid-column: span 3; }
  .material-fields label, .line-cost span { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; }
  .material-fields label { font-size: .85rem; }
  .line-cost { grid-column: span 4; display: flex; gap: 7px; flex-wrap: wrap; align-items: center; min-height: 44px; text-align: left; }
  .line-cost span { color: var(--muted); font-weight: 600; }
  .remove-material { grid-column: span 2; justify-self: end; border-color: #c5cec4; background: var(--white); }
}
@media (max-width: 640px) {
  .wrap { padding-inline: 17px; }
  input, select { font-size: 16px; }
  .masthead-inner { min-height: 65px; gap: 9px; }
  .brand { gap: 6px; font-size: 1.13rem; }
  .brand-mark { width: 25px; height: 25px; padding: 4px; border-radius: 6px; }
  nav { gap: 9px; font-size: .74rem; }
  h1 { margin-block: 15px 16px; font-size: clamp(2.4rem, 9.8vw, 4.1rem); }
  .primary-button { margin-top: 20px; }
  .calculator { padding-block: 37px; }
  .section-head { display: grid; margin-bottom: 13px; }
}
@media (max-width: 365px) {
  .wrap { padding-inline: 12px; }
  h1 { font-size: clamp(2rem, 10.3vw, 2.4rem); }
  .field-grid { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-height: 725px) { .summary { position: static; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
