:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e2e5ea;
  --line-strong: #cbd1da;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #2b5cff;
  --accent-dark: #1c42c4;
  --ok: #0f7b4a;
  --ok-bg: #e6f5ed;
  --warn: #8a5a00;
  --warn-bg: #fdf3df;
  --error: #a3261f;
  --error-bg: #fbeceb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 4px 14px rgba(20, 24, 33, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Kopfzeile ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: .5px;
}
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }

/* Bereichsumschalter: Teilnehmermanagement / Outreach-Listen */
.workspaces { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.workspaces a {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 13px;
}
.workspaces a:hover { border-color: var(--line-strong); color: var(--text); }
.workspaces a.current { background: var(--text); border-color: var(--text); color: #fff; }

/* Navigation innerhalb eines Bereichs */
.subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex; gap: 2px; flex-wrap: wrap;
}
.subnav a {
  padding: 10px 12px; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px;
}
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--accent-dark); border-bottom-color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }

/* ---------- Typografie ---------- */

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }

/* ---------- Flächen ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  display: block;
}
.stat:hover { border-color: var(--line-strong); }
.stat .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.accent .value { color: var(--accent-dark); }

/* ---------- Hinweise ---------- */

.flash { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--error-bg); color: var(--error); }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty p { margin: 0 0 16px; }

/* ---------- Bedienelemente ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--error); border-color: #e8c4c1; }
.btn-danger:hover { background: var(--error-bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--accent); }
textarea { min-height: 200px; resize: vertical; line-height: 1.55; }
.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- Tabellen ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #fafbfc; }
.table-wrap { overflow-x: auto; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
/* ---------- Listenansicht ---------- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .lead { margin-bottom: 20px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=text] { flex: 1 1 280px; }
.toolbar select { flex: 0 1 220px; }

.filterbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.filterbar a {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500;
}
.filterbar a span { color: var(--text); font-weight: 600; margin-left: 4px; }
.filterbar a:hover { border-color: var(--line-strong); }
.filterbar a.current { border-color: var(--accent); color: var(--accent-dark); background: #eef2ff; }

.filterbar-sub { align-items: center; margin-top: -8px; }
.filterbar-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }

/* Aufklappbare Gruppen je Entscheidung */
.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.group > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; cursor: pointer; list-style: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before {
  content: '▸'; color: var(--muted); font-size: 12px; transition: transform .15s ease;
}
.group[open] > summary::before { transform: rotate(90deg); }
.group > summary:hover { background: var(--bg); }
.group-title { font-weight: 650; font-size: 15px; }
.group-count {
  background: var(--bg); border-radius: 999px; padding: 1px 9px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.group-meta { margin-left: auto; font-size: 13px; color: var(--muted); }
.group-meta a { color: var(--muted); text-decoration: none; }
.group-meta a:hover { color: var(--accent-dark); text-decoration: underline; }
.group .table-wrap { border-top: 1px solid var(--line); }

/* „Mehr"-Menü in der Aktionsleiste – hält das Löschen auf Abstand */
.bulkmore { position: relative; margin-left: auto; }
.bulkmore > summary { cursor: pointer; list-style: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.bulkmore > summary::-webkit-details-marker { display: none; }
.bulkmore > summary:hover { background: rgba(255, 255, 255, .12); }
.bulkmore[open] > summary { background: rgba(255, 255, 255, .16); }
.bulkmore > .btn {
  position: absolute; right: 0; top: calc(100% + 6px); white-space: nowrap;
  background: var(--surface); box-shadow: var(--shadow);
}

.quickadd summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.quickadd summary + form { margin-top: 16px; }
.quickadd textarea { min-height: 110px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.bulkbar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--text); color: #fff;
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px;
  box-shadow: 0 6px 20px rgba(20, 24, 33, .18);
}
.bulkbar[hidden] { display: none; }
.bulkbar select, .bulkbar input[type=text] { width: auto; flex: 0 1 200px; }

.table-card { padding: 0; overflow: hidden; }
.col-check { width: 36px; }
.note-dot { color: var(--accent); font-weight: 700; }
td a { color: var(--accent-dark); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }

/* ---------- Anmeldung + Nutzermenü ---------- */

.auth-body { display: grid; place-items: center; min-height: 100vh; }
.auth-main { width: 100%; max-width: 420px; padding: 24px; }
.auth-card { padding: 28px; }

.usermenu { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
.usermenu a {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 13px;
}
.usermenu a:hover { border-color: var(--line-strong); color: var(--text); }
.usermenu a.current { background: var(--text); border-color: var(--text); color: #fff; }
.usermenu form { margin: 0; }
.usermenu button {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.usermenu button:hover { border-color: var(--line-strong); color: var(--text); }

/* ---------- Versand ---------- */

.checkrow { display: flex; gap: 16px; flex-wrap: wrap; }
.checkitem {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 400; font-size: 14px; margin-bottom: 0; cursor: pointer;
}

.progress {
  height: 10px; border-radius: 999px; background: var(--line);
  overflow: hidden; margin-bottom: 14px;
}
.progress-bar { height: 100%; background: var(--accent); transition: width .3s ease; }
.run-line { margin: 0 0 4px; font-size: 15px; }

/* ---------- Mailvorschau ---------- */

.mail-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 20px 22px;
  max-height: 460px;
  overflow-y: auto;
}
.mail-preview p:last-child { margin-bottom: 0; }

code {
  background: #eef1f5; border-radius: 5px; padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
}

.tone-neutral { background: #eef1f5; color: #4b5563; }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-error { background: var(--error-bg); color: var(--error); }
.tone-info { background: #e8eeff; color: var(--accent-dark); }
.tone-hint { background: #f1e9fb; color: #6b3fa0; }
