/* Dunkles Design (Dark Factory), unabhängig von der Einstellung des Systems */
:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --bg-2: #12151a;
  --fg: #e6e8eb;
  --muted: #8b95a3;
  --card: #171b21;
  --card-2: #1d222a;
  --line: #2a3039;
  --accent: #f0a429;
  --accent-soft: rgba(240, 164, 41, 0.14);
  --ok: #3ecf8e;
  --warn: #f0a429;
  --bad: #ff6b6b;
  --idle: #6aa9ff;
  --offline: #5b6573;
  --cpu: #7dd3fc;
  --human: #c4a7ff;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  background: radial-gradient(1200px 500px at 50% -200px, #1a1f27 0%, var(--bg) 70%) fixed, var(--bg);
}
h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
h2 .meta { text-transform: none; letter-spacing: 0; font-weight: 400; }
h3 { margin: 0; font-size: 15px; }

/* Kopfzeile und Navigation */
.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  padding: 10px 16px;
  background: rgba(13, 15, 18, 0.88);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
h1 {
  margin: 0;
  font: 600 15px/1 var(--mono);
  letter-spacing: 0.08em; text-transform: uppercase;
}
h1::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 10px;
  background: var(--accent); border-radius: 2px; box-shadow: 0 0 10px var(--accent);
}
nav { display: flex; gap: 4px; }
nav a {
  padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500;
}
nav a:hover { color: var(--fg); background: var(--card); }
nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.grow { flex: 1; min-width: 0; }

main { padding: 16px clamp(16px, 2vw, 56px); max-width: 2800px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }

/* Bausteine */
.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: 12px; }
.error { color: var(--bad); }
.error:empty, .notice:empty { display: none; }
.notice { color: var(--ok); }
button, input, select, textarea {
  font: inherit; padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--fg);
}
input::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible, nav a:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
button { cursor: pointer; transition: border-color .15s, background .15s; }
button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
button:disabled { opacity: .45; cursor: default; }
button.danger { color: var(--bad); }
button.danger:hover:not(:disabled) { border-color: var(--bad); background: rgba(255, 107, 107, 0.12); }
button.ghost { background: transparent; }
button.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); background: var(--accent); }

/* Anmeldung */
.login { justify-items: center; padding-top: 8vh; }
.login .card { width: min(420px, 100%); display: grid; gap: 10px; }
.login h2 { color: var(--fg); font-size: 16px; text-transform: none; letter-spacing: 0; }
.login p { margin: 0; }
.login label { font-size: 12px; color: var(--muted); }
.login { display: grid; gap: 14px; }
.login details.card summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.login details.card[open] summary { margin-bottom: 8px; }
.stack-s { display: grid; gap: 10px; }
a.button { display: inline-block; text-align: center; text-decoration: none; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--line); }
a.button.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
a.button.primary:hover { filter: brightness(1.1); }
.me-link { color: var(--muted); text-decoration: none; font-size: 13px; margin-right: 8px; }
.me-link:hover, .me-link[aria-current] { color: var(--fg); }

/* Rollen: Benutzer sehen keine Befehle an Worker und keine Einstellungen (der Controller lehnt sie ohnehin ab) */
body[data-role="user"] .bulk, body[data-role="user"] .tile-actions, body[data-role="user"] [data-admin],
body[data-role="pending"] [data-route]:not([data-route="profile"]) { display: none !important; }

/* Profil, Benutzer, Audit */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 10px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; }
.token-status { margin: 8px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#token-form input { min-width: 220px; }
.check { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.chip.member { display: inline-flex; gap: 4px; align-items: center; margin: 0 4px 4px 0; }
.chip-x { padding: 0 4px; border: 0; background: transparent; color: var(--muted); line-height: 1; }
.chip-x:hover:not(:disabled) { color: var(--bad); background: transparent; }
.add-member { gap: 4px; flex-wrap: wrap; }
.add-member select, .add-member button { padding: 3px 8px; font-size: 12px; }
table.users tr.inactive td { opacity: .55; }
table.audit td { vertical-align: top; }
.nowrap { white-space: nowrap; }
.retry-form { gap: 6px; flex-wrap: nowrap; }
.retry-form input { padding: 3px 8px; }

/* Plaketten und Zustände */
.badge {
  padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid currentColor; background: color-mix(in srgb, currentColor 12%, transparent);
}
.running { color: var(--ok); } .idle { color: var(--idle); } .paused { color: var(--warn); } .offline { color: var(--muted); }
.pending { color: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.chip { padding: 1px 8px; border-radius: 4px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.note { margin-top: 6px; padding: 6px 10px; border-left: 3px solid var(--warn); background: var(--accent-soft); border-radius: 4px; font-size: 12px; }
.activity {
  margin-top: 4px; font: 12px/1.4 var(--mono); color: #c9d1d9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }

/* Sammelaktionen */
.bulk { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulk .proj { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; }
.bulk .count { margin-left: auto; }
.more { position: relative; }
.more summary {
  list-style: none; cursor: pointer; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-2); user-select: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: " ▾"; color: var(--muted); }
.more[open] summary { border-color: var(--accent); }
.menu {
  position: absolute; z-index: 3; right: 0; top: calc(100% + 4px); min-width: 210px;
  display: grid; gap: 6px; padding: 8px; background: var(--card-2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.menu button { text-align: left; }
.retry { display: grid; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.retry input { width: 100%; }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi {
  display: grid; gap: 2px; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card-2), var(--card)); border-top: 3px solid var(--line);
}
.kpi-n { font: 600 30px/1.1 var(--mono); }
.kpi-l { color: var(--muted); font-size: 12px; }
.kpi.working { border-color: var(--ok); background: linear-gradient(180deg, rgba(62,207,142,.22), rgba(62,207,142,.06)); } .kpi.working .kpi-n { color: var(--ok); }
.kpi.idle { border-color: var(--idle); background: linear-gradient(180deg, rgba(106,169,255,.22), rgba(106,169,255,.06)); } .kpi.idle .kpi-n { color: var(--idle); }
.kpi.paused { border-color: var(--warn); background: linear-gradient(180deg, rgba(240,164,41,.22), rgba(240,164,41,.06)); } .kpi.paused .kpi-n { color: var(--warn); }
.kpi.offline { border-color: var(--offline); } .kpi.offline .kpi-n { color: var(--muted); }
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; }
.fcell { display: grid; gap: 3px; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--line); border-left: 4px solid var(--offline); background: var(--bg-2); min-width: 0; }
.fcell.running { border-left-color: var(--ok); } .fcell.idle { border-left-color: var(--idle); } .fcell.paused, .fcell.pending { border-left-color: var(--warn); }
.fcell { color: var(--fg); }
.fn { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb { display: grid; grid-template-columns: 26px 1fr 34px; gap: 5px; align-items: center; font-size: 10px; color: var(--muted); }
.fb i { font-style: normal; } .fb em { font-style: normal; text-align: right; font-family: var(--mono); }
.fb b { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; display: block; }
.fb u { display: block; height: 100%; background: var(--ok); } .fb u.warn { background: var(--warn); } .fb u.bad { background: var(--bad); }
.charts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 900px) { .charts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.charts .wide { grid-column: 1 / -1; }
/* Das Diagramm gehört in sein Panel: Chart.js setzt Breite und Höhe der Zeichenfläche in Pixeln und behält sie bei
   geändertem Browser-Zoom oder schmalerem Fenster zu lange. Der Rahmen gibt die Größe vor, nicht die Zeichenfläche. */
.charts .card, .stack > .card { min-width: 0; }
.donut, .line, .bars { min-width: 0; overflow: hidden; }
.donut > canvas, .line > canvas, .bars > canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.donut, .line { position: relative; height: 200px; }
.line { height: 180px; }
.bars { position: relative; height: 140px; }
.donut-mid { position: absolute; left: 0; right: 0; top: 0; bottom: 30px; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-mid span:first-child { font: 600 30px/1 var(--mono); }
.empty { padding: 10px 0; }
.working-list, .settings-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.working-list li, .settings-list li { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.working-list li:last-child, .settings-list li:last-child { border-bottom: 0; padding-bottom: 0; }

/* Worker-Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.tile {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 14px 16px 12px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card-2), var(--card)); overflow: visible;
}
.tile::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--offline); }
.tile.s-running::before { background: var(--ok); } .tile.s-idle::before { background: var(--idle); }
.tile.s-paused::before, .tile.s-pending::before { background: var(--warn); }
.work { font-size: 15px; }
.hw { font-size: 12px; color: var(--muted); }
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gauge { display: grid; justify-items: center; gap: 1px; text-align: center; min-width: 0; }
.gauge svg { width: 58px; height: 58px; }
.g-pct { font: 600 10px var(--mono); fill: var(--fg); }
.gauge .track { stroke: var(--line); }
.gauge .val { transition: stroke-dasharray .4s; }
.gauge .val.ok { stroke: var(--ok); } .gauge .val.warn { stroke: var(--warn); } .gauge .val.bad { stroke: var(--bad); }
.g-label { font-size: 12px; font-weight: 600; }
.g-detail { max-width: 100%; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark { width: 100%; height: 26px; }
.spark polyline { stroke: var(--accent); }
.tile-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-top: 6px; border-top: 1px solid var(--line); }
.tile-actions .more { margin-left: auto; }
pre {
  margin: 0; padding: 10px; max-height: 260px; overflow: auto;
  background: #08090b; border: 1px solid var(--line); border-radius: 6px; color: #c9d1d9;
  font: 12px/1.45 var(--mono); white-space: pre-wrap;
}

/* Einstellungen */
.created { margin-top: 12px; display: grid; gap: 6px; }
.token {
  font: 12px var(--mono); word-break: break-all; padding: 8px;
  background: #08090b; border: 1px solid var(--accent); border-radius: 6px;
}
.settings-list .row { gap: 12px; }

/* ---- Posteingang, Projekte, Zuordnung ---- */
textarea { width: 100%; resize: vertical; min-height: 64px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
code { font: 12px var(--mono); background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; overflow-wrap: anywhere; }
.count-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: var(--accent); color: #111; font: 700 11px/18px var(--mono); text-align: center; }
.kpi.inbox { text-decoration: none; color: inherit; cursor: pointer; }
.kpi.inbox:hover { border-color: var(--accent); }
.kpi.inbox.attention { border-color: var(--accent); background: linear-gradient(180deg, rgba(240,164,41,.22), rgba(240,164,41,.06)); }
.kpi.inbox.attention .kpi-n { color: var(--accent); }
.proj-chip { color: var(--accent); border-color: var(--accent-soft); }
.assign { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.chip.fixed { color: var(--accent); border-color: var(--accent); }
.cap { padding: 0 7px; border-radius: 99px; font-size: 11px; color: var(--cpu); border: 1px solid color-mix(in srgb, var(--cpu) 40%, transparent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-radius: 6px; }

.fld { display: grid; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
.fld input, .fld select, .fld textarea { color: var(--fg); font-size: 14px; width: 100%; }
.fld.narrow { width: 90px; }
.fld.inline { display: flex; align-items: center; gap: 6px; }
.fld.inline select { width: auto; max-width: 180px; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 18px; padding: 0; border-radius: 99px; position: relative; background: var(--bg-2); cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(16px); background: var(--accent); }
.pform, .newvar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.pform .fld { flex: 1 1 140px; } .pform .fld.narrow { flex: 0 0 90px; }
.pform .fld.wide { flex: 2 1 320px; } .pform .fld.narrow.branch { flex: 0 0 130px; }
.newvar { padding-top: 10px; border-top: 1px dashed var(--line); }
.newvar .fld { flex: 1 1 180px; }
.hint { margin: 10px 0 0; }
.proj { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.proj.inactive { opacity: .8; }
.pk { font: 600 15px var(--mono); }
.pmeta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; align-items: center; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.vars { width: 100%; border-collapse: collapse; font-size: 13px; }
.vars th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 6px 10px; background: var(--bg-2); }
.vars td { padding: 6px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.vars td:first-child { overflow-wrap: anywhere; }
.vars .acts { text-align: right; white-space: nowrap; } .vars .acts button { margin-left: 4px; padding: 3px 9px; }
.vars input[type="text"], .vars input[type="password"] { min-width: 150px; flex: 1; }
.secret { color: var(--ok); font-family: var(--mono); font-size: 12px; }
.val { word-break: break-all; }
.wrow { gap: 10px; }
.wrow .winfo { min-width: 120px; }
.wrow strong { overflow-wrap: anywhere; }

/* Posteingang wie ein E-Mail-Client */
.mail { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 0; height: calc(100vh - 100px); min-height: 460px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.mail-list-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--bg-2); }
.mail-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.mail-filters select { flex: 1; min-width: 0; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; padding: 5px 11px; }
.seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; } .seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); position: relative; }
.mail-list { overflow-y: auto; flex: 1; min-height: 0; }
.mail-list-pane .empty { padding: 14px; }
.mail-row { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; color: var(--fg); text-decoration: none; }
.mail-row:hover { background: var(--card); }
.mail-row.selected { background: var(--accent-soft); border-left-color: var(--accent); }
.mail-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.mail-row.done { color: var(--muted); }
.mail-row.unread .m-title { font-weight: 700; }
.mark { flex: none; width: 16px; height: 16px; margin-top: 2px; display: grid; place-items: center; font-size: 11px; font-weight: 700; border-radius: 50%; }
.mark.new { width: 9px; height: 9px; margin: 6px 3.5px 0; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.mark.read { width: 9px; height: 9px; margin: 6px 3.5px 0; border: 1px solid var(--muted); }
.mark.ok { color: var(--ok); } .mark.fail { color: var(--bad); border: 1px solid var(--bad); font-size: 10px; }
.mark.wait { border: 2px solid var(--idle); border-top-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.m-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.m-top { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); min-width: 0; }
.m-proj, .m-ticket { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.m-ticket { font-family: var(--mono); }
.m-time { margin-left: auto; white-space: nowrap; }
.m-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-teaser { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.m-state { font-size: 11px; font-weight: 600; } .m-state.answered { color: var(--idle); } .m-state.failed { color: var(--bad); } .m-state.done { color: var(--ok); }
.kind { display: inline-flex; align-items: center; gap: 4px; padding: 0 7px 0 5px; border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--idle); background: color-mix(in srgb, currentColor 12%, transparent); }
.kind .ki { width: 13px; height: 13px; flex: none; }
.k-plan { color: var(--idle); } .k-decision { color: var(--accent); } .k-paths { color: var(--cpu); } .k-failure { color: var(--bad); } .k-merge { color: var(--ok); }
.mail-read { overflow-y: auto; min-width: 0; padding: 18px 22px 28px; }
.mail-read .back { display: none; margin-bottom: 10px; color: var(--accent); text-decoration: none; font-weight: 600; }
.reader-empty { padding: 40px 0; text-align: center; }
.rd-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rd-title { margin: 8px 0 6px; font-size: 20px; line-height: 1.3; letter-spacing: 0; text-transform: none; color: var(--fg); overflow-wrap: anywhere; }
.rd-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; margin: 0 0 10px; font-size: 12px; }
.rd-meta div { display: flex; gap: 6px; min-width: 0; } .rd-meta dt { color: var(--muted); } .rd-meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.rd-links { display: flex; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 10px; }
a { color: var(--cpu); }
.badge.st-open { color: var(--accent); } .badge.st-answered { color: var(--idle); } .badge.st-done { color: var(--ok); } .badge.st-failed { color: var(--bad); }
.md { line-height: 1.6; overflow-wrap: anywhere; padding: 6px 0 4px; }
.md > :first-child { margin-top: 0; }
.md h3, .md h4, .md h5, .md h6 { margin: 18px 0 6px; line-height: 1.3; }
.md h3 { font-size: 17px; } .md h4 { font-size: 15px; } .md h5, .md h6 { font-size: 14px; color: var(--muted); }
.md p { margin: 0 0 10px; } .md ul, .md ol { margin: 0 0 10px; padding-left: 22px; } .md li.sub { margin-left: 18px; }
.md .diagram { margin: 0 0 14px; overflow-x: auto; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); }
.md .md-table { margin: 0 0 12px; overflow-x: auto; }
.md table { border-collapse: collapse; font-size: 13px; width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; overflow-wrap: break-word; }
.md td code { overflow-wrap: anywhere; }
.md th { background: rgba(255, 255, 255, 0.04); font-weight: 600; }
.md blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md pre.code { margin: 0 0 12px; max-height: 420px; }
.md pre.code code { background: none; border: 0; padding: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.ans-h { margin: 12px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.extra { display: grid; gap: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); cursor: pointer; }
.opt:hover { border-color: var(--muted); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt.rec { border-left: 3px solid var(--ok); }
.opt input { margin-top: 3px; flex: none; accent-color: var(--accent); padding: 0; }
.opt-body { display: grid; gap: 4px; min-width: 0; }
.opt-t { font-weight: 600; overflow-wrap: anywhere; }
.opt-d { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tag { margin-left: 8px; padding: 0 7px; border-radius: 99px; font-size: 11px; color: var(--ok); border: 1px solid var(--ok); font-weight: 600; }
.given { font-size: 14px; } .given-text { white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 12px; border-left: 3px solid var(--line); background: var(--bg-2); border-radius: 4px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; border: 1px solid currentColor; font-weight: 600; overflow-wrap: anywhere; }
.banner.wait { color: var(--idle); } .banner.ok { color: var(--ok); } .banner.fail { color: var(--bad); }
.spin { width: 14px; height: 14px; flex: none; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
/* Breite Bildschirme: Platz nutzen, Lesetext bleibt gut lesbar */
@media (min-width: 1800px) {
  .charts { grid-template-columns: minmax(320px, 1fr) 2fr; }
  .mail { grid-template-columns: minmax(380px, 480px) minmax(0, 1fr); }
  .mail-read { padding: 22px 36px 36px; }
  .md > p, .md > ul, .md > ol, .md > blockquote { max-width: 125ch; }
  .fleet { max-height: 340px; }
}
@media (min-width: 2200px) {
  html { zoom: 1.25; }
  /* vh rechnet nicht mit dem Zoom, die Höhe des Posteingangs gleicht das aus */
  body { min-height: calc(100vh / 1.25); }
  .mail { height: calc(100vh / 1.25 - 100px); }
}
@media (max-width: 800px) {
  .mail { display: block; height: auto; min-height: 0; border: 0; background: none; overflow: visible; }
  .mail-list-pane { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
  .mail-read { padding: 4px 2px 28px; }
  .mail[data-detail="1"] .mail-list-pane { display: none; }
  .mail:not([data-detail="1"]) .mail-read { display: none; }
  .mail-read .back { display: inline-block; }
  .fld.narrow { width: 100%; flex: 1 1 100%; }
  .wrow .fld.inline { flex: 1 1 100%; } .wrow .fld.inline select { flex: 1; max-width: none; }
  .pmeta { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .mark.wait, .spin { animation: none; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 560px) {
  .top { gap: 8px; }
  nav { order: 3; width: 100%; overflow-x: auto; }
  .tiles, .charts { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bulk .count { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .pending { animation: none; } .gauge .val { transition: none; } }
nav a { white-space: nowrap; }

/* ---- Ablauf des Workflows ---- */
.flow { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 2px; font-size: 12px; }
.flow li { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); }
.flow li + li::before { content: '›'; margin-left: -6px; margin-right: 4px; color: var(--line); }
.flow li.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.flow li.done::after { content: '✓'; margin-left: 4px; }
.flow li.now { color: #111; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.flow li.human:not(.now) { border-style: dashed; }

/* Auswertung */
.line.tall { height: 260px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.data .n { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .task-row { cursor: pointer; }
table.data .task-row:hover, table.data .task-row:focus-visible { background: var(--accent-soft); outline: none; }
table.data .task-detail > td { background: var(--bg-2); padding: 8px 10px 12px 24px; }
table.data.inner { width: auto; min-width: 50%; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
