*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal:        #8C1A2B;   /* ServCulinar Crimson — Primärfarbe */
  --teal-dark:   #6E1522;   /* Hover-Zustand */
  --gold:        #F9B72E;   /* Highlight-Akzent */
  --navy:        #1A2B48;   /* Header / dunkle Flächen */
  --green:       #22c55e;
  --red:         #ef4444;
  --orange:      #f97316;
  --gray:        #9ca3af;
  --bg:          #f3f4f6;
  --white:       #ffffff;
  --border:      #e5e7eb;
  --text:        #111827;
  --muted:       #6b7280;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
#header {
  background: var(--navy);
  color: #fff;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}

#header h1 {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 72px;
}

.header-logo {
  height: 30px;
  width: auto;
  display: block;
  /* Auf Navy-Hintergrund: Logo weiß einfärben für klare Lesbarkeit */
  filter: brightness(0) invert(1);
}

.header-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.03em;
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 14px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  margin-left: auto;
  flex-shrink: 0;
}

#kitchenBadge {
  background: var(--teal);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
}

#notifBell {
  position: relative;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}
#notifBell:hover { background: rgba(255,255,255,0.1); }
#notifBell svg { width: 22px; height: 22px; fill: #fff; display: block; }
#notifCount {
  position: absolute;
  top: 0; right: 0;
  background: var(--gold);
  color: var(--navy);
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 10px;
  padding: 1px 5px;
  display: none;
}

#btnLogout {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}
#btnLogout:hover { background: rgba(255,255,255,0.1); }

/* ── MAIN LAYOUT ── */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  /* Footer-Höhe (36px) schon durch flexbox abgedeckt */
}

/* ── SIDEBAR (Auftragsliste) ── */
#sidebar {
  width: 425px;
  min-width: 350px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

#sidebarHeader {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Zeile 1: Titel + "Meine Aufträge" Button */
.sidebar-header-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-header-row1 h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
}

/* "Meine Aufträge" Toggle-Button */
.my-orders-btn {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--teal);
  background: transparent;
  color: var(--teal);
  transition: all 0.15s;
  white-space: nowrap;
}
.my-orders-btn:hover {
  background: var(--teal);
  color: #fff;
}
.my-orders-btn.active {
  background: var(--teal);
  color: #fff;
}

/* Status-Filter-Tabs */
.filter-tabs {
  display: flex;
  gap: 4px;
}

.filter-tab {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: var(--bg);
  color: var(--muted);
  transition: all 0.15s;
}
.filter-tab.active {
  background: var(--navy);
  color: #fff;
}

/* Datums-Filter */
.date-filter {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.date-btn {
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
}
.date-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}
.date-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* Suchfeld */
.search-bar {
  position: relative;
  margin-top: 10px;
}
.search-bar input {
  width: 100%;
  padding: 7px 28px 7px 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  background: var(--white);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(26,43,72,0.1);
}
.search-bar input::placeholder {
  color: var(--muted);
}
.search-bar-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.8rem;
  pointer-events: none;
}
#searchClear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 4px;
  display: none;
  line-height: 1;
}
#searchClear:hover { color: var(--text); }

/* ── E-MAIL LISTE ── */
#emailList {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.email-item {
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: 4px;
  position: relative;
}

.email-item:hover { background: var(--bg); }
.email-item.active { border-color: var(--teal); background: #f0fffe; }
.email-item.item-locked { background: #fef2f2; border-left: 3px solid #fca5a5; opacity: 1; }
.email-item.item-mine   { background: #f0fff4; border-left: 3px solid #86efac; opacity: 1; }
.email-item.item-mine.active { border-color: var(--green); background: #dcfce7; }
.email-item.item-done   { background: #f9fafb; border-left: 3px solid #d1d5db; opacity: 1; }

.email-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.status-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.08);
}
.status-dot.open    { background: var(--green); }
.status-dot.claimed { background: var(--red); }
.status-dot.done    { background: var(--gray); }

.email-sender {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-date {
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
}

.email-subject {
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 18px;
}

.category-badge {
  display: inline-block;
  margin-top: 4px;
  margin-left: 18px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #ede9fe;
  color: #6d28d9;
}

/* ── CLAIMED BADGE in Listeneinträgen ── */
.claimed-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  margin-left: 18px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.claimed-badge.mine {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.claimed-badge.other {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ── DETAIL-BEREICH ── */
#detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#detailEmpty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--muted);
  gap: 12px;
}

#detailEmpty svg { width: 48px; height: 48px; fill: var(--border); }

#detailContent {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

#detailHeader {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}

/* ── CLAIMED BANNER im Detail-Header ── */
#claimedBanner {
  display: none;               /* per JS auf 'flex' gesetzt wenn sichtbar */
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  margin: -20px -24px 16px;   /* bricht aus Header-Padding heraus */
  font-size: 0.875rem;
  font-weight: 600;
}
#claimedBanner strong { font-weight: 800; }
#claimedBanner.locked {
  background: #fee2e2;
  color: #b91c1c;
  border-bottom: 2px solid #fca5a5;
}
#claimedBanner.mine {
  background: #dcfce7;
  color: #15803d;
  border-bottom: 2px solid #86efac;
}

.banner-lock  { font-size: 1rem; }
.banner-check { font-size: 1rem; }

#detailSubject {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

#detailMeta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

#detailActions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: scale(0.97); }

.btn-primary   { background: var(--teal);  color: #fff; }
.btn-primary:hover   { background: var(--teal-dark); }
.btn-danger    { background: var(--red);   color: #fff; }
.btn-danger:hover    { background: #dc2626; }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover   { background: #16a34a; }
.btn-secondary { background: var(--bg);   color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-warning   { background: #f59e0b; color: #fff; }
.btn-warning:hover   { background: #d97706; }
.btn:disabled  { opacity: 0.4; cursor: not-allowed; }

#detailBody {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.email-body-html {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 720px;
}

.email-body-text {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  max-width: 720px;
  font-family: inherit;
}

.attachments-section {
  margin-top: 20px;
  max-width: 720px;
}

.attachments-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.83rem;
  transition: border-color 0.15s;
}
.attachment-item:hover { border-color: var(--teal); }
.attachment-item svg { width: 16px; height: 16px; fill: var(--teal); flex-shrink: 0; }

/* ── INTERNE NOTIZ ── */
#noteSection {
  border-top: 2px solid var(--border);
  padding: 14px 24px 16px;
  background: #fffbeb;
  flex-shrink: 0;
  display: none;
}

.note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.note-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.note-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
}

#noteTextarea {
  width: 100%;
  height: 90px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.2s;
}
#noteTextarea:focus { border-color: var(--gold); }

.note-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.btn-note-save {
  background: var(--navy);
  color: #fff;
  padding: 7px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-note-save:hover { background: #243d6b; }

.btn-note-delete {
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.15s;
}
.btn-note-delete:hover { background: #fee2e2; color: var(--red); border-color: #fca5a5; }

/* ── ALARM BUTTON ── */
@keyframes alarmPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
  50%       { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
}

#alarmBtn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 6px 14px 6px 10px;
  border-radius: 8px;
  background: #ef4444;
  border: none;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background 0.15s;
  animation: alarmPulse 1.4s infinite;
}
#alarmBtn:hover  { background: #dc2626; transform: scale(1.04); }
#alarmBtn:active { transform: scale(0.97); }
#alarmBtn svg    { width: 18px; height: 18px; fill: #fff; display: block; flex-shrink: 0; }
.alarm-btn-label { pointer-events: none; }
#alarmCount {
  background: #fff;
  color: #dc2626;
  font-size: 0.7rem;
  font-weight: 900;
  border-radius: 12px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
}

/* ── ALARM PANEL ── */
#alarmPanel {
  position: fixed;
  top: 56px; right: 0;
  width: 340px;
  max-height: calc(100vh - 56px - 36px);
  background: var(--white);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 101;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
}
#alarmPanel.open { transform: translateX(0); }

#alarmPanelHeader {
  padding: 16px 20px;
  border-bottom: 2px solid #fca5a5;
  background: #fef2f2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#alarmPanelHeader h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #b91c1c;
}
#alarmClose {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
}
#alarmClose:hover { background: var(--bg); }

#alarmPanelInfo {
  padding: 12px 20px;
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #fffbeb;
}

#alarmList {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.alarm-item {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fef2f2;
  border-left: 3px solid #ef4444;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.alarm-item:hover { background: #fee2e2; }

.alarm-item-sender {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 2px;
}
.alarm-item-subject {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.alarm-item-age {
  font-size: 0.72rem;
  color: #ef4444;
  font-weight: 600;
}

/* ── MITTEILUNGEN PANEL ── */
#notifPanel {
  position: fixed;
  top: 56px; right: 0;
  width: 320px;
  height: calc(100vh - 56px - 36px);
  background: var(--white);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}

#notifPanel.open { transform: translateX(0); }

#notifPanelHeader {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#notifPanelHeader h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
}

#notifClearAll {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
#notifClearAll:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

#notifClose {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
}
#notifClose:hover { background: var(--bg); }

#notifList {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.notif-item {
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 8px;
  border-left: 3px solid var(--teal);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.notif-item.new { border-left-color: var(--gold); background: #fffbeb; }

.notif-text {
  font-size: 0.83rem;
  color: var(--text);
  line-height: 1.5;
  flex: 1;
}

.notif-subject {
  font-weight: 600;
  color: var(--navy);
}

.notif-sender {
  display: inline-block;
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

.notif-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.notif-time {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.notif-delete-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s;
}
.notif-delete-btn:hover { background: #fee2e2; color: var(--red); }

/* ── FOOTER ── */
#footer {
  height: 36px;
  background: var(--navy);
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.75rem;
  flex-shrink: 0;
  z-index: 10;
}

#footer a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-weight: 600;
}

/* ── TOASTS ── */
#toastContainer {
  position: fixed;
  bottom: 52px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.875rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease;
  max-width: 300px;
  pointer-events: all;
}

.toast.success { border-left: 4px solid var(--teal); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.info    { border-left: 4px solid var(--gold); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── HEADER: Label ausblenden bei kleiner Auflösung ── */
@media (max-width: 1023px) {
  .btn-label,
  .alarm-btn-label { display: none; }
  #header h1 .header-subtitle { display: none; }
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  #sidebar {
    width: 100%;
    position: absolute;
    top: 56px; left: 0;
    height: calc(100vh - 56px - 36px);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.mobile-open { transform: translateX(0); }
  #detail { width: 100%; }
}

/* Scrollbar Styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── DRUCK / PRINT ── */
@media print {
  /* 1. Root-Elemente: Viewport-Constraints komplett aufheben */
  html, body {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    flex: none !important;
  }

  /* 2. Nicht benötigte Elemente ausblenden */
  #header, #sidebar, #footer, #notifPanel, #alarmPanel, #toastContainer,
  #detailActions, #claimedBanner, #btnPrint, #detailEmpty,
  #noteSection, .attachments-section {
    display: none !important;
  }

  /* 3. Flex-Sizing aus allen Layout-Containern entfernen */
  #main {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #detail {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #detailContent {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* 4. Header: kein erzwungener Seitenumbruch danach */
  #detailHeader {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 16px 0 12px 0 !important;
    border-bottom: 2px solid #333 !important;
    margin-bottom: 16px !important;
    break-after: avoid !important;
    page-break-after: avoid !important;
  }

  /* 5. Body: natürlicher Fluss, kein Scroll-Container mehr */
  #detailBody {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* 6. Typografie */
  #detailSubject { font-size: 1.2rem; font-weight: 700; color: #000; margin-bottom: 6px; }
  #detailMeta { font-size: 0.9rem; color: #333; display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 12px; }

  /* 7. Paragraph-Abstände normalisieren (HTML-Mails haben oft 21+ p-Tags = viel Leerraum) */
  p { margin: 0 0 6px 0 !important; }

  /* 8. E-Mail-Body ohne Box */
  .email-body-html, .email-body-text {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
    font-size: 0.95rem;
    color: #000;
    line-height: 1.6;
  }

  /* 8. Anhänge */
  .attachments-section { margin-top: 16px; border-top: 1px solid #ccc; padding-top: 10px; }
  .attachment-item { color: #000; text-decoration: none; }
}

/* ── WHITEBOARD BUTTON ── */
#whiteboardBtn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 6px 14px 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.72);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#whiteboardBtn:hover  { background: rgba(255,255,255,0.18); color: #fff; border-color: rgba(255,255,255,0.38); }
#whiteboardBtn.active { background: rgba(255,255,255,0.18); color: #fff; border-color: rgba(255,255,255,0.38); }
#whiteboardBtn svg    { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

/* ── KALENDER ── */

#calendarBtn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.22);
  background: transparent; color: rgba(255,255,255,0.85);
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s; white-space: nowrap;
}
#calendarBtn:hover  { background: rgba(255,255,255,0.18); color: #fff; border-color: rgba(255,255,255,0.38); }
#calendarBtn.active { background: rgba(255,255,255,0.18); color: #fff; border-color: rgba(255,255,255,0.38); }
#calendarBtn svg    { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

#calendarView { display: none; flex-direction: column; flex: 1; overflow: hidden; background: var(--bg); }
#calendarView.active { display: flex; }

.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--white); border-bottom: 1px solid var(--border);
  gap: 12px; flex-shrink: 0; flex-wrap: wrap;
}
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav-btn {
  width: 30px; height: 30px; border: 1px solid var(--border); background: var(--white);
  border-radius: 6px; cursor: pointer; font-size: 1.1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; color: var(--text);
  transition: background 0.1s;
}
.cal-nav-btn:hover  { background: var(--bg); }
.cal-nav-today {
  padding: 5px 10px; border: 1px solid var(--border); background: var(--white);
  border-radius: 6px; cursor: pointer; font-size: 0.78rem; font-weight: 600;
  color: var(--text); transition: background 0.1s;
}
.cal-nav-today:hover { background: var(--bg); }
.cal-title { font-size: 0.95rem; font-weight: 700; color: var(--navy); flex: 1; text-align: center; }
.cal-view-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.cal-tab {
  padding: 5px 10px; border: 1.5px solid var(--border); background: var(--white);
  border-radius: 6px; cursor: pointer; font-size: 0.78rem; font-weight: 600;
  color: var(--muted); transition: all 0.1s;
}
.cal-tab:hover  { background: var(--bg); color: var(--text); }
.cal-tab.active { background: var(--teal); color: #fff; border-color: var(--teal); }
.cal-tab-add    { background: var(--teal) !important; color: #fff !important; border-color: var(--teal) !important; margin-left: 6px; }
.cal-tab-add:hover { background: var(--teal-dark) !important; border-color: var(--teal-dark) !important; }

.cal-body { flex: 1; overflow: auto; padding: 14px; }

/* Monat */
.cal-grid-month {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px; min-height: 480px;
}
.cal-weekday-header {
  text-align: center; padding: 7px 4px; font-size: 0.72rem; font-weight: 700;
  color: var(--muted); letter-spacing: 0.05em; background: var(--white); border-radius: 4px;
}
.cal-day-cell {
  background: var(--white); border: 1px solid var(--border); border-radius: 6px;
  min-height: 86px; padding: 6px; cursor: pointer; transition: background 0.1s; overflow: hidden;
}
.cal-day-cell:hover    { background: #f9fafb; }
.cal-day-cell.cal-day-other { background: var(--bg); border-color: transparent; cursor: default; }
.cal-day-cell.cal-today { background: #fff5f5; border-color: var(--teal); }
.cal-day-num { font-size: 0.8rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; display: inline-flex; }
.cal-today .cal-day-num {
  background: var(--teal); color: #fff; width: 22px; height: 22px;
  border-radius: 50%; align-items: center; justify-content: center; font-size: 0.75rem;
}
.cal-event-pill {
  padding: 2px 5px; border-radius: 4px; font-size: 0.69rem; margin-bottom: 2px;
  display: flex; gap: 4px; align-items: center; cursor: pointer; white-space: nowrap;
  overflow: hidden; transition: opacity 0.1s;
}
.cal-event-pill:hover  { opacity: 0.75; }
.cal-pill-time  { font-weight: 700; flex-shrink: 0; color: var(--muted); }
.cal-pill-title { overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.cal-more-events { font-size: 0.68rem; color: var(--muted); font-weight: 600; }

/* Woche */
.cal-grid-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; min-height: 480px; }
.cal-week-col {
  background: var(--white); border-radius: 8px; border: 1px solid var(--border);
  overflow: hidden; display: flex; flex-direction: column;
}
.cal-today-col { border-color: var(--teal); }
.cal-week-header {
  padding: 7px 8px; border-bottom: 1px solid var(--border);
  text-align: center; background: var(--bg);
}
.cal-today-header { background: #fff5f5; }
.cal-week-day  { font-size: 0.7rem; font-weight: 700; color: var(--muted); display: block; }
.cal-week-date { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.cal-today-header .cal-week-date { color: var(--teal); }
.cal-week-events { padding: 6px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.cal-week-event {
  padding: 4px 7px; border-radius: 5px; cursor: pointer; transition: opacity 0.1s;
}
.cal-week-event:hover { opacity: 0.78; }
.cal-we-time  { font-size: 0.68rem; font-weight: 700; color: var(--muted); }
.cal-we-title { font-size: 0.77rem; font-weight: 600; color: var(--text); }
.cal-we-who   { font-size: 0.68rem; font-weight: 600; }
.cal-no-events { font-size: 0.72rem; color: var(--border); text-align: center; padding-top: 14px; }

/* Tag */
.cal-grid-day { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.cal-day-event {
  background: var(--white); border-radius: 10px; border: 1px solid var(--border);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.cal-de-time  { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.cal-de-title { font-size: 1rem; font-weight: 700; color: var(--navy); }
.cal-de-who   { font-size: 0.8rem; font-weight: 600; }
.cal-de-desc  { font-size: 0.84rem; color: var(--muted); margin-top: 4px; }
.cal-de-actions { display: flex; gap: 8px; margin-top: 8px; }
.cal-btn-edit, .cal-btn-delete {
  padding: 4px 10px; border-radius: 5px; font-size: 0.75rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.1s; border: 1px solid;
}
.cal-btn-edit   { background: var(--bg); color: var(--navy); border-color: var(--border); }
.cal-btn-edit:hover { background: var(--border); }
.cal-btn-delete { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.cal-btn-delete:hover { background: #fee2e2; }
.cal-day-empty { text-align: center; color: var(--muted); padding: 48px 0; font-size: 0.9rem; }

/* Modal */
.cal-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.48);
  z-index: 1000; display: none; align-items: center; justify-content: center;
}
.cal-modal-box {
  background: var(--white); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.22);
  width: 100%; max-width: 400px; overflow: hidden;
}
.cal-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border);
}
.cal-modal-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.cal-modal-close {
  width: 26px; height: 26px; border: none; background: none; cursor: pointer;
  font-size: 1rem; color: var(--muted); border-radius: 5px; transition: background 0.1s;
}
.cal-modal-close:hover { background: var(--bg); }
.cal-modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.cal-modal-body label {
  font-size: 0.72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: -4px;
}
.cal-modal-body input[type="text"],
.cal-modal-body input[type="date"],
.cal-modal-body textarea {
  width: 100%; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: 0.88rem; font-family: inherit; color: var(--text); background: var(--white);
  transition: border-color 0.15s;
}
.cal-modal-body input:focus,
.cal-modal-body textarea:focus { outline: none; border-color: var(--teal); }
.cal-modal-body textarea { resize: vertical; min-height: 64px; }
.cal-time-row { display: flex; align-items: center; gap: 6px; }
.cal-time-row input {
  width: 58px; padding: 8px 6px; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: 1rem; font-weight: 700; text-align: center; font-family: monospace;
  color: var(--navy); background: var(--white); transition: border-color 0.15s;
  -moz-appearance: textfield;
}
.cal-time-row input:focus { outline: none; border-color: var(--teal); }
.cal-time-row input::-webkit-outer-spin-button,
.cal-time-row input::-webkit-inner-spin-button { -webkit-appearance: none; }
.cal-time-sep { font-size: 1.1rem; font-weight: 700; color: var(--navy); }
.cal-modal-footer {
  padding: 12px 20px 16px; display: flex; gap: 8px;
  justify-content: flex-end; border-top: 1px solid var(--border);
}
#btnAddToCalendar { border-color: var(--teal); color: var(--teal); }
#btnAddToCalendar:hover { background: var(--teal); color: #fff; }

/* ── WHITEBOARD VIEW ── */
#whiteboardView { display: none; flex: 1; overflow: hidden; background: var(--bg); padding: 14px 16px; }
#whiteboardView.active { display: flex; flex-direction: column; }
#wbColumns { display: flex; gap: 14px; flex: 1; overflow: hidden; }
.wb-col { flex: 1; display: flex; flex-direction: column; background: #e8eaee; border-radius: 10px; overflow: hidden; min-width: 0; }
.wb-col-header { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em; flex-shrink: 0; }
.wb-header-k1 { background: rgba(24,197,184,0.18); color: #0a6b65; }
.wb-header-k2 { background: rgba(249,183,46,0.22); color: #7a4e00; }
.wb-header-k3 { background: rgba(26,43,72,0.15); color: #1a2b48; }
.wb-col-count { background: rgba(0,0,0,0.11); border-radius: 20px; padding: 1px 9px; font-size: 0.72rem; font-weight: 800; }
.wb-col-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 7px; }
.wb-card { background: #fff; border-radius: 8px; padding: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.07); cursor: pointer; transition: box-shadow 0.15s, transform 0.1s; border-left: 3px solid transparent; }
.wb-card:hover { box-shadow: 0 4px 10px rgba(0,0,0,0.11); transform: translateY(-1px); }
.wb-card-k1 { border-left-color: #18C5B8; }
.wb-card-k2 { border-left-color: #F9B72E; }
.wb-card-k3 { border-left-color: #1A2B48; }
.wb-card-subject { font-size: 0.81rem; font-weight: 600; color: var(--text); margin-bottom: 5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.wb-card-meta { font-size: 0.71rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.wb-empty { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 24px 10px; font-style: italic; }

/* ── ZUWEISEN (Admin/Verwaltung) ── */
#reassignSection { display: none; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.reassign-select {
  flex: 1; min-width: 140px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.82rem; color: var(--text);
  background: #fff; cursor: pointer;
}
.reassign-select:focus { outline: none; border-color: var(--teal); }
#adminLink {
  display: none; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 6px; font-size: 0.82rem;
  font-weight: 600; background: var(--navy); color: #fff !important;
  text-decoration: none; border: none; cursor: pointer;
  transition: opacity 0.15s;
}
#adminLink:hover { opacity: 0.85; }
