:root {
  --red: #d7141a; --ink: #1d1d1f; --muted: #6b6b70; --line: #dcdce0; --bg: #f5f5f7; --card: #fff;
  --ok: #1d7a3a; --warn: #a15c00; --blue: #1f5fbf;
  font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.red { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

header.top { display: flex; align-items: center; gap: 18px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 20px; height: 52px; position: sticky; top: 0; z-index: 20; }
header.top .brand { font-weight: bold; color: var(--ink); white-space: nowrap; }
header.top .brand span { color: var(--red); letter-spacing: 1px; }
header.top nav { display: flex; gap: 4px; flex: 1; align-items: center; overflow-x: auto; }
header.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--ink); white-space: nowrap; }
header.top nav a.on { background: var(--bg); font-weight: bold; }
header.top nav .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
header.top .user { display: flex; gap: 10px; align-items: center; white-space: nowrap; }

main.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
main.full { padding: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card.narrow { max-width: 460px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: #e7f4ea; color: var(--ok); }
.flash.err { background: #fbebeb; color: var(--red); }
.login { max-width: 380px; margin: 12vh auto; }
.login h1 { text-align: center; }

label { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
label.chk { display: flex; gap: 6px; align-items: center; color: var(--ink); font-size: 13px; }
input, select, textarea { font: inherit; font-size: 13px; color: var(--ink); width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; margin-top: 3px; }
input[type=checkbox] { width: auto; margin: 0; }
textarea { resize: vertical; min-height: 34px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3f5; border-color: var(--blue); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: #b70f14; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.danger { color: var(--red); }
button.link { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
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: #fafafa; font-size: 12px; color: var(--muted); font-weight: normal; }
table.list tr:hover td { background: #fafbff; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; background: var(--bg); }
.pill.entwurf { background: #eef1f6; } .pill.versendet { background: #e7f1fb; color: var(--blue); }
.pill.angenommen { background: #e5f4e4; color: var(--ok); } .pill.abgelehnt { background: #fbebeb; color: var(--red); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }

/* Editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; max-width: 1600px; margin: 0 auto; padding: 16px 20px 80px; }
.editor .side { position: sticky; top: 68px; align-self: start; max-height: calc(100vh - 80px); overflow: auto; }
.ebar { position: sticky; top: 52px; z-index: 15; background: var(--bg); padding: 10px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.ebar .title { font-weight: bold; font-size: 16px; margin-right: auto; }
.dirty { color: var(--warn); font-size: 12px; }
.group { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.group.option { border-style: dashed; } .group.variante { border-color: #b7c9ea; }
.ghead { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafafa; border-radius: 10px 10px 0 0; flex-wrap: wrap; }
.ghead .gnum { font-weight: bold; width: 36px; }
.ghead input.gtitle { flex: 1; min-width: 220px; font-weight: bold; margin: 0; }
.ghead select { width: auto; margin: 0; }
table.items { width: 100%; border-collapse: collapse; }
table.items th { font-size: 11px; color: var(--muted); font-weight: normal; text-align: left; padding: 4px 4px; border-bottom: 1px solid var(--line); }
table.items td { padding: 3px 4px; border-bottom: 1px solid #f0f0f2; vertical-align: top; }
table.items input, table.items select, table.items textarea { margin: 0; padding: 4px 5px; font-size: 12.5px; }
table.items .pos { width: 40px; color: var(--muted); font-size: 12px; padding-top: 8px; }
table.items tr.textrow td { background: #fcfcfd; }
table.items .amt { width: 92px; text-align: right; padding-top: 8px; font-variant-numeric: tabular-nums; }
.gfoot { display: flex; gap: 6px; padding: 8px 12px; flex-wrap: wrap; align-items: center; }
.gfoot .sub { margin-left: auto; font-weight: bold; }
.ph { background: #fff4d6; }
.iconbtn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 3px 4px; font-size: 13px; }
.iconbtn:hover { color: var(--ink); }
.totals td { padding: 3px 0; } .totals td.num { padding-left: 10px; }
.totals tr.big td { font-weight: bold; border-top: 1px solid var(--line); padding-top: 6px; }
.warn { background: #fff4d6; color: var(--warn); padding: 8px 10px; border-radius: 6px; font-size: 12px; margin-bottom: 8px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; }
.modal { background: #fff; border-radius: 12px; width: min(820px, 94vw); max-height: 80vh; display: flex; flex-direction: column; }
.modal .mh { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.modal .mb { padding: 10px 16px; overflow: auto; }
.modal .mf { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.pick { padding: 8px 6px; border-bottom: 1px solid #f0f0f2; cursor: pointer; display: flex; gap: 10px; }
.pick:hover { background: #f5f8ff; }
.pick .cat { color: var(--muted); font-size: 11px; width: 110px; flex-shrink: 0; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .editor .side { position: static; max-height: none; } }
