:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --border: #e1e4df;
  --text: #1c211f;
  --muted: #5f6964;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f2ef;
  --ok: #15803d;
  --ok-soft: #e5f4ea;
  --warn: #b45309;
  --warn-soft: #fdf1e2;
  --bad: #b91c1c;
  --bad-soft: #fbe9e9;
  --idle: #9aa39e;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(20 30 25 / 6%), 0 2px 8px rgb(20 30 25 / 4%);
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #181d1b;
    --surface-2: #1f2522;
    --border: #2b3330;
    --text: #e6ebe8;
    --muted: #97a39d;
    --accent: #2dd4bf;
    --accent-ink: #062b27;
    --accent-soft: #123a35;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --warn: #fbbf24;
    --warn-soft: #3a2c10;
    --bad: #f87171;
    --bad-soft: #3b1717;
    --idle: #5d6762;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 48px; color: var(--muted); }

/* ---- Layout ---------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; padding: 4px 10px 18px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count {
  font-size: 12px; font-weight: 600; min-width: 22px; text-align: center;
  padding: 0 7px; border-radius: 999px; background: var(--bad); color: #fff;
}
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.side-foot strong { display: block; color: var(--text); font-weight: 600; }
.main { padding: 28px 36px 64px; max-width: 1280px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 24px; line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 620; }
.sub { color: var(--muted); margin: 4px 0 0; }
.section { margin-top: 28px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .brand { padding: 0 8px 0 0; }
  .nav { display: flex; gap: 2px; overflow-x: auto; max-width: 100%; }
  .nav a { white-space: nowrap; }
  .page-head { align-items: flex-start; }
  .search { max-width: none; }
  .side-foot { display: none; }
  .main { padding: 20px 16px 48px; }
  .kpi .value { font-size: 26px; }
  table.alerts td { padding: 10px 10px; }
  table.alerts tr { display: grid; grid-template-columns: auto 1fr; border-bottom: 1px solid var(--border); }
  table.alerts tr:last-child { border-bottom: none; }
  table.alerts td { border-bottom: none; }
  table.alerts td.actions { grid-column: 2; text-align: left; padding-top: 0; }
}

/* ---- Bausteine ---------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi.bad .value { color: var(--bad); }
.kpi.warn .value { color: var(--warn); }
.kpi .hint { font-size: 12px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 550; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.idle { background: var(--surface-2); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--idle); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
td.actions { text-align: right; width: 1%; }
table.alerts td:first-child { width: 1%; white-space: nowrap; }
.msg { overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err-text { color: var(--bad); font-size: 13px; max-width: 460px; overflow-wrap: anywhere; }
.cell-stock { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.channel { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.channel > .row:last-child { margin-top: auto; padding-top: 4px; }
.channel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.channel-name { font-weight: 620; }
.channel-type { font-size: 13px; color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 13px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.copy { display: flex; gap: 6px; align-items: center; }
.copy code {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--surface-2); padding: 5px 8px; border-radius: 6px; font-family: var(--mono); font-size: 12px;
}

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search { flex: 1; min-width: 200px; max-width: 360px; }
input[type='text'], input[type='email'], input[type='password'], input[type='url'], input[type='number'], select, textarea {
  width: 100%; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chips { display: flex; gap: 4px; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 5px 11px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

/* ---- Formulare, Dialoge --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; }
.field .help { font-size: 12.5px; color: var(--muted); }
dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgb(0 0 0 / 25%);
}
dialog::backdrop { background: rgb(10 15 12 / 45%); }
.dlg-head { padding: 18px 22px 0; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 16px 22px; overflow-y: auto; }
.dlg-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
pre.instructions { white-space: pre-wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; font-family: var(--mono); font-size: 12.5px; margin: 0; overflow-wrap: anywhere; }
.err-list { margin: 0; padding-left: 18px; font-size: 13px; }

/* ---- Anmeldung ---------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login .brand { padding: 0 0 18px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
}
.toast.bad { background: var(--bad); color: #fff; }
