:root {
  --bg: #f3f4f1;
  --card: #fff;
  --ink: #1d2521;
  --muted: #66706b;
  --line: #dde1dc;
  --brand: #1f5f4a;
  --brand-2: #e8f1ec;
  --accent: #c9822b;
  --danger: #b4372f;
  --ok: #2f7d4f;
  --radius: 10px;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--brand); }
small, .muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; font-size: .78rem; }
.brand strong { display: block; line-height: 1.1; }
.logo { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: .02em; }
.brand.big .logo { width: 48px; height: 48px; font-size: 1.2rem; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { padding: 8px 14px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; }
.tabs a:hover { background: var(--bg); }
.tabs a.active { background: var(--brand-2); color: var(--brand); }
.user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head .grow { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 160px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

label { display: block; font-size: .85rem; font-weight: 600; color: #39433e; }
input, textarea, select { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink); background: #fff; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand-2); border-color: var(--brand); }
textarea { resize: vertical; min-height: 90px; }
textarea.big { min-height: 320px; font-size: .95rem; line-height: 1.6; }
input[type=checkbox] { width: auto; display: inline; margin: 0 6px 0 0; }
.hint { font-size: .82rem; color: var(--muted); font-weight: 400; margin: 4px 0 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #b9c0ba; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #184d3c; }
.btn.ai { background: #fff8ee; border-color: #f0d3ab; color: #8a5414; }
.btn.danger { color: var(--danger); }
.btn.link { border: 0; background: none; padding: 4px 6px; color: var(--brand); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 4px 10px; font-size: .85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafbf9; }
tr.inactive td { color: #9aa29d; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.list li:hover { background: var(--bg); }
.list li.active { background: var(--brand-2); border-color: #cfe2d7; }
.list li strong { display: block; font-weight: 600; }
.list li small { font-size: .8rem; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: #eef0ed; color: var(--muted); }
.badge.ok { background: #e3f2e8; color: var(--ok); }
.badge.warn { background: #fdf1df; color: #94600f; }
.badge.err { background: #f9e3e1; color: var(--danger); }

.recipients { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.recipients label { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-bottom: 1px solid #eef0ed; font-weight: 400; }
.recipients label:last-child { border-bottom: 0; }
.recipients .sub { color: var(--muted); font-size: .85rem; margin-left: auto; }

.preview { border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; background: #fcfcfb; white-space: pre-wrap; font-size: .93rem; max-height: 420px; overflow: auto; }
.progress { height: 8px; background: #eef0ed; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transition: width .4s; }

.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 0; }
.notice { padding: 10px 14px; border-radius: 8px; background: #fdf1df; color: #6b4708; font-size: .9rem; }
.notice.info { background: var(--brand-2); color: var(--brand); }
#banner .notice { max-width: 1192px; margin: 16px auto 0; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 360px; display: grid; gap: 14px; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(720px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,30,25,.45); }
#dialogBody { padding: 22px 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: #1d2521; color: #fff; padding: 10px 18px; border-radius: 8px; transition: transform .25s; z-index: 50; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

details > summary { cursor: pointer; font-weight: 600; font-size: .9rem; }

@media (max-width: 860px) {
  .split, .grid2, .grid3 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 14px; }
}

/* Druckansicht für Protokolle */
#print { display: none; }
@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; font: 11pt/1.5 Georgia, "Times New Roman", serif; color: #000; white-space: pre-wrap; }
  @page { margin: 2cm 2.2cm; }
}
