:root {
  --brand: #7f395b;
  --brand-dark: #5f0632;
  --brand-soft: #f3e6ed;
  --yellow: #f7dd0c;
  --bg: #f4f1f2;
  --card: #ffffff;
  --text: #2a1f25;
  --muted: #6f6369;
  --line: #e4dce0;
  --ok: #2f7d4f;
  --ok-soft: #e3f3e9;
  --warn: #9a6200;
  --warn-soft: #fdf1d8;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --radius: 12px;
  --nav-w: 210px;
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }

/* ---------- Anmeldung */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: linear-gradient(180deg, #e9e5e7, var(--bg)); }
.login-card { width: 100%; max-width: 440px; background: var(--card); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(95, 6, 50, .15); overflow: hidden; padding: 0 1.25rem 1.25rem; display: grid; gap: .8rem; }
.login-logo { width: calc(100% + 2.5rem); margin: 0 -1.25rem .4rem; display: block; }

/* ---------- Rahmen */
.shell { min-height: 100%; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  background: var(--brand); color: #fff; padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top));
  border-bottom: 3px solid var(--yellow); }
.brand { font-family: "Segoe Script", "Segoe Print", cursive; font-weight: 700; font-size: 1.45rem; color: var(--yellow);
  text-decoration: none; text-shadow: 1px 1px 0 var(--brand-dark), -1px -1px 0 var(--brand-dark), 1px -1px 0 var(--brand-dark), -1px 1px 0 var(--brand-dark);
  white-space: nowrap; }
.global-search { flex: 1; max-width: 560px; }
.global-search input { width: 100%; border: 0; border-radius: 999px; padding: .55rem 1rem; font-size: 1rem; }
.nav { position: fixed; z-index: 15; background: var(--card); display: flex; }
.nav a { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-weight: 600; }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.nav .ico { font-size: 1.25rem; width: 1.5rem; text-align: center; }
.view { padding: 1rem; outline: none; max-width: 1150px; }

@media (min-width: 900px) {
  .nav { top: 58px; bottom: 0; left: 0; width: var(--nav-w); flex-direction: column; padding: .8rem .5rem;
    border-right: 1px solid var(--line); gap: .2rem; }
  .nav a { padding: .7rem .9rem; border-radius: 10px; }
  .view { margin-left: var(--nav-w); padding: 1.5rem 2rem 3rem; }
}
@media (max-width: 899px) {
  .nav { left: 0; right: 0; bottom: 0; border-top: 1px solid var(--line); justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom); }
  .nav a { flex-direction: column; gap: 0; font-size: .72rem; padding: .4rem .2rem .45rem; flex: 1; }
  .view { padding-bottom: 6rem; }
  .brand { font-size: 1.2rem; }
}

/* ---------- Bausteine */
.card { background: var(--card); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(42, 31, 37, .08); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.side { grid-template-columns: 1.1fr .9fr; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--card); border-radius: var(--radius); padding: .9rem 1rem; text-decoration: none; color: var(--text);
  box-shadow: 0 1px 3px rgba(42, 31, 37, .08); border-left: 5px solid var(--brand); }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat.bad { border-left-color: var(--bad); } .stat.warn { border-left-color: #e0a100; } .stat.ok { border-left-color: var(--ok); }
.banner { width: 100%; border-radius: var(--radius); display: block; margin-bottom: 1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line);
  background: var(--card); color: var(--text); border-radius: 10px; padding: .55rem .95rem; font-size: .95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 42px; font-family: inherit; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.yellow { background: var(--yellow); border-color: #d9c100; color: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; }
.btn.big { min-height: 50px; font-size: 1.05rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; text-decoration: none; color: var(--text); }
a.row:hover { background: #faf7f8; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.row .side { text-align: right; flex-shrink: 0; }

.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap; }
.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.grey { background: #eee; color: #555; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.big-phone { font-size: 1.15rem; font-weight: 700; text-decoration: none; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a, .tabs button { padding: .4rem .85rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem; cursor: pointer; font-family: inherit; }
.tabs .active { background: var(--brand); border-color: var(--brand); color: #fff; }

.status-bar { display: flex; flex-wrap: wrap; gap: .35rem; }
.status-bar button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .4rem .8rem;
  font-weight: 600; cursor: pointer; font-family: inherit; font-size: .88rem; }
.status-bar button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.search-box { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-box input { flex: 1; }

input, select, textarea { font: inherit; padding: .6rem .7rem; border: 1px solid #cfc4ca; border-radius: 9px; background: #fff;
  color: var(--text); width: 100%; min-height: 44px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
label { display: grid; gap: .25rem; font-weight: 600; font-size: .9rem; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(6, 1fr); }
.form-grid > * { grid-column: span 6; }
@media (min-width: 640px) {
  .form-grid .w2 { grid-column: span 2; } .form-grid .w3 { grid-column: span 3; } .form-grid .w4 { grid-column: span 4; }
}
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.chips button { border: 1px solid var(--line); background: #faf7f8; border-radius: 999px; padding: .25rem .65rem;
  font-size: .82rem; cursor: pointer; font-family: inherit; }
.chips button:hover { border-color: var(--brand); }
.error { color: var(--bad); min-height: 1em; margin: 0; }

.dialog { border: 0; border-radius: 14px; padding: 0; width: min(680px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dialog::backdrop { background: rgba(42, 31, 37, .45); }
.dialog form { padding: 1.1rem 1.2rem; display: grid; gap: .9rem; }
.dialog .dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog .dialog-head h2 { margin: 0; }
.dialog .actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--muted); line-height: 1; }

.toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%) translateY(20px); background: var(--text); color: #fff;
  padding: .7rem 1.1rem; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); }

table.items { width: 100%; border-collapse: collapse; }
table.items th, table.items td { text-align: left; padding: .55rem .6rem; border-top: 1px solid var(--line); vertical-align: top; }
table.items th { font-size: .8rem; color: var(--muted); border-top: 0; text-transform: uppercase; letter-spacing: .03em; }
table.items tr.click { cursor: pointer; }
table.items tr.click:hover td { background: #faf7f8; }
@media (max-width: 700px) {
  table.items thead { display: none; }
  table.items tr { display: block; border-top: 1px solid var(--line); padding: .5rem 0; }
  table.items td { display: block; border: 0; padding: .1rem .6rem; }
  table.items td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .85rem; }
}
details.legacy summary { cursor: pointer; color: var(--muted); font-weight: 600; }
details.legacy pre { white-space: pre-wrap; font-size: .82rem; background: #faf7f8; padding: .7rem; border-radius: 8px; margin: .5rem 0 0; }
.empty { padding: 1rem; color: var(--muted); text-align: center; }
.loading { padding: 2rem; text-align: center; color: var(--muted); }
.more { display: flex; justify-content: center; padding: .8rem; }
.row.tight { padding: .5rem 0; }
.mt { margin-top: .6rem; }
.card-sub { border-top: 1px solid var(--line); }
.card-sub:first-of-type { border-top: 0; }
.spacer { flex: 1; }
input.cb { width: auto; min-height: 0; margin-right: .4rem; transform: scale(1.3); }
a.danger { color: var(--bad); }
a.main { text-decoration: none; color: inherit; }
a.main:hover .title { color: var(--brand); }
.card-sub { padding: .7rem 0; }
.card-sub .title { font-weight: 600; }
.card-sub .sub { color: var(--muted); font-size: .9rem; margin-top: .15rem; }
details.legacy .card-sub { opacity: .8; }
.form-grid > label { align-content: start; }
@media (min-width: 1100px) { .grid.order { grid-template-columns: 1.7fr .8fr; } }
