:root {
  --brand: #adbf59;
  --brand-strong: #6b8a1f;
  --brand-soft: #f3f7e4;
  --ink: #2b2d2f;
  --ink-2: #5d6166;
  --ink-3: #8b9096;
  --line: #e4e6e9;
  --bg: #f5f6f7;
  --card: #ffffff;
  --input: #fff8e1;
  --input-line: #f0d98c;
  --ok: #1e7b34;
  --ok-bg: #dcf3e0;
  --bad: #a4161a;
  --bad-bg: #fde2e2;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }

/* ---------- Kopfleiste ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar img { height: 40px; }
.topbar .title { border-left: 1px solid var(--line); padding-left: 18px; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; white-space: nowrap; }
.topbar .title { min-width: 0; }
.topbar .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; color: var(--ink-3); }
.topbar .proj { display: flex; gap: 10px; margin-left: auto; }
.topbar .proj label { display: flex; flex-direction: column; font-size: 11px; color: var(--ink-3); }
.topbar .proj input { width: 120px; }
.topbar .proj input#pos { width: 230px; }
.actions { display: flex; gap: 8px; }
.btn {
  white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }

/* ---------- Layout ---------- */
main { display: grid; grid-template-columns: 400px 1fr; gap: 20px; padding: 20px 22px 40px; max-width: 1500px; margin: 0 auto; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h2 { font-size: 13px; text-transform: none; letter-spacing: .02em; margin: 0 0 12px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ""; width: 4px; height: 14px; background: var(--brand); border-radius: 2px; }

/* ---------- Eingaben ---------- */
.field { display: grid; grid-template-columns: 1fr 130px; align-items: center; gap: 10px; padding: 4px 0; }
.field .lbl { color: var(--ink); }
.field .hint { grid-column: 1 / -1; font-size: 11.5px; color: var(--ink-3); margin-top: -3px; }
.inwrap { position: relative; }
.inwrap .unit { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 11.5px; color: var(--ink-3); pointer-events: none; }
input, select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--input); border: 1px solid var(--input-line); border-radius: 7px; padding: 6px 9px;
  text-align: right;
}
.inwrap input { padding-right: 46px; }
select { text-align: left; padding-right: 6px; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.field.disabled .lbl { color: var(--ink-3); }
input:disabled, select:disabled { background: #eef0f2; border-color: #e3e5e8; color: transparent; cursor: not-allowed; }
.topbar input { background: #fafafa; border-color: var(--line); text-align: left; }

/* ---------- Ergebnisse ---------- */
.status { display: flex; gap: 12px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.nok { background: var(--bad-bg); color: var(--bad); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .k { font-size: 11.5px; color: var(--ink-3); }
.kpi .v { font-size: 22px; font-weight: 600; margin-top: 2px; }
.kpi .v small { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 3px; }
.kpi .s { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sketch svg { width: 100%; height: auto; display: block; }
table.res { width: 100%; border-collapse: collapse; }
table.res td { padding: 5px 4px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
table.res td.v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; width: 1%; padding-left: 14px; }
table.res td.n { color: var(--ink-3); font-size: 11.5px; padding-left: 14px; }
table.res tr.sub td { font-weight: 600; font-style: italic; color: var(--ink-2); border-bottom: none; padding-top: 10px; }
table.res tr.strong td { font-weight: 600; }
.mark { display: inline-grid; place-items: center; width: 26px; height: 22px; border-radius: 6px; font-weight: 700; }
.mark.ok { background: var(--ok-bg); color: var(--ok); }
.mark.nok { background: var(--bad-bg); color: var(--bad); }
.mark.na { background: #eef0f2; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.greyed { opacity: .45; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { margin: 0; }
details.card[open] > summary h2 { margin-bottom: 12px; }
details.card > summary h2::after { content: "▾"; margin-left: auto; color: var(--ink-3); transition: transform .15s; }
details.card:not([open]) > summary h2::after { transform: rotate(-90deg); }
.selgrid { display: grid; grid-template-columns: 1.3fr repeat(3, 92px) 1.3fr 34px; gap: 8px 10px; align-items: center; }
.selgrid .hd { font-size: 11.5px; color: var(--ink-3); }
.selgrid .res { font-variant-numeric: tabular-nums; }
.selgrid .res .n { display: block; font-size: 11.5px; color: var(--ink-3); }
.selgrid select { text-align: right; }

#print { display: none; }

@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- Druck (Excel-Stil) ---------- */
@page { size: A4; margin: 12mm 14mm 16mm 16mm;
  @bottom-left { content: "Stahlbetonunterzug mit Durchbruch"; font: 8pt Calibri, Arial, sans-serif; color: #777; }
  @bottom-right { content: "Seite " counter(page) " von " counter(pages); font: 8pt Calibri, Arial, sans-serif; color: #777; } }
@media print {
  body { background: #fff; }
  .topbar, main { display: none !important; }
  #print { display: block; font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 10.5pt; color: #000; }
  #print table.page { width: 100%; border-collapse: collapse; }
  #print thead td { padding-bottom: 4mm; }
  #print .ph { display: flex; align-items: flex-end; justify-content: space-between; border-bottom: .4pt solid #999; padding-bottom: 2mm; }
  #print .ph img { height: 15mm; }
  #print .meta { display: grid; grid-template-columns: 26mm 1fr; gap: .5mm 3mm; margin: 3mm 0 2mm; }
  #print .meta div:nth-child(odd) { background: #fff2cc; padding: .4mm 1.5mm; }
  #print .meta div:nth-child(even) { background: #fff2cc; padding: .4mm 1.5mm; }
  #print h1 { font-size: 14pt; margin: 2mm 0 0; }
  #print .subt { font-style: italic; color: #595959; font-size: 9pt; }
  #print .status { margin: 1mm 0 3mm; font-weight: 700; }
  #print .status.ok { color: #2e7d32; } #print .status.nok { color: #c00000; }
  #print .sec { break-inside: avoid; margin-top: 2.6mm; }
  #print .sec.allow { break-inside: auto; }
  #print .sec h3 { font-size: 10.5pt; margin: 0; padding: .6mm 0; border-bottom: 1.2pt solid #000; width: 118mm; }
  #print table.t { border-collapse: collapse; }
  #print table.t td { padding: .2mm 1.5mm; font-size: 9.5pt; }
  #print table.t td.l { width: 70mm; }
  #print table.t td.v { width: 48mm; text-align: center; border-right: .6pt solid #000; }
  #print table.t td.n { font-size: 8.5pt; font-style: italic; color: #666; padding-left: 3mm; }
  #print table.t tr.inp td.v { background: #fff2cc; font-weight: 700; }
  #print table.t tr.b td { font-weight: 700; }
  #print table.t tr.sub td.l { font-weight: 700; font-style: italic; }
  #print table.t td.v.ok { background: #c6efce; color: #006100; font-weight: 700; }
  #print table.t td.v.nok { background: #ffc7ce; color: #9c0006; font-weight: 700; }
  #print table.t tr.grey td { color: #aaa; }
  #print .twocol { display: grid; grid-template-columns: 120mm 1fr; gap: 4mm; align-items: start; }
  #print .sk svg { width: 118mm; height: auto; display: block; margin-top: 1mm; }
  #print .pb { break-before: page; }
  #print .fazit { break-inside: avoid; margin-top: 4mm; padding: 2mm 3mm; font-weight: 700; border: 1pt solid; width: 118mm; }
  #print .fazit.ok { color: #006100; background: #c6efce; border-color: #2e7d32; }
  #print .fazit.nok { color: #9c0006; background: #ffc7ce; border-color: #c00000; }
  #print .note { font-size: 8.5pt; font-style: italic; color: #666; margin-top: 3mm; }
}
