:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e3e7ee;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fe;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --error: #c62828;
  --error-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
code, pre { font-family: var(--mono); font-size: .9em; background: #eef1f6; border-radius: 4px; padding: .05em .35em; }
pre.code { padding: .75rem; overflow-x: auto; user-select: all; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.brand-mark { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: .95rem; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { padding: .35rem .7rem; border-radius: 7px; color: var(--muted); }
.topbar nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.topbar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.logout { display: flex; align-items: center; gap: .6rem; margin: 0; }

main { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }
main.narrow, .narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.login { margin-top: 10vh; }
.setup main { padding-top: 3rem; }
.foot { text-align: center; padding: 1rem; font-size: .8rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumb { margin: 0; color: var(--muted); font-size: .9rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.table-card { padding: 1.25rem 0 .5rem; }
.card.table-card > h2, .card.table-card > .card-head, .card.table-card > p, .card.table-card > .bulkbar { padding: 0 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.card.empty { text-align: center; padding: 2.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 1.25rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-accent { border-color: var(--accent); background: var(--accent-soft); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: .5rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th:first-child, .table td:first-child { padding-left: 1.25rem; }
.table th:last-child, .table td:last-child { padding-right: 1.25rem; }
.table tbody tr:hover { background: #fafbfd; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-check { width: 2rem; }
.table tr.dim td { color: var(--muted); }
.log .msg { white-space: pre-wrap; word-break: break-word; }
.nowrap { white-space: nowrap; }

.bulkbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }

progress { width: 100%; max-width: 160px; height: .55rem; border: 0; border-radius: 99px; overflow: hidden; background: var(--line); appearance: none; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eef1f6; color: var(--muted); white-space: nowrap; vertical-align: middle; }
.phase-neu { background: #eef1f6; color: var(--muted); }
.phase-initial, .phase-delta { background: var(--accent-soft); color: var(--accent); }
.phase-final { background: var(--warn-soft); color: var(--warn); }
.phase-abgeschlossen, .job-done { background: var(--ok-soft); color: var(--ok); }
.job-queued { background: #eef1f6; color: var(--muted); }
.job-running, .job-cancelling { background: var(--accent-soft); color: var(--accent); }
.job-failed { background: var(--error-soft); color: var(--error); }
.job-cancelled { background: var(--warn-soft); color: var(--warn); }
.lvl-warn.badge { background: var(--warn-soft); color: var(--warn); }
.lvl-error.badge { background: var(--error-soft); color: var(--error); }
tr.lvl-error td { background: #fff8f8; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.ok-text { color: var(--ok); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.error-text { color: var(--error); font-weight: 600; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); border-color: #b7e1c1; color: #14532d; }
.flash-error { background: var(--error-soft); border-color: #f5c2c2; color: #7f1d1d; }
.flash-info { background: var(--accent-soft); border-color: #c6d8fb; color: #1e3a8a; }
.flash.pre { white-space: pre-wrap; font-family: var(--mono); font-size: .85rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(31, 111, 235, .35); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1a5fd0; }
.btn-warn { background: var(--warn-soft); border-color: #f0d38a; color: var(--warn); }
.btn-danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn-danger:hover { background: #a61f1f; }
.btn-small { padding: .25rem .6rem; font-size: .82rem; }

.form { display: flex; flex-direction: column; gap: .8rem; }
.form label, .field > label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }
.form .btn { align-self: flex-start; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input:not([type]), select, textarea {
  font: inherit; padding: .5rem .65rem; border: 1px solid #cfd5df; border-radius: 7px; background: #fff; color: var(--text); width: 100%;
}
input[readonly] { background: #f3f5f8; color: var(--muted); }
textarea { font-family: var(--mono); font-size: .88rem; resize: vertical; }
label.check { flex-direction: row !important; align-items: center; gap: .45rem; font-weight: 500; }
fieldset.inline { border: 0; padding: 0; margin: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }
fieldset.inline legend { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem 1.5rem; }
.field p { margin: .25rem 0 0; }
.field-error { color: var(--error); font-size: .85rem; font-weight: 600; }
.has-error input, .has-error select { border-color: var(--error); }
.sticky-actions { position: sticky; bottom: 0; padding: .75rem 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.inline-form { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 240px; }

.phase-buttons { display: grid; gap: .75rem; margin-bottom: 1rem; }
.phase-buttons form { margin: 0; }
.phase-buttons p { margin: .3rem 0 0; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.checks li { display: grid; grid-template-columns: 1.4rem 1fr; column-gap: .4rem; padding: .5rem .65rem; border-radius: 7px; font-size: .9rem; }
.checks li::before { grid-row: span 2; font-weight: 700; }
.checks li.ok { background: var(--ok-soft); }
.checks li.ok::before { content: "✓"; color: var(--ok); }
.checks li.fail { background: var(--error-soft); }
.checks li.fail::before { content: "✕"; color: var(--error); }
.checks li span { color: var(--muted); word-break: break-word; }

.tabs { display: flex; gap: .25rem; }
.tabs a { padding: .3rem .7rem; border-radius: 7px; color: var(--muted); font-size: .88rem; }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

details.group { border-top: 1px solid var(--line); padding: .6rem 0; }
details summary { cursor: pointer; }
.members { margin: .5rem 0 0; padding-left: 1.2rem; font-size: .9rem; columns: 2 260px; }

.danger-zone { border-color: #f5c2c2; }
.steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .4rem; }

@media (max-width: 700px) {
  main { padding: 1rem; }
  .topbar { padding: .6rem 1rem; gap: .75rem; }
  .table th:first-child, .table td:first-child { padding-left: 1rem; }
}

/* System und Assistent */
.checks li.warn { background: var(--warn-soft); }
.checks li.warn::before { content: "!"; color: var(--warn); }
.stack { display: flex; flex-direction: column; gap: 1.25rem; }
.stack > .card { margin-bottom: 0; }
form.inline { display: inline-flex; margin: 0 .25rem 0 0; vertical-align: middle; }
.wizard { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1.25rem; counter-reset: w; flex-wrap: wrap; }
.wizard li { counter-increment: w; padding: .35rem .8rem; border-radius: 99px; background: #eef1f6; color: var(--muted); font-size: .88rem; }
.wizard li::before { content: counter(w) ". "; }
.wizard li.current { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.wizard li.done { background: var(--ok-soft); color: var(--ok); }
input[type="file"] { font: inherit; padding: .4rem; border: 1px dashed #cfd5df; border-radius: 7px; background: #fafbfd; }

/* Analyse */
.findings { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; }
.findings li { padding: .5rem .7rem; border-radius: 7px; background: #f6f8fb; font-size: .9rem; }
.findings li.find-error { background: var(--error-soft); }
.findings li.find-warn { background: var(--warn-soft); }
.lvl-info.badge { background: var(--accent-soft); color: var(--accent); }
.stat-warn { border-color: #f0d38a; background: var(--warn-soft); }
#analyse h3 { margin-top: 1.5rem; }
#analyse .table-wrap { margin: 0 -1.25rem; }
