/* Tera Engineering injection molding estimator. Colours and type follow teraengineering.com. */
:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #0b1b3f;
  --ink-2: #3d4a66;
  --ink-3: #6b7791;
  --blue: #1d4ed8;
  --blue-d: #1a3fae;
  --blue-50: #eef3ff;
  --navy: #0b1b3f;
  --line: #e1e7f0;
  --line-2: #cfd8e6;
  --red: #b42318;
  --red-50: #fef3f2;
  --amber: #92400e;
  --amber-50: #fffbeb;
  --green: #067647;
  --radius: 14px;
  --head: "Space Grotesk", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --shadow: 0 1px 2px rgba(11, 27, 63, .04), 0 8px 24px -12px rgba(11, 27, 63, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body { font-family: var(--body); background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-3); font-weight: 400; }

/* header */
.top { background: #fff; border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.brand img { height: 56px; width: auto; }
.call { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); text-decoration: none; padding: 10px 12px; border-radius: 10px; }
.call:hover { background: var(--bg); }
.call svg { width: 18px; height: 18px; fill: none; stroke: var(--blue); stroke-width: 2; }

/* intro */
.intro { padding: 32px 0 24px; max-width: 720px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--blue); font-weight: 500; display: inline-flex; align-items: center; gap: 10px; }
.eyebrow::before { content: ""; width: 22px; height: 2px; background: currentColor; border-radius: 2px; }
h1, h2 { font-family: var(--head); letter-spacing: -.02em; line-height: 1.15; color: var(--ink); }
h1 { font-size: clamp(30px, 5vw, 44px); margin: 10px 0 10px; }
.lead { font-size: 17px; color: var(--ink-2); }

/* layout */
.layout { display: grid; gap: 20px; padding-bottom: 40px; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
  .side { position: sticky; top: 16px; }
}
.inputs, .side { display: grid; gap: 16px; min-width: 0; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card h2 { font-size: 20px; }
.card-sub { color: var(--ink-3); font-size: 14px; margin: -6px 0 14px; }
.card-tag { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.need { font-size: 12px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.dot, label.req::after { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
label.req::after { content: ""; margin-left: 6px; vertical-align: middle; }
label.star::after { content: " *"; color: var(--blue); }

/* fields */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.grid-1 { grid-template-columns: minmax(0, 1fr); }
.inputs { container-type: inline-size; }
@container (min-width: 560px) { .inputs .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.span-2 { grid-column: span 2; }
.field { min-width: 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.in { position: relative; display: flex; align-items: stretch; background: #fff; border: 1px solid var(--line-2); border-radius: 10px; transition: border-color .15s, box-shadow .15s; }
.in:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.in input, .in select { flex: 1; min-width: 0; width: 100%; height: 44px; border: 0; background: transparent; padding: 0 12px; font: inherit; font-size: 16px; color: var(--ink); border-radius: 10px; outline: none; }
.in input[inputmode] { font-variant-numeric: tabular-nums; }
.in select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.unit { display: flex; align-items: center; padding: 0 12px 0 0; font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; pointer-events: none; }
textarea { display: block; width: 100%; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink); resize: vertical; outline: none; }
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.err { font-size: 12px; color: var(--red); margin-top: 4px; font-weight: 500; }
.field.bad .in, .field.bad textarea { border-color: var(--red); background: var(--red-50); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* repeating rows (fasteners, operations) */
.rows { display: grid; gap: 10px; }
.rows:not(:empty) { margin-bottom: 12px; }
.row { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 10px; padding: 12px 44px 12px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.row .span-desc { grid-column: 1 / -1; }
.row-op .op-result { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.row-op .op-result:empty { display: none; }
@container (min-width: 420px) { .row-op { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (min-width: 560px) {
  .row-hw { grid-template-columns: minmax(0, 3fr) repeat(3, minmax(0, 1.3fr)); }
  .row-hw .span-desc { grid-column: auto; }
}
@container (min-width: 760px) { .row-op { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.x { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); font-size: 16px; cursor: pointer; }
.x:hover { background: var(--red-50); color: var(--red); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s, transform .15s; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.btn-primary { background: var(--blue); color: #fff; width: 100%; box-shadow: 0 8px 20px -8px rgba(29, 78, 216, .55); }
.btn-primary:hover { background: var(--blue-d); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: #fff; border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-add { background: var(--blue-50); color: var(--blue); }
.btn-add:hover { background: #e0e9ff; }
.btn-link { background: none; color: var(--ink-3); font-weight: 500; }
.btn-link:hover { color: var(--red); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }

/* results */
.result .card-head { margin-bottom: 8px; }
.result h2.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .16em; }
.saved { font-size: 12px; color: var(--ink-3); }
.empty { color: var(--ink-3); padding: 8px 0 4px; }
.headline { display: grid; gap: 2px; padding: 4px 0 12px; }
.headline .label { font-size: 13px; color: var(--ink-3); }
.big { font-family: var(--head); font-size: 46px; font-weight: 700; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; background: var(--navy); color: #fff; border-radius: 10px; }
.total strong { font-family: var(--head); font-size: 22px; font-variant-numeric: tabular-nums; }
.warn { list-style: none; margin-top: 12px; padding: 10px 12px; background: var(--amber-50); color: var(--amber); border-radius: 10px; font-size: 13px; }
.tables { display: grid; gap: 14px; margin-top: 14px; }
table.num { width: 100%; border-collapse: collapse; font-size: 14px; }
table.num caption { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; padding-bottom: 4px; }
table.num td { padding: 4px 0; border-bottom: 1px solid var(--line); }
table.num td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
table.num tr.sum td { font-weight: 600; border-bottom-color: var(--line-2); }
table.num tr.strong td { font-weight: 700; color: var(--ink); }
table.num td.sub { color: var(--ink-3); }
.result-actions { display: flex; gap: 8px; margin-top: 16px; }
.result-actions .btn { flex: 1; }
.copied { font-size: 13px; color: var(--green); min-height: 1.5em; margin-top: 6px; }

/* send for review */
.send h2 { margin-bottom: 8px; }
.send .card-sub { margin-top: 0; }
.send form { display: grid; gap: 14px; }
.fine { font-size: 12px; color: var(--ink-3); }
.form-msg { font-size: 14px; color: var(--red); font-weight: 500; }
.form-msg:empty { display: none; }
.sent { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 8px 0; }
.sent svg { width: 48px; height: 48px; fill: none; stroke: var(--green); stroke-width: 2; }
.sent p { color: var(--ink-2); }

/* phone: a bar with the price at the bottom while the result card is off screen */
.mbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--navy); color: #fff; text-decoration: none; box-shadow: 0 -8px 24px -12px rgba(11, 27, 63, .5); font-variant-numeric: tabular-nums; }
.mbar strong { font-family: var(--head); font-size: 18px; }
.mbar-l { font-size: 12px; opacity: .75; margin-right: 4px; }
@media (min-width: 1000px) { .mbar { display: none !important; } }
body.has-mbar { padding-bottom: 64px; }

/* footer */
.foot { border-top: 1px solid var(--line); background: #fff; padding: 20px 0 28px; font-size: 13px; color: var(--ink-2); }
.foot p + p { margin-top: 6px; }
.foot a { color: inherit; }

/* print: only the customer-facing sheet (no costs or rates) */
.print-sheet { display: none; }
@media print {
  @page { margin: 16mm; }
  body { background: #fff; padding: 0 !important; }
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; color: #000; font-size: 12pt; }
  .print-sheet img { height: 52px; width: auto; margin-bottom: 18px; }
  .print-sheet h1 { font-size: 22pt; margin: 0 0 4px; }
  .print-sheet .p-date { color: #555; margin-bottom: 18px; }
  .print-sheet table { border-collapse: collapse; width: 100%; margin: 10px 0 18px; }
  .print-sheet td { padding: 6px 0; border-bottom: 1px solid #ccc; vertical-align: top; }
  .print-sheet td:last-child { text-align: right; }
  .print-sheet pre { font-family: inherit; white-space: pre-wrap; margin: 0 0 14px; }
  .print-sheet .p-fine { font-size: 9pt; color: #555; margin-top: 24px; }
}
