:root {
  --bg: #f5f5f3; --card: #fff; --text: #1f2328; --muted: #6b7280; --line: #e3e3df;
  --accent: #f08a1c; --accent-dark: #c96d0c; --danger: #c0392b; --ok: #1e7f4f;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.top { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem; background: #24292f; color: #fff; flex-wrap: wrap; }
.top .brand { color: #fff; font-weight: 700; display: inline-flex; align-items: center; gap: .5rem; }
.top .brand img { height: 28px; background: #fff; border-radius: 5px; padding: 2px 4px; }
.top nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.top nav a { color: #d0d7de; padding: .35rem .7rem; border-radius: 6px; }
.top nav a.active, .top nav a:hover { background: #3a4048; color: #fff; text-decoration: none; }
.top .logout button { color: #d0d7de; }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
main.narrow { max-width: 420px; padding-top: 10vh; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head h1 { margin: 0; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.head .actions { margin-top: 0; }
.spacer { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.btn { display: inline-block; border: 1px solid #c9ccd1; background: #fff; color: var(--text); padding: .5rem .95rem; border-radius: 7px; font: inherit; cursor: pointer; }
.btn:hover { background: #f0f0ee; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-dark); cursor: pointer; }
.danger { color: var(--danger) !important; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
label.check, label.inline { display: inline-flex; gap: .4rem; align-items: center; color: var(--text); font-size: .95rem; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; font: inherit; color: var(--text); padding: .45rem .6rem; border: 1px solid #c9ccd1; border-radius: 6px; background: #fff; }
input[type=checkbox], input[type=radio] { width: auto; display: inline; margin: 0; }
input[type=color] { padding: 0; height: 2.3rem; }
label.inline input { display: inline-block; width: auto; margin: 0; }
textarea { resize: vertical; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1rem; }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #e7f6ee; color: var(--ok); border: 1px solid #b9e3cc; }
.flash.error { background: #fdecea; color: var(--danger); border-color: #f5c2bd; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.r { text-align: right; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list th, table.list td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { background: #fafaf8; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
table.list th.r, table.list td.r { text-align: right; }
table.list tr:last-child td { border-bottom: 0; }
table.list td input { margin: 0; }
tr.inactive td { color: var(--muted); }
.badge { display: inline-block; font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; background: #eee; color: #444; vertical-align: middle; font-weight: 600; }
.badge.draft { background: #eef2ff; color: #3949ab; }
.badge.final { background: #fff4e5; color: #b35c00; }
.badge.paid { background: #e7f6ee; color: var(--ok); }
.badge.done { background: #e8f0fe; color: #1a5fb4; }
.badge.cancelled { background: #f3f3f3; color: #777; text-decoration: line-through; }
.overdue { color: var(--danger); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; }
.stat span { display: block; color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.5rem; }
.big { font-size: 1.6rem; }
.search { display: flex; gap: .5rem; }
.search input, .search select { margin: 0; width: auto; }
.subnav { display: flex; gap: .25rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.subnav a { padding: .35rem .8rem; border-radius: 6px; color: var(--text); }
.subnav a.active { background: #fff; border: 1px solid var(--line); font-weight: 600; }
img.preview { max-width: 260px; border: 1px solid var(--line); display: block; margin-bottom: .5rem; }
img.preview.small { max-width: 160px; }
/* positions editor */
table.items { width: 100%; border-collapse: collapse; margin: .5rem 0; }
table.items th { font-size: .75rem; color: var(--muted); text-align: left; padding: .3rem; text-transform: uppercase; }
table.items td { padding: .25rem; vertical-align: top; }
table.items td input, table.items td select, table.items td textarea { margin: 0; padding: .35rem .45rem; }
table.items td:nth-child(1) { width: 2.5rem; color: var(--muted); padding-top: .6rem; }
table.items td:nth-child(2) { width: 6.5rem; }
table.items td:nth-child(4) { width: 6rem; }
table.items td:nth-child(5) { width: 5.5rem; }
table.items td:nth-child(6) { width: 7rem; }
table.items td.disc, table.items td.tax { width: 5rem; }
table.items td.total { width: 7rem; padding-top: .6rem; font-variant-numeric: tabular-nums; }
table.items tr.textrow td:nth-child(n+4):not(:last-child) input { visibility: hidden; }
body.ku table.items .tax { display: none; }
.row-actions { display: flex; gap: .5rem; align-items: center; }
.row-actions select { width: auto; margin: 0; }
table.sum { margin: 1rem 0 1.25rem auto; min-width: 280px; border-collapse: collapse; }
table.sum td { padding: .25rem .5rem; }
table.sum tr.gross td { border-top: 2px solid var(--text); font-weight: 700; }
form.inline, .inlineform { display: inline-flex; gap: .5rem; align-items: center; }
.inlineform label { margin: 0; }
.narrowform { max-width: 420px; }
@media (max-width: 760px) {
  table.items thead { display: none; }
  table.items tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .25rem; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.items td { width: auto !important; }
  table.items td:nth-child(3) { grid-column: 1 / -1; }
}
.filters { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; }
.filters label { min-width: 150px; flex: 1; }
.filters .filter-actions { display: flex; gap: .5rem; margin-bottom: .75rem; }
.filters .presets { width: 100%; color: var(--muted); }
.stats + .small { margin: .5rem 0 1rem; }
.nowrap { white-space: nowrap; }
.quickpay input[type=date] { width: auto; display: inline-block; margin: 0; padding: .2rem .35rem; font-size: .85rem; }
.small-btn { padding: .2rem .55rem; font-size: .85rem; }
/* Kassenbuch */
.yearpick select { display: inline-block; width: auto; margin: 0 0 0 .5rem; font-size: 1.1rem; font-weight: 700; padding: .2rem .4rem; }
h2.kb-in { color: #1f4fbf; }
h2.kb-out { color: #b02a1a; }
table.kb td:nth-child(1), table.kb td:nth-child(2) { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.list tr.sumrow td { font-weight: 700; background: #fafaf8; }
.kb-export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.kb-export-grid .actions { margin-top: .5rem; }
.flash.warn { background: #fff4e5; color: #8a4b00; border-color: #f3d19e; }
.inbox-item.has-error { border-color: var(--danger); }
.inbox-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.inbox-grid { display: grid; grid-template-columns: 11rem 9rem 1fr 1fr; gap: 0 1rem; }
@media (max-width: 860px) { .inbox-grid { grid-template-columns: 1fr 1fr; } .inbox-grid .wide { grid-column: 1 / -1; } }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; border-top: 1px solid var(--line); }
