:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --line: #dddddd;
  --soft: #f4f4f4;
  --red: #e10600;
  --red-soft: #fdecea;
  --ok: #0a7a33;
  --ok-soft: #e7f5ec;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: 16px; line-height: 1.5; }
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.2; margin: 1.4em 0 .5em; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .04em; }
h4 { font-size: 1rem; margin: 1em 0 .3em; }
p { margin: .4em 0; }
small, .muted { color: var(--muted); }
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }
.wide { max-width: 1400px; }

/* Formulare */
label { display: block; font-weight: 600; margin: 18px 0 6px; }
label .req { color: var(--red); }
.hint { font-weight: 400; color: var(--muted); font-size: .9rem; margin: -2px 0 6px; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #bbb; border-radius: var(--radius); background: #fff; color: var(--fg);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--fg); outline-offset: 1px; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); font-weight: 400; margin: 0; cursor: pointer; }
.choice:hover { border-color: #999; }
.choice input { margin-top: 4px; accent-color: var(--fg); }
.choice:has(input:checked) { border-color: var(--fg); background: var(--soft); }
.choice .price { margin-left: auto; font-weight: 700; white-space: nowrap; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 0 16px; }
.err-text { color: var(--red); font-size: .9rem; margin-top: 4px; }
.has-err input, .has-err select, .has-err textarea, .has-err .choice { border-color: var(--red); }
fieldset { border: 0; padding: 0; margin: 0; }
.box { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 18px 18px; margin: 24px 0; }
.box > h2:first-child { margin-top: 16px; }
.hidden { display: none !important; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn { display: inline-block; font: inherit; font-weight: 700; padding: 11px 20px; border-radius: var(--radius); border: 2px solid var(--fg); background: var(--fg); color: #fff; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: #333; }
.btn.red { background: var(--red); border-color: var(--red); }
.btn.ghost { background: transparent; color: var(--fg); }
.btn.ghost:hover { background: var(--soft); }
.btn.small { padding: 6px 12px; font-size: .9rem; border-width: 1px; }
.btn.big { width: 100%; padding: 16px; font-size: 1.1rem; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
button:disabled { opacity: .4; cursor: not-allowed; }

/* Öffentliche Seite */
.brand { font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .85rem; }
.brand span { color: var(--red); }
.info { background: var(--soft); border-radius: var(--radius); padding: 6px 20px 16px; margin: 20px 0; max-height: 420px; overflow: auto; }
.info .warn { color: var(--red); font-weight: 700; }
.summary { position: sticky; bottom: 0; background: #fff; border-top: 2px solid var(--fg); padding: 14px 0; margin-top: 24px; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.summary strong { font-size: 1.3rem; }
.agree { font-weight: 400; display: flex; gap: 10px; align-items: flex-start; }
.agree input { margin-top: 5px; width: 20px; height: 20px; accent-color: var(--fg); flex: none; }
footer.legal { margin-top: 40px; font-size: .85rem; color: var(--muted); display: flex; gap: 16px; }

/* Admin */
.topbar { background: var(--fg); color: #fff; }
.topbar .inner { max-width: 1400px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 6px 20px; align-items: center; flex-wrap: wrap; }
.topbar a { color: #fff; text-decoration: none; opacity: .8; font-weight: 600; }
.topbar a:hover, .topbar a.on { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.topbar .brand { opacity: 1; margin-right: 12px; }
.topbar form { margin-left: auto; }
.topbar button { background: none; border: 1px solid #fff6; color: #fff; border-radius: 6px; padding: 4px 10px; font: inherit; cursor: pointer; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin: 14px 0; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--red-soft); color: var(--red); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 10px 0 16px; }
.filters label { margin: 0; font-size: .8rem; font-weight: 600; color: var(--muted); }
.filters select, .filters input { width: auto; min-width: 150px; padding: 7px 10px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 160px; }
.stat b { display: block; font-size: 1.3rem; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.list { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.list th, table.list td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { background: var(--soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; position: sticky; top: 0; }
table.list tr:hover td { background: #fafafa; }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }
table.list a.rowlink { font-weight: 700; text-decoration: none; }
table.list a.rowlink:hover { text-decoration: underline; }
tr.canceled td { color: #999; text-decoration: line-through; }
tr.groupline td { background: #fff; font-weight: 800; border-bottom: 2px solid var(--fg); padding-top: 18px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--soft); white-space: nowrap; }
.pill.draft { background: #fff4d6; color: #7a5200; }
.pill.final, .pill.sent { background: #e6efff; color: #1d4ed8; }
.pill.paid, .pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.canceled { background: var(--red-soft); color: var(--red); }
.pill.new { background: var(--fg); color: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 16px; margin-bottom: 18px; }
.panel h2 { margin-top: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.actions form { margin: 0; }
.items td { padding: 4px; vertical-align: top; }
.items textarea { min-height: 52px; }
.items input { padding: 7px 8px; }
.items .qty { width: 70px; }
.items .price { width: 120px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0; font-size: .92rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; white-space: pre-line; }
.totals { margin-left: auto; width: 280px; font-size: .95rem; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .sum { border-top: 2px solid var(--fg); font-weight: 800; margin-top: 4px; padding-top: 6px; }
.login { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.logo-preview { max-width: 200px; max-height: 80px; display: block; margin: 8px 0; border: 1px solid var(--line); padding: 6px; }
.split-bar { display: flex; gap: 8px; align-items: center; }
.split-bar input { width: 90px; }

@media (max-width: 800px) {
  .row2, .row3, .grid2, .cols { grid-template-columns: 1fr; }
  .totals { width: 100%; }
  .topbar form { margin-left: 0; }
}
.items { width: 100%; border-collapse: collapse; }
.items th { text-align: left; font-size: .85rem; padding: 4px; }
.items td:first-child { width: 100%; }
.disc { white-space: nowrap; }
pre { white-space: pre-wrap; background: var(--soft); padding: 12px; border-radius: var(--radius); font-size: .9rem; }
details.panel > summary { cursor: pointer; padding: 12px 0; }
td.actions > * { display: inline-block; margin: 0 4px 4px 0; vertical-align: top; }
td .agree { margin: 2px 0; }
