/* EngCalc — site-office calc sheet: concrete-grey ground, engineering blue for action, hi-vis yellow only on results */
:root {
  --bg: #F2F3EF;
  --surface: #FFFFFF;
  --surface-2: #E9EBE5;
  --ink: #15202B;
  --muted: #56626E;
  --line: #D5D9D1;
  --grid: rgba(29, 86, 184, .07);
  --accent: #1D56B8;
  --accent-hover: #17469A;
  --accent-ink: #FFFFFF;
  --hi: #F4C531;
  --hi-ink: #1B1A12;
  --danger: #B3261E;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --band-bg: #0E2F5A;
  --band-card: #143B6E;
  --band-ink: #EAF1FC;
  --band-muted: #A9BEDD;
  --radius: 6px;
  --wrap: 1120px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --band-bg: #0B2142; --band-card: #10305A; --band-ink: #E6EEFA; --band-muted: #9FB4D4;
    --bg: #10151B; --surface: #18202A; --surface-2: #202A35; --ink: #E6EAEE; --muted: #9AA6B2;
    --line: #2A3542; --grid: rgba(110, 160, 245, .08); --accent: #6EA0F5; --accent-hover: #8DB5F8;
    --accent-ink: #0C1420; --hi: #E9BA25; --hi-ink: #16140A; --danger: #F2827A; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --band-bg: #0B2142; --band-card: #10305A; --band-ink: #E6EEFA; --band-muted: #9FB4D4;
  --bg: #10151B; --surface: #18202A; --surface-2: #202A35; --ink: #E6EAEE; --muted: #9AA6B2;
  --line: #2A3542; --grid: rgba(110, 160, 245, .08); --accent: #6EA0F5; --accent-hover: #8DB5F8;
  --accent-ink: #0C1420; --hi: #E9BA25; --hi-ink: #16140A; --danger: #F2827A; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.6;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; text-wrap: balance; margin: 0; letter-spacing: .005em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.2rem); font-weight: 700; }
h2 { font-size: clamp(1.55rem, 3vw, 2rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
p { margin: 0; }
.num, input, select { font-variant-numeric: tabular-nums; }

.wrap {
  max-width: var(--wrap); margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.site-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; letter-spacing: .01em; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand b { color: var(--accent); font-weight: 700; }
.nav { display: flex; gap: 4px 16px; flex-wrap: wrap; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--hi); }

/* Breadcrumb + page head */
.crumbs { font-size: .85rem; color: var(--muted); padding-block: 18px 0; }
.crumbs a { color: var(--muted); }
.page-head { padding-block: 10px 22px; display: grid; gap: 10px; }
.page-head .lede { color: var(--muted); max-width: 62ch; font-size: 1.05rem; }
.eyebrow { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 16px; min-width: 0; }
.panel-title { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 480px) { .fields, .fields.three { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
label, .label { font-size: .85rem; font-weight: 500; color: var(--ink); }
.hint { font-size: .8rem; color: var(--muted); }
input[type="number"], input[type="text"], input[type="date"], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px; padding: 9px 10px; min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input-unit { position: relative; }
.input-unit input { padding-right: 46px; }
.input-unit span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: .8rem; color: var(--muted); pointer-events: none; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--bg); flex-wrap: wrap; }
.seg button { font: inherit; font-size: .9rem; border: 0; background: transparent; color: var(--muted); padding: 8px 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:not([aria-pressed="true"]):hover { color: var(--ink); }

.btn { font: inherit; font-weight: 600; font-size: .95rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 4px; padding: 10px 16px; min-height: 42px; cursor: pointer; text-decoration: none; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-calc { width: 100%; font-size: 1.05rem; min-height: 48px; }
#resultPanel { scroll-margin-top: calc(124px + env(safe-area-inset-top, 0px)); }
@keyframes ec-flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); transform: scale(1.015); } 100% { box-shadow: 0 0 0 12px transparent; transform: scale(1); } }
.result-main.flash { animation: ec-flash .6s ease-out; }
.link-btn { font: inherit; font-size: .85rem; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 0; }
.link-btn.danger { color: var(--danger); }

/* Results — calc sheet */
.result {
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
.result-main { background: var(--hi); color: var(--hi-ink); border-radius: 4px; padding: 14px 16px; display: grid; gap: 2px; }
.result-main .k { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.result-main .v { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.2rem, 6vw, 3rem); line-height: 1; font-variant-numeric: tabular-nums; }
.result-main .v small { font-size: .45em; font-weight: 600; margin-left: 4px; }
.result-main .sub { font-family: var(--font-mono); font-size: .85rem; }
.kv { display: grid; gap: 0; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: .92rem; }
.kv dd { margin: 0; font-family: var(--font-mono); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.working { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; white-space: pre-wrap; overflow-x: auto; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: var(--surface-2); white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 2px solid var(--ink); border-bottom: 0; }

/* Article / SEO content */
.content { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 40px; padding-block: 48px 24px; }
@media (max-width: 900px) { .content { grid-template-columns: minmax(0, 1fr); } }
.prose { display: grid; gap: 16px; max-width: 68ch; min-width: 0; }
.prose h2 { margin-top: 18px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }
.formula { font-family: var(--font-mono); background: var(--surface); border-left: 4px solid var(--hi); padding: 12px 14px; border-radius: 0 4px 4px 0; overflow-x: auto; }
.faq { display: grid; gap: 8px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin-top: 8px; color: var(--muted); }
.aside { display: grid; gap: 14px; align-content: start; }
.aside h3 { font-size: 1.1rem; }
.related { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.related a { display: block; text-decoration: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); font-weight: 500; }
.related a:hover { border-color: var(--accent); color: var(--accent); }
.related span { display: block; font-size: .8rem; color: var(--muted); font-weight: 400; }

/* Homepage */
.hero { padding-block: 48px 36px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 36px; align-items: center; }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); padding-block: 32px 24px; } }
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.4rem); text-transform: uppercase; letter-spacing: .01em; }
.hero h1 em { font-style: normal; background: linear-gradient(transparent 62%, var(--hi) 62%); }
.hero p { color: var(--muted); font-size: 1.12rem; max-width: 52ch; margin-top: 16px; }
.hero .btn-row { margin-top: 24px; }
.ticket { font-family: var(--font-mono); font-size: .86rem; }
.ticket .row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.ticket .row span:first-child { color: var(--muted); }
.section { padding-block: 32px; display: grid; gap: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tool-card { display: grid; gap: 8px; grid-template-rows: auto auto 1fr auto; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; transition: border-color .15s, transform .15s; }
a.tool-card:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-2px); }
.tool-card p { color: var(--muted); font-size: .92rem; }
.tool-card .go { font-weight: 600; color: var(--accent); font-size: .9rem; }
.tag { justify-self: start; font-family: var(--font-mono); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; padding: 3px 7px; border-radius: 3px; background: var(--surface-2); color: var(--muted); }
.tag.live { background: var(--hi); color: var(--hi-ink); }
.tool-card.soon { opacity: .72; }
.cats { display: grid; gap: 28px; }
.cat h3 { margin-bottom: 12px; }
.feature-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-block: 24px; }
.feature-strip div { display: grid; gap: 4px; }
.feature-strip b { font-family: var(--font-display); font-size: 1.2rem; }
.feature-strip span { color: var(--muted); font-size: .92rem; }

/* BOQ */
.boq-table input, .boq-table select { min-height: 36px; padding: 6px 8px; background: transparent; border-color: transparent; }
.boq-table input:hover, .boq-table select:hover { border-color: var(--line); }
.boq-table input:focus { background: var(--bg); }
.boq-table td { padding: 4px 6px; }
.boq-table .desc { min-width: 220px; }
.boq-table .qty, .boq-table .rate { width: 110px; text-align: right; }
.boq-table .unit { width: 84px; }
.boq-table .amt { white-space: nowrap; font-family: var(--font-mono); padding-right: 12px; }
.boq-table tr.section-row td { background: var(--surface-2); }
.boq-table tr.section-row input { font-weight: 700; font-family: var(--font-display); font-size: 1.05rem; text-transform: uppercase; }
.notice { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; border-radius: 4px; background: color-mix(in srgb, var(--hi) 28%, var(--surface)); border: 1px solid color-mix(in srgb, var(--hi) 70%, var(--line)); font-size: .92rem; }
.totals { display: grid; gap: 0; max-width: 380px; margin-left: auto; width: 100%; }
.totals > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-family: var(--font-mono); }
.totals > div.grand { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 700; font-size: 1.15rem; padding-top: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 4px; font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast a { color: var(--hi); margin-left: 8px; }

/* Footer */
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); background: var(--surface); }
.site-footer .wrap { padding-block: 28px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; font-size: .9rem; }
.site-footer h4 { margin: 0 0 8px; font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.site-footer a { color: var(--ink); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.site-footer .fine { color: var(--muted); grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 16px; font-size: .82rem; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Phones: show the result first, inputs below */
@media (max-width: 820px) { .calc > .result { order: -1; } }

/* Brand wordmark */
.brand b { color: var(--accent); }

/* Stories band (homepage) */
.stories-band { background: var(--band-bg); color: var(--band-ink); margin-block: 32px; }
.stories-band .wrap { padding-block: 48px; display: grid; gap: 24px; }
.stories-band .eyebrow { color: var(--hi); }
.stories-band h2 { color: var(--band-ink); margin-top: 6px; }
.band-lede { color: var(--band-muted); max-width: 60ch; margin-top: 10px; }
.stories-band .btn-ghost { color: var(--band-ink); border-color: rgba(255,255,255,.3); }
.stories-band .btn-ghost:hover { border-color: var(--hi); color: var(--hi); }

/* Story cards */
.story-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 960px) { .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .story-grid { grid-template-columns: minmax(0, 1fr); } }
.story-card { display: grid; grid-template-rows: auto 1fr; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .2s, border-color .2s, box-shadow .2s; }
.story-card:hover { color: var(--ink); transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 24px -14px rgba(10, 30, 60, .45); }
.stories-band .story-card { background: var(--band-card); color: var(--band-ink); border-color: rgba(255,255,255,.12); }
.stories-band .story-card:hover { border-color: var(--hi); color: var(--band-ink); }
.story-card .thumb { aspect-ratio: 16 / 9; max-width: 100%; overflow: hidden; background: #0E3566; }
.story-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.story-card:hover .thumb img { transform: scale(1.04); }
.story-card .body { display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; padding: 16px 18px 18px; }
.story-card .meta { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stories-band .story-card .meta { color: var(--hi); }
.story-card h3 { font-size: 1.4rem; }
.story-card p { font-size: .93rem; color: var(--muted); }
.stories-band .story-card p { color: var(--band-muted); }
.story-card .go { font-weight: 600; font-size: .9rem; color: var(--accent); }
.stories-band .story-card .go { color: var(--band-ink); }
.story-card.featured { grid-column: span 2; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-template-rows: none; }
.story-card.featured .thumb { aspect-ratio: auto; min-height: 100%; }
.story-card.featured h3 { font-size: 1.9rem; }
@media (max-width: 600px) { .story-card.featured { grid-column: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; } .story-card.featured .thumb { aspect-ratio: 16 / 9; } }

/* Story page */
.story-head { padding-block: 10px 24px; display: grid; gap: 12px; max-width: 820px; }
.story-head .lede { color: var(--muted); font-size: 1.15rem; max-width: 62ch; }
.story-meta { display: flex; gap: 8px 18px; flex-wrap: wrap; font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }
.story-figure { margin: 0; max-width: 1000px; }
.story-figure img { width: 100%; height: auto; border-radius: var(--radius); display: block; border: 1px solid var(--line); }
.story-figure figcaption { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.story-body { font-size: 1.08rem; line-height: 1.75; }
.story-body h2 { margin-top: 22px; }
.dropcap::first-letter { font-family: var(--font-display); font-weight: 700; float: left; font-size: 4.2em; line-height: .82; padding: 6px 10px 0 0; color: var(--accent); }
.lesson { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--hi); border-radius: 0 var(--radius) var(--radius) 0; padding: 16px 18px; display: grid; gap: 6px; margin-top: 10px; }
.lesson p { font-size: 1rem; }
.cta-box { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--band-bg); color: var(--band-ink); border-radius: var(--radius); padding: 18px 20px; }
.cta-box b { font-family: var(--font-display); font-size: 1.3rem; display: block; }
.cta-box span { color: var(--band-muted); font-size: .92rem; }
.cta-box .btn { background: var(--hi); color: var(--hi-ink); }
.cta-box .btn:hover { color: var(--hi-ink); filter: brightness(1.05); }
.more-stories { display: grid; gap: 18px; padding-block: 24px 8px; }

.contact-email { font-family: var(--font-mono); font-size: 1.3rem; user-select: all; word-break: break-all; }
