/* timeler CRM — Stylesheet
   Farbverwaltung: Auto-Kontrast-Logik (analog zu OneFlow SectionRenderer::getContrastColor)
   wird via CSS custom properties + JS-Klassen gesteuert.
*/

/* ------------------------------------------------------------------
   Tokens
   ------------------------------------------------------------------ */
:root {
    --crm-primary:      #2563eb;
    --crm-primary-dark: #1d4ed8;
    --crm-surface:      #ffffff;
    --crm-surface-2:    #f8fafc;
    --crm-border:       #e2e8f0;
    --crm-text:         #1e293b;
    --crm-text-muted:   #64748b;
    --crm-danger:       #ef4444;
    --crm-warning:      #f59e0b;
    --crm-success:      #22c55e;
    --crm-radius:       6px;
    --crm-shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --crm-header-h:     56px;
}

/* ------------------------------------------------------------------
   Reset
   ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Inter, system-ui, sans-serif; font-size: 14px; color: var(--crm-text); background: var(--crm-surface-2); }
a { color: var(--crm-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------
   Header
   ------------------------------------------------------------------ */
.crm-header {
    position: sticky; top: 0; z-index: 100;
    height: var(--crm-header-h);
    background: var(--crm-surface);
    border-bottom: 1px solid var(--crm-border);
    display: flex; align-items: center; gap: 1.5rem;
    padding: 0 1.5rem;
    box-shadow: var(--crm-shadow);
}
.crm-header-brand { display: flex; align-items: center; gap: .5rem; }
.crm-header-logo  { font-weight: 700; font-size: 1.1rem; color: var(--crm-primary); }
.crm-header-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
                     background: var(--crm-primary); color: #fff; padding: 2px 6px; border-radius: 99px; }
.crm-header-tenant { color: var(--crm-text-muted); font-size: .85rem; }

.crm-nav         { display: flex; gap: .25rem; flex: 1; }
.crm-nav-item    { padding: .4rem .8rem; border-radius: var(--crm-radius); color: var(--crm-text-muted);
                    transition: background .15s, color .15s; }
.crm-nav-item:hover, .crm-nav-item.active {
    background: var(--crm-surface-2); color: var(--crm-primary); text-decoration: none;
}
.crm-nav-item.active { font-weight: 600; }

.crm-badge { display: inline-flex; align-items: center; justify-content: center;
              min-width: 18px; height: 18px; padding: 0 5px;
              background: var(--crm-danger); color: #fff; border-radius: 99px;
              font-size: 11px; font-weight: 700; margin-left: 4px; }

.crm-header-user { margin-left: auto; display: flex; align-items: center; gap: 1rem; color: var(--crm-text-muted); }

/* ------------------------------------------------------------------
   Main Layout
   ------------------------------------------------------------------ */
.crm-main { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }
.crm-main--wide { max-width: 100%; padding-left: 2rem; padding-right: 2rem; }

/* ------------------------------------------------------------------
   Toolbar
   ------------------------------------------------------------------ */
.crm-toolbar { display: flex; align-items: center; justify-content: space-between;
                gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.crm-toolbar-left  { display: flex; align-items: center; gap: 1rem; }
.crm-toolbar-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.crm-page-title { font-size: 1.35rem; font-weight: 700; }

/* ------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------ */
.crm-input, .crm-select, .crm-textarea {
    border: 1px solid var(--crm-border); border-radius: var(--crm-radius);
    padding: .45rem .75rem; font-size: 14px; color: var(--crm-text);
    background: var(--crm-surface); outline: none;
    transition: border-color .15s;
}
.crm-input:focus, .crm-select:focus, .crm-textarea:focus {
    border-color: var(--crm-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.crm-input { width: 220px; }
.crm-select { min-width: 140px; }
.crm-select-sm { min-width: 0; font-size: 12px; padding: .3rem .5rem; }
.crm-textarea { width: 100%; resize: vertical; }
.crm-label { display: block; font-size: 12px; font-weight: 600; color: var(--crm-text-muted);
              text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3rem; }
.crm-form-group { margin-bottom: .85rem; }

/* ------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------ */
.crm-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .9rem; border-radius: var(--crm-radius);
    background: var(--crm-primary); color: #fff;
    border: none; cursor: pointer; font-size: 13px; font-weight: 600;
    transition: background .15s;
}
.crm-btn:hover { background: var(--crm-primary-dark); }
.crm-btn-ghost {
    background: transparent; color: var(--crm-text-muted);
    border: 1px solid var(--crm-border);
}
.crm-btn-ghost:hover { background: var(--crm-surface-2); }
.crm-btn-sm { padding: .3rem .65rem; font-size: 12px; }
.crm-btn-icon { display: inline-flex; align-items: center; gap: .3rem; }
.crm-btn-svg { display: inline-flex; line-height: 1; }
.crm-btn-svg svg { width: 14px; height: 14px; }
.crm-doc-icon { flex-shrink: 0; color: var(--crm-text-muted); line-height: 1; }
.crm-doc-icon svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------------
   Tabelle
   ------------------------------------------------------------------ */
.crm-table { width: 100%; border-collapse: collapse; background: var(--crm-surface);
              border-radius: var(--crm-radius); box-shadow: var(--crm-shadow);
              overflow: hidden; }
.crm-table th { padding: .65rem 1rem; text-align: left; font-size: 11px; font-weight: 700;
                 text-transform: uppercase; letter-spacing: .06em; color: var(--crm-text-muted);
                 background: var(--crm-surface-2); border-bottom: 1px solid var(--crm-border); }
.crm-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--crm-border); vertical-align: middle; }
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-row:hover td { background: var(--crm-surface-2); }

.crm-loading { text-align: center; color: var(--crm-text-muted); padding: 2rem !important; }
.crm-empty   { text-align: center; color: var(--crm-text-muted); padding: 2rem !important;
                font-style: italic; }

/* ------------------------------------------------------------------
   Tags
   /* Auto-Kontrast: Textfarbe (schwarz/weiss) wird via getContrastColor()
      in crm.js berechnet — analog zu OneFlow SectionRenderer::getContrastColor()
      (WCAG-Luminanz-Formel: 0.299R + 0.587G + 0.114B, Schwelle 0.5)
      Hintergrundfarbe kommt aus crm_tags.color (hex), Text wird per JS gesetzt.
   ------------------------------------------------------------------ */
.crm-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 99px;
    font-size: 11px; font-weight: 600;
    /* bg + color werden via JS / inline-style gesetzt (auto-contrast) */
}
.crm-tags-bar    { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.crm-tag-editor  { display: flex; flex-direction: column; gap: .5rem; }
.crm-tag-remove  { background: none; border: none; cursor: pointer; opacity: .6;
                    font-size: 14px; line-height: 1; padding: 0; }
.crm-tag-remove:hover { opacity: 1; }

/* ------------------------------------------------------------------
   Status-Badges
   /* Gleiche Auto-Kontrast-Logik — Farbe je Status, Text via getContrastColor()
   ------------------------------------------------------------------ */
.crm-status-badge {
    display: inline-block; padding: 2px 8px; border-radius: 99px;
    font-size: 11px; font-weight: 600;
    /* bg + color per JS */
}

/* ------------------------------------------------------------------
   Status-Tabs (Leads)
   ------------------------------------------------------------------ */
.crm-status-tabs { display: flex; gap: .25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.crm-tab { padding: .4rem .85rem; border-radius: var(--crm-radius);
            background: var(--crm-surface); border: 1px solid var(--crm-border);
            cursor: pointer; font-size: 13px; color: var(--crm-text-muted); }
.crm-tab:hover { background: var(--crm-surface-2); }
.crm-tab.active { background: var(--crm-primary); color: #fff; border-color: var(--crm-primary); }

/* ------------------------------------------------------------------
   Panels (Detail-View)
   ------------------------------------------------------------------ */
.crm-detail-header { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.crm-back-link { color: var(--crm-text-muted); font-size: 13px; margin-top: .3rem; }

.crm-detail-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.25rem;
    align-items: start;
    position: relative;
}
.crm-layout-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 80px;
    padding-bottom: 60px; /* Platz fuer Timer-Bar + Drop-Zone */
}
.crm-main--wide .crm-layout-left {
    position: sticky;
    top: calc(var(--crm-header-h, 60px) + 3.5rem); /* Header + Panel-Nav */
    max-height: calc(100vh - var(--crm-header-h, 60px) - 4.5rem);
    overflow-y: auto;
    scrollbar-width: thin;
}
@media (max-width: 768px) {
    .crm-detail-grid { grid-template-columns: 1fr !important; }
    .crm-main--wide .crm-layout-left { position: static; max-height: none; overflow-y: visible; }
}

.crm-panel {
    background: var(--crm-surface); border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow); padding: 1.25rem;
}

/* Drag & Drop */
.crm-drag-handle {
    cursor: grab; opacity: 0; padding: 0 4px; font-size: 16px;
    transition: opacity .15s; user-select: none; color: var(--crm-text-muted);
}
.crm-panel:hover .crm-drag-handle { opacity: .5; }
.crm-drag-handle:hover { opacity: .8 !important; }
.crm-drag-handle:active { cursor: grabbing; }
.crm-panel.dragging { opacity: .35; outline: 2px dashed var(--crm-primary); }
.crm-drop-placeholder {
    border: 2px dashed var(--crm-primary); border-radius: var(--crm-radius);
    background: rgba(37, 99, 235, .04); min-height: 50px;
    transition: min-height .15s;
}
.crm-layout-column.drag-over {
    background: rgba(37, 99, 235, .02); border-radius: var(--crm-radius);
}
/* Column Resize */
.crm-resize-handle {
    position: absolute; top: 0; bottom: 0; width: 7px;
    cursor: col-resize; z-index: 10; user-select: none;
    background: transparent; transition: background .15s;
}
.crm-resize-handle:hover,
.crm-resize-handle.active {
    background: rgba(37, 99, 235, .15);
}
.crm-resize-handle::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); width: 3px; height: 24px;
    border-radius: 2px; background: var(--crm-text-muted); opacity: 0;
    transition: opacity .15s;
}
.crm-resize-handle:hover::after,
.crm-resize-handle.active::after { opacity: .5; }

@media (max-width: 768px) {
    .crm-drag-handle, .crm-resize-handle { display: none; }
}

.crm-panel-header  { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem;
                      background: var(--crm-bg, #f1f5f9); margin: -1.25rem -1.25rem 1rem; padding: .75rem 1.25rem;
                      border-radius: var(--crm-radius) var(--crm-radius) 0 0; }
.crm-panel-title   { font-size: 1rem; font-weight: 700; margin-right: auto; }

/* Collapsible panels */
.crm-panel-toggle { cursor: pointer; user-select: none; }
.crm-panel-toggle::before { content: '▾'; display: inline-block; width: 1.2em; font-size: 16px;
                             transition: transform .2s; margin-right: 4px; color: var(--crm-text-muted); }
.crm-panel-toggle:hover::before { color: var(--crm-primary, #2563eb); }
.crm-panel.collapsed .crm-panel-toggle::before { transform: rotate(-90deg); }
.crm-panel.collapsed .crm-panel-header { margin-bottom: 0; border-radius: var(--crm-radius); }
.crm-panel-body { transition: none; }
.crm-panel.collapsed .crm-panel-body { display: none; }
.crm-panel-subtitle { font-size: .85rem; font-weight: 600; color: var(--crm-text-muted);
                       margin: 1rem 0 .5rem; }

.crm-dl dt { font-size: 11px; font-weight: 700; text-transform: uppercase;
              letter-spacing: .05em; color: var(--crm-text-muted); margin-top: .6rem; }
.crm-dl dd { margin: 0; }

/* ------------------------------------------------------------------
   Timeline
   ------------------------------------------------------------------ */
.crm-tl-item {
    display: flex; gap: .75rem; padding: .75rem 0;
    border-bottom: 1px solid var(--crm-border); position: relative;
}
.crm-tl-item:last-child { border-bottom: none; }
.crm-tl-icon  { flex-shrink: 0; margin-top: 2px; color: var(--crm-text-muted); line-height: 1; }
.crm-tl-body  { flex: 1; min-width: 0; }
.crm-tl-summary { font-weight: 600; word-break: break-word; }
.crm-tl-meta    { font-size: 12px; color: var(--crm-text-muted); margin-top: 2px; }
.crm-tl-detail  { font-size: 13px; color: var(--crm-text-muted); margin-top: .4rem;
                   white-space: pre-wrap; word-break: break-word; }
.crm-tl-delete { background: none; border: none; cursor: pointer;
                  color: var(--crm-text-muted); font-size: 16px; opacity: 0;
                  transition: opacity .15s; align-self: flex-start; }
.crm-tl-item:hover .crm-tl-delete { opacity: 1; }
.crm-tl-gmail { border-left: 3px solid var(--crm-primary); padding-left: .5rem;
                cursor: pointer; transition: background .15s; border-radius: 0 var(--crm-radius) var(--crm-radius) 0; }
.crm-tl-gmail:hover { background: var(--crm-surface-2); }
.crm-tl-gmail--unread .crm-tl-summary { font-weight: 800; }
.crm-tl-snippet { font-style: italic; max-height: 3.6em; overflow: hidden;
                   display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.crm-tl-dir-badge { display: inline-flex; align-items: center; gap: 2px;
                     font-size: 11px; padding: 1px 6px; border-radius: 99px; font-weight: 600; }
.crm-tl-dir-badge--in     { background: #eff6ff; color: #2563eb; }
.crm-tl-dir-badge--out    { background: #f0fdf4; color: #16a34a; }
.crm-tl-dir-badge--missed     { background: #fef2f2; color: #dc2626; }
.crm-tl-dir-badge--unanswered { background: #fff7ed; color: #c2410c; }
.crm-tl-call { border-left: 3px solid #6b7280; padding-left: .5rem;
               border-radius: 0 var(--crm-radius) var(--crm-radius) 0; }
.crm-tl-call--missed { border-left-color: #dc2626; opacity: .7; }
.crm-tl-call--missed .crm-tl-summary { color: var(--crm-text-muted); }
.crm-tl-filter-wrap { position: relative; display: inline-flex; align-items: center; }
.crm-tl-filter-count { position: absolute; top: -6px; right: -8px;
                        background: var(--crm-primary); color: #fff;
                        font-size: 10px; font-weight: 700; line-height: 1;
                        min-width: 16px; height: 16px; padding: 0 4px;
                        border-radius: 99px; display: flex; align-items: center;
                        justify-content: center; }
.crm-tl-actions { display: flex; gap: .25rem; align-self: flex-start; }
.crm-tl-edit { background: none; border: none; cursor: pointer;
               color: var(--crm-text-muted); font-size: 14px; opacity: 0;
               transition: opacity .15s; }
.crm-tl-item:hover .crm-tl-edit { opacity: 1; }
.crm-tl-note-editor { margin-top: .5rem; }
.crm-tl-note-input { width: 100%; font-size: 13px; resize: vertical; }
.crm-tl-note-actions { display: flex; gap: .5rem; margin-top: .35rem; }
.crm-tl-source-badge { display: inline-flex; align-items: center; font-size: 11px;
                        padding: 1px 6px; border-radius: 99px; font-weight: 600;
                        background: #faf5ff; color: #7c3aed; margin-left: .25rem; }
.crm-tl-timeler-link { display: inline-flex; align-items: center; font-size: 13px;
                        color: var(--crm-primary); text-decoration: none; margin-left: .25rem;
                        opacity: .6; transition: opacity .15s; }
.crm-tl-timeler-link:hover { opacity: 1; }

/* Termin-Notizen (inline editierbar) */
.crm-appt-notes { margin-top: .35rem; cursor: pointer; width: 100%; }
.crm-appt-notes-text { font-size: 13px; color: var(--crm-text-muted); white-space: pre-wrap;
                        padding: .25rem .5rem; border-left: 2px solid var(--crm-border);
                        transition: border-color .15s; }
.crm-appt-notes:hover .crm-appt-notes-text { border-color: var(--crm-primary); }
.crm-appt-notes-add { background: none; border: none; cursor: pointer;
                       font-size: 12px; color: var(--crm-text-muted); padding: .2rem 0;
                       transition: color .15s; }
.crm-appt-notes-add:hover { color: var(--crm-primary); }
.crm-appt-notes-edit { width: 100%; font-size: 13px; resize: vertical; min-height: 2.5rem;
                        box-sizing: border-box; }
.crm-appt-notes-actions { display: flex; gap: .35rem; margin-top: .35rem; align-items: center; }

/* ------------------------------------------------------------------
   Timeline Toolbar (Gmail-Link + Suchfilter)
   ------------------------------------------------------------------ */
.crm-tl-toolbar {
    display: flex; gap: .5rem; align-items: center;
    padding: .5rem .75rem; margin-bottom: .25rem;
    background: var(--crm-surface-2); border-radius: var(--crm-radius);
    font-size: 13px;
}
.crm-tl-toolbar-search {
    flex: 1; min-width: 0;
}
.crm-tl-toolbar-search input {
    width: 100%; padding: .35rem .6rem;
    border: 1px solid var(--crm-border); border-radius: var(--crm-radius);
    font-size: 13px; background: #fff;
}
.crm-tl-toolbar-search input:focus {
    outline: none; border-color: var(--crm-primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.crm-tl-gmail-link {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .35rem .65rem; border-radius: var(--crm-radius);
    background: #fff; border: 1px solid var(--crm-border);
    color: var(--crm-text); text-decoration: none; font-size: 12px;
    font-weight: 500; white-space: nowrap;
    transition: border-color .15s, box-shadow .15s;
}
.crm-tl-gmail-link:hover {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,.1);
}
.crm-tl-gmail-link svg { flex-shrink: 0; }
.crm-tl-item--hidden { display: none !important; }

/* ------------------------------------------------------------------
   E-Mail Modal
   ------------------------------------------------------------------ */
.crm-modal-box--email   { max-width: 720px; }
.crm-modal-box--compose { max-width: 580px; }
.crm-email-subject { font-size: 1.1rem; font-weight: 700; margin-bottom: .25rem; }
.crm-email-date    { font-size: 12px; color: var(--crm-text-muted); margin-bottom: .75rem; }
.crm-email-header  { border-bottom: 1px solid var(--crm-border); padding-bottom: .75rem; margin-bottom: 1rem; }
.crm-email-header-row   { display: flex; gap: .5rem; font-size: 13px; line-height: 1.6; }
.crm-email-header-label { flex: 0 0 28px; color: var(--crm-text-muted); font-weight: 600; font-size: 12px; }
.crm-email-header-value { flex: 1; word-break: break-word; }
.crm-email-body    { max-height: 50vh; overflow-y: auto; font-size: 14px; line-height: 1.6;
                     border: 1px solid var(--crm-border); border-radius: var(--crm-radius);
                     padding: 1rem; background: var(--crm-surface-2); }
.crm-email-body-iframe { width: 100%; border: none; min-height: 200px; }
.crm-email-body-text   { white-space: pre-wrap; word-break: break-word; font-family: inherit; }
.crm-email-actions { display: flex; gap: .5rem; margin-top: 1rem; padding-top: .75rem;
                     border-top: 1px solid var(--crm-border); }
.crm-email-loading { text-align: center; padding: 2rem; color: var(--crm-text-muted); }
.crm-compose-quote { border-left: 3px solid var(--crm-border); padding-left: .75rem; margin-top: .75rem;
                     color: var(--crm-text-muted); font-size: 13px; max-height: 150px;
                     overflow-y: auto; white-space: pre-wrap; }

/* ------------------------------------------------------------------
   Tasks
   ------------------------------------------------------------------ */
.crm-task-item, .crm-task-row {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .6rem 0; border-bottom: 1px solid var(--crm-border);
}
.crm-task-item:last-child, .crm-task-row:last-child { border-bottom: none; }
.crm-task-check { margin-top: 2px; cursor: pointer; }
.crm-task-body  { flex: 1; }
.crm-task-entity { display: block; font-size: 12px; color: var(--crm-primary); text-decoration: none;
                   margin-top: 2px; }
.crm-task-entity:hover { text-decoration: underline; }
.crm-task-assigned { display: block; font-size: 11px; color: var(--crm-text-muted); margin-top: 1px; }
.crm-task-meta  { text-align: right; font-size: 12px; color: var(--crm-text-muted); white-space: nowrap; }
.crm-task-row .crm-actions-menu { opacity: 0; transition: opacity .15s; }
.crm-task-row:hover .crm-actions-menu { opacity: 1; }
.crm-task-item .crm-actions-menu { opacity: 0; transition: opacity .15s; }
.crm-task-item:hover .crm-actions-menu { opacity: 1; }

.crm-task-overdue { background: #fef2f2; border-radius: var(--crm-radius); padding: .5rem .6rem; }
.crm-overdue-label { color: var(--crm-danger); font-weight: 600; }

/* ------------------------------------------------------------------
   Aufgabe-Erstellen: Entity-Suche
   ------------------------------------------------------------------ */
.crm-entity-results {
    border: 1px solid var(--crm-border); border-radius: var(--crm-radius);
    background: var(--crm-surface); max-height: 180px; overflow-y: auto;
    margin-top: .35rem;
}
.crm-entity-results:empty { display: none; }
.crm-search-result-item {
    padding: .5rem .75rem; cursor: pointer; font-size: 14px;
    border-bottom: 1px solid var(--crm-border);
}
.crm-search-result-item:last-child { border-bottom: none; }
.crm-search-result-item:hover { background: var(--crm-surface-2); }
.crm-search-result-empty { padding: .5rem .75rem; font-size: 13px; color: var(--crm-text-muted); }
.crm-entity-chosen { display: flex; align-items: center; gap: .5rem; margin-top: .35rem; }

/* ------------------------------------------------------------------
   Pagination
   ------------------------------------------------------------------ */
.crm-pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.crm-page-btn { padding: .35rem .7rem; border-radius: var(--crm-radius);
                 background: var(--crm-surface); border: 1px solid var(--crm-border);
                 cursor: pointer; font-size: 13px; }
.crm-page-btn:hover { background: var(--crm-surface-2); }
.crm-page-btn.active { background: var(--crm-primary); color: #fff; border-color: var(--crm-primary); }
.crm-page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ------------------------------------------------------------------
   Modal
   ------------------------------------------------------------------ */
.crm-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 500;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.crm-modal[hidden] { display: none; }
.crm-modal-box {
    background: var(--crm-surface); border-radius: var(--crm-radius);
    padding: 1.5rem; width: 100%; max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.crm-modal-title   { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.crm-modal-actions { display: flex; gap: .75rem; margin-top: 1.25rem; }

/* ------------------------------------------------------------------
   Utility
   ------------------------------------------------------------------ */
.crm-muted      { color: var(--crm-text-muted); }
.crm-link-muted { color: var(--crm-text-muted); font-size: 13px; }
.crm-link-muted:hover { color: var(--crm-primary); }

/* SSO Switch Button */
.crm-sso-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    background: transparent;
    color: var(--crm-text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.crm-sso-btn:hover {
    background: var(--crm-primary);
    border-color: var(--crm-primary);
    color: #fff;
}
.crm-sso-btn svg { flex-shrink: 0; }
@media (max-width: 768px) {
    .crm-sso-label { display: none; }
    .crm-sso-btn { padding: 0.3rem 0.4rem; }
}

/* ==================================================================
   Dashboard
   ================================================================== */
.crm-dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}
.crm-dash-today    { grid-column: 1; }
.crm-dash-week     { grid-column: 2; }
.crm-dash-calendar { grid-column: 1 / -1; }
.crm-dash-pipeline { grid-column: 1; }
.crm-dash-alerts   { grid-column: 2; }

/* Card (Dashboard) */
.crm-card {
    background: var(--crm-surface); border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow); padding: 1.25rem;
}
.crm-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.crm-card-title  { font-size: 1rem; font-weight: 700; }
.crm-badge-count { background: var(--crm-surface-2); border: 1px solid var(--crm-border);
                    color: var(--crm-text); font-size: 12px; font-weight: 700;
                    padding: 1px 7px; border-radius: 99px; }

/* Termine (Heute) */
.crm-appt-row {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem 0; border-bottom: 1px solid var(--crm-border);
    cursor: pointer; transition: background .1s;
}
.crm-appt-row:last-child { border-bottom: none; }
.crm-appt-row:hover      { background: var(--crm-surface-2); margin: 0 -.5rem; padding-left: .5rem; padding-right: .5rem; border-radius: var(--crm-radius); }
.crm-appt-time { font-size: 13px; font-weight: 700; color: var(--crm-primary); min-width: 38px; }
.crm-appt-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.crm-appt-info { flex: 1; min-width: 0; }
.crm-appt-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-appt-info span   { font-size: 12px; }
.crm-appt-status { font-size: 11px; color: var(--crm-text-muted); }
.crm-appt-status--bestaetigt { color: var(--crm-success); }
.crm-appt-status--verschoben  { color: var(--crm-warning); }

/* Wochenvorschau */
.crm-week-day   { padding: .5rem 0; border-bottom: 1px solid var(--crm-border); }
.crm-week-day:last-child { border-bottom: none; }
.crm-week-day-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .25rem; }
.crm-week-label { font-size: 13px; font-weight: 600; }
.crm-week-count { font-size: 12px; color: var(--crm-text-muted); }
.crm-week-appts { display: flex; flex-direction: column; gap: 2px; }
.crm-week-appt  { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.crm-week-appt:hover { background: var(--crm-surface-2); border-radius: .25rem; }
.crm-week-appt-time { font-size: 12px; font-weight: 600; color: var(--crm-primary); min-width: 38px; }
.crm-week-appt-info { flex: 1; min-width: 0; }
.crm-week-appt-name { font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-week-appt-meta { font-size: 11px; color: var(--crm-text-muted); }
.crm-week-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.crm-appt-notes { display: block; font-size: 11px; color: var(--crm-text-muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Pipeline */
.crm-pipeline-row      { display: flex; align-items: center; gap: .65rem; padding: .5rem 0; color: inherit; }
.crm-pipeline-label    { font-size: 12px; min-width: 88px; }
.crm-pipeline-bar-wrap { flex: 1; height: 8px; background: var(--crm-surface-2); border-radius: 99px; overflow: hidden; }
.crm-pipeline-bar      { height: 100%; border-radius: 99px; transition: width .4s; min-width: 4px; }
.crm-pipeline-num      { font-size: 13px; font-weight: 700; min-width: 24px; text-align: right; }
.crm-pipeline-total    { font-size: 12px; color: var(--crm-text-muted); text-align: right; margin-top: .5rem; }

/* Alerts */
.crm-alert-row  { display: flex; align-items: center; gap: .65rem; padding: .55rem 0;
                   border-bottom: 1px solid var(--crm-border); cursor: pointer; color: inherit; text-decoration: none; }
.crm-alert-row:last-child { border-bottom: none; }
.crm-alert-row:hover      { color: var(--crm-primary); }
.crm-alert-icon          { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.crm-alert-icon--task    { background: var(--crm-primary); }
.crm-alert-icon--cold    { background: var(--crm-danger); }
.crm-alert-body          { flex: 1; min-width: 0; }
.crm-alert-body strong   { display: block; }
.crm-alert-body span     { font-size: 12px; }
.crm-alert-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
                             color: var(--crm-text-muted); margin: .75rem 0 .25rem; }

/* ------------------------------------------------------------------
   Pipeline-Bar (Lead-Detail)
   ------------------------------------------------------------------ */
.crm-pipeline {
    --pip-h: 36px;
    --pip-arrow: 14px;
    --pip-active: #2c5f7c;
    --pip-inactive: #dfe4ea;
    --pip-inactive-text: #8896a6;
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.crm-pipeline-stages {
    display: flex;
    flex: 1;
    min-width: 0;
    height: var(--pip-h);
}
/* Wrapper noetig damit clip-path kein Nachbar-Element abschneidet */
.crm-pipeline-stage {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--pip-h);
    padding: 0 .5rem 0 calc(var(--pip-arrow) + .35rem);
    font-size: 12px;
    font-weight: 600;
    color: var(--pip-inactive-text);
    background: var(--pip-inactive);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background .2s, color .2s;
    margin-right: -1px; /* nahtlos */
}
/* Pfeil-Form via clip-path: Einbuchtung links, Spitze rechts */
.crm-pipeline-stage { clip-path: polygon(0 0, calc(100% - var(--pip-arrow)) 0, 100% 50%, calc(100% - var(--pip-arrow)) 100%, 0 100%, var(--pip-arrow) 50%); }
.crm-pipeline-stage:first-child {
    clip-path: polygon(0 0, calc(100% - var(--pip-arrow)) 0, 100% 50%, calc(100% - var(--pip-arrow)) 100%, 0 100%);
    padding-left: .75rem;
    border-radius: 4px 0 0 4px;
}
.crm-pipeline-stage:last-child {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, var(--pip-arrow) 50%);
    padding-right: .75rem;
    border-radius: 0 4px 4px 0;
}
/* Durchlaufen + aktuelle Phase */
.crm-pipeline-stage.passed,
.crm-pipeline-stage.current { background: var(--pip-active); color: #fff; }
/* Hover zukuenftige */
.crm-pipeline-stage:not(.current):not(.passed):hover { background: #c5cdd6; color: var(--crm-text); }

/* Outcome-Buttons */
.crm-pipeline-outcomes { display: flex; gap: .35rem; flex-shrink: 0; }
.crm-pipeline-outcome {
    height: var(--pip-h);
    padding: 0 .75rem;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--crm-border);
    background: var(--crm-surface);
    color: var(--crm-text-muted);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.crm-pipeline-outcome--won:hover { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.crm-pipeline-outcome--won.active { background: var(--crm-success); color: #fff; border-color: var(--crm-success); }
.crm-pipeline-outcome--lost:hover { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.crm-pipeline-outcome--lost.active { background: var(--crm-danger); color: #fff; border-color: var(--crm-danger); }
.crm-pipeline-outcome--other:hover { background: #f1f5f9; color: var(--crm-text); }
.crm-pipeline-outcome--other.active { background: #94a3b8; color: #fff; border-color: #94a3b8; }

/* Mobile */
@media (max-width: 768px) {
    .crm-pipeline { flex-direction: column; align-items: stretch; gap: .5rem; }
    .crm-pipeline-stages { height: 30px; }
    .crm-pipeline-stage {
        --pip-h: 30px;
        --pip-arrow: 10px;
        font-size: 11px;
        padding: 0 .3rem 0 calc(var(--pip-arrow) + .2rem);
    }
    .crm-pipeline-stage:first-child { padding-left: .5rem; }
    .crm-pipeline-stage:last-child { padding-right: .5rem; }
    .crm-pipeline-outcomes { justify-content: flex-end; }
    .crm-pipeline-outcome { height: 30px; font-size: 11px; padding: 0 .5rem; }
}

/* ------------------------------------------------------------------
   Kanban-Board
   ------------------------------------------------------------------ */
.crm-kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }

.crm-kanban-col { background: var(--crm-surface-2); border-radius: var(--crm-radius); padding: .75rem; }
.crm-kanban-col-header {
    display: flex; justify-content: space-between; align-items: center;
    border-top: 3px solid #e2e8f0; padding-top: .5rem; margin-bottom: .75rem;
}
.crm-kanban-col-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.crm-kanban-col-count { font-size: 12px; color: var(--crm-text-muted); }

.crm-kanban-card {
    background: var(--crm-surface); border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow); padding: .85rem;
    margin-bottom: .6rem; cursor: pointer;
    transition: box-shadow .15s, transform .1s;
    border-left: 3px solid transparent;
}
.crm-kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: translateY(-1px); }
.crm-kanban-card--cold { border-left-color: var(--crm-danger); }
.crm-kanban-card-name  { font-weight: 600; margin-bottom: 2px; }
.crm-kanban-card-email { font-size: 12px; margin-bottom: .4rem; }
.crm-kanban-card-tags  { margin-bottom: .5rem; }
.crm-kanban-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: .5rem; }
.crm-kanban-move-btn {
    font-size: 11px; padding: 2px 8px; border-radius: var(--crm-radius);
    background: var(--crm-surface-2); border: 1px solid var(--crm-border);
    cursor: pointer; color: var(--crm-text-muted);
    transition: background .15s;
}
.crm-kanban-move-btn:hover { background: var(--crm-primary); color: #fff; border-color: var(--crm-primary); }

/* Cold Badge */
.crm-cold-badge {
    display: inline-block; padding: 1px 6px; border-radius: 99px;
    background: #fef2f2; color: var(--crm-danger); border: 1px solid #fecaca;
    font-size: 10px; font-weight: 700;
}

/* Letzter Kontakt in Lead-Liste */
.crm-last-contact { display: flex; flex-direction: column; gap: 1px; font-size: 12px; line-height: 1.3; }
.crm-last-contact-type { font-weight: 600; font-size: 11px; color: var(--crm-primary); }
.crm-last-contact-summary { color: var(--crm-text); white-space: nowrap; overflow: hidden;
                             text-overflow: ellipsis; max-width: 180px; }
.crm-last-contact-date { color: var(--crm-text-muted); font-size: 11px; }

/* View-Toggle (Liste / Kanban) */
.crm-view-toggle { display: flex; gap: 2px; }
.crm-view-btn {
    display: flex; align-items: center; padding: .35rem .5rem;
    border: 1px solid var(--crm-border); background: var(--crm-surface);
    border-radius: var(--crm-radius); cursor: pointer;
    color: var(--crm-text-muted); transition: background .15s;
}
.crm-view-btn:hover { background: var(--crm-surface-2); }
.crm-view-btn.active { background: var(--crm-primary); color: #fff; border-color: var(--crm-primary); }

/* ------------------------------------------------------------------
   Settings
   ------------------------------------------------------------------ */
.crm-tag-create-form { display: flex; gap: .5rem; align-items: center; margin: .75rem 0; flex-wrap: wrap; }
.crm-color-input { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--crm-border);
                    border-radius: var(--crm-radius); cursor: pointer; background: var(--crm-surface); }
.crm-settings-tag-row  { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--crm-border); }
.crm-settings-tag-count { font-size: 12px; }
.crm-settings-tag-actions { margin-left: auto; display: flex; gap: .4rem; }
.crm-btn-danger { color: var(--crm-danger); border-color: #fecaca; }
.crm-btn-danger:hover { background: #fef2f2; }

/* Next Appointment (Patient Detail) */
.crm-next-appt {
    display: flex; flex-direction: column; gap: 2px;
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--crm-radius);
    padding: .65rem .85rem; margin-bottom: 1rem;
}
.crm-next-appt-label { font-size: 11px; font-weight: 700; text-transform: uppercase;
                         letter-spacing: .05em; color: var(--crm-primary); }
.crm-next-appt strong { font-size: 14px; }
.crm-next-appt span   { font-size: 12px; }

/* ==================================================================
   RESPONSIVE — Mobile First
   ================================================================== */

/* Bottom-Nav: standardmaessig unsichtbar (Desktop) */
.crm-bottom-nav { display: none; }

/* ------------------------------------------------------------------
   Mobile (bis 640 px)
   ------------------------------------------------------------------ */
@media (max-width: 640px) {

    /* Platz fuer fixierte Bottom-Nav */
    body { padding-bottom: 64px; }

    /* Header: kompakter, Desktop-Nav ausblenden */
    .crm-header {
        padding: 0 .875rem;
        gap: .5rem;
    }
    .crm-nav                      { display: none; }
    .crm-header-tenant            { display: none; }
    .crm-header-user > span:first-child { display: none; } /* Nutzername */

    /* Main: weniger Padding */
    .crm-main { padding: .875rem .75rem; }

    /* Toolbar: untereinander */
    .crm-toolbar       { flex-direction: column; align-items: stretch; }
    .crm-toolbar-right { flex-direction: column; }

    /* Inputs und Selects: volle Breite */
    .crm-input  { width: 100%; }
    .crm-select { width: 100%; min-width: 0; }

    /* Status-Tabs: horizontal scrollen statt umbrechen */
    .crm-status-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: .25rem;
    }
    .crm-tab { white-space: nowrap; flex-shrink: 0; }

    /* Tabellen: horizontaler Scroll */
    .crm-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .crm-table th,
    .crm-table td { white-space: nowrap; }
    .crm-table th:first-child,
    .crm-table td:first-child { white-space: normal; min-width: 130px; }

    /* Detail-Header */
    .crm-detail-header { gap: .5rem; margin-bottom: 1rem; }

    /* Modal: Bottom Sheet */
    .crm-modal     { padding: 0; align-items: flex-end; }
    .crm-modal-box {
        border-radius: var(--crm-radius) var(--crm-radius) 0 0;
        max-width: 100%;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Dashboard: untereinander stapeln */
    .crm-dash-grid {
        grid-template-columns: 1fr;
    }
    .crm-dash-today,
    .crm-dash-week,
    .crm-dash-calendar,
    .crm-dash-pipeline,
    .crm-dash-alerts { grid-column: 1; grid-row: auto; }

    /* Kanban: Cards horizontal scrollbar */
    .crm-kanban {
        grid-template-columns: repeat(3, 78vw);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: .5rem;
    }

    /* Bottom-Nav einblenden */
    .crm-bottom-nav {
        display: flex;
        position: fixed; bottom: 0; left: 0; right: 0;
        height: 64px;
        background: var(--crm-surface);
        border-top: 1px solid var(--crm-border);
        box-shadow: 0 -2px 12px rgba(0,0,0,.08);
        z-index: 200;
    }
    .crm-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: .4rem .25rem;
        color: var(--crm-text-muted);
        font-size: 10px;
        font-weight: 500;
        text-align: center;
        text-decoration: none;
        border-top: 2px solid transparent;
        overflow: hidden;
        transition: color .15s, border-color .15s;
        position: relative;
    }
    .crm-bottom-nav-item.active {
        color: var(--crm-primary);
        border-top-color: var(--crm-primary);
        font-weight: 700;
    }
    .crm-bottom-nav-icon {
        display: block;
        width: 22px; height: 22px;
        margin: 0 auto;
    }
    .crm-bottom-nav-icon svg {
        width: 100%; height: 100%;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    .crm-bottom-nav-item .crm-badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 20px);
        font-size: 10px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
    }
    .crm-bottom-nav-label {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }
}

/* ------------------------------------------------------------------
   Tablet (641–960 px)
   ------------------------------------------------------------------ */
@media (min-width: 641px) and (max-width: 960px) {
    .crm-main { padding: 1.25rem 1rem; }
    .crm-detail-grid { grid-template-columns: 240px 1fr !important; }
}

/* ------------------------------------------------------------------
   Kontaktdetails
   ------------------------------------------------------------------ */
.crm-cd-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem 0;
    border-bottom: 1px solid var(--crm-border);
    font-size: 13px;
}
.crm-cd-row:last-child { border-bottom: none; }
.crm-cd-type {
    flex: 0 0 80px;
    color: var(--crm-text-muted);
    font-size: 12px;
}
.crm-cd-value { flex: 1; word-break: break-word; }
.crm-cd-value a { color: var(--crm-primary); }
.crm-cd-delete {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--crm-text-muted);
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: opacity .15s;
}
.crm-cd-row:hover .crm-cd-delete { opacity: 1; }
.crm-cd-row-input { gap: .35rem; }
.crm-cd-row-input .crm-cd-input { flex: 1; }
.crm-cd-add-row { display: flex; gap: .5rem; }
.crm-empty-sm { font-size: 12px; padding: .25rem 0; }
.crm-btn-xs {
    padding: .2rem .5rem;
    font-size: 12px;
    border-radius: var(--crm-radius);
    cursor: pointer;
    border: 1px solid var(--crm-border);
    background: var(--crm-surface);
    color: var(--crm-text);
}
.crm-input-sm { padding: .3rem .5rem; font-size: 13px; }

/* Ansprechpartner-Cards */
.crm-contact-card {
    padding: .6rem .8rem;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    margin-bottom: .5rem;
    background: var(--crm-surface);
}
.crm-contact-card--primary {
    border-left: 3px solid var(--crm-primary);
}
.crm-contact-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.crm-contact-card-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.crm-contact-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--crm-primary);
    background: rgba(37, 99, 235, .08);
    padding: 1px 6px;
    border-radius: 99px;
}
.crm-contact-card-role {
    font-size: 12px;
    color: var(--crm-text-muted);
    margin-top: 2px;
}
.crm-contact-card-details {
    font-size: 12px;
    margin-top: .35rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.crm-contact-card-actions {
    margin-top: .4rem;
    display: flex;
    gap: .5rem;
}
.crm-text-danger { color: var(--crm-danger); }

/* Timeline: Kontaktperson */
.crm-tl-contact {
    color: var(--crm-primary);
    font-weight: 500;
}

/* ------------------------------------------------------------------
   Dokumente
   ------------------------------------------------------------------ */
.crm-doc-list { list-style: none; }
.crm-doc-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem 0; border-bottom: 1px solid var(--crm-border);
    font-size: 13px;
}
.crm-doc-item:last-child { border-bottom: none; }
.crm-doc-icon { flex: 0 0 20px; font-size: 16px; text-align: center; }
.crm-doc-info { flex: 1; min-width: 0; }
.crm-doc-title { font-weight: 600; display: block; white-space: nowrap;
                  overflow: hidden; text-overflow: ellipsis; }
.crm-doc-title a { color: var(--crm-text); }
.crm-doc-title a:hover { color: var(--crm-primary); text-decoration: none; }
.crm-doc-meta { font-size: 11px; color: var(--crm-text-muted); }
.crm-doc-type-badge {
    display: inline-block; padding: 1px 6px; border-radius: 99px;
    font-size: 10px; font-weight: 600; flex-shrink: 0;
}
.crm-doc-type-badge--link       { background: #eff6ff; color: #2563eb; }
.crm-doc-type-badge--google_doc { background: #fef9c3; color: #a16207; }
.crm-doc-type-badge--file       { background: #f1f5f9; color: #475569; }
.crm-doc-delete {
    flex: 0 0 auto; background: none; border: none;
    color: var(--crm-text-muted); cursor: pointer;
    font-size: 14px; opacity: 0; transition: opacity .15s;
}
.crm-doc-item:hover .crm-doc-delete { opacity: 1; }
.crm-doc-notes { font-size: 11px; color: var(--crm-text-muted);
                  font-style: italic; margin-top: 1px;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-doc-empty { font-size: 12px; color: var(--crm-text-muted);
                  font-style: italic; padding: .5rem 0; }

/* Checkbox-Label */
.crm-label-checkbox {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-transform: none;
    font-weight: 400;
    cursor: pointer;
}

/* ------------------------------------------------------------------
   Actions-Dropdown (Lead-Aktionen: Spam, Loeschen)
   ------------------------------------------------------------------ */
.crm-actions-cell { position: relative; padding: 0 !important; vertical-align: middle; }
.crm-actions-menu { position: relative; display: inline-block; }
.crm-actions-btn {
    background: none; border: none; cursor: pointer; font-size: 18px;
    color: var(--crm-text-muted); padding: 4px 8px; border-radius: var(--crm-radius);
    line-height: 1;
}
.crm-actions-btn:hover { background: var(--crm-border); color: var(--crm-text); }
.crm-actions-dropdown {
    position: absolute; right: 0; top: 100%; z-index: 50;
    background: var(--crm-surface); border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius); box-shadow: var(--crm-shadow);
    min-width: 120px; padding: 4px 0;
}
.crm-actions-dropdown button {
    display: block; width: 100%; text-align: left; padding: 6px 12px;
    background: none; border: none; cursor: pointer; font-size: 13px;
    color: var(--crm-text); white-space: nowrap;
}
.crm-actions-dropdown button:hover { background: var(--crm-surface-2); }
.crm-actions-dropdown button.crm-danger { color: var(--crm-danger); }
.crm-actions-dropdown button.crm-danger:hover { background: #fef2f2; }

/* Kanban-Card Header (Name + Actions nebeneinander) */
.crm-kanban-card-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 4px;
}
.crm-kanban-card-header .crm-actions-btn { padding: 2px 4px; font-size: 16px; }
.crm-kanban-card-header .crm-actions-dropdown { right: 0; }

/* ------------------------------------------------------------------
   Custom Fields
   ------------------------------------------------------------------ */
.crm-cf-row {
    display: flex; align-items: center; gap: .5rem;
    padding: .375rem 0; border-bottom: 1px solid var(--crm-border);
}
.crm-cf-row:last-child { border-bottom: none; }
.crm-cf-label {
    font-size: 13px; color: var(--crm-text-muted);
    min-width: 120px; flex-shrink: 0;
}
.crm-cf-value {
    flex: 1; font-size: 14px; cursor: pointer;
    padding: 2px 4px; border-radius: var(--crm-radius);
    min-height: 1.5em;
}
.crm-cf-value:hover { background: var(--crm-surface-2); }
.crm-cf-value--empty { color: var(--crm-text-muted); font-style: italic; }
.crm-cf-value--required { border-left: 2px solid #f59e0b; padding-left: 6px; }
.crm-cf-value--required.crm-cf-value--empty { border-left-color: var(--crm-danger); }
.crm-cf-input { width: 100%; }
.crm-cf-checkbox { cursor: pointer; width: 16px; height: 16px; }
.crm-cf-type-badge {
    display: inline-block; font-size: 11px; padding: 2px 6px;
    border-radius: 4px; background: var(--crm-surface-2); color: var(--crm-text-muted);
}
.crm-cf-def-row {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem 0; border-bottom: 1px solid var(--crm-border);
}
.crm-cf-def-row:last-child { border-bottom: none; }
.crm-cf-def-label { flex: 1; font-size: 14px; }
.crm-cf-def-required { font-size: 11px; color: #f59e0b; font-weight: 600; }
.crm-cf-preset-banner {
    background: #eff6ff; border: 1px solid #bfdbfe;
    border-radius: var(--crm-radius); padding: .75rem 1rem; margin-bottom: 1rem;
}

/* Settings 2-Column Layout */
.crm-settings-grid {
    display: grid; grid-template-columns: 240px 1fr;
    gap: 1.5rem; align-items: start;
}
.crm-settings-sidebar {
    position: sticky; top: calc(var(--crm-header-h, 60px) + 1rem);
    max-height: calc(100vh - var(--crm-header-h, 60px) - 2rem);
    overflow-y: auto; scrollbar-width: thin;
    background: var(--crm-surface); border-radius: var(--crm-radius, 8px);
    box-shadow: var(--crm-shadow, 0 1px 3px rgba(0,0,0,.1));
    padding: .75rem 0;
}
.crm-settings-content {
    display: flex; flex-direction: column; gap: 1.25rem; min-width: 0;
}
.crm-settings-cat-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--crm-text-muted, #64748b);
    padding: .75rem 1rem .25rem; margin: 0;
}
.crm-settings-cat-label:first-child { padding-top: .25rem; }
.crm-settings-cat-item {
    display: block; padding: .4rem 1rem .4rem 1.5rem;
    font-size: 13px; color: var(--crm-text, #1e293b);
    border-left: 2px solid transparent;
    text-decoration: none; transition: all .15s; cursor: pointer;
}
.crm-settings-cat-item:hover { color: var(--crm-primary); background: rgba(0,0,0,.02); }
.crm-settings-cat-item.active {
    border-left-color: var(--crm-primary); color: var(--crm-primary); font-weight: 600;
}
.crm-settings-cat-link {
    display: block; padding: .4rem 1rem .4rem 1.5rem;
    font-size: 13px; color: var(--crm-text-muted, #64748b);
    text-decoration: none; transition: all .15s;
}
.crm-settings-cat-link:hover { color: var(--crm-primary); }
.crm-settings-separator { border-top: 1px solid var(--crm-border, #e2e8f0); margin: .5rem 1rem; }
.crm-settings-group-heading {
    font-size: 14px; font-weight: 700; margin: 1.5rem 0 .5rem;
    padding-bottom: .5rem; border-bottom: 1px solid var(--crm-border, #e2e8f0);
}
.crm-settings-group-heading:first-child { margin-top: 0; }
@media (max-width: 768px) {
    .crm-settings-grid { grid-template-columns: 1fr; }
    .crm-settings-sidebar {
        position: static; max-height: none;
        display: flex; flex-wrap: wrap; gap: .25rem; padding: .5rem;
    }
    .crm-settings-cat-label, .crm-settings-separator { display: none; }
    .crm-settings-cat-item {
        border-left: none; border-radius: 999px;
        border: 1px solid var(--crm-border, #e2e8f0); padding: .25rem .75rem;
    }
    .crm-settings-cat-item.active {
        background: var(--crm-primary); color: #fff;
        border-color: var(--crm-primary);
    }
    .crm-settings-cat-link {
        border-radius: 999px; border: 1px solid var(--crm-border, #e2e8f0);
        padding: .25rem .75rem;
    }
}

/* Panel Anchor Navigation */
.crm-panel-nav {
    position: sticky; top: var(--crm-header-h, 60px); z-index: 80;
    display: flex; gap: .375rem;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: var(--crm-surface-2, #f1f5f9);
    padding: .5rem 1rem; margin: 0 -1rem .75rem;
    border-bottom: 1px solid var(--crm-border);
}
.crm-panel-nav::-webkit-scrollbar { display: none; }
.crm-panel-nav-pill {
    flex-shrink: 0;
    padding: .3rem .65rem;
    font-size: 12px; font-weight: 500;
    color: var(--crm-text-muted);
    background: var(--crm-surface, #fff);
    border: 1px solid var(--crm-border);
    border-radius: 999px;
    cursor: pointer; white-space: nowrap;
    transition: all .15s;
}
.crm-panel-nav-pill:hover {
    color: var(--crm-primary); border-color: var(--crm-primary);
}
.crm-panel-nav-pill.active {
    background: var(--crm-primary); color: #fff;
    border-color: var(--crm-primary);
}
@media (max-width: 768px) {
    .crm-panel-nav { padding: .375rem .75rem; margin: 0 -.75rem .5rem; }
    .crm-panel-nav-pill { font-size: 11px; padding: .25rem .5rem; }
}

/* Branding */
.crm-header-logo-img {
    height: 32px; width: auto; max-width: 160px; object-fit: contain;
}
.crm-brand-preview {
    width: 120px; height: 60px;
    border: 1px dashed var(--crm-border); border-radius: var(--crm-radius);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: .5rem; overflow: hidden; background: var(--crm-surface-2);
}
.crm-brand-preview img {
    max-width: 100%; max-height: 100%; object-fit: contain;
}
.crm-color-input {
    width: 40px; height: 34px; padding: 2px;
    border: 1px solid var(--crm-border); border-radius: var(--crm-radius);
    cursor: pointer; background: transparent;
}
.crm-color-row {
    display: flex; gap: .5rem; align-items: center;
}

/* ── Audio-Notiz: Transkript & Zusammenfassung ── */
.crm-tl-collapsible {
    margin-top: .5rem;
    border: 1px solid var(--crm-border);
    border-radius: .375rem;
    overflow: hidden;
}
.crm-tl-collapsible-header {
    padding: .375rem .75rem;
    font-size: 12px;
    font-weight: 600;
    color: var(--crm-muted);
    cursor: pointer;
    user-select: none;
    background: var(--crm-bg-subtle, #f8fafc);
    list-style: none;
}
.crm-tl-collapsible-header::marker,
.crm-tl-collapsible-header::-webkit-details-marker {
    display: none;
}
.crm-tl-collapsible-header::before {
    content: '▸ ';
}
details[open] > .crm-tl-collapsible-header::before {
    content: '▾ ';
}
.crm-tl-collapsible-header:hover {
    color: var(--crm-text);
}
.crm-tl-collapsible-body {
    padding: .5rem .75rem;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}
.crm-task-row .crm-tl-collapsible-body {
    white-space: normal;
}
.crm-task-transcript-actions {
    display: flex;
    gap: .375rem;
    margin-top: .5rem;
    flex-wrap: wrap;
}
.crm-task-transcript-edit .crm-textarea {
    width: 100%;
    font-size: 13px;
    line-height: 1.5;
}
.crm-tl-transcript {
    font-family: var(--crm-font-mono, 'SF Mono', 'Fira Code', monospace);
    font-size: 12px;
}
.crm-tl-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .03em;
    vertical-align: middle;
    margin-left: .375rem;
}
.crm-tl-badge--audio {
    background: #dbeafe;
    color: #1e40af;
}
.crm-tl-badge--transcript {
    background: #f0fdf4;
    color: #166534;
}
/* Timeline: Task-Items */
.crm-tl-task {
    border-left: 2px solid #e2e8f0;
}
.crm-tl-task--done {
    opacity: .6;
}
.crm-tl-icon--task {
    flex-shrink: 0;
}
.crm-tl-task-title--done {
    text-decoration: line-through;
    color: var(--crm-text-muted);
}
.crm-tl-badge--done {
    background: #dcfce7 !important;
    color: #166534 !important;
}
.crm-tl-badge--consent-given {
    background: #dcfce7 !important;
    color: #166534 !important;
}
.crm-tl-badge--consent-revoked {
    background: #fef2f2 !important;
    color: #991b1b !important;
}
.crm-tl-task-overdue {
    color: #dc2626;
    font-weight: 600;
}

.crm-tl-error {
    margin-top: .375rem;
    padding: .375rem .5rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: .25rem;
    font-size: 12px;
    color: #991b1b;
}
.crm-btn-danger {
    color: #dc2626;
    border-color: #fca5a5;
}
.crm-btn-danger:hover {
    background: #fef2f2;
}
.crm-btn-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.crm-btn-link:hover {
    color: var(--crm-danger, #dc2626);
}

/* ------------------------------------------------------------------
   Task-Erweiterungen: Kategorien, Delegation, KI-Pill, Dashboard
   ------------------------------------------------------------------ */

/* Kategorie-Dot */
.crm-category-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Task-Zeile Erweiterungen */
.crm-task-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.crm-task-desc {
    font-size: 12px;
    margin-top: 2px;
    line-height: 1.4;
}
.crm-task-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}
.crm-task-time {
    font-size: 11px;
    color: #64748b;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
}
.crm-task-delegation {
    font-size: 11px;
    color: #7c3aed;
    font-style: italic;
}

/* Audio/Transkript-Badges auf Tasks */
.crm-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.crm-badge--audio {
    background: #dbeafe;
    color: #1e40af;
}
.crm-badge--transcript {
    background: #dcfce7;
    color: #166534;
}
.crm-badge--review {
    background: #fef3c7;
    color: #92400e;
}
.crm-badge--review.crm-badge--ai {
    background: #ede9fe;
    color: #5b21b6;
}

/* AI-Ergebnis Preview in Task */
.crm-task-ai-result {
    border-left: 3px solid #f59e0b;
    background: #fffbeb;
    padding: 6px 10px;
    margin: 6px 0;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 0 4px 4px 0;
    color: #78350f;
}

/* Success-Button */
.crm-btn-success {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}
.crm-btn-success:hover {
    background: #15803d;
}

/* KI-Delegation Pill */
.crm-ai-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity .2s;
    line-height: 1.4;
}
.crm-ai-pill:hover {
    opacity: 0.85;
}
.crm-ai-pill:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Dashboard: Handlungsbedarf Erweiterungen */
.crm-alert-urgent {
    background: #fef2f2 !important;
    border-color: #fecaca !important;
}
.crm-alert-urgent:hover {
    background: #fee2e2 !important;
}
.crm-alert-icon--overdue::before {
    content: '!';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}
.crm-alert-icon--today::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    margin: 6px;
}
.crm-alert-today {
    background: #fffbeb !important;
}
.crm-alert-category {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

/* Dashboard: kompakte Stat-Pills */
.crm-dash-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
}
.crm-dash-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: #f1f5f9;
    color: #475569;
}
.crm-dash-pill--overdue {
    background: #fef2f2;
    color: #dc2626;
}
.crm-dash-pill--today {
    background: #fffbeb;
    color: #d97706;
}
.crm-dash-pill--time {
    background: #f0f9ff;
    color: #0284c7;
}
.crm-dash-pill--new {
    background: #f0fdf4;
    color: #16a34a;
}
.crm-dash-pill--converted {
    background: #f0fdf4;
    color: #15803d;
}

/* Pipeline-Badges (inline neben Zahl) */
.crm-pipeline-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    font-weight: 600;
    line-height: 1.4;
    flex-shrink: 0;
}
.crm-pipeline-badge--new {
    background: #f0fdf4;
    color: #16a34a;
}
.crm-pipeline-badge--stale {
    background: #fef2f2;
    color: #dc2626;
}

/* Dashboard: einzelne Task-Zeilen */
.crm-dash-task {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.crm-dash-task:hover {
    background: #f8fafc;
}
.crm-dash-task:last-of-type {
    border-bottom: none;
}
.crm-dash-task .crm-category-dot {
    margin-top: 5px;
    flex-shrink: 0;
}
.crm-dash-task-body {
    flex: 1;
    min-width: 0;
}
.crm-dash-task-title {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-dash-task-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 11px;
    color: #94a3b8;
}
.crm-dash-entity {
    color: #64748b;
    font-weight: 500;
}
.crm-dash-deleg {
    color: #8b5cf6;
}
.crm-dash-est {
    color: #0284c7;
}
.crm-dash-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
}
.crm-dash-badge--audio {
    background: #dbeafe;
    color: #3b82f6;
}
.crm-dash-badge--transcript {
    background: #ede9fe;
    color: #7c3aed;
}

/* Dashboard: Faelligkeits-Labels */
.crm-dash-due {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
    margin-top: 3px;
}
.crm-dash-due--overdue {
    color: #dc2626;
}
.crm-dash-due--today {
    color: #d97706;
}

/* Dashboard: "Alle X Aufgaben" Link */
.crm-dash-show-all {
    display: block;
    padding: 8px 12px;
    font-size: 12px;
    color: #64748b;
    text-decoration: none;
    text-align: center;
    border-top: 1px solid #f1f5f9;
}
.crm-dash-show-all:hover {
    color: #1e293b;
    background: #f8fafc;
}

/* ------------------------------------------------------------------
   Dashboard Kalender
   ------------------------------------------------------------------ */
.crm-cal-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}
.crm-cal-nav button {
    background: none;
    border: 1px solid var(--crm-border);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 16px;
    cursor: pointer;
    color: var(--crm-text);
    display: flex;
    align-items: center;
    justify-content: center;
}
.crm-cal-nav button:hover { background: var(--crm-surface-2); }
.crm-cal-month-label {
    font-size: 13px;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

.crm-cal-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 2px;
}
.crm-cal-header-cell {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--crm-text-muted);
    padding: 4px 0;
}
.crm-cal-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--crm-border);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    overflow: hidden;
}
.crm-cal-cell {
    background: var(--crm-surface);
    min-height: 68px;
    padding: 4px 5px;
    cursor: pointer;
    transition: background .15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.crm-cal-cell:hover { background: #f1f5f9; }
.crm-cal-cell--other {
    background: var(--crm-surface-2);
    cursor: default;
}
.crm-cal-cell--today {
    box-shadow: inset 0 0 0 2px var(--crm-primary);
}
.crm-cal-cell--past .crm-cal-day-num { color: #94a3b8; }
.crm-cal-cell--selected { background: #eff6ff; }
.crm-cal-cell--has-items { cursor: pointer; }

.crm-cal-day-num {
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 2px;
}
.crm-cal-event {
    border-left: 3px solid #6b7280;
    padding: 1px 4px;
    font-size: 10px;
    line-height: 1.3;
    background: #f8fafc;
    border-radius: 0 2px 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-cal-event-time {
    color: var(--crm-text-muted);
    font-variant-numeric: tabular-nums;
}
.crm-cal-task-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 1px 0;
}
.crm-cal-task-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.crm-cal-more {
    font-size: 10px;
    color: var(--crm-text-muted);
    line-height: 1;
}

/* Detail-Panel */
.crm-cal-detail {
    margin-top: 12px;
    border-top: 1px solid var(--crm-border);
    padding-top: 12px;
}
.crm-cal-detail-header {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}
.crm-cal-detail-section {
    font-size: 11px;
    font-weight: 600;
    color: var(--crm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0 4px;
}
.crm-cal-detail-appt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background .15s;
}
.crm-cal-detail-appt:hover { background: #f1f5f9; }
.crm-cal-detail-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--crm-text);
    font-variant-numeric: tabular-nums;
    min-width: 36px;
}
.crm-cal-detail-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.crm-cal-detail-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 13px;
    min-width: 0;
}
.crm-cal-detail-task {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--crm-text);
    font-size: 13px;
    transition: background .15s;
}
.crm-cal-detail-task:hover { background: #f1f5f9; }
.crm-cal-detail-task-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-cal-detail-task--done .crm-cal-detail-task-title { text-decoration: line-through; color: #94a3b8; }
.crm-cal-detail-task--overdue .crm-cal-detail-task-title { color: var(--crm-danger); }
.crm-cal-detail-status {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 8px;
    flex-shrink: 0;
}
.crm-cal-detail-task--done .crm-cal-detail-status { background: #f0fdf4; color: #16a34a; }
.crm-cal-detail-task--overdue .crm-cal-detail-status { background: #fef2f2; color: #dc2626; }

/* Kalender responsive */
@media (max-width: 768px) {
    .crm-cal-cell { min-height: 44px; padding: 3px; }
    .crm-cal-event { display: none; }
    .crm-cal-cell--has-items::after {
        content: '';
        display: block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--crm-primary);
        margin: auto;
    }
    .crm-cal-task-indicator { display: none; }
    .crm-cal-more { display: none; }
}

/* Ressourcen-Balken */
.crm-resource-bar {
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #475569;
    margin-top: 8px;
}

/* Team-Workload */
.crm-workload-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-bottom: 1px solid #f1f5f9;
}
.crm-workload-row:last-child {
    border-bottom: none;
}
.crm-workload-name {
    font-size: 13px;
    font-weight: 500;
    color: #334155;
}
.crm-workload-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #64748b;
}

/* ==================================================================
   Zeiterfassung — Time Entries
   ================================================================== */

/* Summary-Bar */
.crm-te-summary {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--crm-surface-2);
    border-radius: var(--crm-radius);
    margin-bottom: .75rem;
    font-size: 13px;
}
.crm-te-summary-item { display: flex; align-items: baseline; gap: 4px; }
.crm-te-summary-val { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.crm-te-summary-label { color: var(--crm-text-muted); }

/* Time Entry Cards */
.crm-te-card {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .625rem .75rem;
    border-radius: 8px;
    border: 1px solid var(--crm-border, #e2e8f0);
    margin-bottom: .5rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    position: relative;
}
.crm-te-card:hover { background: var(--crm-surface-2); border-color: var(--crm-primary, #2563eb); }
.crm-te-card--billable { border-left: 3px solid #22c55e; }
.crm-te-card--non-billable { border-left: 3px solid var(--crm-border, #e2e8f0); }
.crm-te-card-left {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    min-width: 56px; flex-shrink: 0;
}
.crm-te-card-duration {
    font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums;
    white-space: nowrap; color: var(--crm-text);
}
.crm-te-card-body { flex: 1; min-width: 0; }
.crm-te-card-product {
    font-weight: 600; font-size: 13px; color: var(--crm-text);
    margin-bottom: 2px;
}
.crm-te-card-note {
    font-size: 12.5px; color: var(--crm-text-muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.crm-te-card-meta {
    font-size: 11px; color: var(--crm-text-muted);
    margin-top: 3px;
}
.crm-te-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    font-size: 10px; font-weight: 600;
}
.crm-te-badge--billable { background: #dcfce7; color: #15803d; }
.crm-te-badge--non-billable { background: #f1f5f9; color: #94a3b8; }
.crm-te-card-delete {
    background: none; border: none; color: var(--crm-text-muted);
    cursor: pointer; padding: 2px 6px; border-radius: 4px;
    font-size: 14px; line-height: 1;
    opacity: 0; transition: opacity .15s, color .15s, background .15s;
    flex-shrink: 0; align-self: center;
}
.crm-te-card:hover .crm-te-card-delete { opacity: 1; }
.crm-te-card-delete:hover { color: var(--crm-danger); background: #fef2f2; }
.crm-te-edited { font-size: 11px; color: var(--crm-text-muted, #94a3b8); font-style: italic; }

/* Actions-Zeile am Ende des Panels */
.crm-te-actions {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--crm-border);
}

/* Timer-Start Modal */
.crm-timer-modal .crm-modal-box { max-width: 420px; }
.crm-timer-modal .crm-form-row {
    display: flex;
    gap: .75rem;
}
.crm-timer-modal .crm-form-row > .crm-form-group { flex: 1; }
.crm-timer-modal .crm-form-group { margin-bottom: .75rem; }
.crm-timer-modal .crm-form-group:last-child { margin-bottom: 0; }
.crm-timer-modal .crm-label { display: block; font-size: 12px; font-weight: 600; color: var(--crm-text-muted); margin-bottom: 4px; }
.crm-timer-modal .crm-select,
.crm-timer-modal .crm-input,
.crm-timer-modal textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    font-size: 13px;
    font-family: inherit;
    background: var(--crm-surface);
    color: var(--crm-text);
    transition: border-color .15s;
}
.crm-timer-modal textarea { resize: vertical; min-height: 60px; }
.crm-timer-modal .crm-select:focus,
.crm-timer-modal .crm-input:focus,
.crm-timer-modal textarea:focus {
    outline: none;
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.crm-timer-modal .crm-checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.crm-timer-modal .crm-checkbox-row input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: var(--crm-primary);
}

/* Timer Widget (bottom bar) — Stopp-Notiz eingeblendet */
.crm-timer-stop-note {
    display: none;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.crm-timer-stop-note.active { display: flex; }
.crm-timer-stop-note input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 4px;
    background: rgba(255,255,255,.15);
    color: #fff;
    font-size: 12px;
    font-family: inherit;
}
.crm-timer-stop-note input::placeholder { color: rgba(255,255,255,.5); }
.crm-timer-stop-note input:focus { outline: none; border-color: rgba(255,255,255,.6); }

/* ---- Navbar Timer-Link / Indikator ---- */
.crm-timer-nav {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--crm-bg, #f1f5f9);
    color: var(--crm-text-muted, #64748b);
    font-size: 13px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.crm-timer-nav:hover { background: var(--crm-border, #e2e8f0); }
.crm-timer-nav-icon { font-size: 14px; line-height: 1; }
.crm-timer-nav-active {
    background: rgba(239, 68, 68, .1);
    color: var(--crm-danger, #ef4444);
    font-weight: 600;
    font-size: 12px;
}
.crm-timer-nav-active:hover { background: rgba(239, 68, 68, .18); }
.crm-timer-nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--crm-danger, #ef4444);
    animation: crm-timer-pulse 1.5s ease-in-out infinite;
}
@keyframes crm-timer-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .4; transform: scale(.8); }
}
.crm-timer-admin-row { display:flex; align-items:center; gap:.75rem; border-bottom:1px solid var(--crm-border,#e2e8f0); font-size:13px; }
.crm-timer-admin-row:last-child { border-bottom:none; }

.crm-timer-widget-stuck {
    background: var(--crm-danger, #ef4444) !important;
    animation: crm-timer-stuck-flash 2s ease-in-out infinite;
}
@keyframes crm-timer-stuck-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: .85; }
}

@media (max-width: 768px) {
    .crm-te-card { padding: .5rem .625rem; gap: .5rem; }
    .crm-te-card-left { min-width: 48px; }
    .crm-te-card-delete { opacity: 1; }
}

/* RBAC Toggle-Switches */
.crm-toggle-wrap {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    cursor: pointer;
}
.crm-toggle-wrap input {
    opacity: 0;
    width: 0;
    height: 0;
}
.crm-toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 18px;
    transition: background .2s;
}
.crm-toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}
.crm-toggle-wrap input:checked + .crm-toggle-slider {
    background: var(--crm-primary, #2563eb);
}
.crm-toggle-wrap input:checked + .crm-toggle-slider::before {
    transform: translateX(14px);
}
.crm-btn-xs {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}
