/* rockinCRM v2 – Stil im Look gängiger CRM-Tools (Sidebar-Layout, Karten, Kacheln) */

:root {
    --crm-bg: #f4f5f7;
    --crm-sidebar-bg: #1c2230;
    --crm-sidebar-fg: #c7cbd6;
    --crm-sidebar-fg-active: #ffffff;
    --crm-accent: #4f6df5;
    --crm-accent-dark: #3952c4;
    --crm-text: #1f2430;
    --crm-text-muted: #6b7280;
    --crm-border: #e3e6ec;
    --crm-card-bg: #ffffff;
    --crm-success: #1f9d55;
    --crm-error: #d6493c;
    --crm-radius: 10px;
}

html { font-size: 87.5%; } /* globale Basis: 14px statt 16px – alles rem-basierte skaliert mit */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--crm-bg);
    color: var(--crm-text);
}

a { color: var(--crm-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout: Sidebar + Content ------------------------------------------- */
.crm-shell {
    display: flex;
    min-height: 100vh;
}

.crm-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--crm-sidebar-bg);
    color: var(--crm-sidebar-fg);
    display: flex;
    flex-direction: column;
    padding: 12px 12px;
}

.crm-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 12px;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
}
.crm-brand-mark { font-size: 1.4rem; }

/* Mit inzwischen ueber 20 Punkten passt die Navigation auf kleineren
   Bildschirmen nicht mehr in die auf 100vh fixierte Leiste. Die Abstaende sind
   deshalb bewusst eng gehalten - auf dem Touchscreen setzt die Media-Query
   weiter unten wieder groessere Ziele. */
.crm-nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; min-height: 0; }
.crm-nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 11px;
    border-radius: var(--crm-radius);
    color: var(--crm-sidebar-fg);
    font-size: 0.88rem;
    font-weight: 500;
}
.crm-nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.crm-nav-link.is-active { background: var(--crm-accent); color: #fff; }
.crm-nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.crm-sidebar-foot {
    margin-top: auto;
    font-size: 0.75rem;
    color: #8189a0;
    line-height: 1.4;
    padding: 14px 12px 4px;
}

/* --- Content area --------------------------------------------------------- */
.crm-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.crm-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    background: var(--crm-card-bg);
    border-bottom: 1px solid var(--crm-border);
    position: sticky;
    top: 0;
    /* Hoeher als .crm-page-head-sticky (z-index 50): sonst haengt das
       Ergebnisfeld der Suche - obwohl es selbst z-index 20 traegt - hinter
       der Titelzeile jeder Detailseite. Kindelemente koennen den z-index
       ihres Vorfahren nicht ueberbieten, eigener Stapelkontext hin oder her. */
    z-index: 60;
}

.crm-search { position: relative; flex: 1; max-width: 420px; }
.crm-search input {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--crm-border);
    border-radius: 999px;
    background: var(--crm-bg);
    font-size: 0.9rem;
}
.crm-search input:focus { outline: none; border-color: var(--crm-accent); background: #fff; }

#crm-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    box-shadow: 0 12px 28px rgba(20,24,40,0.14);
    max-height: 420px;
    overflow-y: auto;
    z-index: 20;
}
#crm-search-results.is-visible { display: block; }
#crm-search-results .group-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--crm-text-muted);
    padding: 10px 14px 4px;
}
#crm-search-results a {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    color: var(--crm-text);
    font-size: 0.88rem;
}
#crm-search-results a:hover { background: var(--crm-bg); text-decoration: none; }
#crm-search-results .meta { color: var(--crm-text-muted); font-size: 0.8rem; }
#crm-search-results .empty { padding: 14px; color: var(--crm-text-muted); font-size: 0.88rem; }

.crm-user { display: flex; align-items: center; gap: 14px; }
.crm-user-info { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.crm-user-name { font-weight: 600; font-size: 0.88rem; }
.crm-user-role { font-size: 0.76rem; color: var(--crm-text-muted); }
.crm-logout { font-size: 0.82rem; color: var(--crm-text-muted); }

.crm-main { padding: 28px; max-width: none; }

/* --- Page head ------------------------------------------------------------ */
.crm-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}
.crm-page-head h1 { margin: 0 0 4px; font-size: 1.4rem; }
.crm-page-sub { margin: 0; color: var(--crm-text-muted); font-size: 0.88rem; }
.crm-sync-status { margin: 2px 0 0; font-size: 0.8rem; color: var(--crm-text-muted); }
.crm-breadcrumb { margin: 0 0 6px; font-size: 0.82rem; color: var(--crm-text-muted); }
.crm-breadcrumb span { margin: 0 4px; }

/* --- Buttons --------------------------------------------------------------- */
.crm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--crm-radius);
    border: 1px solid var(--crm-border);
    background: #fff;
    color: var(--crm-text);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}
.crm-btn:hover { text-decoration: none; border-color: var(--crm-accent); }
.crm-btn-primary { background: var(--crm-accent); border-color: var(--crm-accent); color: #fff; }
.crm-btn-primary:hover { background: var(--crm-accent-dark); border-color: var(--crm-accent-dark); }
.crm-btn-block { width: 100%; justify-content: center; margin-top: 18px; }

/* --- Dashboard tiles ------------------------------------------------------- */
.crm-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.crm-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    color: var(--crm-text);
    transition: box-shadow .15s, border-color .15s;
}
.crm-tile:hover { text-decoration: none; box-shadow: 0 10px 26px rgba(20,24,40,0.08); border-color: var(--crm-accent); }
.crm-tile-icon { font-size: 1.4rem; }
.crm-tile-label { font-size: 0.78rem; color: var(--crm-text-muted); font-weight: 600; }
.crm-tile-count { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.crm-tile-meta { font-size: 0.76rem; color: var(--crm-text-muted); }
.crm-tile-error { color: var(--crm-error); font-size: 0.84rem; font-weight: 600; margin-top: 4px; }
.crm-tile--row-start { grid-column-start: 1; }
.crm-tile-status-list { display:flex; flex-wrap:wrap; gap:3px 8px; margin-top:6px; }
.crm-tile-status-item { font-size:0.72rem; color:var(--crm-text-muted); white-space:nowrap; }
.crm-tile-status-item strong { color:var(--crm-text); font-weight:600; }

/* --- Social-Media-Konten: nach Plattform gruppiert, im Raster ------------- */
.crm-social-abschnitt { margin-bottom: 22px; }
.crm-social-abschnitt-titel {
    display: flex; align-items: center; gap: 8px;
    font-size: 1rem; margin: 0 0 10px;
}
.crm-social-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
}
.crm-social-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
}
.crm-social-icon { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 8px; }
.crm-social-body { flex: 1 1 auto; min-width: 0; }
.crm-social-name { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.crm-social-meta { font-size: 0.8rem; color: var(--crm-text-muted); }
.crm-social-zahlen { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.86rem; margin-top: 4px; }
.crm-social-spark { display: block; width: 100%; height: 28px; margin-top: 6px; }
.crm-social-klickbar { cursor: pointer; }
.crm-social-klickbar:hover { border-color: var(--crm-accent); box-shadow: 0 6px 18px rgba(20,24,40,0.08); }

/* --- Detail-Popup (Klick auf eine Social-/Matomo-Kachel) ------------------ */
.crm-modal-overlay {
    position: fixed; inset: 0; background: rgba(15,18,30,0.5);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 6vh 16px; z-index: 100;
}
.crm-modal {
    position: relative;
    background: var(--crm-card-bg);
    border-radius: var(--crm-radius);
    padding: 20px 24px;
    max-width: 560px; width: 100%;
    max-height: 82vh; overflow-y: auto;
}
.crm-modal-schliessen {
    position: absolute; top: 12px; right: 14px;
    background: none; border: none; font-size: 1.1rem; color: #9ca3af; cursor: pointer;
}
.crm-modal-liste { list-style: none; margin: 8px 0 16px; padding: 0; }
.crm-modal-liste li { padding: 8px 0; border-bottom: 1px solid var(--crm-border); }
.crm-modal-liste li:last-child { border-bottom: none; }
.crm-modal-eintrag-text { font-weight: 600; }
.crm-modal-eintrag-meta { font-size: 0.8rem; color: var(--crm-text-muted); margin-top: 2px; }

/* --- Beiträge-Kalender ----------------------------------------------------- */
.crm-kalender { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.crm-kalender-kopf { text-align: center; font-size: 0.78rem; font-weight: 600; color: var(--crm-text-muted); padding-bottom: 4px; }
.crm-kalender-tag {
    min-height: 90px;
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    padding: 6px;
}
.crm-kalender-tag--ausserhalb { opacity: 0.4; }
.crm-kalender-tag--heute { border-color: var(--crm-accent); border-width: 2px; }
.crm-kalender-tagnr { font-size: 0.78rem; color: var(--crm-text-muted); margin-bottom: 4px; }
.crm-kalender-pille {
    font-size: 0.74rem;
    padding: 3px 5px;
    margin-bottom: 3px;
    border-left: 3px solid #9ca3af;
    background: rgba(0,0,0,0.03);
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-kalender-pille[draggable="true"] { cursor: grab; }
.crm-kalender-uebersicht { display: flex; gap: 16px; font-size: 0.85rem; color: var(--crm-text-muted); margin-left: auto; }

/* --- Social Media im Metricool-Stil: linke Konto-Leiste + Pastell-Kacheln - */
.crm-sm-layout { display: flex; gap: 20px; align-items: flex-start; }
.crm-sm-sidebar {
    flex: 0 0 220px; background: var(--crm-card-bg); border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius); padding: 10px 8px; position: sticky; top: 12px;
    max-height: calc(100vh - 24px); overflow-y: auto;
}
.crm-sm-sidebar a {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 8px; margin-bottom: 2px;
    color: var(--crm-text); text-decoration: none; font-size: .86rem;
}
.crm-sm-sidebar a:hover { background: #f3f4f6; }
.crm-sm-sidebar a.is-aktiv { background: #1c1729; color: #fff; }
.crm-sm-sidebar-titel { font-weight: 700; }
.crm-sm-sidebar-gruppe {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--crm-text-muted); padding: 12px 10px 4px;
}
.crm-sm-sidebar hr { border: none; border-top: 1px solid var(--crm-border); margin: 8px 4px; }
.crm-sm-inhalt { flex: 1 1 auto; min-width: 0; }

.crm-sm-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--crm-border); margin-bottom: 18px; flex-wrap: wrap; }
.crm-sm-tabs a {
    padding: 8px 2px 10px; font-size: .78rem; font-weight: 700; letter-spacing: .03em;
    text-transform: uppercase; color: var(--crm-text-muted); text-decoration: none; border-bottom: 2px solid transparent;
}
.crm-sm-tabs a.is-aktiv { color: #b45309; border-bottom-color: #b45309; }

.crm-sm-abschnitt { background: var(--crm-card-bg); border: 1px solid var(--crm-border); border-radius: var(--crm-radius); padding: 20px; margin-bottom: 18px; }
.crm-sm-abschnitt-kopf { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.crm-sm-abschnitt-titel { font-size: 1.1rem; font-weight: 700; margin: 0; }

.crm-sm-kacheln { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.crm-sm-kachel { border-radius: 12px; padding: 16px 20px; min-width: 130px; flex: 1 1 130px; }
.crm-sm-kachel-wert { font-size: 1.8rem; font-weight: 800; line-height: 1.15; display: flex; align-items: baseline; gap: 6px; }
.crm-sm-kachel-delta { font-size: .82rem; font-weight: 600; }
.crm-sm-kachel-label { font-size: .78rem; margin-top: 4px; opacity: .82; }
.crm-sm-mint   { background: #bbf7d0; color: #14532d; }
.crm-sm-pink   { background: #f9a8d4; color: #831843; }
.crm-sm-blau   { background: #a5b4fc; color: #1e2a6e; }
.crm-sm-orange { background: #fdba74; color: #7c2d12; }
.crm-sm-grau   { background: #e5e7eb; color: #6b7280; }
.crm-sm-rot    { background: #fca5a5; color: #7f1d1d; }

.crm-sm-chart { width: 100%; aspect-ratio: 1200 / 260; height: auto; display: block; max-height: 320px; }
.crm-inbox-liste { display: flex; flex-direction: column; gap: 10px; }
.crm-inbox-eintrag {
    display: flex; gap: 12px; padding: 14px 16px;
    background: var(--crm-card-bg); border: 1px solid var(--crm-border); border-radius: var(--crm-radius);
}
.crm-inbox-eintrag--ungelesen { border-left: 3px solid #2563eb; background: #f5f8ff; }
.crm-inbox-inhalt { flex: 1 1 auto; min-width: 0; }
.crm-inbox-kopf { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.crm-inbox-meta { font-size: .78rem; color: var(--crm-text-muted); }
.crm-inbox-text { margin: 6px 0; }
.crm-inbox-aktionen { display: flex; gap: 14px; font-size: .82rem; }
.crm-inbox-aktionen a { color: #2563eb; text-decoration: none; }
.crm-inbox-antwortform { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.crm-inbox-antwortform textarea { flex: 1 1 auto; border: 1px solid var(--crm-border); border-radius: 8px; padding: 8px; font: inherit; }

.crm-sm-tooltip {
    position: absolute; z-index: 200; pointer-events: none;
    background: #1c1729; color: #fff; font-size: .78rem; line-height: 1.4;
    padding: 6px 10px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
    white-space: nowrap;
}

/* --- Tables ---------------------------------------------------------------- */
.crm-table-wrap {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    overflow: hidden;
    overflow-x: auto;
}
.crm-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.crm-table th, .crm-table td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--crm-border);
    white-space: nowrap;
}
.crm-table th { color: var(--crm-text-muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: .03em; }
.crm-table tbody tr { cursor: pointer; }
.crm-table tbody tr:hover { background: var(--crm-bg); }
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table-meta { margin-top: 12px; color: var(--crm-text-muted); font-size: 0.82rem; }
.crm-empty { color: var(--crm-text-muted); }

/* --- Detail cards / forms --------------------------------------------------- */
.crm-card {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    padding: 20px 22px;
    margin-bottom: 16px;
}
.crm-card-title { margin: 0 0 14px; font-size: 1rem; }
.crm-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px 22px;
}
.crm-field-label { display: block; font-size: 0.74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--crm-text-muted); margin-bottom: 5px; }
.crm-field-value { font-size: 0.92rem; }
.crm-field input[type="text"]:not(.kb-chip-search):not(.crm-tag-input),
.crm-field input[type="password"] {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    cursor: text;
    transition: border-color .15s, box-shadow .15s;
}
.crm-field input:not(.kb-chip-search):not(.crm-tag-input):hover { border-color: var(--crm-accent); }
.crm-field input:not(.kb-chip-search):not(.crm-tag-input):focus { outline: none; border-color: var(--crm-accent); background: #fff; box-shadow: 0 0 0 3px rgba(91,108,255,0.12); }
.crm-form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* --- Flash messages ---------------------------------------------------------- */
.crm-flash { padding: 12px 16px; border-radius: var(--crm-radius); margin-bottom: 18px; font-size: 0.88rem; }
.crm-flash-error { background: #fdecea; color: var(--crm-error); border: 1px solid #f6c4bd; }
.crm-flash-success { background: #e9f9ef; color: var(--crm-success); border: 1px solid #bfe9cf; }

/* --- Login / Error pages ----------------------------------------------------- */
.crm-login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1c2230, #4f6df5);
}
.crm-login-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 16px;
    padding: 32px 30px;
    box-shadow: 0 30px 60px rgba(10,14,30,0.35);
    display: flex;
    flex-direction: column;
}
.crm-login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; }
.crm-login-sub { margin: 6px 0 20px; color: var(--crm-text-muted); font-size: 0.86rem; }
.crm-login-card label { margin-top: 4px; }
.crm-login-card input { padding: 10px 12px; border: 1px solid var(--crm-border); border-radius: 8px; margin-bottom: 4px; font-size: 0.92rem; }

/* ── BURGER-BUTTON (nur mobile sichtbar) ─────────────────────────── */
.crm-burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border: none; background: transparent;
    cursor: pointer; font-size: 1.35rem;
    color: var(--crm-text); flex-shrink: 0; padding: 0;
    border-radius: 8px; transition: background .15s;
}
.crm-burger:hover { background: var(--crm-bg); }

/* ── MOBILE OVERLAY ─────────────────────────────────────────────── */
#crm-mob-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 299;
}
#crm-mob-overlay.active { display: block; }

/* ── MOBILE (≤ 768px) ───────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Burger einblenden */
    .crm-burger { display: flex; }

    /* Desktop-Toggle verstecken */
    #sidebar-toggle { display: none !important; }

    /* Sidebar als Slide-in Drawer */
    .crm-sidebar {
        position: fixed !important;
        top: 0; left: -270px; bottom: 0;
        width: 260px !important;
        z-index: 300;
        transition: left .25s ease;
        padding: 20px 14px !important;
        overflow-y: auto;
        box-shadow: none;
    }
    .crm-sidebar.mob-open {
        left: 0 !important;
        box-shadow: 6px 0 28px rgba(0,0,0,.30);
    }
    /* Die enge Desktop-Variante dient dem Platz auf 100vh. Der Drawer scrollt
       ohnehin, hier zaehlen treffbare Ziele. */
    .crm-nav { gap: 2px; }
    .crm-nav-link { padding: 9px 12px; font-size: .92rem; }
    .crm-nav-icon { font-size: 1.05rem; width: 22px; }
    /* Desktop-Collapsed-State ignorieren */
    body.sidebar-collapsed .crm-sidebar {
        width: 260px !important;
        padding: 20px 14px !important;
    }
    body.sidebar-collapsed .crm-brand-name,
    body.sidebar-collapsed #crm-logo-full  { display: block !important; }
    body.sidebar-collapsed #crm-logo-small { display: none !important; }
    body.sidebar-collapsed .crm-nav { padding: 0 !important; gap: 2px !important; }
    body.sidebar-collapsed .crm-nav-link {
        font-size: .92rem !important; display: flex !important;
        justify-content: flex-start !important; padding: 10px 12px !important;
        gap: 10px !important; width: auto !important; border-radius: var(--crm-radius) !important;
    }
    body.sidebar-collapsed .crm-nav-link .crm-nav-icon {
        font-size: 1.05rem !important; background: none !important;
        padding: 0 !important; border-radius: 0 !important;
    }
    body.sidebar-collapsed .crm-nav-link.is-active { background: var(--crm-accent) !important; }
    body.sidebar-collapsed .sb-foot-links,
    body.sidebar-collapsed .sb-foot-copy { display: block !important; }
    body.sidebar-collapsed .crm-sidebar-foot { padding: .75rem !important; text-align: left !important; }

    /* Content füllt volle Breite */
    .crm-content { width: 100%; min-width: 0; }

    /* Topbar */
    .crm-topbar { padding: 9px 12px; gap: 8px; }
    .crm-search { flex: 1; min-width: 0; max-width: none; }
    .crm-user-info { display: none; }
    .crm-user { gap: 8px; }

    /* Main padding */
    .crm-main { padding: 14px 12px; }

    /* Page head */
    .crm-page-head { flex-direction: column; gap: 8px; margin-bottom: 14px; }
    .crm-page-head h1 { font-size: 1.2rem; }
    .crm-page-head-actions { flex-wrap: wrap; }

    /* Filter bar */
    .crm-filters { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
    .crm-filters-label { width: 100%; margin-bottom: 2px; }
    .crm-filter-select { flex: 1 1 calc(50% - 6px); min-width: 130px; font-size: .8rem; }
    .crm-filter-reset { width: 100%; }
    .crm-filter-badge { margin-left: 0; }
    .crm-sort-bar { display: none !important; }

    /* Tabelle */
    .crm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .crm-table { min-width: 600px; }
    .crm-table td, .crm-table th { font-size: .8rem; padding: 8px 10px; }

    /* Detail-Grid */
    .crm-detail-grid { grid-template-columns: 1fr !important; }
    .crm-field-picker { grid-column: 1 / -1; }

    /* Side-by-side Sektionen → stack */
    .crm-sbs-grid { grid-template-columns: 1fr !important; }

    /* Buttons: größere Touch-Targets */
    .crm-btn { min-height: 42px; padding: 9px 16px; font-size: .88rem; }
    .crm-btn-sm { min-height: 34px; }

    /* Karten */
    .crm-card { padding: 14px 12px; }
    .crm-section-title { font-size: .82rem; }

    /* Flash-Meldungen */
    .crm-flash { border-radius: 0; margin: 0 0 10px; }

    /* Summenbalken */
    .crm-sum-bar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }

    /* Sticky Page-Head: kein sticky auf mobile (zu wenig Platz) */
    .crm-page-head-sticky { position: static !important; box-shadow: none !important; }
}

/* --- Long-Text-Felder (z.B. "Auszug", "Bemerkung") ------------------------- */
.crm-field-wide { grid-column: 1 / -1; }
.crm-field-wide2 { grid-column: span 2; }
.crm-field-textarea {
    width: 100%;
    min-height: 150px;
    padding: 9px 12px;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    background: #fff;
    cursor: text;
    font: inherit;
    line-height: 1.5;
    resize: vertical;
    transition: border-color .15s, box-shadow .15s;
}
.crm-field-textarea:hover { border-color: var(--crm-accent); }
.crm-field-textarea:focus { outline: none; border-color: var(--crm-accent); background: #fff; box-shadow: 0 0 0 3px rgba(91,108,255,0.12); }
.crm-field-value-long {
    white-space: pre-wrap;
    line-height: 1.6;
    min-height: 60px;
}

/* --- Auswahldialog für Link-Felder (z.B. "Komponist", "Main Vocals") ------- */
.crm-link-filter {
    width: 100%;
    margin-bottom: 6px;
    padding: 7px 10px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    font-size: 0.85rem;
    background: #fff;
}
.crm-link-filter:focus { outline: none; border-color: var(--crm-accent); }
.crm-link-select {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    background: #fff;
    font: inherit;
}
.crm-link-select:focus { outline: none; border-color: var(--crm-accent); }
.crm-hint { font-size: 0.78rem; color: #888; margin-top: 4px; }

/* --- Datei-Anlagen (z.B. "Partitur", "Sheet") als Linkliste ---------------- */
.crm-file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.crm-file-list li { padding: 8px 12px; border: 1px solid var(--crm-border); border-radius: 8px; background: #fff; }
.crm-file-list a { color: var(--crm-accent); text-decoration: none; font-weight: 500; }
.crm-file-list a:hover { text-decoration: underline; }
.crm-file-size { color: #888; font-size: 0.82rem; }

.crm-link-picker {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
}
.crm-link-col {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.crm-link-col-label {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--crm-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.crm-link-arrows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
}
.crm-link-arrows button {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.5rem;
    border: 1px solid var(--crm-border, #d1d5db);
    background: var(--crm-surface, #fff);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}
.crm-link-arrows button:hover {
    background: var(--crm-accent-soft, #eef2ff);
}
.crm-link-select.crm-link-available,
.crm-link-select.crm-link-selected {
    flex: 1;
}

.crm-link-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.crm-link-add {
    border: 1px solid var(--crm-border, #d1d5db);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--crm-surface, #fff);
}
.crm-link-add summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--crm-accent, #4f46e5);
    list-style: none;
}
.crm-link-add summary::-webkit-details-marker { display: none; }
.crm-link-add[open] summary {
    margin-bottom: 0.5rem;
}
.crm-link-col-selected .crm-link-select {
    width: 100%;
}

.crm-field-picker {
    grid-column: span 2;
    min-width: 260px;
}
@media (max-width: 720px) {
    .crm-field-picker { grid-column: 1 / -1; }
}

.crm-select {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: #fff;
}
.crm-select-multi { height: auto; }
.crm-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}
.crm-checkbox-label input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
}

.crm-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}
.crm-checkbox-chip {
    border: 1px solid var(--crm-border);
    border-radius: 999px;
    padding: 5px 12px;
    font-weight: 400;
    font-size: 0.92rem;
}
.crm-checkbox-chip:has(input:checked) {
    background: var(--crm-accent-soft, #eef2ff);
    border-color: var(--crm-accent, #4f46e5);
}
.crm-field-value-readonly {
    color: #6b7280;
    font-style: italic;
}

.crm-table thead th.crm-sortable {
    cursor: pointer;
    user-select: none;
}
.crm-table thead th.crm-sortable:hover {
    background: rgba(0, 0, 0, 0.04);
}
.crm-sort-arrow {
    display: inline-block;
    margin-left: 0.25em;
    font-size: 0.8em;
    opacity: 0.7;
}
.crm-sort-arrow-idle {
    opacity: 0.35;
}
.crm-sort-arrow-active {
    opacity: 1;
    font-weight: bold;
}
.crm-sort-bar {
    margin: 0 0 0.5em;
    font-size: 0.78rem;
    color: #888;
    min-height: 1.6em;
    display: block;
}
#crm-sort-bar-active {
    display: none;
    align-items: center;
    gap: 0.5em;
    background: #eef0fd;
    border: 1px solid #c7cefc;
    border-radius: 6px;
    padding: 3px 10px 3px 8px;
    color: #3451c7;
    font-weight: 500;
}
.crm-btn-xs {
    font-size: .78rem;
    padding: 2px 8px;
    background: #fff;
    color: #555;
    border-radius: 5px;
    border: 1px solid #c7cefc;
    cursor: pointer;
    white-space: nowrap;
    margin-left: 6px;
}
.crm-btn-xs:hover { background: #dde1fb; }
/* ── Tag-Dropdown (Multi-Select) ───────────────────────────────────────────── */
.crm-tag-select { position: relative; }
.crm-tag-select-box {
    display: flex; flex-wrap: wrap; gap: 0.3em; align-items: center;
    border: 1px solid #d1d5db; border-radius: 6px;
    padding: 0.35em 0.5em; min-height: 2.4em;
    cursor: text; background: #fff;
}
.crm-tag-select-box:focus-within { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,.15); }
.crm-tag {
    display: inline-flex; align-items: center; gap: 0.2em;
    background: #dbeafe; color: #1e40af;
    border-radius: 4px; padding: 0.15em 0.35em 0.15em 0.5em;
    font-size: 0.85em; white-space: nowrap;
}
.crm-tag-remove {
    background: none; border: none; color: #93c5fd;
    cursor: pointer; padding: 0; font-size: 1em; line-height: 1;
}
.crm-tag-remove:hover { color: #1e40af; }
.crm-tag-input {
    border: none; outline: none; background: transparent;
    font: inherit; min-width: 7em; flex: 1; padding: 0;
}
.crm-tag-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
    background: #fff; border: 1px solid #d1d5db;
    border-radius: 0 0 6px 6px; box-shadow: 0 4px 12px rgba(0,0,0,.1);
    list-style: none; margin: 0; padding: 0.25em 0;
    max-height: 12em; overflow-y: auto;
}
.crm-tag-option {
    padding: 0.4em 0.75em; cursor: pointer; font-size: 0.9em;
}
.crm-tag-option:hover { background: rgba(99,102,241,.08); }
/* File-Manager (Upload + Löschen) */
.crm-file-manager { display: flex; flex-direction: column; gap: 10px; }
.crm-file-list li { display: flex; align-items: center; gap: 8px; }
.crm-file-delete { margin-left: auto; background: none; border: none; color: #999; font-size: 1.1rem; cursor: pointer; padding: 0 4px; line-height: 1; }
.crm-file-delete:hover { color: #c00; }
/* Bedienleiste unter der Dateiliste: Buttons nebeneinander, jeweils inhaltsbreit.
   Ohne diesen Wrapper streckt der Spalten-Flex von .crm-file-manager sie auf 100%. */
.crm-file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* font: inherit, damit <button> nicht die Browser-Schrift nutzt und optisch
   vom <span> in "+ Dateien hinzufügen" abweicht. */
.crm-file-actions .crm-btn { flex: 0 0 auto; font-family: inherit; line-height: 1.4; }
.crm-file-add-label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.crm-file-input { display: none; }
.crm-file-chosen { font-size: .85em; color: #555; font-style: italic; }
.crm-btn-sm { font-size: .85rem; padding: 4px 12px; background: var(--crm-accent); color: #fff; border-radius: 6px; border: none; cursor: pointer; }
.crm-filter-badge { background: #c00; color: #fff; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 12px; }
.crm-btn-danger { background: #c00; color: #fff; border: none; } .crm-btn-danger:hover { background: #900; }

/* Sticky Detail-Header */
.crm-page-head-sticky { position: sticky; top: 0; z-index: 50; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.07); padding-bottom: 12px; justify-content: space-between; align-items: center; }
.crm-page-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* --- Sum-Bar (Kostenkalkulation) --- */
.crm-sum-bar {
    display: flex;
    gap: 32px;
    padding: 10px 16px;
    background: #f0f4ff;
    border: 1px solid #c8d4f0;
    border-radius: 6px;
    margin: 12px 0 4px;
    font-size: 0.95rem;
}
.crm-sum-bar strong { color: #1a3a8f; }

/* --- Sum-Head im Sticky-Header --- */
.crm-sum-head {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: #555;
    align-items: center;
}
.crm-sum-head div { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.crm-sum-head strong { color: #1a3a8f; font-size: 1.05rem; }

/* --- DAW-Projektdateien Panel --- */
.crm-daw-panel{margin:24px 0 8px;padding:16px 20px;background:#f8f8f8;border:1px solid #ddd;border-radius:8px}
.crm-daw-title{margin:0 0 12px;font-size:1rem;font-weight:600;color:#333}
.crm-daw-group{margin-bottom:12px}
.crm-daw-group strong{font-size:.8rem;color:#666;text-transform:uppercase;letter-spacing:.04em}
.crm-daw-group ul{margin:4px 0 0;padding:0;list-style:none}
.crm-daw-group li{display:flex;align-items:center;gap:8px;padding:4px 0;border-bottom:1px solid #eee}
.crm-daw-link{color:#1a3a8f;text-decoration:none;display:flex;align-items:center;gap:6px;flex:1}
.crm-daw-link:hover{text-decoration:underline}
.crm-daw-badge{background:#e8eef8;color:#1a3a8f;font-size:.7rem;font-weight:700;padding:1px 6px;border-radius:4px;white-space:nowrap}
.crm-daw-meta{font-size:.75rem;color:#999;margin-left:auto;white-space:nowrap}
.crm-daw-loading,.crm-daw-empty{font-size:.9rem;color:#888;font-style:italic}

/* DAW-Panel – History & Rang */
.crm-daw-group-title { margin-bottom: 4px; }
.crm-daw-item { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border-light, #eee); }
.crm-daw-rank { font-size: .75rem; color: #999; min-width: 22px; font-weight: 600; }
.crm-daw-history-toggle {
    margin-top: 6px; background: none; border: 1px solid var(--border-light, #ccc);
    border-radius: 4px; padding: 2px 10px; font-size: .78rem; cursor: pointer; color: #666;
}
.crm-daw-history-toggle:hover { background: #f5f5f5; }

/* DAW-Panel inline in Eckdaten-Section */
.crm-card:has(.crm-daw-inline) {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}
.crm-card:has(.crm-daw-inline) .crm-field-grid {
    flex: 1 1 55%;
    min-width: 300px;
}
.crm-daw-inline {
    flex: 0 0 280px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: .82rem;
}
.crm-daw-title-inline {
    font-size: .85rem;
    font-weight: 600;
    color: #555;
    margin: 0 0 8px 0;
}

.crm-daw-list-badge {
    font-size: .72rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
    display: inline-block;
}

.crm-daw-list-link { color: inherit; text-decoration: none; }
.crm-daw-list-link:hover { text-decoration: underline; color: #4a6cf7; }

/* --- Lager Bestandsleiste im Sticky-Header --- */
.crm-page-head-sticky.has-stock-bar { flex-wrap: wrap; }
.lager-stock-bar {
    width: 100%; order: 99;
    display: flex; flex-wrap: wrap; gap: 4px 14px;
    padding: 7px 0 0; border-top: 1px solid #e5e8ee; margin-top: 4px;
    font-size: 0.82rem;
}
.lager-stock-item { display: flex; align-items: baseline; gap: 5px; }
.lager-stock-lbl { color: #555; }
.lager-stock-qty { font-weight: 700; color: #1a3a8f; }
.lager-stock-neg-qty { color: #dc2626 !important; }

/* --- File Download-Button in Listenansicht --- */
.crm-file-dl-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 4px;
    background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
    font-size: 0.78rem; font-weight: 500; text-decoration: none;
    white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
    transition: background 0.15s;
}
.crm-file-dl-btn:hover { background: #dbeafe; color: #1e40af; }

/* --- BH Script-Buttons --- */
.bh-script-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bh-script-btn { background: #f0f4ff; color: #1e3a8a; border-color: #c7d7f9; font-size: 0.82rem; }
.bh-script-btn:hover:not(:disabled) { background: #dbeafe; color: #1e40af; }
.bh-script-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.bh-script-status {
    width: 100%; margin-top: 6px; padding: 7px 12px; border-radius: 5px;
    font-size: 0.85rem; font-weight: 500; order: 100;
}
.bh-script-status-running { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.bh-script-status-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.bh-script-status-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.bh-script-status-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.crm-linked-badge {
    font-size: .7rem;
    font-weight: 500;
    color: #6b7280;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: .1rem .45rem;
    vertical-align: middle;
    margin-left: .5rem;
    white-space: nowrap;
}

/* ── Kanban ──────────────────────────────────────────────────────────────── */
.kanban-board { display: flex; gap: 1rem; overflow-x: auto; padding: .5rem 0; }
.kanban-col { flex: 0 0 260px; background: var(--crm-bg, #f8f9fa); border-radius: 8px; padding: .75rem; }
.kanban-col-header { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6b7280; margin-bottom: .5rem; display: flex; justify-content: space-between; align-items: center; }
.kanban-count { background: #e5e7eb; border-radius: 999px; padding: 1px 7px; font-size: .7rem; }
.kanban-cards { min-height: 80px; display: flex; flex-direction: column; gap: .5rem; }
.kanban-cards.drag-over { background: rgba(99,102,241,.08); border-radius: 6px; outline: 2px dashed #6366f1; }
.kanban-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: .6rem .75rem; cursor: grab; user-select: none; }
.kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.kanban-card-title { font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.kanban-card-meta { font-size: .72rem; color: #6b7280; display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .3rem; }
.kanban-progress { background: #e0e7ff; color: #4f46e5; border-radius: 999px; padding: 0 5px; }
.kanban-card-progress { height: 4px; background: #e5e7eb; border-radius: 2px; }
.kanban-card-progress div { height: 100%; background: #6366f1; border-radius: 2px; transition: width .3s; }
.kanban-add-btn { width: 100%; margin-top: .5rem; background: none; border: 1px dashed #d1d5db; border-radius: 6px; padding: .4rem; font-size: .8rem; color: #6b7280; cursor: pointer; }
.kanban-add-btn:hover { background: #f3f4f6; }

.kanban-col[data-status="neu"]       .kanban-col-header { color: #3b82f6; }
.kanban-col[data-status="geplant"]   .kanban-col-header { color: #f59e0b; }
.kanban-col[data-status="in Arbeit"] .kanban-col-header { color: #f97316; }
.kanban-col[data-status="erledigt"]  .kanban-col-header { color: #22c55e; }

/* Projekt-Detail: Aufgaben (bis 2.78.0 standen rechts daneben die Projektnotizen). */
.crm-projekt-spalten { margin-top: 1.5rem; }
.crm-pn-oeffner { margin: .6rem 0 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.crm-pn-oeffner span { color: var(--crm-text-muted, #75767d); font-size: .75rem; }

/* Projektnotizen-Popup: kleines rockinNote (Liste links, Editor rechts) */
.crm-pn { border: none; border-radius: 12px; padding: 0; width: min(1180px, 96vw); max-width: none; height: min(780px, 90vh);
  box-shadow: 0 20px 60px rgba(0,0,0,.3); color: inherit; }
.crm-pn[open] { display: flex; flex-direction: column; }
.crm-pn::backdrop { background: rgba(0,0,0,.45); }
.crm-pn [hidden] { display: none !important; }
.crm-pn-kopf { display: flex; align-items: baseline; gap: .75rem; padding: .9rem 1.1rem .7rem; border-bottom: 1px solid var(--crm-border, #e5e7eb); }
.crm-pn-kopf h2 { margin: 0; font-size: 1.05rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-pn-ort { font-size: .75rem; color: var(--crm-text-muted, #75767d); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-pn-zu { margin-left: auto; border: none; background: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--crm-text-muted, #75767d);
  padding: 0 .3rem; border-radius: 6px; }
.crm-pn-zu:hover { background: rgba(0,0,0,.06); }
.crm-pn-rumpf { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(200px, 280px) 1fr; }
.crm-pn-seite { border-right: 1px solid var(--crm-border, #e5e7eb); padding: .75rem; display: flex; flex-direction: column; gap: .6rem; min-height: 0; }
.crm-pn-neu { align-self: stretch; }
.crm-pn-liste { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .3rem; min-height: 0; }
.crm-pn-zeile { display: flex; flex-direction: column; gap: .1rem; width: 100%; text-align: left; background: none; border: 1px solid transparent;
  border-radius: 8px; padding: .5rem .6rem; cursor: pointer; font: inherit; color: inherit; transition: background-color .12s ease; }
.crm-pn-zeile:hover { background: rgba(0,0,0,.04); }
.crm-pn-zeile.ist-offen { background: rgba(143,42,42,.08); border-color: rgba(143,42,42,.25); }
.crm-pn-zeile-titel { font-weight: 600; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-pn-zeile-meta { font-size: .72rem; color: var(--crm-text-muted, #75767d); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-pn-leer { color: var(--crm-text-muted, #75767d); font-size: .85rem; margin: .25rem .2rem; }
.crm-pn-leer.ist-fehler { color: #b91c1c; }
.crm-pn-haupt { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: .75rem 1rem; gap: .5rem; }
.crm-pn-leerhaupt { margin: auto; color: var(--crm-text-muted, #75767d); font-size: .9rem; }
.crm-pn-editor { flex: 1; min-height: 0; resize: none !important; }
.crm-pn-fuss { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.crm-pn-hinweis { margin: 0; font-size: .78rem; color: var(--crm-text-muted, #75767d); flex: 1; min-width: 12rem; }
.crm-pn-hinweis.ist-fehler { color: #b91c1c; }
.crm-pn-konflikt, .crm-pn-aktionen { display: flex; gap: .5rem; }
@media (max-width: 720px) {
  .crm-pn { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; }
  .crm-pn-rumpf { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .crm-pn-seite { border-right: none; border-bottom: 1px solid var(--crm-border, #e5e7eb); max-height: 30vh; }
}

/* ── Timeline ────────────────────────────────────────────────────────────── */
#task-timeline { overflow-x: auto; }
.tl-wrap { min-width: 500px; }
.tl-header { display: flex; border-bottom: 1px solid #e5e7eb; }
.tl-month { flex: 1; text-align: center; font-size: .7rem; color: #6b7280; padding: .25rem 0; border-right: 1px solid #f0f0f0; }
.tl-row { display: flex; align-items: center; height: 30px; border-bottom: 1px solid #f3f4f6; }
.tl-label { width: 140px; flex-shrink: 0; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: .5rem; }
.tl-track { flex: 1; position: relative; height: 20px; }
.tl-bar { position: absolute; height: 18px; border-radius: 3px; top: 1px; display: flex; align-items: center; padding: 0 .3rem; font-size: .65rem; color: #fff; white-space: nowrap; overflow: hidden; min-width: 4px; }
.tl-today { position: absolute; top: 0; width: 2px; height: 100%; background: #ef4444; opacity: .7; pointer-events: none; }

/* ── Dashboard-Panels (Projekte-Listenansicht) ───────────────────────────── */
.proj-dash-panels { display: flex; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.proj-dash-panel { flex: 1; min-width: 280px; background: var(--crm-bg, #f8f9fa); border-radius: 8px; padding: .75rem 1rem; }
.proj-dash-panel h3 { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6b7280; margin: 0 0 .6rem; }
.proj-open-task-row { display: flex; justify-content: space-between; align-items: center; padding: .3rem 0; border-bottom: 1px solid #e5e7eb; font-size: .82rem; gap: .5rem; }
.proj-open-task-row:last-child { border-bottom: none; }
.proj-task-badge { font-size: .7rem; padding: 1px 7px; border-radius: 999px; background: #fee2e2; color: #991b1b; white-space: nowrap; }
.proj-task-badge.inarbeit { background: #fef3c7; color: #92400e; }

/* ── Task-Modal ──────────────────────────────────────────────────────────── */
.task-modal { border: none; border-radius: 12px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-width: 520px; width: 92%; }
.task-modal::backdrop { background: rgba(0,0,0,.4); }
.task-modal-body { padding: 1.5rem; }
.task-modal-title { font-size: 1rem; font-weight: 700; margin: 0 0 1.25rem; }
.task-field { margin-bottom: .9rem; }
.task-field label { display: block; font-size: .78rem; font-weight: 600; color: #374151; margin-bottom: .3rem; }
.task-field input, .task-field textarea, .task-field select { width: 100%; border: 1px solid #d1d5db; border-radius: 6px; padding: .4rem .6rem; font-size: .85rem; box-sizing: border-box; font-family: inherit; }
.task-field-row { display: flex; gap: .75rem; }
.task-field-row .task-field { flex: 1; min-width: 0; }
.task-modal-actions { display: flex; gap: .5rem; justify-content: flex-end; padding: .75rem 1.5rem; border-top: 1px solid #e5e7eb; }
.task-modal-body { max-height: 80vh; overflow-y: auto; }

/* Timeline Milestone (Datum / Einzeltermin) */
.tl-milestone { position: absolute; top: 0; bottom: 0; width: 2px; transform: translateX(-50%); }
.tl-milestone::before { content: ''; position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; border-radius: 50%; background: currentColor; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); transform: translate(-50%,-50%); }
.tl-milestone-label { position: absolute; top: calc(50% + 8px); left: 50%; transform: translateX(-50%); font-size: .68rem; white-space: nowrap; color: #374151; background: rgba(255,255,255,.88); padding: 0 3px; border-radius: 3px; pointer-events: none; }
.tl-section-divider { margin-left: 140px; border: none; border-top: 1px dashed #d1d5db; margin-bottom: 2px; margin-top: 2px; }

/* Chip-Picker (Beteiligte + CRM) */
.kb-chip-picker { border: 1px solid #b0b7c3; border-radius: 8px; padding: 5px 10px; background: #fff; position: relative; min-height: 36px; display: flex; flex-wrap: wrap; gap: .25rem .3rem; align-items: center; align-content: center; cursor: text; transition: border-color .15s, box-shadow .15s; }
.kb-chip-picker:focus-within { border-color: var(--crm-accent); box-shadow: 0 0 0 3px rgba(91,108,255,0.12); outline: none; }
.kb-chip { display: inline-flex; align-items: center; gap: .2rem; background: #dbeafe; color: #1e40af; border-radius: 4px; padding: .1rem .45rem .1rem .5rem; font-size: .78rem; white-space: nowrap; }
.kb-chip-link { color: inherit; text-decoration: none; }
.kb-chip-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.kb-chip-link:focus-visible { outline: 2px solid var(--crm-accent, #8f2a2a); outline-offset: 1px; border-radius: 2px; }
.kb-chip-remove { background: none; border: none; color: #93c5fd; cursor: pointer; padding: 0 0 0 .1rem; font-size: 1rem; line-height: 1; }
.kb-chip-remove:hover { color: #1e40af; }
.kb-chip-search { -webkit-appearance: none; appearance: none; border: none !important; box-shadow: none !important; outline: none; flex: 1; min-width: 60px; font-size: .84rem; font-family: inherit; padding: .1rem 0 !important; background: transparent !important; color: inherit; width: auto !important; border-radius: 0 !important; }
.kb-chip-dropdown { position: absolute; top: calc(100% + 3px); left: 0; right: 0; z-index: 1000; background: #fff; border: 1px solid #d1d5db; border-radius: 6px; padding: .2rem 0; list-style: none; margin: 0; max-height: 180px; overflow-y: auto; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.kb-chip-dropdown li { padding: .35rem .75rem; cursor: pointer; font-size: .84rem; }
.kb-chip-dropdown li:hover { background: #f3f4f6; }
.kb-chip-dropdown li small { color: #9ca3af; margin-left: .4rem; }

/* Task-Modal: Dateien */
.tm-file-list { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.tm-file-list li { display: flex; align-items: center; gap: .5rem; font-size: .82rem; padding: .3rem .5rem; border: 1px solid #e5e7eb; border-radius: 5px; }
.tm-file-list a { color: var(--crm-accent); text-decoration: none; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-file-list a:hover { text-decoration: underline; }
.tm-file-remove { background: none; border: none; color: #9ca3af; cursor: pointer; padding: 0 2px; font-size: 1rem; line-height: 1; flex-shrink: 0; }
.tm-file-remove:hover { color: #c00; }
.tm-file-upload-label { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .kanban-card { background: #1f2937; border-color: #374151; }
    .kanban-col { background: #111827; }
    .kanban-count { background: #374151; color: #e5e7eb; }
    .kanban-add-btn { border-color: #4b5563; color: #9ca3af; }
    .kanban-add-btn:hover { background: #1f2937; }
    .proj-dash-panel { background: #111827; }
    .proj-open-task-row { border-color: #374151; }
    .task-modal { background: #1f2937; color: #f3f4f6; }
    .task-field input, .task-field textarea, .task-field select { background: #111827; border-color: #4b5563; color: #f3f4f6; }
    .task-modal-actions { border-color: #374151; }
    .kb-chip-picker { background: #111827; border-color: #4b5563; }
    .kb-chip-dropdown { background: #1f2937; border-color: #4b5563; }
    .kb-chip-dropdown li:hover { background: #374151; }
    .tm-file-list li { background: #1f2937; border-color: #374151; }
}


/* ---- Rich-Text-Editor fuer Long-Text-Felder ------------------------------- */
.crm-rt { width: 100%; }
.crm-rt-leiste { display: flex; gap: 3px; align-items: center; flex-wrap: wrap;
                 border: 1px solid #e2e8f0; border-bottom: none;
                 border-radius: 6px 6px 0 0; padding: 4px 6px; background: #f8fafc; }
.crm-rt-leiste button { border: 1px solid transparent; background: none; cursor: pointer;
                        border-radius: 4px; padding: 3px 7px; font-size: .8rem;
                        line-height: 1.2; color: #334155; }
.crm-rt-leiste button:hover:not(:disabled) { background: #e8edf5; border-color: #d3dbe6; }
.crm-rt-leiste button:disabled { opacity: .4; cursor: default; }
.crm-rt-trenner { width: 1px; height: 15px; background: #dbe2ec; margin: 0 3px; }
.crm-rt-abstand { flex: 1; }
.crm-rt-quelle { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
                 font-size: .72rem !important; color: #64748b !important; }
.crm-rt-leiste-aus button:not(.crm-rt-quelle) { opacity: .35; pointer-events: none; }

.crm-rt-editor { border: 1px solid #e2e8f0; border-radius: 0 0 6px 6px;
                 padding: .55rem .7rem; min-height: 120px; background: #fff;
                 font-size: .9rem; line-height: 1.6; overflow-y: auto; max-height: 480px; }
.crm-rt-editor:focus { outline: 2px solid #2563eb; outline-offset: -1px; }
.crm-rt-editor:empty::before { content: attr(data-platzhalter); color: #b6bccd; }
.crm-rt-editor > *:first-child { margin-top: 0; }
.crm-rt-editor > *:last-child { margin-bottom: 0; }
.crm-rt-editor p { margin: .4em 0; }
.crm-rt-editor h1, .crm-rt-editor h2, .crm-rt-editor h3 { margin: .7em 0 .3em; line-height: 1.3; }
.crm-rt-editor h1 { font-size: 1.25rem; }
.crm-rt-editor h2 { font-size: 1.1rem; }
.crm-rt-editor h3 { font-size: 1rem; }
.crm-rt-editor ul, .crm-rt-editor ol { padding-left: 1.4em; margin: .4em 0; }
.crm-rt-editor blockquote { border-left: 3px solid #e2e8f0; margin: .5em 0;
                            padding-left: .8em; color: #64748b; }
.crm-rt-editor pre { background: #f5f7fa; border: 1px solid #e6ebf2; border-radius: 4px;
                     padding: .5rem .65rem; overflow-x: auto; font-size: .82rem; }
.crm-rt-editor code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.crm-rt-editor table { border-collapse: collapse; }
.crm-rt-editor td, .crm-rt-editor th { border: 1px solid #e2e8f0; padding: .25rem .5rem; }

textarea.crm-rt-quelltext { width: 100%; min-height: 220px; border: 1px solid #e2e8f0;
                            border-radius: 0 0 6px 6px; padding: .55rem .7rem;
                            font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
                            font-size: .82rem; line-height: 1.55; resize: vertical; }


/* Pflege der Auswahllisten, aufgerufen am jeweiligen Feld */
.crm-opt-knopf { margin-left:.35rem; padding:.1rem .35rem; border:1px solid #d1d5db;
    border-radius:4px; background:#fff; cursor:pointer; font-size:.85rem; line-height:1.2; }
.crm-opt-knopf:hover { background:#f3f4f6; }
.crm-opt-hg { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:9000;
    display:flex; align-items:center; justify-content:center; }
.crm-opt-fenster { background:#fff; border-radius:8px; width:min(520px,92vw);
    max-height:82vh; display:flex; flex-direction:column;
    box-shadow:0 12px 40px rgba(0,0,0,.3); }
.crm-opt-kopf { display:flex; align-items:baseline; gap:.6rem; padding:.9rem 1rem;
    border-bottom:1px solid #e5e7eb; }
.crm-opt-feld { font-size:.8rem; color:#6b7280; flex:1; }
.crm-opt-zu { border:0; background:none; font-size:1.4rem; line-height:1; cursor:pointer;
    color:#6b7280; }
.crm-opt-liste { list-style:none; margin:0; padding:.5rem; overflow-y:auto; flex:1; }
.crm-opt-zeile { display:flex; align-items:center; gap:.3rem; padding:.15rem 0; }
.crm-opt-wert { flex:1; padding:.3rem .45rem; border:1px solid #d1d5db; border-radius:4px; }
.crm-opt-pfeil, .crm-opt-weg { border:1px solid #e5e7eb; background:#fff; border-radius:4px;
    cursor:pointer; padding:.15rem .35rem; font-size:.75rem; }
.crm-opt-pfeil[disabled] { opacity:.3; cursor:default; }
.crm-opt-weg:hover { background:#fee2e2; border-color:#fca5a5; }
.crm-opt-leer { color:#6b7280; padding:.5rem; font-size:.9rem; }
.crm-opt-neu { display:flex; gap:.4rem; padding:.6rem 1rem; border-top:1px solid #e5e7eb; }
.crm-opt-eingabe { flex:1; padding:.35rem .5rem; border:1px solid #d1d5db; border-radius:4px; }
.crm-opt-hinweis { margin:0; padding:0 1rem .8rem; font-size:.8rem; color:#6b7280; min-height:1.2em; }


/* Postenblock der Rechnung */
/* Breit genug, dass die Beschreibung nicht abschneidet, aber nicht ueber
   die ganze Flaeche gezogen. */
#crm-positionen { margin:.8rem 0 1.2rem; max-width:1400px; }
.crm-pos-tabelle { width:100%; border-collapse:collapse; font-size:.82rem; }
.crm-pos-tabelle th { text-align:left; font-size:.65rem; text-transform:uppercase;
    letter-spacing:.03em; color:#6b7280; border-bottom:1px solid #d1d5db;
    padding:.25rem .4rem; font-weight:600; }
.crm-pos-tabelle td { padding:.2rem .4rem; border-bottom:1px solid #f3f4f6;
    vertical-align:middle; }
.crm-pos-tabelle .r, .crm-pos-tabelle th.r { text-align:right; }
.crm-pos-abgeleitet { color:#4b5563; white-space:nowrap; }
.crm-pos-select { width:100%; max-width:100%; padding:.18rem .3rem; font-size:.82rem;
    border:1px solid #d1d5db; border-radius:3px; text-overflow:ellipsis; }
/* Die Beschreibung bekommt den ganzen uebrigen Platz. */
.crm-pos-tabelle th:nth-child(2), .crm-pos-tabelle td:nth-child(2) { width:40rem; }
.crm-pos-menge { width:3.2rem; padding:.18rem .3rem; font-size:.82rem;
    border:1px solid #d1d5db; border-radius:3px; text-align:right; }
.crm-pos-aktionen { white-space:nowrap; text-align:right; }
/* Die MWST-Bezeichnung ist laenger als sie aussieht ("200 \00b7 Normalsatz
   Inland") - ohne Mindestbreite schneidet das Auswahlfeld sie ab. */
.crm-pos-tabelle th:nth-child(6), .crm-pos-tabelle td:nth-child(6) { min-width:15.5rem; }
.crm-pos-pfeil, .crm-pos-weg { border:1px solid #e5e7eb; background:#fff; border-radius:3px;
    cursor:pointer; padding:0 .22rem; font-size:.7rem; line-height:1.4; }
.crm-pos-pfeil[disabled] { opacity:.3; cursor:default; }
.crm-pos-weg:hover { background:#fee2e2; border-color:#fca5a5; }
.crm-pos-leer, .crm-pos-hinweis { color:#6b7280; padding:.5rem .4rem; font-size:.85rem; }
.crm-pos-summen { margin:.5rem 0 .5rem auto; width:15rem; font-size:.82rem; }
.crm-pos-summen div { display:flex; justify-content:space-between; padding:.12rem 0; }
.crm-pos-summen .summe { border-top:1px solid #374151; font-weight:600;
    margin-top:.15rem; padding-top:.25rem; }
.crm-pos-neu { margin-top:.2rem; font-size:.82rem; padding:.25rem .6rem; }

/* ---- Versandlisten: eine Zeile je Liste, Empfaenger zum Aufklappen -------- */
.vl-leer { background: var(--crm-card-bg); border: 1px solid var(--crm-border);
           border-radius: var(--crm-radius); padding: 2rem; text-align: center;
           color: var(--crm-text-muted); }

.vl-gruppe { background: var(--crm-card-bg); border: 1px solid var(--crm-border);
             border-radius: var(--crm-radius); margin-bottom: 8px; overflow: hidden; }
.vl-gruppe > summary { display: flex; align-items: center; gap: 1rem; cursor: pointer;
                       padding: .7rem .9rem; font-size: .88rem; list-style: none; }
.vl-gruppe > summary::-webkit-details-marker { display: none; }
.vl-gruppe > summary::before { content: '▸'; color: var(--crm-text-muted);
                               font-size: .8rem; width: .8em; flex: none; }
.vl-gruppe[open] > summary::before { content: '▾'; }
.vl-gruppe[open] > summary { border-bottom: 1px solid var(--crm-border); background: var(--crm-bg); }
.vl-gruppe > summary:hover { background: var(--crm-bg); }
.vl-titel { font-weight: 600; flex: none; min-width: 12rem; }
.vl-projekt { color: var(--crm-text-muted); flex: 1; }
.vl-zahlen { color: var(--crm-text-muted); font-size: .8rem; white-space: nowrap; }
.vl-zahlen b { color: var(--crm-text); font-weight: 600; }
.vl-datum { color: var(--crm-text-muted); font-size: .8rem; white-space: nowrap;
            min-width: 9rem; text-align: right; }
.vl-warn { display: inline-block; margin-left: .5rem; padding: 1px 7px; border-radius: 999px;
           background: #fef3c7; color: #92400e; font-size: .72rem; font-weight: 600; }

.vl-inhalt { padding: .9rem; }
.vl-kopf-felder { display: flex; gap: .9rem; flex-wrap: wrap; align-items: flex-end;
                  margin-bottom: .8rem; }
.vl-kopf-felder label { display: flex; flex-direction: column; gap: .25rem;
                        font-size: .7rem; font-weight: 600; letter-spacing: .03em;
                        text-transform: uppercase; color: var(--crm-text-muted); }
.vl-kopf-felder input { font-size: .88rem; padding: .35rem .5rem; font-weight: 400;
                        border: 1px solid var(--crm-border); border-radius: 6px;
                        text-transform: none; letter-spacing: 0;
                        color: var(--crm-text); background: #fff; min-width: 210px; }
.vl-kopf-felder input:focus { outline: 2px solid var(--crm-accent); border-color: var(--crm-accent); }
.vl-hinweis { flex-basis: 100%; padding: .45rem .6rem; border-radius: 6px;
              background: #fef3c7; border: 1px solid #fde68a; color: #92400e;
              font-size: .76rem; font-weight: 400; text-transform: none; letter-spacing: 0; }

.vl-eintraege { width: 100%; border-collapse: collapse; font-size: .85rem; }
.vl-eintraege th { text-align: left; font-size: .68rem; text-transform: uppercase;
                   letter-spacing: .03em; color: var(--crm-text-muted);
                   font-weight: 600; padding: 0 .35rem .35rem; }
.vl-eintraege td { padding: .25rem .35rem; border-top: 1px solid var(--crm-border);
                   vertical-align: middle; }
.vl-eintraege tr.ist-geloescht td { opacity: .45; text-decoration: line-through; }
.vl-auswahl, .vl-menge, .vl-datum-feld {
    width: 100%; padding: .3rem .4rem; font-size: .84rem;
    border: 1px solid var(--crm-border); border-radius: 5px;
    background: #fff; color: var(--crm-text); }
.vl-menge { text-align: right; }
.vl-adresse { color: var(--crm-text-muted); font-size: .79rem; line-height: 1.35; }
.vl-fehlt { color: #b45309; font-style: italic; }
.vl-tag { display: inline-block; margin-left: .35rem; padding: 0 6px; border-radius: 999px;
          background: #eef2ff; color: #3730a3; font-size: .69rem; }
.vl-loeschen { border: none; background: none; cursor: pointer; color: #9ca3af;
               font-size: .92rem; padding: .2rem .3rem; line-height: 1; }
.vl-loeschen:hover { color: var(--crm-error); }

.vl-inhalt-fuss { display: flex; align-items: center; gap: .75rem; margin-top: .8rem; }
.vl-meldung { font-size: .78rem; color: var(--crm-text-muted); margin-left: auto; }
.vl-meldung.ist-fehler { color: var(--crm-error); }

@media (prefers-color-scheme: dark) {
    .vl-gruppe { background: #1f2937; border-color: #374151; }
    .vl-gruppe[open] > summary, .vl-gruppe > summary:hover { background: #111827; }
    .vl-gruppe[open] > summary { border-color: #374151; }
    .vl-eintraege td { border-color: #374151; }
    .vl-kopf-felder input, .vl-auswahl, .vl-menge, .vl-datum-feld {
        background: #111827; border-color: #4b5563; color: #f3f4f6; }
    .vl-leer { background: #1f2937; border-color: #374151; }
    .vl-hinweis { background: #422006; border-color: #78350f; color: #fcd34d; }
    .vl-tag { background: #312e81; color: #c7d2fe; }
}
/* Social-Navigation: angekündigter Eintrag ohne Ziel (daw.rockinbear.net, 14.11.2026) */
.crm-sm-folgt { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 2px; font-size: .86rem; color: var(--crm-text-muted); cursor: default; }
.crm-sm-folgt small { margin-left: auto; font-size: .68rem; padding: 1px 6px; border-radius: 999px; background: rgba(35,35,38,.06); }

/* Hinweis, wenn Dateien zuhause nicht erreichbar sind (Speicherorte.php, seit 18.11.2026) */
.crm-speicher-hinweis { margin: .5rem 1rem 0; padding: .6rem .9rem; border-radius: 8px; background: #fff4e5; color: #7a4a00; font-size: .85rem;
  border: 1px solid #f5d8a8; }
