/* SIPI Designsystem: Basis, Layout und Komponenten. Nur semantische Tokens aus tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-15);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-24); }
h2 { font-size: var(--fs-18); }
h3 { font-size: var(--fs-15); }
p { margin: 0; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; }
:focus { outline: none; }
[tabindex="-1"]:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.num, .k-value, .g-big, .nav-count, .count, .counter { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }

.skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--surface); color: var(--text); padding: 10px 14px; border-radius: var(--r-md); box-shadow: var(--shadow-2); }
.skip:focus { top: 12px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.shell-main { min-width: 0; display: flex; flex-direction: column; }
.page { padding: var(--sp-8) var(--sp-8) var(--sp-12); width: 100%; max-width: var(--content-max); margin: 0 auto; flex: 1; }
.page:focus { outline: none; }
[tabindex="-1"]:focus { outline: none; }
.auth-mode .shell { display: none; }

/* Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; height: var(--header-h); text-decoration: none; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.brand-name { font-weight: var(--fw-semibold); font-size: var(--fs-16); letter-spacing: 0.01em; line-height: 1.1; }
.brand-sub { font-size: var(--fs-12); color: var(--text-muted); font-weight: var(--fw-regular); letter-spacing: 0; }
.nav-scroll { flex: 1; overflow-y: auto; padding: 4px 12px 12px; overscroll-behavior: contain; }
.nav-label { font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-subtle); text-transform: uppercase; letter-spacing: 0.06em; padding: 14px 10px 6px; }
.nav-item, .nav-mod > summary {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 38px; padding: 6px 10px; border-radius: var(--r-md);
  color: var(--text); text-decoration: none; font-weight: var(--fw-medium);
  background: none; border: 0; text-align: left; position: relative; list-style: none;
}
.nav-mod > summary::-webkit-details-marker { display: none; }
.nav-item:hover, .nav-mod > summary:hover { background: var(--surface-hover); color: var(--text); }
.nav-item .icon, .nav-mod > summary .icon { color: var(--text-muted); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: var(--fw-semibold); }
.nav-item[aria-current="page"] .icon { color: var(--accent-text); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-mod > summary .chev { margin-left: auto; transition: transform var(--dur) var(--ease); color: var(--text-subtle); }
.nav-mod[open] > summary .chev { transform: rotate(90deg); }
.nav-mod > summary .lbl { flex: 1; }
.nav-mod.has-current > summary { font-weight: var(--fw-semibold); }
.nav-mod.has-current > summary .icon:first-child { color: var(--accent-text); }
.nav-sub { margin: 2px 0 6px 19px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-sub .nav-item { min-height: 34px; font-weight: var(--fw-regular); font-size: var(--fs-14); color: var(--text-muted); }
.nav-sub .nav-item:hover { color: var(--text); }
.nav-sub .nav-item[aria-current="page"] { color: var(--accent-text); font-weight: var(--fw-semibold); }
.nav-sub .nav-item[aria-current="page"]::before { left: -11px; top: 6px; bottom: 6px; }
.nav-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--accent); color: var(--on-accent); font-size: var(--fs-12); font-weight: var(--fw-semibold); display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.nav-soon { color: var(--text-muted); }
.nav-soon .tag { margin-left: auto; }
.side-foot { border-top: 1px solid var(--border); padding: 12px; display: grid; gap: 10px; }
.demo-box { border: 1px dashed var(--border-input); border-radius: var(--r-md); padding: 10px; display: grid; gap: 6px; background: var(--surface-2); }
.demo-box label { font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.demo-box .row { display: flex; gap: 6px; flex-wrap: wrap; }
.demo-box .hint { font-size: var(--fs-12); color: var(--text-muted); }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-8);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.top-search {
  display: flex; align-items: center; gap: 10px; min-width: 280px; height: 36px; padding: 0 12px;
  border: 1px solid var(--border-input); border-radius: var(--r-md); background: var(--surface); color: var(--text-muted);
}
.top-search:hover { background: var(--surface-hover); }
.kbd { font-size: var(--fs-12); border: 1px solid var(--border); border-radius: 5px; padding: 0 6px; margin-left: auto; color: var(--text-muted); background: var(--surface-2); line-height: 20px; }
.top-title { display: none; font-weight: var(--fw-semibold); }
.topbar .menu-btn { display: none; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: var(--r-full); border: 1px solid transparent; background: none; }
.user-btn:hover { background: var(--surface-hover); }
.user-meta { text-align: left; line-height: 1.2; }
.user-meta b { display: block; font-size: var(--fs-14); font-weight: var(--fw-semibold); }
.user-meta span { font-size: var(--fs-12); color: var(--text-muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-12); font-weight: var(--fw-semibold); background: var(--accent-soft); color: var(--accent-text); flex: none; letter-spacing: 0.02em; }
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-lg { width: 44px; height: 44px; font-size: var(--fs-16); }
.pop-wrap { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 6px;
}
.popover[hidden] { display: none; }
.popover .pop-head { padding: 10px 12px 8px; }
.popover .pop-head b { display: block; }
.popover .pop-head span { color: var(--text-muted); font-size: var(--fs-13); }
.popover hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.pop-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 12px; border-radius: var(--r-md); background: none; border: 0; text-align: left; text-decoration: none; color: var(--text); min-height: 38px; }
.pop-item:hover { background: var(--surface-hover); color: var(--text); }
.pop-item[aria-checked="true"] { font-weight: var(--fw-semibold); }
.pop-item[aria-checked="true"]::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.pop-item.danger { color: var(--danger); }
.pop-label { padding: 6px 12px 2px; font-size: var(--fs-12); color: var(--text-subtle); text-transform: uppercase; letter-spacing: 0.06em; font-weight: var(--fw-semibold); }

/* Bottom-Navigation (Smartphone) */
.bottomnav { display: none; }

/* ---------- Seitenkopf ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: var(--fs-13); color: var(--text-muted); margin-bottom: 10px; }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs .icon { width: 14px; height: 14px; color: var(--text-subtle); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3) var(--sp-6); margin-bottom: var(--sp-6); }
.page-head .titles { flex: 1 1 320px; min-width: 0; }
.page-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.page-head .lede { margin-top: 6px; color: var(--text-muted); max-width: 68ch; }
.page-head .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: var(--sp-8) 0 var(--sp-3); }
.section-title h2 { font-size: var(--fs-16); }

/* ---------- Layout-Helfer ---------- */
.stack { display: grid; gap: var(--sp-4); }
.stack-lg { display: grid; gap: var(--sp-6); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.split { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-6); align-items: start; }
.sticky-side { position: sticky; top: calc(var(--header-h) + 20px); }

/* ---------- Karten ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: var(--fs-15); }
.card-body { padding: 20px; }
.card-body.tight { padding: 8px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card.flush > .table-wrap { border: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text);
  font-weight: var(--fw-medium); font-size: var(--fs-14); text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-hover); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { border-color: transparent; background: none; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: var(--fs-13); }
.btn-icon { width: var(--tap); padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-5); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field > label, .field > legend, .label { font-weight: var(--fw-medium); font-size: var(--fs-14); }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 6px; }
.req { color: var(--text-muted); font-weight: var(--fw-regular); font-size: var(--fs-13); }
.hint { font-size: var(--fs-13); color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border-input); border-radius: var(--r-md); color: var(--text);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23788396' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
.select-sm { min-height: 32px; padding: 2px 32px 2px 10px; font-size: var(--fs-13); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; padding: 7px 11px; }
.input[disabled], .select[disabled], .textarea[disabled] { background: var(--surface-2); color: var(--text-muted); }
.error-msg { display: flex; gap: 6px; align-items: flex-start; color: var(--danger); font-size: var(--fs-13); font-weight: var(--fw-medium); }
.error-msg span { white-space: pre-line; }
.error-msg .icon { width: 16px; height: 16px; margin-top: 2px; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .suffix { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-input); border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--surface-2); color: var(--text-muted); }
.counter { text-align: right; font-size: var(--fs-12); color: var(--text-muted); }

.choice { display: flex; align-items: flex-start; gap: 10px; min-height: 28px; cursor: pointer; }
.choice input { appearance: none; margin: 2px 0 0; width: 20px; height: 20px; flex: none; border: 1.5px solid var(--border-input); background: var(--surface); display: grid; place-content: center; cursor: pointer; }
.choice input[type="checkbox"] { border-radius: 5px; }
.choice input[type="radio"] { border-radius: 50%; }
.choice input:checked { background: var(--accent); border-color: var(--accent); }
.choice input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 5px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: rotate(-45deg) translate(1px, -1px); }
.choice input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-accent); }
.choice input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice input[disabled] { opacity: 0.5; cursor: not-allowed; }
.choice .choice-text { padding-top: 1px; }
.choice small { display: block; color: var(--text-muted); font-size: var(--fs-13); }
.choice-row { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); }

.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip-check span { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: var(--r-full); border: 1px solid var(--border-input); background: var(--surface); font-size: var(--fs-14); }
.chip-check input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: var(--fw-medium); }
.chip-check input:checked + span::before { content: ""; width: 10px; height: 5px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translate(1px, -1px); }
.chip-check input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip-check input:hover + span { background: var(--surface-hover); }
.chip-check input:checked:hover + span { background: var(--accent-soft); }

.picker { border: 1px solid var(--border-input); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.picker .picker-search { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.picker-list { max-height: 188px; overflow: auto; padding: 4px; }
.picker-list .choice { padding: 6px 8px; border-radius: var(--r-sm); min-height: 36px; align-items: center; }
.picker-list .choice:hover { background: var(--surface-hover); }
.picker-list .choice input { margin: 0; }
.picker-selected { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-top: 1px solid var(--border); background: var(--surface-2); min-height: 44px; align-items: center; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; margin: 0; width: 38px; height: 22px; border-radius: 11px; background: var(--border-input); position: relative; cursor: pointer; transition: background var(--dur); flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--dur) var(--ease); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); background: var(--on-accent); }
.switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input[disabled] { opacity: 0.5; cursor: not-allowed; }

.form-section { padding: 24px 0; border-top: 1px solid var(--border); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section > h2 { margin-bottom: 4px; }
.form-section > .lede { color: var(--text-muted); margin-bottom: var(--sp-4); font-size: var(--fs-14); }
.conditional { margin-top: var(--sp-3); padding: var(--sp-4); border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--r-md) var(--r-md) 0; display: grid; gap: var(--sp-4); }
.conditional[hidden] { display: none; }
.form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: var(--sp-3); align-items: center; padding: 14px 0; margin-top: var(--sp-4); background: linear-gradient(to top, var(--bg) 70%, transparent); flex-wrap: wrap; }

/* ---------- Badges, Tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 7px; border-radius: var(--r-full); font-size: var(--fs-13); font-weight: var(--fw-medium); white-space: nowrap; background: var(--st-neutral-bg); color: var(--st-neutral-fg); }
.badge .icon { width: 14px; height: 14px; stroke-width: 2; }
.b-info { background: var(--st-info-bg); color: var(--st-info-fg); }
.b-violet { background: var(--st-violet-bg); color: var(--st-violet-fg); }
.b-warn { background: var(--st-warn-bg); color: var(--st-warn-fg); }
.b-ok { background: var(--st-ok-bg); color: var(--st-ok-fg); }
.b-bad { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.b-neutral { background: var(--st-neutral-bg); color: var(--st-neutral-fg); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-12); font-weight: var(--fw-medium); white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; border-radius: var(--r-full); background: var(--accent-soft); color: var(--accent-text); font-size: var(--fs-13); font-weight: var(--fw-medium); }
.chip button { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 0; background: none; color: inherit; padding: 0; }
.chip button:hover { background: color-mix(in srgb, currentColor 16%, transparent); }
.chip.static { padding-right: 10px; }
.prio { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-14); }
.prio i { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.prio i b { width: 3px; background: var(--border-input); border-radius: 1px; }
.prio i b:nth-child(1) { height: 5px; } .prio i b:nth-child(2) { height: 8px; } .prio i b:nth-child(3) { height: 12px; }
.prio-hoch i b { background: var(--text); }
.prio-mittel i b:nth-child(-n+2) { background: var(--text); }
.prio-niedrig i b:nth-child(1) { background: var(--text); }

/* ---------- Segment / Tabs ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); max-width: 100%; overflow-x: auto; }
.seg button, .seg a { min-height: 32px; padding: 0 12px; border-radius: 6px; border: 0; background: none; color: var(--text-muted); font-weight: var(--fw-medium); font-size: var(--fs-14); white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover, .seg a:hover { color: var(--text); }
.seg [aria-pressed="true"], .seg [aria-selected="true"], .seg [aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); font-weight: var(--fw-semibold); }
.seg .count { font-size: var(--fs-12); color: var(--text-subtle); font-variant-numeric: tabular-nums; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--r-md); border: 1px solid transparent; background: var(--st-info-bg); color: var(--st-info-fg); align-items: flex-start; }
.alert .icon { margin-top: 2px; }
.alert b { font-weight: var(--fw-semibold); }
.alert .alert-body { flex: 1; min-width: 0; }
.alert p + p { margin-top: 4px; }
.alert-warn { background: var(--st-warn-bg); color: var(--st-warn-fg); }
.alert-ok { background: var(--st-ok-bg); color: var(--st-ok-fg); }
.alert-bad { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.alert-neutral { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.alert a, .alert .link-btn { color: inherit; font-weight: var(--fw-semibold); }
.alert .quote { margin-top: 6px; font-style: normal; }
.error-summary { border: 2px solid var(--danger); background: var(--surface); color: var(--text); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: var(--sp-6); }
.error-summary h2 { color: var(--danger); font-size: var(--fs-16); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.error-summary ul { display: grid; gap: 4px; padding-left: 26px; list-style: disc; }
.error-summary a { color: var(--danger); font-weight: var(--fw-medium); }

/* ---------- Tabellen (responsiv) ---------- */
.table-wrap { overflow-x: auto; }
.rtable { width: 100%; font-size: var(--fs-14); }
.rtable caption { text-align: left; padding: 0; }
.rtable th, .rtable td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.rtable thead th { position: sticky; top: 0; background: var(--surface-2); font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; border-bottom: 1px solid var(--border); z-index: 1; }
.rtable th.num, .rtable td.num { text-align: right; }
.rtable tbody tr:hover > td { background: var(--surface-hover); }
.rtable tbody tr:last-child > td { border-bottom: 0; }
.rtable tfoot td, .rtable tfoot th { font-weight: var(--fw-semibold); background: var(--surface-2); border-top: 1px solid var(--border-input); border-bottom: 0; text-transform: none; letter-spacing: 0; font-size: var(--fs-14); color: var(--text); position: static; }
.rtable tr.is-selected > td { background: var(--accent-soft); }
.rtable tr.is-selected > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.rtable tr.detail-row > td { background: var(--surface-2); padding: 0; }
.rtable tr.detail-row:hover > td { background: var(--surface-2); }
.rtable tr[hidden], .rtable tr.detail-row[hidden] { display: none !important; }
.rtable .cell-title { font-weight: var(--fw-medium); color: var(--text); text-decoration: none; display: block; }
.rtable a.cell-title:hover { color: var(--accent-text); text-decoration: underline; }
.rtable .cell-sub { display: block; font-size: var(--fs-13); color: var(--text-muted); font-weight: var(--fw-regular); }
.rtable .th-sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; gap: 4px; align-items: center; }
.rtable .th-sort:hover { color: var(--text); }
.rtable .th-sort .icon { width: 12px; height: 12px; }
.rtable .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.expander > span { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.rtable.dense .expander { max-width: 100%; gap: 4px; margin-left: -6px; }
.expander { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; text-align: left; font-weight: var(--fw-medium); }
.expander .icon { transition: transform var(--dur) var(--ease); color: var(--text-muted); }
.expander[aria-expanded="true"] .icon { transform: rotate(90deg); }
.neg { color: var(--danger); font-weight: var(--fw-semibold); }
.mini-table { width: 100%; font-size: var(--fs-13); }
.mini-table th, .mini-table td { padding: 8px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.mini-table th { font-weight: var(--fw-medium); color: var(--text-muted); font-size: var(--fs-12); }
.mini-table tr:last-child td { border-bottom: 0; }
.mini-table .num { text-align: right; }
.detail-inner { padding: 4px 8px 8px 44px; overflow-x: auto; }

/* dichte Tabelle für Zahlenspalten: engere Zellen, erste Spalte bleibt beim Scrollen stehen */
.rtable.dense { font-size: var(--fs-13); }
.rtable.dense th, .rtable.dense td { padding: 10px 4px; }
.rtable.dense thead th { white-space: normal; line-height: 1.25; letter-spacing: 0; text-transform: none; font-size: var(--fs-12); font-weight: var(--fw-semibold); }
.rtable.dense th:first-child, .rtable.dense td:first-child { padding-left: 14px; }
.rtable.dense th:last-child, .rtable.dense td:last-child { padding-right: 14px; }
.rtable.dense td:not(:first-child):not(:last-child) { padding-left: 3px; padding-right: 3px; }
.rtable.dense th:not(:first-child):not(:last-child) { padding-left: 3px; padding-right: 3px; }
.rtable.dense td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 150px; max-width: 196px; }
.rtable.dense .expander .cell-title { font-size: var(--fs-13); }
.rtable.dense thead th:first-child { position: sticky; left: 0; z-index: 2; }
.rtable.dense tbody tr:hover > td:first-child { background: var(--surface-hover); }
.rtable.dense tfoot td:first-child { background: var(--surface-2); }
.rtable.dense tr.detail-row > td:first-child { position: static; min-width: 0; }
.rtable thead tr + tr th { top: 0; }
.rtable thead th.grp { text-align: center; border-bottom: 1px solid var(--border); }
.rtable .meter-sm { min-width: 0; width: 100%; }

/* ---------- Definitionslisten, Verlauf, Stepper ---------- */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-6); margin: 0; }
.dl > div { min-width: 0; }
.dl dt { font-size: var(--fs-13); color: var(--text-muted); margin-bottom: 2px; }
.dl dd { margin: 0; font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.dl .full { grid-column: 1 / -1; }
.dl dd.plain { font-weight: var(--fw-regular); }

.timeline { display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-bottom: var(--sp-5); position: relative; }
.timeline li::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--st-neutral-bg); color: var(--st-neutral-fg); }
.tl-dot .icon { width: 15px; height: 15px; stroke-width: 2; }
.tl-dot.b-ok { background: var(--st-ok-bg); color: var(--st-ok-fg); }
.tl-dot.b-bad { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.tl-dot.b-warn { background: var(--st-warn-bg); color: var(--st-warn-fg); }
.tl-dot.b-info { background: var(--st-info-bg); color: var(--st-info-fg); }
.tl-dot.b-violet { background: var(--st-violet-bg); color: var(--st-violet-fg); }
.tl-body b { font-weight: var(--fw-semibold); }
.tl-meta { font-size: var(--fs-13); color: var(--text-muted); }
.tl-text { margin-top: 4px; padding: 8px 12px; background: var(--surface-2); border-radius: var(--r-md); font-size: var(--fs-14); }
.timeline li.old .tl-body { opacity: 0.75; }
.timeline .old-note { font-size: var(--fs-12); color: var(--text-subtle); }

.stepper { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; }
.stepper li { display: grid; gap: 8px; justify-items: start; align-content: start; position: relative; padding-right: 8px; min-width: 0; }
.stepper li::before { content: ""; position: absolute; top: 15px; left: 34px; right: 4px; height: 2px; background: var(--border); }
.stepper li:last-child::before { display: none; }
.stepper li.done::before { background: var(--st-ok-fg); }
.step-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-input); background: var(--surface); color: var(--text-muted); font-size: var(--fs-13); font-weight: var(--fw-semibold); position: relative; z-index: 1; }
.stepper li.done .step-dot { background: var(--st-ok-bg); border-color: var(--st-ok-fg); color: var(--st-ok-fg); }
.stepper li.current .step-dot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.stepper li.stop .step-dot { background: var(--st-bad-bg); border-color: var(--st-bad-fg); color: var(--st-bad-fg); }
.stepper li.na .step-dot { border-style: dashed; }
.step-dot .icon { width: 16px; height: 16px; stroke-width: 2.2; }
.step-label { font-size: var(--fs-13); font-weight: var(--fw-semibold); line-height: 1.25; }
.step-sub { font-size: var(--fs-12); color: var(--text-muted); font-weight: var(--fw-regular); display: block; }

/* ---------- KPI, Meter ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
.kpi { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.kpi .k-label { font-size: var(--fs-13); color: var(--text-muted); }
.kpi .k-value { font-size: var(--fs-24); font-weight: var(--fw-semibold); letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: var(--fs-13); color: var(--text-muted); margin-top: 2px; }
.kpi.warn { border-color: var(--st-bad-fg); }
.meter { height: 8px; border-radius: 4px; background: var(--bar-track); overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; background: var(--bar-fill); border-radius: 4px; }
.meter.over > i { background: var(--bar-over); }
.meter-sm { height: 6px; margin-top: 6px; min-width: 88px; }
.gauge { display: grid; gap: 10px; }
.gauge .g-big { font-size: var(--fs-30); font-weight: var(--fw-semibold); letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge .g-of { font-size: var(--fs-15); color: var(--text-muted); font-weight: var(--fw-regular); }
.gauge .meter { height: 10px; border-radius: 5px; }
.gauge .meter > i { border-radius: 5px; }

/* ---------- Aufgabenliste, Kacheln ---------- */
.task { display: flex; gap: 14px; align-items: center; padding: 14px 20px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); min-height: 64px; }
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--surface-hover); color: var(--text); }
.task .t-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text); }
.task .t-ico.b-warn { background: var(--st-warn-bg); color: var(--st-warn-fg); }
.task .t-ico.b-bad { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.task .t-ico.b-violet { background: var(--st-violet-bg); color: var(--st-violet-fg); }
.task .t-main { flex: 1; min-width: 0; }
.task .t-main b { display: block; font-weight: var(--fw-semibold); }
.task .t-main span { color: var(--text-muted); font-size: var(--fs-14); }
.task .t-go { color: var(--text-subtle); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-4); }
.tile { display: grid; gap: 10px; align-content: start; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); text-decoration: none; color: var(--text); min-height: 138px; position: relative; }
a.tile:hover { border-color: var(--accent); color: var(--text); box-shadow: var(--shadow-2); }
.tile .tile-ico { width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; }
.tile h3 { font-size: var(--fs-16); }
.tile p { color: var(--text-muted); font-size: var(--fs-14); }
.tile.soon { background: transparent; border-style: dashed; box-shadow: none; }
.tile.soon .tile-ico { background: var(--surface-2); color: var(--text-muted); }
.tile .tag { position: absolute; top: 14px; right: 14px; }

.hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-4) var(--sp-6); margin-bottom: var(--sp-6); }
.hero h1 { font-size: var(--fs-30); }
.hero p { color: var(--text-muted); margin-top: 4px; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); display: grid; gap: 8px; justify-items: center; }
.empty .e-ico { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--text-muted); }
.empty b { color: var(--text); font-size: var(--fs-16); }

/* ---------- Filterleiste ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .field { min-width: 150px; }
.toolbar .field > label { font-size: var(--fs-12); color: var(--text-muted); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.05em; }
.toolbar .spacer { flex: 1; }
.result-line { padding: 10px 16px; font-size: var(--fs-13); color: var(--text-muted); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- Master/Detail (Arbeitsliste) ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--sp-5); align-items: start; }
.workspace .preview { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100vh - var(--header-h) - 32px); overflow: auto; }
.wl-item { display: grid; gap: 4px; padding: 14px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); width: 100%; background: none; border-left: 3px solid transparent; border-top: 0; border-right: 0; text-align: left; }
.wl-item:hover { background: var(--surface-hover); }
.wl-item[aria-current="true"] { background: var(--accent-soft); border-left-color: var(--accent); }
.wl-item:last-child { border-bottom: 0; }
.wl-item .wl-title { font-weight: var(--fw-semibold); }
.wl-item .wl-meta { font-size: var(--fs-13); color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.wl-item .wl-meta span { display: inline-flex; gap: 4px; align-items: center; }

/* ---------- Menü (Zeilenaktionen) ---------- */
.row-menu { position: relative; display: inline-block; }
.row-menu .popover { min-width: 230px; text-align: left; white-space: normal; }
.row-menu .popover.up { top: auto; bottom: calc(100% + 6px); }

/* ---------- Dialog, Toast, Palette ---------- */
dialog { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: var(--overlay); }
dialog[open] { display: flex; flex-direction: column; animation: pop var(--dur) var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.985); } }
.dlg-head { padding: 20px 24px 8px; display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.dlg-body { padding: 8px 24px 20px; overflow: auto; display: grid; gap: var(--sp-4); }
.dlg-foot { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-2); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap; }
dialog.wide { width: min(720px, calc(100vw - 32px)); }
.palette { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; align-self: start; }
.palette-input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; min-height: 52px; font-size: var(--fs-16); padding: 0 20px; width: 100%; background: transparent; }
.palette-list { max-height: 50vh; overflow: auto; padding: 8px; }
.palette-group { padding: 8px 12px 4px; font-size: var(--fs-12); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); font-weight: var(--fw-semibold); }
.palette-item { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-radius: var(--r-md); min-height: 44px; cursor: pointer; }
.palette-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); }
.palette-item .icon { color: var(--text-muted); }
.palette-item[aria-selected="true"] .icon { color: var(--accent-text); }
.palette-item small { margin-left: auto; color: var(--text-muted); }

#toasts { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: center; padding: 12px 14px 12px 16px; border-radius: var(--r-md); background: var(--text); color: var(--bg); box-shadow: var(--shadow-3); animation: pop var(--dur) var(--ease); }
.toast .icon { flex: none; }
.toast .t-text { flex: 1; }
.toast button { background: none; border: 1px solid color-mix(in srgb, var(--bg) 50%, transparent); color: var(--bg); border-radius: var(--r-sm); padding: 4px 10px; font-weight: var(--fw-medium); min-height: 32px; }
.toast button:hover { background: color-mix(in srgb, var(--bg) 16%, transparent); }
.scrim { display: none; }

/* ---------- Anmeldung ---------- */
.auth { display: none; min-height: 100vh; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-mode .auth { display: grid; }
.auth-form-side { display: grid; align-content: center; justify-items: center; padding: var(--sp-8); }
.auth-form { width: min(400px, 100%); display: grid; gap: var(--sp-5); }
.auth-side { background: linear-gradient(160deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 55%, #000) 100%); color: var(--on-accent); display: grid; align-content: center; padding: var(--sp-12); gap: var(--sp-6); }
html[data-theme="dark"] .auth-side { background: linear-gradient(160deg, #1e2740 0%, #0e1116 100%); color: var(--text); }
.auth-side h2 { font-size: var(--fs-30); max-width: 18ch; letter-spacing: -0.02em; }
.auth-side ul { display: grid; gap: 14px; max-width: 42ch; }
.auth-side li { display: flex; gap: 12px; align-items: flex-start; }
.auth-side .icon { margin-top: 3px; }
.demo-login { display: grid; gap: 8px; }

/* ---------- Unternavigation (Stammdaten) ---------- */
.subnav-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
.subnav { display: grid; gap: 2px; position: sticky; top: calc(var(--header-h) + 20px); }
.subnav a { display: block; padding: 8px 12px; border-radius: var(--r-md); color: var(--text-muted); text-decoration: none; font-weight: var(--fw-medium); font-size: var(--fs-14); }
.subnav a:hover { background: var(--surface-hover); color: var(--text); }
.subnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: var(--fw-semibold); }
.subnav-select { display: none; margin-bottom: var(--sp-4); }
.dl-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Diverses ---------- */
.kv-inline { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: var(--fs-14); color: var(--text-muted); }
.kv-inline > span + span::before { content: "·"; margin-right: 8px; color: var(--text-subtle); }
.kv-inline b { color: var(--text); font-weight: var(--fw-medium); }
.divider { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
.role-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.people-list { display: grid; gap: 8px; }
.people-list li { display: flex; gap: 10px; align-items: center; }
.hours-input { width: 88px; text-align: right; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs-13); color: var(--text-muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--bar-fill); }
.sync-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.sync-row:last-child { border-bottom: 0; }
.sync-row .grow { flex: 1; min-width: 0; }

/* ================= Responsiv ================= */
@media (max-width: 1279px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-main-side { grid-template-columns: minmax(0, 1fr); }
  .sticky-side { position: static; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace .preview { display: none; }
}

@media (max-width: 1023px) {
  .subnav-layout { grid-template-columns: minmax(0, 1fr); }
  .subnav { display: none; }
  .subnav-select { display: grid; }
  .dl-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 90; width: min(320px, 88vw);
    transform: translateX(-102%); transition: transform 200ms var(--ease); box-shadow: var(--shadow-3);
    visibility: hidden;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 80; }
  body.nav-open { overflow: hidden; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 0 var(--sp-4); }
  .top-search { min-width: 0; width: 36px; padding: 0; justify-content: center; }
  .top-search .top-search-label, .top-search .kbd { display: none; }
  .user-meta { display: none; }
  .page { padding: var(--sp-6) var(--sp-5) var(--sp-12); }
}

@media (max-width: 719px) {
  :root { --tap: 44px; --header-h: 52px; }
  h1 { font-size: 1.375rem; }
  .hero h1 { font-size: var(--fs-24); }
  .page { padding: var(--sp-5) var(--sp-4) calc(var(--sp-12) + 72px); }
  .top-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .cols-2, .cols-3, .form-grid, .dl { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .kpi { padding: 12px 14px; }
  .kpi .k-value { font-size: var(--fs-20); }
  .card-body { padding: 16px; }
  .card-head { padding: 12px 16px; }
  .toolbar { padding: 12px; }
  .toolbar .field { min-width: calc(50% - 8px); flex: 1; }
  .toolbar .field.wide { min-width: 100%; }
  input.input, select.select, textarea.textarea { font-size: 1rem; }
  .form-actions { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .stepper { grid-auto-flow: row; gap: 14px; }
  .stepper li { grid-template-columns: 30px minmax(0, 1fr); align-items: start; gap: 12px; padding-right: 0; }
  .stepper li::before { top: 32px; bottom: -14px; left: 14px; right: auto; width: 2px; height: auto; }
  .detail-inner { padding-left: 8px; }
  .dlg-head, .dlg-body { padding-left: 16px; padding-right: 16px; }
  .dlg-foot { padding: 12px 16px; }
  .dlg-foot .btn { flex: 1; }
  dialog { margin-bottom: 0; width: 100vw; max-width: 100vw; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
  dialog[open] { margin-top: auto; }
  .palette { margin-top: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); align-self: start; max-height: 80vh; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  #toasts { bottom: 84px; }

  .bottomnav {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a, .bottomnav button { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; min-height: 52px; color: var(--text-muted); text-decoration: none; background: none; border: 0; font-size: var(--fs-12); font-weight: var(--fw-medium); border-radius: var(--r-md); position: relative; }
  .bottomnav [aria-current="page"] { color: var(--accent-text); font-weight: var(--fw-semibold); }
  .bottomnav [aria-current="page"] .icon { stroke-width: 2.25; }
  .bottomnav .bn-plus { color: var(--on-accent); }
  .bottomnav .bn-plus span.bn-disc { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; margin-top: -18px; box-shadow: var(--shadow-2); }
  .bottomnav .bn-plus > span:last-child { color: var(--text-muted); }
  .bn-badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; display: grid; place-items: center; font-weight: var(--fw-semibold); }

  /* Tabellen werden zu Karten: jede Zeile ein Block, Spaltenname als Beschriftung */
  .table-wrap { overflow: visible; }
  .rtable, .rtable tbody, .rtable tfoot, .rtable tr, .rtable td { display: block; }
  .rtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .rtable tbody tr, .rtable tfoot tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .rtable tr.detail-row { display: block; padding: 0; }
  .rtable.dense td:first-child { position: static; min-width: 0; }
  .rtable.dense th, .rtable.dense td { padding: 0; }
  .rtable tbody tr:last-child { border-bottom: 0; }
  .rtable td { padding: 0; border: 0; min-width: 0; text-align: left; }
  .rtable td.num { text-align: left; white-space: normal; }
  .rtable tbody tr:hover > td { background: none; }
  .rtable td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-12); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: var(--fw-semibold); margin-bottom: 1px; }
  .rtable td.m-full, .rtable td.m-title { grid-column: 1 / -1; }
  .rtable td.m-title::before, .rtable td.m-nolabel::before { display: none; }
  .rtable td.m-title { font-size: var(--fs-16); }
  .rtable td.m-hide { display: none; }
  .rtable td.col-actions { grid-column: 1 / -1; text-align: left; width: auto; }
  .rtable td.col-actions::before { display: none; }
  .rtable tfoot tr { background: var(--surface-2); border-top: 1px solid var(--border-input); }
  .rtable tfoot td { background: none; border: 0; }
  .rtable tr.is-selected > td:first-child { box-shadow: none; }
  .rtable tr.is-selected { background: var(--accent-soft); }
  .detail-inner .mini-table, .detail-inner .mini-table tbody { display: block; }
  .detail-inner .mini-table thead { display: none; }
  .detail-inner .mini-table tr { display: flex; flex-wrap: wrap; gap: 2px 12px; padding: 10px 8px; border-bottom: 1px solid var(--border); }
  .detail-inner .mini-table td { padding: 0; border: 0; }
  .detail-inner .mini-table td:first-child { flex: 1 1 100%; font-weight: var(--fw-medium); }
  .mini-table .num { text-align: left; }
  .task { padding: 12px 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .tile { padding: 14px; min-height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .badge, .chip, .tag { border: 1px solid CanvasText; }
  .meter > i { background: Highlight; }
}
