/* 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; }

/* ------------------------------------------------------------------
   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; }

/* ------------------------------------------------------------------
   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;
    grid-template-rows: auto auto;
    gap: 1.25rem;
    align-items: start;
}
@media (max-width: 768px) {
    .crm-detail-grid { grid-template-columns: 1fr; }
}

.crm-panel {
    background: var(--crm-surface); border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow); padding: 1.25rem;
}
.crm-panel-wide { grid-column: 2; grid-row: 1 / 3; }
@media (max-width: 768px) { .crm-panel-wide { grid-column: 1; grid-row: auto; } }

.crm-panel-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.crm-panel-title   { font-size: 1rem; font-weight: 700; }
.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  { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.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, #3b82f6); padding-left: .5rem; }
.crm-tl-snippet { font-style: italic; max-height: 3.6em; overflow: hidden;
                   display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

/* ------------------------------------------------------------------
   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-meta  { text-align: right; font-size: 12px; color: var(--crm-text-muted); }

.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); }

/* ==================================================================
   Dashboard
   ================================================================== */
.crm-dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1.25rem;
    align-items: start;
}
.crm-dash-today    { grid-column: 1; grid-row: 1; }
.crm-dash-week     { grid-column: 1; grid-row: 2; }
.crm-dash-pipeline { grid-column: 2; grid-row: 1; }
.crm-dash-alerts   { grid-column: 2; grid-row: 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; }

/* ------------------------------------------------------------------
   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;
}

/* 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-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; }
}

/* ------------------------------------------------------------------
   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);
}
.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;
}

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