@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  /* Legacy tokens — now aliased to the new ix-* palette so all old views
     (Settings, Reports, KB, Contacts, etc.) automatically pick up the
     refreshed look without touching their individual CSS rules. */
  --accent: #ed0099;
  --accent-hover: #b8007a;
  --accent-light: rgba(237, 0, 153, 0.08);
  --accent-glow: rgba(237, 0, 153, 0.25);
  --bg: #fcfbf9;
  --sidebar-bg: #ffffff;
  --sidebar-text: #525252;
  --sidebar-active: #0a0a0a;
  --border: rgba(0, 0, 0, 0.06);
  --border-light: rgba(0, 0, 0, 0.06);
  --text: #0a0a0a;
  --text-secondary: #525252;
  --text-muted: #737373;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
  --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #ea8a0f;
  --radius: 12px;
  --radius-lg: 16px;

  /* ═══ New Intercom-inspired design tokens (Phase 1) ═══
     Used by the redesigned inbox/conversation/panel. Coexist with
     legacy tokens so migration can happen view-by-view. */
  --ix-ink:        #0a0a0a;
  --ix-ink-2:      #1f1f1f;
  --ix-ink-3:      #525252;
  --ix-ink-4:      #737373;
  --ix-ink-5:      #a3a3a3;
  --ix-white:      #ffffff;
  --ix-ivory:      #fcfbf9;             /* conversation background */
  --ix-nav-bg:     #ffffff;
  --ix-nav-hover:  #f4f4f5;
  --ix-nav-active: #eeedee;
  --ix-line:       rgba(0, 0, 0, 0.06);
  --ix-line-2:     rgba(0, 0, 0, 0.1);
  --ix-brand:      #ed0099;
  --ix-brand-ink:  #b8007a;
  --ix-brand-veil: rgba(237, 0, 153, 0.08);
  --ix-agent-bubble: #fcf5f9;
  --ix-ease:       cubic-bezier(0.22, 0.61, 0.36, 1);
}

body {
  font-family: 'General Sans', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  letter-spacing: -0.003em;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: 200px 290px 1fr;
  height: 100dvh;
}

/* Collapsed nav — Intercom-style icon-only rail (default state) */
.app.nav-collapsed { grid-template-columns: 60px 300px 1fr; }
.app.nav-collapsed .settings-view,
.app.nav-collapsed .stats-view,
.app.nav-collapsed .kb-view,
.app.nav-collapsed .contacts-view,
.app.nav-collapsed .features-view,
.app.nav-collapsed .surveys-view,
.app.nav-collapsed .news-view { grid-column: 2 / -1; }
.app.nav-collapsed .nav-title,
.app.nav-collapsed .nav-item span,
.app.nav-collapsed .avail-label,
.app.nav-collapsed .nav-footer-text,
.app.nav-collapsed .nav-agent-info { display: none; }
.app.nav-collapsed .nav { background: var(--ix-nav-bg); border-right: 1px solid var(--ix-line); }
.app.nav-collapsed .nav-header {
  justify-content: center;
  padding: 14px 0 8px;
}
.app.nav-collapsed .nav-collapse-btn { display: none; }
.app.nav-collapsed .nav-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  display: grid; place-items: center;
}
.app.nav-collapsed .nav-section {
  padding: 4px 0;
  align-items: center;
  gap: 2px;
}
.app.nav-collapsed .nav-item {
  justify-content: center;
  padding: 0;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  color: var(--ix-ink-3);
  background: transparent;
  position: relative;
  transition: all 0.12s var(--ix-ease);
}
.app.nav-collapsed .nav-item:hover {
  background: var(--ix-nav-hover);
  color: var(--ix-ink);
}
.app.nav-collapsed .nav-item.active {
  background: var(--ix-nav-active);
  color: var(--ix-ink);
}
.app.nav-collapsed .nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--ix-brand);
  border-radius: 0 2px 2px 0;
}
.app.nav-collapsed .nav-item svg {
  width: 17px; height: 17px;
  stroke-width: 1.75;
}
.app.nav-collapsed .nav-item .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  margin: 0;
  min-width: 16px;
  height: 16px;
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ix-brand);
  color: white;
  display: grid;
  place-items: center;
  border: 2px solid var(--ix-nav-bg);
}
.app.nav-collapsed .nav-footer { padding: 8px 0 10px; align-items: center; gap: 4px; }
.app.nav-collapsed .nav-footer-item {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  transition: background 0.12s var(--ix-ease);
}
.app.nav-collapsed .nav-footer-item:hover { background: var(--ix-nav-hover); }
.app.nav-collapsed .nav-footer-icon {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  position: relative;
  color: var(--ix-ink-3);
}
.app.nav-collapsed .nav-footer-icon svg { width: 17px; height: 17px; }
.app.nav-collapsed .nav-footer-icon .status-dot {
  position: absolute;
  right: -2px; bottom: -2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 2px solid var(--ix-nav-bg);
}
.app.nav-collapsed .nav-footer-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 14px;
  height: 14px;
  font-size: 9px;
  font-weight: 600;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--ix-brand);
  color: white;
  display: grid;
  place-items: center;
  border: 2px solid var(--ix-nav-bg);
}
.app.nav-collapsed .nav-availability { padding: 0; }
.app.nav-collapsed .nav-agent {
  justify-content: center;
  padding: 4px 0 0;
  border-top: 1px solid var(--ix-line);
  width: 100%;
}
.app.nav-collapsed .nav-agent-avatar {
  width: 30px; height: 30px;
  font-size: 11px;
}

/* nav-expand-btn was removed: in collapsed mode the logo is now the expand
 * trigger (handleLogoClick → toggleNavCollapse), so no second button is
 * needed and the 32px logo fits cleanly into the 64px collapsed sidebar. */

/* ===== CMD+K SEARCH ===== */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 3000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: cmdk-fade 0.15s ease;
}

@keyframes cmdk-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cmdk-dialog {
  width: 560px;
  max-width: 90vw;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  overflow: hidden;
  animation: cmdk-slide 0.2s cubic-bezier(.25,.8,.25,1);
  position: relative;
  z-index: 1;
}

@keyframes cmdk-slide {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.cmdk-input-wrap svg { color: var(--text-muted); flex-shrink: 0; }

.cmdk-input-wrap input {
  flex: 1;
  border: none;
  font-size: 16px;
  font-family: inherit;
  font-weight: 400;
  outline: none;
  background: none;
  color: var(--text);
}

.cmdk-input-wrap input::placeholder { color: var(--text-muted); }

.cmdk-input-wrap kbd {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--bg);
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 500;
  border: 1px solid rgba(0,0,0,0.06);
}

.cmdk-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.cmdk-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.cmdk-section {
  margin-bottom: 8px;
}

.cmdk-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 4px;
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
}

.cmdk-item:hover { background: var(--bg); }

.cmdk-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--text-secondary);
}

.cmdk-item-icon.conv { background: var(--accent-light); color: var(--accent); }
.cmdk-item-icon.contact { background: #e8faf0; color: #1a8a4a; }
.cmdk-item-icon.article { background: #f0e6ff; color: #6d28d9; }

.cmdk-item-text { flex: 1; min-width: 0; }
.cmdk-item-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== STATS / OVERVIEW (home view) ===== */
.stats-view {
  grid-column: 2 / -1;
  grid-row: 1;
  overflow-y: auto;
  padding: 44px 52px 64px;
  background: var(--bg);
  z-index: 1;
}
@media (max-width: 1400px) {
  .stats-view { padding: 36px 40px 56px; }
}

/* Header */
.overview-header { margin-bottom: 32px; }
.overview-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  min-height: 13px;
}
.overview-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text);
}
.overview-subtitle {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.5;
}

/* ===== STATS HERO: clean analytics redesign ===== */
.stats-hero-head { margin-bottom: 36px; }
.stats-hero-head h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text);
}
.stats-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
@media (max-width: 1100px) {
  .stats-hero { grid-template-columns: repeat(2, 1fr); }
}
.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 24px 26px 22px;
  cursor: default;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 130px;
}
.kpi-card[onclick] { cursor: pointer; }
.kpi-card[onclick]:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 15, 35, 0.06);
}
.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.kpi-value {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-unit {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
  margin-left: 2px;
}
.kpi-trend {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 5px;
}
.kpi-trend .trend-arrow { font-weight: 700; font-size: 12px; }
.kpi-trend.up .trend-arrow,
.kpi-trend.up { color: #10b981; }
.kpi-trend.down .trend-arrow,
.kpi-trend.down { color: #e84545; }
.kpi-trend.flat { color: var(--text-muted); }
.kpi-trend.inverse.up { color: #e84545; }
.kpi-trend.inverse.down { color: #10b981; }

/* Shared card style used across the stats view (chart card, secondary, heatmap, etc.) */
.stats-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 18px 22px 18px;
}
.stats-chart-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 26px 28px 20px;
}
.stats-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.stats-card-eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.stats-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.volume-chart {
  width: 100%;
  min-height: 200px;
  display: block;
}
.volume-chart svg { width: 100%; height: 200px; display: block; }

.stats-secondary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 1100px) {
  .stats-secondary { grid-template-columns: 1fr; }
}
.stats-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 22px;
  margin-top: 14px;
}
.mini-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.mini-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stats-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 1100px) {
  .stats-two-col { grid-template-columns: 1fr; }
}

/* Uniform vertical spacing between top-level stat sections.
 * MUST use the direct-child combinator (>) so the rule only applies to
 * sections that are direct children of .stats-view, not to individual cards
 * *inside* a grid like .stats-two-col > .stats-card — otherwise those
 * nested cards would also get a 32px top margin and end up offset from
 * their neighbours inside the same grid row. (The old rule .stats-card +
 * .stats-card caused exactly that bug.) */
.stats-view > .stats-hero,
.stats-view > .stats-chart-card,
.stats-view > .stats-secondary,
.stats-view > .stats-card,
.stats-view > .stats-two-col {
  margin-bottom: 32px;
}
.stats-view > *:last-child { margin-bottom: 0; }

/* Status strip (top): 4 editorial columns separated by vertical dividers */
.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #fff;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 16px;
  padding: 36px 0;
  margin-bottom: 32px;
}
.status-col {
  padding: 0 40px;
  border-right: 1px solid rgba(0,0,0,0.06);
  cursor: pointer;
  transition: background 0.18s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}
.status-col:last-child { border-right: none; }
.status-col:hover { background: rgba(0,0,0,0.015); }
.status-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.status-value {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
  margin-bottom: 10px;
}
.status-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Main two-column layout */
.overview-main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 1200px) {
  .overview-main { grid-template-columns: 1fr; }
}

/* Panel primitive */
.panel {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 16px;
  padding: 32px 36px;
}
.panel.panel-wide { margin-bottom: 24px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.panel-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.panel-divider {
  border: none;
  height: 1px;
  background: rgba(0,0,0,0.06);
  margin: 28px 0;
}

/* Activity panel */
.panel-activity { display: flex; flex-direction: column; }
.activity-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
}
@media (max-width: 900px) {
  .activity-metrics { grid-template-columns: repeat(2, 1fr); }
}
.metric-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.metric-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}

/* Split bar (bot vs. team, positive vs. negative feedback) */
.activity-split .split-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.split-bar {
  height: 4px;
  background: rgba(0,0,0,0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}
.split-fill {
  height: 100%;
  background: var(--text);
  transition: width 0.6s cubic-bezier(.25,.8,.25,1);
  width: 0%;
}
.split-fill.good { background: var(--success); }
.split-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Quality panel */
.panel-quality { display: flex; flex-direction: column; }
.csat-display { margin-top: 4px; }
.csat-score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}
.csat-value {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}
.csat-max {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 500;
}
.csat-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.feedback-section { margin-top: 14px; }

/* Detail strip (below main) */
.detail-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 16px;
  padding: 32px 0;
  margin-bottom: 32px;
}
.detail-cell {
  padding: 0 36px;
  border-right: 1px solid rgba(0,0,0,0.06);
}
.detail-cell:last-of-type { border-right: none; }
.detail-cell .detail-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.detail-cell .detail-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 8px;
  color: var(--text);
}
.detail-cell .detail-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Top lists two-col */
.overview-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 1000px) {
  .overview-lists { grid-template-columns: 1fr; }
}
.top-list { margin-top: 6px; }
.top-row {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 13px;
}
.top-row:last-child { border-bottom: none; }
.top-row-rank {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.top-row-name {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-row-count {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.list-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 28px 0;
  text-align: center;
}

/* Team table */
.team-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.team-table th {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 0 0 16px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.team-table td {
  padding: 16px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 13px;
  color: var(--text);
}
.team-table tr:last-child td { border-bottom: none; }
.team-table th:not(:first-child),
.team-table td:not(:first-child) { text-align: right; }

/* ===== NAV SIDEBAR ===== */
.nav {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.nav-header {
  display: flex;
  align-items: center;
  gap: 10px;
  /* left padding is 22px on purpose: the nav-section has padding 0 10px and
   * each .nav-item has padding-left 12px — so the nav-item icons land at
   * exactly 22px from the sidebar edge. Matching the logo here makes the
   * whole left-rail optically flush. */
  padding: 20px 16px 16px 22px;
}

.nav-collapse-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.nav-collapse-btn:hover { color: var(--text); background: var(--bg); }
.app.nav-collapsed .nav-collapse-btn { display: none; }
/* In collapsed mode the logo IS the expand trigger — click it to open the
 * sidebar. This avoids having both a logo AND a chevron button that would
 * together overflow the 64px collapsed width. */
.app.nav-collapsed .nav-logo { cursor: pointer; }
.app.nav-collapsed .nav-logo:hover { transform: scale(1.05); }
.nav-logo { transition: transform 0.15s ease; }

.nav-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  padding: 5px;
  box-shadow: 0 1px 3px rgba(240,4,156,0.15);
}
.nav-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.nav-title {
  color: var(--sidebar-active);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  width: 100%;
}

.nav-item svg { flex-shrink: 0; }

.nav-item:hover {
  color: var(--sidebar-active);
  background: var(--bg);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 11px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  padding: 0 6px;
}
.nav-item .badge.muted {
  background: var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

/* Standard "visually hidden" — entfernt ein Element aus der visuellen Ausgabe,
   ohne es via display:none zu verstecken. Wichtig für file-inputs, die per
   Label geklickt werden: display:none bricht in manchen Browsern die
   label→input-Click-Delegation. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.nav-footer {
  padding: 10px 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Einheitlicher Stil für alle klickbaren Footer-Items (System, Availability, Team).
   Ein kleines Icon links mit einem farbigen Status-Overlay, dann zweizeiliger Text
   (Label + Sub-Label) rechts. Im collapsed-Mode wird der Text ausgeblendet. */
.nav-footer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--sidebar-text);
  position: relative;
}
.nav-footer-item:hover { background: var(--bg); }
.nav-footer-icon {
  position: relative;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
  flex-shrink: 0;
}
.nav-footer-icon svg { display: block; }
.nav-footer-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.nav-footer-label {
  color: var(--sidebar-active);
  font-size: 12px;
  font-weight: 600;
}
.nav-footer-sub {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.nav-footer-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e84545;
  color: #ffffff;
  min-width: 16px;
  text-align: center;
}
.nav-footer-badge.warning { background: #f5a623; }

/* Status-Dot Overlay: kleiner farbiger Punkt unten-rechts am Icon */
.status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--sidebar-bg);
  transition: background 0.2s;
}
.status-dot.offline { background: var(--text-muted); }
.status-dot.warning { background: #f5a623; }
.status-dot.critical {
  background: #e84545;
  animation: statusDotPulse 1.6s ease-in-out infinite;
}
@keyframes statusDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 69, 69, 0.55); }
  50%      { box-shadow: 0 0 0 4px rgba(232, 69, 69, 0); }
}

/* Collapsed-Mode: nur Icons, kein Text */
.app.nav-collapsed .nav-footer { padding: 10px 6px; align-items: center; gap: 4px; }
.app.nav-collapsed .nav-footer-item {
  padding: 8px;
  justify-content: center;
  width: 44px;
}
.app.nav-collapsed .nav-footer-text,
.app.nav-collapsed .nav-footer-badge {
  display: none;
}

.nav-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.nav-agent-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.nav-agent-info { min-width: 0; }

.nav-agent-name {
  color: var(--sidebar-active);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-logout-link {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.nav-logout-link:hover { color: var(--accent); }

/* Legacy .avail-dot / .health-dot Klassen hängen noch am HTML, werden aber
   jetzt von .status-dot gesteuert. Diese Regeln neutralisieren die alten
   Dimensionen, damit das neue Icon-basierte Layout greift. */
.avail-dot, .health-dot, .team-presence-dot { flex-shrink: 0; }

/* ===== MEIN TAG (Home / Landing) =====
   Persönliches Start-Dashboard: Begrüßung + 4 KPIs + "Jetzt dran"-Liste +
   Team-Puls + heute-Zusammenfassung. Design bewusst ruhig, ohne Charts,
   fokussiert auf das, was der Agent für den Tag braucht. */
.my-day-view {
  grid-column: 2 / -1;
  grid-row: 1;
  overflow-y: auto;
  background: var(--bg);
  position: relative;
  z-index: 1;
}
.my-day-bg-gradient {
  position: absolute;
  inset: 0 0 auto 0;
  height: 380px;
  background: linear-gradient(180deg, rgba(240, 4, 156, 0.06) 0%, rgba(240, 4, 156, 0.02) 45%, rgba(240, 4, 156, 0) 100%);
  pointer-events: none;
  z-index: 0;
}
.my-day-inner {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 68px 64px 80px;
}
@media (max-width: 900px) {
  .my-day-inner { padding: 36px 24px 56px; }
  .my-day-bg-gradient { height: 260px; }
}

/* Header: Datum + Begrüßung + Untertitel */
.my-day-header {
  margin-bottom: 44px;
  animation: myDayFadeIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.my-day-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.my-day-greeting {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.1;
  color: var(--text);
  margin: 0 0 8px;
  background: linear-gradient(135deg, #1a1a1a 0%, #3a2540 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.my-day-sub {
  font-size: 16px;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 400;
}
@media (max-width: 900px) {
  .my-day-greeting { font-size: 30px; }
  .my-day-sub { font-size: 14px; }
  .my-day-header { margin-bottom: 32px; }
}
@keyframes myDayFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* KPI-Kacheln */
.my-day-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 48px;
  animation: myDayFadeIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
}
@media (max-width: 900px) {
  .my-day-kpis { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 36px; }
}
.my-day-kpi {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
  cursor: default;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s, border-color 0.2s;
  box-shadow: 0 1px 2px rgba(15, 15, 25, 0.03);
}
a.my-day-kpi { cursor: pointer; }
a.my-day-kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 15, 25, 0.08), 0 2px 4px rgba(15, 15, 25, 0.04);
  border-color: rgba(240, 4, 156, 0.2);
}
.my-day-kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--text-secondary);
}
.kpi-mine .my-day-kpi-icon { background: rgba(240, 4, 156, 0.08); color: var(--accent); }
.kpi-new .my-day-kpi-icon { background: rgba(56, 139, 253, 0.08); color: #388bfd; }
.kpi-escalated .my-day-kpi-icon { background: rgba(232, 69, 69, 0.08); color: #e84545; }
.kpi-done .my-day-kpi-icon { background: rgba(48, 209, 88, 0.1); color: #30a04a; }
.my-day-kpi-main {
  flex: 1;
  min-width: 0;
}
.my-day-kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.05;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.my-day-kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
}
.my-day-kpi-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Sektionen: Jetzt dran / Team jetzt / Heute im Team */
.my-day-section {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 26px;
  box-shadow: 0 1px 2px rgba(15, 15, 25, 0.03);
  animation: myDayFadeIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}
.my-day-section + .my-day-section { margin-top: 20px; }
.my-day-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.my-day-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.1px;
}
.my-day-section-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* "Jetzt dran" Liste */
.my-day-focus-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.my-day-list-skeleton {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.my-day-focus-item {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.my-day-focus-item:hover {
  background: var(--bg);
  border-color: var(--border-light);
}
.my-day-focus-bar {
  width: 4px;
  height: 36px;
  border-radius: 4px;
  background: var(--border);
}
.my-day-focus-bar.priority-urgent { background: #e84545; }
.my-day-focus-bar.priority-high { background: #f5a623; }
.my-day-focus-bar.priority-normal { background: #c8c8d0; }
.my-day-focus-bar.priority-low { background: #e6e6ec; }
.my-day-focus-main { min-width: 0; }
.my-day-focus-title {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.my-day-focus-title .focus-priority-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.focus-priority-tag.urgent { background: #e84545; color: #fff; }
.focus-priority-tag.high { background: #f5a623; color: #fff; }
.my-day-focus-title .focus-new-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.my-day-focus-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 520px;
}
.my-day-focus-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.my-day-focus-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 8px;
}
.my-day-focus-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(48, 209, 88, 0.12);
  color: #30a04a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.my-day-focus-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.my-day-focus-empty-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* Split: Team + Heute */
.my-day-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
  animation: myDayFadeIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.18s both;
}
.my-day-split .my-day-section { margin-top: 0; }
@media (max-width: 900px) {
  .my-day-split { grid-template-columns: 1fr; gap: 16px; }
}

/* Team-Puls: kleine Avatar-Liste */
.my-day-team-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.my-day-team-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
}
.my-day-team-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
}
.my-day-team-avatar::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #30d158;
  border: 2px solid #fff;
}
.my-day-team-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.my-day-team-role {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 4px;
}
.my-day-team-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Heute-Grid: 4 kleine Zahlen */
.my-day-today-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.my-day-today-stat {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 16px;
}
.my-day-today-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.my-day-today-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

/* Footer: Primär-Button "Alle Tickets öffnen" */
.my-day-footer {
  display: flex;
  justify-content: center;
  margin-top: 40px;
  animation: myDayFadeIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.25s both;
}
.my-day-primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  box-shadow: 0 4px 14px rgba(240, 4, 156, 0.22);
}
.my-day-primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 6px 18px rgba(240, 4, 156, 0.32);
}
.my-day-primary-btn svg { stroke: #fff; }

/* ===== BÜRO-STANDORTE (SETTINGS → ÖFFNUNGSZEITEN) ===== */
.office-locations-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.office-location-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.office-location-item:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.office-location-item input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
}
.office-location-item.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.office-location-code {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: auto;
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 4px;
}
.office-location-item.selected .office-location-code {
  background: #fff;
  color: var(--accent);
}

/* Info-Box: nächster Feiertag (Büro geschlossen) */
#nextHolidayHint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 8px;
  font-size: 12.5px;
  color: #7a5d00;
}
#nextHolidayHint:empty { display: none; }

/* ===== STATS-TOGGLE: "Nach Öffnungszeiten rechnen" ===== */
.stats-toggle-row {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.stats-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-secondary);
  background: #fff;
  transition: all 0.15s;
}
.stats-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.stats-toggle input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
}
.stats-toggle input[type="checkbox"]:checked ~ .stats-toggle-label {
  color: var(--accent);
  font-weight: 600;
}
.stats-toggle-label { font-weight: 500; }

/* ===== SURVEY QUESTION EDITOR ===== */
.survey-q-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.survey-q-card {
  padding: 16px 18px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.survey-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.survey-q-num {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}
.survey-q-card input[type="text"],
.survey-q-card textarea,
.survey-q-card select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
.survey-q-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.survey-q-row label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.survey-q-row input[type="text"] { flex: 1; }
.survey-q-required {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.survey-q-required input[type="checkbox"] { accent-color: var(--pink, #ff009d); }
.survey-q-options-label {
  font-size: 11.5px;
  color: var(--text-muted);
}
.survey-q-remove {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.survey-q-remove:hover { background: #fef2f2; color: #e84545; border-color: #fecaca; }
.survey-q-showif {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-light);
}
.survey-q-showif select { background: #fff; }
.survey-q-showif-label {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: -4px;
}

/* ===== SURVEYS ===== */
.survey-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.survey-item {
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: #fff;
  align-items: flex-start;
}
.survey-item-main { flex: 1; min-width: 0; }
.survey-item-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.survey-inactive {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 7px;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 6px;
  letter-spacing: 0.3px;
}
.survey-item-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  align-items: center;
}
.survey-type-pill {
  background: color-mix(in srgb, var(--pink, #ff009d) 10%, var(--card, #fff));
  color: var(--pink, #ff009d);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.survey-item-url {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.survey-item-url code {
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 6px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-icon {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg); border-color: var(--text-muted); }
.survey-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.survey-item-actions .btn { font-size: 12px; padding: 6px 10px; }
.btn.btn-danger {
  color: #e84545;
  border-color: #fecaca;
  background: #fef2f2;
}
.btn.btn-danger:hover { background: #fee2e2; }

.survey-dist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0 8px;
}
.dist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.dist-label {
  min-width: 60px;
  color: var(--text);
  font-weight: 500;
}
.dist-bar-wrap {
  flex: 1;
  height: 20px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}
.dist-bar {
  height: 100%;
  background: var(--pink, #ff009d);
  border-radius: 6px;
  transition: width 0.4s ease;
}
.dist-count {
  min-width: 40px;
  text-align: right;
  font-weight: 600;
  color: var(--text);
  font-size: 12px;
}
.survey-recent {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.survey-recent-item {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.survey-recent-text {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  line-height: 1.5;
}
.survey-recent-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ===== GDPR SEARCH RESULTS ===== */
.gdpr-results {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gdpr-result-card {
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px 18px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gdpr-result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.gdpr-result-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}
.gdpr-result-email {
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: monospace;
}
.gdpr-result-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.gdpr-result-counts strong { color: var(--text); }
.gdpr-result-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.gdpr-result-none {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg);
  border-radius: 12px;
}

/* ===== INCIDENT DRAWER ===== */
.incident-drawer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  pointer-events: none;
}
.incident-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 20, 0.35);
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: auto;
}
.incident-drawer.open .incident-drawer-backdrop { opacity: 1; }
.incident-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 92vw);
  background: #ffffff;
  box-shadow: -8px 0 32px rgba(0,0,0,0.14);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
}
.incident-drawer.open .incident-drawer-panel { transform: translateX(0); }
.incident-drawer-header {
  padding: 22px 24px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.incident-drawer-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}
.incident-drawer-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.incident-drawer-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.incident-drawer-close:hover { background: var(--bg); color: var(--text); }

.incident-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 24px;
}
.incident-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.incident-item {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: background 0.15s;
}
.incident-item:hover { background: var(--bg); }
.incident-sev {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f5a623;
  margin-top: 5px;
  flex-shrink: 0;
}
.incident-sev.error, .incident-sev.critical { background: #e84545; }
.incident-sev.info { background: #3b82f6; }
.incident-body { flex: 1; min-width: 0; }
.incident-type-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 2px;
}
.incident-type {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.incident-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.incident-message {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toast notification for live incident alerts */
.incident-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-left: 4px solid #e84545;
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.16);
  padding: 14px 18px 14px 16px;
  max-width: 380px;
  z-index: 1300;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: incidentToastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
}
.incident-toast.warning { border-left-color: #f5a623; }
@keyframes incidentToastIn {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}
.incident-toast-icon {
  font-size: 18px;
  line-height: 1.2;
}
.incident-toast-body { flex: 1; min-width: 0; }
.incident-toast-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.incident-toast-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== CONVERSATION LIST ===== */
.conv-list {
  border-right: 1px solid var(--ix-line);
  background: var(--ix-white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conv-list-header {
  padding: 14px 16px 10px;
  flex-shrink: 0;
}

.conv-list-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.conv-list-header h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0;
}

.conv-select-toggle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.conv-select-toggle:hover {
  background: var(--bg);
  color: var(--text);
}
.conv-select-toggle.active {
  background: var(--accent);
  color: white;
}

.conv-search-wrap { position: relative; margin-bottom: 12px; }
.conv-search-wrap input { width: 100%; padding: 10px 14px 10px 36px; border: 1px solid transparent; border-radius: 10px; background: var(--bg); font-size: 16px; font-family: inherit; outline: none; transition: all 0.2s; }
.conv-search-wrap input:focus { background: white; border-color: var(--border); box-shadow: 0 0 0 3px rgba(240,4,156,0.08); }
.conv-search-wrap input::placeholder { color: var(--text-muted); }
.conv-search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.tag-filter { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--accent-light); border-radius: 8px; margin-top: 8px; font-size: 12px; }
.tag-filter-label { color: var(--text-secondary); font-weight: 500; }
.tag-filter-value { color: var(--accent); font-weight: 600; }
.tag-filter-clear { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; padding: 0 2px; }
.tag-filter-clear:hover { color: var(--text); }

.conv-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.conv-tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--accent-light); color: var(--accent); font-weight: 600; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 3px; }
.conv-tag:hover { background: rgba(240,4,156,0.15); }
.conv-tag .tag-remove { font-size: 10px; opacity: 0; transition: opacity 0.15s; }
.conv-tag:hover .tag-remove { opacity: 1; }

.tag-select {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px dashed rgba(0,0,0,0.1);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.tag-select:hover { border-color: var(--accent); color: var(--accent); }
.tag-select:focus { outline: none; border-color: var(--accent); }

/* Tag manager in settings */
.tag-manager-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.tag-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid rgba(0,0,0,0.06);
  transition: transform 0.15s;
}
.tag-color-dot:hover { transform: scale(1.2); }

.tag-manager-item input {
  flex: 1;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  transition: all 0.15s;
}
.tag-manager-item input:hover { background: var(--bg); }
.tag-manager-item input:focus { background: var(--bg); border-color: var(--accent); outline: none; }

.tag-manager-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.15s;
  opacity: 0.4;
}
.tag-manager-delete:hover { opacity: 1; color: var(--danger); }

/* Color picker popover */
.tag-color-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px;
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  position: absolute;
  z-index: 100;
}

.tag-color-option {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.tag-color-option:hover { transform: scale(1.2); border-color: rgba(0,0,0,0.2); }

/* Bulk actions */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--accent-light);
  border-radius: 10px;
  margin-top: 10px;
  animation: bulkBarSlide 0.2s ease;
}

@keyframes bulkBarSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.bulk-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
  white-space: nowrap;
}

.bulk-bar-actions {
  display: flex;
  gap: 4px;
}

.bulk-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: none;
  background: white;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.bulk-action-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(240,4,156,0.25);
}
/* Danger-Variante: Löschen-Button. Ruhe-Zustand schon leicht rötlich,
   damit klar ist dass es eine destruktive Aktion ist. */
.bulk-action-btn.bulk-action-danger {
  color: #c52828;
}
.bulk-action-btn.bulk-action-danger:hover {
  background: #e84545;
  color: #fff;
  box-shadow: 0 2px 6px rgba(232,69,69,0.35);
}

.bulk-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.bulk-clear:hover { color: var(--text); background: rgba(255,255,255,0.5); }

/* Checkbox in conversation items — only visible in select mode */
.conv-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid rgba(0,0,0,0.18);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.15s;
  background: var(--card);
  display: none;
}
.conv-list.select-mode .conv-checkbox { display: block; }

.conv-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 3L4.5 8.5 2 6' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 10px;
  background-position: center;
  background-repeat: no-repeat;
}

.status-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
}

.status-tab {
  padding: 7px 6px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.status-tab:hover { color: var(--text); }
.status-tab.active {
  background: white;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 0px 1px rgba(0,0,0,0.08);
}

.conv-items {
  flex: 1;
  overflow-y: auto;
}

/* ═══ Intercom-style conv-item (Phase 2 migration) ═══ */
.conv-item {
  padding: 12px 14px;
  margin: 0 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s var(--ix-ease);
  display: flex;
  gap: 11px;
  align-items: flex-start;
  border-bottom: none;
}
.conv-item:first-child { margin-top: 6px; }
.conv-item:hover { background: rgba(0, 0, 0, 0.025); }
.conv-item.active {
  background: var(--ix-white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.08);
  border-left: none;
}
.conv-item.unread .conv-item-name { font-weight: 700; color: var(--ix-ink); }

/* Hide the old unread-dot (no longer rendered anyway) */
.conv-item .unread-dot { display: none; }

/* ═══ Intercom-style pastel avatars ═══ */
.ix-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  text-transform: uppercase;
  font-family: 'General Sans', -apple-system, sans-serif;
}
.ix-avatar.av-violet  { background: #dcd0f5; color: #4a1f9c; }
.ix-avatar.av-emerald { background: #c7e8cf; color: #17693a; }
.ix-avatar.av-amber   { background: #f4d8a8; color: #6e4410; }
.ix-avatar.av-sky     { background: #c9ddf3; color: #1d4e8a; }
.ix-avatar.av-rose    { background: #f3cbcf; color: #851b2e; }
.ix-avatar.av-teal    { background: #b8e0d6; color: #0b5d4c; }
.ix-avatar.av-indigo  { background: #cfd0f2; color: #2a309c; }
.ix-avatar.av-pink    { background: #f4c8dd; color: #881849; }
.ix-avatar.av-peach   { background: #f9d6b3; color: #7d3a0d; }
.ix-avatar.av-lemon   { background: #f2e4a1; color: #605010; }
.ix-avatar.av-ink     { background: #e5e5e5; color: #262626; }

.conv-item-content { flex: 1; min-width: 0; }

.conv-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.conv-item-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ix-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.conv-item-assigned {
  font-size: 11px;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 1px 6px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}

.conv-item-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.conv-item-preview {
  font-size: 12px;
  color: var(--ix-ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
  line-height: 1.45;
}

.conv-item-tags {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.channel-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.channel-badge.escalated {
  background: #fff0f0;
  color: var(--danger);
  font-weight: 600;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
  gap: 12px;
}

.empty-state svg { opacity: 0.2; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ===== CONVERSATION DETAIL ===== */
.conv-detail-wrapper {
  display: flex;
  overflow: hidden;
}

.conv-detail {
  display: flex;
  flex-direction: column;
  background: var(--ix-ivory);
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.conv-detail-header {
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ix-line);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  row-gap: 8px;
}

.conv-detail-header .conv-name {
  font-weight: 700;
  font-size: 16px;
  flex: 1;
  letter-spacing: -0.02em;
  color: var(--ix-ink);
}

.conv-detail-header select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  background: white;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.conv-detail-header select:focus { border-color: var(--accent); outline: none; }

.priority-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.priority-badge.normal { background: var(--bg); color: var(--text-secondary); }
.priority-badge.high { background: #fff3e0; color: #e65100; }
.priority-badge.urgent { background: #fff0f0; color: var(--danger); }

/* ═══ Intercom-style messages (Phase 3 migration) ═══ */
.conv-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 44px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.msg {
  display: flex;
  gap: 12px;
  max-width: 640px;
  animation: msg-in 0.25s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Contact on the LEFT (like an email thread / Intercom).
   Agent + Bot on the RIGHT (we are the ones viewing/replying). */
.msg.contact { align-self: flex-start; flex-direction: row; }
.msg.agent, .msg.bot { align-self: flex-end; flex-direction: row-reverse; }

.msg .msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 650;
  flex-shrink: 0;
  margin-top: 2px;
}
/* .msg-avatar already gets .ix-avatar + .av-* pastel class from renderMessages,
   which applies the right pastel palette. No per-sender override needed. */

.msg-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.msg.agent .msg-body, .msg.bot .msg-body { align-items: flex-end; }

.msg .msg-content {
  padding: 14px 18px 15px;
  border-radius: 18px;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  color: var(--ix-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
}

.msg.contact .msg-content {
  background: var(--ix-white);
}

.msg.bot .msg-content {
  background: #fcf5f9;
}

.msg.agent .msg-content {
  background: #fcf5f9;
}

.msg.internal-note .msg-content {
  background: #fffbe6 !important;
  color: var(--text) !important;
  border: 1px dashed var(--warning) !important;
}

.msg .msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-read-status {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  transition: color 0.25s ease;
}
.msg-read-status.sent { color: var(--text-muted); opacity: 0.55; }
.msg-read-status.read { color: #1e88e5; opacity: 1; }

.msg .ai-badge {
  background: #f0e6ff;
  color: #7c3aed;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text-muted);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: cursor-blink 0.8s step-end infinite;
}
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* System messages (status changes, tags, etc.) */
.msg-system {
  text-align: center;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.msg-system span:first-child {
  background: rgba(0,0,0,0.04);
  padding: 4px 12px;
  border-radius: 10px;
  font-weight: 500;
}

.msg-system-time {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
}

.msg .note-badge {
  background: #fff3e0;
  color: #e65100;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ═══ Reply box — Intercom-style floating card ═══ */
.reply-box {
  border-top: none;
  padding: 0 24px 24px;
  flex-shrink: 0;
  background: transparent;
}

.reply-box textarea {
  width: 100%;
  border: 1px solid var(--ix-line-2);
  border-radius: 14px;
  padding: 14px 92px 14px 18px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 52px;
  max-height: 160px;
  line-height: 1.55;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  background: var(--ix-white);
  color: var(--ix-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
}

.reply-box textarea::placeholder { color: var(--ix-ink-5); }

.reply-box textarea:focus {
  border-color: rgba(237, 0, 153, 0.4);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 28px rgba(237, 0, 153, 0.1);
}

.reply-input-wrap { position: relative; }

/* Toolbar inside textarea (attach + send) */
.reply-input-toolbar {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.reply-toolbar-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.reply-toolbar-btn:hover { background: var(--bg); color: var(--text); }

.reply-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(240,4,156,0.25);
}
.reply-send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.reply-send-btn:active { transform: scale(0.95); }

/* Secondary actions row */
.reply-actions {
  display: flex;
  gap: 2px;
  margin-top: 8px;
  align-items: center;
  padding: 0 4px;
}

.reply-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}
.reply-action-btn:hover { background: var(--bg); color: var(--text); }
.reply-action-btn:active { transform: scale(0.97); }
.reply-action-btn svg { opacity: 0.6; }
.reply-action-btn:hover svg { opacity: 1; }

/* Note mode toggle */
.reply-note-toggle.active {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}
.reply-note-toggle.active svg { opacity: 1; stroke: #92400e; }

/* Note mode — yellow textarea */
.reply-box.note-mode textarea {
  background: #fefce8;
  border-color: #f59e0b;
}
.reply-box.note-mode textarea:focus {
  background: #fef9c3;
  border-color: #d97706;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}
.reply-box.note-mode .reply-send-btn {
  background: #f59e0b;
  box-shadow: 0 2px 6px rgba(245,158,11,0.3);
}
.reply-box.note-mode .reply-send-btn:hover { background: #d97706; }

.reply-action-done {
  color: var(--success);
}
.reply-action-done:hover {
  background: rgba(34,197,94,0.08);
  color: #16a34a;
}

.reply-actions-spacer { flex: 1; }

/* ===== AGENT PRESENCE ===== */

/* Presence dots in conversation list */
.conv-presence {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.presence-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: #94a3b8;
  position: relative;
  flex-shrink: 0;
}

.presence-dot.viewing {
  background: #3b82f6;
  box-shadow: 0 0 0 2px white, 0 0 0 3.5px rgba(59,130,246,0.3);
}

.presence-dot.typing {
  background: #8b5cf6;
  box-shadow: 0 0 0 2px white, 0 0 0 3.5px rgba(139,92,246,0.3);
  animation: presence-pulse 1.5s ease-in-out infinite;
}

@keyframes presence-pulse {
  0%, 100% { box-shadow: 0 0 0 2px white, 0 0 0 3.5px rgba(139,92,246,0.3); }
  50% { box-shadow: 0 0 0 2px white, 0 0 0 5px rgba(139,92,246,0.15); }
}

/* Presence bar in conversation header */
.conv-presence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  background: linear-gradient(135deg, rgba(59,130,246,0.06), rgba(139,92,246,0.06));
  border-bottom: 1px solid rgba(59,130,246,0.1);
  font-size: 12px;
  color: #475569;
}

.conv-presence-bar .presence-dot {
  width: 20px;
  height: 20px;
  font-size: 8px;
}

.presence-label {
  font-weight: 500;
  color: #64748b;
}

/* ===== ROLE-BASED UI ===== */

/* Role badge next to agent name in nav */
.role-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 4px;
  vertical-align: middle;
}
.role-badge.admin {
  background: rgba(240,4,156,0.1);
  color: var(--accent);
}
.role-badge.viewer {
  background: rgba(148,163,184,0.15);
  color: #64748b;
}

/* Agent role: hide admin-only elements */
.app.role-agent .admin-only { display: none !important; }

/* Viewer role: hide admin-only + disable reply + hide action buttons */
.app.role-viewer .admin-only { display: none !important; }
.app.role-viewer .reply-box { display: none !important; }
.app.role-viewer .conv-detail-header select[id="statusSelect"],
.app.role-viewer .conv-detail-header select[id="assignSelect"],
.app.role-viewer .conv-detail-header .snooze-wrap { display: none !important; }

/* ===== PERMISSIONS TABLE ===== */
.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.perm-table th {
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}
.perm-table th:first-child { text-align: left; }
.perm-table td { padding: 10px 16px; border-bottom: 1px solid var(--border-light); }
.perm-label { font-weight: 500; color: var(--text); }
.perm-cell { text-align: center; }
.perm-group-row td {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 20px 16px 6px;
  border-bottom: none;
  background: none;
}

/* Toggle switch */
.perm-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}
.perm-toggle input { opacity: 0; width: 0; height: 0; }
.perm-slider {
  position: absolute;
  inset: 0;
  background: #e2e8f0;
  border-radius: 20px;
  transition: all 0.2s;
}
.perm-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.perm-toggle input:checked + .perm-slider { background: var(--accent); }
.perm-toggle input:checked + .perm-slider::before { transform: translateX(16px); }

.mention-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 180px;
  overflow-y: auto;
  z-index: 100;
  margin-bottom: 4px;
}

.mention-dropdown.visible { display: block; }

.mention-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mention-item:hover,
.mention-item.active {
  background: var(--bg);
}

.mention-item .mention-name { font-weight: 500; color: var(--text); }
.mention-item .mention-email { color: var(--text-muted); font-size: 12px; }

.mention-tag {
  background: rgba(240,4,156,0.1);
  color: var(--accent);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 500;
}

/* .reply-actions styles moved to reply-box section above */

.btn {
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn:hover { background: var(--bg); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(240,4,156,0.18), 0 1px 3px rgba(240,4,156,0.10);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-danger {
  background: white;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover { background: #fff0f0; }
.btn-danger:active { transform: scale(0.98); }
.btn-success:active { transform: scale(0.98); }

/* legacy spacer — replaced by .reply-actions-spacer */

/* Live Typing Preview (Kunde tippt …) */
.typing-preview {
  margin: 0 24px;
  padding: 8px 14px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 10px 10px 0 0;
  font-size: 12.5px;
  font-style: italic;
  font-weight: 500;
  border-bottom: 1px solid rgba(240,4,156,0.15);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Snooze Button + Menu + Banner */
.snooze-wrap { position: relative; }
.snooze-btn {
  font-size: 16px;
  padding: 6px 10px;
  cursor: pointer;
}
.snooze-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  flex-direction: column;
  min-width: 180px;
  z-index: 100;
}
.snooze-menu button {
  background: none;
  border: none;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.snooze-menu button:hover { background: var(--bg); }
.snooze-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.snooze-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: #fef9c3;
  border-bottom: 1px solid #fde68a;
  color: #854d0e;
  font-size: 13px;
}
.snooze-banner button {
  margin-left: auto;
  background: #fff;
  border: 1px solid #fde68a;
  color: #854d0e;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.snooze-banner button:hover { background: #fef3c7; }
.channel-badge.snoozed {
  background: #fef9c3;
  color: #854d0e;
  border-color: #fde68a;
}

/* Saved Replies Editor */
.saved-reply-row {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: #fff;
}
.saved-reply-row .sr-head {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.saved-reply-row .sr-title {
  flex: 2;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
}
.saved-reply-row .sr-shortcut-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  max-width: 140px;
}
.saved-reply-row .sr-content {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  margin-bottom: 8px;
}
.saved-reply-row .sr-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.sr-shortcut {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 6px;
}
.empty-hint {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Senden-Split-Button (Senden | & Erledigt) */
.send-split { display: inline-flex; }
.send-split .send-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: 0 2px 8px rgba(240,4,156,0.18), 0 1px 3px rgba(240,4,156,0.10);
}
.send-split .send-close {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid rgba(255,255,255,0.35);
  padding-left: 12px;
  padding-right: 14px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(240,4,156,0.18), 0 1px 3px rgba(240,4,156,0.10);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a1e;
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  animation: toast-in 0.3s ease;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
  letter-spacing: -0.1px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== CONTACT SIDEBAR ===== */
/* ═══ Contact sidebar — Intercom-style (Phase 4 migration) ═══ */
.contact-sidebar {
  width: 296px;
  border-left: 1px solid var(--ix-line);
  background: var(--ix-white);
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-section {
  padding: 18px 22px;
  border-bottom: 1px solid var(--ix-line);
}
.sidebar-section:last-child { border-bottom: none; }

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #dcd0f5;
  color: #4a1f9c;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 auto 10px;
  box-shadow: none;
  font-family: 'General Sans', -apple-system, sans-serif;
}

.contact-main-name {
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.015em;
  color: var(--ix-ink);
}

.contact-main-email {
  text-align: center;
  font-size: 11.5px;
  color: var(--ix-ink-4);
  margin-top: 3px;
  word-break: break-all;
  font-weight: 500;
}

.sidebar-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ix-ink-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.sidebar-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 9px;
  gap: 10px;
  color: var(--ix-ink);
}
.sidebar-row:last-child { margin-bottom: 0; }

/* AI Summary section */
.ai-summary-section .sidebar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-summary-refresh {
  background: transparent;
  border: 1px solid var(--border, #e5e5e5);
  color: var(--text-muted);
  border-radius: 6px;
  width: 22px;
  height: 22px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.ai-summary-refresh:hover {
  background: var(--bg-hover, #f5f5f5);
  color: var(--text);
}
.ai-summary-body {
  font-size: 11.5px;
  line-height: 1.5;
}
.ai-summary-text {
  color: var(--text);
  background: linear-gradient(135deg, rgba(255, 0, 157, 0.04), rgba(255, 0, 157, 0.08));
  border-left: 3px solid #ff009d;
  padding: 8px 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  font-size: 11.5px;
}
.ai-summary-loading {
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}
.btn-ai-summary {
  width: 100%;
  background: linear-gradient(135deg, #ff009d, #c3007a);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s;
}
.btn-ai-summary:hover {
  opacity: 0.9;
}

/* Reply Suggestions (C2) */
.reply-suggestions {
  background: #fff;
  border: 1px solid #f0d4e6;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(255, 0, 157, 0.06);
}
.reply-suggestions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: #ff009d;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.reply-suggestions-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 6px;
  line-height: 1;
  border-radius: 4px;
}
.reply-suggestions-close:hover {
  background: var(--bg-hover, #f5f5f5);
  color: var(--text);
}
.reply-suggestion-card {
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(255, 0, 157, 0.03), rgba(255, 0, 157, 0.06));
  border: 1px solid rgba(255, 0, 157, 0.15);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.reply-suggestion-card:hover {
  background: linear-gradient(135deg, rgba(255, 0, 157, 0.08), rgba(255, 0, 157, 0.14));
  border-color: rgba(255, 0, 157, 0.35);
  transform: translateY(-1px);
}
.reply-suggestion-card:last-child {
  margin-bottom: 0;
}
.reply-suggestion-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.reply-suggestions-loading,
.reply-suggestions-empty {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  padding: 6px 0;
  text-align: center;
}
.btn-suggest {
  font-size: 12px;
}
.btn-suggest:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Sentiment Badges (C4) */
.sentiment-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-right: 4px;
  cursor: help;
}
.sentiment-positive   { background: rgba(34, 197, 94, 0.12); }
.sentiment-neutral    { background: rgba(148, 163, 184, 0.12); }
.sentiment-negative   { background: rgba(249, 115, 22, 0.14); }
.sentiment-frustrated {
  background: rgba(239, 68, 68, 0.18);
  animation: sentiment-pulse 2s ease-in-out infinite;
}
@keyframes sentiment-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%      { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* Conversation-level sentiment badge (in header) */
.sentiment-badge-conv {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 10px;
  cursor: help;
  flex-shrink: 0;
}

/* Tag Suggestion Pill (C3) */
.tag-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  background: linear-gradient(135deg, rgba(255, 0, 157, 0.08), rgba(255, 0, 157, 0.14));
  border: 1px dashed rgba(255, 0, 157, 0.45);
  border-radius: 16px;
  font-size: 12px;
  color: #c3007a;
  margin-left: 4px;
  animation: tag-suggestion-fade-in 0.3s ease-out;
}
@keyframes tag-suggestion-fade-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tag-suggestion-icon {
  font-size: 13px;
}
.tag-suggestion-label {
  color: var(--text-muted);
  font-size: 11px;
}
.tag-suggestion-name {
  font-weight: 600;
}
.tag-suggestion-accept,
.tag-suggestion-reject {
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: transform 0.1s;
}
.tag-suggestion-accept {
  background: #22c55e;
  color: #fff;
}
.tag-suggestion-reject {
  background: rgba(0,0,0,0.08);
  color: var(--text-muted);
}
.tag-suggestion-accept:hover,
.tag-suggestion-reject:hover {
  transform: scale(1.1);
}
.threshold-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}
.threshold-row input[type="range"] {
  flex: 1;
  accent-color: #ff009d;
}
.threshold-val {
  font-weight: 600;
  color: #ff009d;
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sidebar-key { color: var(--text-secondary); font-size: 11px; }
.sidebar-val { color: var(--text); font-weight: 500; font-size: 11px; }

.sidebar-convs { display: flex; flex-direction: column; gap: 6px; }

.sidebar-conv-item {
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-conv-item:hover { background: #e8e8ed; }

.sidebar-conv-item .sci-preview {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.sidebar-conv-item .sci-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-conv-item .sci-status {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.sci-status.open { background: var(--accent-light); color: var(--accent); }
.sci-status.done { background: #e8faf0; color: #1a8a4a; }
.sci-status.in_progress { background: #fff3e0; color: #e65100; }

.sidebar-empty { font-size: 11px; color: var(--text-muted); }

/* ===== Phase D: Visitor Profile + Pages + Stripe ===== */
.sidebar-pill {
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}
.sidebar-sublabel {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 12px 0 6px 0;
}
.visitor-pages {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.visitor-page-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 10.5px;
  gap: 6px;
}
.visitor-page-item .vpi-url {
  color: var(--text);
  font-family: 'SF Mono', Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.visitor-page-item .vpi-duration {
  color: var(--text-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.stripe-row {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.stripe-row-title {
  color: var(--text);
  font-weight: 600;
}
.stripe-row-title a { color: #635bff; text-decoration: none; }
.stripe-row-title a:hover { text-decoration: underline; }
.stripe-row-meta {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}
.stripe-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}
.stripe-badge.stripe-active { background: #e8faf0; color: #1a8a4a; }
.stripe-badge.stripe-inactive { background: var(--bg); color: var(--text-muted); }
.stripe-badge.stripe-warn { background: #fff3e0; color: #e65100; }

.status-banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}
.status-banner.status-ok { background: #e8faf0; color: #1a8a4a; }
.status-banner.status-warn { background: #fff3e0; color: #e65100; }
.status-banner.status-error { background: #ffe8e8; color: #c33; }

/* ===== Phase E: Proactive Messages list ===== */
.proactive-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 8px;
  gap: 12px;
}
.proactive-row-main { flex: 1; min-width: 0; }
.proactive-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.proactive-trigger {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.proactive-message-preview {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proactive-stats {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.proactive-row-actions { display: flex; gap: 4px; }
.btn-icon {
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-icon:hover { background: #fff; border-color: var(--border); }
.badge-inactive {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-muted);
  text-transform: uppercase;
  margin-left: 6px;
}
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}
.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ===== Phase F: Analytics ===== */
.heatmap-container { padding: 8px; }
.heatmap-grid {
  display: grid;
  grid-template-columns: 32px repeat(24, 1fr);
  gap: 3px;
  font-size: 10px;
  color: var(--text-muted);
}
.heatmap-corner { }
.heatmap-hour-label {
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 2px 0;
}
.heatmap-day-label {
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-secondary);
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  min-height: 18px;
  cursor: default;
  transition: transform 0.1s;
}
.heatmap-cell:hover { transform: scale(1.2); z-index: 2; position: relative; }

/* .agent-perf-name is still used by JS in renderAgentPerf (team-table cells) */
.agent-perf-name { font-weight: 600; color: var(--text); }

/* ===== Processor table (Privacy settings) ===== */
.processor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.processor-table th {
  text-align: left;
  padding: 8px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}
.processor-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.processor-table input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
}
.processor-table input:focus { border-color: var(--accent); outline: none; }
.processor-table .btn-icon { width: 28px; height: 28px; font-size: 13px; }

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.audit-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}
.audit-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.audit-table tr:last-child td { border-bottom: none; }
.audit-ts { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.audit-ref { color: var(--text-muted); font-family: 'SF Mono', Menlo, monospace; font-size: 11px; }
.audit-table a { color: var(--accent); text-decoration: none; }
.audit-table a:hover { text-decoration: underline; }

.shortcuts-hint {
  font-size: 16px;
  color: var(--text-muted);
  cursor: help;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.shortcuts-hint:hover { opacity: 1; }

/* ===== Contacts view ===== */
.contacts-view {
  grid-column: 2 / -1;
  padding: 32px 40px;
  overflow-y: auto;
}
.contacts-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.contacts-header h2 { font-size: 22px; font-weight: 700; margin: 0; }
.contacts-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  flex: 1;
  max-width: 320px;
}
.contacts-search-wrap input {
  border: none;
  background: none;
  outline: none;
  font-size: 14px;
  flex: 1;
  font-family: inherit;
}
.contacts-meta { font-size: 13px; color: var(--text-muted); }
.contacts-table-wrap { overflow-x: auto; }
.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.contacts-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.contacts-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.contacts-row { cursor: pointer; transition: background 0.1s; }
.contacts-row:hover { background: var(--bg); }
.contact-row-name { font-weight: 600; color: var(--text); }

.bulk-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.bulk-assign-select,
.bulk-tag-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  background: #fff;
  cursor: pointer;
}
.bulk-assign-select:focus,
.bulk-tag-select:focus { border-color: var(--accent); outline: none; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 0;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.modal-header .close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  line-height: 1;
  transition: all 0.15s;
}

.modal-header .close-btn:hover { color: var(--text); }

.modal-body { padding: 24px 28px 28px; }

.setting-group { margin-bottom: 28px; }

.setting-group h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -0.1px;
}

.setting-hint {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.setting-row label {
  font-size: 13px;
  font-weight: 500;
  width: 60px;
}

.setting-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  min-height: 120px;
  transition: border-color 0.2s;
}

.setting-textarea:focus { border-color: var(--accent); }

.setting-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: white;
  font-family: inherit;
}

/* Schedule editor */
.schedule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.schedule-row label {
  width: 55px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.schedule-row input[type="time"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}

.schedule-row input[type="time"]:disabled { opacity: 0.35; }
.schedule-row span { font-size: 12px; color: var(--text-muted); }

/* ===== KNOWLEDGE BASE ===== */
.kb-view {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: 380px 1fr;
  overflow: hidden;
}

.kb-list {
  border-right: 1px solid var(--border-light);
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kb-list-header {
  padding: 16px 20px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.kb-list-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-right: auto;
}

.kb-items { flex: 1; overflow-y: auto; padding: 4px 0; }

/* Category groups */
.kb-category-group {
  margin-bottom: 2px;
}
.kb-category-group.dragging { opacity: 0.4; }
.kb-category-group.drag-over { box-shadow: 0 -2px 0 0 var(--accent); }

.kb-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  cursor: pointer;
  user-select: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
  position: sticky;
  top: 0;
  z-index: 1;
}

.kb-category-header:hover { background: #eef0f4; }

.kb-category-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.kb-category-header:hover .kb-category-drag-handle { opacity: 1; }
.kb-category-drag-handle:active { cursor: grabbing; }

.kb-category-arrow {
  transition: transform 0.2s ease;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.kb-category-header.collapsed .kb-category-arrow {
  transform: rotate(-90deg);
}

.kb-category-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  flex: 1;
}

.kb-category-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--border-light);
  color: var(--text-secondary);
  padding: 1px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.kb-category-items {
  /* Container for items within a category */
}

/* Article items - card style */
.kb-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px 12px 20px;
  margin: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
}

.kb-item:hover { background: var(--bg); }
.kb-item.active { background: var(--accent-light); border-left-color: var(--accent); }
.kb-item.drag-over { border-top: 2px solid var(--accent); }
.kb-item.dragging { opacity: 0.4; }

.kb-item-drag-handle {
  flex-shrink: 0;
  color: var(--text-muted);
  cursor: grab;
  padding: 2px 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.kb-item:hover .kb-item-drag-handle { opacity: 1; }

.kb-item-content {
  flex: 1;
  min-width: 0;
}

.kb-item-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-item-url {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.kb-item-preview {
  font-size: 13px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.kb-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.kb-item-updated {
  font-size: 11px;
  color: var(--text-muted);
}

.kb-type-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  background: #f0e6ff;
  color: #7c3aed;
}

.kb-type-badge.source {
  background: #e6f4ff;
  color: #2563eb;
}

.kb-editor, .kb-empty-editor {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kb-editor-header {
  padding: 20px 24px 16px;
  background: white;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.kb-editor-header h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.kb-editor-body { padding: 24px; flex: 1; overflow-y: auto; }

.kb-field { margin-bottom: 20px; }

.kb-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.kb-field input, .kb-field select, .kb-field textarea {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: white;
}

.kb-field input:focus, .kb-field select:focus, .kb-field textarea:focus {
  border-color: var(--accent);
}

.kb-field textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.6;
}

/* KB Category row */
.kb-category-row {
  display: flex;
  gap: 8px;
}

.kb-category-row select {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--card);
  transition: border-color 0.2s;
}

.kb-category-row select:focus { border-color: var(--accent); }

.kb-category-row input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.kb-category-row input:focus { border-color: var(--accent); }

.kb-category-row .btn {
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

/* Quill editor overrides */
.kb-field .ql-toolbar {
  border: 1px solid var(--border-light);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg);
  font-family: inherit;
}

.kb-field .ql-container {
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  min-height: 200px;
  background: var(--card);
}

.kb-field .ql-container:focus-within {
  border-color: var(--accent);
}

.kb-field .ql-editor {
  min-height: 200px;
  line-height: 1.7;
  padding: 16px;
}

.kb-field .ql-editor.ql-blank::before {
  color: var(--text-muted);
  font-style: normal;
}

.kb-field .ql-snow .ql-stroke { stroke: var(--text-secondary); }
.kb-field .ql-snow .ql-fill { fill: var(--text-secondary); }
.kb-field .ql-snow .ql-picker { color: var(--text-secondary); }
.kb-field .ql-snow button:hover .ql-stroke { stroke: var(--accent); }
.kb-field .ql-snow button:hover .ql-fill { fill: var(--accent); }
.kb-field .ql-snow button.ql-active .ql-stroke { stroke: var(--accent); }
.kb-field .ql-snow button.ql-active .ql-fill { fill: var(--accent); }

.kb-field .ql-editor img {
  max-width: 100%;
  border-radius: 10px;
  margin: 8px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Marker/highlighter effect */
.ql-editor [style*="background-color"],
.help-detail-text [style*="background-color"],
.article-body [style*="background-color"] {
  padding: 2px 5px 1px 4px;
  margin: 0 -1px;
  border-radius: 3px 7px 4px 6px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* KB Tabs */
.kb-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
}

.kb-tab {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  transition: all 0.2s;
}

.kb-tab:hover { color: var(--text); }
.kb-tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* KB Feedback list */
.kb-feedback-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.fb-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

.fb-item:hover { background: var(--bg); }

.fb-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.fb-item-title {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.1px;
}

.fb-stats {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.fb-stat {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.fb-stat.positive { color: #1a8a4a; }
.fb-stat.negative { color: #c62828; }

.fb-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--bg);
  overflow: hidden;
  margin-bottom: 8px;
}

.fb-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(.25,.8,.25,1);
}

.fb-bar-fill.good { background: var(--success); }
.fb-bar-fill.bad { background: var(--danger); }

.fb-feedbacks {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fb-text {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 8px;
  line-height: 1.4;
  border-left: 3px solid var(--danger);
}

.kb-editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

/* ===== MESSAGE ATTACHMENTS ===== */
.msg-attachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.msg-att-img { display: block; border-radius: 8px; overflow: hidden; max-width: 240px; cursor: pointer; }
.msg-att-img img { width: 100%; height: auto; max-height: 200px; object-fit: cover; display: block; border-radius: 8px; transition: opacity 0.15s; }
.msg-att-img:hover img { opacity: 0.85; }
.msg-att-file {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: var(--bg-secondary); border-radius: 8px;
  text-decoration: none; color: var(--text-primary); font-size: 13px;
  border: 1px solid var(--border); transition: background 0.15s;
}
.msg-att-file:hover { background: var(--border); }
.msg-att-icon { font-size: 16px; }
.msg-att-name { font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-att-size { color: var(--text-secondary); font-size: 12px; }

/* ===== REPLY ATTACHMENTS ===== */
.reply-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 6px; }
.reply-attachments:empty { display: none; }
.reply-att-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; background: var(--bg-secondary); border-radius: 6px;
  font-size: 12px; color: var(--text-primary); border: 1px solid var(--border);
}
.reply-att-chip.uploading { opacity: 0.6; }
.reply-att-chip.error { border-color: var(--danger); color: var(--danger); }
.reply-att-chip button {
  background: none; border: none; cursor: pointer; font-size: 14px;
  color: var(--text-secondary); padding: 0 2px; line-height: 1;
}
.reply-att-chip button:hover { color: var(--danger); }

.btn-icon {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; font-size: 16px; line-height: 1;
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg-secondary); }

/* ===== SETTINGS VIEW ===== */
.settings-view {
  grid-column: 2 / -1;
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ===== AI CONTROL CENTER ===== */
/* Full-width view shown when the user switches into AI → Wissen / Einstellungen.
   For the "Unterhaltungen" sub-pane, aiView stays hidden and the normal
   conv-list + conv-detail layout is reused (same as Inbox). */
.ai-view {
  grid-column: 2 / -1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.ai-view-header {
  padding: 36px 48px 0;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  flex-shrink: 0;
}
.ai-view-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.ai-view-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.3px;
}
/* Unobtrusive stat strip next to the AI title — not a dashboard of cards,
   just a horizontal readout so the user can glance at today's Bot activity
   without clicking into stats. */
.ai-metrics {
  display: flex;
  gap: 28px;
  align-items: center;
}
.ai-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ai-metric-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.ai-metric-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Pending-badge neben Wissen-Sub-Tab (wie der graue navBadgeAi, aber kleiner) */
.ai-pane-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 8px;
  background: var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ai-view-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px 64px;
}
.ai-pane-content {
  max-width: 900px;
  margin: 0 auto;
}
/* Sub-tab bar shared between conv-list-header (when in AI/Unterhaltungen) and
   ai-view-header (when in AI/Wissen or AI/Einstellungen). Sync via JS. */
.ai-pane-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  margin: 0 0 -1px;
  width: fit-content;
  border: 1px solid var(--border);
}
.ai-view-header .ai-pane-tabs {
  margin-bottom: 0;
  transform: translateY(1px);
}
.ai-pane-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.15s ease;
  font-family: inherit;
}
.ai-pane-tab:hover:not(.active) {
  color: var(--text);
  background: rgba(0, 0, 0, 0.03);
}
.ai-pane-tab.active {
  background: #ffffff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
/* In the narrow conv-list-header, the sub-tabs need to shrink */
.conv-list-header .ai-pane-tabs {
  width: 100%;
  margin: 10px 0 12px;
  box-sizing: border-box;
}
.conv-list-header .ai-pane-tab {
  flex: 1;
  padding: 7px 6px;
  font-size: 12px;
  text-align: center;
}
@media (max-width: 900px) {
  .ai-view-header { padding: 20px 20px 0; }
  .ai-view-body { padding: 20px; }
  .ai-view-header h1 { font-size: 22px; }
  .ai-view-title-row { gap: 16px; margin-bottom: 16px; }
  .ai-metrics { gap: 20px; width: 100%; justify-content: space-between; }
  .ai-metric-value { font-size: 16px; }
}

.settings-nav {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 28px 12px 28px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
  overflow-y: auto;
}

.settings-nav h2 {
  font-size: 16px;
  font-weight: 700;
  padding: 0 10px 18px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.settings-nav-group {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 14px 12px 5px;
  user-select: none;
}
.settings-nav-group:first-of-type { padding-top: 0; }

.settings-nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.settings-nav-item:hover { background: var(--bg); color: var(--text); }
.settings-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* Coming Soon Card */
.setting-card.coming-soon {
  text-align: center;
  padding: 48px 24px;
  background: linear-gradient(180deg, var(--bg) 0%, #ffffff 100%);
  border: 1px dashed var(--border);
}
.coming-soon-icon { font-size: 36px; margin-bottom: 12px; }
.coming-soon-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.coming-soon-text { font-size: 13px; color: var(--text-secondary); }

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 40px 60px;
  max-width: 720px;
}

.settings-section { display: none; }
.settings-section.active { display: block; }

.settings-page-header { margin-bottom: 28px; }
.settings-page-header h3 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.settings-page-header p { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }

.setting-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.setting-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.setting-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}
.setting-card-help {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 14px;
  line-height: 1.5;
}
.setting-card-help code {
  font-family: 'SF Mono', Menlo, monospace;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.setting-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ===== TEAM MANAGEMENT ===== */
.team-list { margin-bottom: 12px; }
.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.team-row:last-child { border-bottom: none; }
.team-info { display: flex; align-items: center; gap: 10px; }
.team-name { font-weight: 600; font-size: 14px; }
.team-email { font-size: 12px; color: var(--text-secondary); }
.team-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-tertiary, #ccc); flex-shrink: 0;
}
.team-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.team-actions { display: flex; align-items: center; gap: 8px; }
.team-role-select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; font-family: inherit; background: var(--bg-secondary);
  cursor: pointer;
}
.team-role-select:disabled { opacity: 0.5; cursor: default; }
.team-role-label {
  font-size: 12px; color: var(--text-secondary);
  padding: 4px 8px; background: var(--bg-secondary); border-radius: 6px;
}
.team-remove-btn {
  width: 24px; height: 24px; border-radius: 6px;
  border: none; background: none; color: var(--text-secondary);
  font-size: 18px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.15s;
}
.team-remove-btn:hover { background: #fef2f2; color: var(--danger); }
.team-invite-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.team-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; flex: 1; min-width: 120px;
}
.team-input:focus { outline: none; border-color: var(--primary); }
.empty-hint { color: var(--text-secondary); font-size: 13px; padding: 8px 0; }

/* ===== SNIPPET REVIEW ===== */
.snippet-list { display: flex; flex-direction: column; gap: 12px; }
.snippet-card {
  padding: 16px; background: var(--bg); border-radius: 10px;
  border: 1px solid var(--border);
}
.snippet-q { font-size: 14px; margin-bottom: 8px; line-height: 1.5; }
.snippet-a { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.snippet-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.snippet-actions { display: flex; gap: 8px; }
.embed-status { font-size: 13px; color: var(--text-secondary); margin-left: 12px; }

/* ===== FEATURE REQUESTS ===== */
.features-view {
  grid-column: 2 / -1;
  padding: 28px 40px;
  overflow-y: auto;
}
.features-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.features-header h2 { font-size: 20px; font-weight: 700; flex: 1; }
.fr-table { width: 100%; border-collapse: collapse; }
.fr-table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.fr-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
.fr-table tr:hover { background: rgba(0,0,0,0.01); }
.fr-desc { font-size: 12px; color: var(--text-secondary); }
.fr-status {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; font-family: inherit; background: var(--bg);
}
.fr-votes { font-weight: 700; text-align: center; }
.fr-date { color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.fr-title-cell { cursor: pointer; transition: color 0.15s; }
.fr-title-cell:hover { color: var(--accent); }
.fr-actions { text-align: right; width: 48px; }
.fr-actions .btn-icon {
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fr-actions .btn-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: #fff;
}

/* ===== ASSIGNMENT ===== */
.assign-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg-secondary);
  cursor: pointer;
}
.channel-badge.assigned {
  background: #dbeafe;
  color: #1d4ed8;
}

/* ===== BRANDING SETTINGS ===== */
.branding-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.branding-row:last-child { margin-bottom: 0; }
.branding-row label {
  font-size: 13px;
  font-weight: 500;
  width: 100px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.branding-input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.branding-input:focus { border-color: var(--accent); }
.color-pick {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-pick input[type="color"] {
  width: 40px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: none;
}
.color-text {
  width: 90px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: monospace;
  outline: none;
}
.color-text:focus { border-color: var(--accent); }
.position-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.pos-btn {
  padding: 8px 20px;
  border: none;
  background: none;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.pos-btn + .pos-btn { border-left: 1px solid var(--border); }
.pos-btn.active { background: var(--accent-light); color: var(--accent); }
.pos-btn:hover:not(.active) { background: var(--bg); }

/* ===== SURVEYS VIEW ===== */
.surveys-view {
  grid-column: 2 / -1;
  padding: 28px 40px;
  overflow-y: auto;
}
.surveys-header { margin-bottom: 24px; }
.surveys-header h2 { font-size: 20px; font-weight: 700; }

.surveys-stats {
  display: flex; gap: 16px; margin-bottom: 28px;
}
.survey-stat-card {
  flex: 1; background: white; border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; text-align: center;
}
.survey-stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.survey-stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.dist-chart { max-width: 400px; }
.dist-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dist-emoji { font-size: 20px; width: 28px; text-align: center; }
.dist-bar-bg { flex: 1; height: 24px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.dist-bar { height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.4s ease; min-width: 2px; }
.dist-count { font-size: 13px; color: var(--text-secondary); width: 30px; text-align: right; }

.survey-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border-light);
}
.survey-emoji { font-size: 22px; }
.survey-row-info { flex: 1; min-width: 0; }
.survey-row-name { font-size: 14px; font-weight: 500; }
.survey-row-feedback { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.survey-row-time { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

.csat-home-score { display: flex; align-items: baseline; gap: 4px; }
.csat-home-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.csat-home-label { font-size: 13px; color: var(--text-secondary); }

/* ===== NEWS / RELEASE NOTES ===== */
.news-view {
  grid-column: 2 / -1;
  padding: 28px 40px;
  overflow-y: auto;
}
.news-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 24px;
}
.news-header h2 { font-size: 20px; font-weight: 700; }
.news-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; max-width: 540px; }
.news-header-actions { display: flex; gap: 10px; flex-shrink: 0; }

.news-list { display: flex; flex-direction: column; gap: 14px; }

.news-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  transition: all 0.15s;
}
.news-card:hover { border-color: rgba(240,4,156,0.2); box-shadow: 0 2px 12px rgba(0,0,0,0.04); }

.news-card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; font-size: 12px;
}
.news-cat-badge {
  padding: 4px 10px; border-radius: 6px; font-weight: 600; font-size: 11px;
}
.news-status { font-weight: 500; font-size: 11px; }
.news-status-published { color: #10b981; }
.news-status-draft { color: var(--text-secondary); }
.news-date { color: var(--text-secondary); margin-left: auto; }

.news-card-actions { display: flex; gap: 4px; }
.news-edit-btn, .news-delete-btn {
  width: 28px; height: 28px; border: none; background: var(--bg);
  border-radius: 6px; cursor: pointer; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.news-edit-btn:hover { background: var(--accent-light); color: var(--accent); }
.news-delete-btn:hover { background: #fee; color: #c00; }

.news-card-title {
  font-size: 16px; font-weight: 600; color: var(--text);
  margin: 0 0 8px;
}
.news-card-content {
  font-size: 13px; color: var(--text-secondary); line-height: 1.5;
}
.news-card-content p { margin: 0; }
.news-card-content p + p { margin-top: 8px; }

/* News editor modal */
.news-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.news-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.news-modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 640px;
  max-width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: newsModalIn 0.2s ease;
}
@keyframes newsModalIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.news-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.news-modal-header h3 { font-size: 17px; font-weight: 600; }
.news-modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--text-secondary); width: 32px; height: 32px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.news-modal-close:hover { background: var(--bg); color: var(--text); }

.news-modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.news-field-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.5px;
}
.news-field-label + .news-field-label { margin-top: 16px; }

.news-category-tabs {
  display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap;
}
.news-cat-btn {
  padding: 8px 14px; border: 1px solid var(--border);
  border-radius: 8px; background: white; cursor: pointer;
  font-size: 13px; font-family: inherit; transition: all 0.15s;
}
.news-cat-btn:hover { border-color: var(--accent); }
.news-cat-btn.active {
  background: var(--accent); color: white; border-color: var(--accent);
}

.news-input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit;
  outline: none; transition: border-color 0.15s; margin-bottom: 16px;
}
.news-input:focus { border-color: var(--accent); }

.news-editor { background: white; }
.news-editor .ql-toolbar {
  border: 1px solid var(--border); border-radius: 10px 10px 0 0;
  border-bottom: none;
}
.news-editor .ql-container {
  border: 1px solid var(--border); border-radius: 0 0 10px 10px;
  font-family: inherit; font-size: 14px; min-height: 180px;
}

.news-modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-top: 1px solid var(--border);
}
.news-publish-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer;
}
.news-publish-toggle input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.news-modal-actions { display: flex; gap: 8px; }

/* ===== WELCOME FLOW EDITOR ===== */
.welcome-flow-editor { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.wf-empty { color: var(--text-secondary); font-size: 13px; padding: 16px; text-align: center; background: var(--bg); border-radius: 8px; }

.wf-step {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}
.wf-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.wf-step-body { flex: 1; min-width: 0; }
.wf-step-label { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.wf-step-input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  resize: vertical; outline: none; background: white;
}
.wf-step-input:focus { border-color: var(--accent); }
.wf-step-delay { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.wf-step-delay input { width: 60px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 16px; }
.wf-step-info { font-size: 12px; color: var(--text-secondary); }

.wf-step-actions { display: flex; flex-direction: column; gap: 4px; }
.wf-btn {
  width: 26px; height: 26px; border: 1px solid var(--border);
  background: white; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-secondary); padding: 0;
}
.wf-btn:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.wf-btn-del:hover { background: #fee; border-color: #f88; color: #c00; }

.welcome-flow-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ===== HOME MODULES EDITOR ===== */
.modules-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-width: 480px;
}

.module-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: grab;
  transition: all 0.15s;
  user-select: none;
}
.module-row:hover { border-color: rgba(240,4,156,0.3); box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.module-row.dragging { opacity: 0.5; cursor: grabbing; }
.module-row.drag-over { border-color: var(--accent); background: var(--accent-light); }
.module-row.module-hidden { opacity: 0.5; background: var(--bg); }

.module-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  display: flex;
  align-items: center;
}
.module-row:hover .module-drag-handle { color: var(--accent); }

.module-icon {
  font-size: 20px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 8px;
  flex-shrink: 0;
}
.module-info { flex: 1; min-width: 0; }
.module-label { font-size: 14px; font-weight: 600; color: var(--text); }
.module-desc { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

.module-toggle {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
  flex-shrink: 0;
}
.module-toggle:hover { background: var(--accent-light); color: var(--accent); }
.module-row.module-hidden .module-toggle { color: var(--text-muted); }

/* Custom link config */
.customlink-config {
  padding: 10px 16px 14px 48px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.cl-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.cl-input:focus { border-color: var(--accent); }
.cl-input::placeholder { color: var(--text-muted); }
.cl-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.cl-checkbox input { cursor: pointer; }

/* ===== PROFILE AVATAR ===== */
.profile-avatar-row {
  display: flex; align-items: center; gap: 18px; margin-top: 8px;
}
.profile-avatar-preview {
  width: 72px; height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.profile-avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-avatar-preview.initial { background: var(--accent); }
.profile-avatar-preview.initial span {
  color: white; font-size: 24px; font-weight: 700; letter-spacing: -0.5px;
}
.profile-avatar-actions { display: flex; gap: 8px; }

/* ===== CRAWLED WEBSITES ===== */
.websites-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.website-row {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: flex-start;
}
.website-info { flex: 1; min-width: 0; }
.website-url {
  font-size: 14px; font-weight: 600; color: var(--text);
  word-break: break-all; margin-bottom: 4px;
}
.website-meta {
  font-size: 12px; color: var(--text-secondary); line-height: 1.5;
}
.website-status { font-weight: 600; }
.website-error {
  margin-top: 6px; padding: 6px 10px;
  background: #fee; color: #c00;
  border-radius: 6px; font-size: 12px;
}
.website-excludes {
  margin-top: 6px; font-size: 11px; color: var(--text-muted);
  padding: 4px 8px; background: var(--bg); border-radius: 6px; display: inline-block;
}
.website-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.website-actions .btn { padding: 6px 12px; font-size: 12px; }

/* Pages tabs */
.pages-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.pages-tab {
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pages-tab:hover { color: var(--text); }
.pages-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.pages-tab-count {
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 8px;
  min-width: 20px;
  text-align: center;
}
.pages-tab.active .pages-tab-count {
  background: var(--accent-light);
  color: var(--accent);
}

/* Compact pages list (Gleap-style) */
.pages-list-compact {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: white;
}

.page-row {
  border-bottom: 1px solid var(--border);
}
.page-row:last-child { border-bottom: none; }

.page-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.page-row-head:hover { background: var(--bg); }

.page-row-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.page-row-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 8px;
  background: var(--bg);
  color: var(--text-secondary);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.page-row-count:not(:empty)[data-count]:not([data-count="0"]) {
  background: var(--accent-light);
  color: var(--accent);
}

.page-row-url {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  font-family: 'SFMono-Regular', Consolas, monospace;
}

.page-row-exclude {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.page-row-exclude:hover { background: #fee; color: #dc2626; }

.page-row-body {
  padding: 4px 14px 16px 54px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.page-row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.page-row-content {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.page-row-actions {
  margin-top: 8px;
  font-size: 11px;
}
.page-row-actions a {
  color: var(--accent);
  text-decoration: none;
}
.page-row-actions a:hover { text-decoration: underline; }

/* Mobile back button — hidden on desktop */
.mobile-back-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
  align-items: center;
  justify-content: center;
}
.mobile-back-btn:hover { background: var(--bg); }
@media (max-width: 720px) {
  .mobile-back-btn { display: inline-flex; }
}

/* ===== Responsive: Tablet (≤ 1100px) — collapse the contact sidebar inside conv detail ===== */
@media (max-width: 1100px) {
  .contact-sidebar { display: none; }
}

/* ===== Responsive: Tablet (≤ 900px) — collapse main nav to icons-only ===== */
@media (max-width: 900px) {
  .app { grid-template-columns: 64px 320px 1fr; }
  .nav-title,
  .nav-item span,
  .avail-label,
  .nav-agent-info { display: none; }
  .nav-header { justify-content: center; padding: 20px 0 16px; }
}

/* ===== Responsive: Mobile (≤ 720px) — single-column stack with view-aware hiding ===== */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr !important;
    grid-template-rows: 56px 1fr;
  }
  /* All child views have desktop-hardcoded `grid-column: 2 / -1` — override to span full row */
  .stats-view,
  .kb-view,
  .features-view,
  .surveys-view,
  .news-view,
  .contacts-view,
  .settings-view,
  .conv-list,
  .conv-detail-wrapper {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
  }
  .contacts-view { padding: 16px; }
  .nav { grid-column: 1 / -1 !important; grid-row: 1 !important; }
  /* Nav becomes a top bar */
  .nav,
  .main-nav {
    flex-direction: row !important;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 6px 8px;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    height: 56px;
    width: 100%;
  }
  .nav-header { display: none !important; }
  .nav-section {
    display: flex;
    flex-direction: row;
    gap: 4px;
    flex-shrink: 0;
  }
  .nav-item {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    width: auto !important;
    padding: 8px 12px !important;
    border-radius: 8px;
    white-space: nowrap;
    justify-content: center;
  }
  .nav-item svg { flex-shrink: 0; }
  .nav-footer { display: none !important; }
  .nav-bottom { display: none !important; }

  /* Conv list full-width */
  .conv-list { width: 100%; max-width: 100%; }
  .conv-detail-wrapper { width: 100%; }

  /* When a conversation is open on mobile, hide the list and show only the detail */
  .app.mobile-conv-open .conv-list { display: none; }
  .app.mobile-conv-open .conv-detail-wrapper { display: flex; }

  /* When no conversation is open, hide detail */
  .app:not(.mobile-conv-open) .conv-detail-wrapper { display: none; }

  /* Overview mobile: stack the strips */
  .stats-view { padding: 32px 20px 56px; }
  .status-strip { grid-template-columns: 1fr 1fr; padding: 0; }
  .status-col {
    border-right: 1px solid rgba(0,0,0,0.06);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 24px 20px;
  }
  .status-col:nth-child(2) { border-right: none; }
  .status-col:nth-child(3), .status-col:nth-child(4) { border-bottom: none; }
  .status-col:nth-child(4) { border-right: none; }
  .overview-main { grid-template-columns: 1fr; }
  .detail-strip { grid-template-columns: 1fr 1fr; padding: 0; }
  .detail-cell {
    padding: 24px 20px;
    border-right: 1px solid rgba(0,0,0,0.06);
    border-bottom: 1px solid rgba(0,0,0,0.06);
  }
  .detail-cell:nth-child(2) { border-right: none; }
  .detail-cell:nth-child(3), .detail-cell:nth-child(4) { border-bottom: none; }
  .detail-cell:nth-child(4) { border-right: none; }
  .activity-metrics { grid-template-columns: 1fr 1fr; }
  .overview-lists { grid-template-columns: 1fr; }
  .heatmap-grid { font-size: 8px; }
  .heatmap-grid .heatmap-cell { min-height: 12px; }

  /* Settings: stack nav on top */
  .settings-view { flex-direction: column; }
  .settings-nav {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-direction: row;
    padding: 8px;
    gap: 4px;
  }
  .settings-nav-group { display: none; }
  .settings-nav-item {
    flex-shrink: 0;
    width: auto;
    padding: 8px 12px;
    font-size: 13px;
  }
  .settings-content { padding: 16px; }

  /* Conv detail header: stack the controls */
  .conv-detail-header {
    flex-wrap: wrap;
    gap: 6px;
  }
  /* Reply actions: wrap to multiple rows on mobile */
  .reply-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE LAYOUT (< 768px)
   Single column, nav as full-screen overlay, one view at a time.
   ═══════════════════════════════════════════════════════════════════════ */

.mobile-menu-btn {
  display: none; /* hidden on desktop */
}

@media (max-width: 768px) {
  /* ─── Grid → single column ─── */
  .app,
  .app.nav-collapsed {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr;
  }

  /* ─── Mobile hamburger button ─── */
  .mobile-menu-btn {
    display: grid;
    place-items: center;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2500;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--ix-white);
    border: 1px solid var(--ix-line-2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    color: var(--ix-ink);
    cursor: pointer;
  }
  .mobile-menu-btn svg { width: 18px; height: 18px; }

  /* ─── Nav: hidden by default on mobile.
       When NOT collapsed (user tapped hamburger), show as fullscreen overlay. ─── */
  .app.nav-collapsed .nav {
    display: none !important;
  }
  .app:not(.nav-collapsed) .nav {
    position: fixed;
    inset: 0;
    z-index: 2400;
    width: 100%;
    max-width: 300px;
    background: var(--ix-white);
    box-shadow: 8px 0 40px rgba(0,0,0,0.15);
    display: flex !important;
    overflow-y: auto;
    padding: 60px 16px 16px;
  }
  /* Backdrop behind expanded nav */
  .app:not(.nav-collapsed)::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 2399;
    background: rgba(0, 0, 0, 0.3);
  }
  /* When nav is expanded, show labels (undo collapsed styling) */
  .app:not(.nav-collapsed) .nav-title,
  .app:not(.nav-collapsed) .nav-item span,
  .app:not(.nav-collapsed) .nav-agent-info,
  .app:not(.nav-collapsed) .nav-footer-text { display: unset !important; }
  .app:not(.nav-collapsed) .nav-item {
    width: auto !important;
    height: auto !important;
    justify-content: flex-start !important;
    padding: 9px 12px !important;
    gap: 10px !important;
  }
  .app:not(.nav-collapsed) .nav-section { padding: 0 8px !important; }
  .app:not(.nav-collapsed) .nav-collapse-btn { display: none; }
  .app:not(.nav-collapsed) .nav-header {
    justify-content: flex-start !important;
    padding: 4px 8px 16px !important;
    gap: 10px !important;
  }
  .app:not(.nav-collapsed) .nav-footer {
    padding: 12px 8px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
  }
  .app:not(.nav-collapsed) .nav-footer-item {
    width: auto !important;
    height: auto !important;
    display: flex !important;
    gap: 10px !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
  }
  .app:not(.nav-collapsed) .nav-agent { justify-content: flex-start !important; }

  /* ─── Conv list: full width when on inbox view ─── */
  .conv-list {
    border-right: none !important;
    width: 100% !important;
  }

  /* ─── Conv detail wrapper: hidden on mobile unless a conversation is
       actively open. When no conversation is selected, the user sees
       the conv-list full-width instead of the "Wähle eine Unterhaltung"
       empty state. ─── */
  .conv-detail-wrapper {
    display: none !important;
  }
  .app.mobile-conv-open .conv-detail-wrapper {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--ix-ivory);
  }
  /* ─── Contact sidebar: hide on mobile ─── */
  .contact-sidebar {
    display: none !important;
  }

  /* ─── Full-width views (stats, settings, KB, etc.) ─── */
  .stats-view,
  .settings-view,
  .ai-view,
  .kb-view,
  .contacts-view,
  .features-view,
  .surveys-view,
  .news-view {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }

  /* ─── Stats view: tighter padding on mobile ─── */
  .stats-view {
    padding: 24px 16px 40px !important;
  }
  .overview-header { margin-bottom: 20px !important; }
  .overview-header h1 { font-size: 22px !important; }
  .overview-main { grid-template-columns: 1fr !important; }
  .overview-lists { grid-template-columns: 1fr !important; }

  /* ─── Reply box: tighter on mobile ─── */
  .reply-box {
    padding: 0 12px 12px !important;
  }
  .reply-box textarea {
    padding: 12px 80px 12px 14px !important;
    font-size: 16px !important; /* prevents iOS zoom on focus */
  }

  /* ─── Messages: less padding ─── */
  .conv-messages {
    padding: 20px 14px 12px !important;
  }
  .msg { max-width: 85% !important; }

  /* ─── Settings view: single column nav ─── */
  .settings-view {
    flex-direction: column !important;
  }
  .settings-nav {
    width: 100% !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .settings-content {
    flex: 1 !important;
    overflow-y: auto !important;
  }

  /* ─── Conv detail header: add padding for hamburger button ─── */
  .conv-detail-header {
    padding-left: 60px !important;
  }

  /* ─── Mein-Tag mobile header padding ─── */
  .stats-view {
    padding-top: 60px !important;
  }

  /* ─── Prevent iOS Safari auto-zoom on input focus ─── */
  .conv-search-wrap input {
    font-size: 16px;
  }
}
