/* ============================================================= *
 *  Vantario DIG – Overlay stylesheet
 *  Light is default. `body.dark` swaps the palette (Dark Mode).
 * ============================================================= */
:root {
  --bg: #e9edf2;
  --bg-panel: #ffffff;
  --bg-panel-2: #eef1f5;
  --bg-hover: #e2e8f0;
  --border: #c4ccd6;
  --text: #141a24;
  --text-soft: #444d5c;      /* kontrastreicher als vorher */
  --text-faint: #6a7482;     /* kontrastreicher als vorher */
  --accent: #454f5e;
  --accent-strong: #2b333f;
  --danger: #b5281c;
  --shadow: 0 10px 34px rgba(20, 28, 40, 0.14);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-pill: 980px;
}

body.dark {
  --bg: #10131a;
  --bg-panel: #1c2027;
  --bg-panel-2: #272d37;
  --bg-hover: #343c48;
  --border: #454e5c;         /* sichtbarere Trennlinien */
  --text: #f2f5f9;
  --text-soft: #ccd4de;      /* kontrastreicher */
  --text-faint: #a6b1bf;     /* kontrastreicher */
  --accent: #3b82f6;         /* echtes Blau statt Blassgrau – weiße Schrift lesbar */
  --accent-strong: #7cadff;
  --danger: #f0796b;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  color-scheme: dark;        /* native Datums-/Scrollbars passen sich an */
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.view { height: 100vh; }
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; transition: background .15s, transform .06s, filter .15s; }
button:active { transform: scale(0.97); }
input, textarea, select {
  font-family: inherit; font-size: 14px;
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
a { color: var(--accent-strong); }

/* ===================== LOGIN ===================== */
.login-view {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #5c6674 0%, #2b3038 45%, #14171c 100%);
  color: #eef1f5;
}
.login-box {
  display: flex; flex-direction: column; align-items: center; gap: 26px;
  padding: 44px 46px;
  background: rgba(28, 32, 38, 0.55);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  min-width: 360px;
}
.login-logo { width: 210px; height: auto; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.45)); }
.login-form { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.login-row { display: flex; align-items: center; gap: 12px; }
.login-row span { width: 92px; text-align: right; color: #cdd3da; font-weight: 600; }
.login-row input {
  flex: 1; background: rgba(255,255,255,0.92); color: #1d2330; border: none;
  border-radius: var(--radius-pill); padding: 10px 16px;
}
.login-row input:focus { box-shadow: 0 0 0 3px rgba(255,255,255,0.35); }
.login-btn {
  margin-top: 8px; padding: 12px; border: none; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #aab4c0, #6d7784);
  color: #12151a; font-weight: 700; letter-spacing: 0.5px;
}
.login-btn:hover { filter: brightness(1.08); }
.login-error {
  margin: 4px 0 0; color: #ffb4a8; font-size: 13px; text-align: center;
}
.login-foot { color: rgba(255,255,255,0.5); font-size: 12px; letter-spacing: 2px; }

/* ===================== APP SHELL ===================== */
.app-view { display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.topbar-logo { height: 30px; width: auto; }
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search input { width: 100%; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.whoami { color: var(--text-soft); font-size: 13px; margin-right: 4px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-panel-2); color: var(--text); font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: var(--bg-hover); }
.topbar-search input { border-radius: var(--radius-pill); padding-left: 16px; }

.app-body { flex: 1; display: flex; min-height: 0; }

/* ---- contact list ---- */
.contact-list {
  width: 300px; flex-shrink: 0; border-right: 1px solid var(--border);
  background: var(--bg-panel); overflow: hidden;
  transition: width .28s ease, border-color .28s ease;
}
.contact-list-inner {
  width: 300px; height: 100%; display: flex; flex-direction: column;
}
/* Kontakt ausgewählt -> Liste fährt nach rechts ein */
.app-body.focus-contact .contact-list { width: 0; border-right-color: transparent; }

.back-btn {
  align-self: flex-start; margin-bottom: 12px;
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text);
  border-radius: var(--radius-pill); padding: 6px 14px 6px 10px; font-weight: 600; font-size: 13px;
}
.back-btn:hover { background: var(--bg-hover); }

/* ---- presence (Discord-style) ---- */
.presence { margin: 0 12px 6px; }
.presence:empty { display: none; }
.presence-title {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-faint); margin: 4px 4px 6px;
}
.presence-row { display: flex; gap: 9px; align-items: flex-start; padding: 6px 6px; border-radius: 10px; }
.presence-row.me { background: var(--bg-panel-2); }
.presence-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #34c759; margin-top: 4px; flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, #34c759 22%, transparent);
}
.presence-info { min-width: 0; }
.presence-name { font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.presence-act { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.new-contact-btn {
  margin: 12px; padding: 11px; border-radius: var(--radius-pill); border: 1px dashed var(--accent);
  background: transparent; color: var(--accent-strong); font-weight: 600;
}
.new-contact-btn:hover { background: var(--bg-hover); }
.contact-items { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.contact-items { padding: 6px; }
.contact-item {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  border-radius: 14px; cursor: pointer; margin-bottom: 2px;
}
.contact-item:hover { background: var(--bg-hover); }
.contact-item.active { background: var(--bg-hover); }
.contact-item.active .ci-company { color: var(--accent-strong); }
.ci-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #aab4c0, #6d7784); color: #12151a; font-weight: 700;
}
.ci-main { min-width: 0; flex: 1; }
.ci-company { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-sub { color: var(--text-faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-badge {
  background: #ff3b30; color: #fff; border-radius: var(--radius-pill); font-size: 11px;
  font-weight: 700; min-width: 18px; text-align: center; padding: 1px 6px; flex-shrink: 0;
}
.contact-empty { padding: 20px; color: var(--text-faint); text-align: center; }

/* ---- detail area ---- */
.detail-area { flex: 1; min-width: 0; overflow: hidden; }

/* ===================== HOME: Chat-Liste + Unterhaltung + Mitglieder ===================== */
.home-view {
  height: 100%; display: grid; grid-template-columns: 268px minmax(0, 1fr) 240px;
}

/* --- Chat-Liste (WhatsApp-Stil) --- */
.chat-list {
  min-width: 0; display: flex; flex-direction: column;
  background: var(--bg-panel); border-right: 1px solid var(--border);
}
.chat-list-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.home-logo { height: 24px; width: auto; flex-shrink: 0; }
.chat-newbtn {
  margin-left: auto; border: 1px solid var(--border); background: var(--bg-panel-2);
  color: var(--accent-strong); border-radius: var(--radius-pill);
  padding: 6px 12px; font-weight: 600; font-size: 12px; flex-shrink: 0;
}
.chat-newbtn:hover { background: var(--bg-hover); }
.chat-list-rows { flex: 1; overflow-y: auto; padding: 6px; }
.chatrow {
  width: 100%; display: flex; gap: 10px; align-items: center; text-align: left;
  border: none; background: transparent; padding: 9px 10px; border-radius: 12px; color: var(--text);
}
.chatrow:hover { background: var(--bg-hover); }
.chatrow.active { background: var(--bg-hover); }
.chatrow.active .chatrow-name { color: var(--accent-strong); }
.chatrow-av {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
  background: linear-gradient(180deg, #aab4c0, #6d7784); color: #12151a;
}
.chatrow-av.team { background: linear-gradient(180deg, #6f7b8a, #454f5c); color: #fff; }
.chatrow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chatrow-top, .chatrow-bottom { display: flex; align-items: center; gap: 6px; }
.chatrow-name { font-weight: 700; font-size: 13.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatrow-time { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.chatrow-preview { flex: 1; font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread {
  background: #25d366; color: #06301a; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 800; padding: 1px 6px; min-width: 18px; text-align: center; flex-shrink: 0;
}

/* --- Unterhaltung --- */
.home-chat { min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.thread-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: var(--bg-panel); min-height: 56px;
}
.thread-head .chatrow-av { width: 34px; height: 34px; font-size: 13px; }
.thread-title { font-weight: 700; font-size: 14px; }
.thread-sub { font-size: 11.5px; color: var(--text-faint); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px;
  /* Firmenlogo als dezenter, feststehender Hintergrund; Nachrichten liegen darüber */
  background-image:
    linear-gradient(color-mix(in srgb, var(--bg) 87%, transparent),
                    color-mix(in srgb, var(--bg) 87%, transparent)),
    url("/assets/logo.png");
  background-repeat: no-repeat, no-repeat;
  background-position: center, center;
  background-size: auto, min(260px, 42%);
  background-attachment: scroll, scroll;   /* bleibt beim Scrollen der Nachrichten stehen */
}
.chat-empty {
  color: var(--text-faint); text-align: center; margin: auto;
  background: color-mix(in srgb, var(--bg-panel) 82%, transparent);
  padding: 8px 14px; border-radius: var(--radius-pill);
}
.chat-msg { max-width: 78%; align-self: flex-start; }
.chat-msg.me { align-self: flex-end; text-align: right; }
.chat-msg-head { font-size: 11px; color: var(--text-faint); margin-bottom: 2px; }
.chat-msg-author { font-weight: 700; color: var(--text-soft); }
.chat-msg-time { margin-left: 6px; }
.chat-msg-body {
  display: inline-block; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 8px 13px; font-size: 13.5px; white-space: pre-wrap;
  text-align: left; word-break: break-word;
}
.chat-msg.me .chat-msg-body { background: var(--accent); color: #fff; border-color: var(--accent); }

.chat-msg { position: relative; }
.chat-msg-edited { font-size: 10.5px; opacity: .7; font-style: italic; }
.chat-msg.deleted .chat-msg-del {
  background: transparent; border: 1px dashed var(--border); color: var(--text-faint);
  font-style: italic;
}
.chat-msg.me.deleted .chat-msg-del { color: var(--text-faint); }
.chat-msg-actions {
  display: none; gap: 2px; margin-top: 3px;
}
.chat-msg.me .chat-msg-actions { justify-content: flex-end; }
.chat-msg:hover .chat-msg-actions { display: flex; }
.cm-act {
  border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-soft);
  border-radius: var(--radius-pill); width: 26px; height: 24px; font-size: 12px;
  cursor: pointer; padding: 0; line-height: 1;
}
.cm-act:hover { background: var(--bg-hover); }

.chat-composer {
  display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border);
  background: var(--bg-panel); align-items: center;
}
.chat-composer #chat-input { flex: 1; border-radius: var(--radius-pill); }
.chat-ai {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-panel); cursor: pointer;
  font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.chat-ai:hover { background: var(--bg-hover); }
.chat-ai.busy { opacity: .5; pointer-events: none; animation: cm-pulse 1s ease-in-out infinite; }
@keyframes cm-pulse { 50% { opacity: .85; } }

.trash-btn {
  flex: none; margin: 4px 10px 12px; text-align: left;
  border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-soft);
  border-radius: 12px; padding: 10px 12px; font-size: 13px; cursor: pointer;
}
.trash-btn:hover { background: var(--bg-hover); }
.trash-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.home-online {
  border-left: 1px solid var(--border); background: var(--bg-panel);
  overflow-y: auto; padding: 12px 10px;
}
.member-group {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); margin: 12px 6px 6px;
}
.member-group:first-child { margin-top: 2px; }
.member-row {
  display: flex; gap: 9px; align-items: flex-start; padding: 7px 8px; border-radius: 10px; cursor: pointer;
}
.member-row:hover { background: var(--bg-hover); }
.member-row.me { cursor: default; }
.member-row.me:hover { background: transparent; }
.member-row.off { opacity: 0.5; }
.member-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #34c759; margin-top: 4px; flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, #34c759 22%, transparent);
}
.member-dot.off, .member-row.off .member-dot { background: var(--text-faint); box-shadow: none; }
.member-info { min-width: 0; }
.member-name { font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-act { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dm-picker { display: flex; flex-direction: column; gap: 6px; }
.dm-pick {
  display: flex; align-items: center; gap: 9px; text-align: left;
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text);
  border-radius: 12px; padding: 10px 12px; font-weight: 600;
}
.dm-pick:hover { background: var(--bg-hover); }
.dm-pick-act { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--text-faint); }

.detail-grid {
  height: 100%;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 260px;
  gap: 0;
}
.col { height: 100%; overflow-y: auto; padding: 16px; }
.col-left { border-right: 1px solid var(--border); background: var(--bg-panel); }
.col-mid { background: var(--bg); }
.col-right { border-left: 1px solid var(--border); background: var(--bg-panel); }

/* customer head */
.cust-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.cust-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #aab4c0, #6d7784); color: #12151a; font-weight: 700;
}
.cust-headinfo { flex: 1; min-width: 0; }
.cust-company { font-size: 16px; font-weight: 700; }
.cust-email { display: block; font-size: 13px; word-break: break-all; }
.cust-phone { font-size: 13px; color: var(--text-soft); }
.cust-head-actions { display: flex; gap: 6px; flex-shrink: 0; position: relative; }
.mini-btn, .mini-danger {
  border: 1px solid var(--border); background: var(--bg-panel-2); border-radius: 50%;
  width: 30px; height: 30px; flex-shrink: 0; font-size: 13px;
}
.mini-btn { color: var(--text-soft); }
.mini-danger { color: var(--danger); }
.mini-btn:hover, .mini-danger:hover { background: var(--bg-hover); }
.mini-danger.armed {
  width: auto; border-radius: var(--radius-pill); padding: 0 12px; height: 30px;
  background: var(--danger); color: #fff; border-color: var(--danger);
  font-weight: 700; font-size: 12px;
}

/* accordion */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.acc-head {
  width: 100%; text-align: left; border: none; background: var(--bg-panel-2);
  padding: 11px 12px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.acc-head:hover { background: var(--bg-hover); }
.acc-caret { transition: transform 0.15s; display: inline-block; color: var(--text-faint); }
.accordion.open .acc-caret { transform: rotate(90deg); }
.acc-meta { margin-left: auto; font-weight: 400; font-size: 11px; color: var(--text-faint); }
.acc-body { padding: 12px; display: none; }
.accordion.open .acc-body { display: block; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--text-faint); margin-bottom: 3px; }
.field-view { white-space: pre-wrap; min-height: 18px; color: var(--text); }
.field-view:empty::after { content: "—"; color: var(--text-faint); }
.field-edit { width: 100%; }
textarea.field-edit { min-height: 60px; resize: vertical; }
.acc-actions { display: flex; gap: 8px; margin-top: 4px; }
.btn-edit, .btn-save, .btn-cancel, .btn-inline {
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text);
  border-radius: var(--radius-pill); padding: 7px 16px; font-weight: 600;
}
.btn-save { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-edit:hover, .btn-cancel:hover, .btn-inline:hover { background: var(--bg-hover); }

/* middle: tabs — iOS segmented style */
.tabbar {
  display: flex; gap: 3px; margin-bottom: 14px; flex-wrap: wrap;
  background: var(--bg-panel-2); border: 1px solid var(--border);
  border-radius: 18px; padding: 4px;
}
.tab {
  flex: 1 1 auto; text-align: center;
  border: none; background: transparent; padding: 7px 10px; color: var(--text-soft);
  font-weight: 600; font-size: 12.5px; border-radius: 14px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--bg-panel); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
.tab-panel { min-width: 0; }
.tab-panel * { max-width: 100%; }

/* Alle Aktivitäten — Ereignis-Feed (console look, aber normale Schrift) */
.event-feed {
  background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; max-height: calc(100vh - 210px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.event-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden;
}
.event-card.flat { opacity: 0.92; }
.event-main {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
}
.event-card[data-expandable] .event-main { cursor: pointer; }
.event-card[data-expandable] .event-main:hover { background: var(--bg-hover); }
.event-ico {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg-panel-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.event-text { flex: 1; min-width: 0; }
.event-action { font-weight: 600; font-size: 13px; }
.event-detail { font-weight: 400; color: var(--text-soft); }
.event-meta { display: flex; gap: 10px; margin-top: 2px; font-size: 11.5px; color: var(--text-faint); flex-wrap: wrap; }
.event-actor::before { content: "· "; }
.event-caret { color: var(--text-faint); transition: transform .15s; align-self: center; }
.event-card.open .event-caret { transform: rotate(90deg); }
.event-body { display: none; padding: 0 12px 12px 48px; text-align: left; }
.event-card.open .event-body { display: block; }
.event-quote {
  background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font-size: 13px; text-align: left;
}
.event-quote-body { white-space: pre-wrap; margin-top: 4px; }
.event-mailbody { margin-top: 4px; }
.event-by { margin-top: 6px; font-size: 11.5px; color: var(--text-faint); }
.event-field { display: flex; gap: 8px; padding: 3px 0; white-space: normal; }
.event-field span { flex-shrink: 0; width: 120px; color: var(--text-faint); font-size: 12px; }

/* entry cards (notes/calls/tasks) */
.entry-toolbar { margin-bottom: 12px; }
.entry-list { display: flex; flex-direction: column; gap: 8px; }
.entry-card { border: 1px solid var(--border); border-radius: 14px; background: var(--bg-panel); overflow: hidden;
  transition: opacity .16s ease, transform .16s ease, margin .16s ease, max-height .18s ease; max-height: 600px; }
.entry-card.removing { opacity: 0; transform: translateX(12px); max-height: 0; margin: 0; border-width: 0; }
.entry-card-head {
  padding: 10px 12px; cursor: pointer; display: flex; gap: 6px 8px; align-items: baseline; flex-wrap: wrap;
}
.entry-card-head .entry-title { flex-basis: 100%; }
.entry-card-head:hover { background: var(--bg-hover); }
.entry-author { font-weight: 700; }
.entry-when { margin-left: auto; font-size: 11px; color: var(--text-faint); }
.entry-title { color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-body { padding: 0 12px 12px; white-space: pre-wrap; display: none; }
.entry-card.open .entry-body { display: block; }
.entry-card.open .entry-card-head { border-bottom: 1px solid var(--border); }
.entry-actions { display: flex; gap: 8px; padding: 8px 12px 12px; }
.entry-actions button {
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text);
  border-radius: var(--radius-pill); padding: 5px 14px; font-size: 12px;
}
.task-check { margin-right: 6px; }
.task-done .entry-title { text-decoration: line-through; color: var(--text-faint); }

/* Notiz-Wichtigkeit (aus KI-Einordnung eingehender Kundenmails) */
.imp-wichtig { font-weight: 800; color: #d98a00; }
.imp-very { font-weight: 800; text-decoration: underline; color: #e0625f; }

/* farbige Kante je Kategorie an Notiz-Karten */
.entry-card.cat-absage   { border-left: 3px solid #b5281c; }
.entry-card.cat-frage    { border-left: 3px solid #2f7cff; }
.entry-card.cat-aenderung { border-left: 3px solid #6d4aa8; }
.entry-card.cat-zusage   { border-left: 3px solid #1f9d55; }

/* email list */
.email-item { border: 1px solid var(--border); border-radius: 14px; margin-bottom: 8px; background: var(--bg-panel); overflow: hidden; }
.email-item.incoming { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-panel)); }
.email-item-head { padding: 10px 12px; cursor: pointer; }
.email-item-head:hover { background: var(--bg-hover); }
.email-subject { font-weight: 700; }
.email-cat {
  display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .03em; padding: 1px 7px; border-radius: 999px; margin-right: 8px; color: #fff;
}
.email-cat.cat-absage { background: #b5281c; }
.email-cat.cat-frage { background: #2f7cff; }
.email-cat.cat-aenderung { background: #6d4aa8; }
.email-cat.cat-zusage { background: #1f9d55; }
.email-cat.cat-sonstiges,
.email-cat.cat-manuell { background: #5b6472; }
.email-cat.cat-alert { background: #d98a00; }
.email-ai {
  background: var(--bg-panel-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px;
  font-size: 13px; color: var(--text-soft);
}
.email-ai .imp-wichtig, .email-ai .imp-very { margin-right: 4px; }
.rg-preview {
  font-size: 12px; color: var(--text-faint); background: var(--bg-panel-2);
  border-radius: 8px; padding: 8px 10px; margin: 8px 0 4px; white-space: pre-wrap;
}
.email-meta { font-size: 12px; color: var(--text-faint); }
.email-body { padding: 12px; border-top: 1px solid var(--border); display: none; }
.email-item.open .email-body { display: block; }
.email-attas { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.email-atta { font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 3px 10px; }

/* compose */
.compose { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-panel); padding: 14px; margin-bottom: 14px; }
.compose .crow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.compose .crow label { width: 60px; color: var(--text-faint); font-size: 12px; }
.compose .crow input { flex: 1; }
.rte-toolbar { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.rte-toolbar button {
  min-width: 32px; height: 30px; border: 1px solid var(--border); background: var(--bg-panel-2);
  color: var(--text); border-radius: 9px;
}
.rte {
  min-height: 150px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px;
  background: var(--bg-panel); overflow-y: auto;
}
.rte:focus { outline: 2px solid var(--accent); }
.compose-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.compose-actions .form-hint { flex-basis: 100%; }
.btn-ai {
  border: 1px solid transparent; border-radius: var(--radius-pill); padding: 9px 18px; font-weight: 700;
  color: #fff; background: linear-gradient(120deg, #6a5cff, #b45cff 60%, #5c9dff);
}
.btn-ai:hover { filter: brightness(1.08); }
.btn-ai:disabled { opacity: 0.6; cursor: default; }
.btn-ai-sm { padding: 5px 12px; font-size: 12px; font-weight: 700; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.label-row label { margin: 0; }
.compose input[type="file"], #c-files { max-width: 100%; }

/* right column summary */
.right-title { margin: 0 0 12px; font-size: 15px; }
.sum-note { margin-bottom: 14px; }
.sum-note label { font-size: 12px; color: var(--text-faint); display: block; margin-bottom: 4px; }
.sum-note textarea { width: 100%; resize: vertical; margin-bottom: 6px; }
.sum-item { border-top: 1px solid var(--border); padding: 10px 0; }
.sum-item-head { display: flex; align-items: center; justify-content: space-between; }
.sum-item-head span { font-weight: 600; font-size: 13px; }
.add-btn {
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--accent-strong);
  font-size: 12px; font-weight: 600; border-radius: var(--radius-pill); padding: 4px 12px;
}
.add-btn:hover { background: var(--bg-hover); }
.sum-item-val { margin-top: 4px; white-space: pre-wrap; font-size: 13px; color: var(--text-soft); }
.sum-item-edit { margin-top: 6px; display: flex; gap: 6px; }
.sum-item-edit input { flex: 1; }

/* ===================== MODALS ===================== */
.modal-root {
  position: fixed; inset: 0; background: rgba(10, 14, 20, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: var(--shadow); width: min(520px, 92vw); max-height: 88vh; overflow-y: auto;
}
.modal-head button { border-radius: 50%; width: 30px; height: 30px; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: space-between; }
.modal-head button { border: none; background: transparent; font-size: 18px; color: var(--text-soft); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { font-size: 12px; color: var(--text-faint); display: block; margin-bottom: 4px; }
.modal-body input[type=text], .modal-body input[type=email], .modal-body input[type=password] { width: 100%; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal-tabs { display: flex; gap: 3px; margin: 14px 18px 0; background: var(--bg-panel-2);
  border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 3px; }
.modal-tab { border: none; background: transparent; padding: 8px 14px; font-weight: 600;
  color: var(--text-soft); border-radius: var(--radius-pill); flex: 1; }
.modal-tab.active { color: var(--text); background: var(--bg-panel); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius-pill); padding: 9px 20px; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary.danger { background: #d9534f; border-color: #d9534f; }
.btn-primary.danger:hover { filter: brightness(1.06); }
#cm-edit-body { width: 100%; resize: vertical; min-height: 90px; }
.btn-ghost { background: var(--bg-panel-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 9px 20px; font-weight: 600; }
.btn-ghost:hover { background: var(--bg-hover); }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row > div { min-width: 0; }
.toggle-row b { font-size: 13.5px; color: var(--text); }
.toggle-row .form-hint { margin-top: 2px; }

.switch {
  position: relative; display: inline-flex; flex-shrink: 0;
  width: 46px; height: 28px; cursor: pointer;
}
.switch input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; border: none; opacity: 0; cursor: pointer;
}
.slider {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 999px; transition: background .2s ease;
}
.slider::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform .2s ease;
}
.switch input:checked + .slider { background: #34c759; }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}
.form-hint { font-size: 12px; color: var(--text-faint); }

.sound-picker { display: flex; flex-direction: column; gap: 2px; }
.sound-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-bottom: 1px solid var(--border); font-size: 13.5px; cursor: pointer;
}
.sound-row:last-child { border-bottom: none; }
.sound-row input[type="radio"] { flex-shrink: 0; }
.sound-row span { flex: 1; }
.sound-row .btn-inline { padding: 4px 12px; font-size: 12px; flex-shrink: 0; }
.modal-error { color: var(--danger); font-size: 13px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--accent-strong); color: #fff; padding: 11px 20px; border-radius: var(--radius-pill);
  box-shadow: var(--shadow); z-index: 100; font-size: 13px;
}
body.dark .toast { color: #12151a; }

/* Narrow screens: fold the summary column into a strip above the middle area. */
@media (max-width: 980px) {
  .detail-grid {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-areas: "left mid" "left right";
    grid-template-rows: 1fr auto;
  }
  .col-left { grid-area: left; }
  .col-mid { grid-area: mid; }
  .col-right {
    grid-area: right; border-left: none; border-top: 1px solid var(--border);
    max-height: 240px;
  }
}
@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; grid-template-areas: "left" "mid" "right"; }
  .col-left, .col-mid, .col-right { max-height: none; }
}
@media (max-width: 900px) {
  .home-view { grid-template-columns: 220px minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .home-view { grid-template-columns: 1fr; grid-template-rows: 42% minmax(0, 1fr); }
  .home-side { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ===================== Neue Komponenten (Feature-Batch) ===================== */

/* Status-Filter in der Kontaktliste */
.status-filter {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px 8px;
}
.sf-chip {
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text-soft);
  border-radius: var(--radius-pill); padding: 4px 10px; font-size: 11.5px; font-weight: 600;
}
.sf-chip:hover { background: var(--bg-hover); }
.sf-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sf-chip.trash { margin-left: auto; }

/* Ungelesen-Punkt + Status-Pill in Kontaktzeilen */
.ci-unseen, .ci-unseen-spacer { width: 8px; height: 8px; flex-shrink: 0; }
.ci-unseen {
  --dot: #2f7cff; border-radius: 50%; background: var(--dot);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 22%, transparent);
}
.ci-unseen.k-note    { --dot: #3b82f6; }
.ci-unseen.k-call    { --dot: #22c55e; }
.ci-unseen.k-task    { --dot: #f59e0b; }
.ci-unseen.k-email   { --dot: #2f7cff; animation: dot-pulse 1.8s ease-in-out infinite; }
.ci-unseen.k-contact { --dot: #14b8a6; }
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 20%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--dot) 8%, transparent),
                         0 0 8px 2px color-mix(in srgb, var(--dot) 45%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .ci-unseen.k-email { animation: none; } }
.ci-sub { display: flex; align-items: center; gap: 6px; }
.ci-status {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
  padding: 1px 6px; border-radius: var(--radius-pill); flex-shrink: 0;
}
.s-neu     { background: #5b6472; color: #fff; }
.s-termin  { background: #2f7cff; color: #fff; }
.s-angebot { background: #d98a00; color: #fff; }
.s-kunde   { background: #1f9d55; color: #fff; }
.s-verloren{ background: #b5281c; color: #fff; }
.s-spam    { background: #6d4aa8; color: #fff; }

/* Status-Auswahl im Kontaktkopf */
.cust-status {
  margin-top: 6px; font-size: 11px; font-weight: 800; text-transform: uppercase;
  border-radius: var(--radius-pill); padding: 3px 10px; color: #fff; border: none;
  background: var(--accent);
}
.cust-status.s-neu { background: #5b6472; }
.cust-status.s-termin { background: #2f7cff; }
.cust-status.s-angebot { background: #d98a00; }
.cust-status.s-kunde { background: #1f9d55; }
.cust-status.s-verloren { background: #b5281c; }
.cust-status.s-spam { background: #6d4aa8; }

.archived-banner {
  background: color-mix(in srgb, var(--danger) 14%, var(--bg-panel));
  border: 1px solid var(--danger); border-radius: 12px; padding: 10px 12px;
  margin-bottom: 12px; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.dupe-banner {
  background: color-mix(in srgb, #d98a00 14%, var(--bg-panel));
  border: 1px solid #d98a00; border-radius: 12px; padding: 8px 12px;
  margin-bottom: 12px; font-size: 12.5px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

/* Zusammenführen-Dialog */
.merge-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.merge-opt {
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; cursor: pointer;
}
.merge-opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* System-Status */
.st-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 6px; }
.st-table th { text-align: left; color: var(--text-faint); font-weight: 700; padding: 4px 8px; }
.st-table td { padding: 5px 8px; border-top: 1px solid var(--border); vertical-align: top; }
.st-when { color: var(--text-faint); white-space: nowrap; }
.st-ok { color: #1f9d55; font-weight: 700; }
.st-bad { color: var(--danger); font-weight: 700; }
.st-muted { color: var(--text-faint); }
.st-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 12.5px; }
.st-grid > div { display: flex; flex-direction: column; }
.st-k { color: var(--text-faint); }
.st-v { font-weight: 600; }
.gdpr-log { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; }
.gdpr-log li { padding: 4px 0; border-top: 1px solid var(--border); }

/* Dubletten-Liste */
.dupe-group { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.dupe-group-h { font-weight: 700; font-size: 12.5px; margin-bottom: 6px; }
.dupe-row { padding: 3px 0; font-size: 12.5px; }
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
@media (max-width: 560px) { .st-grid { grid-template-columns: 1fr; } }

/* Ansprechpartner */
.persons-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.person-row {
  display: flex; gap: 8px; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 10px; background: var(--bg-panel-2);
}
.person-main { flex: 1; min-width: 0; }
.person-name { font-weight: 700; font-size: 13px; }
.person-primary {
  background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 800;
  padding: 1px 6px; border-radius: var(--radius-pill); text-transform: uppercase; margin-left: 4px;
}
.person-role { font-size: 11.5px; color: var(--text-faint); }
.person-contact { font-size: 12px; color: var(--text-soft); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.person-actions { display: flex; gap: 4px; align-items: flex-start; }
.muted-hint { color: var(--text-faint); font-size: 12.5px; margin: 4px 0 10px; }

/* Bearbeitungs-Lock-Banner */
.lock-banner {
  background: color-mix(in srgb, #d98a00 16%, var(--bg-panel));
  border: 1px solid #d98a00; border-radius: 10px; padding: 8px 10px;
  font-size: 12.5px; font-weight: 600; margin-bottom: 10px;
}

/* Feld-Historie im Aktivitäts-Feed */
.event-change {
  font-size: 12.5px; padding: 3px 0; border-bottom: 1px dashed var(--border);
}
.event-change:last-child { border-bottom: none; }

/* Home: Seitenleiste mit Reitern */
.home-view { grid-template-columns: 276px minmax(0, 1fr); }
.home-side {
  min-width: 0; display: flex; flex-direction: column;
  background: var(--bg-panel); border-right: 1px solid var(--border);
}
.home-side-head { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.home-side-tabs {
  display: flex; gap: 3px; margin-top: 8px; background: var(--bg-panel-2);
  border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 3px;
}
.hs-tab {
  flex: 1; border: none; background: transparent; padding: 6px 10px; font-weight: 700;
  font-size: 12.5px; color: var(--text-soft); border-radius: var(--radius-pill);
}
.hs-tab.active { background: var(--bg-panel); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.14); }
.home-side-body { flex: 1; min-height: 0; display: flex; }
.hs-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.hs-pane .chat-newbtn { margin: 10px 10px 4px; align-self: stretch; text-align: center; }
.home-online { border-left: none; padding: 8px; }

/* Zugänge (Chef) */
.access-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
}
.access-name { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.access-name-btn {
  border: 1px dashed transparent; background: none; color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer; padding: 2px 6px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
}
.access-name-btn:hover { border-color: var(--border); background: var(--bg-hover); }
.access-name-pen { font-size: 11px; opacity: .5; }
.access-name-edit {
  font: inherit; font-weight: 600; padding: 4px 8px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--bg-panel); color: var(--text); min-width: 140px;
}
.access-sub { font-size: 11.5px; color: var(--text-faint); }
.access-locked { font-size: 12px; color: var(--danger); font-weight: 600; margin-top: 2px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check-row input { width: auto; }

/* ===================== Einstellungen: linke Navi + Speichern-Fuß ===================== */
.modal.settings-modal { width: min(760px, 94vw); }
.settings-wrap { display: flex; min-height: 380px; max-height: 74vh; }
.settings-nav {
  flex: 0 0 190px; border-right: 1px solid var(--border); padding: 10px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; background: var(--bg-panel-2);
}
.settings-nav button {
  text-align: left; border: none; background: transparent; color: var(--text-soft);
  padding: 9px 12px; border-radius: 10px; font-weight: 600; font-size: 13px;
}
.settings-nav button:hover { background: var(--bg-hover); color: var(--text); }
.settings-nav button.active { background: var(--accent); color: #fff; }
.settings-nav-h {
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); margin: 12px 8px 4px;
}
.settings-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.settings-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.settings-body > div > label,
.settings-body > label:not(.toggle-row):not(.check-row) {
  display: block; font-size: 12px; color: var(--text-faint); margin-bottom: 4px;
}
.settings-body input[type=text], .settings-body input[type=email],
.settings-body input[type=password], .settings-body select, .settings-body textarea { width: 100%; }
.settings-h { margin: 0 0 4px; font-size: 15px; }
.settings-hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.settings-foot {
  border-top: 1px solid var(--border); padding: 12px 18px;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
}
.settings-saved { color: #1f9d55; font-weight: 700; font-size: 13px; }

/* Segmentierte Auswahl (Theme) */
.seg { display: flex; gap: 3px; background: var(--bg-panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 3px; }
.seg button { flex: 1; border: none; background: transparent; color: var(--text-soft);
  font-weight: 700; font-size: 12.5px; padding: 7px 10px; border-radius: var(--radius-pill); }
.seg button.active { background: var(--bg-panel); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.14); }

/* Textbausteine-Verwaltung */
.snip-row { display: flex; gap: 8px; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 10px; background: var(--bg-panel-2); margin-bottom: 6px; }
.snip-main { flex: 1; min-width: 0; }
.snip-title { font-weight: 700; font-size: 13px; }
.snip-body { font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snip-actions { display: flex; gap: 4px; }
.c-snippet { border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text);
  border-radius: 9px; font-size: 12px; padding: 4px 6px; height: 30px; }

/* Zugänge erweitert */
.access-row { flex-wrap: wrap; }
.access-info { flex: 1; min-width: 160px; }
.access-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.temp-pw {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 16px; font-weight: 700;
  background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; text-align: center; letter-spacing: 1px; user-select: all;
}
.ai-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mt-danger { color: var(--danger); border-color: var(--danger); }
a.btn-ghost { text-decoration: none; display: inline-block; text-align: center; }

/* Signatur im Mail-Entwurf */
.mail-sig { color: var(--text-soft); border-top: 1px solid var(--border); margin-top: 8px; padding-top: 6px; font-size: 13px; }

@media (max-width: 620px) {
  .settings-wrap { flex-direction: column; max-height: 80vh; }
  .settings-nav { flex-basis: auto; flex-direction: row; overflow-x: auto; border-right: none;
    border-bottom: 1px solid var(--border); }
  .settings-nav-h { display: none; }
}

/* Neuer-Kontakt-Assistent: Kurz-Fragebogen */
.nc-group { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--bg-panel-2); }
.nc-group + .nc-group { margin-top: 10px; }
.nc-group-h {
  font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 8px;
}
.nc-group > div { margin-bottom: 8px; }
.nc-group > div:last-child { margin-bottom: 0; }
.nc-group input, .nc-group textarea { width: 100%; }
#nc-step2 { max-height: 60vh; overflow-y: auto; }

/* ===================== Anhänge (Chat + Notizen) ===================== */
.chat-clip {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text);
  font-size: 16px; line-height: 1;
}
.chat-clip:hover { background: var(--bg-hover); }
.chat-attach-bar, .att-bar {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 0;
}
.att-bar { padding: 8px 0 0; }
.att-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  background: var(--bg-panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 4px 6px 4px 10px;
}
.att-chip button {
  border: none; background: transparent; color: var(--text-faint); cursor: pointer;
  font-size: 12px; padding: 0 2px;
}
.att-chip button:hover { color: var(--danger); }

.att-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-img {
  display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
  max-width: 220px; line-height: 0;
}
.att-img img { display: block; max-width: 100%; max-height: 220px; object-fit: cover; }
.att-file {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; color: var(--text); font-size: 13px; max-width: 260px;
}
.att-file:hover { background: var(--bg-hover); }
.att-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-size { color: var(--text-faint); font-size: 11px; flex-shrink: 0; }
.chat-msg.me .att-wrap { justify-content: flex-end; }

/* ===================== Runde 14: Benachrichtigungen, Fälligkeit, DnD, PDF ===================== */

/* Glocke + Panel */
.notif-wrap { position: relative; display: inline-flex; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-height: 72vh;
  overflow-y: auto; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); z-index: 70; padding: 6px;
}
.notif-panel[hidden] { display: none; }
.notif-empty { padding: 22px 12px; text-align: center; color: var(--text-faint); font-size: 13px; }
.notif-sec-title {
  font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint); padding: 10px 10px 4px;
}
.notif-item {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  border: none; background: none; color: var(--text); padding: 9px 10px; border-radius: 10px;
  cursor: pointer; font: inherit;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.notif-alert { background: color-mix(in srgb, #d98a00 12%, transparent); }
.notif-item.notif-alert:hover { background: color-mix(in srgb, #d98a00 20%, transparent); }
.notif-item .notif-item-main { border: none; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; padding: 0; }
.notif-mini-btn {
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--text);
  border-radius: var(--radius-pill); padding: 4px 12px; font-size: 12px; font-weight: 600;
  flex-shrink: 0; align-self: center; cursor: pointer;
}
.notif-mini-btn:hover { background: var(--bg-hover); }
.notif-item-main { min-width: 0; flex: 1; }
.notif-item-t { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-s { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.notif-pill { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; flex-shrink: 0; align-self: center; }
.notif-pill.overdue { background: color-mix(in srgb, #ef4444 20%, transparent); color: #ef4444; }
.notif-pill.today   { background: color-mix(in srgb, #f59e0b 24%, transparent); color: #d98a00; }
.notif-pill.soon    { background: var(--bg-hover); color: var(--text-faint); }
.notif-pill.appt-1d  { background: var(--bg-hover); color: var(--text-faint); }
.notif-pill.appt-2h  { background: color-mix(in srgb, #f59e0b 24%, transparent); color: #d98a00; }
.notif-pill.appt-15m { background: color-mix(in srgb, #ef4444 20%, transparent); color: #ef4444; }

/* Fälligkeitsdatum bei Aufgaben / Termin-Formulare mit zwei Feldern nebeneinander */
.due-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.due-row input[type="date"] { width: auto; }
.due-row .btn-inline { padding: 4px 10px; }
.due-row > div { flex: 1; }
.due-row > div input { width: 100%; }

/* Termin-Kalender */
.cal-nav-group { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 15px; }
.cal-nav-group button { font-size: 16px !important; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow {
  font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--text-faint);
  text-align: center; padding-bottom: 4px;
}
.cal-cell {
  position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 12px; background: var(--bg-panel-2);
  border: 0; color: inherit; font-family: inherit; cursor: pointer;
}
button.cal-cell:hover { background: color-mix(in srgb, var(--accent) 22%, var(--bg-panel-2)); }
.cal-cell.empty { background: none; cursor: default; }
.cal-cell.today { outline: 2px solid var(--accent); font-weight: 800; }
.cal-cell.has-appt { background: color-mix(in srgb, var(--accent) 16%, var(--bg-panel-2)); font-weight: 700; }
.cal-cell.selected { background: var(--accent); color: #fff; font-weight: 800; }
.cal-cell.selected .cal-dot { background: #fff; }
.cal-dot { position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.cal-list-head { font-size: 13px; font-weight: 800; margin: 0 0 6px; text-transform: capitalize; }
.task-due {
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-left: 8px;
  white-space: nowrap;
}
.task-due.overdue { background: color-mix(in srgb, #ef4444 18%, transparent); color: #ef4444; }
.task-due.today   { background: color-mix(in srgb, #f59e0b 20%, transparent); color: #d98a00; }
.task-due.soon    { background: var(--bg-hover); color: var(--text-faint); }
body.dark .task-due.today, body.dark .notif-pill.today { color: #f7b955; }

/* Drag & Drop Zone */
.dnd-over { outline: 2px dashed var(--accent); outline-offset: -6px; background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* Kontakt-Kopf: 3-Punkte-Menü */
#btn-contact-menu { font-size: 16px; line-height: 1; }
#btn-contact-menu.open { background: var(--bg-hover); }
.cust-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 210px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 5px;
}
.cust-menu[hidden] { display: none; }
.cust-menu-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  color: var(--text); font: inherit; font-size: 13px; padding: 9px 10px; border-radius: 8px; cursor: pointer;
}
.cust-menu-item:hover { background: var(--bg-hover); }
.cust-menu-item.danger { color: var(--danger); }
.cust-menu-item.danger.armed { background: var(--danger); color: #fff; font-weight: 700; }

/* Kunden-Schnellsuche (Typeahead unter der Topbar-Suche) */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 80;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 5px; max-height: 60vh; overflow-y: auto;
}
.search-results[hidden] { display: none; }
.sr-empty { padding: 14px 12px; color: var(--text-faint); font-size: 13px; }
.sr-item {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  border: none; background: none; color: var(--text); font: inherit;
  padding: 8px 9px; border-radius: 9px; cursor: pointer;
}
.sr-item:hover, .sr-item.active { background: var(--bg-hover); }
.sr-av { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; background: var(--bg-panel-2); }
.sr-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sr-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub { font-size: 11.5px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===================== Dokumente (Rechnung / Angebot / Vertrag) ===================== */
.doc-warn { color: var(--danger); font-weight: 600; }
.doc-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.doc-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px;
}
.doc-badge {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 999px; flex-shrink: 0; color: #fff;
}
.doc-rechnung   { background: #2563eb; }
.doc-angebot    { background: #0891b2; }
.doc-auftrag    { background: #7c3aed; }
.doc-vertrag    { background: #b45309; }
.doc-erstanalyse { background: #1f9d55; }
.doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-num { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { font-size: 11.5px; color: var(--text-faint); }
.doc-del.armed { background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 700; }

/* Formular */
.doc-modal { max-width: 720px; width: 94vw; }
.doc-modal .doc-form input[type="text"],
.doc-modal .doc-form input[type="email"],
.doc-modal .doc-form select { width: 100%; }
.doc-modal .doc-form textarea {
  width: 100%; display: block; min-height: 96px; resize: vertical; line-height: 1.55;
}
.doc-modal #an-empf, .doc-modal #an-ausgang { min-height: 112px; }
.doc-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.doc-grid2 > div { min-width: 0; }
.doc-grid2 > div > label { display: block; margin-bottom: 3px; }
.doc-sec-h {
  font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint); margin: 16px 0 6px; border-bottom: 1px solid var(--border); padding-bottom: 3px;
}
.doc-pos-row {
  display: grid; grid-template-columns: 1fr 64px 70px 100px 28px; gap: 6px; margin-bottom: 6px; align-items: center;
}
.doc-pos-row input { width: 100%; }
.doc-pos-row .p-rm {
  border: 1px solid var(--border); background: var(--bg-panel-2); color: var(--danger);
  border-radius: 8px; height: 30px; cursor: pointer; padding: 0;
}
.doc-total { text-align: right; font-weight: 700; margin: 6px 0 4px; }
.doc-clauses { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }

/* Erstanalyse – „Rechnet sich das?" */
.an-checks { display: flex; flex-direction: column; gap: 5px; margin: 4px 0 12px; }
.calc-box {
  background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 16px 14px; margin-bottom: 12px;
}
.calc-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.calc-row .rl {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 700;
}
.calc-row .rl b { color: var(--text); font-size: 14px; letter-spacing: 0; }
.calc-row input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px;
  background: var(--border); outline: none; cursor: pointer;
}
.calc-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 3px solid var(--bg-panel-2);
  box-shadow: 0 0 0 1px var(--accent);
}
.calc-row input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 3px solid var(--bg-panel-2);
}
.calc-assume {
  font-size: 12px; color: var(--text-faint); line-height: 1.45;
  margin: 2px 0 14px; padding-left: 12px; border-left: 2px solid var(--border);
}
.calc-out { border-top: 1px solid var(--border); padding-top: 14px; }
.calc-lead { font-size: 13px; color: var(--text); }
.calc-big { font-size: 28px; font-weight: 800; color: var(--accent-strong); letter-spacing: -.02em; margin: 3px 0; }
.calc-sub { font-size: 12px; color: var(--text-faint); }
.an-reco {
  align-self: end; font-size: 12.5px; color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.an-reco b { font-size: 14px; }
.an-reco-sub { color: var(--text-faint); font-size: 11.5px; }

@media (max-width: 620px) {
  .doc-grid2 { grid-template-columns: 1fr; }
  .doc-pos-row { grid-template-columns: 1fr 1fr; }
}

/* Liste der automatischen Sicherungen */
.backup-list { list-style: none; margin: 10px 0 0; padding: 0; }
.backup-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 2px; border-bottom: 1px solid var(--border); font-size: 12.5px;
}
.backup-list li:last-child { border-bottom: none; }
