:root {
  --canvas: #f4f5f7;
  --paper: #ffffff;
  --ink: #1c2128;
  --ink-muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --brand: #ffcc00;        /* Swiss-Post-Gelb als Akzent */
  --primary: #111827;
  --primary-hover: #000000;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Sidebar layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  font-weight: 700; font-size: 15px;
  border-bottom: 1px solid var(--line);
}
.sidebar__logo {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; color: #111; font-size: 13px;
}
.sidebar__nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__nav--bottom { margin-top: auto; border-top: 1px solid var(--line); }
.nav__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  text-decoration: none; color: var(--ink-muted);
  font-weight: 500;
}
.nav__link:hover { background: var(--canvas); color: var(--ink); }
.nav__link.is-active { background: #111827; color: #fff; }
.nav__icon { width: 18px; text-align: center; opacity: .9; }
.sidebar__foot { padding: 12px; border-top: 1px solid var(--line); }
.sidebar__user { font-size: 12px; color: var(--ink-muted); margin-bottom: 8px; padding: 0 4px; }

.main { margin-left: 240px; flex: 1; padding: 28px 40px 60px; min-width: 0; }

/* ---------- Header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--ink-muted); }

/* ---------- Test-mode banner ---------- */
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 8px;
  margin-bottom: 18px; font-weight: 600; font-size: 13px;
}
.banner--test { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }
.banner--live { background: var(--err-bg); color: var(--err); border: 1px solid #fecaca; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 15px; margin: 0 0 4px; }
.card__sub { color: var(--ink-muted); font-size: 13px; margin: 0 0 18px; }
.card__section { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 20px; }
.card__section:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.card__section > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); margin: 0 0 14px; }

/* ---------- Stat grid ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat__label { color: var(--ink-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat__value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat__hint { font-size: 12px; margin-top: 4px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { color: var(--ink-muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #111827; outline-offset: 0; border-color: #111827; }
input[readonly] { background: var(--canvas); color: var(--ink-muted); }

.check { display: flex; align-items: flex-start; gap: 10px; }
.check input { margin-top: 3px; width: 16px; height: 16px; }
.check label { font-weight: 600; }
.check .hint { font-weight: 400; }

.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 22px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-hover); }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--canvas); }
.btn--danger { background: #fff; color: var(--err); border-color: #fca5a5; }
.btn--danger:hover { background: var(--err-bg); }
.btn--sm { padding: 6px 11px; font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--canvas); font-weight: 600; color: var(--ink-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
td.wrap, th.wrap { white-space: normal; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--err { background: var(--err-bg); color: var(--err); }
.badge--muted { background: var(--canvas); color: var(--ink-muted); border: 1px solid var(--line); }
.badge--test { background: var(--warn-bg); color: var(--warn); }

/* ---------- Flash / toast ---------- */
.flash { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow);
  background: #fff; border: 1px solid var(--line); font-size: 13.5px;
}
.toast--ok { border-left: 4px solid var(--ok); }
.toast--err { border-left: 4px solid var(--err); }

/* ---------- Auth (login/setup) ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth__box { width: 100%; max-width: 400px; }
.auth__brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 22px; font-weight: 700; font-size: 18px; }
.auth__card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.auth__card h1 { font-size: 18px; margin: 0 0 4px; }
.auth__card p.sub { color: var(--ink-muted); margin: 0 0 20px; font-size: 13px; }
.auth .field { margin-bottom: 14px; }
.auth .btn { width: 100%; justify-content: center; margin-top: 6px; }
.auth__error { background: var(--err-bg); color: var(--err); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

/* ---------- Toggle switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch > input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative; width: 46px; height: 26px; flex-shrink: 0;
  background: var(--line-strong); border-radius: 999px; transition: background .15s ease;
}
.switch__thumb {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .15s ease;
}
.switch > input:checked + .switch__track { background: #16a34a; }
.switch > input:checked + .switch__track .switch__thumb { transform: translateX(20px); }
.switch > input:focus-visible + .switch__track { outline: 2px solid #111827; outline-offset: 2px; }
.switch__text { font-weight: 600; }

/* ---------- Collapsible "Erweitert" ---------- */
details.adv {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px;
}
details.adv > summary {
  cursor: pointer; padding: 16px 24px; font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 8px; color: var(--ink);
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: '▸'; color: var(--ink-muted); }
details.adv[open] > summary::before { content: '▾'; }
details.adv[open] > summary { border-bottom: 1px solid var(--line); }
details.adv > .adv__body { padding: 20px 24px 22px; }

.muted { color: var(--ink-muted); }
.empty { padding: 40px; text-align: center; color: var(--ink-muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 13px; }
.kv dt { color: var(--ink-muted); }
.token-box { display: flex; gap: 10px; align-items: center; }
.token-box input { font-family: ui-monospace, monospace; font-size: 12.5px; }
