/* ============================================================================
   BusinessHub Komponenten
   Alle Klassen nutzen ausschließlich semantische Tokens (tokens.css).
   Legacy-Namen (btn, card, badge, form-control, table-responsive, alert, tabs,
   stat-card, empty-state, kanban-modal-*) bleiben erhalten und werden hier neu
   gestylt, damit noch nicht migrierte Seiten weiter funktionieren.
   ============================================================================ */

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    min-height: 40px; padding: 0 var(--sp-4);
    border-radius: var(--r-sm); border: 1px solid transparent;
    font-size: var(--fs-base); font-weight: 500; line-height: 1.2; white-space: nowrap;
    background: var(--color-surface-2); color: var(--color-text);
    cursor: pointer; text-decoration: none; user-select: none;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; background: var(--color-surface-3); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 1.15em; height: 1.15em; }

.btn-primary { background: var(--color-primary); color: var(--color-primary-fg); }
.btn-primary:hover { background: var(--color-primary-hover); color: var(--color-primary-fg); }
.btn-accent { background: var(--color-accent); color: var(--color-accent-fg); }
.btn-accent:hover { background: #12c3c5; color: var(--color-accent-fg); }
.btn-secondary, .btn-light { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover, .btn-light:hover { background: var(--color-surface-2); }
.btn-outline { background: transparent; border-color: var(--color-border-strong); color: var(--color-text); }
.btn-outline:hover { background: var(--color-surface-2); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); }
.btn-danger { background: var(--color-danger-solid); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--color-danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--color-danger-bg); color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-solid-hover); color: #fff; }
.btn-success { background: var(--color-success-solid); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: transparent; }
.btn-warning:hover { background: #fde68a; color: #854d0e; }
.btn-info { background: var(--color-info-bg); color: var(--color-info); }
.btn-info:hover { background: #bfdbfe; }
.btn-outline-danger { background: transparent; border-color: var(--color-danger); color: var(--color-danger); }
.btn-outline-danger:hover { background: var(--color-danger-bg); }
.btn-outline-success { background: transparent; border-color: var(--color-success); color: var(--color-success); }
.btn-outline-success:hover { background: var(--color-success-bg); }
.btn-outline-secondary { background: transparent; border-color: var(--color-border-strong); color: var(--color-text-muted); }
.btn-outline-secondary:hover { background: var(--color-surface-2); }
.btn-link { background: none; color: var(--color-link); padding: 0; min-height: 0; }
.btn-link:hover { text-decoration: underline; background: none; }

.btn-sm { min-height: 34px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-lg { min-height: 48px; padding: 0 var(--sp-6); font-size: var(--fs-md); }
.btn-icon { padding: 0; width: 40px; min-width: 40px; }
.btn-icon.btn-sm { width: 34px; min-width: 34px; }
.btn-block { width: 100%; }
.btn-disabled { pointer-events: none; opacity: 0.55; }
.btn-remove { background: var(--color-surface-2); color: var(--color-danger); border: 0; border-radius: var(--r-sm); min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-remove:hover { background: var(--color-danger-bg); }

.btn-group { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.btn-group form { display: contents; }
.btn-group form[style*="inline"] { display: contents !important; }

@media (max-width: 768px) {
    .btn { min-height: var(--touch); font-size: var(--fs-md); }
    .btn-sm { min-height: 40px; font-size: var(--fs-base); }
    .btn-icon { width: var(--touch); min-width: var(--touch); }
    .btn-icon.btn-sm { width: 40px; min-width: 40px; }
}

/* --------------------------------------------------------------- Badges */
.badge {
    display: inline-flex; align-items: center; gap: 0.35em;
    padding: 0.2em 0.65em; border-radius: var(--r-full);
    font-size: var(--fs-xs); font-weight: 600; line-height: 1.4; white-space: nowrap;
    background: var(--color-surface-2); color: var(--color-text-muted);
}
.badge .icon { width: 1em; height: 1em; }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info); }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-accent  { background: var(--color-accent-soft); color: var(--color-accent-text); }
.badge-secondary, .badge-dark { background: var(--color-surface-2); color: var(--color-text-muted); }
.badge-solid   { background: var(--color-primary); color: var(--color-primary-fg); }
.badge-dot::before { content: ''; width: 0.5em; height: 0.5em; border-radius: 50%; background: currentColor; }
.badge-lg { font-size: var(--fs-sm); padding: 0.3em 0.8em; }

/* ---------------------------------------------------------------- Cards */
.card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--r); box-shadow: var(--shadow-xs); overflow: hidden;
}
.card + .card, .card + .stats-grid, .stats-grid + .card { margin-top: var(--sp-4); }
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
    padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--color-border);
}
.card-title { font-size: var(--fs-md); font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); margin: 0; }
.card-title .icon { color: var(--color-accent-text); }
.card-body { padding: var(--sp-4); }
.card-footer { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--color-border); display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: flex-end; }
.card-body > .card-body { padding: 0; }
.card-subtitle { flex: 1 0 100%; margin: 0; font-size: var(--fs-sm); color: var(--color-text-muted); }
.card-header-inner { border-top: 1px solid var(--color-border); }
.card-footer.card-footer-start { justify-content: flex-start; }
.form-row-cards { align-items: start; }
.form-row-cards > .card { margin: 0; }
.inline-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
/* Einzeilige Info + Aktionen (z.B. PDF-Zeile) */
.pdf-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.pdf-row-text { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.pdf-row-text > .icon { color: var(--color-accent-text); flex-shrink: 0; width: 1.25rem; height: 1.25rem; }
.pdf-row-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
@media (max-width: 600px) { .pdf-row-actions { width: 100%; } .pdf-row-actions .btn, .pdf-row-actions form { flex: 1; } .pdf-row-actions form .btn { width: 100%; } }
.card.is-flush .card-body { padding: 0; }
.card-accent { border-left: 4px solid var(--color-accent); }
.card-info    { border-left: 4px solid var(--color-info);    background: var(--color-surface); }
.card-warning { border-left: 4px solid var(--color-warning); }
.card-danger  { border-left: 4px solid var(--color-danger); }
.card-success { border-left: 4px solid var(--color-success); }
@media (min-width: 769px) { .card-body { padding: var(--sp-5); } .card-header { padding: var(--sp-4) var(--sp-5); } }

/* Aufklappbare Karten-Sektion (Details/Summary) */
.card details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); }
.card details > summary::-webkit-details-marker { display: none; }

/* ------------------------------------------------------------- Seitenkopf */
.page-header {
    display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
    gap: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4);
}
.page-header > div:first-child, .page-header-main { flex: 1 1 260px; min-width: 0; }
.page-header-actions, .page-header > .btn-group, .page-header > div:not(:first-child) {
    display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; flex: 0 1 auto;
}
.page-title {
    font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; color: var(--color-text);
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-1);
}
.page-title .badge { font-size: var(--fs-xs); }
.page-subtitle { color: var(--color-text-muted); font-size: var(--fs-sm); margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35em var(--sp-2); }
.page-back { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--color-text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.page-back:hover { color: var(--color-text); text-decoration: none; }
@media (min-width: 769px) { .page-title { font-size: var(--fs-2xl); } .page-header { margin-bottom: var(--sp-6); } }
@media (max-width: 768px) {
    /* Aktionen unter dem Titel, volle Breite, nie neben dem Titel */
    .page-header-actions, .page-header > .btn-group, .page-header > div:not(:first-child) { flex: 1 0 100%; }
    .page-header-actions > .btn, .page-header > div:not(:first-child) > .btn,
    .page-header-actions form, .page-header > div:not(:first-child) form { flex: 1 1 auto; }
    .page-header-actions > .btn-primary, .page-header > div:not(:first-child) > .btn-primary { flex-basis: 100%; }
    .page-header-actions > .menu, .page-header > div:not(:first-child) > .menu { flex: 0 0 auto; }
    .page-header-actions form .btn, .page-header > div:not(:first-child) form .btn { width: 100%; }
}

/* ------------------------------------------------------------ Filterleiste */
.toolbar {
    display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: flex-end;
    padding: var(--sp-3) var(--sp-4); background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--r); margin-bottom: var(--sp-4);
}
.toolbar .form-group { margin: 0; flex: 1 1 160px; min-width: 0; }
.toolbar .form-group.is-search { flex: 2 1 220px; }
.toolbar .form-label { font-size: var(--fs-xs); margin-bottom: 4px; }
.toolbar .toolbar-actions { display: flex; gap: var(--sp-2); flex: 0 0 auto; }
.toolbar .form-check { min-height: 40px; }
@media (max-width: 768px) {
    .toolbar { padding: var(--sp-3); }
    .toolbar .form-group { flex: 1 1 calc(50% - var(--sp-2)); }
    .toolbar .form-group.is-search, .toolbar .toolbar-actions { flex: 1 1 100%; }
    .toolbar .toolbar-actions .btn { flex: 1; }
    /* Zusammenklappbar auf Mobile */
    .toolbar[data-collapsible] > :not(.toolbar-toggle):not(.is-search):not(.toolbar-actions) { display: none; }
    .toolbar[data-collapsible].is-open > * { display: flex; }
}
.toolbar-toggle { display: none; }
@media (max-width: 768px) { .toolbar-toggle { display: inline-flex; flex: 0 0 auto; } }

/* --------------------------------------------------------------- Formulare */
.form-group { margin-bottom: var(--sp-4); }
.form-label { display: block; margin-bottom: var(--sp-1); font-weight: 500; font-size: var(--fs-sm); color: var(--color-text); }
.form-label .req, .form-label abbr { color: var(--color-danger); text-decoration: none; }
.form-hint, .form-text, .form-group small, .form-group .text-muted:not(.badge) { display: block; margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--color-text-muted); line-height: 1.45; }
.form-error { color: var(--color-danger); font-size: var(--fs-xs); margin-top: var(--sp-1); }

.form-control, .form-select, .q-input, .q-textarea {
    display: block; width: 100%; min-height: 40px; padding: 0.5rem 0.75rem;
    background: var(--color-input-bg); color: var(--color-text);
    border: 1px solid var(--color-input-border); border-radius: var(--r-sm);
    font-size: var(--fs-base); line-height: 1.4;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.form-control:focus, .form-select:focus, .q-input:focus, .q-textarea:focus {
    outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--brand-cyan-glow);
}
.form-control::placeholder { color: var(--color-text-faint); }
.form-control[readonly], .form-control:disabled { background: var(--color-surface-2); color: var(--color-text-muted); }
.form-control.is-invalid { border-color: var(--color-danger); }
.form-control-sm { min-height: 34px; padding: 0.3rem 0.6rem; font-size: var(--fs-sm); }
textarea.form-control { min-height: 96px; resize: vertical; line-height: 1.5; }
select.form-control, .form-select {
    appearance: none; padding-right: 2.25rem; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5a6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.7rem center;
}
html[data-theme="dark"] select.form-control, html[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a7b6c5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
select.form-control[multiple] { background-image: none; padding-right: 0.75rem; }
input[type="date"].form-control, input[type="datetime-local"].form-control { min-width: 0; }
input[type="file"].form-control { padding: 0.35rem 0.5rem; cursor: pointer; }
input[type="file"].form-control::file-selector-button {
    border: 1px solid var(--color-border-strong); background: var(--color-surface-2); color: var(--color-text);
    border-radius: var(--r-sm); padding: 0.3rem 0.75rem; margin-right: 0.75rem; font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
input[type="color"].form-control { padding: 2px; width: 48px; }
@media (max-width: 768px) {
    .form-control, .form-select, .q-input, .q-textarea { min-height: var(--touch); font-size: 16px; } /* verhindert Zoom auf iOS */
    .form-control-sm { min-height: 40px; font-size: 15px; }
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--sp-3) var(--sp-4); }
.form-row .form-group { margin-bottom: 0; }
.form-row + .form-row, .form-row + .form-group, .form-group + .form-row { margin-top: var(--sp-4); }
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: var(--sp-4) var(--sp-5); }

.form-check, .custom-control { display: flex; align-items: flex-start; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-base); }
.form-check input, .custom-control-input { width: 18px; height: 18px; margin-top: 0.15em; accent-color: var(--color-accent); flex-shrink: 0; cursor: pointer; }
.form-check-inline { display: inline-flex; margin-right: var(--sp-4); }
.form-check-group { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; padding-top: var(--sp-4); margin-top: var(--sp-4); border-top: 1px solid var(--color-border); }
.form-actions .spacer { flex: 1; }
@media (max-width: 768px) { .form-actions .btn { flex: 1 1 calc(50% - var(--sp-2)); } .form-actions .btn-primary { flex-basis: 100%; order: -1; } }

/* Umschalter (Netto/Brutto etc.) */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-slider { position: absolute; inset: 0; background: var(--color-border-strong); border-radius: var(--r-full); transition: background var(--dur) var(--ease); }
.switch-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-xs); transition: transform var(--dur) var(--ease); }
.switch input:checked + .switch-slider { background: var(--color-accent); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--color-ring); outline-offset: 2px; }
.switch-group { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: 500; background: var(--color-surface); border: 1px solid var(--color-border); padding: 4px 10px; border-radius: var(--r-full); }
.switch-group .switch-label { color: var(--color-text-faint); }
.switch-group .switch-label.active { color: var(--color-text); }

/* Segment-Auswahl (Radio als Buttons) */
.segmented { display: inline-flex; background: var(--color-surface-2); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.segmented label { position: relative; padding: 0.35rem 0.8rem; border-radius: 4px; font-size: var(--fs-sm); font-weight: 500; color: var(--color-text-muted); cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.segmented label:has(input:checked) { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-xs); }

/* ------------------------------------------------------------- Tabellen */
.table-wrap, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.table, .table-responsive table, .table-wrap table, .table-scroll table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
th, td { padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
thead th {
    background: var(--color-surface-2); color: var(--color-text-muted);
    font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--color-surface-2); }
tr.is-muted td { color: var(--color-text-muted); }
td.actions, th.actions { text-align: right; white-space: nowrap; }
td.actions .btn-group { justify-content: flex-end; flex-wrap: nowrap; }
td .badge { vertical-align: middle; }
.table-sm th, .table-sm td { padding: 0.4rem 0.6rem; font-size: var(--fs-sm); }
.detail-table th { background: transparent; text-transform: none; letter-spacing: 0; font-size: var(--fs-sm); font-weight: 500; color: var(--color-text-muted); width: 34%; }

/* Karten-Modus auf Mobile (Legacy-Klasse .table-responsive + neue .table-cards) */
@media (max-width: 768px) {
    .table-responsive, .table-cards { overflow: visible; }
    .table-responsive table, .table-responsive thead, .table-responsive tbody, .table-responsive tr, .table-responsive td, .table-responsive th,
    .table-cards table, .table-cards thead, .table-cards tbody, .table-cards tr, .table-cards td, .table-cards th { display: block; }
    .table-responsive thead, .table-cards thead { display: none; }
    .table-responsive tr, .table-cards tr {
        background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r);
        padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3); box-shadow: var(--shadow-xs);
        position: relative;
    }
    .table-responsive tr:hover td, .table-cards tr:hover td { background: transparent; }
    .table-responsive td, .table-cards td {
        display: grid; grid-template-columns: minmax(84px, 38%) 1fr; gap: var(--sp-3); align-items: start;
        padding: 0.45rem 0; border-bottom: 1px solid var(--color-border); text-align: left;
    }
    .table-responsive td:last-child, .table-cards td:last-child { border-bottom: 0; }
    .table-responsive td::before, .table-cards td::before {
        content: attr(data-label); font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
        color: var(--color-text-muted); padding-top: 0.2em; overflow-wrap: normal; word-break: normal; hyphens: manual;
    }
    .table-responsive td:not([data-label])::before, .table-responsive td[data-label=""]::before,
    .table-cards td:not([data-label])::before, .table-cards td[data-label=""]::before { display: none; }
    .table-responsive td:not([data-label]), .table-responsive td[data-label=""],
    .table-cards td:not([data-label]), .table-cards td[data-label=""] { grid-template-columns: 1fr; }
    .table-responsive td.text-right, .table-cards td.text-right { text-align: left; }
    /* Erste Zelle = Titel der Karte */
    .table-responsive td:first-child, .table-cards td:first-child { grid-template-columns: 1fr; font-size: var(--fs-md); font-weight: 600; padding-top: 0; padding-right: 44px; }
    .table-responsive td:first-child::before, .table-cards td:first-child::before { display: none; }
    /* Aktionen: als Reihe unten (Legacy) bzw. „⋯"-Menü oben rechts (neu, .row-menu) */
    .table-responsive td.actions, .table-cards td.actions { grid-template-columns: 1fr; padding-top: var(--sp-3); padding-bottom: 0; }
    .table-responsive td.actions::before, .table-cards td.actions::before { display: none; }
    .table-responsive td.actions .btn-group, .table-cards td.actions .btn-group { justify-content: stretch; flex-wrap: wrap; }
    .table-responsive td.actions .btn, .table-cards td.actions .btn { flex: 1 1 calc(50% - var(--sp-2)); }
    td.actions.has-menu { position: absolute; top: var(--sp-2); right: var(--sp-2); padding: 0; border: 0; width: auto; }
    td.actions.has-menu .btn-group { display: none; }
}
@media (min-width: 769px) { .row-menu-only-mobile { display: none !important; } }

/* ------------------------------------------------------------- Dropdown-Menü („⋯") */
.menu { position: relative; display: inline-block; }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px; z-index: var(--z-menu);
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r);
    box-shadow: var(--shadow-md); padding: var(--sp-1); display: none;
}
.menu.is-open .menu-panel, .menu-panel.open { display: block; }
.menu-panel.align-left { right: auto; left: 0; }
@media (min-width: 769px) { .menu-panel.drop-up { top: auto; bottom: calc(100% + 4px); } }
.menu-panel a, .menu-panel button, .menu-item {
    display: flex; align-items: center; gap: var(--sp-2); width: 100%; text-align: left;
    padding: 0.55rem 0.75rem; border-radius: var(--r-sm); color: var(--color-text); font-size: var(--fs-base);
    background: transparent; border: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.menu-panel a:hover, .menu-panel button:hover, .menu-item:hover { background: var(--color-surface-2); text-decoration: none; }
.menu-panel .is-danger, .menu-panel .text-danger { color: var(--color-danger); }
.menu-panel .is-danger:hover { background: var(--color-danger-bg); }
.menu-panel hr, .menu-sep { margin: var(--sp-1) 0; border-top: 1px solid var(--color-border); }
.menu-panel .menu-section { padding: 0.5rem 0.75rem 0.2rem; font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-faint); }
.menu-panel form { display: contents; }
.menu-panel .icon { color: var(--color-text-muted); }
@media (max-width: 768px) {
    /* Am Handy als Bottom-Sheet */
    .menu-panel { position: fixed; left: var(--sp-2); right: var(--sp-2); top: auto; bottom: calc(var(--sp-2) + env(safe-area-inset-bottom)); min-width: 0; padding: var(--sp-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
    .menu-panel a, .menu-panel button, .menu-item { min-height: var(--touch); font-size: var(--fs-md); }
    .menu-backdrop { position: fixed; inset: 0; background: var(--color-backdrop); z-index: calc(var(--z-menu) - 1); }
}

/* ------------------------------------------------------------------ Tabs */
.tabs, .user-tabs, .dashboard-tabs {
    display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--color-border); margin-bottom: var(--sp-4);
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap;
}
.tabs::-webkit-scrollbar, .user-tabs::-webkit-scrollbar, .dashboard-tabs::-webkit-scrollbar { display: none; }
.tab, .user-tab, .dashboard-tab {
    display: inline-flex; align-items: center; gap: var(--sp-2); flex-shrink: 0;
    padding: 0.7rem 0.9rem; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
    background: transparent; color: var(--color-text-muted); font-weight: 500; font-size: var(--fs-base);
    cursor: pointer; text-decoration: none; white-space: nowrap; transition: color var(--dur-fast), border-color var(--dur-fast);
}
.tab:hover, .user-tab:hover, .dashboard-tab:hover { color: var(--color-text); text-decoration: none; background: transparent; }
.tab.active, .user-tab.active, .dashboard-tab.active { color: var(--color-primary); border-bottom-color: var(--color-accent); background: transparent; }
.dashboard-tab.active::after { display: none; }
.tab-count, .user-tab-count { background: var(--color-surface-2); color: var(--color-text-muted); border-radius: var(--r-full); padding: 0 0.5em; font-size: var(--fs-2xs); font-weight: 600; }
.tab.active .tab-count, .user-tab.active .user-tab-count { background: var(--color-accent-soft); color: var(--color-accent-text); }
html[data-theme="dark"] .tab.active, html[data-theme="dark"] .user-tab.active, html[data-theme="dark"] .dashboard-tab.active { color: var(--color-accent-text); }

/* ---------------------------------------------------------------- Alerts */
.alert {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4); border-radius: var(--r); margin-bottom: var(--sp-4);
    border: 1px solid transparent; font-size: var(--fs-sm); line-height: 1.5;
    background: var(--color-surface-2); color: var(--color-text);
}
.alert > .icon { flex-shrink: 0; margin-top: 0.1em; width: 1.25rem; height: 1.25rem; }
.alert > div, .alert-body { flex: 1 1 auto; min-width: 0; }
.alert strong { font-weight: 600; }
.alert .alert-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-left: auto; align-self: center; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: color-mix(in srgb, var(--color-success) 25%, transparent); }
.alert-error, .alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 25%, transparent); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: color-mix(in srgb, var(--color-warning) 30%, transparent); }
.alert-info { background: var(--color-info-bg); color: var(--color-info); border-color: color-mix(in srgb, var(--color-info) 25%, transparent); }
.alert-success strong, .alert-error strong, .alert-warning strong, .alert-info strong { color: inherit; }
@media (max-width: 768px) { .alert { flex-wrap: wrap; } .alert .alert-actions { flex: 1 0 100%; margin-left: 0; } .alert .alert-actions .btn { flex: 1; } }

/* Flash-Toast (Layout-Meldung) */
.toast-stack { position: fixed; z-index: var(--z-toast); left: var(--sp-3); right: var(--sp-3); bottom: calc(var(--bottomnav-h, 0px) + var(--sp-3) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--sp-2); pointer-events: none; }
@media (min-width: 769px) { .toast-stack { left: auto; right: var(--sp-6); bottom: var(--sp-6); width: 380px; } }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r); background: var(--brand-navy); color: #fff; box-shadow: var(--shadow-lg); font-size: var(--fs-sm); transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease); }
.toast.is-hiding { opacity: 0; transform: translateY(8px); }
.toast-success { border-left: 4px solid #4ade80; }
.toast-error, .toast-danger { border-left: 4px solid #f87171; }
.toast-warning { border-left: 4px solid #fbbf24; }
.toast .icon { flex-shrink: 0; margin-top: 0.1em; }
.toast-close { margin-left: auto; color: rgba(255,255,255,0.7); padding: 0 4px; }
.toast-close:hover { color: #fff; }

/* -------------------------------------------------------------- Stat-Karten */
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4); } }
.stat-card {
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r);
    padding: var(--sp-3) var(--sp-4); display: flex; align-items: center; gap: var(--sp-3); min-width: 0; box-shadow: var(--shadow-xs);
}
.stat-card > a { display: contents; color: inherit; }
.stat-icon { width: 40px; height: 40px; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--color-accent-soft); color: var(--color-accent-text); font-size: 1.1rem; }
.stat-icon .icon { width: 20px; height: 20px; }
.stat-icon.primary { background: var(--color-primary-soft); color: var(--color-primary); }
.stat-icon.success { background: var(--color-success-bg); color: var(--color-success); }
.stat-icon.warning { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-icon.danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.stat-icon.info    { background: var(--color-info-bg);    color: var(--color-info); }
.stat-content { min-width: 0; }
.stat-content h3, .stat-value { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-content p, .stat-label { color: var(--color-text-muted); font-size: var(--fs-xs); margin: 0; line-height: 1.3; }
.stat-subtitle { font-size: var(--fs-2xs); color: var(--color-text-faint); margin-top: 2px; }
@media (max-width: 480px) { .stat-card { padding: var(--sp-3); gap: var(--sp-2); flex-direction: column; align-items: flex-start; } .stat-icon { width: 34px; height: 34px; } }
@media (min-width: 769px) { .stat-content h3, .stat-value { font-size: var(--fs-2xl); } .stat-icon { width: 46px; height: 46px; } }

/* ------------------------------------------------------------- Leerzustand */
.empty-state { text-align: center; padding: var(--sp-10) var(--sp-4); color: var(--color-text-muted); }
.empty-state .icon, .empty-state svg { width: 44px; height: 44px; margin: 0 auto var(--sp-3); color: var(--color-text-faint); opacity: 1; }
.empty-state h3, .empty-state .empty-state-title { font-size: var(--fs-md); font-weight: 600; color: var(--color-text); margin: 0 0 var(--sp-1); max-width: none; }
.empty-state p { font-size: var(--fs-sm); max-width: 38ch; margin: 0 auto; }
.empty-state .btn { margin-top: var(--sp-4); }
.empty-state .btn .icon, .empty-state .btn svg { width: 1.15em; height: 1.15em; margin: 0; color: inherit; }
.empty-state-sm { padding: var(--sp-4); } .empty-state-sm .icon { width: 28px; height: 28px; margin-bottom: var(--sp-2); }

/* -------------------------------------------------------------- Modale */
.modal, .kanban-modal, .ot-modal {
    position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: var(--sp-4);
}
.modal[hidden], .kanban-modal[hidden], .ot-modal[hidden] { display: none !important; }
.modal-backdrop, .kanban-modal-backdrop, .ot-modal-backdrop { position: absolute; inset: 0; background: var(--color-backdrop); }
.modal-dialog, .kanban-modal-dialog, .ot-modal-card {
    position: relative; width: 100%; max-width: 560px; max-height: min(90vh, 90dvh);
    background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
}
.modal-sm, .kanban-modal-sm { max-width: 420px; }
.modal-lg, .kanban-modal-lg { max-width: 760px; }
.modal-md, .kanban-modal-md { max-width: 600px; }
.modal-header, .kanban-modal-header, .ot-modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--color-border); }
.modal-title, .kanban-modal-title, .ot-modal-head h3 { margin: 0; font-size: var(--fs-lg); font-weight: 600; }
.modal-close, .kanban-modal-close, .ot-modal-close { width: 36px; height: 36px; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-muted); font-size: 1.4rem; line-height: 1; background: transparent; border: 0; cursor: pointer; }
.modal-close:hover, .kanban-modal-close:hover, .ot-modal-close:hover { background: var(--color-surface-2); color: var(--color-text); }
.modal-body, .kanban-modal-body, .ot-modal-body { padding: var(--sp-4) var(--sp-5); overflow-y: auto; }
.modal-footer, .kanban-modal-footer { display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--color-border); background: var(--color-surface); }
.modal-footer form, .kanban-modal-footer form { display: contents; }
@media (max-width: 768px) {
    /* Bottom-Sheet am Handy */
    .modal, .kanban-modal, .ot-modal { align-items: flex-end; padding: 0; }
    .modal-dialog, .kanban-modal-dialog, .ot-modal-card { max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; border-bottom: 0; }
    .modal-header, .kanban-modal-header, .ot-modal-head, .modal-body, .kanban-modal-body, .ot-modal-body { padding-left: var(--sp-4); padding-right: var(--sp-4); }
    .modal-footer, .kanban-modal-footer { padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom)); }
    .modal-footer .btn, .kanban-modal-footer .btn { flex: 1 1 calc(50% - var(--sp-2)); }
}
.modal-dialog.is-danger .modal-title .icon, .kanban-modal-dialog.is-danger .kanban-modal-title .icon { color: var(--color-danger); }
.kanban-modal-title { display: flex; align-items: center; gap: var(--sp-2); }
.kanban-modal-title .icon { flex-shrink: 0; }

/* -------------------------------------------------------------- Stepper */
.stage-stepper { display: flex; align-items: flex-start; gap: 0; margin: var(--sp-2) 0 var(--sp-4); overflow-x: auto; padding: var(--sp-2) 0 var(--sp-3); scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.stage-step { flex: 1 0 96px; min-width: 96px; text-align: center; position: relative; padding: 0 var(--sp-1); scroll-snap-align: center; }
.stage-step-circle { width: 32px; height: 32px; border-radius: 50%; background: var(--color-surface-2); color: var(--color-text-muted); border: 2px solid var(--color-border-strong); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--sp-2); position: relative; z-index: 1; }
.stage-step.done .stage-step-circle { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success); }
.stage-step.active .stage-step-circle { background: var(--color-primary); color: var(--color-primary-fg); border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--brand-cyan-glow); }
.stage-step-label { font-size: var(--fs-xs); color: var(--color-text-muted); line-height: 1.3; overflow-wrap: anywhere; }
.stage-step.active .stage-step-label { color: var(--color-text); font-weight: 600; }
.stage-step::after { content: ''; position: absolute; top: 16px; left: calc(50% + 16px); right: calc(-50% + 16px); height: 2px; background: var(--color-border-strong); }
.stage-step.done::after, .stage-step.done-line::after { background: var(--color-success); }
.stage-step:last-child::after { display: none; }
.stage-info-box { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); color: var(--color-text-muted); line-height: 1.5; }
.stage-info-box strong { color: var(--color-text); }

/* ------------------------------------------------------------- Avatar / Chips */
.user-avatar, .avatar { width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 600; font-size: var(--fs-xs); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; text-transform: uppercase; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.user-row { display: flex; align-items: center; gap: var(--sp-3); }
.chip { display: inline-flex; align-items: center; gap: 0.35em; padding: 0.25em 0.7em; border-radius: var(--r-full); background: var(--color-surface-2); color: var(--color-text-muted); font-size: var(--fs-xs); font-weight: 500; }
.chip.is-active { background: var(--color-accent-soft); color: var(--color-accent-text); }
.placeholder-chip { display: inline-block; font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 4px; padding: 0.1em 0.45em; cursor: pointer; margin: 2px; }
.placeholder-chip:hover { background: var(--color-accent-soft); border-color: var(--color-accent); }

/* ------------------------------------------------------------- Definitionslisten (Detail-Ansichten) */
.dl { display: grid; grid-template-columns: minmax(110px, 32%) 1fr; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-base); }
.dl dt { color: var(--color-text-muted); font-size: var(--fs-sm); padding-top: 0.1em; }
.dl dd { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dl { grid-template-columns: 1fr; gap: 0; } .dl dt { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.04em; margin-top: var(--sp-3); } .dl dt:first-child { margin-top: 0; } }

/* ------------------------------------------------------------- Listen-Karten (mobile Standardliste) */
.list { display: flex; flex-direction: column; gap: var(--sp-2); }
.list-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r); min-width: 0; }
.list-item-main { flex: 1 1 auto; min-width: 0; }
.list-item-title { font-weight: 600; overflow-wrap: anywhere; }
.list-item-meta { font-size: var(--fs-xs); color: var(--color-text-muted); display: flex; flex-wrap: wrap; gap: 0.25em var(--sp-2); margin-top: 2px; }
.list-item-end { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

/* ------------------------------------------------------------- Code-Ansicht */
.code-editor, textarea.code-editor { font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.6; border: 1px solid var(--color-input-border); border-radius: var(--r-sm); min-height: 300px; background: var(--color-input-bg); color: var(--color-text); padding: var(--sp-3); tab-size: 2; white-space: pre; overflow: auto; }
.code-block { font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); overflow-wrap: anywhere; word-break: break-all; }

/* ------------------------------------------------------------- Fortschritt */
.progress { height: 8px; background: var(--color-surface-3); border-radius: var(--r-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--color-accent); border-radius: var(--r-full); transition: width var(--dur-slow) var(--ease); }
.progress-bar.success { background: var(--color-success); }
.progress-bar.warning { background: var(--color-warning); }
.progress-bar.danger { background: var(--color-danger); }

/* ------------------------------------------------------------- Skeleton / Lade-Indikator */
.spinner { width: 1.1em; height: 1.1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- Einstellungs-Übersicht */
.settings-group-title { font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-faint); margin: var(--sp-6) 0 var(--sp-2); }
.settings-group-title:first-of-type { margin-top: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--sp-3); }
.settings-tile {
    display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); min-height: 72px;
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r); color: var(--color-text);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}
.settings-tile:hover { text-decoration: none; border-color: var(--color-accent); box-shadow: var(--shadow-sm); }
.settings-tile-icon { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--color-accent-soft); color: var(--color-accent-text); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.settings-tile-icon .icon { width: 20px; height: 20px; }
.settings-tile-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.settings-tile-title { font-weight: 600; }
.settings-tile-desc { font-size: var(--fs-xs); color: var(--color-text-muted); }
.settings-tile-chevron { color: var(--color-text-faint); }

/* Utility-Ergänzungen (UI-Refresh, Ersatz für letzte statische Inline-Styles) */
.eyebrow { text-transform: uppercase; letter-spacing: 0.04em; }
.form-actions-plain { border: 0; padding-top: var(--sp-3); margin-top: 0; }
.empty-state-md { padding: var(--sp-6); }
.code-editor-sm, textarea.code-editor-sm { min-height: 140px; }
.code-editor-xs, textarea.code-editor-xs { min-height: 90px; }
/* Abschnitts-Titel, Trennlinie, schmale Eingabe (Editoren, Portal) */
.mail-section-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); font-weight: 600; margin: 0 0 var(--sp-3); }
.mail-divider { border: 0; border-top: 1px solid var(--color-border); margin: var(--sp-5) 0; }
.form-control-narrow { max-width: 320px; }
.modal-dialog > form.modal-form { display: contents; }
