:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --text: #14171F;
  --muted: #5B6271;
  --border: #E2E5EA;
  --border-strong: #C3C9D3;
  --line: #EEF0F3;
  --accent: #2F5BEA;
  --accent-hover: #2449C8;
  --ok: #1F7A4D;
  --ok-bg: #E8F5EE;
  --neutral-fg: #424955;
  --neutral-bg: #EEF1F5;
  --bad: #B42318;
  --bad-bg: #FDECEA;
  --warn: #B45309;
  --warn-bg: #FEF3E2;
  --radius: 12px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
.h-sm { font-size: 16px; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--neutral-bg); padding: 1px 5px; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); }
.serif { font-family: Georgia, serif; }
.accent-icon { color: var(--accent); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Kopfzeile ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 12px 24px;
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 700; font-size: 17px; }
.topbar-actions { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; margin-left: auto; }

.link-btn {
  background: none; border: none; padding: 0 4px; min-height: 40px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--accent);
}
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }

.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px;
  font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 999px; border: none; cursor: pointer;
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- Layout ---------- */
.container {
  max-width: 1120px; margin: 0 auto; padding: 40px 24px 64px;
  display: flex; flex-direction: column; gap: 28px;
}
.page-head { display: flex; flex-direction: column; gap: 6px; }
.page-head .muted { font-size: 16px; }

.step-panel { display: flex; flex-direction: column; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.main-col { flex: 999 1 520px; min-width: 0; }
.side-col { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row-between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.row-gap { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex-grow: 1; }
.grow-input { flex: 1 1 160px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; display: flex; flex-direction: column; gap: 16px;
}
.card-flush { padding: 0; gap: 0; overflow: hidden; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Schritte ---------- */
.stepper { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.step {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  padding: 6px 4px; min-height: 44px; cursor: pointer; font: inherit;
}
.step:disabled { cursor: not-allowed; }
.step-num {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; background: var(--surface); color: var(--muted); border: 1px solid #D5D9E0;
}
.step-label { font-size: 15px; font-weight: 500; color: var(--muted); }
.step.active .step-num, .step.done .step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.active .step-label { font-weight: 600; color: var(--text); }
.step-line { width: 48px; height: 2px; background: #D5D9E0; }

/* ---------- Formulare & Buttons ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 14px; font-weight: 600; }
.input {
  min-height: 44px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 14px;
  font: inherit; font-size: 15px; color: var(--text); background: var(--surface); width: 100%;
}
select.input { padding-right: 32px; text-overflow: ellipsis; }
textarea.input { resize: vertical; line-height: 1.6; }
textarea.mono { font-size: 13px; }
.input:focus, .editor-source:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input::placeholder, textarea::placeholder { color: #7A818E; }
button:focus, a:focus { outline: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; text-align: center; text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: #F1B8B2; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 13px; }
.btn-md { min-height: 48px; padding: 0 24px; font-size: 15px; }
.btn-lg { min-height: 56px; font-size: 16px; font-weight: 700; border-radius: 10px; }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.seg {
  min-height: 40px; padding: 0 14px; border: none; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; background: var(--surface); color: var(--neutral-fg);
}
.seg.active { background: var(--text); color: #fff; }

.check { display: flex; gap: 10px; align-items: center; font-size: 14px; min-height: 32px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.form-error { color: var(--bad); font-size: 14px; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- Schritt 1 ---------- */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: 10px; padding: 36px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: #F0F4FF; }
.dropzone .btn { margin-top: 6px; pointer-events: none; }
.dz-title { font-size: 15px; font-weight: 500; }
#recipient-file:focus-visible + * , .dropzone:focus-within { outline: 2px solid var(--accent); }

.result-head {
  padding: 18px 24px; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
}
.result-source { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 999px; }
.st-ok { background: var(--ok-bg); color: var(--ok); }
.st-skip { background: var(--neutral-bg); color: var(--neutral-fg); }
.st-bad { background: var(--bad-bg); color: var(--bad); }

.filters { display: flex; gap: 4px; padding: 10px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.filter {
  min-height: 36px; padding: 0 12px; border-radius: 6px; border: none; background: none;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
}
.filter.active { background: var(--neutral-bg); color: var(--text); font-weight: 600; }

.table-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.table th {
  text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 24px; font-weight: 600; position: sticky; top: 0; background: var(--surface);
}
.table td { padding: 10px 24px; border-top: 1px solid var(--line); }
.table td:first-child { color: var(--muted); font-family: var(--mono); width: 80px; }
.table td:nth-child(2) { font-family: var(--mono); word-break: break-all; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.result-foot { padding: 12px 24px; border-top: 1px solid var(--line); }

/* ---------- Schritt 2 ---------- */
.editor { border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.toolbar { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.toolbar-spacer { flex-grow: 1; }
.tool {
  min-width: 36px; height: 36px; border: none; background: none; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--neutral-fg); font: inherit; font-size: 15px;
}
.tool:hover { background: var(--neutral-bg); }
.tool-text { padding: 0 10px; font-size: 13px; font-weight: 600; }
.tool[aria-pressed="true"] { background: var(--text); color: #fff; }
.toolbar.disabled .tool:not(.tool-text) { opacity: 0.4; pointer-events: none; }
.editor-frame { width: 100%; height: 380px; border: none; background: #fff; display: block; }
.editor-source {
  width: 100%; height: 380px; border: none; padding: 14px; font-size: 13px; line-height: 1.6; resize: vertical; color: var(--text);
}
.plain-editor { font-size: 15px; min-height: 320px; }

.mail-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.mail-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-frame { width: 100%; height: 440px; border: none; display: block; background: #fff; }

/* ---------- Schritt 3 ---------- */
.summary { margin: 0; display: flex; flex-direction: column; }
.summary > div {
  display: flex; justify-content: space-between; gap: 16px; padding: 12px 0;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.summary > div:last-child { border-bottom: none; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 500; text-align: right; word-break: break-word; }
.options { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 10px; background: var(--bg); }

.notice { border-radius: 8px; padding: 12px 14px; font-size: 14px; background: var(--neutral-bg); color: var(--neutral-fg); }
.notice.ok { background: var(--ok-bg); color: #1F5E3E; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }

.progress-card { gap: 12px; }
.bar { height: 10px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; display: flex; }
.bar-ok { background: var(--ok); width: 0; transition: width .4s; }
.bar-fail { background: var(--bad); width: 0; transition: width .4s; }
.events { list-style: none; margin: 0; padding: 0; font-size: 12.5px; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; }
.events li { padding: 5px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; word-break: break-all; }
.events .ev-time { color: var(--muted); flex-shrink: 0; }
.events li > span:nth-child(2) { flex-shrink: 0; font-weight: 600; word-break: normal; }
.events .ev-ok { color: var(--ok); }
.events .ev-failed { color: var(--bad); }
.events .ev-info { color: var(--accent); }

.actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 24px; border-top: 1px solid var(--border); }
#next { margin-left: auto; }
#send-test { flex: 1 1 auto; }
#dry-run { width: 100%; }

/* ---------- Anmeldung ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 360px; max-width: 100%; gap: 12px; }
.login-card .brand { margin-bottom: 12px; }

/* ---------- Dialoge & Hinweise ---------- */
.dialog {
  border: none; border-radius: 16px; padding: 28px; width: 460px; max-width: calc(100vw - 32px);
  color: var(--text); box-shadow: 0 20px 50px rgba(20, 23, 31, 0.25);
}
.dialog::backdrop { background: rgba(20, 23, 31, 0.45); }
.dialog > * + * { margin-top: 14px; }
.dialog p { line-height: 1.6; color: var(--neutral-fg); }
.dialog-wide { width: 860px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.log-box {
  margin: 0; margin-top: 14px; background: #0E1013; color: #D2D7DD; border-radius: 10px; padding: 14px;
  font-size: 12.5px; line-height: 1.7; max-height: 60vh; overflow: auto; white-space: pre;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(20, 23, 31, 0.3); z-index: 10; white-space: pre-line;
}
.toast.bad { background: var(--bad); }

/* ---------- Hauptmenü ---------- */
.mainnav { display: flex; gap: 2px 16px; flex-wrap: wrap; flex-grow: 1; margin-left: 16px; }
.nav-item {
  background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 0; min-height: 44px;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--neutral-fg); cursor: pointer;
}
.nav-item:hover { color: var(--text); }
.nav-item.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

/* ---------- Postfächer ---------- */
.container-wide { max-width: 1240px; }
.mb-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.mb-list { flex: 999 1 500px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.mb-panel { flex: 1 1 450px; min-width: 0; }
.table-wrap-free { max-height: none; }
.mb-table td { vertical-align: middle; }
.mb-table td:first-child { width: auto; font-family: var(--font); color: var(--text); padding: 0; }
.mb-table td:nth-child(2) { font-size: 13px; color: var(--neutral-fg); word-break: normal; }
.mb-table tr.selected { background: #F3F6FF; }
.mb-row-btn {
  width: 100%; min-height: 64px; padding: 10px 20px; border: none; border-left: 3px solid transparent; background: none;
  font: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; color: var(--text);
}
.mb-table tr.selected .mb-row-btn { border-left-color: var(--accent); }
.mb-row-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mb-row-mail { font-size: 13px; color: var(--muted); font-family: var(--mono); word-break: break-all; }
.badge-default { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #EEF2FF; color: #2442B8; }

.mb-panel-head { padding: 20px 22px 0; display: flex; flex-direction: column; gap: 4px; }
.mb-panel-head h2 { font-size: 20px; font-weight: 700; word-break: break-word; }
.tabs { display: flex; gap: 4px; padding: 14px 22px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  min-height: 44px; padding: 0 12px; border: none; border-bottom: 2px solid transparent; background: none;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.mb-form { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.pane { display: flex; flex-direction: column; gap: 16px; }
.grid-2-tight { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mb-panel-foot {
  padding: 16px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between;
}
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.bar-thin { height: 8px; }
.bar-accent { background: var(--accent); width: 0; }

/* ---------- Absender-Wahl ---------- */
.mb-options { display: flex; flex-direction: column; gap: 10px; }
.mb-option {
  min-height: 72px; padding: 14px 16px; border-radius: 10px; border: 1.5px solid #D5D9E0; background: var(--surface);
  font: inherit; text-align: left; cursor: pointer; display: flex; gap: 14px; align-items: center; color: var(--text);
}
.mb-option:hover:not(:disabled) { border-color: var(--border-strong); }
.mb-option[aria-checked="true"] { border-color: var(--accent); background: #F3F6FF; }
.mb-option:disabled { opacity: 0.6; cursor: not-allowed; }
.mb-mark {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #A3AAB6; background: var(--surface);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.mb-mark.square { border-radius: 5px; }
.mb-mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; opacity: 0; }
.mb-option[aria-checked="true"] .mb-mark { border-color: var(--accent); background: var(--accent); }
.mb-option[aria-checked="true"] .mb-mark::after { opacity: 1; }
.mb-option[aria-checked="true"] .mb-mark.square::after {
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  border-radius: 0; background: none; transform: rotate(45deg) translate(-1px, -1px);
}
.mb-opt-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-grow: 1; }
.mb-opt-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; font-size: 13px; text-align: right; }
.txt-ok { color: var(--ok); font-weight: 600; }
.txt-bad { color: var(--bad); font-weight: 600; }
.link-btn-icon { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; font-weight: 600; }
.notice.warn { background: var(--warn-bg); color: #8A3F06; }
.summary-sm > div { padding: 9px 0; font-size: 14px; }

/* ---------- Konten & Verwaltung ---------- */
.account-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 2px 10px 2px 2px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit;
}
.account-btn:hover { border-color: var(--border-strong); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #EEF2FF; color: #2442B8;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.account-name { font-size: 14px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs-page { padding: 0; margin-bottom: 4px; }
.badge-admin { background: #EEF2FF; color: #2442B8; }
.mb-table .badge { font-family: var(--font); }

/* ---------- Versandeinstellungen ---------- */
.settings-form { display: flex; flex-direction: column; gap: 18px; }
.settings-group { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.settings-group legend { font-weight: 600; font-size: 15px; padding: 0 6px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.input-unit { position: relative; }
.input-unit .input { padding-right: 44px; }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--muted); pointer-events: none; }
.settings-group.off .grid-4 { opacity: 0.5; }
@media (max-width: 720px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.access-list { display: flex; flex-direction: column; gap: 4px; }
.access-list .check { padding: 6px 0; border-bottom: 1px solid var(--line); }
.access-list .check:last-child { border-bottom: none; }
.access-list .muted { margin-left: auto; font-size: 12px; }
.jobs-table td { vertical-align: middle; }
.jobs-table td:first-child { width: auto; font-family: var(--font); color: var(--text); }
.jobs-table td:nth-child(2) { font-family: var(--font); word-break: break-word; }
.job-progress { display: flex; flex-direction: column; gap: 4px; min-width: 140px; font-size: 13px; }
.mb-row-access { font-size: 12px; color: var(--muted); }
.stack-sm h3 { margin: 8px 0 0; }

@media (max-width: 560px) {
  .account-name { display: none; }
  .account-btn { padding: 3px; }
  .topbar-actions { margin-left: 0; }
  .mainnav { margin-left: 0; order: 3; width: 100%; }
  .grid-2-tight { grid-template-columns: minmax(0, 1fr); }
  .container { padding: 24px 16px 48px; }
  .topbar-inner { padding: 10px 16px; }
  h1 { font-size: 26px; }
  .card { padding: 18px; }
  .step-line { width: 20px; }
  .actions .btn { flex: 1 1 auto; }
}
