:root {
  --bg: #f7f8f7;
  --surface: #ffffff;
  --text: #17201e;
  --muted: #56625f;
  --border: #dde3e1;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f1;
  --warn: #9a3412;
  --warn-soft: #fff1e7;
  --ok: #166534;
  --focus: #2563eb;
  --c1: #0f766e; --c2: #f59e0b; --c3: #6366f1; --c4: #e11d48; --c5: #0ea5e9; --c6: #84cc16;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 4px 16px rgba(16, 24, 22, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1211;
    --surface: #151c1b;
    --text: #e7eeec;
    --muted: #9fb0ac;
    --border: #283432;
    --accent: #2dd4bf;
    --accent-ink: #062320;
    --accent-soft: #12302c;
    --warn: #fdba74;
    --warn-soft: #3a2314;
    --ok: #86efac;
    --focus: #93c5fd;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; }
code { font: .92em ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--accent-soft); padding: .1em .35em; border-radius: 6px; overflow-wrap: anywhere; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
main { outline: none; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand svg { color: var(--accent); }
.nav { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav a { display: block; padding: 8px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.hero { padding-top: 32px; padding-bottom: 8px; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; }
h2 { font-size: 1.45rem; line-height: 1.25; margin: 2rem 0 .75rem; }
.h3, h3 { font-size: 1.1rem; line-height: 1.3; margin: 0 0 .75rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 70ch; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.calc-layout { display: grid; gap: 20px; margin-top: 20px; align-items: start; }
@media (min-width: 900px) {
  .calc-layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .results { position: sticky; top: 16px; }
}
.calc { display: grid; gap: 16px; min-width: 0; }
fieldset.card { margin: 0; min-width: 0; }
legend.h3 { padding: 0 6px; margin-left: -6px; font-weight: 700; }
.grid { display: grid; gap: 14px; }
@media (min-width: 560px) {
  .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.grid + .grid { margin-top: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: .95rem; }
label small { font-weight: 400; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--warn); border-width: 2px; }
label .field-error { color: var(--warn); font-weight: 600; }
[hidden] { display: none !important; }
fieldset.card > p { margin: 0 0 14px; }

.dropzone { border-style: dashed; border-width: 2px; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone p { margin: 0 0 12px; }
.file-btn { display: inline-flex; flex-direction: row; position: relative; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.file-btn span, .btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.file-btn:focus-within span { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn:hover { filter: brightness(1.05); }
.file-status { margin: 12px 0 0 !important; font-weight: 500; }
.file-status.ok { color: var(--ok); }
.file-status.warn { color: var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.mobile-summary {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 5;
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px;
  background: var(--accent); color: var(--accent-ink); border-radius: 12px; text-decoration: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); font-size: .95rem; font-variant-numeric: tabular-nums;
}
.mobile-summary strong { font-size: 1.05rem; margin-left: 4px; }
@media (min-width: 900px) { .mobile-summary { display: none; } }
@media (max-width: 899px) { .site-footer { padding-bottom: 72px; } }
.results .label { display: block; color: var(--muted); font-size: .9rem; }
.big-number output { display: block; font-size: 2.4rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.breakdown { width: 100%; border-collapse: collapse; margin: 16px 0; font-variant-numeric: tabular-nums; }
.breakdown th { text-align: left; font-weight: 400; padding: 6px 0; }
.breakdown td { text-align: right; padding: 6px 0; white-space: nowrap; }
.breakdown tr + tr { border-top: 1px solid var(--border); }
.breakdown .total th, .breakdown .total td { font-weight: 700; padding-top: 10px; }
.breakdown .subtotal th, .breakdown .subtotal td { font-weight: 600; }
.big-number output.neg { color: var(--warn); }
.big-number p { margin: 4px 0 0; }
.results > p { margin: 12px 0 0; }
.price-box { background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; }
.price-box output { display: block; font-size: 1.9rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.price-box p { margin: 4px 0 0; }
.bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin-top: 16px; background: var(--border); }
.seg { flex-basis: 0; min-width: 0; }
.seg-material { background: var(--c1); } .seg-electricity { background: var(--c2); } .seg-machine { background: var(--c3); }
.seg-failure { background: var(--c4); } .seg-labor { background: var(--c5); } .seg-extras { background: var(--c6); }

.prose { max-width: 760px; margin-top: 24px; }
.prose li { margin: .35rem 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-variant-numeric: tabular-nums; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table-scroll { overflow-x: auto; }
.formula { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 8px 0; }
summary { cursor: pointer; font-weight: 600; }
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 10px 10px 0; }
.related { margin-top: 32px; }
.related h2 { margin-top: 0; }
.link-list { padding-left: 1.2rem; margin: 0; }
.link-list li { margin: .4rem 0; }
.cards { list-style: none; padding: 0; display: grid; gap: 14px; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cards a { display: block; text-decoration: none; color: var(--text); height: 100%; }
.cards a:hover { border-color: var(--accent); }
.cards strong { display: block; color: var(--accent); margin-bottom: 4px; }
.breadcrumbs { font-size: .9rem; margin: 24px 0 0; }

.site-footer { margin-top: 48px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .92rem; }
.footer-inner { padding-top: 20px; padding-bottom: 28px; }
.footer-links { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 12px 0; }
.consent-settings { font: inherit; color: var(--accent); background: transparent; border: 0; padding: 4px; min-height: 44px; text-decoration: underline; cursor: pointer; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .site-header, .site-footer, .dropzone, .actions, .related { display: none; }
  .card { box-shadow: none; }
}
