/* ============================================================
   Helloworkflow Hub - Design System
   ============================================================ */

/* ---- CSS Variables / Tokens ---- */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-bg: #eef2ff;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;

  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 150ms ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---- Typography ---- */
h1 { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
h2 { font-size: 1.35rem; font-weight: 600; color: var(--gray-800); }
h3 { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger) !important; font-weight: 600; }
.text-warning { color: var(--warning) !important; font-weight: 500; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }

/* ---- Login Page ---- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  text-align: center;
  margin-bottom: .5rem;
}
.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}
.login-card .logo {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

/* ---- App Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-header .logo-icon {
  font-size: 1.5rem;
}
.sidebar-header h2 {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}
.sidebar-nav .nav-section {
  padding: .5rem 1.25rem;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  margin-top: .5rem;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.25rem;
  color: var(--gray-300);
  text-decoration: none;
  font-size: .9rem;
  border-radius: 0;
  transition: all var(--transition);
  margin: 1px 8px;
  border-radius: var(--radius-sm);
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}
.sidebar-nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
}
.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  padding: 1px 7px;
  border-radius: 99px;
  font-weight: 600;
}
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-footer .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-footer .user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-footer .user-name {
  font-size: .85rem;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer .user-role {
  font-size: .7rem;
  color: var(--gray-400);
}
.sidebar-footer .logout-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 1.1rem;
  padding: .25rem;
  transition: color var(--transition);
}
.sidebar-footer .logout-btn:hover { color: var(--danger); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1 1 0;
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
@media (max-width: 768px) {
  .main-content { max-width: 100vw; }
}
.page-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}
.page-header h1 { 
  font-size: 1.35rem; 
  margin: 0;
  flex: 1;
  min-width: 0;
}
.page-header .header-actions {
  display: flex !important;
  gap: .5rem;
  align-items: center;
  flex-shrink: 0;
  visibility: visible !important;
}
.page-header .header-actions button {
  white-space: nowrap;
  display: inline-flex !important;
}
.page-body {
  padding: 1.5rem 2rem;
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.card-header h3 { margin: 0; }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---- Stat Cards (Dashboard) ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-card .stat-label {
  font-size: .8rem;
  color: var(--text-secondary);
}

/* ---- Grid Layouts ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; text-decoration: none; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; }
.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-300); text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: none;
  padding: .4rem .75rem;
}
.btn-ghost:hover { background: var(--gray-100); text-decoration: none; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: .35rem;
}
.form-group label .required { color: var(--danger); }
.form-control {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-control::placeholder { color: var(--gray-400); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: auto; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-hint {
  font-size: .75rem;
  color: var(--gray-400);
  margin-top: .25rem;
}

/* ---- Tables ---- */
.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: .65rem 1rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: .9rem;
}
tr:hover td { background: var(--gray-50); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--primary-bg); }
a.table-row-link { color: inherit; text-decoration: none; font-weight: inherit; }
a.table-row-link:hover { text-decoration: underline; }

/* Avatare – immer rund, nicht durch Tabellenzeilen gestreckt */
.user-avatar {
  flex-shrink: 0;
  aspect-ratio: 1;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  overflow: hidden;
  vertical-align: middle;
  font-weight: 600;
}
.user-avatar-xs { width: 24px; height: 24px; min-width: 24px; min-height: 24px; font-size: .6rem; }
.user-avatar-sm { width: 28px; height: 28px; min-width: 28px; min-height: 28px; font-size: .65rem; }
.user-avatar-md { width: 32px; height: 32px; min-width: 32px; min-height: 32px; font-size: .7rem; }
#freelancer-cases-table td .flex.items-center { align-items: center; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab {
  padding: .65rem 1.25rem;
  font-size: .9rem;
  color: var(--gray-500);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--gray-700); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 200ms;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 95%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 200ms;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-lg { max-width: 900px; }
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1.15rem; margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--gray-400);
  padding: .25rem;
  cursor: pointer;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { 
  padding: 1.5rem; 
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  flex-shrink: 0;
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---- Checklist ---- */
.checklist-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--gray-100);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.checklist-item.done .checklist-text {
  text-decoration: line-through;
  color: var(--gray-400);
}
.checklist-text { flex: 1; font-size: .9rem; }
.checklist-assignee {
  font-size: .75rem;
  color: var(--text-secondary);
  background: var(--gray-100);
  padding: .15rem .5rem;
  border-radius: 99px;
}
.checklist-due {
  font-size: .75rem;
  color: var(--text-secondary);
}

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
  align-items: center;
}
.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.filter-bar .search-input input {
  padding-left: 2.25rem;
  width: 100%;
}
.filter-bar .search-input::before {
  content: '🔍';
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  z-index: 1;
  pointer-events: none;
}
.filter-bar select {
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  background: var(--bg-card);
  color: var(--text);
  min-width: 120px;
}
#archive-toggle.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 600;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  max-width: min(28rem, calc(100vw - 2.5rem));
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  color: #fff;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 300ms;
  word-wrap: break-word;
  line-height: 1.35;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

/* ---- Timeline / Comments ---- */
.timeline {
  position: relative;
  padding-left: 2rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: .75rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.6rem;
  top: .35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
}
.timeline-item .timeline-meta {
  font-size: .75rem;
  color: var(--text-secondary);
  margin-bottom: .25rem;
}
.timeline-item .timeline-content {
  background: var(--gray-50);
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
}

/* ---- Calendar Grid ---- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}
.calendar-day-header {
  background: var(--gray-50);
  padding: .5rem;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
}
.calendar-day {
  background: var(--bg-card);
  min-height: 100px;
  padding: .35rem;
  min-width: 0;
  overflow: hidden;
}
.calendar-day .day-number {
  font-size: .8rem;
  font-weight: 500;
  color: var(--gray-500);
  padding: .15rem .35rem;
}
.calendar-day.today .day-number {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.calendar-day.other-month { background: var(--gray-50); }
.calendar-day.other-month .day-number { color: var(--gray-300); }
.calendar-event {
  font-size: .7rem;
  padding: .15rem .35rem;
  border-radius: 3px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all var(--transition);
  max-width: 100%;
}
.calendar-event:hover {
  opacity: 0.85;
  transform: translateX(2px);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* Calendar header: fluid resize without jump/overflow */
.calendar-header {
  flex-wrap: wrap;
  row-gap: .5rem;
}
.calendar-header-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex: 1 1 260px;
  min-width: 0;
}
.calendar-header .header-actions {
  margin-left: auto;
  flex: 0 0 auto;
}

/* ---- Pipeline / Kanban ---- */
.pipeline {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}
.pipeline-stage {
  flex: 0 0 140px;
  text-align: center;
  padding: .5rem .4rem;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
}
.pipeline-stage:hover { border-color: currentColor; }
.pipeline-stage.active { border-color: currentColor; font-weight: 700; }
.pipeline-stage .stage-count {
  font-size: 1.25rem;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: .75rem;
}
.empty-state p {
  margin-bottom: 1rem;
}

/* ---- Responsive ---- */
@media (max-width: 1400px) {
  .modal-lg { max-width: 95vw; }
  .detail-sidebar { width: 250px; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .page-header { padding: 1rem 1.5rem; }
  .page-body { padding: 1rem 1.5rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-sidebar { width: 100%; margin-top: 1.5rem; }
  .detail-header { flex-direction: column; }
  .steckbrief-grid { grid-template-columns: 1fr; }
  /* Stack detail layout on tablets */
  .page-body > div[style*="display:flex"] {
    flex-direction: column !important;
  }
  .pipeline { flex-wrap: wrap; }
  .pipeline-stage { flex: 0 0 calc(33% - .5rem); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-header { 
    padding: .75rem 1rem; 
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
  }
  .calendar-header {
    flex-direction: row !important;
    align-items: center !important;
    width: 100%;
  }
  .page-header h1 { font-size: 1.15rem; }
  .page-header .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .calendar-header .header-actions {
    width: auto;
    margin-left: auto;
  }
  .page-header .header-actions .btn { font-size: .75rem; padding: .3rem .6rem; }
  .page-body { padding: .75rem; }
  .grid-2, .grid-3, .grid-auto { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .stat-card { padding: .85rem; }
  .stat-card .stat-value { font-size: 1.35rem; }
  .stat-card .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; }
  .mobile-menu-btn { display: block !important; }
  .filter-bar { flex-direction: column; }
  .filter-bar .search-input,
  .filter-bar select { width: 100% !important; }
  
  /* Modals - full screen on mobile */
  .modal-overlay { align-items: flex-end; }
  .modal {
    max-height: 95vh;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
  }
  .modal-lg { max-width: 100vw; }
  .modal-body { padding: 1rem; }
  .modal-footer { padding: .75rem 1rem; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 0; justify-content: center; }
  
  /* Calendar mobile */
  .calendar-grid { font-size: .7rem; }
  .calendar-day { min-height: 60px; padding: .2rem; }
  .calendar-day .day-number { font-size: .7rem; }
  .calendar-event { font-size: .6rem; padding: .1rem .2rem; }
  .calendar-nav { flex-direction: column; gap: .5rem; }
  .calendar-nav h2 { font-size: 1rem; }
  
  /* Tabs mobile */
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; font-size: .8rem; padding: .5rem .75rem; }
  
  /* Table mobile */
  .table-container { margin: 0 -1rem; }
  table { font-size: .8rem; }
  th, td { padding: .5rem .6rem; }
  
  /* Pipeline mobile */
  .pipeline { flex-wrap: wrap; }
  .pipeline-stage { flex: 0 0 calc(33% - .5rem); font-size: .65rem; padding: .35rem; }
  .pipeline-stage .stage-count { font-size: 1rem; }
  
  /* Quick actions mobile */
  .quick-actions { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .quick-action { padding: .65rem; }
  .quick-action .qa-icon { font-size: 1.1rem; }
  .quick-action .qa-label { font-size: .75rem; }
  
  /* Activity items mobile */
  .activity-item { padding: .5rem 0; gap: .5rem; }
  .activity-text { font-size: .8rem; }
  .activity-time { font-size: .7rem; }
  
  /* Checklist mobile */
  .checklist-item { gap: .5rem; padding: .4rem 0; flex-wrap: wrap; }
  .checklist-text { font-size: .85rem; }
  .drag-handle { font-size: .85rem !important; }
  
  /* Card mobile */
  .card-header { padding: .75rem 1rem; }
  .card-body { padding: .75rem; }
  
  /* Toast mobile */
  .toast { bottom: 1rem; right: 1rem; left: 1rem; text-align: center; }
  
  /* Detail sidebar mobile */
  .detail-sidebar { width: 100% !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .form-row { gap: .5rem; }
  .steckbrief-grid { grid-template-columns: 1fr; gap: .5rem; }
  .pipeline-stage { flex: 0 0 calc(50% - .5rem); }
  h1 { font-size: 1.1rem; }
  h2 { font-size: 1rem; }
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  padding: .25rem;
  min-width: 44px;
  min-height: 44px;
  line-height: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-shrink: 0;
}

/* ---- Multi-day calendar events ---- */
.calendar-event.multi-day-start { border-radius: 3px 0 0 3px; margin-right: -2px; }
.calendar-event.multi-day-mid { border-radius: 0; border-left: none; margin-left: -2px; margin-right: -2px; }
.calendar-event.multi-day-end { border-radius: 0 3px 3px 0; border-left: none; margin-left: -2px; }

/* ---- Stat card link hover ---- */
.stat-card-link { transition: all var(--transition); }
.stat-card-link:hover { box-shadow: var(--shadow-md); border-color: var(--primary); text-decoration: none !important; }

/* ---- Drag handle ---- */
.drag-handle { opacity: .4; transition: opacity .2s; }
.checklist-item:hover .drag-handle { opacity: 1; }
.checklist-item[draggable="true"] { transition: opacity .2s; }

/* ---- Quick Actions Grid ---- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.quick-action {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
}
.quick-action:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.quick-action .qa-icon {
  font-size: 1.35rem;
}
.quick-action .qa-label {
  font-size: .85rem;
  font-weight: 500;
}

/* ---- Activity List ---- */
.activity-item {
  display: flex;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--gray-100);
}
.activity-item:last-child { border-bottom: none; }

/* Kleiner Zähler im Tab-Label (z. B. „Notizen (3)") */
.tab .tab-count {
  display: inline-block;
  margin-left: .35rem;
  font-size: .72rem;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
}
.tab.active .tab-count { color: var(--primary, #3b82f6); }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: .45rem;
  flex-shrink: 0;
}
.activity-text { flex: 1; font-size: .85rem; }
.activity-time { font-size: .75rem; color: var(--text-secondary); white-space: nowrap; }

/* ---- Detail Header ---- */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.detail-header .detail-info { flex: 1; }
.detail-header .detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .5rem;
}
.detail-sidebar {
  width: 300px;
  flex-shrink: 0;
}

/* ---- Steckbrief (Customer Profile) ---- */
.steckbrief-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.steckbrief-item {
  padding: .65rem;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}
.steckbrief-item .steckbrief-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  margin-bottom: .15rem;
}
.steckbrief-item .steckbrief-value {
  font-size: .9rem;
  font-weight: 500;
}

/* ---- Dev Day Slots ---- */
.slot-bar {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: .5rem;
}
.slot-bar .slot {
  flex: 1;
  border-radius: 4px;
}
.slot.filled { background: var(--primary); }
.slot.empty { background: var(--gray-200); }

/* ---- Loading / Spinner ---- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---- Misc Utilities ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: .5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.mb-sm { margin-bottom: .5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.cursor-pointer { cursor: pointer; }
.relative { position: relative; }

/* ---- Multi-Select Dropdown ---- */
.multi-select {
  position: relative;
  min-width: 140px;
}
.multi-select-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, box-shadow .15s;
  color: var(--gray-700);
  min-height: 38px;
}
.multi-select-btn:hover { border-color: var(--gray-400); }
.multi-select.open .multi-select-btn {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.multi-select-btn .ms-arrow {
  font-size: .6rem;
  color: var(--gray-400);
  transition: transform .15s;
}
.multi-select.open .ms-arrow { transform: rotate(180deg); }
.multi-select-btn .ms-count {
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  padding: .1rem .4rem;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
  line-height: 1.3;
}
.multi-select-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 280px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: .25rem 0;
}
.multi-select.open .multi-select-panel { display: block; }
.multi-select-panel label {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .75rem;
  font-size: .85rem;
  cursor: pointer;
  transition: background .1s;
  white-space: nowrap;
}
.multi-select-panel label:hover { background: var(--gray-50); }
.multi-select-panel label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.multi-select-panel .ms-clear {
  display: block;
  width: 100%;
  padding: .4rem .75rem;
  font-size: .8rem;
  color: var(--gray-500);
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  margin-top: .25rem;
}
.multi-select-panel .ms-clear:hover { color: var(--primary); background: var(--gray-50); }

/* ---- Sortable Table Headers ---- */
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
th.sortable:hover { color: var(--primary); }
.sort-icon {
  font-size: .55rem;
  margin-left: .2rem;
  opacity: .3;
  vertical-align: middle;
}
.sort-icon.active { opacity: 1; color: var(--primary); }

/* ---- Case New Badge (red dot in list) ---- */
.case-new-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  margin-right: .4rem;
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}
/* Offenes Follow-up mit Fälligkeit heute oder früher (nicht erledigt) */
.case-followup-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #dc2626;
  border-radius: 50%;
  margin-right: .35rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.28);
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ---- @Mention Styles ---- */
.mention {
  color: var(--primary);
  font-weight: 500;
  background: var(--primary-bg);
  padding: 0 .25rem;
  border-radius: 3px;
}
.mention-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 200;
  min-width: 220px;
}
.mention-option {
  padding: .45rem .75rem;
  font-size: .85rem;
  cursor: pointer;
  transition: background var(--transition);
}
.mention-option:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

/* ---- Inbox Slide-out Panel ---- */
.inbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 1099;
  opacity: 0;
  visibility: hidden;
  transition: all 200ms;
}
.inbox-overlay.open { opacity: 1; visibility: visible; }
.inbox-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  transition: right 300ms ease;
  display: flex;
  flex-direction: column;
}
.inbox-panel.open { right: 0; }
.inbox-panel-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.inbox-panel-header h2 { margin: 0; }
.inbox-panel-body {
  flex: 1;
  overflow-y: auto;
}
.inbox-message {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background var(--transition);
}
.inbox-message:hover { background: var(--gray-50); }
.inbox-message.unread {
  background: var(--primary-bg);
  border-left: 3px solid var(--primary);
}
.inbox-msg-title {
  font-weight: 500;
  font-size: .9rem;
  margin-bottom: .25rem;
}
.inbox-msg-body {
  font-size: .8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: pre-wrap;
  max-height: 3em;
  overflow: hidden;
}
.inbox-msg-meta {
  font-size: .7rem;
  color: var(--gray-400);
  margin-top: .35rem;
}

/* ---- Case Detail: Checklist + Comments side by side ---- */
.case-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) {
  .case-main-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Owner Quick-Change ---- */
.owner-change-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .5rem;
  font-size: .8rem;
  color: var(--primary);
  background: var(--primary-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.owner-change-btn:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

/* Hard lock calendar header layout */
body.calendar-page .page-header.calendar-header {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: space-between !important;
}

body.calendar-page .page-header.calendar-header .calendar-header-title {
  display: flex !important;
  align-items: center !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
}

body.calendar-page .page-header.calendar-header .header-actions {
  display: flex !important;
  width: auto !important;
  margin-left: auto !important;
  flex: 0 0 auto !important;
  justify-content: flex-end !important;
}

/* Prevent horizontal scroll on calendar page */
body.calendar-page .main-content,
body.calendar-page .page-body {
  overflow-x: hidden;
}


/* ============================================================
   Hub Version & Sidebar Settings/Logout Icons (v5)
   ============================================================ */
.sidebar-footer .settings-btn,
.sidebar-footer .logout-btn,
.sidebar-footer .lang-btn {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,.55);
  font-size: 1.1rem;
  padding: .25rem .4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  flex-shrink: 0;
  cursor: pointer;
}
.sidebar-footer .settings-btn:hover,
.sidebar-footer .logout-btn:hover,
.sidebar-footer .lang-btn:hover,
.sidebar-footer .lang-btn[aria-expanded="true"] {
  color: #fff;
  background: rgba(255,255,255,.1);
}
.lang-selector-wrap {
  position: relative;
  flex-shrink: 0;
}
.lang-selector-menu {
  position: absolute;
  bottom: calc(100% + .45rem);
  right: 0;
  min-width: 9.5rem;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: .35rem;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.lang-selector-menu[hidden] { display: none !important; }
.lang-selector-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  padding: .45rem .6rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255,255,255,.88);
  font-size: .85rem;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.lang-selector-item:hover { background: rgba(255,255,255,.08); }
.lang-selector-item.active {
  background: rgba(14,165,233,.22);
  color: #fff;
  font-weight: 600;
}
.lang-selector-flag { font-size: 1.05rem; line-height: 1; }
.lang-selector-label { line-height: 1.2; }
.hub-version-bar {
  font-size: .7rem;
  color: rgba(255,255,255,.45);
  letter-spacing: .04em;
  padding: .35rem 1.25rem .75rem;
  border-top: 1px solid rgba(255,255,255,.05);
  display: flex;
  align-items: center;
  gap: .4rem;
  background: rgba(0,0,0,.15);
}
.hub-version-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  display: inline-block;
}

.deploy-log-env-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .85rem 1.25rem;
}
.deploy-log-env-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  margin-bottom: .2rem;
}
.deploy-log-env-value code {
  font-size: .82rem;
  background: var(--gray-100);
  padding: .1rem .35rem;
  border-radius: 4px;
}
.deploy-log-entry {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: .85rem 1rem;
  margin-bottom: .75rem;
}
.deploy-log-entry:last-child { margin-bottom: 0; }
.deploy-log-entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .5rem;
}
.deploy-log-entry-title {
  font-weight: 600;
  font-size: .95rem;
}
.deploy-log-entry-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--gray-700);
  font-size: .88rem;
  line-height: 1.55;
}

.activity-log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
.activity-log-table td { vertical-align: top; }
.activity-log-table td .badge { white-space: nowrap; }
.deploy-log-details > summary::-webkit-details-marker { display: none; }
.deploy-log-details[open] > summary { border-bottom: 1px solid var(--gray-200); }

/* Filter-toggle buttons (Mine / Archive) - active state */
#mine-toggle.active,
#archive-toggle.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============================================================
   AI Settings Modal
   ============================================================ */
.ai-settings-modal .ai-key-row {
  display: flex;
  gap: .4rem;
  align-items: center;
}
.ai-settings-modal .ai-key-row .form-control {
  flex: 1;
}
.ai-test-result {
  margin-top: 1rem;
  padding: .65rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
}
.ai-test-result.info {
  background: var(--info-bg);
  color: var(--info);
}
.ai-test-result.success {
  background: var(--success-bg);
  color: var(--success);
}
.ai-test-result.error {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ============================================================
   Floating AI Chat Widget
   ============================================================ */
.ai-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: 0;
  box-shadow: 0 8px 24px rgba(102,126,234,.45);
  cursor: pointer;
  font-size: 1.6rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}
.ai-fab:hover { transform: translateY(-2px) scale(1.04); }
.ai-fab .ai-fab-icon { position: relative; z-index: 2; }
.ai-fab .ai-fab-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(102,126,234,.4);
  animation: aiFabPulse 2.4s ease-out infinite;
  z-index: 1;
}
@keyframes aiFabPulse {
  0% { opacity: .6; transform: scale(.7); }
  100% { opacity: 0; transform: scale(1.3); }
}

.ai-chat-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 420px;
  max-width: calc(100vw - 2rem);
  height: min(640px, calc(100vh - 3rem));
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 1001;
  overflow: hidden;
}
.ai-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.ai-chat-header {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.ai-chat-title {
  display: flex;
  gap: .65rem;
  align-items: center;
}
.ai-chat-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}
.ai-chat-name { font-weight: 600; font-size: .95rem; }
.ai-chat-sub { font-size: .72rem; opacity: .85; }
.ai-chat-sub .ai-warning { color: #fde68a; }
.ai-chat-sub a { color: #fff; text-decoration: underline; }
.ai-chat-actions { display: flex; gap: .25rem; }
.ai-chat-btn {
  background: rgba(255,255,255,.12);
  border: 0;
  color: #fff;
  border-radius: var(--radius-sm);
  width: 30px; height: 30px;
  font-size: .9rem;
  cursor: pointer;
  transition: background var(--transition);
}
.ai-chat-btn:hover { background: rgba(255,255,255,.24); }

.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: linear-gradient(180deg, #fafbff 0%, #ffffff 100%);
}
.ai-empty {
  text-align: center;
  padding: 2rem 1rem;
}
.ai-empty-icon { font-size: 2rem; margin-bottom: .5rem; }
.ai-msg {
  margin-bottom: .85rem;
  display: flex;
  flex-direction: column;
}
.ai-msg-user { align-items: flex-end; }
.ai-msg-assistant { align-items: flex-start; }
.ai-msg-bubble {
  max-width: 88%;
  padding: .65rem .85rem;
  border-radius: 16px;
  font-size: .88rem;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  word-wrap: break-word;
}
.ai-msg-user .ai-msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg-assistant .ai-msg-bubble {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-msg-bubble code {
  background: rgba(0,0,0,.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .8rem;
}
.ai-msg-user .ai-msg-bubble code { background: rgba(255,255,255,.2); }

.ai-typing { display: inline-flex; gap: 4px; }
.ai-typing span {
  width: 6px; height: 6px;
  background: var(--gray-400);
  border-radius: 50%;
  animation: aiTyping 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiTyping {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-actions-block {
  margin-top: .5rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem;
  max-width: 100%;
}
.ai-actions-title {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-bottom: .5rem;
  font-weight: 500;
}
.ai-action-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .65rem;
  margin-bottom: .5rem;
}
.ai-action-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: .4rem;
}
.ai-action-type { color: var(--gray-700); }
.ai-action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .4rem;
  font-size: .78rem;
}
.ai-action-grid label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-secondary);
}
.ai-action-wide { grid-column: 1 / -1; }
.ai-action-input {
  font-size: .8rem;
  padding: .35rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  width: 100%;
  font-family: inherit;
}
.ai-actions-footer {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: .5rem;
}

.ai-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .5rem 1rem .25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.ai-chip {
  background: var(--primary-bg);
  border: 0;
  color: var(--primary-dark);
  font-size: .72rem;
  padding: .25rem .55rem;
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition);
}
.ai-chip:hover { background: var(--primary); color: #fff; }

.ai-chat-input {
  border-top: 1px solid var(--border);
  padding: .65rem .75rem;
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  background: var(--bg-card);
}
.ai-chat-input textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .55rem .75rem;
  font-size: .88rem;
  resize: none;
  max-height: 140px;
  min-height: 40px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.ai-chat-input textarea:focus { border-color: var(--primary); }
.ai-chat-send {
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 12px;
  width: 40px; height: 40px;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background var(--transition);
}
.ai-chat-send:hover:not(:disabled) { background: var(--primary-dark); }
.ai-chat-send:disabled { background: var(--gray-300); cursor: wait; }

@media (max-width: 640px) {
  .ai-chat-panel { right: .5rem; left: .5rem; bottom: .5rem; width: auto; height: 80vh; }
  .ai-fab { right: 1rem; bottom: 1rem; }
}

/* ============================================================
   Wissen-Hub Page
   ============================================================ */
/* Hinweis: Wissen-Hub nutzt den Standard-.page-header wie alle anderen
   Seiten. Frueher gab es hier einen lila Gradient, der wurde entfernt
   damit die Headers konsistent aussehen. */
.badge-subtle {
  background: var(--gray-100);
  color: var(--text-secondary);
  font-size: .7rem;
  padding: .15rem .5rem;
  border-radius: 99px;
  font-weight: 500;
}

.wissen-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.wissen-search { flex: 1; min-width: 240px; }
.wissen-view-toggle {
  display: flex;
  gap: .35rem;
  padding: .25rem;
  background: var(--gray-100);
  border-radius: 99px;
}
.view-pill {
  background: transparent;
  border: 0;
  padding: .4rem .85rem;
  border-radius: 99px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.view-pill.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.wissen-view.hidden { display: none; }

.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.knowledge-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  gap: .85rem;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.knowledge-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}
.knowledge-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.knowledge-card-body { flex: 1; min-width: 0; }
.knowledge-card-body h3 { font-size: 1rem; margin-bottom: .25rem; }
.knowledge-card-meta { margin-top: .65rem; }

.knowledge-cat-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  grid-column: 1 / -1;
}
.knowledge-cat-header h2 { flex: 1; }
.knowledge-entries {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.knowledge-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  cursor: pointer;
  transition: all var(--transition);
}
.knowledge-entry:hover {
  border-color: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.knowledge-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .35rem;
}
.knowledge-entry h4 { font-size: .95rem; margin-bottom: .35rem; }
.knowledge-entry-body {
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.knowledge-entry-tags {
  margin-top: .5rem;
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
}
.knowledge-entry-tags .badge {
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: .7rem;
}

/* Recent Meeting List on Categories View */
.recent-meetings {
  display: grid;
  gap: .5rem;
}
.meeting-card-compact {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem 1rem;
  cursor: pointer;
  transition: all var(--transition);
}
.meeting-card-compact:hover {
  border-color: var(--primary-light);
  transform: translateX(2px);
}
.meeting-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .25rem;
}

/* Meetings Feed */
.meetings-feed {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.meeting-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.meeting-card.flash { box-shadow: 0 0 0 3px var(--primary-light); }
.meeting-card-footer.flash {
  box-shadow: inset 0 0 0 2px var(--primary);
  border-radius: var(--radius-md);
  animation: meeting-footer-pulse 1.2s ease-in-out 2;
}
@keyframes meeting-footer-pulse {
  0%, 100% { background: transparent; }
  50% { background: var(--primary-light); }
}
.meeting-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  background: var(--gray-50);
}
.meeting-card-header h3 { margin-bottom: .25rem; }
.meeting-card-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.meeting-raw {
  padding: 1rem 1.25rem;
  background: #fafbff;
  border-bottom: 1px solid var(--border);
}
.meeting-raw.hidden { display: none; }
.meeting-raw .text-right { text-align: right; margin-top: .5rem; }

.meeting-section {
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.meeting-section > summary {
  padding: .85rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--gray-700);
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  user-select: none;
}
.meeting-section > summary::before {
  content: '▶';
  font-size: .65rem;
  color: var(--gray-400);
  transition: transform var(--transition);
}
.meeting-section[open] > summary::before { transform: rotate(90deg); }
.meeting-section > summary::-webkit-details-marker { display: none; }
.meeting-bullets {
  padding: 0 1.5rem 1rem 2.5rem;
  margin: 0;
}
.meeting-bullets li {
  margin-bottom: .3rem;
  font-size: .88rem;
  line-height: 1.5;
}
.meeting-cat-group {
  padding: .5rem 1.25rem .75rem;
  border-bottom: 1px solid var(--border);
}
.meeting-cat-group:last-child { border-bottom: none; }
.meeting-cat-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .5rem;
  font-size: .9rem;
  font-weight: 600;
}
.meeting-cleanup {
  padding: .75rem 1.25rem 1rem;
}
.proposed-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .25rem 1.25rem 1rem;
}
.proposed-item {
  background: #fafbff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .85rem;
}
.proposed-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  margin-bottom: .5rem;
  cursor: pointer;
}
.proposed-title { color: var(--primary-dark); font-weight: 600; }
.proposed-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
  font-size: .8rem;
}
.proposed-fields label {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  color: var(--text-secondary);
}
.proposed-fields .form-control { font-size: .82rem; padding: .4rem .55rem; }
.proposed-fields .proposed-assignees { min-height: 70px; }
.proposed-wide { grid-column: 1 / -1; }

.proposed-reject-reason {
  margin: 0 0 .55rem;
  padding: .45rem .55rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: calc(var(--radius) - 2px);
}
.proposed-reject-label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  color: #991b1b;
}
.proposed-reject-reason .form-control {
  font-size: .82rem;
  padding: .4rem .55rem;
}

.meeting-rejection-bar {
  padding: .75rem 1.25rem;
  border-top: 1px solid #fecaca;
  background: linear-gradient(180deg, #fff5f5 0%, #fef2f2 100%);
}
.meeting-rejection-bar-inner strong {
  color: #991b1b;
  font-size: .9rem;
}

.rejection-cat-header {
  padding-bottom: .5rem;
}

.rejection-hub {
  grid-column: 1 / -1;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 22rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 0;
  align-items: start;
}
.rejection-hub-aside {
  position: sticky;
  top: .75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
}
.rejection-aside-hint {
  margin: 0 0 .75rem;
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.rejection-rule-nav {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.rejection-rule-nav-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .2rem;
  align-items: stretch;
}
.rejection-rule-nav-row.is-empty {
  opacity: .75;
}
.rejection-rule-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: var(--gray-50);
  border-radius: calc(var(--radius) - 2px);
  padding: .5rem .65rem;
  font-size: .86rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.rejection-rule-nav-item:hover {
  background: #fff;
  border-color: var(--border);
}
.rejection-rule-nav-item.active {
  background: #fafaf9;
  border-color: #78716c;
  box-shadow: 0 0 0 1px #78716c22;
  font-weight: 600;
}
.rejection-rule-count {
  min-width: 1.5rem;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .05rem .45rem;
}
.rejection-rule-nav-item.active .rejection-rule-count {
  color: #57534e;
  border-color: #d6d3d1;
}
.rejection-rule-nav-divider {
  margin: .55rem 0 .25rem;
  padding: 0 .2rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
}
.rejection-rule-edit-btn {
  min-width: 2rem;
  padding: .25rem .4rem;
}
.rejection-hub-main {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem 1rem;
}
.rejection-main-head {
  margin-bottom: .75rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--border);
}
.rejection-main-head h3 {
  margin: 0 0 .25rem;
  font-size: 1.05rem;
}
.rejection-main-desc {
  margin: 0;
  line-height: 1.45;
}
.rejection-entry-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.rejection-entry-card {
  width: 100%;
  text-align: left;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem .85rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.rejection-entry-card:hover {
  background: #fff;
  border-color: #d6d3d1;
  box-shadow: var(--shadow-sm);
}
.rejection-entry-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-bottom: .35rem;
}
.rejection-kind-badge {
  background: #fee2e2 !important;
  color: #991b1b !important;
}
.rejection-rule-badge {
  background: #f5f5f4 !important;
  color: #57534e !important;
}
.rejection-entry-time {
  margin-left: auto;
}
.rejection-entry-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: .35rem;
  line-height: 1.35;
}
.rejection-entry-reason {
  font-size: .84rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.rejection-entry-reason-label {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #78716c;
  margin-right: .35rem;
}
.rejection-empty-state {
  padding: 2rem 1rem;
}

@media (max-width: 900px) {
  .rejection-hub {
    grid-template-columns: 1fr;
  }
  .rejection-hub-aside {
    position: static;
  }
}

.meeting-manual-add {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}
.meeting-manual-add-label {
  margin-bottom: .45rem;
  font-weight: 500;
}
.meeting-manual-add-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  margin-bottom: .55rem;
}
.meeting-manual-add-categories {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}
.meeting-cat-add-btns {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}

.meeting-card-footer {
  padding: .85rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: flex-end;
  align-items: center;
  background: var(--gray-50);
  border-top: 1px solid var(--border);
}

.attendees-picker {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  max-height: 140px;
  overflow-y: auto;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
}
.attendee-chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .25rem .65rem;
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
}
.attendee-chip input { margin: 0; }
.attendee-chip:has(input:checked) {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Badges variants used in wissen */
.badge.badge-success { background: var(--success-bg); color: var(--success); }
.badge.badge-info { background: var(--info-bg); color: var(--info); }
.badge.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge.badge-processing { background: #e0e7ff; color: #4338ca; }

.meeting-card-processing {
  border-color: #c7d2fe;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.12);
}
.meeting-analysis-progress {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f8faff 0%, #fff 100%);
}
.meeting-analysis-progress-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}
.meeting-analysis-progress-head .spinner {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}
.meeting-analysis-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}
.meeting-analysis-badges .meeting-analysis-step {
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  padding: .12rem .5rem;
  white-space: nowrap;
}
.meeting-analysis-pct {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #4338ca;
}
.meeting-analysis-progress-bar {
  height: .5rem;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.meeting-analysis-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  border-radius: 999px;
  transition: width .35s ease;
}
.meeting-analysis-progress-label {
  margin-top: .45rem;
}

/* Alerts (used in wissen) */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .88rem;
}
.alert.alert-warning {
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid #fcd34d;
}
.alert.hidden { display: none; }

/* Knowledge Graph – Layout
   Two-column: [graph stretches] + [details panel 320px on the right].
   Beide Spalten zusammen passen in den verfuegbaren Page-Body-Bereich,
   ohne horizontalen Scroll auszuloesen. */
.graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: stretch;
  min-width: 0;
}
.graph-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}
.graph-toolbar-actions { display: flex; gap: .35rem; }
.knowledge-graph-container {
  background: #070b1e;
  height: clamp(420px, calc(100vh - 280px), 720px);
  width: 100%;
  min-width: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}
.knowledge-graph-container canvas {
  display: block;
  max-width: 100%;
}
/* Ladezustand im Graph-Container (vor 3D-Engine-Init) */
.graph-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: rgba(255,255,255,.85);
  gap: .75rem;
  text-align: center;
  padding: 2rem;
  font-size: .9rem;
}
.graph-loading .spinner {
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: rgba(255,255,255,.75);
}
.knowledge-graph-container .empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.85);
  gap: .75rem;
  text-align: center;
  padding: 2rem;
}
.knowledge-graph-container .empty-state .empty-icon {
  font-size: 3rem;
}
.graph-details {
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-width: 0;
  height: clamp(420px, calc(100vh - 280px), 720px);
  overflow-y: auto;
}
.graph-details-header {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.graph-details-body { flex: 1; min-width: 0; }
.graph-node-detail { display: flex; flex-direction: column; gap: .6rem; }
.graph-node-kind {
  display: inline-block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  background: var(--gray-100);
  padding: .15rem .5rem;
  border-radius: 99px;
  align-self: flex-start;
}
.graph-node-title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
  word-break: break-word;
}
.graph-node-body {
  margin: 0;
  font-size: .85rem;
  line-height: 1.55;
  color: var(--text-secondary);
  word-break: break-word;
}
.graph-node-meta {
  font-size: .8rem;
  color: var(--text-primary);
}
.graph-node-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .35rem;
}

.graph-node-detail h3 { margin: 0; }

/* ============================================================
   Responsive Refinements (v6)
   ------------------------------------------------------------
   Schliesst Luecken auf Tablet/Mobile fuer alle Hub-Seiten.
   Greift bewusst NACH den fruheren Media-Queries, damit
   spezifische Overrides ueberschreibbar bleiben.
   ============================================================ */

/* --- Touch-Targets: alle Buttons mindestens 36px hoch auf Touch-Geraeten --- */
@media (hover: none) and (pointer: coarse) {
  .btn, .tab, .btn-icon, .nav-link, .multi-select-btn, .market-tab {
    min-height: 38px;
  }
  .btn-sm { min-height: 32px; }
  .modal-close { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; }
  input, select, textarea { font-size: 16px !important; } /* verhindert iOS-Zoom beim Fokus */
  .form-control { font-size: 16px !important; }
}

/* --- Tablet (≤1100px): grid-3 zwei-spaltig, modal-lg flexibler --- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .modal-lg { max-width: min(900px, 95vw); }
  .detail-sidebar { width: 280px; }
}

/* --- Tablet (≤1024px): grid-3 + andere Layouts --- */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .detail-sidebar { width: 100%; }
  /* Graph: enge Tablet-Spalte fuer das Details-Panel */
  .graph-layout { grid-template-columns: minmax(0, 1fr) 280px; }
  .knowledge-graph-container { height: clamp(380px, calc(100vh - 240px), 620px); }
  .graph-details { height: clamp(380px, calc(100vh - 240px), 620px); }
  /* Quick-Actions auf Tablet 3-spaltig */
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  /* App-Factory pipeline schon mit flex-wrap, sicherstellen */
  .pipeline { flex-wrap: wrap; }
}

/* --- Kleines Tablet / großes Phone (≤768px) --- */
@media (max-width: 768px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }
  /* Graph: Details unter den Graph statt daneben */
  .graph-layout { grid-template-columns: 1fr; }
  .knowledge-graph-container { height: clamp(320px, 65vh, 480px); }
  .graph-details { height: auto; max-height: 360px; }
  .graph-toolbar { gap: .5rem; }
  .graph-toolbar-actions { width: 100%; justify-content: flex-end; }
  .wissen-toolbar { gap: .5rem; }
  .wissen-search { min-width: 0; width: 100%; flex: 1 1 100%; }
  .wissen-view-toggle { flex: 1 1 100%; justify-content: center; }
  .badge-subtle { display: none; } /* version badge auf mobil ausblenden */
  .proposed-fields { grid-template-columns: 1fr; }
  .knowledge-cat-header { flex-wrap: wrap; gap: .5rem; }
  .knowledge-cat-header h2 { font-size: 1.1rem; }
  .login-card { padding: 1.75rem 1.5rem; }
  .meeting-card-header { flex-direction: column; gap: .5rem; }
  .meeting-card-actions { width: 100%; }
  /* Page-header h1: nicht zu klein, aber ausreichend kompakt */
  .page-header h1 { font-size: 1.1rem; line-height: 1.3; }
  /* Inbox-Panel auf Vollbreite */
  .inbox-panel { width: 100vw; max-width: 100vw; right: -100vw; }
  .inbox-panel.open { right: 0; }
  /* Tabs scrollbar im Touch-Modus */
  .tabs { scrollbar-width: none; -ms-overflow-style: none; }
  .tabs::-webkit-scrollbar { display: none; }
}

/* --- Phone (≤640px) --- */
@media (max-width: 640px) {
  :root { --sidebar-width: 240px; }
  .page-header { padding: .5rem .85rem; gap: .35rem; }
  .page-header .header-actions { gap: .35rem; }
  .page-header .header-actions .btn { font-size: .72rem; padding: .3rem .55rem; }
  .page-header .header-actions .btn .btn-icon { font-size: .85rem; }
  .page-body { padding: .75rem .75rem 5rem; } /* extra bottom padding fuer Chat-FAB */
  .card-header { flex-wrap: wrap; gap: .35rem; padding: .65rem .85rem; }
  .card-header h3 { font-size: .95rem; }
  .card-body { padding: .85rem; }
  /* Stat-cards kompakter */
  .stat-card { padding: .75rem .85rem; gap: .65rem; }
  .stat-card .stat-icon { width: 34px; height: 34px; font-size: 1rem; }
  .stat-card .stat-value { font-size: 1.2rem; }
  .stat-card .stat-label { font-size: .72rem; }
  /* Buttons in der filter-bar nehmen ganze Breite */
  .filter-bar { gap: .4rem; }
  .filter-bar .btn { flex: 1 1 auto; min-width: 0; justify-content: center; }
  .filter-bar select,
  .filter-bar input[type="search"],
  .filter-bar input[type="text"] { max-width: none !important; width: 100% !important; flex: 1 1 100%; min-width: 0; }
  /* Tabs minimal */
  .tab { padding: .45rem .6rem; font-size: .75rem; }
  /* Modal Vollbild */
  .modal { max-height: 100vh; height: 100vh; border-radius: 0; }
  .modal-overlay { align-items: stretch; padding: 0; }
  .modal-header { padding: .85rem 1rem; }
  .modal-header h2 { font-size: 1rem; }
  .modal-body { padding: .85rem; }
  .modal-footer { padding: .65rem .85rem; }
  /* Forms: alle Form-Rows einspaltig */
  .form-row { grid-template-columns: 1fr; gap: .5rem; }
  /* Tables: Min-Schriftgroesse + Padding */
  table { font-size: .78rem; }
  th, td { padding: .45rem .5rem; }
  th { font-size: .65rem; }
  /* Activity */
  .activity-text { font-size: .78rem; }
  /* Timeline */
  .timeline { padding-left: 1.5rem; }
  .timeline-item::before { left: -1.15rem; }
  /* AI Chat panel: bottom sheet auf Phone */
  .ai-chat-panel { right: 0; left: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 85vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .ai-fab { right: .85rem; bottom: .85rem; width: 48px; height: 48px; font-size: 1.35rem; }
  .ai-msg-bubble { max-width: 92%; font-size: .85rem; }
  /* Chat suggestions: scrollbarer Streifen statt wrap */
  .ai-chat-suggestions { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ai-chat-suggestions::-webkit-scrollbar { display: none; }
  .ai-chip { white-space: nowrap; }
  /* Action grid in AI cards: einspaltig */
  .ai-action-grid { grid-template-columns: 1fr; }
  /* Login auf kleinen Phones */
  .login-card { padding: 1.5rem 1.25rem; }
  /* Steckbrief einspaltig */
  .steckbrief-grid { grid-template-columns: 1fr; }
  /* Multi-Select */
  .multi-select { width: 100%; min-width: 0; }
  .multi-select-btn { width: 100%; }
  .multi-select-panel { width: 100%; max-width: 100%; }
}

/* --- Sehr kleine Phones (≤380px) --- */
@media (max-width: 380px) {
  html { font-size: 14px; }
  .calendar-day { min-height: 48px; padding: .15rem; }
  .calendar-day .day-number { font-size: .65rem; padding: 0 .15rem; }
  .calendar-event { font-size: .55rem; padding: 0 .15rem; }
  .pipeline-stage { flex: 0 0 calc(50% - .35rem); font-size: .6rem; padding: .25rem; }
  .page-header h1 { font-size: 1rem; }
  .ai-fab { width: 44px; height: 44px; bottom: .65rem; right: .65rem; }
}

/* --- Freelancer-Bereich Mobile-Fixes --- */
@media (max-width: 900px) {
  /* Detail-Sidebar stackt unter den Main-Content */
  main .page-body > div[style*="display:flex"][style*="gap:1.5rem"] { flex-direction: column !important; }
  main .detail-sidebar { width: 100% !important; max-width: 100% !important; }
}
@media (max-width: 768px) {
  .digital-tool-pill-bar { max-height: 160px !important; }
  #fl-cases-category-pills,
  .category-pill-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap !important; padding-bottom: .25rem; }
  #fl-cases-category-pills::-webkit-scrollbar,
  .category-pill-bar::-webkit-scrollbar { display: none; }
  /* Milestone-Karten kompakter */
  .milestone-card { padding: .85rem; }
  .milestone-card-header { flex-wrap: wrap; gap: .35rem; }
  /* Filter-Bar in Freelancer-Cases responsiv */
  #freelancer-cases-filters { gap: .4rem; }
  #freelancer-cases-filters select,
  #freelancer-cases-filters input[type="search"] { flex: 1 1 100%; max-width: none; }
  /* Freelancer-Tabelle: bestimmte Spalten auf Mobil ausblenden */
  #freelancer-cases-table th:nth-child(4),
  #freelancer-cases-table td:nth-child(4),
  #freelancer-cases-table th:nth-child(5),
  #freelancer-cases-table td:nth-child(5) { display: none; }
}
@media (max-width: 640px) {
  /* Lang-Button: kompakter, weniger Platz */
  .sidebar-footer .lang-btn { padding: .2rem .35rem !important; font-size: .9rem !important; }
  /* Steckbrief-Sub-Headings nicht zu groß */
  #freelancer-steckbrief .steckbrief-label { font-size: .68rem; }
  /* Multi-Pill-Selects mit Wrap */
  #efl-languages-pills, #efl-specialties-pills { gap: .35rem; }
  /* Newsletter-Templates Mobile */
  .newsletter-template-grid { grid-template-columns: 1fr !important; }
}

/* --- Landscape Phones (kurze Hoehe + breit) --- */
@media (max-height: 500px) and (orientation: landscape) {
  .ai-chat-panel { height: 90vh; }
  .modal { max-height: 100vh; }
  .login-card { padding: 1rem 1.5rem; max-height: 92vh; overflow-y: auto; }
}

/* --- Print-Modus fuer Case-Detail / Wissen --- */
@media print {
  .sidebar, .mobile-menu-btn, .ai-fab, .ai-chat-panel, .toast, .inbox-overlay, .inbox-panel,
  .page-header .header-actions, .filter-bar, .tabs { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-header { position: static; border-bottom: 1px solid #ccc; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}

/* --- Sidebar Overlay: stoere keine Inhalte unter dem Backdrop --- */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 0s linear 200ms;
}
.sidebar.open ~ .sidebar-backdrop,
.sidebar-backdrop.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease;
}
@media (min-width: 769px) {
  .sidebar-backdrop { display: none; }
}

/* --- Hilfsklassen --- */
.no-scroll { overflow: hidden !important; }

/* ============================================================
   Responsive Refinements (v7)
   Mobile-Optimierung fuer alle Hub-Seiten
   ============================================================ */

.detail-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.detail-layout-main {
  flex: 1;
  min-width: 0;
}

.detail-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  width: 100%;
}

.detail-header-row .header-actions {
  margin-left: auto;
}

.page-header > .flex.items-center {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
}

.page-header h1 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.table-container {
  position: relative;
}

.table-scroll-hint::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to left, var(--color-bg-secondary, #f8fafc), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

@media (max-width: 768px) {
  .table-scroll-hint::after { opacity: 1; }

  .detail-layout,
  .detail-layout > [style*="display:flex"] {
    flex-direction: column !important;
  }

  .detail-layout-main,
  .detail-layout > div[style*="flex:1"] {
    width: 100% !important;
    min-width: 0 !important;
  }

  .detail-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 0 !important;
  }

  .detail-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-header-row .header-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .page-header > .flex.items-center {
    width: 100%;
  }

  .page-header .header-actions .btn {
    flex: 0 1 auto;
  }

  .card-header .flex,
  .card-header > div[style*="display:flex"] {
    flex-wrap: wrap;
    gap: .5rem;
  }

  .card-header input[type="search"],
  .card-header input[type="text"],
  .card-header select {
    width: 100% !important;
    max-width: none !important;
  }

  /* Cases: Status, Titel, Aktionen sichtbar */
  .hub-table--cases th:nth-child(3),
  .hub-table--cases td:nth-child(3),
  .hub-table--cases th:nth-child(4),
  .hub-table--cases td:nth-child(4),
  .hub-table--cases th:nth-child(5),
  .hub-table--cases td:nth-child(5),
  .hub-table--cases th:nth-child(6),
  .hub-table--cases td:nth-child(6),
  .hub-table--cases th:nth-child(7),
  .hub-table--cases td:nth-child(7) { display: none; }

  /* CRM Kunden */
  .hub-table--customers th:nth-child(4),
  .hub-table--customers td:nth-child(4),
  .hub-table--customers th:nth-child(5),
  .hub-table--customers td:nth-child(5),
  .hub-table--customers th:nth-child(6),
  .hub-table--customers td:nth-child(6) { display: none; }

  /* CRM Freelancer */
  .hub-table--freelancers th:nth-child(3),
  .hub-table--freelancers td:nth-child(3),
  .hub-table--freelancers th:nth-child(4),
  .hub-table--freelancers td:nth-child(4),
  .hub-table--freelancers th:nth-child(5),
  .hub-table--freelancers td:nth-child(5) { display: none; }

  /* Admin Nutzer */
  .hub-table--users th:nth-child(3),
  .hub-table--users td:nth-child(3),
  .hub-table--users th:nth-child(4),
  .hub-table--users td:nth-child(4),
  .hub-table--users th:nth-child(5),
  .hub-table--users td:nth-child(5) { display: none; }

  /* App Factory Briefings */
  .hub-table--briefings th:nth-child(3),
  .hub-table--briefings td:nth-child(3),
  .hub-table--briefings th:nth-child(4),
  .hub-table--briefings td:nth-child(4),
  .hub-table--briefings th:nth-child(5),
  .hub-table--briefings td:nth-child(5) { display: none; }

  .newsletter-editor-grid {
    grid-template-columns: 1fr !important;
  }

  .mobile-menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .page-header .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .page-header .header-actions .btn:only-child,
  .page-header .header-actions .btn-primary:only-of-type {
    grid-column: 1 / -1;
  }

  .wissen-header-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: .35rem;
  }

  .wissen-header-actions .btn:first-child {
    grid-column: 1 / -1;
  }

  .meeting-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .35rem;
  }

  .meeting-card-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .booking-card,
  .dev-day-card {
    padding: .85rem;
  }

  .mp-detail-header {
    flex-direction: column;
    align-items: stretch !important;
  }

  .mp-detail-header .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (hover: none) and (pointer: coarse) {
  .mobile-menu-btn { min-height: 44px; min-width: 44px; }
}

