/* ZHD STAMMDATEN — lokale Styles, KEINE externen Fonts/CDN. */
:root {
    --accent: #1c5fc4;
    --accent-dark: #154a9c;
    --bg: #f6f8fb;
    --card: #ffffff;
    --border: #dee2e6;
    --text: #1a1a2e;
    --muted: #6c757d;
    --danger: #842029;
    --danger-bg: #f8d7da;
    --ok: #0f5132;
    --ok-bg: #d1e7dd;
}
[data-theme="dark"] {
    --accent: #4e8fe0;
    --accent-dark: #2f6fc4;
    --bg: #0f1115;
    --card: #161a20;
    --border: #2a2f38;
    --text: #e6e9ef;
    --muted: #8892a0;
    --danger: #ff8a92;
    --danger-bg: rgba(220,53,69,.18);
    --ok: #7ee0a4;
    --ok-bg: rgba(25,135,84,.20);
}
[data-theme="dark"] body { color-scheme: dark; }
[data-theme="dark"] .topbar { background: var(--card); }
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] textarea,
[data-theme="dark"] select { background: #1c2129; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .field-row .field-input { background: #1c2129; color: var(--text); }
[data-theme="dark"] .entity-card,
[data-theme="dark"] .audit-item,
[data-theme="dark"] .modal-card,
[data-theme="dark"] .login-card { background: var(--card); }
[data-theme="dark"] .filter-pill { background: var(--card); }
[data-theme="dark"] .diff-panel { background: #1c2129; }
[data-theme="dark"] .diff-row { border-bottom-color: #23272f; }
[data-theme="dark"] .diff-row.diff-changed { background: rgba(255,193,7,.15); }
[data-theme="dark"] .diff-row.diff-added   { background: rgba(25,135,84,.22); }
[data-theme="dark"] .diff-row.diff-removed { background: rgba(220,53,69,.18); }
[data-theme="dark"] .audit-item:not(.collapsed) .audit-head { background: #1c2129; }
[data-theme="dark"] .audit-body { background: #12161c; }
[data-theme="dark"] .audit-head:hover,
[data-theme="dark"] .entity-list[data-accordion="1"] .entity-head[data-toggle="1"]:hover { background: #1c2129; }
[data-theme="dark"] .modal-card pre { background: #12161c; }
[data-theme="dark"] .badge { background: rgba(255,255,255,.06); color: var(--text); }
[data-theme="dark"] .badge-ok { background: var(--ok-bg); color: var(--ok); }
[data-theme="dark"] .badge-danger { background: var(--danger-bg); color: var(--danger); }
[data-theme="dark"] .badge-eigen { background: rgba(255,255,255,.06); color: var(--muted); }
[data-theme="dark"] .audit-action-create { background: rgba(25,135,84,.22); color: #7ee0a4; }
[data-theme="dark"] .audit-action-update { background: rgba(78,143,224,.22); color: #a5c4ee; }
[data-theme="dark"] .audit-action-delete { background: rgba(220,53,69,.22); color: #ff8a92; }
[data-theme="dark"] .v-badge:hover, [data-theme="dark"] .v-badge:focus { background: rgba(78,143,224,.25); }
[data-theme="dark"] body.auth { background: linear-gradient(135deg, #1c2540 0%, #0f1115 100%); }
.theme-toggle { font-size: 16px; line-height: 1; padding: 6px 10px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

/* ── Auth-Screen ──────────────────────────────────────────────────────── */
body.auth {
    background: linear-gradient(135deg, #4a8fd9 0%, var(--accent) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.login-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}
.brand { text-align: center; margin-bottom: 28px; }
.brand .logo {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 3px;
    margin-bottom: 14px;
}
.brand h1 { font-size: 18px; margin: 0; }
.brand p { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: both; }
.error {
    background: var(--danger-bg);
    color: var(--danger);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}
.version {
    text-align: center;
    font-size: 11px;
    color: #adb5bd;
    margin-top: 24px;
}

/* ── App-Chrome (angeglichen an Werkstatt/Verleihfix/Montageberichte) ── */
.topbar {
    background: #0e1b34;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand-row { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; }
.brand-row strong { font-size: 15px; letter-spacing: 1px; }
.brand-row .muted { color: rgba(255,255,255,0.55); font-weight: 400; }
.brand-row .version-badge { font-size: 11px; opacity: 0.45; font-weight: 400; margin-left: 4px; color: rgba(255,255,255,0.7); }
.logo-sm {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 2px;
}
.muted { color: var(--muted); }

/* Nav-Tabs (identische Optik wie shared.css .nav-tab) */
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links .nav-tab {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    padding: 8px 14px;
    font-size: 14px;
    font-family: inherit;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: color .15s, background .15s;
}
.nav-links .nav-tab:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-links .nav-tab.active {
    background: none;
    color: #fff;
    font-weight: 700;
    border-radius: 0;
    box-shadow: inset 0 -3px 0 var(--accent);
}
.nav-links .nav-tab.active::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.18);
    flex-shrink: 0;
}
.nav-links .nav-tab.active:hover { background: none; }
.nav-links .btn-logout {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.85);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    margin-left: 8px;
}
.nav-links .btn-logout:hover { background: rgba(255,255,255,0.2); color: #fff; }
.nav-links .theme-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 16px;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
}
.nav-links .theme-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}
.container h1 { margin-top: 0; }

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0 20px;
    font-size: 14px;
}
.flash.ok  { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--danger-bg); color: var(--danger); }
.hidden { display: none; }

/* ── Settings-Cards ───────────────────────────────────────────────────── */
.settings-list {
    display: grid;
    gap: 16px;
}
.setting-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.setting-head {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}
.setting-head h2 {
    font-size: 16px;
    margin: 0;
    font-weight: 600;
}
.setting-head code {
    background: #eef3f9;
    color: var(--accent-dark);
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 14px;
}
.badge {
    background: #eef3f9;
    color: var(--accent-dark);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
}
.desc {
    margin: 8px 0 12px;
    color: var(--muted);
    font-size: 13px;
}
.setting-body { margin: 8px 0 12px; }
.setting-body .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.setting-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 8px;
}
.meta { font-size: 12px; color: var(--muted); }

.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}
.switch input { width: 18px; height: 18px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
.btn-ghost:hover { background: #eef3f9; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #a5301f; }
.btn-block { width: 100%; padding: 12px; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}
.modal.hidden { display: none; }
.modal-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-card-wide { max-width: 880px; }
.modal-card h2 { margin-top: 0; }
.modal-card h2 code {
    background: #eef3f9;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.85em;
}
.modal-card pre {
    background: #f6f8fb;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
    flex-wrap: wrap;
}
.cm-explain {
    background: #fef7ec;
    border-left: 4px solid #f59e0b;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.cm-explain p { margin: 6px 0; }
.cm-explain ul { margin: 6px 0 6px 20px; padding: 0; }
.cm-explain li { margin: 3px 0; }
.cm-diff {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 12px 0;
}
.cm-diff .cm-col h3 {
    margin: 0 0 4px 0;
    font-size: 15px;
    color: var(--accent);
}
.cm-diff .cm-col .muted { font-size: 12px; margin: 0 0 6px 0; }
.cm-diff .cm-col pre { margin: 0; max-height: 220px; }
.cm-hint {
    background: #eef7ee;
    border-left: 4px solid #16a34a;
    padding: 12px 16px;
    border-radius: 6px;
    margin: 16px 0 8px 0;
    font-size: 13px;
}
.cm-hint ul { margin: 6px 0 0 20px; padding: 0; }
.cm-hint li { margin: 4px 0; }
@media (max-width: 720px) {
    .cm-diff { grid-template-columns: 1fr; }
}

/* ── Nav-Links in Topbar ─────────────────────────────────────────────────── */
.nav-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.nav-links .btn { padding: 6px 12px; font-size: 13px; }

/* ── Toolbar (Suche, Neu-Button) ─────────────────────────────────────────── */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 12px 0 20px;
    flex-wrap: wrap;
}
.toolbar-spacer { flex: 1; }
.search-input {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--accent); }

/* ── Entity-Cards (Kunden / Maschinen / Mitarbeiter) ─────────────────────── */
.entity-list {
    display: grid;
    gap: 16px;
}
.entity-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.entity-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.entity-head h2 {
    font-size: 16px;
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.entity-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px 16px;
    margin: 12px 0;
}
.field-row label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field-row .field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.field-row .field-input {
    padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    width: 100%;
}
.field-row .field-input:focus { outline: none; border-color: var(--accent); }
.field-row textarea.field-input {
    resize: none; /* nativer Handle abgeschaltet, wir bauen eigenen */
    min-height: 80px;
    max-width: 100%;
    display: block;
    overflow: auto;
}
/* Custom Resize-Wrapper + Handle (funktioniert auch auf iOS/iPad) */
.textarea-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.textarea-wrap textarea.field-input {
    padding-right: 22px; /* Platz für Handle, damit Text nicht drunter läuft */
}
.textarea-handle {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 28px;
    height: 28px;
    cursor: nwse-resize;
    touch-action: none;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 4px;
    background: transparent;
    border: none;
    -webkit-user-select: none;
    user-select: none;
    z-index: 2;
}
.textarea-handle::before {
    content: "";
    width: 16px;
    height: 16px;
    background:
        linear-gradient(135deg,
            transparent 0 45%,
            var(--muted) 45% 55%,
            transparent 55% 65%,
            var(--muted) 65% 75%,
            transparent 75% 85%,
            var(--muted) 85% 95%,
            transparent 95%);
    border-bottom-right-radius: 4px;
    transition: background 120ms;
}
.textarea-handle:hover::before,
.textarea-handle:active::before {
    background:
        linear-gradient(135deg,
            transparent 0 45%,
            var(--accent) 45% 55%,
            transparent 55% 65%,
            var(--accent) 65% 75%,
            transparent 75% 85%,
            var(--accent) 85% 95%,
            transparent 95%);
}
.field-row input[type="checkbox"].field-input {
    width: 20px;
    height: 20px;
    align-self: flex-start;
}

.entity-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.entity-foot .actions {
    display: flex;
    gap: 8px;
}

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

/* ── Bonitäts-Ampel (T-020) ─────────────────────────────────────────────
   Dezenter farbiger Punkt links vom Firmennamen. Kunde könnte daneben
   stehen — bewusst klein und ohne Text-Label. Klartext im Tooltip. */
.bonitaet-icon {
    display: inline-block;
    font-size: 0.85em;
    line-height: 1;
    margin-right: 6px;
    cursor: help;
    vertical-align: baseline;
}
.bonitaet-rot    { color: #c92a2a; }
.bonitaet-orange { color: #e67700; }
[data-theme="dark"] .bonitaet-rot    { color: #ff8080; }
[data-theme="dark"] .bonitaet-orange { color: #ffb066; }

/* ── Version-Badge + Popover (S.4a) ─────────────────────────────────────── */
.v-badge {
    cursor: help;
    transition: background 120ms ease;
}
.v-badge:hover, .v-badge:focus {
    background: #d9e6f5;
    outline: none;
}

/* ── Accordion-Maschinen (v0.3.2) ──────────────────────────────────────── */
.filter-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    flex-wrap: wrap;
}
.filter-pill {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms, color 120ms, border-color 120ms;
    font-family: inherit;
}
.filter-pill:hover { color: var(--text); border-color: var(--accent); }
.filter-pill.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.filter-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
}

/* Accordion-Verhalten: nur wenn Liste [data-accordion="1"] ist */
.entity-list[data-accordion="1"] { gap: 6px; }
.entity-list[data-accordion="1"] .entity-card {
    padding: 0;
    box-shadow: none;
    transition: border-color 120ms, box-shadow 120ms;
}
.entity-list[data-accordion="1"] .entity-card:hover { border-color: #adb5bd; }
.entity-list[data-accordion="1"] .entity-card:not(.collapsed) {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(28,95,196,0.08);
}
.entity-list[data-accordion="1"] .entity-card.collapsed .entity-body,
.entity-list[data-accordion="1"] .entity-card.collapsed .entity-foot { display: none; }

.entity-list[data-accordion="1"] .entity-head {
    padding: 12px 16px;
    margin: 0;
    gap: 12px;
    align-items: center;
}
.entity-list[data-accordion="1"] .entity-head[data-toggle="1"] {
    cursor: pointer;
    user-select: none;
}
.entity-list[data-accordion="1"] .entity-head[data-toggle="1"]:hover {
    background: #f0f4f9;
    border-radius: 12px 12px 0 0;
}
.entity-list[data-accordion="1"] .entity-card.collapsed .entity-head[data-toggle="1"]:hover {
    border-radius: 12px;
}
.entity-list[data-accordion="1"] .entity-body { padding: 12px 16px 0; margin: 0; }
.entity-list[data-accordion="1"] .entity-foot { padding: 10px 16px 12px; margin-top: 12px; }

.chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    color: var(--muted);
    font-size: 11px;
    transition: transform 180ms ease, color 120ms;
    flex-shrink: 0;
}
.entity-card:not(.collapsed) .chevron {
    transform: rotate(90deg);
    color: var(--accent);
}

.head-grid {
    flex: 1;
    display: grid;
    gap: 12px;
    align-items: baseline;
    min-width: 0;
}
.head-grid--maschinen    { grid-template-columns: 1.1fr 1fr 1.6fr auto; }
.head-grid--kunden       { grid-template-columns: 1.6fr 1.2fr 1.2fr 1.4fr; }
.head-grid--mitarbeiter  { grid-template-columns: 1.4fr 0.7fr 1.2fr 1.4fr; }

.head-c1 { font-weight: 700; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-c2 { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-c3 { font-size: 14px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-c4 { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.head-chips     { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.head-chips .badge {
    font-size: 10px;
    padding: 2px 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-eigen { background: #e9ecef; color: var(--muted); }

/* ── Audit-Log Akkordeon + Diff (v0.3.5) ──────────────────────────────── */
.audit-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 6px 0 12px;
    flex-wrap: wrap;
}
.audit-showall {
    font-size: 13px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.audit-showall input { accent-color: var(--accent); }

.audit-list { display: flex; flex-direction: column; gap: 6px; }

.audit-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 120ms, box-shadow 120ms;
}
.audit-item:hover { border-color: #adb5bd; }
.audit-item:not(.collapsed) {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(28,95,196,0.08);
}
.audit-item.collapsed .audit-body { display: none; }

.audit-head {
    display: grid;
    grid-template-columns: 20px 170px 130px 90px minmax(0, 1fr) 100px auto;
    gap: 10px;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
}
.audit-head:hover { background: #f0f4f9; }
.audit-item:not(.collapsed) .audit-head { border-bottom: 1px solid var(--border); background: #f8fafc; }

.audit-ts       { color: var(--text); font-size: 12px; }
.audit-user     { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-entity   { justify-self: start; }
.audit-eid      { color: var(--muted); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-action   { justify-self: start; font-weight: 700; text-transform: uppercase; font-size: 10px; white-space: nowrap; }
.audit-action-create { background: #d1e7dd; color: #0f5132; }
.audit-action-update { background: #cfe2ff; color: #084298; }
.audit-action-delete { background: #f8d7da; color: #842029; }
.audit-changed-chip {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audit-body { padding: 14px; background: #fafbfc; }

.diff-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.diff-col-head {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 6px;
    padding: 0 4px;
}
.diff-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 320px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.diff-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

.diff-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px;
    padding: 6px 10px;
    font-size: 13px;
    border-bottom: 1px solid #f1f3f5;
    align-items: baseline;
}
.diff-row:last-child { border-bottom: none; }
.diff-key {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.diff-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.diff-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.diff-val {
    color: var(--text);
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* Farb-Hinterlegung nach Diff-Kind */
.diff-row.diff-changed { background: #fff8db; }         /* gelb: geändert */
.diff-row.diff-added   { background: #d1e7dd; }         /* grün: neu */
.diff-row.diff-removed { background: #f8d7da; }         /* rot: entfernt */
.diff-row.diff-same    { background: transparent; color: var(--muted); }
.diff-row.diff-same .diff-val { color: var(--muted); }

/* "same"-Zeilen standardmäßig ausblenden, außer show-unchanged aktiv */
.audit-list:not(.show-unchanged) .diff-row.diff-same { display: none; }

@media (max-width: 900px) {
    .audit-head {
        grid-template-columns: 20px 1fr auto;
        row-gap: 4px;
    }
    .audit-user, .audit-entity, .audit-eid, .audit-action { grid-column: 2; justify-self: start; }
    .audit-changed-chip { grid-column: 3; }
    .diff-grid { grid-template-columns: 1fr; }
    .diff-row { grid-template-columns: 120px 1fr; }
}

.entity-card.hidden-by-filter { display: none; }

/* ── T-056: Rot-Aufleuchten-Animation vor Verschwinden ──────────────────
   Alle 3 Entities (Mitarbeiter/Kunden/Maschinen) durchlaufen nach einem
   erfolgreichen Hard-Delete diese Sequenz: erst kurz rot aufleuchten
   (0 → 40 %), dann rot ausblenden + leicht nach oben verschieben +
   Höhe/Padding kollabieren, damit die Folge-Zeilen nachrücken ohne Sprung.
   Duration ~700 ms — schnell genug, dass Uwe nicht wartet, langsam genug
   dass er sieht *welche* Zeile weg ist. */
@keyframes row-delete-flash {
    0%   { background: #fee2e2; opacity: 1; transform: translateY(0); }
    40%  { background: #fecaca; opacity: 1; transform: translateY(0); }
    100% { background: transparent; opacity: 0; transform: translateY(-4px);
           max-height: 0; padding-top: 0; padding-bottom: 0;
           margin-top: 0; margin-bottom: 0; border-width: 0; }
}
.entity-card.row-delete-flash {
    animation: row-delete-flash 700ms ease-in forwards;
    overflow: hidden;
    pointer-events: none;
}
[data-theme="dark"] .entity-card.row-delete-flash {
    /* Dunkleres Rot im Dark-Mode, damit es auf dunklem Hintergrund glüht. */
    animation-name: row-delete-flash-dark;
}
@keyframes row-delete-flash-dark {
    0%   { background: rgba(220,53,69,.55); opacity: 1; transform: translateY(0); }
    40%  { background: rgba(220,53,69,.35); opacity: 1; transform: translateY(0); }
    100% { background: transparent; opacity: 0; transform: translateY(-4px);
           max-height: 0; padding-top: 0; padding-bottom: 0;
           margin-top: 0; margin-bottom: 0; border-width: 0; }
}

@media (max-width: 820px) {
    .head-grid,
    .head-grid--maschinen,
    .head-grid--kunden,
    .head-grid--mitarbeiter { grid-template-columns: 1fr auto; }
    .head-c2, .head-c4 { display: none; }
    .head-c3 { font-size: 13px; }
}

.v-popover {
    position: absolute;
    z-index: 200;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    padding: 10px 12px;
    max-width: 460px;
    min-width: 280px;
    font-size: 13px;
    line-height: 1.4;
}
.v-popover.hidden { display: none; }
.v-popover-header {
    font-weight: 600;
    color: var(--accent-dark);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin-bottom: 6px;
}
.v-popover-loading, .v-popover-empty {
    color: var(--muted);
    font-style: italic;
}
.v-popover-more {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    padding-top: 4px;
    border-top: 1px dashed var(--border);
    margin-top: 4px;
}
.v-row {
    padding: 4px 0;
    border-bottom: 1px dotted #e9edf1;
}
.v-row:last-child { border-bottom: none; }
.v-row-head {
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
    font-size: 12px;
}
.v-row-version {
    background: #eef3f9;
    color: var(--accent-dark);
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 700;
}
.v-row-ts {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    color: var(--muted);
}
.v-row-user {
    color: var(--text);
    font-weight: 500;
}
.v-row-value {
    display: block;
    margin-top: 2px;
    word-break: break-word;
    color: var(--text);
}

/* ── Audit-Log Seite (S.4b) ─────────────────────────────────────────────── */
.audit-filter {
    align-items: flex-end;
}
.audit-filter label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.audit-filter .field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.audit-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}
.audit-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}
.audit-table thead {
    background: #f6f8fb;
}
.audit-table th, .audit-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.audit-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}
.audit-table .mono {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
}
.audit-table .nowrap { white-space: nowrap; }
.audit-diff-cell {
    max-width: 320px;
    overflow-wrap: break-word;
}
.audit-diff-cell code {
    background: #f6f8fb;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: break-word;
}
.audit-pager {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
    flex-wrap: wrap;
}
.audit-retention-note {
    margin-top: 24px;
    font-size: 13px;
    text-align: center;
}
