/* ==========================================================================
   Webapp-Grundgerüst – Gestaltung
   Farben nur aus dem Schema (--c1 … --c5) und deren Aufhellungen
   (--cX-10 … --cX-96 = Farbe mit 10 … 96 % Weiß), erzeugt in View::themeCss().
   ========================================================================== */

:root {
  --c1:#714329; --c2:#808463; --c3:#899378; --c4:#D089A7; --c5:#85A192;
  --ink: var(--c1);
  --muted: var(--c2);
  --line: var(--c3-75, #e2e4de);
  --line-strong: var(--c3-60, #d0d4c9);
  --bg: var(--c3-92, #f6f6f4);
  --surface: #ffffff;
  --accent: var(--c4);
  --accent-soft: var(--c4-85, #f8eaf0);
  --accent-faint: var(--c4-96, #fdf9fb);
  --ok: var(--c5);
  --ok-soft: var(--c5-85, #ecf1ee);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "URW Palladio L", "Book Antiqua", P052, Georgia, serif;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, "Noto Sans", sans-serif;

  --fs-xs: .75rem; --fs-sm: .8125rem; --fs: .9375rem; --fs-md: 1.0625rem; --fs-lg: 1.375rem; --fs-xl: 1.75rem; --fs-xxl: 2.5rem;
  --r-sm: 5px; --r: 8px; --r-lg: 14px;
  --panel-w: 268px;
  --top-h: 64px;
  --shadow-pop: 0 18px 50px -12px color-mix(in srgb, var(--c1) 35%, transparent), 0 2px 6px color-mix(in srgb, var(--c1) 12%, transparent);
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fs)/1.5 var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.005em; }
p { margin: 0 0 .75em; }
a { color: var(--ink); text-decoration-color: var(--c4); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: .92em; }
small { font-size: var(--fs-sm); }
[hidden] { display: none !important; }
::selection { background: var(--c4-75); color: var(--c1); }
:focus-visible { outline: 2px solid var(--c4); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--r); }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Farbband (Erkennungszeichen) ---------- */
.band { display: flex; flex-direction: column; }
.band i { flex: 1; display: block; }
.band i:nth-child(1) { background: var(--c1-40); }
.band i:nth-child(2) { background: var(--c2); }
.band i:nth-child(3) { background: var(--c3); }
.band i:nth-child(4) { background: var(--c4); }
.band i:nth-child(5) { background: var(--c5); }

/* ==========================================================================
   Schaltflächen und Formulare
   ========================================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink);
  font: 600 var(--fs-sm)/1 var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { border-color: var(--c3); background: var(--c3-96); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--c1); border-color: var(--c1); color: #fff; }
.btn-primary:hover { background: var(--c1-10); border-color: var(--c1-10); }
.btn-accent { background: var(--c4); border-color: var(--c4); color: var(--c1); }
.btn-accent:hover { background: var(--c4-10); }
.btn-danger { background: var(--accent-soft); border-color: var(--c4); color: var(--c1); }
.btn-danger:hover { background: var(--c4-75); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--c3-92); border-color: transparent; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: var(--fs-xs); }
.btn-lg { min-height: 50px; padding: 0 26px; font-size: var(--fs); }
.btn-block { width: 100%; }
.btn[disabled], .icon-btn[disabled] { opacity: .45; cursor: not-allowed; }

.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; padding: 0; border: 0; border-radius: var(--r);
  background: transparent; color: inherit; cursor: pointer; text-decoration: none; transition: background .15s, color .15s; position: relative; }
.icon-btn:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.icon-btn.is-danger:hover { background: var(--accent-soft); color: var(--c1); }
.icon-btn.is-on { background: var(--accent-soft); }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-sm .ic { width: 17px; height: 17px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--c1); display: flex; align-items: center; gap: 4px; min-height: 28px; }
.field .hint { color: var(--muted); font-size: var(--fs-xs); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search], input[type=url], input[type=tel],
input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: var(--fs)/1.35 var(--sans); transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 110px; resize: vertical; }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808463' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; }
input:hover, select:hover, textarea:hover { border-color: var(--c3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c4); box-shadow: 0 0 0 3px var(--c4-75); }
input[disabled], select[disabled], textarea[disabled], input[readonly] { background: var(--c3-96); color: var(--c2); }
input[type=color] { width: 44px; height: 44px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r); background: none; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 5px; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 6px 0; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--c1); flex: none; }
.check small { display: block; color: var(--muted); font-size: var(--fs-xs); }
input[type=checkbox], input[type=radio] { accent-color: var(--c1); }

.pw { position: relative; display: block; }
.pw input { padding-right: 44px; }
.pw .pw-toggle { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); color: var(--c2); }

.with-flag { display: flex; align-items: center; gap: 10px; }
.with-flag select { flex: 1; }
.flag { display: inline-flex; width: 26px; height: 18px; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); flex: none; }
.flag svg { width: 100%; height: 100%; display: block; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px 20px; align-items: start; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

/* Hinweise */
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); font-size: var(--fs-sm); margin: 0 0 16px; }
.note .ic { margin-top: 1px; }
.note ul { margin: 4px 0 0; padding-left: 18px; }
.note-info { background: var(--ok-soft); }
.note-error { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--c4); }
.note-warn { background: var(--c2-85); }

/* Toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: var(--r); background: var(--c1); color: #fff;
  box-shadow: var(--shadow-pop); font-size: var(--fs-sm); animation: toast-in .35s var(--ease); }
.toast-success .ic:first-child { color: var(--c5-40); }
.toast-error { background: var(--surface); color: var(--c1); box-shadow: var(--shadow-pop), inset 4px 0 0 var(--c4); }
.toast span { flex: 1; }
.toast-x { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 4px; display: grid; }
.toast-x:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ==========================================================================
   Dashboard-Rahmen
   ========================================================================== */
.shell { display: flex; min-height: 100dvh; }
.panel { width: var(--panel-w); flex: none; background: var(--c1); color: var(--c1-92); display: flex; position: sticky; top: 0; height: 100dvh;
  transition: margin-left .3s var(--ease); z-index: 40; }
.panel .band { width: 5px; flex: none; }
.panel-inner { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 14px 12px 12px; overflow-y: auto; }
.shell.is-collapsed .panel { margin-left: calc(var(--panel-w) * -1); }

.brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 18px; }
.brand a { font-family: var(--serif); font-size: var(--fs-lg); color: #fff; text-decoration: none; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; }
.panel .icon-btn { color: var(--c1-75); }
.panel .icon-btn:hover { color: #fff; background: color-mix(in srgb, #fff 10%, transparent); }

.modules { display: grid; gap: 2px; padding: 4px; background: color-mix(in srgb, #000 16%, var(--c1)); border-radius: var(--r); }
.module-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--c1-85); text-decoration: none; font-size: var(--fs-sm); font-weight: 600; }
.module-link .ic { width: 18px; height: 18px; color: var(--mc); }
.module-link:hover { background: color-mix(in srgb, #fff 7%, transparent); color: #fff; }
.module-link.is-active { background: var(--c1-10); color: #fff; box-shadow: inset 3px 0 0 var(--mc); }
.module-link.c1, .mod-c1 { --mc: var(--c1-60); }
.module-link.c2, .mod-c2 { --mc: var(--c2-40); }
.module-link.c3, .mod-c3 { --mc: var(--c3-40); }
.module-link.c4, .mod-c4 { --mc: var(--c4); }
.module-link.c5, .mod-c5 { --mc: var(--c5-40); }

.menu { margin-top: 22px; display: grid; gap: 1px; }
.menu-title { margin: 0 10px 8px; font-family: var(--serif); font-size: var(--fs-md); color: #fff; font-style: italic; }
.menu-link { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 6px; color: var(--c1-85); text-decoration: none; font-size: var(--fs); position: relative; }
.menu-link .ic { width: 19px; height: 19px; color: var(--c1-60); }
.menu-link:hover { background: color-mix(in srgb, #fff 7%, transparent); color: #fff; }
.menu-link.is-active { color: #fff; background: color-mix(in srgb, var(--c4) 22%, transparent); }
.menu-link.is-active .ic { color: var(--c4-40); }
.menu-link.is-active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c4); }

.whoami { margin-top: auto; padding-top: 14px; border-top: 1px solid color-mix(in srgb, #fff 12%, transparent); display: flex; align-items: center; gap: 6px; }
.whoami-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 6px; border-radius: 6px; }
.whoami-name:hover { background: color-mix(in srgb, #fff 7%, transparent); }
.whoami-name span:last-child { min-width: 0; display: grid; }
.whoami-name strong { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whoami-name small { color: var(--c1-60); font-size: var(--fs-xs); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--c4); color: var(--c1); font-weight: 700; flex: none; font-family: var(--serif); font-size: var(--fs-md); }

.scrim { display: none; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 24px 0 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--mc); transform-origin: left; transform: scaleX(.06); }
.panel-open { color: var(--c1); }
.crumb { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.crumb-mod { font-size: var(--fs-xs); color: var(--muted); }
.crumb h1 { font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.page { flex: 1; padding: 24px; min-width: 0; }
.page:focus { outline: none; }
.page-fill { padding: 0; display: flex; flex-direction: column; height: calc(100dvh - var(--top-h)); }

/* ==========================================================================
   Inhaltsbausteine
   ========================================================================== */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.sheet-pad { padding: 22px 24px; }
.stack { display: grid; gap: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.muted { color: var(--muted); }
.lead { font-size: var(--fs-md); color: var(--muted); max-width: 70ch; }

/* Gruppen (Einrichtung, Systemkonfiguration) */
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.group + .group { margin-top: 16px; }
.group-head { display: flex; gap: 14px; align-items: flex-start; padding: 18px 22px 0; }
.group-head h2 { font-size: var(--fs-md); }
.group-head p { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-sm); max-width: 70ch; }
.group-body { padding: 16px 22px 22px; }
.step { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--c1); color: #fff; font: 600 var(--fs-sm)/1 var(--serif); }
.sec-ic { width: 30px; height: 30px; padding: 5px; border-radius: 50%; background: var(--c3-85); color: var(--c1); }

/* Systemkonfiguration ohne Rahmen um die Formulare */
.flat .group { background: transparent; border: 0; border-radius: 0; border-top: 1px solid var(--line); }
.flat .group + .group { margin-top: 0; }
.flat .group:first-child { border-top: 0; }
.flat .group-head, .flat .group-body { padding-left: 0; padding-right: 0; }
.flat .group-body { padding-bottom: 26px; }

/* Register */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 0; background: none; color: var(--muted); font: 600 var(--fs-sm)/1 var(--sans);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab .ic { width: 17px; height: 17px; }
.tab:hover { color: var(--c1); }
.tab.is-active { color: var(--c1); border-bottom-color: var(--c4); }
.tab .count { font-size: var(--fs-xs); background: var(--c3-85); color: var(--c1); border-radius: 99px; padding: 2px 7px; }

/* Farbfelder */
.swatches { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.swatch { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 8px 12px 8px 8px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; min-width: 150px; }
.swatch input { grid-row: span 2; }
.swatch span { font-size: var(--fs-sm); font-weight: 600; }
.swatch code { font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.tbl th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; color: var(--c2); background: var(--c3-96); padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--c3-85); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--accent-faint); }
.tbl tr.is-selected td { background: var(--accent-soft); }
.tbl tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--c4); }
.tbl td.actions, .tbl th.actions { width: 1%; white-space: nowrap; text-align: right; }
.tbl td.actions .icon-btn { width: 30px; height: 30px; color: var(--c2); }
.tbl td.actions .icon-btn:hover { color: var(--c1); }
.tbl .nowrap { white-space: nowrap; }
.tbl td.num { text-align: right; }
.tbl .wrap { white-space: normal; word-break: break-word; }
.tbl-plain { border: 0; border-radius: 0; }

.sort-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.sort-btn:hover { color: var(--c1); }
.sort-btn .ic { width: 14px; height: 14px; opacity: 0; }
.sort-btn.is-sorted { color: var(--c1); }
.sort-btn.is-sorted .ic { opacity: 1; fill: var(--c4); stroke: var(--c4); }
.th-inner { display: flex; align-items: center; gap: 2px; }
.filter-btn { width: 24px; height: 24px; border-radius: 4px; color: var(--c3); }
.filter-btn .ic { width: 14px; height: 14px; }
.filter-btn.is-on { color: var(--c1); background: var(--c4-75); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: var(--fs-xs); font-weight: 600; background: var(--c3-85); color: var(--c1); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); }
.badge-ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c5); }
.badge-warn { background: var(--c2-85); }
.badge-warn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c2); }
.badge-error { background: var(--accent-soft); }
.badge-error::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c4); }

/* Schalter */
.switch { position: relative; display: inline-flex; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--c3-60); transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 2px color-mix(in srgb, var(--c1) 30%, transparent); }
.switch input:checked + span { background: var(--c5); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--c4); outline-offset: 2px; }

/* Werkzeugleiste */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.search { position: relative; min-width: 180px; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--c2); pointer-events: none; }
.search input { padding-left: 34px; min-height: 36px; }

/* Leere Zustände */
.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ic { width: 34px; height: 34px; color: var(--c3); stroke-width: 1.4; }
.empty p { margin: 0; max-width: 40ch; }

/* Popover / Dialog */
.pop { position: fixed; z-index: 70; min-width: 220px; max-width: min(320px, calc(100vw - 20px)); background: var(--surface); border-radius: var(--r);
  box-shadow: var(--shadow-pop); padding: 10px; animation: pop-in .14s var(--ease); }
.pop-list { max-height: 260px; overflow: auto; margin: 8px 0; display: grid; gap: 1px; }
.pop-list .check { padding: 4px 6px; border-radius: 4px; font-size: var(--fs-sm); }
.pop-list .check:hover { background: var(--c3-96); }
.pop-foot { display: flex; gap: 6px; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 8px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

dialog.dlg { border: 0; padding: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); color: var(--ink); }
dialog.dlg::backdrop { background: color-mix(in srgb, var(--c1) 40%, transparent); backdrop-filter: blur(2px); }
dialog.dlg[open] { animation: pop-in .18s var(--ease); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px 22px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { flex: 1; font-size: var(--fs-md); }
.dlg-body { padding: 18px 22px; overflow: auto; max-height: calc(100dvh - 180px); }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 22px 18px; }

/* Countdown */
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; background: var(--surface); padding: 1px 8px; border-radius: 99px; margin-left: 4px; }

/* Kennzahlen (Systemstatus) */
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.status-card h2 { font-size: var(--fs-md); padding: 16px 18px 6px; }
.status-list { list-style: none; margin: 0; padding: 4px 18px 14px; }
.status-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--c3-85); font-size: var(--fs-sm); align-items: center; }
.status-list li:last-child { border-bottom: 0; }

/* Rechte-Matrix */
.perm-mod { border-top: 1px solid var(--line); padding: 12px 0; }
.perm-mod h3 { font-size: var(--fs); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; }

/* Code-Ausgabe */
.code-block { background: var(--c1); color: var(--c1-92); padding: 14px 16px; border-radius: var(--r); overflow: auto; font-size: var(--fs-sm); }
.copy-line { display: flex; gap: 8px; align-items: center; }
.copy-line input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: var(--fs-sm); }

/* Paginierung */
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 12px; font-size: var(--fs-sm); color: var(--muted); }

/* ==========================================================================
   Anmeldung und Einrichtung
   ========================================================================== */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); min-height: 100dvh; }
.auth-brand { position: relative; background: var(--c1); color: var(--c1-92); display: flex; align-items: flex-end; padding: 56px; overflow: hidden; }
.auth-brand .band-tall { position: absolute; left: 56px; top: 0; height: 46%; width: 120px; flex-direction: row; gap: 0; }
.auth-brand .band-tall i { transform-origin: top; animation: band-grow .9s var(--ease) both; }
.auth-brand .band-tall i:nth-child(2) { animation-delay: .08s; } .auth-brand .band-tall i:nth-child(3) { animation-delay: .16s; }
.auth-brand .band-tall i:nth-child(4) { animation-delay: .24s; } .auth-brand .band-tall i:nth-child(5) { animation-delay: .32s; }
@keyframes band-grow { from { transform: scaleY(0); } }
.auth-app { font-family: var(--serif); font-size: clamp(2.6rem, 6vw, 5.2rem); line-height: .98; color: #fff; margin: 0 0 18px; font-weight: 600; letter-spacing: -.02em; overflow-wrap: anywhere; }
.auth-claim { font-size: var(--fs-md); max-width: 34ch; color: var(--c1-75); margin: 0; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-form { width: min(380px, 100%); display: grid; gap: 18px; }
.auth-form h1 { font-size: var(--fs-xl); margin-bottom: 4px; }
.auth-form .note { margin: 0; }
.langs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.lang-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 99px; text-decoration: none; font-size: var(--fs-sm); color: var(--muted); }
.lang-pill .flag { width: 20px; height: 14px; }
.lang-pill:hover { background: var(--c3-85); color: var(--c1); }
.lang-pill[aria-current] { color: var(--c1); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }

.setup { max-width: 860px; margin: 0 auto; padding: 40px 20px 60px; }
.setup-head { display: flex; gap: 22px; align-items: stretch; margin-bottom: 28px; }
.setup-head .band { width: 10px; border-radius: 2px; overflow: hidden; flex: none; }
.setup-head h1 { font-size: var(--fs-xxl); letter-spacing: -.02em; }
.setup-head p { color: var(--muted); font-size: var(--fs-md); margin: 6px 0 0; max-width: 60ch; }
.setup-submit { display: flex; justify-content: flex-end; margin-top: 24px; position: sticky; bottom: 16px; }
.setup-submit .btn { box-shadow: var(--shadow-pop); }
.checks { display: grid; gap: 4px; margin-top: 12px; }

.error-page { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.error-box { max-width: 520px; background: var(--surface); padding: 32px; border-radius: var(--r-lg); border: 1px solid var(--line); }
.error-box h1 { font-size: var(--fs-xl); margin-bottom: 10px; }
.error-box pre { overflow: auto; font-size: var(--fs-xs); background: var(--c3-96); padding: 12px; border-radius: var(--r); }

/* ==========================================================================
   Handy
   ========================================================================== */
@media (max-width: 900px) {
  .panel { position: fixed; left: 0; top: 0; bottom: 0; margin-left: calc(var(--panel-w) * -1 - 10px); box-shadow: var(--shadow-pop); }
  .shell.is-open .panel { margin-left: 0; }
  .shell.is-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: color-mix(in srgb, var(--c1) 35%, transparent); }
  .shell.is-collapsed .panel { margin-left: calc(var(--panel-w) * -1 - 10px); }
  .topbar { padding: 0 12px 0 6px; }
  .page { padding: 16px; }
  .page-fill { padding: 0; }
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { padding: 34px 104px 28px 24px; min-height: 0; }
  .auth-brand .band-tall { left: auto; right: 24px; height: 100%; width: 60px; }
  .auth-app { font-size: 2.4rem; }
}
@media (max-width: 640px) {
  :root { --top-h: 56px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .crumb h1 { font-size: var(--fs-md); }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 10px; }
  .group-head, .group-body { padding-left: 16px; padding-right: 16px; }
  .sheet-pad { padding: 16px; }
  .setup { padding-top: 24px; }
  .setup-head h1 { font-size: var(--fs-xl); }

  /* Tabellen werden Karten */
  .table-cards { border: 0; background: transparent; overflow: visible; }
  .table-cards table, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards thead { display: none; }
  .table-cards tr { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; padding: 8px 12px; position: relative; }
  .table-cards td { border: 0 !important; padding: 4px 0; display: grid; grid-template-columns: 38% 1fr; gap: 10px; background: transparent !important; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; padding-top: 2px; }
  .table-cards td.actions { display: flex; justify-content: flex-end; width: 100%; border-top: 1px solid var(--c3-85) !important; margin-top: 6px; padding-top: 6px; }
  .table-cards td.actions::before { display: none; }
  .table-cards td.card-title { order: -1; display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: var(--fs); padding-bottom: 6px; }
  .table-cards td:empty { display: none; }
  .table-cards td.actions { order: 99; }
  .table-cards td.card-title::before { display: none; }
  .table-cards tr.is-selected { box-shadow: inset 3px 0 0 var(--c4); background: var(--accent-faint); }
  .table-cards tr.is-selected td:first-child { box-shadow: none; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .table-cards td.nowrap { white-space: normal; }
  .table-cards td > .badge, .table-cards td > form > .switch { justify-self: start; }
  .mod-table tr { flex-direction: row; flex-wrap: wrap; }
  .mod-table td.mod-order { order: 98; width: auto; display: flex; border-top: 1px solid var(--c3-85) !important; margin-top: 6px; padding-top: 6px; }
  .mod-table td.mod-order::before { display: none; }
  .mod-table td.actions { flex: 1; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .panel, .topbar, .toasts { display: none !important; }
  .page { padding: 0; }
}

/* ==========================================================================
   Modulverwaltung
   ========================================================================== */
.ic.flip { transform: rotate(180deg); }
.mod-title { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.mod-title > span:last-child { display: grid; min-width: 0; }
.mod-title small { font-size: var(--fs-xs); white-space: normal; }
a.mod-title:hover strong { text-decoration: underline; text-decoration-color: var(--c4); text-underline-offset: 3px; }
.mod-mark { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; color: var(--c1); background: var(--mk); }
.mod-c1 { --mk: var(--c1-85); } .mod-c2 { --mk: var(--c2-75); } .mod-c3 { --mk: var(--c3-75); } .mod-c4 { --mk: var(--c4-75); } .mod-c5 { --mk: var(--c5-75); }
.mod-table tr.is-off td { color: var(--muted); }
.mod-table .mod-order { width: 1%; white-space: nowrap; }
.mod-table tr.is-off .mod-mark { opacity: .5; filter: grayscale(.6); }

.color-pick { display: inline-flex; gap: 6px; }
.cp { position: relative; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.cp input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.cp1 { background: var(--c1); } .cp2 { background: var(--c2); } .cp3 { background: var(--c3); } .cp4 { background: var(--c4); } .cp5 { background: var(--c5); }
.cp:has(input:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c1); }
.cp:has(input:focus-visible) { outline: 2px solid var(--c4); outline-offset: 4px; }

.mod-facts { display: flex; flex-wrap: wrap; gap: 10px 32px; padding: 12px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px; font-size: var(--fs-sm); }
.mod-facts > div { display: grid; gap: 2px; }
.mod-facts .label { min-height: 0; color: var(--muted); font-weight: 600; font-size: var(--fs-xs); }
.mod-lists h3 { font-size: var(--fs); margin-bottom: 6px; }
.mod-lists ul { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; font-size: var(--fs-sm); }
.mod-lists li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mod-lists li .ic { width: 16px; height: 16px; color: var(--c2); }
.mod-danger { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-top: 18px; padding: 14px 16px; border-radius: var(--r); background: var(--accent-faint); box-shadow: inset 3px 0 0 var(--c4); }
