/* Wowerk – ein Stylesheet, keine Fremd-Fonts (schnell auch im Mobilnetz) */
/*
 * Farbschemata – pro Benutzer unter „Mein Konto“ wählbar (<html data-theme="…">):
 *   system (wie Betriebssystem) · light · dark · sepia (augenschonend) · contrast (hoher Kontrast)
 */
:root {
    --bg: #f4f6f9; --surface: #fff; --surface-2: #f8fafc; --border: #e2e8f0; --text: #0f172a; --muted: #64748b;
    --primary: #0b6bcb; --primary-fg: #fff; --primary-soft: #e0efff; --danger: #dc2626; --danger-soft: #fee2e2; --danger-text: #7f1d1d;
    --warn: #b45309; --warn-soft: #fef3c7; --auto: #fef9c3; --auto-text: #1f1a05; --auto-border: #eab308;
    --danger-line: #dc2626; --danger-ring: rgba(220, 38, 38, .14); --warn-line: #d97706; --warn-ring: rgba(217, 119, 6, .14);
    --ok: #15803d; --ok-soft: #dcfce7; --new: #7c3aed; --new-soft: #ede9fe; --radius: 10px; --shadow: 0 1px 2px rgba(15, 23, 42, .06);
    --topbar: 56px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme=light]):not([data-theme=sepia]):not([data-theme=contrast]) {
        --bg: #0b1220; --surface: #111a2b; --surface-2: #162238; --border: #24324a; --text: #e2e8f0; --muted: #94a3b8;
        --primary: #4ea1ff; --primary-fg: #04121f; --primary-soft: #12304f; --warn-soft: #3b2a0a; --ok-soft: #0f2e1b; --new-soft: #2a1d4d;
        --danger-soft: #3a1212; --danger-text: #fecaca; color-scheme: dark;
        --auto: #2e2a12; --auto-text: #fef3c7; --auto-border: #a16207;
        --danger-line: #f87171; --danger-ring: rgba(248, 113, 113, .18); --warn-line: #fbbf24; --warn-ring: rgba(251, 191, 36, .15);
    }
}
:root[data-theme=dark] {
    --bg: #0b1220; --surface: #111a2b; --surface-2: #162238; --border: #24324a; --text: #e2e8f0; --muted: #94a3b8;
    --primary: #4ea1ff; --primary-fg: #04121f; --primary-soft: #12304f; --warn-soft: #3b2a0a; --ok-soft: #0f2e1b; --new-soft: #2a1d4d;
    --danger-soft: #3a1212; --danger-text: #fecaca; color-scheme: dark;
    --auto: #2e2a12; --auto-text: #fef3c7; --auto-border: #a16207;
    --danger-line: #f87171; --danger-ring: rgba(248, 113, 113, .18); --warn-line: #fbbf24; --warn-ring: rgba(251, 191, 36, .15);
}
/* Augenschonend: warmes Papier, wenig Blauanteil, weicher Kontrast – gut für lange Arbeit am iPad */
:root[data-theme=sepia] {
    --bg: #efe6d4; --surface: #f8f1e3; --surface-2: #f1e7d3; --border: #dccfb6; --text: #3b2f22; --muted: #7a6a55;
    --primary: #8a5a2b; --primary-fg: #fff8ec; --primary-soft: #eadbc0; --warn-soft: #f3e2bd; --ok-soft: #e1ebcf; --new-soft: #eadfd2;
    --new: #7b4b8c; --auto: #f6e7a8; --auto-border: #c9a227; --shadow: 0 1px 2px rgba(59, 47, 34, .08); color-scheme: light;
    --danger-line: #b42318; --warn-line: #a15c07;
}
/* Hoher Kontrast: schwarz auf weiß, kräftige Ränder und Farben */
:root[data-theme=contrast] {
    --bg: #fff; --surface: #fff; --surface-2: #f0f0f0; --border: #000; --text: #000; --muted: #222;
    --primary: #0033cc; --primary-fg: #fff; --primary-soft: #d6e0ff; --danger: #b00000; --danger-soft: #ffd6d6; --danger-text: #600;
    --warn: #7a3d00; --warn-soft: #ffe6b3; --ok: #005c1a; --ok-soft: #ccf0d6; --new: #5b00b3; --new-soft: #e6d6ff; --auto: #fff27a;
    --auto-border: #000; --danger-line: #b00000; --danger-ring: rgba(176, 0, 0, .25); --warn-line: #7a3d00; --warn-ring: rgba(122, 61, 0, .25);
    --shadow: none; color-scheme: light;
}
:root[data-theme=contrast] a { text-decoration: underline; }
:root[data-theme=contrast] .btn, :root[data-theme=contrast] input, :root[data-theme=contrast] select, :root[data-theme=contrast] textarea,
:root[data-theme=contrast] .card { border-width: 2px; }
:root[data-theme=contrast] :focus-visible { outline: 3px solid #ff8c00 !important; outline-offset: 2px; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
mark { background: #fde68a; color: #000; border-radius: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
@keyframes row-back { from { background: var(--new-soft); } }
tr.row-back td { animation: row-back 2.5s ease-out; }
.danger { color: var(--danger) !important; }
[hidden] { display: none !important; }

/* Kopfzeile + Navigation */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 1rem;
    padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: var(--primary-fg); font-size: 18px; }
.nav-toggle { display: none; background: none; border: 0; font-size: 22px; color: var(--text); cursor: pointer; padding: .25rem .5rem; }
.search { position: relative; flex: 1; max-width: 640px; }
.search input { width: 100%; padding: .55rem .9rem; border-radius: 999px; background: var(--surface-2); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 70vh; overflow: auto; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .18); padding: .25rem 0; }
.search-results h4 { margin: .5rem .9rem .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.search-results a { display: block; padding: .45rem .9rem; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--primary-soft); text-decoration: none; }
.search-results a span { display: block; font-size: .8rem; color: var(--muted); }
.search-results .all { border-top: 1px solid var(--border); color: var(--primary); }
/* Benutzermenü oben rechts */
.top-help { margin-left: auto; display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .75rem .3rem .3rem; border-radius: 999px;
    border: 1px solid var(--border); color: var(--text); font-weight: 600; text-decoration: none; white-space: nowrap; }
.top-help:hover, .top-help.active { background: var(--surface-2); color: var(--primary); }
.top-help-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem; border-radius: 50%;
    background: var(--primary); color: #fff; font-weight: 700; }
@media (max-width: 700px) { .top-help-text { display: none; } .top-help { padding: .3rem; } }
.top-feedback { margin-left: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.nav-count { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; background: var(--warn); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1.3rem; text-align: center; }
.nav-count[hidden] { display: none; }
.link-btn { border: 0; padding: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
.imp-bar { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: .75rem; max-width: calc(100vw - 2rem);
    padding: .45rem .6rem .45rem 1rem; border-radius: 999px; background: var(--warn); color: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); font-size: .9rem; }
.notice-target { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; border: 0; padding: 0; margin: 0; }
.notice-target legend { font-weight: 600; padding: 0; margin-bottom: .25rem; }
.notice-meta { margin: 0 0 .5rem; }
#notice-form { display: grid; gap: .7rem; }
.notice-list { max-width: 1100px; margin-top: 1rem; }
.fb-form { display: grid; gap: .6rem; white-space: normal; }
.fb-form p { margin: 0; }
.fb-item { margin-bottom: .6rem; }
.fb-head { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; }
.fb-body { margin: .5rem 0 .6rem; overflow-wrap: anywhere; }
.fb-tabs button.tab { border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; font-weight: 600; cursor: pointer; }
.user-menu { position: relative; }
.user-menu > summary { display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .25rem; border-radius: 999px;
    cursor: pointer; list-style: none; border: 1px solid transparent; user-select: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--surface-2); border-color: var(--border); }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
    color: var(--primary-fg); font-size: .8rem; font-weight: 700; letter-spacing: .02em; flex-shrink: 0; }
.user-text { display: flex; flex-direction: column; line-height: 1.15; max-width: 180px; }
.user-text strong { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text small { font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { font-size: .7rem; color: var(--muted); }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; padding: .35rem; z-index: 50;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .22); }
.user-dropdown-head { display: flex; flex-direction: column; padding: .5rem .65rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.user-dropdown-head small { color: var(--muted); font-size: .75rem; }
.user-dropdown a, .user-dropdown button { display: block; width: 100%; text-align: left; padding: .55rem .65rem; border-radius: 8px;
    color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.user-dropdown form { margin: .2rem 0 0; padding-top: .2rem; border-top: 1px solid var(--border); }
.user-dropdown button { color: var(--danger-line); font-weight: 600; }
.shell { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidenav { width: 230px; flex-shrink: 0; padding: 1rem .75rem; background: var(--surface); border-right: 1px solid var(--border);
    position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow: auto; display: flex; flex-direction: column; }
.sidenav a { display: block; padding: .55rem .75rem; border-radius: 8px; color: var(--text); }
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidenav .nav-cta { margin: .5rem 0; background: var(--primary); color: var(--primary-fg); text-align: center; font-weight: 600; }
.sidenav .nav-cta:hover { background: var(--primary); filter: brightness(1.08); }
.nav-group { margin-top: .15rem; }
.nav-group > summary { display: flex; align-items: center; gap: .4rem; padding: .55rem .75rem; border-radius: 8px; color: var(--text); font-weight: 600; cursor: pointer; list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: var(--surface-2); }
.nav-arrow { width: .45rem; height: .45rem; margin-left: auto; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.nav-group[open] > summary .nav-arrow { transform: rotate(45deg); }
.nav-group[open] > summary .nav-count { display: none; }
.nav-group > a { margin-left: .75rem; padding-left: .75rem; border-left: 2px solid var(--border); border-radius: 0 8px 8px 0; font-size: .95rem; }
.nav-group > a.active { border-left-color: var(--primary); }
.nav-sep { margin: .6rem .75rem; border-top: 1px solid var(--border); }
.nav-label { margin: 1.1rem .75rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.main { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 3rem; max-width: 1400px; }

/* Bausteine */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.lead { margin: .25rem 0 0; color: var(--muted); font-size: 1.05rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-2 > .span-2 { grid-column: 1 / -1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat strong { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat-hl { background: var(--new-soft); border-color: var(--new); }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row > form { margin: 0; }
.btn-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
.actions { display: flex; gap: .5rem; margin-top: .5rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-icon { font-size: 3rem; font-weight: 800; color: var(--border); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* Formulare */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: .55rem .7rem; min-height: 42px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); flex-shrink: 0; }
input[type=color] { padding: 2px; width: 44px; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; cursor: pointer; }
.input-sm { min-height: 34px; padding: .3rem .55rem; width: auto; }
.input-xs { width: 80px; min-height: 34px; padding: .3rem .5rem; }
input.strong { font-weight: 700; width: auto; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; margin: 0; }
legend { padding: 0 .4rem; font-weight: 600; font-size: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid .span-all { grid-column: 1 / -1; }
.quick { background: var(--primary-soft); padding: .75rem; border-radius: var(--radius); }
.req { color: var(--danger); font-weight: 700; }

/* Gegliederte Formulare (Neues Objekt / Auftrag bearbeiten) */
.form-card { max-width: 1100px; padding: 1.25rem 1.5rem; }
.form-section-title { font-size: 1rem; margin: 0 0 .75rem; }
.form-section { border: 0; border-top: 1px solid var(--border); padding: 1rem 0 .25rem; margin: 0; }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section legend { padding: 0; margin-bottom: .75rem; font-size: .8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--primary); float: left; width: 100%; }
.form-section legend + * { clear: both; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem 1rem; align-items: start; }
.grid-4 .c2 { grid-column: span 2; }
.form-footer { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    margin: 1rem -1.5rem -1.25rem; padding: .85rem 1.5rem; background: var(--surface); border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius); }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: stretch; }
.quick-grid .sheet-drop { flex-direction: column; gap: .4rem; }
.quick-side { display: grid; gap: .75rem; align-content: start; min-width: 0; }
.folder-info { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .6rem 0 0; }
.quick-name { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
@media (max-width: 900px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quick-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .grid-4 { grid-template-columns: 1fr; }
    .grid-4 .c2 { grid-column: auto; }
    .form-card { padding: 1rem; }
    .form-footer { margin: 1rem -1rem -1rem; padding: .75rem 1rem; }
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
input.auto, select.auto, textarea.auto { background: var(--auto); color: var(--auto-text); border-color: var(--auto-border); }
.sheet-drop { border: 2px dashed var(--primary); border-radius: var(--radius); padding: 1rem; text-align: center; background: var(--surface-2);
    display: flex; gap: .75rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.sheet-drop[hidden] { display: none; }
.sheet-drop.over { background: var(--primary); color: var(--primary-fg); }
.sheet-drop label { flex-direction: row; }
.sheet-result { margin-top: .75rem; }
.sheet-status { margin-bottom: .5rem; }
#sheet-preview { display: block; width: 100%; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .25rem .75rem; max-height: 320px; overflow: auto; padding: .35rem 0; }
.filter-list { margin-bottom: .35rem; }
.firm-list { max-height: 460px; overflow: auto; padding-right: .25rem; }
.assign .firm-list { max-height: none; overflow: visible; padding-right: 0; }
.firm-group h4 { position: sticky; top: 0; z-index: 1; margin: .5rem 0 .25rem; padding: .35rem 0; background: var(--surface);
    font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--primary); }
.firm-group.no-trade h4 { color: var(--warn); border-bottom-color: var(--warn); }
.firm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .15rem .75rem; }
label.firm { flex-direction: row; align-items: flex-start; gap: .5rem; padding: .35rem .25rem; border-radius: 6px; font-weight: 400; cursor: pointer; }
label.firm:hover { background: var(--surface-2); }
label.firm input { margin-top: .15rem; }
label.firm small { display: block; line-height: 1.3; }
.checklist-head { grid-column: 1 / -1; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: .4rem; }
.import-table td { vertical-align: middle; }
.import-table .input-sm { min-width: 150px; }
.code-input { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem; }
.filters select, .filters input { width: auto; min-width: 140px; }
.filters .grow { flex: 1; min-width: 220px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 40px; padding: .45rem .95rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 32px; padding: .2rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

/* Hinweise, Abzeichen, Status */
.alert { position: relative; padding: .7rem 2.6rem .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid;
    transition: opacity .3s, transform .3s; }
.alert-hide { opacity: 0; transform: translateY(-6px); }
.alert-close { position: absolute; top: .35rem; right: .4rem; width: 32px; height: 32px; border: 0; background: transparent;
    color: inherit; opacity: .6; cursor: pointer; font-size: 1rem; border-radius: 6px; }
.alert-close:hover { opacity: 1; background: rgba(127, 127, 127, .15); }
.alert-success { background: var(--ok-soft); border-color: var(--ok); }
.alert-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger-text); }
.alert-info { background: var(--primary-soft); border-color: var(--primary); }
.badge { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); vertical-align: middle; }
.badge-new { background: var(--new-soft); color: var(--new); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.status { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; vertical-align: middle; }
.status-neu { background: var(--new-soft); color: var(--new); }
.status-in_arbeit { background: var(--warn-soft); color: var(--warn); }
.status-erledigt { background: var(--ok-soft); color: var(--ok); }
.status-archiviert { background: var(--surface-2); color: var(--muted); }

/* Tabellen */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tr[data-href] { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--new); }
.table tr.inactive { opacity: .55; }
.table .num { text-align: right; }
.table.compact td { padding: .3rem .4rem; border: 0; }
.matrix td.center, .matrix th { text-align: center; }
.matrix td:first-child { text-align: left; }
.matrix tr.hl { background: var(--primary-soft); }
.pager { display: flex; gap: .3rem; justify-content: center; align-items: center; margin: 1rem 0; }
.pager a { padding: .35rem .7rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }
.pager a.active { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .45rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.meter { display: inline-block; width: 80px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.meter span { display: block; height: 100%; background: var(--ok); }

/* Dateien */
.ficon { display: inline-grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 6px; font-size: .62rem; font-weight: 800;
    text-transform: uppercase; color: #fff; background: #64748b; }
.ficon::after { content: "DATEI"; }
.ficon-pdf { background: #dc2626; } .ficon-pdf::after { content: "PDF"; }
.ficon-img { background: #0891b2; } .ficon-img::after { content: "BILD"; }
.ficon-doc { background: #2563eb; } .ficon-doc::after { content: "DOC"; }
.ficon-xls { background: #16a34a; } .ficon-xls::after { content: "XLS"; }
.ficon-cad { background: #9333ea; } .ficon-cad::after { content: "CAD"; }
.ficon-zip { background: #a16207; } .ficon-zip::after { content: "ZIP"; }
.ficon-vid { background: #db2777; } .ficon-vid::after { content: "VIDEO"; }
.ficon-folder { background: #f59e0b; width: 22px; height: 18px; border-radius: 3px; } .ficon-folder::after { content: ""; }
.ficon-big { width: 72px; height: 72px; font-size: .9rem; }
.folder { border-top: 1px solid var(--border); }
.folder > summary { cursor: pointer; padding: .55rem .2rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; list-style: none; }
.folder > summary::-webkit-details-marker { display: none; }
.file-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.file { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: .75rem; padding: .35rem .4rem; border-radius: 8px; }
.file:hover { background: var(--surface-2); }
.file.is-new { background: var(--new-soft); }
.file-main { display: flex; align-items: center; gap: .65rem; color: var(--text); min-width: 0; }
.file-main:hover { text-decoration: none; }
.file-name { overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; background: var(--surface-2); flex-shrink: 0; }
.file-actions { display: flex; gap: .1rem; }
.file-actions form { margin: 0; }
.seen { white-space: nowrap; cursor: help; }
.seen-yes { color: var(--ok); }
.seen-no { color: var(--muted); }
.view-switch .btn.active { background: var(--primary-soft); border-color: var(--primary); }
/* Kacheln: alle gleich groß, Inhalt bleibt in der Kachel */
.files[data-mode=grid] .file-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.files[data-mode=grid] .file { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--border);
    border-radius: 10px; padding: 0; gap: 0; background: var(--surface); }
.files[data-mode=grid] .file:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.files[data-mode=grid] .file-main { flex-direction: column; align-items: stretch; gap: 0; text-align: center; min-width: 0; }
.files[data-mode=grid] .file-main .thumb, .files[data-mode=grid] .file-main .ficon, .files[data-mode=grid] .file-main .pdf-thumb {
    width: 100%; height: 140px; border-radius: 0; flex-shrink: 0; }
.files[data-mode=grid] .file-main .thumb { object-fit: cover; }
.files[data-mode=grid] .file-main .ficon { font-size: .9rem; letter-spacing: .08em; opacity: .9; }
.files[data-mode=grid] .file-name { padding: .5rem .6rem 0; font-size: .85rem; line-height: 1.3; min-height: calc(2 * 1.3em + .5rem);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; overflow: hidden; word-break: break-word; }
.files[data-mode=grid] .file-name .badge { display: none; }
.files[data-mode=grid] .file-meta, .files[data-mode=grid] .seen { display: block; padding: .15rem .6rem 0; font-size: .72rem; text-align: center; }
.files[data-mode=grid] .file-actions { margin-top: auto; padding: .4rem .5rem .5rem; justify-content: center; flex-wrap: wrap; gap: .25rem; }
.files[data-mode=grid] .file-actions .btn-tour { width: 100%; }
.files[data-mode=grid] .file.is-new { box-shadow: inset 0 3px 0 var(--new); }
/* Vorschau der ersten PDF-Seite (wird beim Hinscrollen gerendert) */
/* Nur in der Kachel-Ansicht: Vorschaufläche; in der Liste bleibt das kleine PDF-Symbol */
.files[data-mode=grid] .pdf-thumb { display: block; background: #fff; overflow: hidden; position: relative; }
.files[data-mode=grid] .pdf-thumb canvas { display: block; width: 100%; height: auto; }
.files[data-mode=grid] .pdf-thumb .ficon { position: absolute; inset: 0; width: 100%; height: 100%; }
.files[data-mode=grid] .pdf-thumb canvas + .ficon { display: none; }
.files[data-mode=list] .pdf-thumb { display: inline-flex; flex-shrink: 0; }
.files[data-mode=list] .pdf-thumb canvas { display: none; }

/* Upload */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; text-align: center; background: var(--surface-2); transition: .15s; }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone p { margin: 0 0 .5rem; display: flex; gap: .5rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.dropzone .row { justify-content: center; }
.dropzone label { flex-direction: row; align-items: center; }
.upload-list { list-style: none; margin: .75rem 0 0; padding: 0; text-align: left; max-height: 240px; overflow: auto; }
.upload-list li { display: grid; grid-template-columns: 1fr 120px; gap: .5rem; align-items: center; font-size: .85rem; padding: .15rem 0; }
.upload-list progress { width: 100%; height: 8px; }
.upload-list .err { color: var(--danger); grid-column: 1 / -1; }
.show-touch { display: none !important; }
@media (pointer: coarse) { .show-touch { display: inline-flex !important; } .hide-touch { display: none !important; } }

/* Nachrichten */
.messages { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.msg { background: var(--surface-2); border-radius: 10px; padding: .55rem .8rem; max-width: 80%; }
.msg.mine { align-self: flex-end; background: var(--primary-soft); }
.msg-head { margin-bottom: .15rem; }
.msg-card .messages { max-height: 22rem; overflow-y: auto; margin: .75rem 0 0; padding-right: .25rem; }
.msg-form { margin-bottom: 0; }
.msg-form .row { align-items: center; }
.msg-send { justify-content: space-between; flex-wrap: nowrap; }
.assign-send .btn { margin-left: auto; }
.msg-send .btn { margin-left: auto; flex-shrink: 0; }
.msg.unread { box-shadow: inset 3px 0 0 var(--new); }
.dash-msgs { border-left: 4px solid var(--primary); }
.dash-msgs .msg-item { display: block; padding: .5rem .25rem; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.dash-msgs .msg-item:last-child { border-bottom: 0; }
.dash-msgs .msg-item:hover { background: var(--surface-2); }
.dash-msgs .msg-item.unread .msg-text { font-weight: 600; }
.dash-msgs .msg-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assign { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .5rem; }
/* Status per Klick (Auftragsseite) */
.status-switch { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: -.25rem 0 1rem; }
/* Andere Status: neutrale Umriss-Knöpfe; aktueller Status: kräftig in seiner Farbe ausgefüllt */
.status-btn, .status-btn.status-neu, .status-btn.status-in_arbeit, .status-btn.status-erledigt, .status-btn.status-archiviert {
    font: inherit; font-size: .85rem; font-weight: 600; min-height: 36px; padding: .3rem .95rem; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.status-btn:hover:not(:disabled) { color: var(--text); border-color: var(--text); }
.status-btn.current { color: #fff; cursor: default; border-color: transparent; }
.status-btn.current::before { content: '✓ '; }
.status-btn.current.status-neu { background: var(--new); }
.status-btn.current.status-in_arbeit { background: #d97706; }
.status-btn.current.status-erledigt { background: #16a34a; }
.status-btn.current.status-archiviert { background: #64748b; }
.danger-zone { border-color: var(--border); padding: .85rem 1.5rem; }
.danger-zone[open] { border-color: var(--danger); }
.danger-zone > summary { cursor: pointer; color: var(--danger); font-weight: 600; list-style: none; }
.danger-zone > summary::-webkit-details-marker { display: none; }
.danger-zone > summary::before { content: '▸ '; }
.danger-zone[open] > summary::before { content: '▾ '; }
.danger-zone form { margin-top: .75rem; }
.danger-row { display: grid; grid-template-columns: minmax(0, 320px) auto; gap: .75rem; align-items: end; justify-content: start; }
@media (max-width: 560px) { .danger-row { grid-template-columns: 1fr; } }

/* Anzeige & Editoren */
.viewer-head { position: sticky; top: var(--topbar); z-index: 10; background: var(--bg); padding: .5rem 0; margin-bottom: .5rem; }
.file-title { font-size: 1.15rem; word-break: break-word; }
.pdf-viewer { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0 40px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); max-width: 100%; }
.pdf-page canvas { display: block; width: 100%; height: auto; }
.pdf-page .ink { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y pinch-zoom; }
.editing .pdf-page .ink { cursor: crosshair; }
.editing:not(.tool-form) .pdf-page .ink { touch-action: none; }
.editing.tool-select .pdf-page .ink { cursor: default; }
.editing.tool-select .pdf-page .fields > .note { pointer-events: none; }
.pdf-page .fields .note.selected { outline: 2px solid #0b6bcb; outline-offset: 1px; }
.editing.tool-form .pdf-page .ink { pointer-events: none; }
.editing .pdf-viewer.pencil .pdf-page .ink { touch-action: pan-y pinch-zoom; } /* Apple Pencil schreibt, Finger scrollt */
.editing .pdf-page .fields > input:not([type=checkbox]):not([type=radio]), .editing .pdf-page .fields > textarea:not(.note), .editing .pdf-page .fields > select { background: #eef4ff; }
.pdf-page .fields { position: absolute; inset: 0; pointer-events: none; }
.pdf-page .fields > * { pointer-events: none; }
.editing.tool-form .pdf-page .fields > *, .editing .pdf-page .fields > .note { pointer-events: auto; }
.pdf-page .fields > * { position: absolute; margin: 0; min-height: 0; border-radius: 2px; padding: 0 2px; font-family: Helvetica, Arial, sans-serif;
    background: rgba(37, 99, 235, .1); border: 1px solid rgba(37, 99, 235, .45); color: #000; }
.pdf-page .fields textarea { resize: none; line-height: 1.15; }
.pdf-page .fields input[type=checkbox], .pdf-page .fields input[type=radio] { accent-color: #1d4ed8; width: auto; height: auto; padding: 0; }
.pdf-page .fields .note { background: rgba(253, 230, 138, .55); border: 1px dashed #b45309; min-width: 60px; }
.pdf-page .page-no { position: absolute; bottom: -20px; right: 0; font-size: .75rem; color: var(--muted); }
.loading { padding: 3rem; color: var(--muted); }
.editor-toolbar { position: sticky; top: calc(var(--topbar) + 54px); z-index: 11; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.tool-group { display: flex; gap: .3rem; align-items: center; }
.tool { min-height: 40px; min-width: 40px; padding: .3rem .65rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.tool.active { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.tool-group select { width: auto; min-height: 40px; }
#img-toolbar { justify-content: center; }
.tool:disabled { opacity: .4; cursor: default; }
.ico { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool:has(.ico) { display: inline-flex; align-items: center; justify-content: center; padding: 0; width: 40px; }
.tool:not(:disabled):not(.active):not(.tool-primary):hover { background: var(--surface-2); color: var(--primary); }
.ctx-menu { position: fixed; z-index: 70; min-width: 210px; padding: .3rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 10px 30px rgba(0, 0, 0, .22); }
.ctx-menu button { display: flex; justify-content: space-between; gap: 1.5rem; width: 100%; padding: .42rem .65rem; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: .92rem; text-align: left; cursor: pointer; }
.ctx-menu button:hover:not(:disabled), .ctx-menu button:focus-visible { background: var(--primary-soft); color: var(--primary); outline: 0; }
.ctx-menu button:disabled { color: var(--muted); opacity: .55; cursor: default; }
.ctx-menu kbd { font: inherit; font-size: .8rem; color: var(--muted); background: none; border: 0; padding: 0; }
.ctx-menu hr { margin: .25rem .3rem; border: 0; border-top: 1px solid var(--border); }
.ctx-menu .ctx-danger { color: var(--danger, #c0262d); }
.tool-primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.img-text-size { display: flex; flex-direction: row; align-items: center; gap: .35rem; font-size: .85rem; }
.img-text-size input { width: 110px; min-height: 0; padding: 0; }
.img-text-size span { min-width: 1.8rem; text-align: right; font-variant-numeric: tabular-nums; }
.image-viewer { display: flex; justify-content: center; padding: .5rem 0 2rem; }
.image-viewer img, .image-viewer canvas { max-width: 100%; max-height: calc(100vh - 200px); box-shadow: 0 2px 10px rgba(0, 0, 0, .15); background: #fff; }
.image-viewer canvas { touch-action: none; cursor: crosshair; }
.video { width: 100%; max-height: 75vh; background: #000; border-radius: var(--radius); }
.totp-setup { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
#qrcode { width: 200px; background: #fff; padding: 6px; border-radius: 8px; }
#qrcode svg { display: block; width: 100%; height: auto; }
.secret { font-size: 1rem; letter-spacing: .08em; word-break: break-all; }
.area-block { padding: .5rem 0 1rem; border-bottom: 1px solid var(--border); margin-bottom: .75rem; }

/* Modal (ersetzt alle Browser-Popups) */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 1rem;
    background: rgba(15, 23, 42, .55); }
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 480px; max-height: 85vh; overflow: auto; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem 1.25rem 1rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.modal h2 { margin: 0 0 .6rem; font-size: 1.1rem; }
.modal-body { white-space: pre-line; }
.modal-body ul { margin: .5rem 0 0; padding-left: 1.2rem; white-space: normal; }
.modal-input { margin-top: .75rem; }
.modal-input:empty { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; margin-top: 1.1rem; }
.modal-actions .btn { min-height: 44px; }

/* Logos der Auftraggeber – immer auf weißem Grund, damit sie auch im Dunkel-Modus sauber wirken */
.logo-chip { display: inline-flex; align-items: center; justify-content: center; background: #fff; border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, .08); flex-shrink: 0; }
.logo-chip img { display: block; width: auto; }
.logo-chip.has-place { flex-direction: column; gap: 1px; }
.logo-place { font-size: .6rem; line-height: 1; font-weight: 600; color: #4b5563; } /* Chip ist immer weiß, auch im Dunkelmodus */
.logo-md .logo-place, .logo-lg .logo-place { font-size: .75rem; }
.logo-xs { padding: 2px 4px; } .logo-xs img { height: 16px; max-width: 46px; }
.logo-sm { padding: 3px 6px; } .logo-sm img { height: 22px; }
.logo-md { padding: 6px 10px; border-radius: 8px; } .logo-md img { height: 40px; }
.logo-lg { padding: 8px 14px; border-radius: 10px; } .logo-lg img { height: 46px; }
.topbar-logos { display: flex; gap: .4rem; align-items: center; }
.guest-logos { display: flex; justify-content: center; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.order-head { display: flex; gap: 1rem; align-items: flex-start; }
.addr-cell { display: flex; gap: .55rem; align-items: flex-start; }
.addr-cell .logo-chip, .addr-cell .logo-slot { margin-top: 2px; width: 54px; flex-shrink: 0; } /* gleiche Breite → Adressen bündig */
@media (max-width: 1100px) { .topbar-logos { display: none; } }
@media (max-width: 640px) { .order-head .logo-chip { display: none; } }

/* Bitte warten (Sicherung …) */
.busy .modal { max-width: 360px; text-align: center; }
.spinner { width: 42px; height: 42px; margin: .5rem auto 1rem; border: 4px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Sicherung */
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; overflow-x: auto;
    font-size: .85rem; user-select: all; }
.backup-actions { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.restore-card { border-color: var(--danger-line); }
.restore-card ol { margin: 0; padding-left: 1.2rem; line-height: 1.6; }

/* Web-Inhalt im Modal (360°-Rundgang) */
body.no-scroll { overflow: hidden; }
.web-backdrop { padding: 2vh 2vw; }
.web-box { display: flex; flex-direction: column; width: min(1200px, 94vw); height: 82vh; min-width: 320px; min-height: 260px;
    max-width: 100vw; max-height: 100vh; resize: both; overflow: hidden; background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); }
.web-box.max { width: 100vw !important; height: 100vh !important; border-radius: 0; resize: none; }
.web-backdrop:has(.web-box.max) { padding: 0; }
.web-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.web-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.web-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.web-body { position: relative; flex: 1; background: #000; }
.web-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; }
.web-hint { position: absolute; inset: auto 0 1rem; text-align: center; z-index: 0; color: #ccc; }
.web-body iframe { z-index: 1; }
.tour-gone { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem;
    padding: 1.5rem; overflow: auto; text-align: center; background: var(--surface); color: var(--text); }
.tour-gone h3 { margin: .4rem 0 0; font-size: 1.25rem; }
.tour-gone p { max-width: 34rem; margin: 0; color: var(--muted); }
.tour-gone address { display: flex; flex-direction: column; gap: .1rem; font-style: normal; margin-bottom: .4rem; }
.btn-tour { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.btn-tour:hover { filter: brightness(1.1); border-color: #7c3aed; }
.btn-vr { min-height: 30px; padding: .15rem .55rem; font-size: .8rem; white-space: nowrap; }
.table .center { text-align: center; }
.link-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.pdf-page .pdf-links { position: absolute; inset: 0; pointer-events: none; }
.pdf-page .pdf-links a { position: absolute; pointer-events: auto; border-radius: 2px; }
.pdf-page .pdf-links a:hover { background: rgba(124, 58, 237, .18); outline: 2px solid rgba(124, 58, 237, .6); }
.editing .pdf-page .pdf-links { display: none; }

/* Prüfung von Formularfeldern */
/* Fehler: rot umrandet (Feld bleibt normal). Hinweis „bitte prüfen“: orange umrandet. */
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-ring); }
input.warn, select.warn, textarea.warn { border-color: var(--warn-line) !important; box-shadow: 0 0 0 3px var(--warn-ring); }
.field-msg { color: var(--danger-line); font-size: .8rem; font-weight: 500; }
.field-msg.warn { color: var(--warn-line); }
.field-msg::before { content: '● '; font-size: .6rem; vertical-align: middle; }
.check-summary { border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger-text); border-radius: var(--radius); padding: .6rem .9rem; }
.check-summary.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }

/* Zugriffsprotokoll */
.log-filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.4fr) 150px 150px auto; gap: .75rem; align-items: end; }
.log-reset { min-height: 42px; display: flex; align-items: center; }
.log-card { padding: 0; overflow: hidden; }
.log-card > p { padding: 1rem; margin: 0; }
.log-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.log-table col.c-time { width: 70px; } .log-table col.c-user { width: 24%; } .log-table col.c-act { width: 30%; }
.log-table col.c-obj { width: auto; } .log-table col.c-ip { width: 110px; }
.log-table th, .log-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.log-table thead th { background: var(--surface-2); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.log-table .day-row th { background: var(--bg); color: var(--primary); font-size: .8rem; font-weight: 700; padding: .45rem .75rem; }
.log-table tbody tr:not(.day-row):hover td { background: var(--surface-2); }
.log-table .ellipsis { overflow: hidden; text-overflow: ellipsis; }
.log-table td.ellipsis { white-space: normal; }
.act { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap;
    background: var(--surface-2); color: var(--text); }
.act-view { background: var(--primary-soft); color: var(--primary); }
.act-down { background: #ccfbf1; color: #0f766e; }
.act-up { background: var(--ok-soft); color: var(--ok); }
.act-del { background: var(--danger-soft); color: var(--danger); }
.act-mail { background: var(--new-soft); color: var(--new); }
.act-tour { background: #7c3aed; color: #fff; }
.act-order { background: var(--warn-soft); color: var(--warn); }
@media (max-width: 1100px) { .log-filters { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 640px) { .log-filters { grid-template-columns: 1fr 1fr; } .log-table { min-width: 640px; } }

/* Rollen & Rechte */
.roles-card { max-width: 1200px; }
.role-matrix { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; border: 1px solid var(--border); border-radius: var(--radius); }
.role-matrix th, .role-matrix td { padding: .55rem .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.role-matrix tr:last-child td { border-bottom: 0; }
.role-matrix .perm-col { width: 34%; }
.role-matrix thead th { background: var(--surface-2); vertical-align: bottom; }
.role-matrix thead .perm-col { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.role-col input { width: 100%; min-height: 36px; padding: .3rem .4rem; font-size: .82rem; font-weight: 600; text-align: center; text-overflow: ellipsis; }
.role-meta { display: flex; justify-content: center; align-items: center; gap: .4rem; margin-top: .3rem; font-size: .75rem; font-weight: 500;
    color: var(--muted); flex-wrap: wrap; min-height: 1.4rem; }
.role-matrix .center { text-align: center; }
.role-matrix .group-row th { background: transparent; padding: .9rem .75rem .3rem; font-size: .75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--primary); }
.role-matrix tbody tr:not(.group-row):hover td { background: var(--surface-2); }
.role-matrix tr.hl td { background: var(--primary-soft); }
.role-matrix input[type=checkbox] { width: 22px; height: 22px; }
.align-end { align-self: end; min-height: 42px; }
@media (max-width: 900px) { .role-matrix { min-width: 720px; } }

/* Bereiche & Teams */
.area-head { display: grid; grid-template-columns: minmax(0, 2fr) 140px auto; gap: 1rem; align-items: end; margin-bottom: .75rem; }
.area-head input.strong { font-weight: 700; width: 100%; }
.area-head .check { align-self: center; }
.team-table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.team-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) 110px minmax(0, 1.6fr) 80px; gap: .75rem;
    align-items: center; padding: .45rem .75rem; border-top: 1px solid var(--border); }
.team-row:first-child { border-top: 0; }
.team-row input, .team-row select { min-height: 38px; }
.team-head { background: var(--surface-2); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.team-row .center { text-align: center; }
.team-table > p { margin: 0; padding: .6rem .75rem; }
@media (max-width: 900px) {
    .team-row { grid-template-columns: 1fr 1fr; }
    .team-head { display: none; }
    .area-head { grid-template-columns: 1fr 120px; }
}

/* Farbschema-Auswahl (Mein Konto) */
.theme-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
label.theme-choice { flex-direction: column; align-items: stretch; gap: .4rem; padding: .6rem; border: 2px solid var(--border);
    border-radius: 10px; cursor: pointer; font-weight: 500; position: relative; }
label.theme-choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.theme-choice input { position: absolute; top: .6rem; right: .6rem; }
.theme-swatch { display: grid; grid-template-columns: 2fr 1fr 1fr; height: 54px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .15); }
.theme-swatch i { display: block; }
.theme-swatch-light i:nth-child(1) { background: #f4f6f9; } .theme-swatch-light i:nth-child(2) { background: #fff; } .theme-swatch-light i:nth-child(3) { background: #0b6bcb; }
.theme-swatch-dark i:nth-child(1) { background: #0b1220; } .theme-swatch-dark i:nth-child(2) { background: #111a2b; } .theme-swatch-dark i:nth-child(3) { background: #4ea1ff; }
.theme-swatch-sepia i:nth-child(1) { background: #efe6d4; } .theme-swatch-sepia i:nth-child(2) { background: #f8f1e3; } .theme-swatch-sepia i:nth-child(3) { background: #8a5a2b; }
.theme-swatch-contrast i:nth-child(1) { background: #fff; } .theme-swatch-contrast i:nth-child(2) { background: #000; } .theme-swatch-contrast i:nth-child(3) { background: #0033cc; }
.theme-swatch-system { background: linear-gradient(135deg, #f4f6f9 50%, #0b1220 50%); }
.theme-swatch-system i { display: none; }

/* Anmeldung */
body.guest { display: grid; place-items: center; min-height: 100vh; padding: 1rem; background: linear-gradient(160deg, var(--primary-soft), var(--bg)); }
.guest-box { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem 1.75rem; box-shadow: 0 10px 40px rgba(15, 23, 42, .12); }
.brand-big { display: flex; align-items: center; justify-content: center; gap: .6rem; font-size: 1.5rem; font-weight: 800; }
.guest-box h2 { margin-top: .5rem; }

/* Tablet / Handy */
@media (max-width: 1100px) { .hide-md { display: none; } }
@media (max-width: 900px) {
    .nav-toggle { display: block; }
    .sidenav { position: fixed; left: 0; top: var(--topbar); z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0, 0, 0, .2); }
    .sidenav.open { transform: none; }
    .main { padding: 1rem; }
    .grid-2 { grid-template-columns: 1fr; }
    .user-text, .caret { display: none; }
    .brand span:last-child { display: none; }
}
@media (max-width: 640px) {
    .hide-sm { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .file { grid-template-columns: 1fr auto; }
    .file-meta, .seen { grid-column: 1 / -1; padding-left: 48px; }
    .msg { max-width: 95%; }
    .filters select, .filters input { flex: 1 1 140px; }
}
@media print {
    .topbar, .sidenav, .btn, .dropzone, .editor-toolbar, form { display: none !important; }
    .main { padding: 0; }
    .card { box-shadow: none; border: 0; }
}

/* Rundgang nicht erreichbar: rot, durchgestrichen, mit Kreuz */
.btn-tour.is-offline, .btn-tour.is-offline:hover { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-line);
    text-decoration: line-through; text-decoration-thickness: 2px; position: relative; }
.btn-tour.is-offline::after { content: "✕"; position: absolute; top: -.45rem; right: -.45rem; width: 1.05rem; height: 1.05rem; border-radius: 50%;
    background: var(--danger); color: #fff; font-size: .65rem; line-height: 1.05rem; text-align: center; text-decoration: none; font-weight: 700; }

/* Einstellungen: E-Mail-Konto & Systemprüfung */
.mail-account .form-grid + .form-grid { margin-top: .9rem; }
.mail-account .form-grid.inner { grid-template-columns: 1fr 1.4fr; gap: 1rem; }
.mail-account .btn-row { margin-top: .9rem; }
.btn-row.end { justify-content: flex-end; }
.check-pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-weight: 600; margin-right: .3rem; }
.check-pill.ok { background: var(--ok-soft); color: var(--ok); }
.check-pill.warn { background: var(--warn-soft); color: var(--warn); }
.check-pill.fail { background: var(--danger-soft); color: var(--danger-text); }
.table.checks .group-row th { background: transparent; padding: .9rem .5rem .3rem; font-size: .75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); }
.table.checks td { vertical-align: top; }
.check-icon { width: 2rem; }
.check-icon span { display: inline-block; width: 1.3rem; height: 1.3rem; border-radius: 50%; text-align: center; line-height: 1.3rem; font-size: .75rem; font-weight: 700; color: #fff; }
.check-ok .check-icon span { background: var(--ok); }
.check-warn .check-icon span { background: var(--warn); }
.check-fail .check-icon span { background: var(--danger); }
.check-fail td { background: var(--danger-soft); }
@media (max-width: 640px) { .mail-account .form-grid, .mail-account .form-grid.inner { grid-template-columns: 1fr; } }

/* Seitenleiste unten: Sicherheits-Schild & Ersteller */
.nav-foot { margin-top: auto; padding-top: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.sec-badge { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .65rem; border-radius: 12px; cursor: pointer;
    font: inherit; text-align: left; border: 1px solid var(--ok); background: var(--ok-soft); color: var(--text); transition: transform .15s; }
.sec-badge:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.sec-badge.sec-warn { border-color: var(--warn); background: var(--warn-soft); }
.sec-badge.sec-fail { border-color: var(--danger); background: var(--danger-soft); }
.sec-shield { width: 30px; height: 30px; flex-shrink: 0; }
.sec-shape { fill: var(--ok); }
.sec-warn .sec-shape { fill: var(--warn); }
.sec-fail .sec-shape { fill: var(--danger); }
.sec-mark { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; display: none; }
.sec-ok .sec-mark-ok, .sec-warn .sec-mark-warn, .sec-fail .sec-mark-fail { display: inline; }
.sec-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sec-text strong { font-size: .85rem; }
.sec-text small { font-size: .72rem; color: var(--muted); }
.sec-badge.checking .sec-shield { animation: sec-spin 1s linear infinite; }
@keyframes sec-spin { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }
.sec-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 55vh; overflow: auto; }
.sec-list li { display: grid; grid-template-columns: 1.4rem 1fr; gap: .1rem .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.sec-list li span.i { grid-row: span 2; width: 1.2rem; height: 1.2rem; border-radius: 50%; color: #fff; text-align: center; line-height: 1.2rem; font-size: .7rem; font-weight: 700; }
.sec-list .s-ok span.i { background: var(--ok); } .sec-list .s-warn span.i { background: var(--warn); } .sec-list .s-fail span.i { background: var(--danger); }
.sec-list small { color: var(--muted); }
.credits { display: flex; flex-direction: column; gap: .25rem; font-size: .72rem; color: var(--muted); line-height: 1.35; padding: 0 .25rem; }
.credits-label { text-transform: uppercase; letter-spacing: .05em; font-size: .65rem; }
.credits-logo { width: 140px; height: auto; padding: .35rem .5rem; background: #fff; border-radius: 8px; box-sizing: content-box; }
.credits address { display: flex; flex-direction: column; font-style: normal; gap: .05rem; }
.credits strong { color: var(--text); font-weight: 600; }
.sidenav .credits a, .credits a { display: inline; padding: 0; border-radius: 0; color: var(--muted); background: none; font-weight: 400; }
.sidenav .credits a:hover, .credits a:hover { color: var(--primary); text-decoration: underline; background: none; }
.guest-foot { display: flex; justify-content: center; padding: 1.5rem 1rem 2rem; }
.guest-foot .credits { align-items: center; text-align: center; }

.dash-msgs .msg-obj { display: flex; align-items: center; flex-wrap: wrap; gap: .1rem .45rem; font-size: .9rem; }
.dash-msgs .msg-text { margin: .15rem 0 .1rem; }
.dash-msgs .msg-item > .small { display: block; }

/* Countdown bis zur Fertigstellung (Liste + Objekt) */
.countdown { display: inline-flex; align-items: center; gap: .25rem; margin-top: .2rem; padding: .05rem .5rem; border-radius: 999px; font-size: .74rem; white-space: nowrap; font-variant-numeric: tabular-nums; border: 1px solid transparent; }
.countdown b { font-weight: 600; }
.cd-ok { background: var(--ok-soft); color: var(--ok); }
.cd-near { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.cd-soon { background: var(--warn-soft); color: var(--warn); }
.cd-over { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-line); }

/* Fertigmeldung & Fotos (Auftragnehmer) */
.photo-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; }
.photo-card h2 { margin: 0 0 .2rem; }
.photo-card p { margin: 0; }
.photo-card.photo-missing { border-color: var(--warn); background: var(--warn-soft); }
.photo-card.photo-ok { border-color: var(--ok); }
.btn-lg { padding: .7rem 1.2rem; font-size: 1.05rem; }
.assign-send { flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; }
.assign-send .due-box { display: flex; align-items: flex-end; gap: .9rem; padding: .5rem .75rem; border: 2px solid var(--primary); border-radius: 10px; background: var(--surface); }
.assign-send .due-field { display: flex; flex-direction: column; font-weight: 600; font-size: .9rem; gap: .25rem; }
.assign-send .due-field input { font-size: 1.15rem; font-weight: 600; padding: .45rem .6rem; min-width: 11rem; }
.assign-send .due-cd { margin: 0 0 .55rem; font-weight: 600; white-space: nowrap; }
.assign-send .btn { margin-left: 0; align-self: flex-end; }
.assign-send { justify-content: flex-end; }
.assign-send > .small { flex: 1 1 100%; text-align: right; }
.dash-photos .msg-item { border-left: 3px solid var(--warn); }
.photo-card.over { outline: 3px dashed var(--primary); outline-offset: 3px; }

/* Fortschritt der Firmen (Fertigmeldungen) */
.prog-bar { display: block; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.prog-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.prog-all .prog-bar > span { background: var(--ok); }
.prog-sm { display: inline-flex; align-items: center; gap: .35rem; margin-top: .25rem; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.prog-sm .prog-bar { width: 3.2rem; height: 6px; }
.prog-sm.prog-all { color: var(--ok); font-weight: 600; }
.prog-lg .prog-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; margin-bottom: .45rem; }
.prog-lg .prog-bar { height: 12px; }
.prog-firms { list-style: none; margin: .7rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.prog-firms li { padding: .2rem .6rem; border-radius: 999px; font-size: .82rem; border: 1px solid var(--border); }
.prog-firms li.is-done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.prog-firms li.is-open { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
.prog-firms .muted { font-weight: 400; font-size: .75rem; }
.progress-card:has(.prog-all) { border-color: var(--ok); }
.dash-done .msg-item { border-left: 3px solid var(--ok); }
.dash-newphotos .msg-item { border-left: 3px solid var(--new); }

/* Hilfe */
.tabs { display: flex; gap: .25rem; margin-bottom: .75rem; border-bottom: 2px solid var(--border); }
.tabs .tab { padding: .5rem 1rem; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; text-decoration: none; margin-bottom: -2px; border-bottom: 2px solid transparent; }
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.help .help-filter { width: 100%; margin-bottom: .75rem; font-size: 1rem; }
.help-sec { border: 1px solid var(--border); border-radius: 10px; margin: .5rem 0; background: var(--surface); }
.help-sec > summary { cursor: pointer; padding: .7rem 1rem; font-weight: 600; font-size: 1.02rem; }
.help-sec[open] > summary { border-bottom: 1px solid var(--border); }
.help-body { padding: .4rem 1.1rem .9rem; line-height: 1.55; }
.help-body li { margin: .3rem 0; }
.help-body dt { font-weight: 600; margin-top: .6rem; }
.help-body dd { margin: .1rem 0 0 0; }
.help-body .tip { background: var(--ok-soft); padding: .5rem .75rem; border-radius: 8px; }
.help-body kbd { border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; font-size: .85em; }
.help-sec:target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.help-contact { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); }

/* Versionen & Updates */
.nav-version { display: block; font-size: .75rem; color: var(--muted); padding: .35rem .5rem !important; }
.changelog { list-style: none; margin: 0; padding: 0; }
.changelog > li { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.changelog > li:last-child { border-bottom: 0; }
.cl-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; }
.cl-ver { font-weight: 700; padding: .1rem .55rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.changelog .is-current .cl-ver { background: var(--primary); color: #fff; border-color: var(--primary); }
.changelog ul { margin: .4rem 0 0; padding-left: 1.25rem; }
.changelog li li { margin: .2rem 0; }
.update-upload { flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.update-check { padding: .75rem 1rem; border-radius: 10px; border: 1px solid var(--border); }
.update-check.is-ok { border-color: var(--ok); background: var(--ok-soft); }
.update-check.is-bad { border-color: var(--danger-line); background: var(--danger-soft); }
.update-check .err-list { color: var(--danger-text); }
.whats-new ul { margin: .35rem 0 .5rem; padding-left: 1.2rem; }
.help-link { display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; font-size: .75rem; font-weight: 700;
    text-decoration: none; color: var(--primary); border: 1.5px solid currentColor; vertical-align: middle; margin-left: .25rem; }
.help-link:hover { background: var(--primary); color: #fff; }

/* Nachricht: Empfänger wählen (aufklappbar) */
.to-picker { position: relative; align-self: flex-start; }
.to-picker > summary { list-style: none; display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; cursor: pointer;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: .88rem; user-select: none; }
.to-picker > summary::-webkit-details-marker { display: none; }
.to-picker > summary:hover, .to-picker[open] > summary { border-color: var(--primary); }
.to-label { color: var(--muted); }
.to-value { font-weight: 600; }
.to-caret { width: .5rem; height: .5rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px);
    transition: transform .15s; margin-left: .2rem; color: var(--muted); }
.to-picker[open] .to-caret { transform: rotate(-135deg) translate(-2px, -2px); }
.to-panel { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 300px; max-width: min(440px, 90vw); max-height: 360px; overflow: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: .35rem; }
label.to-row { display: flex; flex-direction: row; align-items: center; gap: .55rem; padding: .4rem .55rem; border-radius: 6px; font-weight: 400; cursor: pointer; }
label.to-row:hover { background: var(--surface-2); }
label.to-row.to-all { border-bottom: 1px solid var(--border); border-radius: 6px 6px 0 0; margin-bottom: .2rem; }
.to-group { padding: .45rem .55rem .15rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.to-actions { position: sticky; bottom: -.35rem; display: flex; justify-content: flex-end; padding: .4rem .3rem .3rem; background: var(--surface); border-top: 1px solid var(--border); margin-top: .25rem; }
.to-badge { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* Firmenauswahl beim Zuweisen: Gewerke auf-/zuklappen */
.firm-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem 1rem; margin: .25rem 0 .4rem; }
.firm-tools-btns { display: flex; gap: .25rem; }
details.firm-group { border: 1px solid var(--border); border-radius: 10px; margin: .35rem 0; background: var(--surface); }
details.firm-group > summary { list-style: none; display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; cursor: pointer; user-select: none; border-radius: 10px; }
details.firm-group > summary::-webkit-details-marker { display: none; }
details.firm-group > summary:hover { background: var(--surface-2); }
details.firm-group[open] > summary { border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0; }
.fg-arrow { width: .55rem; height: .55rem; border-right: 2px solid var(--primary); border-bottom: 2px solid var(--primary); transform: rotate(-45deg); transition: transform .15s; flex: none; }
details.firm-group[open] .fg-arrow { transform: rotate(45deg); }
.fg-title { font-weight: 700; text-transform: uppercase; letter-spacing: .03em; font-size: .85rem; }
.fg-count { color: var(--muted); font-size: .8rem; margin-right: auto; }
details.firm-group.no-trade .fg-title { color: var(--warn); }
details.firm-group .firm-grid { padding: .5rem .8rem .6rem; }

/* Filter lädt im Hintergrund */
main.is-loading > :not(form) { opacity: .55; transition: opacity .15s; }
.check-row { display: flex; flex-wrap: wrap; gap: .5rem 2rem; }

/* Objektliste: sortierbare Spalten, Nachladen */
a.th-sort { display: inline-flex; align-items: center; gap: .3rem; color: inherit; text-decoration: none; white-space: nowrap; }
a.th-sort:hover { color: var(--primary); }
a.th-sort.is-active { color: var(--primary); }
.th-arrow { display: inline-block; position: relative; width: .7rem; height: .7rem; opacity: .35; }
.th-arrow::before, .th-arrow::after { content: ''; position: absolute; left: .12rem; border: .23rem solid transparent; }
.th-arrow::before { top: -.15rem; border-bottom-color: currentColor; }
.th-arrow::after { bottom: -.15rem; border-top-color: currentColor; }
a.th-sort:hover .th-arrow, a.th-sort.is-active .th-arrow { opacity: 1; }
a.th-sort.is-auf .th-arrow::after, a.th-sort.is-ab .th-arrow::before { opacity: .2; }
th.center a.th-sort, th.num a.th-sort { justify-content: center; }
.btn-sort-dir { white-space: nowrap; }
.load-more { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: .9rem 0 .2rem; }
.load-more.is-loading::after { content: 'lädt …'; font-size: .8rem; color: var(--muted); }

/* Kurze Meldung unten rechts, Element wird entfernt */
.toast-stack { position: fixed; top: calc(var(--topbar, 56px) + .75rem); right: 1rem; z-index: 300; display: flex; flex-direction: column;
    align-items: flex-end; gap: .5rem; pointer-events: none; max-width: min(440px, calc(100vw - 2rem)); }
.toast { position: relative; pointer-events: auto; padding: .75rem 2.6rem .75rem 1rem; border-radius: 10px; font-size: .92rem; line-height: 1.4;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--ok);
    box-shadow: 0 10px 30px rgba(0,0,0,.18); opacity: 0; transform: translateX(110%); transition: opacity .3s ease, transform .35s cubic-bezier(.2,.8,.2,1); }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--ok); }
.toast-success::before { content: '✓ '; color: var(--ok); font-weight: 700; }
.toast-error { border-left-color: var(--danger); color: var(--danger-text); }
.toast-error::before { content: '! '; font-weight: 700; }
.toast-info { border-left-color: var(--primary); }
.toast-close { position: absolute; top: .35rem; right: .35rem; width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent;
    color: inherit; opacity: .55; cursor: pointer; font-size: .85rem; }
.toast-close:hover { opacity: 1; background: rgba(127,127,127,.15); }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity .2s; transform: none; } }
.is-removing { opacity: .4; pointer-events: none; transition: opacity .2s; }

/* Dateivorschau: Text, Word, Excel, Folien, E-Mail */
.doc-preview { overflow: hidden; }
.pv-head { display: flex; align-items: center; gap: .5rem; margin: -.25rem 0 .75rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.pv-text { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Consolas, monospace; font-size: .88rem; line-height: 1.5;
    max-height: 75vh; overflow: auto; margin: 0; padding: .75rem; background: var(--surface-2); border-radius: 8px; }
.pv-doc { max-width: 52rem; margin: 0 auto; padding: 1.5rem 2rem; background: #fff; color: #111; border: 1px solid var(--border);
    border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.06); line-height: 1.55; font-size: .95rem; }
.pv-doc h2, .pv-doc h3, .pv-doc h4 { color: #111; margin: 1.1rem 0 .4rem; }
.pv-doc p { margin: 0 0 .5rem; }
.pv-doc .pv-empty { min-height: .6rem; }
.pv-doc .pv-table td { color: #111; }
.pv-img { max-width: 100%; height: auto; display: block; margin: .5rem 0; }
.pv-img-missing { color: #888; font-style: italic; }
.pv-table-wrap { overflow: auto; max-height: 75vh; border: 1px solid var(--border); border-radius: 6px; margin: .5rem 0; }
.pv-table { border-collapse: collapse; font-size: .85rem; }
.pv-table td { min-width: 4rem; }
.pv-table td, .pv-table th { border: 1px solid var(--border); padding: .25rem .5rem; vertical-align: top; white-space: pre-wrap; }
.pv-table th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; z-index: 1; }
.pv-table .pv-rn { color: var(--muted); font-weight: 500; text-align: right; position: sticky; left: 0; background: var(--surface-2); min-width: 2.5rem; }
.pv-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pv-tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .25rem; }
.pv-tab { border: 1px solid var(--border); background: var(--surface); border-radius: 8px 8px 0 0; padding: .35rem .8rem; cursor: pointer; font: inherit; font-size: .85rem; }
.pv-tab.active { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.pv-slides { display: grid; gap: .75rem; }
.pv-slide { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; background: var(--surface); }
.pv-slide-no { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pv-slide h3 { margin: .2rem 0 .4rem; }
.pv-slide p { margin: .15rem 0; }
.pv-mail dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; margin: 0 0 .75rem; }
.pv-mail dt { color: var(--muted); }
.pv-mail dd { margin: 0; font-weight: 500; }

/* Benutzer löschen / Super-Admin */
.danger-zone { border-color: var(--danger-line); }
.danger-zone h2 { color: var(--danger-text); }
.delete-user { align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.delete-user label { flex: 1 1 18rem; }
.badge-owner { background: var(--primary); color: #fff; border-color: transparent; }
.crown { width: 1em; height: 1em; vertical-align: -.12em; fill: #c9a227; flex: none; }
.crown title { pointer-events: none; }

/* Versand an Firmen: Vorschau im Modal, Versandverlauf */
.modal.modal-wide { width: min(760px, 94vw); max-width: min(760px, 94vw); }
.mail-preview { display: grid; gap: .6rem; text-align: left; }
.mp-row { display: grid; grid-template-columns: 4.5rem 1fr; gap: .5rem; align-items: baseline; }
.mp-note { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
.mp-note textarea { font-weight: 400; }
.mp-body { white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 40vh; overflow: auto; padding: .7rem .85rem; border-radius: 8px;
    background: var(--surface-2); border: 1px solid var(--border); font-family: inherit; font-size: .86rem; line-height: 1.45; }
.mp-body mark { background: var(--warn-soft); color: inherit; border-radius: 3px; }
.sends { margin: 1rem 0; }
.send-item { border: 1px solid var(--border); border-radius: 8px; margin: .35rem 0; background: var(--surface); }
.send-item > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; padding: .5rem .75rem; list-style: none; }
.send-item > summary::-webkit-details-marker { display: none; }
.send-item > summary::before { content: '▸'; color: var(--primary); transition: transform .15s; }
.send-item[open] > summary::before { transform: rotate(90deg); }
.send-when { font-variant-numeric: tabular-nums; font-weight: 600; }
.send-body { padding: 0 .75rem .75rem; display: grid; gap: .4rem; }

/* Statistik (nur Super-Admin) */
.stats.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.stats-filter { gap: .5rem; flex-wrap: wrap; }
.month-chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: .4rem; align-items: end; height: 190px; padding-top: .5rem; }
.mc-col { display: flex; flex-direction: column; align-items: center; height: 100%; gap: .25rem; }
.mc-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--border); }
.mc-bar { width: 26%; min-height: 1px; border-radius: 3px 3px 0 0; }
.mc-label { font-size: .72rem; color: var(--muted); }
.lg-c { background: var(--primary); } .lg-s { background: #8b5cf6; } .lg-f { background: var(--ok); }
.legend { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }
.legend .lg { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-left: .5rem; }
table[data-sortable] th { cursor: pointer; user-select: none; white-space: nowrap; }
table[data-sortable] th:hover { color: var(--primary); }
table[data-sortable] th.sort-asc::after { content: ' ▲'; font-size: .7em; }
table[data-sortable] th.sort-desc::after { content: ' ▼'; font-size: .7em; }
.stats-table td { white-space: nowrap; }
.score { position: relative; display: inline-block; width: 70px; height: 18px; border-radius: 999px; background: var(--surface-2); overflow: hidden; vertical-align: middle; }
.score > span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; }
.score b { position: relative; font-size: .75rem; line-height: 18px; display: block; text-align: center; }
.score-good > span { background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.score-mid > span { background: var(--warn-soft); }
.score-low > span { background: var(--danger-soft); }
.hbar { display: inline-block; width: 120px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; vertical-align: middle; }
.hbar > span { display: block; height: 100%; background: var(--primary); }
.grid-2 > * { min-width: 0; }

/* Benutzermenü: Schalter */
.menu-toggle { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; }
.switch { position: relative; flex: none; width: 30px; height: 17px; border-radius: 999px; background: var(--border); transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .2s; }
.switch.on { background: var(--primary); }
.switch.on::after { left: 15px; }
.user-dropdown button.menu-toggle { display: flex; color: var(--text); font-weight: 400; }

/* Gewerke als Mehrfachauswahl */
.trade-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
label.trade-chip { display: inline-flex; flex-direction: row; align-items: center; gap: .35rem; padding: .25rem .7rem .25rem .5rem; border: 1px solid var(--border);
    border-radius: 999px; font-weight: 400; cursor: pointer; background: var(--surface); }
label.trade-chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
label.trade-chip input { margin: 0; }

/* Zuweisen: Gewerke je Objekt */
.also-trades, .assigned-trades { display: block; font-size: .72rem; color: var(--muted); }
.assigned-trades { color: var(--ok); }
.firm-trades { margin: .75rem 0; padding: .75rem .9rem; border: 1px solid var(--primary); border-radius: 10px; background: var(--surface); }
.firm-trades h4 { margin: 0 0 .2rem; }
.ft-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; padding: .4rem 0; border-top: 1px solid var(--border); }
.ft-row:first-child { border-top: 0; }
.ft-chips { display: flex; flex-wrap: wrap; gap: .3rem; }

/* Fertigmeldung je Gewerk (Auftragnehmer) */
.photo-card-text { flex: 1 1 18rem; }
.trade-done { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; flex: 1 1 100%; }
.trade-done li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; padding: .45rem .7rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.trade-done li.is-done { border-color: var(--ok); }
.trade-done .td-name { font-weight: 600; min-width: 9rem; }
.trade-done form { margin-left: auto; }

/* E-Mail-Vorlagen */
.tpl { border: 1px solid var(--border); border-radius: 10px; margin: .4rem 0; background: var(--surface); }
.tpl > summary { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; padding: .6rem .85rem; cursor: pointer; }
.tpl > summary::-webkit-details-marker { display: none; }
.tpl-arrow { width: .5rem; height: .5rem; border-right: 2px solid var(--primary); border-bottom: 2px solid var(--primary); transform: rotate(-45deg); transition: transform .15s; }
.tpl[open] .tpl-arrow { transform: rotate(45deg); }
.tpl[open] > summary { border-bottom: 1px solid var(--border); }
.tpl-body { display: grid; gap: .6rem; padding: .75rem .85rem .85rem; }
.tpl-body textarea { font-family: ui-monospace, Consolas, monospace; font-size: .86rem; line-height: 1.45; }
.tpl-vars { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.tpl-var { border: 1px dashed var(--primary); background: var(--surface-2); color: var(--primary); border-radius: 6px; padding: .1rem .45rem;
    font-family: ui-monospace, Consolas, monospace; font-size: .78rem; cursor: pointer; }
.tpl-var:hover { background: var(--primary); color: #fff; }
