/* =============================================================================
   Abschluss – Design-System (Core, SPEC §8)
   Klassen: .btn .btn-primary/.btn-secondary/.btn-ghost/.btn-danger .btn-sm/.btn-lg/.btn-icon
            .card .card-header .card-body .table .pill .badge .tabs .field .input .select .checkbox .chip
            .dropdown .dropdown-menu .dropdown-item .modal .toast .timeline .timeline-item .avatar .empty-state
   ============================================================================= */

:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-muted: #f3f4f6;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-text-faint: #9ca3af;
  --color-primary: #0f766e;
  --color-primary-hover: #0d6560;
  --color-primary-soft: #ccfbf1;
  --color-success: #16a34a;
  --color-success-soft: #dcfce7;
  --color-warning: #d97706;
  --color-warning-soft: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;
  --color-info: #2563eb;
  --color-info-soft: #dbeafe;
  --color-sidebar: #111827;
  --color-sidebar-text: #d1d5db;
  --color-sidebar-hover: #1f2937;
  --color-sidebar-active: #0f766e;
  --sidebar-width: 220px;
  --topbar-height: 52px;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .06);
  --shadow: 0 4px 12px rgba(17, 24, 39, .08);
  --shadow-lg: 0 20px 40px rgba(17, 24, 39, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --row-height: 36px;
  --transition: 120ms ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  color: var(--color-text); background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; } h4 { font-size: 13px; }
p { margin: 0 0 .5em; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: 16px 0; }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }
kbd {
  font-family: var(--font); font-size: 11px; padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--color-border-strong); background: var(--color-surface-muted); color: var(--color-text-muted);
  box-shadow: inset 0 -1px 0 var(--color-border-strong);
}
code, pre { font-family: var(--font-mono); font-size: 12.5px; }
pre { background: var(--color-surface-muted); padding: 10px 12px; border-radius: var(--radius-sm); overflow: auto; }
.skip-link { position: absolute; left: -9999px; top: 0; background: #fff; padding: 8px; z-index: 1000; }
.skip-link:focus { left: 8px; }
.icon { flex-shrink: 0; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  background: var(--color-sidebar); color: var(--color-sidebar-text);
  display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; z-index: 40;
}
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; padding: 20px 24px 40px; min-width: 0; }
.main-full { padding: 0; }
.container { max-width: 1200px; margin: 0 auto; }
.container-narrow { max-width: 760px; margin: 0 auto; }

/* Sidebar */
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border-radius: 7px; background: var(--color-primary); color: #fff;
}
.brand-mark-lg { width: 44px; height: 44px; border-radius: 10px; }
.nav { list-style: none; margin: 0; padding: 6px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--color-sidebar-text); font-weight: 500; transition: background var(--transition), color var(--transition);
  min-width: 0;
}
.nav-link:hover { background: var(--color-sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--color-sidebar-active); color: #fff; }
.nav-compact .nav-link { padding: 5px 10px; font-weight: 400; font-size: 13px; }
.nav-flag { margin-left: auto; color: #fbbf24; display: inline-flex; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sidebar-section { padding: 6px 0 4px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 4px; }
.sidebar-section-head {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 18px 2px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9ca3af; font-weight: 600;
}
.sidebar-section-action { color: #9ca3af; display: inline-flex; }
.sidebar-section-action:hover { color: #fff; }
.sidebar-empty { font-size: 12px; color: #9ca3af; padding: 6px 18px 8px; margin: 0; }
.sidebar-empty a { color: #5eead4; }
.sidebar-footer { margin-top: auto; padding: 10px 8px 12px; border-top: 1px solid rgba(255,255,255,.08); position: relative; }
.user-menu-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; background: transparent;
  color: var(--color-sidebar-text); border-radius: var(--radius-sm); cursor: pointer; text-align: left; font: inherit;
}
.user-menu-btn:hover { background: var(--color-sidebar-hover); color: #fff; }
.user-menu-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-menu-name { font-weight: 600; font-size: 13px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-role { font-size: 11px; color: #9ca3af; }
.sidebar-backdrop { display: none; }
.topbar-menu { display: none; }

/* Topbar */
.topbar {
  height: var(--topbar-height); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--color-surface); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 30;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.omnibox { position: relative; flex: 1; max-width: 560px; display: flex; align-items: center; }
.omnibox-icon { position: absolute; left: 10px; color: var(--color-text-faint); display: inline-flex; pointer-events: none; }
.omnibox-input {
  width: 100%; height: 36px; padding: 0 40px 0 34px; border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-bg); font: inherit; color: var(--color-text); outline: none; transition: border var(--transition), box-shadow var(--transition);
}
.omnibox-input:focus { background: #fff; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
.omnibox-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.omnibox-kbd { position: absolute; right: 10px; pointer-events: none; }
.omnibox-suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow); max-height: 70vh; overflow: auto; z-index: 50;
}
.omnibox-suggestions:empty { display: none; }
.suggest-group { padding: 6px 0; border-top: 1px solid var(--color-border); }
.suggest-group:first-child { border-top: 0; }
.suggest-group-title { padding: 4px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); font-weight: 600; }
.suggest-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px; color: var(--color-text); }
.suggest-item:hover, .suggest-item.is-active { background: var(--color-surface-muted); text-decoration: none; }
.suggest-item .text-muted { margin-left: auto; font-size: 12px; }

/* Page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.page-subtitle { color: var(--color-text-muted); margin: 2px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-muted); margin-bottom: 6px; }

/* ---------- Grid & Spacing ---------- */
.grid { display: grid; gap: 16px; }
.grid-gap { gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } .flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex-1 { flex: 1; min-width: 0; } .ml-auto { margin-left: auto; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.p-0 { padding: 0 !important; }
.w-full { width: 100%; }
.text-muted { color: var(--color-text-muted); } .text-faint { color: var(--color-text-faint); }
.text-primary { color: var(--color-primary); } .text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); } .text-danger { color: var(--color-danger); }
.text-sm { font-size: 12.5px; } .text-xs { font-size: 11.5px; } .text-lg { font-size: 16px; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.text-right { text-align: right; } .text-center { text-align: center; } .nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---------- Karten ---------- */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.card-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--color-text-muted); }
.card-body { padding: 16px; }
.card-body-flush { padding: 0; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--color-border); background: var(--color-bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-compact .card-header { padding: 8px 12px; } .card-compact .card-body { padding: 12px; }
/* Card spacing belongs to the containing layout (grid gap or stack margins).
   A sibling margin here would offset every grid card after the first one. */
.stat { padding: 14px 16px; }
.stat-label { font-size: 12px; color: var(--color-text-muted); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stat-delta { font-size: 12px; color: var(--color-text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: var(--radius); border: 1px solid transparent; font: inherit; font-weight: 500; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: background var(--transition), border var(--transition), color var(--transition), box-shadow var(--transition);
  color: var(--color-text); background: transparent; line-height: 1; text-decoration: none; user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--color-border-strong); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-surface-muted); }
.btn-secondary.active { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-muted); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-danger-outline { background: #fff; color: var(--color-danger); border-color: var(--color-danger); }
.btn-danger-outline:hover { background: var(--color-danger-soft); }
.btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-link { background: none; border: 0; color: var(--color-primary); padding: 0; height: auto; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-xs { height: 24px; padding: 0 7px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14.5px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; } .btn-icon.btn-xs { width: 24px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn .htmx-indicator { display: none; }
.btn.htmx-request .htmx-indicator { display: inline-flex; }
.btn.htmx-request > .icon:not(.htmx-indicator) { display: none; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; }
.form-grid .field-kind-richtext, .form-grid .field-kind-textarea, .form-grid .field-span { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.form-actions-left { justify-content: flex-start; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-inline { flex-direction: row; align-items: center; gap: 12px; }
.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.label { font-size: 12.5px; font-weight: 600; color: var(--color-text); }
.label .required { color: var(--color-danger); }
.field-help { font-size: 12px; color: var(--color-text-muted); margin: 0; }
.field-error { font-size: 12px; color: var(--color-danger); margin: 0; }
.input, .select, textarea.input {
  width: 100%; min-height: 34px; padding: 6px 10px; border: 1px solid var(--color-border-strong); border-radius: var(--radius);
  background: #fff; font: inherit; color: var(--color-text); outline: none; transition: border var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
.input:disabled, .select:disabled { background: var(--color-surface-muted); color: var(--color-text-muted); cursor: not-allowed; }
.input::placeholder { color: var(--color-text-faint); }
.input-sm { min-height: 28px; padding: 3px 8px; font-size: 13px; }
.input-number { text-align: right; font-variant-numeric: tabular-nums; }
.input-color { width: 60px; padding: 2px; height: 34px; }
textarea.input { resize: vertical; line-height: 1.45; }
select.input, .select {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
select[multiple].input { background-image: none; padding-right: 10px; }
.has-error .input, .has-error .select, .has-error textarea.input { border-color: var(--color-danger); }
.has-error .label { color: var(--color-danger); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; height: auto; min-height: 34px; }
.input-group > .input:only-child { border-radius: var(--radius); }
.checkbox, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; }
.checkbox input, .radio input { width: 16px; height: 16px; accent-color: var(--color-primary); margin: 0; cursor: pointer; }
.checkbox-list { display: flex; flex-direction: column; gap: 6px; }
.checkbox-list-inline { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; }
.fieldset { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
.fieldset-legend {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted);
  padding: 0 0 8px; display: flex; align-items: center; gap: 4px; width: 100%;
}
.fieldset-toggle { cursor: pointer; user-select: none; }
.fieldset-toggle:hover { color: var(--color-text); }
.field-archived .label { color: var(--color-text-muted); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 34px; height: 20px; border-radius: 999px; background: var(--color-border-strong); position: relative; transition: background var(--transition); }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--transition); box-shadow: var(--shadow-sm); }
.switch input:checked + .switch-track { background: var(--color-primary); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }

/* Chips & Multiselect */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--color-primary-soft); color: var(--color-primary); border: 1px solid transparent; line-height: 1.4; max-width: 100%;
}
.chip-muted { background: var(--color-surface-muted); color: var(--color-text); }
.chip-remove { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; opacity: .7; }
.chip-remove:hover { opacity: 1; }
.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.multiselect { position: relative; }
.multiselect-control { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; cursor: text; min-height: 34px; padding: 4px 8px; }
.multiselect-input { border: 0; outline: none; flex: 1; min-width: 80px; font: inherit; background: transparent; padding: 2px 0; }
.multiselect-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: 240px; overflow: auto; }

/* Filter-Chips (Timeline etc.) */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--color-border-strong);
  background: #fff; color: var(--color-text-muted); font-size: 12.5px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.filter-chip:hover { background: var(--color-surface-muted); color: var(--color-text); text-decoration: none; }
.filter-chip.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* Richtext */
.richtext { border: 1px solid var(--color-border-strong); border-radius: var(--radius); background: #fff; }
.richtext:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
.richtext-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--color-border); background: var(--color-bg); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.richtext-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 0; border-radius: 4px; background: transparent; color: var(--color-text-muted); cursor: pointer; }
.richtext-btn:hover { background: var(--color-border); color: var(--color-text); }
.richtext-btn.active { background: var(--color-primary-soft); color: var(--color-primary); }
.richtext-sep { width: 1px; height: 18px; background: var(--color-border); margin: 0 4px; }
.richtext-editor { border: 0 !important; box-shadow: none !important; min-height: 110px; max-height: 420px; overflow: auto; border-radius: 0 0 var(--radius) var(--radius); outline: none; }
.richtext-editor:empty::before { content: attr(data-placeholder); color: var(--color-text-faint); pointer-events: none; }
.richtext-editor p { margin: 0 0 .4em; }
.richtext-editor ul, .richtext-editor ol, .prose ul, .prose ol { padding-left: 1.4em; margin: .3em 0; }
.prose { line-height: 1.55; word-break: break-word; overflow-wrap: anywhere; }
.prose p { margin: 0 0 .5em; } .prose p:last-child { margin-bottom: 0; }
.prose a { text-decoration: underline; }
.prose img { max-width: 100%; height: auto; }
.prose table { border-collapse: collapse; } .prose td, .prose th { border: 1px solid var(--color-border); padding: 2px 6px; }
.prose blockquote { margin: .4em 0; padding-left: 10px; border-left: 3px solid var(--color-border-strong); color: var(--color-text-muted); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: #fff; }
.card .table-wrap { border: 0; border-radius: 0; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td { height: var(--row-height); padding: 0 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table th {
  position: sticky; top: 0; z-index: 2; background: var(--color-bg); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--color-text-muted); border-bottom: 1px solid var(--color-border-strong);
}
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th.sorted { color: var(--color-primary); }
.table tbody tr:nth-child(even) { background: #fafafa; }
.table tbody tr:hover { background: var(--color-primary-soft); }
.table tbody tr.is-selected { background: #e0f2fe; }
.table tbody tr.is-focused td:first-child { box-shadow: inset 3px 0 0 var(--color-primary); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.wrap, .table th.wrap { white-space: normal; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-check { width: 36px; padding-right: 0; }
.table .col-actions { width: 1%; text-align: right; }
.table .row-link { color: var(--color-text); font-weight: 500; }
.table .row-link:hover { color: var(--color-primary); }
.table-clickable tbody tr { cursor: pointer; }
.table-compact th, .table-compact td { height: 30px; padding: 0 8px; font-size: 13px; }
.table-plain th { position: static; }
.dl { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--color-text-muted); font-weight: 500; } .dl dd { margin: 0; min-width: 0; word-break: break-word; }
.dl-compact { gap: 3px 10px; }

/* Bulk-Leiste */
.bulk-bar {
  position: sticky; bottom: 12px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-top: 12px;
  background: var(--color-sidebar); color: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 20;
}
.bulk-bar .btn-ghost { color: #d1d5db; } .bulk-bar .btn-ghost:hover { background: var(--color-sidebar-hover); color: #fff; }

/* ---------- Pills & Badges ---------- */
.pill {
  --pill-color: #6b7280;
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5;
  color: var(--pill-color); background: color-mix(in srgb, var(--pill-color) 13%, white); border: 1px solid color-mix(in srgb, var(--pill-color) 30%, white);
  white-space: nowrap; max-width: 100%;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--pill-color); flex-shrink: 0; }
.pill-muted { --pill-color: #9ca3af; }
.pill-plain::before { display: none; }
.pill-sm { font-size: 11px; padding: 1px 7px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 600; line-height: 1.5;
  background: var(--color-surface-muted); color: var(--color-text-muted);
}
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }
.badge-count { min-width: 18px; justify-content: center; border-radius: 999px; padding: 0 5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--color-text-faint); }
.dot-success { background: var(--color-success); } .dot-warning { background: var(--color-warning); } .dot-danger { background: var(--color-danger); } .dot-primary { background: var(--color-primary); }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); border: 1px solid; font-size: 13.5px; margin-bottom: 12px; }
.alert p { margin: 0; }
.alert-info { background: var(--color-info-soft); border-color: #bfdbfe; color: #1e3a8a; }
.alert-success { background: var(--color-success-soft); border-color: #bbf7d0; color: #14532d; }
.alert-warning { background: var(--color-warning-soft); border-color: #fde68a; color: #78350f; }
.alert-danger { background: var(--color-danger-soft); border-color: #fecaca; color: #7f1d1d; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--color-text-muted); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab .badge { margin-left: 2px; }
.tabs-pills { border: 0; gap: 4px; margin-bottom: 12px; }
.tabs-pills .tab { border: 1px solid var(--color-border-strong); border-radius: 999px; padding: 4px 12px; margin: 0; height: 28px; font-size: 12.5px; }
.tabs-pills .tab.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 200px; background: #fff; border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; z-index: 60; display: flex; flex-direction: column;
}
.dropdown-menu.dropdown-left { right: auto; left: 0; }
.dropdown-menu.dropdown-up { top: auto; bottom: calc(100% + 4px); left: 8px; right: 8px; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: var(--radius-sm);
  color: var(--color-text); font: inherit; text-align: left; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.dropdown-item:hover { background: var(--color-surface-muted); text-decoration: none; }
.dropdown-item.active { background: var(--color-primary-soft); color: var(--color-primary); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item kbd { margin-left: auto; }
.dropdown-item .icon { color: var(--color-text-muted); }
.dropdown-divider { height: 1px; background: var(--color-border); margin: 4px 0; }
.dropdown-title { padding: 6px 10px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); font-weight: 600; }
.dropdown-empty { padding: 8px 10px; color: var(--color-text-muted); font-size: 12.5px; }
.dropdown-menu form { display: contents; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); }
.modal-dialog { position: relative; width: 100%; max-width: 640px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: modal-in 140ms ease-out; }
.modal-wide .modal-dialog { max-width: 960px; }
.modal-narrow .modal-dialog { max-width: 440px; }
.modal-close { position: absolute; top: 10px; right: 10px; z-index: 1; }
.modal-body { min-height: 80px; }
.modal-header { padding: 16px 48px 12px 20px; border-bottom: 1px solid var(--color-border); }
.modal-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-content { padding: 16px 20px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--color-border); background: var(--color-bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-footer-left { margin-right: auto; }
.modal-loading { display: flex; align-items: center; gap: 10px; padding: 32px 20px; color: var(--color-text-muted); justify-content: center; }
.confirm-object { padding: 8px 12px; background: var(--color-surface-muted); border-radius: var(--radius-sm); }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--color-sidebar); color: #fff;
  box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in 160ms ease-out; border-left: 4px solid #9ca3af;
}
.toast-success { border-left-color: var(--color-success); } .toast-success .toast-icon { color: #4ade80; }
.toast-error, .toast-danger { border-left-color: var(--color-danger); } .toast-error .toast-icon, .toast-danger .toast-icon { color: #f87171; }
.toast-warning { border-left-color: var(--color-warning); } .toast-warning .toast-icon { color: #fbbf24; }
.toast-info { border-left-color: var(--color-info); } .toast-info .toast-icon { color: #93c5fd; }
.toast-icon { display: inline-flex; margin-top: 1px; }
.toast-text { flex: 1; }
.toast-close { border: 0; background: none; color: #9ca3af; cursor: pointer; padding: 0; display: inline-flex; }
.toast-close:hover { color: #fff; }
.toast.is-leaving { opacity: 0; transform: translateX(12px); transition: opacity 200ms, transform 200ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Avatare ---------- */
.avatar {
  --avatar-color: var(--color-primary);
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--avatar-color); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
}
.avatar-sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.avatar-muted { background: var(--color-border-strong); color: var(--color-text); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-left: -6px; border: 2px solid #fff; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.user-inline { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--color-border); position: relative; }
.timeline-item:last-child { border-bottom: 0; }
.timeline-item.is-pinned { background: #fffbeb; margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-radius: var(--radius-sm); }
.timeline-icon {
  width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-surface-muted); color: var(--color-text-muted);
}
.timeline-icon.type-call { background: var(--color-info-soft); color: var(--color-info); }
.timeline-icon.type-email { background: #ede9fe; color: #6d28d9; }
.timeline-icon.type-note { background: var(--color-warning-soft); color: var(--color-warning); }
.timeline-icon.type-meeting { background: #fce7f3; color: #be185d; }
.timeline-icon.type-sms, .timeline-icon.type-whatsapp { background: var(--color-success-soft); color: var(--color-success); }
.timeline-icon.type-custom { background: var(--color-primary-soft); color: var(--color-primary); }
.timeline-icon.type-task_completed { background: var(--color-success-soft); color: var(--color-success); }
.timeline-icon.type-lead_status_change, .timeline-icon.type-opportunity_status_change { background: var(--color-surface-muted); color: var(--color-text-muted); }
.timeline-main { min-width: 0; }
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.timeline-head .user { font-weight: 600; }
.timeline-head .time { color: var(--color-text-muted); margin-left: auto; white-space: nowrap; font-size: 12px; }
.timeline-head .type { color: var(--color-text-muted); }
.timeline-body { margin-top: 4px; line-height: 1.5; }
.timeline-body .prose { max-height: 400px; overflow: auto; }
.timeline-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 12px; color: var(--color-text-muted); }
.timeline-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.timeline-item:hover .timeline-actions, .timeline-item:focus-within .timeline-actions { opacity: 1; }
.timeline-day { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); padding: 14px 0 4px; }
.timeline-more { display: flex; justify-content: center; padding: 12px 0; }
.timeline-quote { border-left: 3px solid var(--color-border-strong); padding-left: 10px; color: var(--color-text-muted); }

/* ---------- Leerzustände ---------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }
.empty-state-icon { display: inline-flex; width: 56px; height: 56px; border-radius: 50%; align-items: center; justify-content: center; background: var(--color-surface-muted); color: var(--color-text-faint); margin-bottom: 12px; }
.empty-state-title { font-size: 15px; color: var(--color-text); margin-bottom: 4px; }
.empty-state-text { max-width: 420px; margin: 0 auto 14px; }
.empty-state-sm { padding: 18px 12px; font-size: 13px; }
.empty-state-sm .empty-state-icon { width: 36px; height: 36px; margin-bottom: 6px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 0; flex-wrap: wrap; }
.pagination-info { color: var(--color-text-muted); font-size: 12.5px; }
.pagination-pages { display: flex; align-items: center; gap: 2px; }
.pagination-gap { padding: 0 4px; color: var(--color-text-faint); }

/* ---------- Spinner / Indicator ---------- */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--color-border-strong); border-top-color: var(--color-primary); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-sm { width: 12px; height: 12px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-indicator { opacity: 0; transition: opacity var(--transition); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.is-loading { position: relative; pointer-events: none; }
.is-loading::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.6); border-radius: inherit; }
.htmx-request.hx-fade { opacity: .5; transition: opacity 150ms; }

/* ---------- Hilfe-Overlay ---------- */
.help-overlay { position: fixed; inset: 0; z-index: 150; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.help-panel { width: 100%; max-width: 720px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 20px 24px; }
.help-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.help-header h2 { display: flex; align-items: center; gap: 8px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.help-grid h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); margin-bottom: 8px; }
.shortcut-list { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.shortcut-list > div { display: flex; align-items: center; gap: 10px; }
.shortcut-list dt { min-width: 64px; }
.shortcut-list dd { margin: 0; color: var(--color-text); }
.help-footer { margin: 16px 0 0; font-size: 12px; }

/* ---------- Auth ---------- */
.auth-page .main-wrap { justify-content: center; align-items: center; background: linear-gradient(160deg, #f0fdfa 0%, var(--color-bg) 45%, #eef2ff 100%); }
.auth-main { display: flex; align-items: center; justify-content: center; width: 100%; }
.auth-card { width: 100%; max-width: 400px; padding: 28px 28px 22px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-title { font-size: 22px; font-weight: 700; }
.auth-subtitle { margin: 2px 0 0; color: var(--color-text-muted); font-size: 12.5px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-hint { margin: 16px 0 0; font-size: 12px; text-align: center; }
.profile-avatar-row { display: flex; align-items: center; gap: 16px; }
.signature-preview { padding: 10px 12px; border: 1px dashed var(--color-border-strong); border-radius: var(--radius); background: var(--color-bg); }

/* ---------- Fehlerseiten ---------- */
.error-page { text-align: center; padding: 60px 20px; max-width: 520px; margin: 0 auto; }
.error-code { font-size: 64px; font-weight: 800; color: var(--color-border-strong); line-height: 1; }
.error-page h1 { margin: 12px 0 8px; }
.error-page p { color: var(--color-text-muted); }
.error-actions { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }

/* ---------- Kanban-Grundstil ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.board-column { flex: 0 0 280px; background: var(--color-surface-muted); border-radius: var(--radius-lg); padding: 10px; min-height: 200px; }
.board-column-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 13px; padding: 2px 4px 10px; }
.board-card { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow-sm); cursor: grab; }
.board-card:hover { border-color: var(--color-border-strong); }
.board-column.is-over { outline: 2px dashed var(--color-primary); }

/* ---------- Charts (inline SVG) ---------- */
.chart { width: 100%; height: auto; }
.chart .bar { fill: var(--color-primary); }
.chart .bar:hover { fill: var(--color-primary-hover); }
.chart .axis { stroke: var(--color-border-strong); }
.chart .label { fill: var(--color-text-muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--color-primary); stroke-width: 2; }

/* ---------- Responsive ---------- */
@media (max-width: 1023.98px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform 180ms ease; box-shadow: none; }
  .sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 35; }
  .topbar-menu { display: inline-flex; }
  .main { padding: 16px; }
  .topbar { padding: 0 12px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
  body { font-size: 14px; }
  .main { padding: 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 34px; padding: 0; }
  .omnibox-kbd { display: none; }
  .omnibox-input { padding-right: 12px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-dialog { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 96vh; overflow: auto; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 6px; }
  /* Tabellen als Karten */
  .table-responsive .table, .table-responsive .table tbody, .table-responsive .table tr, .table-responsive .table td { display: block; }
  .table-responsive .table thead { display: none; }
  .table-responsive .table tr { padding: 10px 12px; border-bottom: 1px solid var(--color-border); }
  .table-responsive .table td { height: auto; padding: 2px 0; border: 0; white-space: normal; }
  .table-responsive .table td[data-label]::before { content: attr(data-label) ": "; color: var(--color-text-muted); font-size: 12px; }
  .table-responsive .table td.col-check { float: left; margin-right: 8px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Druck ---------- */
@media print {
  .sidebar, .topbar, .toasts, .modal, .help-overlay, .btn, .bulk-bar, .pagination, .timeline-actions, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .main { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .table th { position: static; }
  a { color: inherit; text-decoration: none; }
  .pill { border: 1px solid #999; color: #000; background: none; }
}
