/*
 * dpcenter-Designsystem (ADR-0011, Doku: docs/architektur/designsystem.md).
 * Ruhig und dicht wie ein Issue-Tracker: neutrale Flächen, ein Akzentblau, Farbe nur für Bedeutung.
 * Keine Inline-Styles (CSP style-src 'self'): Varianten immer als Klasse, nie über style="".
 *
 * Aufbau: 1 Tokens · 2 Grundlagen · 3 App-Rahmen · 4 Seitenleiste · 5 Kopfzeile · 6 Inhalt · 7 Formulare
 *         8 Buttons · 9 Rückmeldungen · 10 Tabellen · 11 Fachbausteine · 12 Hilfsklassen
 */

/* --- 1 Tokens ------------------------------------------------------------------------------------------ */
:root {
    color-scheme: light dark;

    --color-bg: #f6f7f9;
    --color-surface: #ffffff;
    --color-sunken: #eef0f3;
    --color-hover: #e9ebee;
    --color-text: #1c2b41;
    --color-text-subtle: #44546f;
    --color-muted: #5b6880;
    --color-border: #dcdfe4;
    --color-border-strong: #8590a2;
    --color-button: #eceef1;
    --color-button-hover: #dfe2e7;

    --color-accent: #1d5fc9;
    --color-accent-hover: #164ea8;
    --color-accent-subtle: #e8f0fd;
    --color-on-accent: #ffffff;

    --color-danger: #b8322a;
    --color-danger-subtle: #fdecea;
    --color-warning: #8a4b00;
    --color-warning-subtle: #fff4d6;
    --color-success: #1f6b4a;
    --color-success-subtle: #dff7ea;

    /* Objekttypen – dezente Marker, Farbfamilien wie im Open-Datenschutzcenter */
    --type-processing: #0f9f6e;
    --type-dpia: #2f9e44;
    --type-measures: #0b8ec9;
    --type-contacts: #8a4fd8;
    --type-transfers: #7048e8;
    --type-processors: #c2389a;
    --type-documents: #d08700;
    --type-policies: #6b7280;
    --type-software: #2b6ee6;
    --type-tasks: #0c94a8;
    --type-retention: #e0661b;
    --type-masterdata: #6a9a12;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-md: 0.875rem;
    --text-lg: 1.125rem;
    --text-xl: 1.5rem;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space: var(--space-4);

    --radius-sm: 3px;
    --radius: 6px;
    --radius-lg: 8px;
    --shadow-raised: 0 1px 1px rgb(9 30 66 / 0.12), 0 0 1px rgb(9 30 66 / 0.2);
    --shadow-overlay: 0 8px 12px rgb(9 30 66 / 0.15), 0 0 1px rgb(9 30 66 / 0.31);
    --focus-ring: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);

    --sidebar-width: 16.5rem;
    --topbar-height: 3.25rem;
    --content-width: 72rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #1b1f24;
        --color-surface: #22272d;
        --color-sunken: #171a1e;
        --color-hover: #2c333a;
        --color-text: #dfe5ec;
        --color-text-subtle: #b5c0cc;
        --color-muted: #9ba8b6;
        --color-border: #39424c;
        --color-border-strong: #7d8998;
        --color-button: #303840;
        --color-button-hover: #3b444e;

        --color-accent: #6ea8ff;
        --color-accent-hover: #93bfff;
        --color-accent-subtle: #1e2e47;
        --color-on-accent: #10161e;

        --color-danger: #ff8a80;
        --color-danger-subtle: #45231f;
        --color-warning: #f5c95c;
        --color-warning-subtle: #45360c;
        --color-success: #63d4a2;
        --color-success-subtle: #173f2e;

        --shadow-raised: 0 1px 1px rgb(0 0 0 / 0.4), 0 0 1px rgb(0 0 0 / 0.5);
        --shadow-overlay: 0 8px 16px rgb(0 0 0 / 0.45), 0 0 1px rgb(255 255 255 / 0.15);
    }
}

/* --- 2 Grundlagen -------------------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-family: var(--font-sans);
    font-size: 100%;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: var(--text-md);
    line-height: 1.5;
    background: var(--color-bg);
}

h1,
h2,
h3 {
    line-height: 1.25;
    margin: 0 0 var(--space-3);
    color: var(--color-text);
}

h1 {
    font-size: var(--text-xl);
    font-weight: 600;
}

h2 {
    font-size: var(--text-lg);
    font-weight: 600;
}

h3 {
    font-size: var(--text-md);
    font-weight: 600;
    margin-top: var(--space-4);
}

p {
    margin: 0 0 var(--space-3);
}

a {
    color: var(--color-accent);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--color-accent-hover);
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

code,
kbd {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

svg.icon {
    width: 1.125rem;
    height: 1.125rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

/* --- 3 App-Rahmen -------------------------------------------------------------------------------------- */
.skip-link {
    position: absolute;
    left: var(--space-2);
    top: var(--space-2);
    z-index: 100;
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius);
}

.skip-link:not(:focus) {
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
    padding: 0;
}

.skip-link:focus {
    box-shadow: var(--shadow-overlay), var(--focus-ring);
}

/* Mit Seitenleiste: zwei Spalten, Leiste über die ganze Höhe */
body:has(> .app-sidebar) {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
}

body:has(> .app-sidebar) > :not(.app-sidebar) {
    grid-column: 2;
}

.app-main {
    flex: 1;
    width: min(var(--content-width), 100% - 2 * var(--space-5));
    margin: 0 auto;
    padding: var(--space-5) 0 var(--space-6);
}

.app-main.narrow {
    width: min(26rem, 100% - 2 * var(--space-4));
    padding-top: var(--space-6);
}

.app-footer {
    padding: var(--space-4) var(--space-5);
    color: var(--color-muted);
    font-size: var(--text-xs);
    text-align: center;
}

.app-footer a {
    color: inherit;
}

/* --- 4 Seitenleiste (#72) ------------------------------------------------------------------------------ */
.app-sidebar {
    grid-row: 1 / -1;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-2) var(--space-4);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    font-weight: 650;
    font-size: var(--text-md);
    color: var(--color-text);
    text-decoration: none;
}

.brand:hover {
    color: var(--color-text);
}

.brand svg.icon {
    width: 1.75rem;
    height: 1.75rem;
    color: var(--color-accent);
}

.context-switcher {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: 0 var(--space-2);
}

.context-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-muted);
}

.context-switcher .row {
    flex-wrap: nowrap;
    gap: var(--space-1);
}

.context-switcher select {
    flex: 1;
    min-width: 0;
}

.context-current {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--color-sunken);
    border-radius: var(--radius);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.system-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    align-self: flex-start;
    padding: 0.125rem var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--color-accent-subtle);
    color: var(--color-accent);
    font-size: var(--text-xs);
    font-weight: 600;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.nav-section {
    margin: 0;
    padding: var(--space-2) var(--space-2) var(--space-1);
    font-size: var(--text-xs);
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-muted);
}

.side-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 2rem;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
    color: var(--color-text-subtle);
    text-decoration: none;
    position: relative;
}

a.nav-item:hover {
    background: var(--color-hover);
    color: var(--color-text);
}

a.nav-item[aria-current="page"] {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
    font-weight: 600;
}

a.nav-item[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: -0.5rem;
    top: 0.375rem;
    bottom: 0.375rem;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--color-accent);
}

.nav-item.planned {
    color: var(--color-muted);
    cursor: default;
}

.nav-label {
    flex: 1;
    min-width: 0;
}

.step-number {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 1.375rem;
    height: 1.375rem;
    border-radius: 50%;
    border: 1.5px solid var(--color-border-strong);
    color: var(--color-text-subtle);
    font-size: var(--text-xs);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.step-number.done {
    border-color: var(--color-success);
    background: var(--color-success);
    color: var(--color-surface);
}

.step-number.done svg.icon {
    width: 0.875rem;
    height: 0.875rem;
    stroke-width: 3;
}

[aria-current="page"] .step-number:not(.done) {
    border-color: var(--color-accent);
}

.nav-meta {
    flex: none;
    font-size: var(--text-xs);
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}

.nav-meta.open {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--color-warning);
}

.nav-meta.planned {
    font-size: 0.6875rem;
    font-style: italic;
}

/* --- 5 Kopfzeile --------------------------------------------------------------------------------------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--topbar-height);
    padding: var(--space-2) var(--space-5);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.app-topbar .spacer {
    flex: 1;
}

.nav-toggle {
    display: none;
}

.user-menu {
    position: relative;
}

.user-menu > summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
    cursor: pointer;
    list-style: none;
    color: var(--color-text-subtle);
}

.user-menu > summary::-webkit-details-marker {
    display: none;
}

.user-menu > summary:hover,
.user-menu[open] > summary {
    background: var(--color-hover);
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-on-accent);
    font-size: var(--text-xs);
    font-weight: 700;
}

.menu {
    position: absolute;
    right: 0;
    top: calc(100% + var(--space-1));
    z-index: 30;
    min-width: 13rem;
    padding: var(--space-1) 0;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-overlay);
}

.menu-header {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-1);
}

.menu-header strong {
    display: block;
}

.menu a,
.menu button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 0;
    font-weight: 400;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--color-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu a:hover,
.menu button:hover {
    background: var(--color-hover);
    color: var(--color-text);
}

.menu form {
    margin: 0;
}

/* Ohne Anmeldung (Login, Passwort vergessen): nur Marke, mittig */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
}

.app-header.centered {
    justify-content: center;
    padding-top: var(--space-6);
}

/* --- 6 Inhalt ------------------------------------------------------------------------------------------ */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
    color: var(--color-muted);
    font-size: var(--text-sm);
}

.breadcrumb a {
    color: var(--color-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

.title-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.title-row h1 {
    margin: 0;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
}

.card > :last-child {
    margin-bottom: 0;
}

.card > h2:first-child {
    font-size: var(--text-md);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.card-grid .card {
    margin: 0;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.stat-value {
    font-size: var(--text-xl);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    color: var(--color-muted);
    font-size: var(--text-sm);
}

.empty-state {
    padding: var(--space-6) var(--space-4);
    text-align: center;
    color: var(--color-muted);
}

.empty-state svg.icon {
    width: 2.5rem;
    height: 2.5rem;
    margin-bottom: var(--space-2);
}

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-5);
    margin: 0 0 var(--space-4);
}

.facts dt {
    color: var(--color-muted);
}

.facts dd {
    margin: 0;
}

/* KI-Vorschlag (#84): als Rohtext, deutlich vom gespeicherten Inhalt getrennt */
.proposal {
    max-height: 28rem;
    overflow: auto;
    padding: var(--space-3);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-sunken);
    white-space: pre-wrap;
    font-size: var(--text-sm);
}

/* Versionsvergleich (#74): Zeichen +/− plus Farbe */
.diff {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.diff-line {
    display: flex;
    gap: var(--space-2);
    padding: 0 var(--space-2);
    white-space: pre-wrap;
    min-height: 1.4em;
}

.diff-line.added {
    background: var(--color-success-subtle);
}

.diff-line.removed {
    background: var(--color-danger-subtle);
    text-decoration: line-through;
}

.diff-sign {
    flex: none;
    width: 1ch;
    font-weight: 600;
}

/* Inhalt gelenkter Dokumente (Markdown, #74): Lesetypografie mit begrenzter Zeilenlänge */
.document-content {
    max-width: 48rem;
    line-height: 1.6;
}

.document-content h1,
.document-content h2,
.document-content h3 {
    margin: var(--space-5) 0 var(--space-2);
}

.document-content table {
    border-collapse: collapse;
    margin: var(--space-3) 0;
}

.document-content th,
.document-content td {
    border: 1px solid var(--color-border);
    padding: var(--space-1) var(--space-2);
    text-align: left;
}

.document-content blockquote {
    margin: var(--space-3) 0;
    padding-left: var(--space-3);
    border-left: 3px solid var(--color-border-strong);
    color: var(--color-text-subtle);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.row .grow {
    flex: 1;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

.actions form,
.inline-form {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
}

.danger-zone {
    border-color: color-mix(in srgb, var(--color-danger) 45%, var(--color-border));
}

/* --- 7 Formulare --------------------------------------------------------------------------------------- */
label {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-weight: 600;
    color: var(--color-text-subtle);
    font-size: var(--text-sm);
}

label.inline {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    font-weight: 400;
    color: var(--color-text);
    font-size: var(--text-md);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
select,
textarea {
    font: inherit;
    font-size: var(--text-md);
    font-weight: 400;
    min-height: 2.25rem;
    padding: 0.375rem var(--space-2);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    max-width: 100%;
}

textarea {
    min-height: 5rem;
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    background: var(--color-sunken);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 1px var(--color-accent);
    background: var(--color-surface);
    border-radius: var(--radius);
}

input[aria-invalid="true"] {
    border-color: var(--color-danger);
}

input[type="checkbox"],
input[type="radio"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--color-accent);
}

fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    margin: 0;
}

legend {
    padding: 0 var(--space-1);
    font-weight: 600;
}

.hint {
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--color-muted);
    margin: 0;
}

/* --- 8 Buttons ----------------------------------------------------------------------------------------- */
button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    min-height: 2.25rem;
    padding: 0.375rem var(--space-3);
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--color-button);
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-md);
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

button:hover,
.button:hover {
    background: var(--color-button-hover);
    color: var(--color-text);
}

button.primary,
.button.primary {
    background: var(--color-accent);
    color: var(--color-on-accent);
}

button.primary:hover,
.button.primary:hover {
    background: var(--color-accent-hover);
    color: var(--color-on-accent);
}

button.danger,
.button.danger {
    background: var(--color-danger);
    color: var(--color-surface);
}

button.danger:hover,
.button.danger:hover {
    background: color-mix(in srgb, var(--color-danger) 85%, var(--color-text));
    color: var(--color-surface);
}

button.subtle,
.button.subtle {
    background: none;
    color: var(--color-text-subtle);
}

button.subtle:hover,
.button.subtle:hover {
    background: var(--color-hover);
}

button.link {
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-accent);
    font-weight: 400;
    text-decoration: underline;
}

button.small,
.button.small {
    min-height: 1.75rem;
    padding: 0.125rem var(--space-2);
    font-size: var(--text-sm);
}

button.icon-only {
    padding: 0.375rem;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- 9 Rückmeldungen ----------------------------------------------------------------------------------- */
.alert {
    display: block;
    padding: var(--space-3) var(--space-4);
    margin: 0 0 var(--space-4);
    border-radius: var(--radius);
    border-left: 4px solid var(--color-accent);
    background: var(--color-accent-subtle);
    color: var(--color-text);
}

.alert ul {
    margin: 0;
    padding-left: var(--space-5);
}

.alert-error {
    border-left-color: var(--color-danger);
    background: var(--color-danger-subtle);
}

.alert-warning {
    border-left-color: var(--color-warning);
    background: var(--color-warning-subtle);
}

.alert-success {
    border-left-color: var(--color-success);
    background: var(--color-success-subtle);
}

/* Lozenges: kurze Statusangaben in Tabellen und Titeln */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0 0.375rem;
    border-radius: var(--radius-sm);
    background: var(--color-sunken);
    color: var(--color-text-subtle);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    vertical-align: middle;
}

.badge.info {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
}

.badge.success {
    background: var(--color-success-subtle);
    color: var(--color-success);
}

.badge.warn {
    background: var(--color-warning-subtle);
    color: var(--color-warning);
}

.badge.danger {
    background: var(--color-danger-subtle);
    color: var(--color-danger);
}

/* --- 10 Tabellen --------------------------------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
}

@supports (display: table) {
    .card > table,
    table.full {
        display: table;
    }
}

th,
td {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

th {
    font-size: var(--text-xs);
    font-weight: 650;
    color: var(--color-muted);
    border-bottom-width: 2px;
}

tbody tr:hover {
    background: color-mix(in srgb, var(--color-hover) 60%, transparent);
}

td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* --- 11 Fachbausteine ---------------------------------------------------------------------------------- */
.type-marker {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--color-border-strong);
    vertical-align: -0.0625rem;
}

.type-marker.processing { background: var(--type-processing); }
.type-marker.dpia { background: var(--type-dpia); }
.type-marker.measures { background: var(--type-measures); }
.type-marker.contacts { background: var(--type-contacts); }
.type-marker.transfers { background: var(--type-transfers); }
.type-marker.processors { background: var(--type-processors); }
.type-marker.documents { background: var(--type-documents); }
.type-marker.policies { background: var(--type-policies); }
.type-marker.software { background: var(--type-software); }
.type-marker.tasks { background: var(--type-tasks); }
.type-marker.retention { background: var(--type-retention); }
.type-marker.masterdata { background: var(--type-masterdata); }

.progress {
    display: block;
    width: 100%;
    height: 0.375rem;
    border: 0;
    border-radius: 999px;
    background: var(--color-sunken);
    appearance: none;
    overflow: hidden;
}

.progress::-webkit-progress-bar {
    background: var(--color-sunken);
}

.progress::-webkit-progress-value {
    background: var(--color-success);
}

.progress::-moz-progress-bar {
    background: var(--color-success);
}

ul.tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.tree li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

ul.tree li:last-child {
    border-bottom: 0;
}

ul.tree li.depth-1 { padding-left: 2.25rem; }
ul.tree li.depth-2 { padding-left: 3.75rem; }
ul.tree li.depth-3 { padding-left: 5.25rem; }
ul.tree li.depth-4 { padding-left: 6.75rem; }
ul.tree li.depth-5 { padding-left: 8.25rem; }
ul.tree li.depth-6 { padding-left: 9.75rem; }

form.roles {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    align-items: center;
    margin: 0;
}

code.secret {
    display: inline-block;
    font-size: 1rem;
    padding: var(--space-1) var(--space-2);
    background: var(--color-sunken);
    border-radius: var(--radius);
    word-break: break-all;
    user-select: all;
}

img.qr {
    background: #fff;
    border-radius: var(--radius);
    padding: var(--space-2);
    max-width: 100%;
    height: auto;
}

ol.codes {
    columns: 2;
    font-family: var(--font-mono);
    font-size: 1rem;
}

.swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--space-2);
}

.swatch {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: var(--text-xs);
}

.swatch::before {
    content: "";
    height: 2.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.swatch.bg::before { background: var(--color-bg); }
.swatch.surface::before { background: var(--color-surface); }
.swatch.sunken::before { background: var(--color-sunken); }
.swatch.text::before { background: var(--color-text); }
.swatch.text-subtle::before { background: var(--color-text-subtle); }
.swatch.muted::before { background: var(--color-muted); }
.swatch.border::before { background: var(--color-border); }
.swatch.accent::before { background: var(--color-accent); }
.swatch.accent-subtle::before { background: var(--color-accent-subtle); }
.swatch.danger::before { background: var(--color-danger); }
.swatch.warning::before { background: var(--color-warning); }
.swatch.success::before { background: var(--color-success); }

/* --- 12 Hilfsklassen ----------------------------------------------------------------------------------- */
.muted {
    color: var(--color-muted);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- Schmale Bildschirme: Seitenleiste als ausklappbare Ebene ------------------------------------------ */
@media (max-width: 899px) {
    body:has(> .app-sidebar) {
        display: flex;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 50;
        width: min(var(--sidebar-width) + 2rem, 85vw);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: none;
    }

    body.nav-open .app-sidebar {
        transform: none;
        box-shadow: var(--shadow-overlay);
    }

    body.nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgb(9 30 66 / 0.4);
    }

    .nav-toggle {
        display: inline-flex;
    }

    .app-topbar {
        padding: var(--space-2) var(--space-3);
    }

    .app-main {
        width: calc(100% - 2 * var(--space-4));
        padding-top: var(--space-4);
    }

    .user-name {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar {
        transition: none;
    }
}
