:root {
  --ink: #1b1b1b; --ink2: #55524d; --mute: #8a867f; --line: #e4e0d8; --bg: #f5f3ee; --card: #fff;
  --acc: #a8321e; --acc-soft: #f6e4df; --ok: #2f7d4f; --ok-soft: #e1f1e7; --warn: #a86a00; --warn-soft: #fbefd6;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --s-spende: #8a867f; --s-bronze: #a5662f; --s-silver: #7f8a96; --s-gold: #b88a00; --s-platinum: #4f7491; --s-goenner: #6b4c9a; --s-diamant: #1f8a7a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
.sub { color: var(--ink2); margin: 0 0 1.25rem; }
.mute { color: var(--mute); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }

/* Kopf */
header.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1280px; margin: 0 auto; padding: .5rem 1.25rem; display: flex; align-items: center; gap: 1.25rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { height: 38px; display: block; }
.brand span { font-size: .78rem; color: var(--ink2); line-height: 1.2; border-left: 1px solid var(--line); padding-left: .75rem; }
nav.main { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
nav.main a { color: var(--ink2); padding: .4rem .55rem; border-radius: 7px; font-size: .9rem; white-space: nowrap; }
nav.main a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
nav.main a.on { background: var(--ink); color: #fff; }
.top-right { display: flex; align-items: center; gap: .6rem; }
.top-right select { width: auto; padding: .3rem .5rem; font-weight: 600; }
.userbtn { white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; background: none; border: 1px solid var(--line); border-radius: 999px; padding: .3rem .75rem; cursor: pointer; font: inherit; font-size: .88rem; color: var(--ink2); }
.menu { position: absolute; right: 1.25rem; top: 56px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 200px; padding: .35rem; z-index: 30; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: .45rem .7rem; border-radius: 6px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--bg); text-decoration: none; }
.menu .who { padding: .45rem .7rem; font-size: .85rem; color: var(--mute); border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.burger { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }

main { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.head .sub { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Karten & Raster */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
.kgrid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1rem; align-items: start; }
.kpi .label { font-size: .82rem; color: var(--ink2); }
.kpi .value { font-size: 1.7rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: .82rem; }
.up { color: var(--ok); } .down { color: var(--acc); }

/* Formulare */
label { display: block; font-size: .82rem; color: var(--ink2); margin: 0 0 .2rem; font-weight: 500; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #d6d1c7; border-radius: 7px; padding: .45rem .6rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(168,50,30,.25); border-color: var(--acc); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--acc); }
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:disabled, select:disabled, textarea:disabled { background: #faf9f6; color: var(--ink2); }
.f { margin-bottom: .75rem; }
.frow { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.check { display: flex; align-items: center; gap: .45rem; font-size: .92rem; color: var(--ink); margin: .3rem 0; font-weight: 400; cursor: pointer; }
.hint { font-size: .8rem; color: var(--mute); margin-top: .2rem; }

.btn { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-size: .92rem; font-weight: 550; border-radius: 7px; padding: .45rem .9rem; cursor: pointer; border: 1px solid #d6d1c7; background: #fff; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.pri { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.pri:hover { background: #000; }
.btn.acc { background: var(--acc); color: #fff; border-color: var(--acc); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--acc); border-color: #e6c3bb; }
.btn.sm { padding: .25rem .6rem; font-size: .84rem; }
.btn.link { border: 0; background: none; color: var(--acc); padding: .2rem .3rem; }
.btn:disabled { opacity: .45; cursor: default; }

/* Tabellen */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink2); font-weight: 600; background: #faf9f6; position: sticky; top: 0; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--ink); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fbfaf7; }
td.c, th.c { text-align: center; }
.count { color: var(--mute); font-size: .85rem; margin: .5rem 0; }

/* Badges */
.badge { display: inline-block; font-size: .75rem; font-weight: 650; padding: .1rem .5rem; border-radius: 999px; color: #fff; background: var(--mute); white-space: nowrap; }
.badge.out { background: none; color: var(--ink2); border: 1px solid var(--line); font-weight: 500; }
.tag { white-space: nowrap; display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 5px; background: var(--bg); color: var(--ink2); margin-right: .25rem; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.acc { background: var(--acc-soft); color: var(--acc); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; vertical-align: baseline; }

/* Filterleiste */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: .75rem; }
.filters > div { min-width: 150px; }
.filters .grow { flex: 1; min-width: 220px; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .85rem; color: var(--ink2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--acc); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .75rem; align-items: center; }
.list li:last-child { border-bottom: 0; }
.bar { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; }
.stack-row { display: grid; grid-template-columns: 110px 1fr 70px; gap: .6rem; align-items: center; font-size: .9rem; margin: .35rem 0; }

/* Mails */
.mailgrid { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.rcpts { max-height: 62vh; overflow-y: auto; margin: 0 -.4rem; }
.rcpt { display: flex; align-items: center; gap: .5rem; padding: .4rem .4rem; border-radius: 7px; cursor: pointer; font-size: .9rem; }
.rcpt:hover { background: var(--bg); }
.rcpt.cur { background: var(--acc-soft); }
.rcpt .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rcpt .done { color: var(--ok); font-size: .8rem; }
.preview-subj { font-weight: 650; }
.preview textarea { min-height: 340px; font-size: .93rem; }
.mailto { word-break: break-all; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

.ph { display: flex; flex-wrap: wrap; gap: .3rem; }
.ph code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: .05rem .35rem; font-size: .8rem; cursor: pointer; }
.ph code:hover { border-color: var(--acc); }
pre.prev { white-space: pre-wrap; font: inherit; font-size: .92rem; background: #fbfaf7; border: 1px solid var(--line); border-radius: 7px; padding: .9rem 1rem; margin: 0; }

/* Meldungen */
.alert { border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1rem; font-size: .92rem; }
.alert.warn { background: var(--warn-soft); color: #6b4500; }
.alert.err { background: var(--acc-soft); color: #7a1f0f; }
.alert.ok { background: var(--ok-soft); color: #1d5233; }
#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; align-items: center; }
#toast div { background: var(--ink); color: #fff; padding: .55rem 1rem; border-radius: 8px; box-shadow: var(--shadow); font-size: .92rem; animation: tin .2s ease-out; }
#toast div.err { background: var(--acc); }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }

/* Dialog */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,18,15,.45); }
dialog .dlg { padding: 1.2rem 1.3rem; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.3rem; background: #faf9f6; border-top: 1px solid var(--line); }

/* Anmeldung */
.login { max-width: 400px; margin: 9vh auto; }
.login img { display: block; width: 230px; margin: 0 auto 1.5rem; }
.login .card { padding: 1.6rem; }

/* Diagramme */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { font: 11px system-ui, sans-serif; fill: var(--ink2); }

/* Pendenzen-Matrix */
.matrix td.c input { width: 18px; height: 18px; cursor: pointer; }
.matrix td.na { color: #d0cbc2; text-align: center; }
.matrix th.c { white-space: normal; min-width: 80px; font-size: .72rem; }

/* Druck */
#print { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  body.printing > *:not(#print) { display: none !important; }
  body.printing #print { display: block; }
  body { background: #fff; }
}
.brief { width: 210mm; height: 296mm; padding: 18mm 20mm 20mm 25mm; position: relative; page-break-after: always; font: 10.5pt/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: #000; overflow: hidden; }
.brief .b-logo { width: 52mm; }
.brief .b-abs { position: absolute; left: 118mm; top: 46mm; font-size: 7pt; color: #444; border-bottom: .3pt solid #888; padding-bottom: 1mm; width: 72mm; }
.brief .b-adr { position: absolute; left: 118mm; top: 52mm; width: 80mm; white-space: pre-line; }
.brief .b-ort { margin-top: 70mm; }
.brief .b-betreff { font-weight: 700; margin: 8mm 0 5mm; font-size: 11pt; }
.brief .b-text { white-space: pre-wrap; }
.etiketten { width: 210mm; height: 297mm; display: grid; grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37.125mm; page-break-after: always; }
.etikett { padding: 5mm 6mm; font: 9.5pt/1.3 system-ui, sans-serif; white-space: pre-line; overflow: hidden; }
.liste { padding: 14mm 14mm; font: 9.5pt/1.35 system-ui, sans-serif; color: #000; }
.liste h1 { font-size: 15pt; margin: 0 0 1mm; }
.liste .lh { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 5mm; }
.liste .lh img { width: 40mm; }
.liste table { font-size: 9pt; }
.liste th { position: static; background: #eee; color: #000; font-size: 8pt; }
.liste th, .liste td { padding: 1.6mm 2mm; border-bottom: .3pt solid #999; }
.liste tr { page-break-inside: avoid; }
.liste td.box { width: 18mm; }
.liste h2 { font-size: 11pt; margin: 6mm 0 2mm; page-break-after: avoid; }

@media (max-width: 1480px) { .brand span { display: none; } }
@media (max-width: 1100px) {
  nav.main { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--card); border-bottom: 1px solid var(--line); flex-direction: column; padding: .5rem; }
  nav.main.open { display: flex; }
  .burger { display: block; }
  .top-in { justify-content: space-between; }
}
@media (max-width: 900px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .mailgrid, .g2, .kgrid { grid-template-columns: 1fr; }
  .brand span { display: none; }
}
@media (max-width: 520px) {
  .g3, .g4 { grid-template-columns: 1fr; }
  main { padding: 1rem .75rem 3rem; }
}
