/* Schaumbeton Engineering System – "Plan & Beton".
   Concrete greys, plan-blue ink, signal yellow only for "outdated".
   Signature: the project title block (Plankopf) of technical drawings. */

@font-face {
  font-family: "Barlow Semi Condensed";
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/barlow-semi-condensed-500.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Semi Condensed";
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/barlow-semi-condensed-600.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-weight: 200 900;
  font-display: swap;
  src: url("/static/fonts/source-sans-3-wght.woff2") format("woff2");
}

:root {
  --concrete: #edefeb;
  --sheet: #fafbf9;
  --ink: #1e2328;
  --graphite: #5b636b;
  --rule: #cdd2cb;
  --plan: #24508a;
  --plan-strong: #1b3d6a;
  --on-plan: #ffffff;
  --signal: #f2b705;
  --signal-soft: #fff4cc;
  --on-signal: #1e2328;
  --good: #2f6b4a;
  --good-soft: #e3f0e8;
  --bad: #a23b2a;
  --bad-soft: #f7e4e0;
  --pending: #7a5300;
  --pending-soft: #fdf1d6;

  --font-display: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 4px;
  --line: 1px solid var(--rule);
  --frame: 2px solid var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root {
    --concrete: #15181b;
    --sheet: #1d2125;
    --ink: #e7e9e6;
    --graphite: #9ba3ab;
    --rule: #353b41;
    --plan: #86abdf;
    --plan-strong: #a9c3e8;
    --on-plan: #0f1a29;
    --signal-soft: #3a3214;
    --good: #9fd3b2;
    --good-soft: #1d3326;
    --bad: #f0a598;
    --bad-soft: #3d2420;
    --pending: #f0d08a;
    --pending-soft: #3a3018;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--concrete);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
}

a { color: var(--plan); text-underline-offset: 2px; }
a:hover { color: var(--plan-strong); }

h1, h2, h3, legend {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .01em;
}
h1 { font-size: 1.9rem; line-height: 1.15; margin: 1.5rem 0 1rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
h2 { font-size: 1.25rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .4rem; text-transform: uppercase; letter-spacing: .08em; color: var(--graphite); }
small, .muted { color: var(--graphite); }

:focus-visible { outline: 2px solid var(--plan); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* ---------------------------------------------------------------- header */

.topbar { background: var(--sheet); border-bottom: var(--frame); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1.5rem; min-height: 56px; flex-wrap: wrap; padding-block: .4rem; }
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--graphite); font-weight: 500; }
.mainnav { display: flex; align-items: center; gap: .4rem 1.25rem; flex-wrap: wrap; }
.mainnav a { text-decoration: none; font-weight: 600; }
.mainnav form { margin: 0; }
.who { color: var(--graphite); font-size: .9rem; }

/* ---------------------------------------------------------------- basics */

.card { background: var(--sheet); border: var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 440px; margin: 3rem auto; border-top: var(--frame); }

.stack { display: grid; gap: .9rem; }
.row { display: flex; gap: .9rem; align-items: flex-end; flex-wrap: wrap; }
.row label { flex: 1 1 200px; align-self: stretch; align-content: space-between; }
.button-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

label { display: grid; gap: .25rem; font-weight: 600; font-size: .92rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: 1rem; margin: .25rem 0 .75rem; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--plan); margin: 0; }

input[type=email], input[type=password], input[type=text], input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%;
  min-width: 0;
  padding: .5rem .6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; }
input::placeholder { color: var(--graphite); opacity: .8; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--concrete); color: var(--ink); }
.button.primary { background: var(--plan); border-color: var(--plan); color: var(--on-plan); }
.button.primary:hover { background: var(--plan-strong); border-color: var(--plan-strong); color: var(--on-plan); }
.button.ghost { border-color: transparent; background: transparent; color: var(--plan); }
.button.ghost:hover { background: var(--concrete); }
.button.danger { background: var(--bad); border-color: var(--bad); color: var(--sheet); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.linkbutton { background: none; border: 0; padding: 0; color: var(--plan); font: inherit; font-weight: 600; cursor: pointer; }
.linkbutton:hover { text-decoration: underline; }

.alert { padding: .7rem .9rem; border-radius: var(--radius); border-left: 4px solid currentColor; overflow-wrap: anywhere; margin: 0 0 1rem; }
.alert.good { background: var(--good-soft); color: var(--good); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.attention { background: var(--signal-soft); color: var(--ink); border-left-color: var(--signal); }

.pill, .state {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.pill.good, .state-current { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.pending { background: var(--pending-soft); color: var(--pending); }
.state-stale { background: var(--signal); color: var(--on-signal); }
.state-none { background: transparent; color: var(--graphite); border: var(--line); }
.tag { font-size: .75rem; color: var(--graphite); border: var(--line); border-radius: 3px; padding: 0 .35rem; }

.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--sheet); }
table.data th, table.data td { padding: .5rem .6rem; border-bottom: var(--line); text-align: left; white-space: nowrap; }
table.data th { font-family: var(--font-display); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--graphite); font-weight: 600; }
.num { text-align: right; }

.field-hint { font-size: .85rem; color: var(--graphite); margin: .3rem 0 0; }
.field-error { font-size: .88rem; color: var(--bad); margin: .3rem 0 0; font-weight: 600; }
.warn { color: var(--bad); font-weight: 600; }

/* ---------------------------------------------------------------- project list */

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }

.new-project { background: var(--sheet); border: var(--line); border-top: var(--frame); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.new-project > label { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em; color: var(--graphite); font-size: .8rem; }
.new-project-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .35rem; }
.new-project-row input { flex: 1 1 280px; }

.project-list { list-style: none; margin: 0; padding: 0; border-top: var(--frame); }
.project-list li { border-bottom: var(--line); }
.project-list a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .1rem 1rem;
  padding: .85rem .25rem;
  color: var(--ink);
  text-decoration: none;
}
.project-list a:hover { background: var(--sheet); }
.pl-title { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.pl-meta { grid-column: 1; color: var(--graphite); font-size: .92rem; }
.project-list .state { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

.empty { border: 1px dashed var(--rule); border-radius: var(--radius); padding: 1.5rem; color: var(--graphite); max-width: 60ch; }

/* ---------------------------------------------------------------- Plankopf */

.crumbs { margin: 1.25rem 0 .75rem; font-size: .92rem; }

.plankopf {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) repeat(4, minmax(0, 1fr));
  background: var(--sheet);
  border: var(--frame);
  margin-bottom: 1.25rem;
}
.pk-cell {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .55rem .75rem .6rem;
  border-left: 1px solid var(--ink);
  border-top: 1px solid var(--ink);
  min-width: 0;
}
.pk-label {
  font-family: var(--font-display);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--graphite);
}
.pk-value { font-weight: 600; overflow-wrap: anywhere; }
.pk-detail { font-size: .85rem; }

/* Title spans both rows on the left; the first row has no top line. */
.pk-title { grid-row: span 2; border-left: 0; border-top: 0; justify-content: flex-end; padding: .75rem 1rem; }
.pk-title h1 { margin: 0; font-size: clamp(1.5rem, 2.4vw, 2.2rem); }
.plankopf > .pk-cell:nth-child(2),
.plankopf > .pk-cell:nth-child(3),
.plankopf > .pk-cell:nth-child(4),
.plankopf > .pk-cell:nth-child(5) { border-top: 0; }
.pk-index .pk-value { font-family: var(--font-display); font-size: 1.6rem; line-height: 1; }
.pk-status { grid-column: span 2; }
.pk-status .pk-value { font-family: var(--font-display); font-size: 1.25rem; text-transform: uppercase; letter-spacing: .06em; }
.status-current .pk-value { color: var(--good); }
.status-none .pk-value { color: var(--graphite); }
.status-stale { background: var(--signal); color: var(--on-signal); }
.status-stale .pk-label { color: var(--on-signal); }

.master-alert { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; flex-wrap: wrap; }
.master-alert p { margin: 0; }

/* ---------------------------------------------------------------- steps */

.steps {
  display: flex;
  overflow-x: auto;
  border-bottom: var(--frame);
  margin-bottom: 1.25rem;
  scrollbar-width: thin;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1rem .55rem;
  border: 0;
  border-bottom: 4px solid transparent;
  background: none;
  color: var(--graphite);
  font: inherit;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  white-space: nowrap;
  cursor: pointer;
}
.step:hover { color: var(--ink); }
.step.active { color: var(--ink); border-bottom-color: var(--plan); }
.step-no {
  display: inline-grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border: 1.5px solid currentColor;
  font-size: .82rem;
}
.step.active .step-no { background: var(--ink); border-color: var(--ink); color: var(--sheet); }

/* ---------------------------------------------------------------- sheet */

.sheet {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

fieldset {
  margin: 0 0 1.5rem;
  padding: 0;
  border: 0;
  min-width: 0;
}
legend {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: 0;
  margin-bottom: .75rem;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--graphite);
}
legend::after { content: ""; flex: 1; border-top: var(--line); }

.grid { display: grid; gap: .9rem 1rem; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.grid + .field, .field + .grid, .grid + .check,
fieldset > .field + .field, fieldset > .field-hint + .field, fieldset > .field-hint + .grid { margin-top: .9rem; }

.field { display: grid; gap: .25rem; align-content: start; }
.field > label { font-size: .9rem; }
.has-error input, .has-error select { border-color: var(--bad); }

.unit-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
}
.unit-input:focus-within { outline: 2px solid var(--plan); outline-offset: 1px; }
.unit-input input { border: 0; text-align: right; outline: none; }
.unit {
  display: flex;
  align-items: center;
  padding: 0 .6rem 0 .1rem;
  color: var(--graphite);
  font-size: .88rem;
  white-space: nowrap;
}
.has-error .unit-input { border-color: var(--bad); }

table.entry { width: 100%; border-collapse: collapse; }
table.entry th {
  font-family: var(--font-display);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--graphite);
  text-align: left;
  padding: 0 .35rem .35rem;
}
table.entry td { padding: .2rem .35rem; vertical-align: middle; }
table.entry input, table.entry select { padding: .4rem .5rem; }
table.dims td:not(.out) { min-width: 7rem; }
table.costs td:first-child { min-width: 19rem; }
table.costs td:nth-child(2) { width: 6.5rem; }
table.costs td.narrow { width: 4.5rem; }
td.out, th.out { text-align: right; white-space: nowrap; color: var(--graphite); }
td.field-error { padding-top: 0; }
.auto-qty { color: var(--graphite); font-style: italic; font-size: .92rem; }

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- results */

.results {
  position: sticky;
  top: 1rem;
  background: var(--sheet);
  border: var(--line);
  border-top: 3px solid var(--plan);
  border-radius: var(--radius);
  padding: 1rem 1.15rem 1.15rem;
}
.result-state { font-size: .92rem; color: var(--graphite); margin: 0 0 .75rem; }
.result-state.stale { background: var(--signal-soft); color: var(--ink); border-left: 4px solid var(--signal); padding: .5rem .7rem; }
.result-note { font-size: .88rem; color: var(--graphite); margin: .6rem 0 0; }

/* Outdated results are hatched like a superseded area on a drawing. */
.results.is-stale,
.results:has(> .result-state.stale:not([hidden])) {
  border-top-color: var(--signal);
  background-image: repeating-linear-gradient(-45deg, transparent 0 9px, color-mix(in srgb, var(--signal) 14%, transparent) 9px 10px);
}
.results.is-stale :is(dl, table, .verdict),
.results:has(> .result-state.stale:not([hidden])) :is(dl, table, .verdict) { opacity: .55; }

.figures { margin: 0; }
.figures > div { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: var(--line); }
.figures dt { color: var(--graphite); }
.figures dd { margin: 0; font-weight: 600; text-align: right; }
.figures .total { border-bottom: 0; border-top: var(--frame); margin-top: .35rem; padding-top: .5rem; }
.figures .total + .total { border-top: 0; margin-top: 0; }
.figures .total dt { color: var(--ink); font-weight: 600; }
.figures .total dd { font-family: var(--font-display); font-size: 1.3rem; }

table.lines, table.compare { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.lines th, table.lines td, table.compare th, table.compare td { padding: .32rem 0; border-bottom: var(--line); text-align: right; }
table.lines th, table.compare tbody th { text-align: left; font-weight: 500; color: var(--graphite); }
table.lines td + td, table.compare td + td { padding-left: .75rem; }
table.compare thead th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink);
  border-bottom: var(--frame);
  padding-left: .75rem;
}
table.compare thead th:first-child { padding-left: 0; text-align: left; color: var(--graphite); }
table.compare tr.sum th, table.compare tr.sum td { font-weight: 700; color: var(--ink); border-top: 1.5px solid var(--ink); }
.verdict { margin: 1rem 0 0; font-weight: 600; }

/* ---------------------------------------------------------------- action bar */

.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem 1.25rem;
  flex-wrap: wrap;
  margin-top: .5rem;
  padding: .75rem 0;
  background: var(--concrete);
  border-top: var(--frame);
}
.actionbar-left, .actionbar-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.action-note { color: var(--graphite); font-size: .9rem; }
.button.calc { padding: .65rem 1.6rem; font-family: var(--font-display); font-size: 1.1rem; text-transform: uppercase; letter-spacing: .08em; }

.danger-link { margin: 1.5rem 0 3rem; font-size: .9rem; }
.danger-link a { color: var(--bad); }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 960px) {
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .results { position: static; }
}

@media (max-width: 720px) {
  h1 { font-size: 1.6rem; }
  .plankopf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pk-title { grid-row: auto; grid-column: 1 / -1; }
  .plankopf > .pk-cell:nth-child(2n) { border-left: 0; }
  .plankopf > .pk-cell:nth-child(2n+1):not(.pk-title) { border-left: 1px solid var(--ink); }
  .pk-status { grid-column: 1 / -1; border-left: 0 !important; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2, .span-3 { grid-column: auto; }
  /* One compact row: the bar must not cover the form. */
  .actionbar { gap: .35rem .5rem; padding: .45rem 0 .55rem; }
  .actionbar-left { flex-wrap: nowrap; gap: .5rem; }
  .actionbar-right { display: contents; }
  .actionbar .button { padding: .5rem .7rem; }
  .button.calc { padding: .5rem 1rem; font-size: 1rem; margin-left: auto; }
  /* The cost of the next run stays visible, as a small line above the buttons. */
  .action-note { order: -1; width: 100%; font-size: .8rem; }
  .hide-narrow { display: none; }
  .plankopf > .pk-cell:nth-child(n) { border-top: 1px solid var(--ink); }
  .plankopf > .pk-title:nth-child(n) { border-top: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .step, .project-list a { transition: background-color .12s, color .12s, border-color .12s; }
}

/* ---------------------------------------------------------------- admin: master data */

.lead { color: var(--graphite); max-width: 70ch; margin: -.25rem 0 1.5rem; }
table.entry th small { display: block; font-family: var(--font-body); text-transform: none; letter-spacing: 0; font-weight: 400; }
table.master td { min-width: 6.5rem; }
table.master input, .price-table td:last-child input, .narrow-table td:last-child input { text-align: right; }
td.has-error input { border-color: var(--bad); }
.cell-error { display: block; font-size: .8rem; color: var(--bad); font-weight: 600; margin-top: .15rem; white-space: normal; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem 1.5rem; }
.price-table h3 { margin-top: 0; }
.narrow-table { max-width: 560px; }
.publish { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; border-top: var(--frame); padding-top: 1rem; margin-bottom: 2.5rem; }
.publish .field { flex: 1 1 320px; }
.versions { margin-bottom: 3rem; }
.wrap-cell { white-space: normal !important; min-width: 16rem; }
.card.settings { max-width: 760px; }
.card.company { max-width: 760px; }
.logo-row { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.logo-preview {
  display: grid;
  place-items: center;
  width: 220px;
  height: 110px;
  padding: .5rem;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  background: #ffffff;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-row .field { flex: 1 1 260px; }
input[type=file] { font: inherit; max-width: 100%; }
.crumbs-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; margin: 1.25rem 0 .75rem; }
.crumbs-row .crumbs { margin: 0; }
.report-hint { font-size: .9rem; }
.danger-zone { border-color: var(--bad); }

/* ---------------------------------------------------------------- legal */

.site-footer { border-top: var(--line); margin-top: 3rem; padding: 1rem 0 1.5rem; font-size: .88rem; color: var(--graphite); }
.site-footer a { color: var(--graphite); }
.legal { max-width: 72ch; margin-bottom: 2rem; }
.legal h2 { margin-top: 1.75rem; }
.legal ul { padding-left: 1.25rem; }
.legal li + li { margin-top: .3rem; }
.legal-editor textarea { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9rem; line-height: 1.45; }
label.check.terms { align-items: flex-start; font-size: .95rem; }
label.check.terms input { margin-top: .2rem; flex: none; }
