/* Kalkulation Holzbau – Arbeitsoberfläche. Eine Schriftfamilie (IBM Plex Sans) mit Tabellenziffern; Grün für Aktionen, Holzton nur für die Angebotssumme. */
:root {
  --bg: #F1F2EE; --paper: #FFFFFF; --ink: #1D2320; --muted: #66706A; --line: #D4D8D0; --line-strong: #AEB5AC;
  --bar: #2B3D30; --bar-ink: #E6EDE7; --green: #3C6E47; --green-dark: #2F5738; --green-soft: #E4EEE6;
  --wood: #B8893A; --wood-soft: #F6EEDF; --err: #A33A2E; --err-soft: #F7E5E2; --ok: #2E6B3A; --info: #3A5A7A; --info-soft: #E6EDF4;
  --radius: 4px; --font: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); line-height: 1.45; color: var(--ink); background: var(--bg); font-variant-numeric: tabular-nums; }
a { color: var(--green); }
h1 { font-size: 21px; font-weight: 600; margin: 0 0 10px; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 22px 0 8px; }
h3 { font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.muted { color: var(--muted); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* Kopfleiste */
header.top { background: var(--bar); color: var(--bar-ink); padding: 0 22px; height: 46px; display: flex; align-items: center; gap: 22px; }
header.top .brand { font-weight: 600; letter-spacing: 0.01em; color: #fff; text-decoration: none; }
header.top nav a { color: var(--bar-ink); text-decoration: none; margin-right: 18px; padding: 13px 0; border-bottom: 2px solid transparent; }
header.top nav a.on, header.top nav a:hover { border-bottom-color: var(--wood); color: #fff; }
header.top .right { margin-left: auto; font-size: 13px; color: #B9C6BC; }
header.top .right a { color: #D9E2DB; }
main { max-width: 1240px; margin: 0 auto; padding: 18px 22px 60px; }
.flash { padding: 8px 12px; border-radius: var(--radius); margin: 0 0 8px; font-size: 14px; border-left: 3px solid; }
.flash.ok { background: var(--green-soft); color: var(--ok); border-color: var(--ok); }
.flash.err { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.flash.info { background: var(--info-soft); color: var(--info); border-color: var(--info); }

/* Bausteine */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.field label, .grid label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 18px; }
.grid .wide { grid-column: 1 / -1; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }
textarea { min-height: 72px; resize: vertical; }
textarea.mono { font: 12.5px/1.4 "IBM Plex Mono", Menlo, Consolas, monospace; min-height: 380px; }
button, .btn { display: inline-block; padding: 7px 14px; border: 1px solid var(--green); background: var(--green); color: #fff; border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.3; }
button:hover, .btn:hover { background: var(--green-dark); border-color: var(--green-dark); }
button.sec, .btn.sec { background: #fff; color: var(--green); } button.sec:hover, .btn.sec:hover { background: var(--green-soft); }
button.danger { background: #fff; color: var(--err); border-color: var(--err); } button.danger:hover { background: var(--err-soft); }
button.small, .btn.small { padding: 3px 9px; font-size: 13px; font-weight: 400; }
button.link { background: none; border: none; color: var(--muted); padding: 2px 6px; font-size: 16px; line-height: 1; } button.link:hover { color: var(--err); background: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #E3E8E2; color: #333; vertical-align: middle; }
.tag.NATURE { background: var(--green-soft); color: var(--green-dark); } .tag.THH { background: #F1E3CF; color: #6B4A12; }
details > summary { cursor: pointer; color: var(--green); }

/* Tabellen (Lesen) */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 500; white-space: nowrap; }
td.r, th.r { text-align: right; white-space: nowrap; }
tr.sum td { font-weight: 600; border-top: 2px solid var(--line-strong); }
tr.stufe td { background: #EEF2EC; font-weight: 600; }
td.nowrap { white-space: nowrap; }

/* Projekt-Arbeitsfläche: Summenleiste + Reiterleiste links */
.sumbar { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; margin-bottom: 14px; }
.sumbar .title { flex: 1 1 260px; }
.sumbar .title h1 { margin: 0; }
.sumbar .kpi { min-width: 120px; }
.sumbar .kpi span { display: block; font-size: 12px; color: var(--muted); }
.sumbar .kpi b { display: block; font-size: 18px; font-weight: 600; }
.sumbar .kpi.total b { font-size: 26px; color: var(--wood); letter-spacing: -0.01em; }
.sumbar .tools { flex-basis: 100%; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.work { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; align-items: start; }
.work > section { min-width: 0; }
.rail { position: sticky; top: 14px; display: flex; flex-direction: column; gap: 2px; }
.rail a { display: block; padding: 7px 12px; color: var(--ink); text-decoration: none; border-radius: var(--radius); border-left: 3px solid transparent; }
.rail a:hover { background: #E8ECE6; }
.rail a.on { background: var(--paper); border-left-color: var(--green); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.rail a small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.tabhead { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.tabhead h2 { margin: 0; font-size: 18px; }
.tabhead .muted { flex: 1 1 300px; min-width: 0; }
.tabhead { flex-wrap: wrap; }

/* Eingabe-Tabellen (Grid) */
table.edit { border: 1px solid var(--line); background: var(--paper); table-layout: fixed; }
.scroll { overflow-x: auto; padding-bottom: 4px; }
table.edit th { background: #F5F6F3; border-bottom: 1px solid var(--line-strong); padding: 6px 6px; white-space: normal; line-height: 1.25; vertical-align: bottom; }
table.edit td { padding: 2px 3px; border-bottom: 1px solid var(--line); }
table.edit td input, table.edit td select { border: 1px solid transparent; background: transparent; padding: 5px 6px; border-radius: 3px; }
table.edit td input:hover, table.edit td select:hover { border-color: var(--line); }
table.edit td input:focus, table.edit td select:focus { background: #fff; }
table.edit td input.num { text-align: right; }
table.edit tr:hover td { background: #FAFBF8; }
table.edit td.del { width: 30px; text-align: center; }
table.edit tr.deleted { display: none; }
table.edit td.hint { color: var(--muted); font-size: 12.5px; padding: 4px 8px; }
.gridfoot { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.sug { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line-strong); box-shadow: 0 6px 18px rgba(30, 40, 33, 0.14); border-radius: var(--radius); max-height: 320px; overflow: auto; width: 620px; max-width: 90vw; }
.sug div { padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 13px; }
.sug div:hover, .sug div.on { background: var(--green-soft); }
.sug div small { color: var(--muted); display: block; }
.paket { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); margin-bottom: 10px; }
.paket > .head { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: #F5F6F3; border-bottom: 1px solid var(--line); }
.paket > .head label { font-weight: 600; display: flex; align-items: center; gap: 8px; margin: 0; }
.paket table.edit { border: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.login { max-width: 380px; margin: 60px auto; }
.search { display: flex; gap: 8px; align-items: center; }
.search input { max-width: 320px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--green); }
kbd { font: 12px "IBM Plex Mono", monospace; background: #EEF0EB; padding: 1px 5px; border-radius: 3px; }
@media (max-width: 900px) {
  .work { grid-template-columns: 1fr; }
  .rail { position: static; flex-direction: row; flex-wrap: wrap; }
  .rail a small { display: none; }
  .two { grid-template-columns: 1fr; }
  main { padding: 12px 12px 40px; }
}
@media (prefers-reduced-motion: no-preference) { .rail a, button, .btn { transition: background-color 120ms ease; } }

/* Kalkulation (Positionsliste wie Grundkalkulation) */
.stufen { display: flex; gap: 6px; flex-wrap: wrap; }
.stufen a { flex: 1 1 150px; display: block; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); text-decoration: none; font-size: 13px; line-height: 1.3; }
.stufen a span { display: block; color: var(--muted); font-variant-numeric: tabular-nums; }
.stufen a.on { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); font-weight: 500; }
.stufen a:hover { background: #F5F6F3; }
.kalk { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.kapnav { position: sticky; top: 10px; max-height: calc(100vh - 40px); overflow: auto; font-size: 12.5px; border-right: 1px solid var(--line); padding-right: 8px; }
.kapnav a { display: flex; justify-content: space-between; gap: 6px; padding: 4px 6px; color: var(--muted); text-decoration: none; border-radius: 3px; }
.kapnav a.aktiv { color: var(--ink); font-weight: 500; }
.kapnav a:hover { background: #E8ECE6; }
.kapnav a .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kapnav a .s { font-variant-numeric: tabular-nums; }
.kap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; scroll-margin-top: 12px; }
.kaphead { display: flex; align-items: baseline; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line-strong); background: #F5F6F3; }
.kaphead h3 { margin: 0; flex: 1; font-size: 14px; }
.kaphead b { font-variant-numeric: tabular-nums; }
table.pos td { padding: 3px 8px; font-size: 13.5px; }
table.pos tr.gruppe td { background: #FAFBF8; color: var(--muted); font-weight: 500; font-size: 12.5px; padding-top: 7px; }
table.pos tr.zw td, table.pos tr.ksum td { font-weight: 600; background: #F5F6F3; }
table.pos tr.hat td:nth-child(2) { font-weight: 500; }
table.pos td:nth-child(1) { width: 62px; color: var(--muted); font-size: 12px; }
table.pos td:nth-child(3) { width: 48px; }
table.pos td:nth-child(4) { width: 90px; font-variant-numeric: tabular-nums; }
table.pos td.mengecell { width: 150px; white-space: nowrap; }
table.pos td:nth-child(6) { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
table.pos .dim { color: var(--muted); }
table.pos .hint { display: block; font-size: 11.5px; color: var(--muted); }
table.pos td.mengecell input.num { padding: 4px 6px; border-color: var(--line); text-align: right; width: 84px; display: inline-block; }
table.pos td.mengecell input.vor { background: #F1F3EE; }
table.pos td.mengecell input.fix { border-color: var(--green); background: #fff; }
table.pos td.mengecell input.edit { background: var(--wood-soft); }
table.pos td.mengecell input.small { width: 64px; display: inline-block; margin-left: 6px; }
table.pos .chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
table.pos .auto { color: var(--muted); font-variant-numeric: tabular-nums; display: block; text-align: right; padding-right: 6px; }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); }
@media (max-width: 900px) { .kalk { grid-template-columns: 1fr; } .kapnav { position: static; max-height: none; border: none; } }

.warn { background: #FBEFE3; border-left: 3px solid #C2701E; color: #7A4510; padding: 8px 12px; border-radius: var(--radius); font-size: 13.5px; }
.warn a { color: #7A4510; font-weight: 600; }
.kap.warnkap { border-color: #C2701E; }
.kapnav a.warnlink { color: #A85A10; font-weight: 600; }

/* Standard-Markierung nach Rezept */
.stdbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 12px; border-bottom: 1px solid var(--line); background: #FAFBF8; font-size: 13px; }
.stdbar select { width: auto; padding: 3px 6px; } .stdbar input.stdmenge { width: 80px; padding: 3px 6px; text-align: right; }
.stdtag { display: none; margin-left: 6px; font-size: 11px; padding: 0 6px; border-radius: 9px; background: #E9EDE7; color: var(--muted); vertical-align: middle; white-space: nowrap; }
.stdtag.def { background: var(--green-soft); color: var(--green-dark); }
section.kap.editing tr.std-def td:nth-child(2) { box-shadow: inset 3px 0 0 var(--green); }
section.kap.editing tr.std-def td { background: #F3F8F3; }
section.kap.editing tr.std-var td { background: #FAFBF8; }
section.kap.editing .stdtag { display: inline-block; }

/* Positionsliste: Listenpreise (Administrator) */
table.pos td.epcell { width: 168px; white-space: nowrap; padding-left: 2px; padding-right: 4px; }
table.pos td.epcell input.ep { width: 54px; padding: 3px 4px; border-color: var(--line); text-align: right; font-size: 12px; margin-left: 2px; }
table.pos td.epcell input.ep.fix { border-color: var(--wood); background: var(--wood-soft); }
table.pos td.epcell .epsum { display: inline-block; min-width: 50px; margin-left: 4px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
body.admin table.pos td.mengecell { width: 120px; }
table.pos td.ov { color: var(--wood); font-weight: 500; }

/* Alternativpositionen */
table.pos tr.alt td { color: var(--muted); font-style: italic; }
table.pos tr.alt td.mengecell input.num { border-style: dashed; }
table.pos .alttag { display: inline-block; font-size: 11px; font-style: normal; color: var(--info); background: var(--info-soft); border-radius: 3px; padding: 1px 6px; margin-left: 6px; }
table.pos td.mengecell label.altchk { font-size: 11px; color: var(--muted); margin-left: 6px; white-space: nowrap; }
table.pos td.mengecell label.altchk input { vertical-align: middle; margin: 0 2px 0 0; }
table.pos td.altsum { color: var(--info); }

/* freie Textzeilen je Position */
table.pos .zt { display: block; }
table.pos .zt input.ztline { display: block; width: 100%; max-width: 520px; margin: 3px 0; padding: 3px 6px; font-size: 12.5px; font-style: italic; border-color: var(--line); }
table.pos .zt a.ztadd { font-size: 11.5px; color: var(--muted); text-decoration: none; }
table.pos .zt a.ztadd:hover { color: var(--green); }
table.pos tr:not(:hover):not(.hat) .zt a.ztadd { visibility: hidden; }

/* freie Preispositionen am Kapitelende */
table.pos tr.freipos td, table.pos tr.freisub td { background: #FBFAF6; }
table.pos tr.freipos td { border-bottom: none; padding-bottom: 0; }
table.pos tr.freisub td { padding-top: 2px; }
table.pos tr.freipos input.fptext { width: 100%; max-width: 560px; }
table.pos tr.freipos input.fpunit { width: 56px; }
table.pos .fpsub { display: flex !important; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; }
table.pos .fpsub > * { flex: 0 0 auto; display: inline-block; margin: 0; }
table.pos .fpsub input.fp { width: 72px !important; padding: 3px 5px; font-size: 12.5px; }
table.pos .fpsub select { width: auto !important; padding: 2px 4px; font-size: 12px; }
table.pos .fpsub label.chk { display: inline-flex; }
table.pos .fpsub a.fpdel { font-size: 11.5px; color: var(--muted); text-decoration: none; margin-left: 4px; }
table.pos .fpsub a.fpdel:hover { color: var(--err); }
table.pos tr.freiadd td { padding: 4px 8px 8px; }
table.pos tr.freiadd a.fpadd { font-size: 12.5px; color: var(--green); text-decoration: none; }

/* Eigene Katalogpositionen */
.eigentag { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--green); color: var(--green); border-radius: 9px; font-size: 11px; line-height: 16px; white-space: nowrap; }
.eigform .grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.eigform .wide { grid-column: span 2; }
table.eigliste td { vertical-align: top; }
table.eigliste details summary { cursor: pointer; color: var(--green); }
table.eigliste tr.aus td { color: var(--muted, #888); }
@media (max-width: 640px) { .eigform .wide { grid-column: auto; } }

/* Richtmeistermontage */
button.rmbtn.an { background: #b7791f; border-color: #b7791f; color: #fff; }
.rminfo { background: #fdf3df; border-left: 3px solid #b7791f; padding: 6px 10px; border-radius: 4px; font-size: 13px; }
td.epcell input.ep.ohnem, td.epcell input.ep.ohnem::placeholder { text-decoration: line-through; color: #b9b9b9; }
