/* ============================================================
   Plank CRM — design prototype
   Aesthetic: dark, dense "observability tool" look.
   Mock data only. Not wired to Radix.
   ============================================================ */

/* ---- Theme tokens ---- */
body.dark {
  --bg:        #0a0b0e;
  --surface:   #141519;
  --surface2:  #0f1013;
  --surface3:  #1b1d23;
  --rail:      #0c0d10;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.04);
  --text:      #e7e8ea;
  --text2:     #9498a1;
  --text3:     #5b5e66;
  --accent:    #6366f1;
  --accent2:   #818cf8;
  --accent-rgb: 99,102,241;
  --ok:        #22c55e;
  --warn:      #f59e0b;
  --danger:    #ef4444;
  --info:      #3b82f6;
  --shadow:    0 8px 32px rgba(0,0,0,.45);
}
body.light {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --surface3:  #f1f3f5;
  --rail:      #ffffff;
  --border:    #e4e7ec;
  --border2:   #eef1f4;
  --text:      #16191d;
  --text2:     #5b6675;
  --text3:     #98a1ad;
  --accent:    #4f46e5;
  --accent2:   #6366f1;
  --accent-rgb: 79,70,229;
  --ok:        #16a34a;
  --warn:      #d97706;
  --danger:    #dc2626;
  --info:      #2563eb;
  --shadow:    0 8px 32px rgba(15,23,42,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
/* Links global ohne Unterstrich (Hover-Unterstreichungen einzelner Komponenten bleiben). */
a { text-decoration: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
/* Global: KEINE Monospace-Schrift mehr — alles in der System-UI-Schrift (Wunsch Martin
   2026-06-07). `.mono` bleibt als Klasse erhalten (vielfach im Markup), erbt aber nur noch
   die Basisschrift; tabular-nums hält Zahlenspalten weiterhin sauber ausgerichtet. */
.mono { font-family: inherit; font-variant-numeric: tabular-nums; }

/* ---- App grid ---- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  transition: grid-template-columns .18s ease;
}
.app.rail { grid-template-columns: 60px 1fr; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  background: var(--rail);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  height: 56px;
  border-bottom: 1px solid var(--border2);
}
.sb-logo {
  width: 28px; height: 28px; flex: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 2px 10px rgba(var(--accent-rgb),.4);
}
.sb-name { font-weight: 700; font-size: 15px; letter-spacing: -.2px; white-space: nowrap; }
.sb-name small { display:block; font-size: 10px; font-weight: 600; color: var(--text3); letter-spacing: .08em; text-transform: uppercase; }
.app.rail .sb-name, .app.rail .sb-group-label, .app.rail .nav-label, .app.rail .uc-meta, .app.rail .sb-foot-actions { display: none; }

.sb-scroll { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sb-group { margin-bottom: 14px; }
.sb-group-label { font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text3); padding: 4px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text2);
  cursor: pointer;
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface3); color: var(--text); }
.nav-item.active {
  background: rgba(var(--accent-rgb),.13);
  color: var(--accent2);
  border-color: rgba(var(--accent-rgb),.22);
}
.nav-item.active .nav-ico { color: var(--accent2); }
.nav-ico { width: 18px; height: 18px; flex: none; color: var(--text3); }
/* Ungelesen-Zähler am Sidebar-Eintrag (farbiger Badge). */
.nav-badge { margin-left: auto; flex: none; min-width: 19px; height: 18px; padding: 0 6px;
  border-radius: 9px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums; }
.nav-item.active .nav-badge { background: var(--accent2); }
/* eingeklappter Rail-Modus: kleiner Punkt statt Zahl */
.app.rail .nav-badge { position: absolute; top: 4px; right: 4px; min-width: 8px; height: 8px; padding: 0; border-radius: 50%; font-size: 0; }
.app.rail .nav-item { justify-content: center; padding: 9px 0; position: relative; }
.app.rail .sb-group-label { text-align: center; font-size: 0; padding: 4px 0; }

.sb-foot { border-top: 1px solid var(--border2); padding: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 10px; cursor: pointer;
  transition: background .12s;
}
.user-chip:hover { background: var(--surface3); }
.uc-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 11px;
}
.uc-meta { min-width: 0; }
.uc-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-mail { font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-foot-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ============================================================
   Top bar
   ============================================================ */
.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 56px; flex: none;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.icon-btn {
  width: 32px; height: 32px; flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.icon-btn:hover { background: var(--surface3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text3); }
.crumbs a { color: var(--text2); text-decoration: none; }
.crumbs a:hover { color: var(--accent2); }
.crumbs .sep { opacity: .4; }
.crumbs .cur { color: var(--text); font-weight: 600; }

.search {
  margin-left: 8px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 7px 12px;
  width: 320px; max-width: 34vw;
  color: var(--text3);
}
.search input { background: none; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; font-family: inherit; }
.search svg { width: 15px; height: 15px; flex: none; }
.search kbd {
  font-size: 10px; color: var(--text3); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; background: var(--surface2);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 9px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  transition: all .12s;
}
.btn:hover { background: var(--surface3); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---- page tabs + range ---- */
.subbar {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--text2);
  cursor: pointer; border: 1px solid transparent;
}
.tab svg { width: 14px; height: 14px; }
.tab:hover { color: var(--text); background: var(--surface); }
.tab.active { background: var(--surface3); color: var(--text); border-color: var(--border); }
.range {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--text2); cursor: pointer;
}
.range svg { width: 14px; height: 14px; }

/* ============================================================
   Content
   ============================================================ */
.content { flex: 1; overflow-y: auto; padding: 22px 24px 60px; }
.view { display: none; }
.view.active { display: block; }
.maxw { max-width: 1480px; margin: 0 auto; }

.page-head { margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.page-sub { font-size: 13.5px; color: var(--text2); margin-top: 3px; }

/* ---- KPI cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 15px 16px 14px;
}
.kpi-top { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.kpi-ico { width: 16px; height: 16px; color: var(--text3); }
.kpi-label { font-size: 12.5px; color: var(--text2); font-weight: 500; }
.kpi-dots { margin-left: auto; color: var(--text3); cursor: pointer; font-size: 16px; line-height: 0; }
.kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.kpi-num { font-size: 30px; font-weight: 600; letter-spacing: -1px; line-height: 1; }
.kpi-num .pre { font-size: 17px; color: var(--text2); font-weight: 500; margin-right: 1px; }
.kpi-num .suf { font-size: 15px; color: var(--text2); font-weight: 500; margin-left: 2px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 38px; }
.spark span { width: 6px; border-radius: 2px; opacity: .9; }
.kpi-foot { margin-top: 13px; font-size: 11.5px; color: var(--text3); display: flex; align-items: center; gap: 6px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.delta svg { width: 11px; height: 11px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }

/* gradients for sparklines */
.g-blue   span { background: linear-gradient(180deg, #60a5fa, #3b82f6); }
.g-violet span { background: linear-gradient(180deg, #a78bfa, #7c3aed); }
.g-amber  span { background: linear-gradient(180deg, #fbbf24, #f97316); }
.g-emerald span{ background: linear-gradient(180deg, #34d399, #10b981); }

/* ---- generic card ---- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols-2-1 { grid-template-columns: 1.55fr 1fr; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 16px; border-bottom: 1px solid var(--border2);
}
.card-head .ch-ico { width: 16px; height: 16px; color: var(--text3); }
.card-title { font-size: 13.5px; font-weight: 650; font-weight: 600; }
.card-head .ch-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px; }
.muted { color: var(--text2); }
.tiny { font-size: 11px; color: var(--text3); }

/* ---- node / pipeline diagram ---- */
.nodewrap { padding: 22px 16px; }
.node-row { display: flex; justify-content: center; gap: 26px; position: relative; }
.node-row + .node-row { margin-top: 30px; }
.node {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; width: 210px;
}
.node-h { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.node-h .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.node-name { font-size: 12.5px; font-weight: 600; }
.node-badge { margin-left: auto; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; display: inline-flex; align-items: center; gap: 4px; }
.node-badge.ok { background: rgba(34,197,94,.14); color: var(--ok); }
.node-badge.warn { background: rgba(245,158,11,.14); color: var(--warn); }
.node-stat { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text2); padding: 2px 0; }
.node-stat b { color: var(--text); font-weight: 600; }
.node-connector { height: 26px; border-left: 1.5px solid var(--border); margin: 0 auto; width: 0; }

/* ---- config rows (detail panel) ---- */
.cfg-section { padding: 6px 0 2px; }
.cfg-section + .cfg-section { border-top: 1px solid var(--border2); margin-top: 6px; padding-top: 12px; }
.cfg-h { font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--text3); text-transform: uppercase; margin-bottom: 9px; }
.cfg-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; font-size: 13px; }
.cfg-row .k { color: var(--text2); display: flex; align-items: center; gap: 8px; }
.cfg-row .k svg { width: 14px; height: 14px; color: var(--text3); }
.cfg-row .v { font-weight: 600; }
.chip-val { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--surface3); border: 1px solid var(--border); color: var(--text); }

/* ---- pills ---- */
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.pill.red    { background: rgba(239,68,68,.14);  color: var(--danger); }
.pill.amber  { background: rgba(245,158,11,.14); color: var(--warn); }
.pill.blue   { background: rgba(59,130,246,.14); color: var(--info); }
.pill.green  { background: rgba(34,197,94,.14);  color: var(--ok); }
.pill.violet { background: rgba(139,92,246,.16); color: #a78bfa; }
.pill.gray   { background: var(--surface3); color: var(--text2); }
.pill .pdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface3); border: 1px solid var(--border); color: var(--text2); }

/* ---- tables ---- */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text3);
  padding: 10px 16px; border-bottom: 1px solid var(--border2);
  white-space: nowrap;
}
.tbl tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border2); font-size: 13px; vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 11.5px; color: var(--text3); }

/* Verkaufschancen-Kanban-Karten: Hover, 2-zeilige Text-Preview, Betreuer-Avatar. */
.lead-card { transition: border-color .12s, background .12s; }
.lead-card:hover { border-color: rgba(var(--accent-rgb),.4); background: var(--surface3); }
.list-prev { margin-top: 3px; font-size: 12px; color: var(--text2); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Anfragen-Liste im Outlook-Stil: Avatar + gestapelt (Absender/Zeit · Betreff · Vorschau).
   Flex-Zeilen statt Tabelle (Tabellenzellen + -webkit-line-clamp kollabieren in Chrome);
   ganze Zeile ist ein <a> → nativ klickbar. */
.inbox-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 16px;
  border-bottom: 1px solid var(--border2); text-decoration: none; color: var(--text);
  cursor: pointer; position: relative; transition: background .1s; }
.inbox-row:last-child { border-bottom: none; }
.inbox-row:hover { background: var(--surface2); }
.inbox-row::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent); opacity: 0; transition: opacity .1s; }
.inbox-row.is-unread::before { opacity: 1; }   /* ungelesen → blauer Akzentbalken links */
.inbox-avatar { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; }
.inbox-body  { flex: 1 1 auto; min-width: 0; }
.inbox-line1 { display: flex; align-items: baseline; gap: 10px; }
.inbox-from  { font-size: 13px; font-weight: 500; color: var(--text2); min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-time  { margin-left: auto; flex: 0 0 auto; font-size: 11.5px; color: var(--text3);
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.inbox-subj  { font-size: 12.5px; font-weight: 400; color: var(--text2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-prev  { font-size: 12px; color: var(--text3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* UNGELESEN (Outlook-Stil): Absender + Betreff fett & kräftiger, Zeit blau. */
.inbox-row.is-unread .inbox-from { font-weight: 700; color: var(--text); }
.inbox-row.is-unread .inbox-subj { font-weight: 600; color: var(--text); }
.inbox-row.is-unread .inbox-time { color: var(--accent2); font-weight: 600; }

/* Fixierte Aktionsleiste — IMMER bündig am unteren Viewport-Rand (auch bei kurzem Inhalt).
   Offset um die Sidebar-Breite (240/60/0 px), 900px zentriert = deckungsgleich mit den Karten.
   `position: fixed` ist viewport-relativ → kein Padding-/Höhen-Problem. */
.actions-sticky { position: fixed; left: 240px; right: 0; bottom: 0; z-index: 30;
  max-width: 1140px; margin: 0 auto;
  border-radius: 13px 13px 0 0; box-shadow: 0 -12px 28px -12px rgba(0,0,0,.6); }
.app.rail .actions-sticky { left: 60px; }
@media (max-width: 720px) { .actions-sticky { left: 0; } }

/* Posteingang-Detail im Outlook-Stil: Lesebereich (E-Mail-Konversation) + schmale
   rechte Spalte (Kontaktdaten/Notiz/Anhänge/Verlauf, gedämpft). */
.inbox2 { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.inbox2-main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.inbox2-rail { display: flex; flex-direction: column; gap: 12px; }
.inbox2-rail .card-title { font-size: 12px; }
.inbox2-rail .card-head { padding-top: 10px; padding-bottom: 10px; }
@media (max-width: 900px) { .inbox2 { grid-template-columns: 1fr; } }
/* Inline gerenderte E-Mail (auto-Höhe via JS); kein innerer Scroll bei normaler Länge. */
.mail-inline { width: 100%; min-height: 220px; border: 0; border-radius: 8px; background: #fff; display: block; }
/* kleine Empfänger-Zeile unter dem Kopf einer gesendeten Antwort */
.msg-sub { font-size: 11px; color: var(--text3); margin-bottom: 5px; }
.msg-avatar { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 50%; font-size: 10px; font-weight: 700; color: #fff; flex: none; }
.lead-ini { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--surface3); border: 1px solid var(--border); font-size: 9px;
  font-weight: 700; color: var(--text2); }

/* Produkt-Thumbnail in den Angebots-Positionen (Bild aus dem Artikel-Grafik-Slot). */
.pos-thumb { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 8px; object-fit: contain; background: var(--surface3); border: 1px solid var(--border); display: inline-block; }
.pos-thumb--empty {
  background: var(--surface3) center / 22px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239498a1' stroke-width='1.7'%3E%3Cpath d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/%3E%3Cpolyline points='3.27 6.96 12 12.01 20.73 6.96'/%3E%3Cline x1='12' y1='22.08' x2='12' y2='12'/%3E%3C/svg%3E");
}

.who { display: flex; align-items: center; gap: 10px; }
.who .av { width: 28px; height: 28px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button { border: none; background: none; color: var(--text2); font-family: inherit; font-size: 12.5px; font-weight: 500; padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface3); color: var(--text); }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text2); padding: 6px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.filter-chip svg { width: 13px; height: 13px; }

/* ---- customer detail ---- */
.detail-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.detail-av { width: 54px; height: 54px; border-radius: 13px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 700; color: #fff; background: linear-gradient(135deg,#6366f1,#8b5cf6); }
.detail-meta h1 { font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.detail-meta .row { display: flex; align-items: center; gap: 10px; margin-top: 5px; flex-wrap: wrap; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; }
.detail-cols { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }

/* notes / activity timeline */
.note-add { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border2); }
.note-add textarea { flex: 1; resize: none; background: var(--surface2); border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 9px 11px; font-family: inherit; font-size: 13px; min-height: 38px; outline: none; }
.note-add textarea:focus { border-color: var(--accent); }
.timeline { padding: 6px 16px 14px; }
.tl-item { display: flex; gap: 12px; padding: 12px 0; position: relative; }
.tl-item::before { content:''; position: absolute; left: 13px; top: 30px; bottom: -12px; width: 1.5px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-ico { width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--surface3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text2); z-index: 1; }
.tl-ico svg { width: 14px; height: 14px; }
.tl-body { flex: 1; min-width: 0; }
.tl-top { display: flex; align-items: center; gap: 8px; }
.tl-actor { font-size: 13px; font-weight: 600; }
.tl-time { font-size: 11.5px; color: var(--text3); margin-left: auto; }
.tl-text { font-size: 13px; color: var(--text2); margin-top: 3px; }
.tl-note { background: var(--surface2); border: 1px solid var(--border2); border-radius: 9px; padding: 9px 11px; margin-top: 6px; color: var(--text); }

/* ---- funnel / kanban ---- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 280px; gap: 14px; overflow-x: auto; padding-bottom: 14px; }
.col { background: var(--surface2); border: 1px solid var(--border); border-radius: 13px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 13px 14px; border-bottom: 1px solid var(--border2); }
.col-h .cdot { width: 9px; height: 9px; border-radius: 50%; }
.col-h .ct { font-size: 13px; font-weight: 600; }
.col-h .cc { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text2); background: var(--surface3); border-radius: 20px; padding: 2px 8px; }
.col-sum { font-size: 11.5px; color: var(--text3); padding: 8px 14px 4px; }
.col-cards { padding: 8px 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.deal { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 12px; cursor: grab; transition: border-color .12s, transform .06s; }
.deal:hover { border-color: rgba(var(--accent-rgb),.4); }
.deal-cust { font-size: 11.5px; color: var(--text3); margin-bottom: 3px; }
.deal-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.deal-val { font-size: 15px; font-weight: 700; margin: 9px 0 10px; letter-spacing: -.3px; }
.deal-foot { display: flex; align-items: center; gap: 8px; }
.deal-foot .av { width: 22px; height: 22px; border-radius: 6px; font-size: 9px; }
.prob { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text2); }
.prob-bar { height: 4px; border-radius: 3px; background: var(--surface3); margin-top: 9px; overflow: hidden; }
.prob-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); background-clip: padding-box; }

/* mobile */
.scrim { display: none; }
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .cols, .cols-2-1 { grid-template-columns: 1fr; }
  .detail-cols { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  /* Sidebar wird fixed (Off-Canvas) → ist KEIN Grid-Item mehr. Darum NUR eine Spalte für
     .main; sonst landet .main in der ersten (0px-)Spalte und der Inhalt kollabiert auf 0 Breite
     (= leerer Bildschirm im Hochformat). */
  /* iOS-Safari-robust: KEIN 100vh-Grid mit innerem Scroll (iOS gibt .content dann oft 0 Höhe
     → weißer/leerer Screen). Stattdessen natürlicher Dokumentfluss, der Body scrollt. */
  .app { display: block; height: auto; min-height: 100vh; }
  .main { overflow: visible; }
  .content { overflow: visible; flex: none; }
  .topbar { position: sticky; top: 0; z-index: 20; }
  .app .sidebar { position: fixed; z-index: 200; width: 240px; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  .app.drawer .sidebar { transform: translateX(0); }
  .app.drawer .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 150; }
  .search { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
}

/* ============================================================
   Dashboard KPI sizing (revenue redesign) · privacy blur · PIN modal
   ============================================================ */

/* primary (large) revenue cards — 2-up */
.kpi-grid-primary { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.kpi.lg { padding: 20px 22px 18px; }
.kpi.lg .kpi-num { font-size: 44px; }
.kpi.lg .kpi-num .pre { font-size: 22px; }
.kpi.lg .kpi-num .suf { font-size: 20px; }
.kpi.lg .spark { height: 56px; gap: 4px; }
.kpi.lg .spark span { width: 8px; }
.kpi.sm .kpi-num { font-size: 24px; }
.kpi.sm .spark { height: 30px; }
@media (max-width: 980px) { .kpi-grid-primary { grid-template-columns: 1fr; } }

/* privacy blur — shoulder-surfing veil, client-side only (NOT security) */
body.is-private .sensitive {
  filter: blur(6px);                      /* soft blur (as before) … */
  user-select: none; -webkit-user-select: none;
  pointer-events: none;                   /* … with decoy digits underneath (see app.js) */
  transition: filter .12s ease;
}
.icon-btn.is-locked { color: var(--accent2); border-color: rgba(var(--accent-rgb),.45); background: rgba(var(--accent-rgb),.13); }

/* PIN unlock modal (first modal in the app) */
.modal {
  display: none; position: fixed; inset: 0; z-index: 300; padding: 20px;
  background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
  align-items: center; justify-content: center;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  box-shadow: var(--shadow); width: 320px; max-width: 92vw; padding: 20px;
}
.modal-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.modal-card p { font-size: 12.5px; color: var(--text2); margin-bottom: 14px; }
.pin-row { display: flex; gap: 10px; }
.pin-input {
  flex: 1; text-align: center; letter-spacing: 12px; font-size: 22px;
  font-family: inherit; font-variant-numeric: tabular-nums;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); padding: 10px 12px; outline: none;
}
.pin-input:focus { border-color: var(--accent); }
.pin-input.bad { border-color: var(--danger); animation: shake .3s; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* dashboard section labels (Auftragseingang / Umsatz …) */
.sec-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); margin: 0 2px 12px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sec-title .sec-note { font-size: 11.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text3); }

/* edit forms (Stammdaten bearbeiten · neuer Ansprechpartner) */
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld.full { grid-column: 1 / -1; }
.fld label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text3); }
.fld input, .fld textarea, .fld select, .inp {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 10px; font-family: inherit; font-size: 13px; outline: none;
}
.fld input:focus, .fld textarea:focus, .fld select:focus, .inp:focus { border-color: var(--accent); }
@media (max-width: 980px) { .edit-grid { grid-template-columns: 1fr; } }

/* ---- Lead detail: mail-client layout (Schritt 2.4) ---- */
.lead-cols { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 980px) { .lead-cols { grid-template-columns: 1fr; } }

.term-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.term { flex: 1 1 120px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.term-k { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); }
.term-v { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); margin-top: 2px; }
.term-v.is-due { color: var(--danger); }

.thread { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; }
.msg { max-width: 88%; border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; }
.msg-in { align-self: flex-start; background: var(--surface2); border-top-left-radius: 4px; }
.msg-out { align-self: flex-end; background: rgba(var(--accent-rgb), .10); border-color: rgba(var(--accent-rgb), .30); border-top-right-radius: 4px; }
.msg-note { align-self: stretch; max-width: 100%; background: rgba(245, 158, 11, .08); border-color: rgba(245, 158, 11, .28); }
.msg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.msg-from { font-size: 12px; font-weight: 600; color: var(--text); }
.msg-time { font-size: 11px; color: var(--text3); margin-left: auto; white-space: nowrap; }
.msg-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

.sys-line { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text3); padding: 2px 2px; }
.sys-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text3); flex: none; }
.sys-time { margin-left: auto; white-space: nowrap; }

.composer { border-top: 1px solid var(--border); padding: 14px 16px; background: var(--surface2); border-radius: 0 0 13px 13px; }
.comp-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.comp-row label { width: 64px; flex: none; font-size: 11.5px; color: var(--text2); }
.comp-row .inp { flex: 1; }
.composer textarea { width: 100%; resize: vertical; }

/* Full inbound HTML email, isolated in a sandboxed iframe (Phase A.0) */
.msg-html { width: 100%; height: 460px; border: 1px solid var(--border); border-radius: 8px; background: #fff; resize: vertical; display: block; }

/* Full-width inbound email (table-heavy web-form mails need the whole column) */
.msg-full { max-width: 100% !important; align-self: stretch !important; }
.msg-open { margin-left: 8px; font-size: 11px; color: var(--accent2); text-decoration: none; white-space: nowrap; }
.msg-open:hover { text-decoration: underline; }

/* Mail popup (full inbound email, bounded + internally scrollable) */
.modal-card.lg { width: 92vw; max-width: 1100px; height: 85vh; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.mail-modal-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.mail-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.msg-preview { max-height: 120px; overflow: hidden; }
.msg-open-btn { margin-top: 8px; }

/* Generic content modal (Interessent-Formular, Kunde-Info, Logs, gesendete Mail) */
.modal-card.md { width: 600px; max-width: 94vw; max-height: 88vh; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.modal-head .modal-x { margin-left: auto; }
.modal-body { padding: 16px; overflow: auto; }
.modal-body .fld label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 4px; }
.modal-body .inp { width: 100%; }
.modal-body pre { white-space: pre-wrap; word-break: break-word; font: 13px/1.55 -apple-system, 'Segoe UI', sans-serif; margin: 0; }
.modal-body .cfg-row { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border2); }
.modal-body .cfg-row .k { color: var(--text2); min-width: 130px; font-size: 12.5px; }
.modal-body .cfg-row .v { font-size: 12.5px; }
.log-line { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border2); font-size: 12.5px; }
.log-line .log-time { margin-left: auto; color: var(--text3); font-size: 11px; white-space: nowrap; }

/* Full-width project checklist grid (Phase A.1) */
.cl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.cl-grid .cl-wide { grid-column: 1 / -1; }

/* Globaler, dezenter Status-Toast (löst die alten Inline-Flash-Karten ab) */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(10px);
  z-index: 9999; max-width: 440px;
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: 10px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--ok);
  font-size: 13px; line-height: 1.4;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .34);
  opacity: 0; pointer-events: none;
  transition: opacity .26s ease, transform .26s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; cursor: default; }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity .12s linear; transform: translateX(-50%); } }
@media (max-width: 480px) { .toast { left: 12px; right: 12px; bottom: 14px; max-width: none; transform: translateY(10px); } .toast.show { transform: translateY(0); } }

/* ============================================================
   R1 — Mobile-Fundament: Touch-Targets · 480px-Tier · Header-Stack
   (Track B, Phase R1 — wirkt seitenübergreifend)
   ============================================================ */

/* Touch-Geräte: interaktive Elemente auf ≥44px Tap-Fläche bringen.
   Über `pointer: coarse` statt Breakpoint → Desktop-Maus bleibt kompakt. */
@media (pointer: coarse) {
  .btn            { min-height: 44px; }
  .btn-sm         { min-height: 40px; }
  .icon-btn       { width: 44px; height: 44px; }
  .icon-btn svg   { width: 18px; height: 18px; }
  .nav-item       { min-height: 44px; }
  .user-chip      { min-height: 44px; }
  .filter-chip, .tab { min-height: 40px; }
  .fld input, .fld textarea, .fld select, .inp, select, .search input { min-height: 44px; }
  .pin-input      { min-height: 52px; }
  .seg button     { min-height: 36px; }
  .tbl thead th, .tbl tbody td { padding-top: 14px; padding-bottom: 14px; }

  /* iOS-Safari-Kernfix: Das 100vh-Gerüst mit innerem Scroll lässt iOS den Inhalt auf 0 Höhe
     kollabieren → weißer Screen (bei JEDER Breite, auch im „Desktop-Website"-Modus, denn das
     bleibt ein Touch-Gerät). Auf Touch daher durchgehend natürlicher Dokumentfluss. */
  .app     { display: block; height: auto; min-height: 100vh; }
  .main    { overflow: visible; height: auto; }
  .content { overflow: visible; height: auto; flex: none; }
  .topbar  { position: sticky; top: 0; z-index: 20; }
}

/* Kleinstes Tier (Smartphone-Hochformat) */
@media (max-width: 480px) {
  /* zusätzliche Sichtbarkeits-Utility (ergänzt .hide-sm aus dem 720er-Tier) */
  .hide-xs { display: none !important; }

  /* Inhalt enger ans Display, kein horizontaler Body-Overflow */
  .content { padding: 14px 12px 56px; }
  .maxw    { max-width: 100%; }
  .page-title { font-size: 19px; }

  /* Seiten-/Detail-Header vertikal stapeln, Aktionen umbrechen lassen */
  .detail-head    { flex-direction: column; align-items: stretch; gap: 12px; }
  .detail-actions { flex-wrap: wrap; }

  /* k/v-Zeilen stapeln, damit lange Werte (Adressen/E-Mails) nicht zerquetschen */
  .cfg-row { flex-direction: column; align-items: flex-start; gap: 2px; }

  /* Topbar entzerren: weniger Padding, dekorativen „Radix live"-Tag weglassen */
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar .topbar-right { display: none; }
}

/* ============================================================
   R2 — Tabellen mobil: horizontaler Scroll als Sicherheitsnetz
   Gilt für ALLE .tbl (auch nicht einzeln angefasste) → kein Layout-Bruch.
   display:block macht die Tabelle zum Scroll-Container; die Zeilen behalten
   ihr Layout über anonyme Tabellen-Boxen. nowrap erzwingt sauberen H-Scroll.
   ============================================================ */
@media (max-width: 720px) {
  table.tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.tbl thead th, table.tbl tbody td { white-space: nowrap; }
  /* dezenter Hinweis-Schatten am rechten Rand, dass weiter scrollbar ist */
  table.tbl { background:
    linear-gradient(90deg, transparent 70%, rgba(0,0,0,.05)) right / 24px 100% no-repeat; }
}

/* ============================================================
   R3 — Grids mobil stapeln
   `.stack-sm` ergänzt INLINE `grid-template-columns` (überschreibt es per !important
   nur am Phone) — so müssen die Inline-Styles in den Views nicht ersetzt werden.
   `.grid-2`/`.grid-3` sind die wiederverwendbaren Klassen für neues Markup.
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stack-sm { grid-template-columns: 1fr !important; }
}

/* ============================================================
   R4 — Komplexe Module: Kanban-Spalten + Modals mobil
   ============================================================ */
/* Kanban: Spalten ~Display-breit → eine Spalte sichtbar, seitlich durchwischen */
@media (max-width: 640px) {
  .board { grid-auto-columns: 84vw; }
  .col { max-height: none; }
}
/* Große/mittlere Modals (Mail-Popup, Artikel-Suche, Formulare) am Phone (fast) vollflächig */
@media (max-width: 480px) {
  .modal { padding: 0; }
  .modal-card.lg, .modal-card.md {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    border-radius: 0; border-left: 0; border-right: 0;
  }
  /* eingebettete HTML-Mail nicht über den Bildschirm hinaus */
  .msg-html { height: 60vh; }
}
