
/* ═══════════════════════════════════════════════════════════════
   APEX OBSIDIAN DESIGN SYSTEM
   Dark mode default + light mode toggle + brand customizable
═══════════════════════════════════════════════════════════════ */

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

:root {
  /* ── Layout ── */
  --sidebar: 240px;
  --header:  56px;
  --r:       10px;
  --r-sm:    6px;
  --r-lg:    16px;
  --trans:   140ms cubic-bezier(.4,0,.2,1);

  /* ── Typography ── */
  --font-h: 'Inter', sans-serif;
  --font:   'Inter', sans-serif;
  --font-m: 'JetBrains Mono', monospace;

  /* ── Brand accent (overrideable per tenant) ── */
  --accent:      #7c3aed;
  --accent2:     #a78bfa;
  --accent3:     #ddd6fe;
  --accent-glow: rgba(124,58,237,.25);
  --accent-text: #ffffff;

  /* ── Semantic colors ── */
  --green:  #10b981;
  --green2: rgba(16,185,129,.15);
  --red:    #ef4444;
  --red2:   rgba(239,68,68,.15);
  --amber:  #f59e0b;
  --amber2: rgba(245,158,11,.15);
  --blue:   #3b82f6;
  --blue2:  rgba(59,130,246,.15);
  --pink:   #ec4899;

  /* ── DARK MODE (default = Obsidian) ── */
  --bg:        #0a0a0a;
  --bg2:       #0d0d0d;
  --surface:   #111111;
  --surface2:  #171717;
  --surface3:  #1f1f1f;
  --surface4:  #262626;
  --border:    rgba(255,255,255,.07);
  --border2:   rgba(255,255,255,.12);
  --text:      #fafafa;
  --text2:     #d4d4d4;
  --muted:     #737373;
  --muted2:    #a3a3a3;

  /* ── Gradients ── */
  --grad-accent: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  --grad-green:  linear-gradient(135deg, #10b981 0%, #059669 100%);
  --grad-surface:linear-gradient(180deg, #1a1a1a 0%, #111111 100%);

  /* ── Shadows ── */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.5);
  --shadow-md:  0 4px 12px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.4);
  --shadow-lg:  0 20px 40px rgba(0,0,0,.6), 0 8px 20px rgba(0,0,0,.5);
  --shadow-accent: 0 0 20px rgba(124,58,237,.3);

  /* ── Glass effect ── */
  --glass-bg:     rgba(17,17,17,.85);
  --glass-border: rgba(255,255,255,.08);
}

/* ── LIGHT MODE ── */
[data-theme="light"] {
  --bg:        #f5f5f5;
  --bg2:       #fafafa;
  --surface:   #ffffff;
  --surface2:  #f9f9f9;
  --surface3:  #f0f0f0;
  --surface4:  #e8e8e8;
  --border:    rgba(0,0,0,.07);
  --border2:   rgba(0,0,0,.12);
  --text:      #0a0a0a;
  --text2:     #262626;
  --muted:     #737373;
  --muted2:    #525252;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg:  0 20px 40px rgba(0,0,0,.1), 0 8px 20px rgba(0,0,0,.08);
  --shadow-accent: 0 0 20px rgba(124,58,237,.2);

  --glass-bg:     rgba(255,255,255,.9);
  --glass-border: rgba(0,0,0,.08);
  --grad-surface: linear-gradient(180deg, #ffffff 0%, #f9f9f9 100%);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background var(--trans), color var(--trans);
}

/* ── LAYOUT ────────────────────────────────── */
#app { display: flex; min-height: 100vh; }
#app.auth { justify-content: center; align-items: center; }

#sidebar {
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 80;
}

#main {
  margin-left: var(--sidebar);
  flex: 1;
  display: flex;
  flex-direction: column;
}

#topbar {
  height: var(--header);
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  transition: background var(--trans);
}

#view {
  padding: 24px 28px;
  flex: 1;
  min-height: calc(100vh - var(--header));
}

/* ── SIDEBAR ───────────────────────────────── */
#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.s-logo {
  height: var(--header);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-h);
  font-weight: 700; font-size: 16px;
  letter-spacing: -0.5px;
  color: var(--text);
  flex-shrink: 0;
}
.s-logo-mark {
  width: 28px; height: 28px;
  background: var(--grad-accent);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800; color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
  flex-shrink: 0;
}

.s-section {
  font-family: var(--font-m);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 18px 16px 5px;
  font-weight: 500;
}

.nav {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px 7px 12px;
  margin: 1px 8px;
  cursor: pointer;
  color: var(--muted2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--trans);
  border: none; background: none;
  width: calc(100% - 16px); text-align: left;
  position: relative;
  border-radius: 8px;
}
.nav:hover { color: var(--text); background: var(--surface3); }
.nav.on {
  color: var(--text);
  background: var(--surface3);
  font-weight: 600;
}
.nav.on::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  height: 60%; width: 3px;
  background: var(--grad-accent);
  border-radius: 0 3px 3px 0;
}
.nav svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .8; }
.nav.on svg { opacity: 1; }

.s-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.u-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  background: var(--surface2);
  margin-bottom: 6px;
}
.u-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.u-email { font-size: 11.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-role-line { margin-top: 1px; }

/* ── TOPBAR ────────────────────────────────── */
.tb-l { display: flex; align-items: center; gap: 10px; }
.tb-r { display: flex; align-items: center; gap: 6px; }
.ctx-badge {
  font-size: 11.5px; font-family: var(--font-m);
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(107,92,255,.13);
  border: 1px solid rgba(107,92,255,.28);
  color: var(--accent2);
}
.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--muted2);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--trans);
  font-size: 14px;
}
.icon-btn:hover { color: var(--text); border-color: var(--border2); background: var(--surface3); }

/* ── STATS ─────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--trans), transform var(--trans), box-shadow var(--trans);
  cursor: default;
}
.stat:hover {
  border-color: var(--border2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.stat::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-accent);
  opacity: 0;
  transition: opacity var(--trans);
}
.stat:hover::after { opacity: 1; }
.stat-l { font-size: 11px; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
.stat-v { font-family: var(--font-h); font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.stat-s { font-size: 11.5px; color: var(--muted2); margin-top: 6px; }

/* ── PAGE ──────────────────────────────────── */
.ph { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.pt { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; line-height: 1.2; }
.ps { color: var(--muted2); font-size: 13px; margin-top: 3px; font-weight: 400; }

.section-title {
  font-size: 13px; font-weight: 600;
  margin-bottom: 14px;
  color: var(--text2);
  letter-spacing: -.01em;
}

/* ── CARDS ─────────────────────────────────── */
.card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card + .card, .card + .mb { margin-top: 14px; }
.mb { margin-bottom: 14px; }

.two-col { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── TABLE ─────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 14px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .03em;
  color: var(--muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface3); }

/* ── BADGES ────────────────────────────────── */
.b {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-family: var(--font-m);
  padding: 2px 8px; border-radius: 99px;
  font-weight: 600; white-space: nowrap;
}
.b-purple { background: rgba(124,58,237,.15); color: var(--accent2); border: 1px solid rgba(124,58,237,.25); }
.b-blue   { background: var(--blue2);   color: var(--blue);   border: 1px solid rgba(59,130,246,.25); }
.b-green  { background: var(--green2);  color: var(--green);  border: 1px solid rgba(16,185,129,.25); }
.b-amber  { background: var(--amber2);  color: var(--amber);  border: 1px solid rgba(245,158,11,.25); }
.b-red    { background: rgba(232,85,85,.12);  color: var(--red);     border: 1px solid rgba(232,85,85,.25); }
.b-gray   { background: rgba(92,92,122,.14);  color: var(--muted2);  border: 1px solid rgba(92,92,122,.22); }
.b-pink   { background: rgba(232,85,153,.12); color: var(--pink);    border: 1px solid rgba(232,85,153,.25); }

/* ── BUTTONS ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer; border: none;
  transition: all var(--trans);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: -.01em;
  text-decoration: none;
}
.btn-p  { background: var(--grad-accent); color: #fff; box-shadow: 0 2px 8px var(--accent-glow); }
.btn-p:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-p:active { transform: translateY(0); }
.btn-s  { background: var(--surface3); border: 1px solid var(--border2); color: var(--text2); }
.btn-s:hover { background: var(--surface4); }
.btn-d  { background: var(--red2); border: 1px solid rgba(239,68,68,.3); color: var(--red); }
.btn-d:hover { background: rgba(239,68,68,.2); }
.btn-g  { background: transparent; color: var(--muted2); border: 1px solid transparent; }
.btn-g:hover { color: var(--text); background: var(--surface3); border-color: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 11.5px; border-radius: 6px; }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.fw { width: 100%; justify-content: center; }

/* ── FORMS ─────────────────────────────────── */
.fg { margin-bottom: 15px; }
.fl { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.fi, .fs {
  width: 100%; background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  padding: 9px 12px; font-size: 13px;
  font-family: var(--font); outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
  appearance: none;
}
.fi:focus, .fs:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.fi::placeholder { color: var(--muted); }
.fs { cursor: pointer; }
.fs option { background: var(--surface2); }

/* ── AUTH ──────────────────────────────────── */
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
}
.auth-logo { display: flex; align-items: center; gap: 9px; margin-bottom: 28px; font-family: var(--font-h); font-weight: 800; font-size: 18px; }
.auth-logo-m { width: 30px; height: 30px; background: var(--accent); border-radius: 8px; display: grid; place-items: center; font-size: 14px; font-weight: 800; color: #fff; }
.auth-title { font-family: var(--font-h); font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { color: var(--muted2); font-size: 12.5px; margin-bottom: 24px; }
.auth-link { color: var(--accent2); cursor: pointer; font-size: 12.5px; }
.auth-link:hover { text-decoration: underline; }

/* ── ALERT ─────────────────────────────────── */
.alert { padding: 9px 12px; border-radius: var(--r-sm); font-size: 12.5px; margin-bottom: 14px; display: none; }
.alert.on { display: flex; align-items: flex-start; gap: 7px; }
.alert-e { background: rgba(232,85,85,.1); border: 1px solid rgba(232,85,85,.28); color: var(--red); }
.alert-s { background: rgba(29,184,145,.1); border: 1px solid rgba(29,184,145,.28); color: var(--green); }
.alert-i { background: rgba(74,158,255,.1); border: 1px solid rgba(74,158,255,.28); color: var(--blue); }

/* ── MODAL ─────────────────────────────────── */
.m-ov {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 999;
  display: none;
  place-items: center;
  backdrop-filter: blur(3px);
}
.m-ov.on { display: grid; }

/* Overlay created by openModal() */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 20, 0.78);
  backdrop-filter: blur(6px);
  padding: 16px;
  box-sizing: border-box;
  overflow-y: auto;
}
#modal-overlay.show { display: flex; }

/* Single merged .modal rule — all properties in one place */
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 26px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  position: relative;
  box-sizing: border-box;
  flex-shrink: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.m-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.m-title { font-family: var(--font-h); font-size: 17px; font-weight: 700; }
.m-x { cursor: pointer; background: none; border: none; color: var(--muted2); font-size: 17px; line-height: 1; }
.m-x:hover { color: var(--text); }

/* ── EMPTY ─────────────────────────────────── */
.empty {
  text-align: center; padding: 48px 20px;
  color: var(--muted2);
}
.empty-ico { font-size: 32px; margin-bottom: 12px; display: block; opacity: .45; }
.empty-t { font-family: var(--font-h); font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.empty-d { font-size: 12.5px; max-width: 280px; margin: 0 auto 18px; }

/* ── ACTIVITY ──────────────────────────────── */
.act-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.act-item:last-child { border-bottom: none; }
.act-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 4px; flex-shrink: 0; }
.act-text { font-size: 12.5px; line-height: 1.5; }
.act-time { font-family: var(--font-m); font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.act-who { color: var(--accent2); font-weight: 600; }

/* ── TOAST ─────────────────────────────────── */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 7px; }
.toast {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r-sm); padding: 10px 14px;
  font-size: 12.5px; min-width: 220px; max-width: 320px;
  display: flex; align-items: center; gap: 8px;
  animation: tsIn .18s ease;
}
.toast.ok  { border-color: rgba(29,184,145,.35); }
.toast.err { border-color: rgba(232,85,85,.35); }
@keyframes tsIn { from { transform: translateX(14px); opacity: 0; } }

/* ── MISC ──────────────────────────────────── */
.mono { font-family: var(--font-m); }
.dim  { color: var(--muted2); }
.flex-r { display: flex; align-items: center; gap: 8px; }
.spin {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff; border-radius: 50%;
  animation: sp .55s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; min-height: 180px; gap: 9px; color: var(--muted2); font-size: 13px; }

.divider { height: 1px; background: var(--border); margin: 18px 0; }

@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  #view { padding: 20px 16px; }
}
/* ── CONVERSATIONS ─────────────────────────────────── */
.conv-filters {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.search-wrap {
  position: relative; flex: 1; min-width: 200px; max-width: 340px;
}
.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted); pointer-events: none;
}
.search-input {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border2); border-radius: var(--r-sm);
  color: var(--text); padding: 7px 11px 7px 32px;
  font-size: 13px; font-family: var(--font); outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }
.filter-select {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r-sm); color: var(--text);
  padding: 7px 10px; font-size: 12.5px; font-family: var(--font);
  outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); }
.filter-select option { background: var(--surface2); }

.conv-row { cursor: pointer; }
.conv-row:hover td { background: rgba(107,92,255,.05) !important; }

/* Detail page */
.detail-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px; margin-bottom: 26px;
}
.detail-meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center;
}

.transcript-body {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
  color: var(--text);
  font-family: var(--font);
}
.transcript-body::-webkit-scrollbar { width: 4px; }
.transcript-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.no-transcript {
  border: 1px dashed var(--border2);
  border-radius: var(--r);
  padding: 36px 24px;
  text-align: center;
  color: var(--muted2);
}
.no-transcript svg { width: 32px; height: 32px; margin: 0 auto 12px; display: block; opacity: .35; }
.no-transcript strong { display: block; font-family: var(--font-h); font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }

.action-item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.action-item-row:last-child { border-bottom: none; }
/* ai-check — canonical definition (duplicates removed below) */
.ai-check {
  width: 24px; height: 24px; min-width: 24px; min-height: 24px;
  border-radius: 6px; border: 1.5px solid var(--border2);
  cursor: pointer; flex-shrink: 0; display: grid; place-items: center;
  background: transparent; transition: all .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ai-check.done { background: var(--green); border-color: var(--green); color: #fff; }
.ai-check svg { width: 12px; height: 12px; color: #fff; }
.ai-text { flex: 1; font-size: 13px; }
.ai-text.done { text-decoration: line-through; color: var(--muted); }
.ai-meta { font-size: 11.5px; color: var(--muted); font-family: var(--font-m); }

.summary-body {
  font-size: 13.5px; line-height: 1.75;
  color: var(--text); white-space: pre-wrap;
}

.section-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--trans);
}
.section-card:hover { border-color: var(--border2); }
.section-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
@media (max-width: 640px) {
  :root { --sidebar: 0px; }
  #sidebar { display: none; }
  #main { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .three-col { grid-template-columns: 1fr; }
}

/* ── AI PIPELINE UI ───────────────────────────────── */
.ai-panel {
  border: 1px solid var(--border2);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 14px;
}
.ai-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.ai-panel-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-h); font-size: 13.5px; font-weight: 700;
}
.ai-panel-body { padding: 18px; background: var(--surface); }

/* Job status bar */
.job-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  margin-bottom: 14px;
}
.job-bar.pending    { background: rgba(92,92,122,.12); border: 1px solid rgba(92,92,122,.2); color: var(--muted2); }
.job-bar.processing { background: rgba(107,92,255,.1); border: 1px solid rgba(107,92,255,.25); color: var(--accent2); }
.job-bar.completed  { background: rgba(29,184,145,.08); border: 1px solid rgba(29,184,145,.2); color: var(--green); }
.job-bar.failed     { background: rgba(232,85,85,.1); border: 1px solid rgba(232,85,85,.25); color: var(--red); }

/* Pulsing processing dot */
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: pulse-ring 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse-ring {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.7); }
}

/* AI run button */
.ai-run-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  background: linear-gradient(135deg, var(--accent), #9b5cff);
  color: #fff;
  transition: opacity .15s;
  white-space: nowrap;
}
.ai-run-btn:hover { opacity: .88; }
.ai-run-btn:disabled { opacity: .35; cursor: not-allowed; }
.ai-run-btn svg { width: 15px; height: 15px; }

/* AI result blocks */
.ai-result-text {
  font-size: 13.5px; line-height: 1.75;
  color: var(--text); white-space: pre-wrap;
  font-family: var(--font);
}

.risk-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  border: 1px solid transparent;
}
.risk-item.high   { background: rgba(232,85,85,.07);  border-color: rgba(232,85,85,.18); }
.risk-item.medium { background: rgba(232,168,48,.07); border-color: rgba(232,168,48,.18); }
.risk-item.low    { background: rgba(74,158,255,.06); border-color: rgba(74,158,255,.15); }

.risk-sev {
  font-family: var(--font-m); font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: 4px;
  white-space: nowrap; flex-shrink: 0; margin-top: 1px;
}
.risk-sev.high   { background: rgba(232,85,85,.18);  color: var(--red);   }
.risk-sev.medium { background: rgba(232,168,48,.18); color: var(--amber); }
.risk-sev.low    { background: rgba(74,158,255,.15); color: var(--blue);  }

.risk-label  { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.risk-detail { font-size: 12.5px; color: var(--muted2); line-height: 1.5; }

/* Follow-up draft textarea */
.draft-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 14px;
  font-size: 13px;
  font-family: var(--font);
  line-height: 1.7;
  outline: none;
  resize: vertical;
  min-height: 160px;
  transition: border-color .15s;
}
.draft-textarea:focus { border-color: var(--accent); }

.ai-source-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-family: var(--font-m);
  padding: 2px 7px; border-radius: 4px;
  background: rgba(107,92,255,.12);
  color: var(--accent2);
  border: 1px solid rgba(107,92,255,.2);
  margin-left: 6px;
}

/* ── TASK SYSTEM ───────────────────────────────────── */
.view-toggle { display:flex; gap:0; border:1px solid var(--border2); border-radius:var(--r-sm); overflow:hidden; }
.view-toggle-btn { padding:5px 12px; font-size:12px; font-weight:600; font-family:var(--font); background:transparent; border:none; color:var(--muted2); cursor:pointer; transition:all var(--trans); }
.view-toggle-btn.on { background:var(--accent); color:#fff; }
.view-toggle-btn:hover:not(.on) { background:var(--surface3); color:var(--text); }

/* Table view */
.priority-dot { display:inline-block; width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.priority-dot.urgent { background:var(--pink); }
.priority-dot.high   { background:var(--red); }
.priority-dot.medium { background:var(--amber); }
.priority-dot.low    { background:var(--muted); }

.due-overdue { color:var(--red); font-weight:600; }
.due-soon    { color:var(--amber); }
.due-ok      { color:var(--muted2); }

/* Kanban */
.kanban-board { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; align-items:start; }
@media(max-width:1100px) { .kanban-board { grid-template-columns:repeat(2,1fr); } }
@media(max-width:640px)  { .kanban-board { grid-template-columns:1fr; } }

.kanban-col { background:var(--surface2); border:1px solid var(--border); border-radius:var(--r); overflow:hidden; }
.kanban-col-head {
  padding:10px 14px; font-size:11.5px; font-weight:700; font-family:var(--font-h);
  display:flex; align-items:center; justify-content:space-between;
  border-bottom:1px solid var(--border);
}
.kanban-col-count { font-family:var(--font-m); font-size:10px; background:var(--surface); padding:2px 7px; border-radius:10px; color:var(--muted2); }
.kanban-cards { padding:8px; display:flex; flex-direction:column; gap:7px; min-height:60px; }
.kanban-add-btn { width:100%; padding:7px; background:transparent; border:none; color:var(--muted); cursor:pointer; font-size:12px; text-align:center; border-top:1px solid var(--border); transition:all var(--trans); }
.kanban-add-btn:hover { background:var(--surface3); color:var(--text); }

.task-card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--r-sm);
  padding:11px 13px; cursor:pointer; transition:all var(--trans);
}
.task-card:hover { border-color:var(--border2); background:var(--surface3); }
.task-card-title { font-size:13px; font-weight:500; line-height:1.4; margin-bottom:7px; }
.task-card-meta { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.task-card-assignee { display:flex; align-items:center; gap:4px; font-size:11px; color:var(--muted2); }

/* Detail / edit drawer */
.task-detail-grid { display:grid; grid-template-columns:1fr 280px; gap:20px; align-items:start; }
@media(max-width:860px) { .task-detail-grid { grid-template-columns:1fr; } }

.task-meta-card { background:var(--surface2); border:1px solid var(--border); border-radius:var(--r); padding:16px; }
.task-meta-row { display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--border); }
.task-meta-row:last-child { border-bottom:none; }
.task-meta-label { font-size:11.5px; color:var(--muted); font-weight:500; }
.task-meta-val { font-size:13px; }

.comment-list { display:flex; flex-direction:column; gap:10px; margin-bottom:14px; }
.comment-item { display:flex; gap:9px; align-items:flex-start; }
.comment-av { width:24px; height:24px; border-radius:50%; background:var(--accent); display:grid; place-items:center; font-size:9px; font-weight:700; color:#fff; flex-shrink:0; margin-top:1px; }
.comment-bubble { background:var(--surface2); border:1px solid var(--border); border-radius:var(--r-sm); padding:9px 12px; flex:1; min-width:0; }
.comment-author { font-size:11.5px; font-weight:600; color:var(--accent2); }
.comment-time   { font-size:10.5px; color:var(--muted); font-family:var(--font-m); margin-left:6px; }
.comment-text   { font-size:13px; line-height:1.55; margin-top:3px; white-space:pre-wrap; word-break:break-word; }
.comment-del    { font-size:11px; color:var(--muted); cursor:pointer; background:none; border:none; margin-top:4px; padding:0; }
.comment-del:hover { color:var(--red); }

.inline-edit { background:transparent; border:none; color:var(--text); font-family:var(--font); font-size:inherit; font-weight:inherit; width:100%; outline:none; padding:2px 4px; border-radius:3px; }
.inline-edit:hover { background:var(--surface2); }
.inline-edit:focus { background:var(--surface2); box-shadow:0 0 0 1px var(--accent); }

/* ── CRM & DEALS ──────────────────────────────────────── */
.pipeline-board { display:grid; grid-template-columns:repeat(6,1fr); gap:12px; align-items:start; margin-bottom:24px; }
@media(max-width:1200px) { .pipeline-board { grid-template-columns:repeat(3,1fr); } }
@media(max-width:700px)  { .pipeline-board { grid-template-columns:repeat(2,1fr); } }

.pipeline-col { background:var(--surface2); border:1px solid var(--border); border-radius:var(--r); overflow:hidden; }
.pipeline-col-head { padding:9px 12px; font-size:11px; font-weight:700; font-family:var(--font-h); display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border); }
.pipeline-col-val  { font-family:var(--font-m); font-size:10px; color:var(--muted2); }
.pipeline-cards    { padding:6px; display:flex; flex-direction:column; gap:6px; min-height:48px; }

.deal-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-sm); padding:10px 12px; cursor:pointer; transition:all var(--trans); }
.deal-card:hover { border-color:var(--border2); }
.deal-card-title  { font-size:12.5px; font-weight:600; margin-bottom:5px; line-height:1.35; }
.deal-card-val    { font-family:var(--font-h); font-size:14px; font-weight:700; color:var(--green); }
.deal-card-meta   { display:flex; align-items:center; gap:6px; margin-top:5px; flex-wrap:wrap; }

/* Risk score indicator */
.risk-gauge { display:inline-flex; align-items:center; gap:5px; }
.risk-bar-wrap { width:48px; height:5px; background:var(--border2); border-radius:3px; overflow:hidden; }
.risk-bar { height:100%; border-radius:3px; transition:width .3s; }
.risk-score-num { font-family:var(--font-m); font-size:11px; font-weight:600; }
.risk-0   { color:var(--green); }
.risk-1   { color:var(--amber); }
.risk-2   { color:var(--red); }
.risk-bar-0 { background:var(--green); }
.risk-bar-1 { background:var(--amber); }
.risk-bar-2 { background:var(--red); }

/* Deal detail layout */
.deal-detail-grid { display:grid; grid-template-columns:1fr 300px; gap:18px; align-items:start; }
@media(max-width:900px) { .deal-detail-grid { grid-template-columns:1fr; } }

.deal-stage-track { display:flex; align-items:center; gap:0; margin-bottom:20px; overflow-x:auto; padding-bottom:2px; }
.stage-step { display:flex; align-items:center; gap:0; flex-shrink:0; }
.stage-btn {
  padding:6px 14px; font-size:11.5px; font-weight:600; font-family:var(--font);
  background:var(--surface2); border:1px solid var(--border2); cursor:pointer;
  white-space:nowrap; transition:all var(--trans); color:var(--muted2);
}
.stage-btn:first-child { border-radius:var(--r-sm) 0 0 var(--r-sm); }
.stage-btn:last-child  { border-radius:0 var(--r-sm) var(--r-sm) 0; }
.stage-btn.active { background:var(--accent); border-color:var(--accent); color:#fff; }
.stage-btn.won   { background:var(--green); border-color:var(--green); color:#fff; }
.stage-btn.lost  { background:var(--red); border-color:var(--red); color:#fff; }
.stage-btn:hover:not(.active):not(.won):not(.lost) { background:var(--surface3); color:var(--text); }
.stage-arrow { color:var(--border2); font-size:12px; margin:0 -1px; z-index:1; }

/* Risk breakdown card */
.risk-reason-row { display:flex; align-items:flex-start; gap:8px; padding:8px 0; border-bottom:1px solid var(--border); }
.risk-reason-row:last-child { border-bottom:none; }
.risk-reason-icon { font-size:14px; flex-shrink:0; margin-top:1px; }
.risk-reason-text { font-size:12.5px; line-height:1.5; flex:1; }
.risk-reason-pts  { font-family:var(--font-m); font-size:11px; color:var(--muted); flex-shrink:0; }
.risk-score-big   { font-family:var(--font-h); font-size:40px; font-weight:800; line-height:1; }

/* Account/contact cards */
.crm-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:14px; }
.crm-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--r); padding:16px; cursor:pointer; transition:all var(--trans); }
.crm-card:hover { border-color:var(--border2); background:var(--surface2); }
.crm-card-name { font-family:var(--font-h); font-size:14px; font-weight:700; margin-bottom:4px; }
.crm-card-meta { font-size:12px; color:var(--muted2); display:flex; flex-direction:column; gap:3px; }
.crm-tab-bar   { display:flex; gap:0; border-bottom:1px solid var(--border); margin-bottom:20px; }
.crm-tab { padding:9px 18px; font-size:13px; font-weight:600; font-family:var(--font); background:none; border:none; cursor:pointer; color:var(--muted2); border-bottom:2px solid transparent; margin-bottom:-1px; transition:all var(--trans); }
.crm-tab.on { color:var(--accent2); border-bottom-color:var(--accent); }
.crm-tab:hover:not(.on) { color:var(--text); }

/* ── INTEGRATIONS ────────────────────────────────── */
.int-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:16px; }

.int-card {
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--r);
  overflow:hidden;
  transition:border-color var(--trans);
}
.int-card.connected { border-color:rgba(29,184,145,.35); }
.int-card.error     { border-color:rgba(232,85,85,.35); }

.int-card-header {
  display:flex; align-items:center; gap:14px;
  padding:18px 20px;
  border-bottom:1px solid var(--border);
}
.int-logo {
  width:40px; height:40px; border-radius:10px;
  display:grid; place-items:center;
  font-size:20px; flex-shrink:0;
  background:var(--surface2); border:1px solid var(--border2);
}
.int-name      { font-family:var(--font-h); font-size:15px; font-weight:700; }
.int-category  { font-size:11.5px; color:var(--muted2); margin-top:1px; }
.int-status-dot {
  width:8px; height:8px; border-radius:50%; flex-shrink:0; margin-left:auto;
}
.int-status-dot.connected    { background:var(--green); box-shadow:0 0 6px var(--green); }
.int-status-dot.disconnected { background:var(--border2); }
.int-status-dot.error        { background:var(--red); box-shadow:0 0 6px var(--red); }
.int-status-dot.syncing      { background:var(--amber); animation:pulse-ring 1s ease-in-out infinite; }

.int-card-body { padding:16px 20px; }
.int-card-footer {
  padding:12px 20px; border-top:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
  background:var(--surface2);
}

.int-stat-row { display:flex; align-items:center; justify-content:space-between; padding:5px 0; font-size:12.5px; }
.int-stat-label { color:var(--muted2); }
.int-stat-val   { font-family:var(--font-m); font-size:12px; }

/* Setup instructions */
.setup-steps { counter-reset:step; margin:12px 0; }
.setup-step  {
  counter-increment:step;
  display:flex; gap:10px; padding:8px 0;
  border-bottom:1px solid var(--border); font-size:12.5px; line-height:1.5;
}
.setup-step:last-child { border-bottom:none; }
.setup-step::before {
  content:counter(step);
  width:20px; height:20px; border-radius:50%;
  background:var(--accent); color:#fff;
  font-size:11px; font-weight:700; font-family:var(--font-h);
  display:grid; place-items:center; flex-shrink:0; margin-top:1px;
}
.setup-note {
  background:rgba(74,158,255,.07); border:1px solid rgba(74,158,255,.18);
  border-radius:var(--r-sm); padding:10px 12px;
  font-size:12px; color:var(--blue); margin-top:10px; line-height:1.6;
}

/* Credentials form */
.cred-field { position:relative; }
.cred-field input { padding-right:36px; }
.cred-toggle {
  position:absolute; right:10px; top:50%; transform:translateY(-50%);
  background:none; border:none; cursor:pointer; color:var(--muted); font-size:13px;
}
.cred-toggle:hover { color:var(--text); }
.cred-masked { font-family:var(--font-m); letter-spacing:.1em; font-size:13px; color:var(--muted2); }

/* Sync log */
.sync-log-item { display:flex; align-items:flex-start; gap:9px; padding:8px 0; border-bottom:1px solid var(--border); font-size:12.5px; }
.sync-log-item:last-child { border-bottom:none; }
.sync-log-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; margin-top:4px; }
.sync-log-dot.ok  { background:var(--green); }
.sync-log-dot.err { background:var(--red); }
.sync-log-dot.info{ background:var(--blue); }

/* ── ANALYTICS ───────────────────────────────────── */
.chart-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--r); padding:20px; }
.chart-title { font-family:var(--font-h); font-size:13.5px; font-weight:700; margin-bottom:16px; display:flex; align-items:center; justify-content:space-between; }
.chart-sub   { font-size:11.5px; color:var(--muted2); font-weight:400; }

/* Bar chart */
.bar-chart   { display:flex; align-items:flex-end; gap:5px; height:140px; }
.bar-col     { display:flex; flex-direction:column; align-items:center; gap:4px; flex:1; min-width:0; }
.bar-fill    { width:100%; border-radius:3px 3px 0 0; transition:height .4s ease; background:var(--accent); min-height:2px; }
.bar-fill.green  { background:var(--green); }
.bar-fill.amber  { background:var(--amber); }
.bar-fill.red    { background:var(--red); }
.bar-label   { font-size:9.5px; font-family:var(--font-m); color:var(--muted); white-space:nowrap; }
.bar-val     { font-size:10px; font-family:var(--font-m); color:var(--muted2); }

/* Donut chart (pure CSS) */
.donut-wrap  { display:flex; align-items:center; gap:20px; }
.donut-svg   { flex-shrink:0; }
.donut-legend { display:flex; flex-direction:column; gap:7px; flex:1; min-width:0; }
.donut-item  { display:flex; align-items:center; gap:7px; font-size:12px; }
.donut-dot   { width:9px; height:9px; border-radius:50%; flex-shrink:0; }

/* Sparkline */
.sparkline-wrap { height:44px; display:flex; align-items:flex-end; gap:2px; }
.spark-bar { flex:1; border-radius:2px 2px 0 0; min-height:2px; background:var(--accent); opacity:.7; }
.spark-bar.active { opacity:1; }

/* Analytics grid */
.analytics-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media(max-width:860px) { .analytics-grid { grid-template-columns:1fr; } }
.analytics-grid-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }
@media(max-width:1100px) { .analytics-grid-3 { grid-template-columns:1fr 1fr; } }
@media(max-width:640px)  { .analytics-grid-3 { grid-template-columns:1fr; } }

.kpi-row { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:12px; margin-bottom:20px; }
.kpi { background:var(--surface2); border-radius:var(--r-sm); padding:14px 16px; border:1px solid var(--border); }
.kpi-label { font-size:10.5px; font-family:var(--font-m); text-transform:uppercase; letter-spacing:.08em; color:var(--muted); margin-bottom:5px; }
.kpi-val   { font-family:var(--font-h); font-size:26px; font-weight:700; line-height:1; }
.kpi-delta { font-size:11px; margin-top:4px; }
.kpi-delta.up   { color:var(--green); }
.kpi-delta.down { color:var(--red); }
.kpi-delta.flat { color:var(--muted2); }

/* ── NOTIFICATIONS ───────────────────────────────── */
.notif-panel {
  position:fixed; top:var(--header); right:12px;
  width:360px; max-height:calc(100vh - var(--header) - 24px);
  background:var(--surface); border:1px solid var(--border2);
  border-radius:var(--r); overflow:hidden;
  display:flex; flex-direction:column;
  z-index:300; box-shadow:0 8px 32px rgba(0,0,0,.5);
  animation:notifSlide .16s ease;
}
@keyframes notifSlide { from { opacity:0; transform:translateY(-8px); } }

.notif-header { padding:14px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; flex-shrink:0; }
.notif-header-title { font-family:var(--font-h); font-size:14px; font-weight:700; }
.notif-list { overflow-y:auto; flex:1; }
.notif-list::-webkit-scrollbar { width:3px; }
.notif-list::-webkit-scrollbar-thumb { background:var(--border2); }

.notif-item {
  display:flex; align-items:flex-start; gap:10px;
  padding:12px 16px; border-bottom:1px solid var(--border);
  cursor:pointer; transition:background var(--trans);
}
.notif-item:hover { background:var(--surface2); }
.notif-item.unread { background:rgba(107,92,255,.05); }
.notif-item:last-child { border-bottom:none; }

.notif-icon { width:32px; height:32px; border-radius:9px; display:grid; place-items:center; font-size:15px; flex-shrink:0; }
.notif-icon.task    { background:rgba(107,92,255,.15); }
.notif-icon.ai      { background:rgba(29,184,145,.12); }
.notif-icon.risk    { background:rgba(232,85,85,.12); }
.notif-icon.info    { background:rgba(74,158,255,.12); }

.notif-title { font-size:13px; font-weight:600; line-height:1.35; }
.notif-body  { font-size:11.5px; color:var(--muted2); margin-top:2px; line-height:1.4; }
.notif-time  { font-size:10.5px; color:var(--muted); font-family:var(--font-m); margin-top:3px; }
.notif-unread-dot { width:6px; height:6px; border-radius:50%; background:var(--accent); flex-shrink:0; margin-top:5px; }

.notif-empty { text-align:center; padding:40px 20px; color:var(--muted2); font-size:13px; }

/* ── TOAST ─────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 11px 18px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; font-family: var(--font);
  background: var(--surface); border: 1px solid var(--border2);
  color: var(--text); z-index: 9999;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none; box-shadow: 0 4px 20px rgba(0,0,0,.4);
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-err { border-color: rgba(232,85,85,.5); color: var(--red); }
.toast.toast-ok  { border-color: rgba(29,184,145,.4); }

/* ── AUTH ─────────────────────────────────────────── */
#app.auth { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.auth-loading { display: grid; place-items: center; min-height: 100vh; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 36px; width: 100%;
  max-width: 420px; display: flex; flex-direction: column; gap: 12px;
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth-title { font-family: var(--font-h); font-size: 22px; font-weight: 700; }
.auth-link  { color: var(--accent2); cursor: pointer; font-size: 13px; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }

/* ── ALERT ─────────────────────────────────────────── */
.alert {
  padding: 10px 14px; border-radius: var(--r-sm);
  font-size: 13px; line-height: 1.5;
  display: none;
}
.alert.on { display: block; }
.alert-e { background: rgba(232,85,85,.1); border: 1px solid rgba(232,85,85,.3); color: var(--red); }
.alert-i { background: rgba(74,158,255,.07); border: 1px solid rgba(74,158,255,.2); color: var(--blue); }

/* ── SPIN ──────────────────────────────────────────── */
.spin {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; padding: 40px; color: var(--muted2); font-size: 13px; }

/* ── SA TERMINAL CHAT ──────────────────────────────── */
.chat-msg { display: flex; gap: 10px; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.chat-bubble h3 { font-size: 13px; font-weight: 700; margin: 10px 0 4px; color: var(--text); }
.chat-bubble p  { margin: 0 0 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol { padding-left: 18px; margin: 4px 0 8px; }
.chat-bubble li { margin-bottom: 3px; line-height: 1.55; }
.chat-bubble strong { font-weight: 700; color: var(--text); }
.chat-bubble code { font-family: var(--font-m); font-size: 12px; background: var(--surface3); padding: 1px 5px; border-radius: 4px; }
.chat-bubble hr  { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.chat-bubble .ai-section { margin: 8px 0; }
.chat-bubble .ai-score-bar { height: 6px; border-radius: 3px; background: var(--surface3); margin: 4px 0 8px; overflow: hidden; }
.chat-bubble .ai-score-fill { height: 100%; border-radius: 3px; background: var(--grad-accent); }
.chat-msg.user .chat-bubble {
  background: var(--grad-accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.chat-msg.user .chat-bubble strong { color: #fff; }
.chat-msg.assistant .chat-bubble {
  background: var(--surface2);
}

/* ── SECTION CARD HEADER ──────────────────────────── */
.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* ── TABLE LINK ────────────────────────────────────── */
.tbl-link {
  text-decoration: none;
  color: var(--accent2);
}
.tbl-link:hover { text-decoration: underline; }

/* ── PLAN BADGE COLORS ─────────────────────────────── */
.b-pink   { background: rgba(236,72,153,.12); color: #f472b6; border-color: rgba(236,72,153,.25); }

/* ── INTEGRATIONS GRID ─────────────────────────────── */
.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 16px; }
.int-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s;
}
.int-card.connected { border-color: rgba(29,184,145,.3); }
.int-card.error     { border-color: rgba(232,85,85,.3); }
.int-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 12px;
}
.int-logo { font-size: 26px; flex-shrink: 0; line-height: 1; }
.int-name { font-family: var(--font-h); font-size: 15px; font-weight: 700; }
.int-category { font-size: 11.5px; color: var(--muted2); margin-top: 2px; }
.int-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px;
  background: var(--muted);
}
.int-status-dot.connected  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.int-status-dot.error      { background: var(--red); }
.int-status-dot.syncing    { background: var(--amber); animation: pulse 1s infinite; }
.int-card-body { padding: 0 18px 12px; flex: 1; }
.int-card-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface2);
}
.int-stat-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.int-stat-label { color: var(--muted2); }
.int-stat-val   { color: var(--text); font-family: var(--font-m); }
.cred-masked  { font-family: var(--font-m); font-size: 12px; color: var(--muted); letter-spacing: .12em; }
.cred-field   { position: relative; }
.cred-toggle  { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 14px; color: var(--muted2); padding: 0; }

/* ── PIPELINE / KANBAN ─────────────────────────────── */
.pipeline-board { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.pipeline-col   { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; }
.pipeline-col-head { font-family: var(--font-h); font-size: 13px; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; }
.pipeline-col-val  { background: var(--border2); border-radius: 99px; padding: 1px 8px; font-size: 11px; }
.deal-card { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r-sm); padding: 12px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s; }
.deal-card:hover { border-color: var(--accent); }
.deal-card-title { font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.deal-card-val   { font-family: var(--font-h); font-size: 15px; font-weight: 700; color: var(--green); margin-bottom: 6px; }
.deal-card-meta  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pipeline-cards  { min-height: 60px; }

/* ── RISK GAUGE ────────────────────────────────────── */
.risk-gauge      { display: flex; align-items: center; gap: 6px; }
.risk-bar-wrap   { width: 60px; height: 5px; background: var(--border2); border-radius: 99px; overflow: hidden; }
.risk-bar        { height: 100%; border-radius: 99px; }
.risk-bar-0      { background: var(--green); }
.risk-bar-1      { background: var(--amber); }
.risk-bar-2      { background: var(--red); }
.risk-score-num  { font-family: var(--font-m); font-size: 11.5px; font-weight: 600; }
.risk-0 { color: var(--green); }
.risk-1 { color: var(--amber); }
.risk-2 { color: var(--red); }
.risk-score-big { font-family: var(--font-h); font-size: 38px; font-weight: 800; line-height: 1; }
.risk-reason-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.risk-reason-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.risk-reason-text { flex: 1; color: var(--muted2); }
.risk-reason-pts  { font-family: var(--font-m); color: var(--red); font-size: 11px; }

/* ── CRM GRID ──────────────────────────────────────── */
.crm-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 14px; }
.crm-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s;
}
.crm-card:hover { border-color: var(--accent); }
.crm-card-name { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.crm-card-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted2); }

/* ── DEAL STAGE TRACK ──────────────────────────────── */
.deal-stage-track { display: flex; align-items: center; gap: 0; margin-bottom: 20px; overflow-x: auto; padding-bottom: 4px; }
.stage-btn {
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--muted2);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.stage-btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.stage-btn:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.stage-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.stage-btn.won    { background: var(--green);  color: #fff; border-color: var(--green); }
.stage-btn.lost   { background: var(--red);    color: #fff; border-color: var(--red); }
.stage-arrow { color: var(--border2); font-size: 16px; margin: 0 -1px; z-index: 1; position: relative; }

/* ── DEAL DETAIL GRID ──────────────────────────────── */
.deal-detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
@media (max-width:900px) { .deal-detail-grid { grid-template-columns: 1fr; } }

/* ── TASK DETAIL GRID ──────────────────────────────── */
.task-detail-grid { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; }
@media (max-width:860px) { .task-detail-grid { grid-template-columns: 1fr; } }

/* ── ANALYTICS ─────────────────────────────────────── */
.analytics-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.analytics-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.kpi-row          { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; margin-bottom: 20px; }
.kpi { background:var(--surface); border:1px solid var(--border2); border-radius:var(--r-sm); padding:16px; }
.kpi-label { font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); margin-bottom:6px; }
.kpi-val   { font-family:var(--font-h); font-size:26px; font-weight:800; margin-bottom:4px; }
.kpi-delta { font-size:11.5px; }
.kpi-delta.up   { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-delta.flat { color: var(--muted2); }
.chart-card  { background:var(--surface); border:1px solid var(--border2); border-radius:var(--r-sm); padding:18px; }
.chart-title { font-family:var(--font-h); font-size:14px; font-weight:700; margin-bottom:14px; }
.chart-sub   { font-size:11.5px; color:var(--muted2); font-family:var(--font); font-weight:400; margin-left:6px; }
.bar-chart   { display:flex; align-items:flex-end; gap:6px; height:100px; }
.bar-col     { display:flex; flex-direction:column; align-items:center; gap:4px; flex:1; height:100%; justify-content:flex-end; }
.bar-val     { font-family:var(--font-m); font-size:10px; color:var(--muted2); min-height:14px; }
.bar-fill    { width:100%; background:var(--accent); border-radius:3px 3px 0 0; min-height:2px; transition:height .3s; }
.bar-label   { font-family:var(--font-m); font-size:9px; color:var(--muted); white-space:nowrap; overflow:hidden; max-width:100%; text-align:center; }
.donut-wrap  { display:flex; align-items:center; gap:16px; }
.donut-svg   { flex-shrink:0; }
.donut-legend{ display:flex; flex-direction:column; gap:6px; flex:1; }
.donut-item  { display:flex; align-items:center; gap:7px; font-size:12px; }
.donut-dot   { width:8px; height:8px; border-radius:50%; flex-shrink:0; }

/* ── NOTIFICATION PANEL ────────────────────────────── */
.notif-panel {
  position: fixed; top: 56px; right: 16px;
  width: 340px; max-height: 500px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r); box-shadow: 0 16px 48px rgba(0,0,0,.4);
  z-index: 998; display: flex; flex-direction: column;
  overflow: hidden;
}
.notif-header { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--border); }
.notif-header-title { font-family:var(--font-h); font-size:14px; font-weight:700; display:flex; align-items:center; gap:8px; }
.notif-list  { overflow-y:auto; flex:1; }
.notif-item  { display:flex; align-items:flex-start; gap:10px; padding:12px 16px; border-bottom:1px solid var(--border); cursor:pointer; transition:background .1s; }
.notif-item:hover { background:var(--surface2); }
.notif-item.unread { background:rgba(107,92,255,.06); }
.notif-icon  { font-size:16px; flex-shrink:0; }
.notif-title { font-weight:600; font-size:13px; margin-bottom:2px; }
.notif-body  { font-size:12px; color:var(--muted2); }
.notif-time  { font-size:11px; color:var(--muted); margin-top:4px; font-family:var(--font-m); }
.notif-unread-dot { width:7px; height:7px; border-radius:50%; background:var(--accent); flex-shrink:0; margin-top:4px; }
.notif-empty { text-align:center; padding:32px 16px; color:var(--muted2); font-size:13px; }

/* ── AI RESULT ─────────────────────────────────────── */
.ai-result-label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); margin-bottom:6px; }
.ai-result-text  { font-size:13.5px; line-height:1.6; color:var(--text); background:var(--surface2); border:1px solid var(--border); border-radius:var(--r-sm); padding:12px 14px; }
.action-item-row { display:flex; align-items:center; gap:10px; padding:7px 0; border-bottom:1px solid var(--border); }
/* ai-check duplicate removed — see canonical definition above */
.ai-text.done    { text-decoration:line-through; color:var(--muted); }
.ai-source-tag   { display:inline-block; padding:1px 6px; background:rgba(107,92,255,.15); color:var(--accent); border-radius:4px; font-size:10.5px; font-weight:700; font-family:var(--font-m); }

/* ── JOB STATUS ────────────────────────────────────── */
.job-bar        { padding:10px 14px; border-radius:var(--r-sm); font-size:13px; display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.job-bar.processing { background:rgba(107,92,255,.1); border:1px solid rgba(107,92,255,.2); color:var(--accent2); }
.job-bar.failed     { background:rgba(232,85,85,.08); border:1px solid rgba(232,85,85,.2); color:var(--red); }
.pulse-dot { width:8px; height:8px; border-radius:50%; background:var(--accent); animation:pulse 1.2s ease-in-out infinite; flex-shrink:0; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.8)} }

/* ── COMMENT STYLES ────────────────────────────────── */
.comment-item   { display:flex; gap:10px; margin-bottom:12px; }
.comment-av     { width:28px; height:28px; border-radius:8px; background:var(--accent); color:#fff; font-size:10px; font-weight:700; display:grid; place-items:center; flex-shrink:0; }
.comment-author { font-weight:600; font-size:13px; margin-right:8px; }
.comment-time   { font-size:11px; color:var(--muted); font-family:var(--font-m); }
.comment-bubble { background:var(--surface2); border:1px solid var(--border); border-radius:0 8px 8px 8px; padding:8px 12px; margin-top:4px; }
.comment-text   { font-size:13px; line-height:1.5; }
.comment-del    { font-size:11px; color:var(--muted); background:none; border:none; cursor:pointer; padding:2px 4px; margin-top:4px; }
.comment-del:hover { color:var(--red); }

/* ── VIEW TOGGLE ───────────────────────────────────── */
.view-toggle     { display:flex; border:1px solid var(--border2); border-radius:var(--r-sm); overflow:hidden; }
.view-toggle-btn { padding:6px 12px; font-size:12.5px; font-weight:500; background:transparent; border:none; color:var(--muted2); cursor:pointer; transition:all .15s; }
.view-toggle-btn.on { background:var(--accent); color:#fff; }

/* ── PRIORITY DOT ──────────────────────────────────── */
.priority-dot { width:7px; height:7px; border-radius:50%; display:inline-block; flex-shrink:0; }
.priority-dot.low    { background:var(--muted); }
.priority-dot.medium { background:var(--blue); }
.priority-dot.high   { background:var(--amber); }
.priority-dot.urgent { background:var(--red); }

/* ── AUDIT ROW ─────────────────────────────────────── */
.audit-row  { display:flex; gap:10px; padding:8px 0; border-bottom:1px solid var(--border); }
.audit-dot  { width:6px; height:6px; border-radius:50%; flex-shrink:0; margin-top:5px; }
.audit-body { flex:1; }
.audit-action { font-size:13px; font-weight:500; }
.audit-meta   { font-size:11.5px; color:var(--muted); font-family:var(--font-m); margin-top:1px; }

/* ── KANBAN ────────────────────────────────────────── */
.kanban-board { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.kanban-col   { background:var(--surface2); border:1px solid var(--border); border-radius:var(--r-sm); padding:12px; }
.kanban-col-head { font-family:var(--font-h); font-size:13px; font-weight:700; margin-bottom:12px; display:flex; justify-content:space-between; align-items:center; }
.kanban-col-count { background:var(--border2); border-radius:99px; padding:1px 8px; font-size:11px; }
.kanban-cards { min-height:50px; }
.task-card { background:var(--surface); border:1px solid var(--border2); border-radius:var(--r-sm); padding:10px 12px; margin-bottom:8px; cursor:pointer; transition:border-color .15s; }
.task-card:hover { border-color:var(--accent); }
.task-card-title { font-weight:600; font-size:13px; margin-bottom:6px; }
.task-card-meta  { display:flex; align-items:center; gap:6px; flex-wrap:wrap; font-size:11px; }
.task-card-assignee { display:flex; align-items:center; gap:4px; color:var(--muted2); }
.kanban-add-btn { width:100%; padding:6px; font-size:12px; color:var(--muted); background:none; border:1px dashed var(--border2); border-radius:var(--r-sm); cursor:pointer; margin-top:6px; transition:all .15s; }
.kanban-add-btn:hover { color:var(--accent); border-color:var(--accent); }

/* ── DUE DATE COLORS ───────────────────────────────── */
.due-overdue { color: var(--red);   font-weight:600; }
.due-soon    { color: var(--amber); font-weight:600; }
.due-ok      { color: var(--muted2); }

/* ── TASK META CARD ────────────────────────────────── */
.task-meta-card { background:var(--surface2); border:1px solid var(--border); border-radius:var(--r-sm); padding:14px 16px; }
.task-meta-row  { display:flex; justify-content:space-between; align-items:center; padding:6px 0; border-bottom:1px solid var(--border); font-size:13px; }
.task-meta-row:last-child { border-bottom:none; }
.task-meta-label { color:var(--muted2); font-size:12px; }

/* ── DETAIL META ───────────────────────────────────── */
.detail-meta { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:6px; }

/* ── CONTEXT BADGE ─────────────────────────────────── */
.ctx-badge { font-family:var(--font-h); font-size:13px; font-weight:700; color:var(--text); background:var(--surface2); border:1px solid var(--border2); border-radius:6px; padding:4px 10px; }

/* ── SECTION CARD HEADER (flex row inside cards) ────── */
.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

/* ── KNOWLEDGE BASE FILTER BUTTONS ──────────────────── */
.kb-filter-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.kb-filter-btn:hover { background: var(--surface2); color: var(--text); }
.kb-filter-btn.on {
  background: rgba(107,92,255,.12);
  border-color: rgba(107,92,255,.25);
  color: var(--accent2);
  font-weight: 600;
}

/* ── TENANT DETAIL TABLE LINK ────────────────────────── */
.tbl-link {
  text-decoration: none;
}
.tbl-link:hover { text-decoration: underline; }

/* ── ALERT SUCCESS ───────────────────────────────────── */
.alert-s {
  background: rgba(29,184,145,.1);
  border: 1px solid rgba(29,184,145,.28);
  color: var(--green);
}

/* ── FLEX ROW UTILITY ────────────────────────────────── */
.flex-r {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

/* ── DETAIL META LINE ────────────────────────────────── */
.detail-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12.5px;
}

/* ── CTX BADGE (topbar workspace name) ──────────────── */
.ctx-badge {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 10px;
}

/* ── STAT GRID IMPROVEMENTS ──────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-s {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  font-family: var(--font-m);
}

/* ── KPI ROW ─────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 16px 18px;
}
.kpi-label { font-size: 11.5px; color: var(--muted2); font-family: var(--font-m); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.kpi-val   { font-family: var(--font-h); font-size: 26px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.kpi-delta { font-size: 11.5px; }
.kpi-delta.up   { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-delta.flat { color: var(--muted2); }

/* ── ANALYTICS GRID ──────────────────────────────────── */
.analytics-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.analytics-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-card    { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r); padding: 20px 22px; }
.chart-title   { font-family: var(--font-h); font-size: 14px; font-weight: 700; margin-bottom: 16px; }
.chart-sub     { font-size: 11.5px; font-weight: 400; color: var(--muted); font-family: var(--font); }

/* ── AUDIT ROW ───────────────────────────────────────── */
.audit-row    { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.audit-row:last-child { border-bottom: none; }
.audit-dot    { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.audit-action { font-size: 12.5px; font-weight: 500; }
.audit-meta   { font-size: 11.5px; color: var(--muted2); font-family: var(--font-m); margin-top: 2px; }

/* ── VIEW TOGGLE (table / kanban) ────────────────────── */
.view-toggle     { display: flex; gap: 2px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.view-toggle-btn { padding: 5px 10px; border-radius: calc(var(--r-sm) - 2px); background: transparent; border: none; color: var(--muted2); font-size: 12px; cursor: pointer; transition: background .12s, color .12s; }
.view-toggle-btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }

/* ── COMMENT STYLES ──────────────────────────────────── */
.comment-item   { display: flex; gap: 10px; margin-bottom: 12px; }
.comment-av     { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.comment-author { font-weight: 600; font-size: 12.5px; }
.comment-time   { font-size: 11px; color: var(--muted2); font-family: var(--font-m); margin-left: 8px; }
.comment-bubble { margin-top: 4px; }
.comment-text   { font-size: 13px; line-height: 1.55; }
.comment-del    { font-size: 11px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 0; margin-top: 3px; }
.comment-del:hover { color: var(--red); }

/* ── PRIORITY DOT ────────────────────────────────────── */
.priority-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.priority-dot.low    { background: var(--muted2); }
.priority-dot.medium { background: var(--amber); }
.priority-dot.high   { background: var(--red); }
.priority-dot.urgent { background: var(--pink); box-shadow: 0 0 6px var(--pink); }

/* ── AI SOURCE TAG ───────────────────────────────────── */
.ai-source-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(107,92,255,.18);
  color: var(--accent2);
  font-family: var(--font-m);
  letter-spacing: .04em;
}

/* ── RISK GAUGE ──────────────────────────────────────── */
.risk-gauge       { display: flex; align-items: center; gap: 6px; }
.risk-bar-wrap    { flex: 1; height: 5px; background: var(--border2); border-radius: 3px; overflow: hidden; min-width: 60px; }
.risk-bar         { height: 100%; border-radius: 3px; transition: width .3s; }
.risk-bar-0       { background: var(--green); }
.risk-bar-1       { background: var(--amber); }
.risk-bar-2       { background: var(--red); }
.risk-score-num   { font-family: var(--font-m); font-size: 12px; font-weight: 600; width: 24px; text-align: right; }
.risk-0           { color: var(--green); }
.risk-1           { color: var(--amber); }
.risk-2           { color: var(--red); }
.risk-score-big   { font-family: var(--font-h); font-size: 40px; font-weight: 800; line-height: 1; }

/* ── KANBAN BOARD ────────────────────────────────────── */
.kanban-board     { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kanban-col       { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.kanban-col-head  { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.kanban-col-count { font-family: var(--font-m); font-size: 11.5px; color: var(--muted2); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1px 7px; }
.kanban-cards     { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kanban-add-btn   { width: 100%; padding: 7px; background: none; border: 1px dashed var(--border2); border-radius: var(--r-sm); color: var(--muted2); font-size: 12px; cursor: pointer; transition: all .12s; margin-top: 4px; }
.kanban-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.task-card        { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r-sm); padding: 11px 13px; cursor: pointer; transition: box-shadow .12s; }
.task-card:hover  { box-shadow: 0 3px 12px rgba(0,0,0,.25); }
.task-card-title  { font-size: 13px; font-weight: 600; margin-bottom: 8px; line-height: 1.35; }
.task-card-meta   { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-card-assignee { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted2); }

/* ── PIPELINE / DEAL KANBAN ──────────────────────────── */
.pipeline-board    { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.pipeline-col      { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 12px; }
.pipeline-col-head { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.pipeline-col-val  { font-family: var(--font-m); font-size: 11.5px; color: var(--muted2); background: var(--surface); border: 1px solid var(--border); padding: 1px 7px; border-radius: 10px; }
.pipeline-cards    { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.deal-card         { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r-sm); padding: 12px 14px; cursor: pointer; transition: box-shadow .12s; }
.deal-card:hover   { box-shadow: 0 3px 12px rgba(0,0,0,.25); }
.deal-card-title   { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.deal-card-val     { font-family: var(--font-h); font-size: 15px; font-weight: 700; color: var(--green); margin-bottom: 6px; }
.deal-card-meta    { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── CRM GRID ────────────────────────────────────────── */
.crm-grid      { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.crm-card      { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r); padding: 16px 18px; cursor: pointer; transition: box-shadow .12s; }
.crm-card:hover{ box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.crm-card-name { font-family: var(--font-h); font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.crm-card-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted2); }

/* ── DEAL STAGE TRACK ────────────────────────────────── */
.deal-stage-track { display: flex; align-items: center; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.stage-btn        { padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border2); background: var(--surface2); color: var(--muted2); font-size: 12.5px; cursor: pointer; transition: all .12s; }
.stage-btn:hover  { border-color: var(--accent); color: var(--text); }
.stage-btn.active { border-color: var(--accent); background: rgba(107,92,255,.15); color: var(--accent2); font-weight: 600; }
.stage-btn.won    { border-color: var(--green); background: rgba(29,184,145,.12); color: var(--green); font-weight: 600; }
.stage-btn.lost   { border-color: var(--red); background: rgba(232,85,85,.1); color: var(--red); font-weight: 600; }
.stage-arrow      { color: var(--muted); font-size: 16px; line-height: 1; }

/* ── TASK DETAIL / DEAL DETAIL GRIDS ─────────────────── */
.task-detail-grid  { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.deal-detail-grid  { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.task-meta-card    { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r); padding: 18px; }
.task-meta-row     { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; gap: 8px; }
.task-meta-row:last-child { border-bottom: none; }
.task-meta-label   { color: var(--muted2); font-size: 12px; flex-shrink: 0; }

/* ── NOTIFICATIONS PANEL ─────────────────────────────── */
.notif-panel       { position: fixed; top: 52px; right: 14px; width: 360px; max-height: 520px; background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r); box-shadow: 0 12px 40px rgba(0,0,0,.4); z-index: 900; display: flex; flex-direction: column; overflow: hidden; }
.notif-header      { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.notif-header-title{ font-family: var(--font-h); font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.notif-list        { overflow-y: auto; flex: 1; }
.notif-empty       { padding: 40px 20px; text-align: center; color: var(--muted2); font-size: 13px; }
.notif-item        { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; position: relative; }
.notif-item:hover  { background: var(--surface2); }
.notif-item.unread { background: rgba(107,92,255,.05); }
.notif-icon        { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; flex-shrink: 0; background: var(--surface2); }
.notif-title       { font-size: 13px; font-weight: 600; }
.notif-body        { font-size: 12px; color: var(--muted2); margin-top: 2px; }
.notif-time        { font-size: 11px; color: var(--muted); font-family: var(--font-m); margin-top: 3px; }
.notif-unread-dot  { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 4px; }

/* ── INTEGRATION CARDS ───────────────────────────────── */
.int-grid     { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.int-card     { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r); display: flex; flex-direction: column; }
.int-card.connected { border-color: rgba(29,184,145,.25); }
.int-card.error     { border-color: rgba(232,85,85,.25); }
.int-card-header    { display: flex; align-items: flex-start; gap: 12px; padding: 18px 18px 14px; }
.int-card-body      { padding: 0 18px; flex: 1; }
.int-card-footer    { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.int-logo    { width: 36px; height: 36px; border-radius: 9px; background: var(--surface2); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.int-name    { font-family: var(--font-h); font-size: 15px; font-weight: 700; }
.int-category{ font-size: 11.5px; color: var(--muted2); margin-top: 2px; }
.int-status-dot { width: 8px; height: 8px; border-radius: 50%; }
.int-status-dot.connected    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.int-status-dot.disconnected { background: var(--muted2); }
.int-status-dot.error        { background: var(--red); }
.int-status-dot.syncing      { background: var(--amber); animation: pulse 1s infinite; }
.int-stat-row   { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; }
.int-stat-label { color: var(--muted2); }
.int-stat-val   { font-family: var(--font-m); font-size: 11.5px; }
.cred-field     { position: relative; }
.cred-toggle    { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 14px; line-height: 1; }
.cred-masked    { font-family: var(--font-m); font-size: 12px; color: var(--muted); letter-spacing: .05em; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── AI RESULT BLOCKS ────────────────────────────────── */
.ai-result-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 7px; }
.ai-result-text  { font-size: 13.5px; line-height: 1.65; color: var(--muted2); white-space: pre-wrap; }
.action-item-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.action-item-row:last-child { border-bottom: none; }
/* ai-check duplicate removed — see canonical definition above */
.ai-text         { flex: 1; font-size: 13px; }
.ai-text.done    { text-decoration: line-through; color: var(--muted); }
.job-bar         { padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.job-bar.processing { background: rgba(107,92,255,.1); border: 1px solid rgba(107,92,255,.2); color: var(--accent2); }
.job-bar.failed     { background: rgba(232,85,85,.1); border: 1px solid rgba(232,85,85,.2); color: var(--red); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; flex-shrink: 0; }

/* ── RISK REASON ROW ─────────────────────────────────── */
.risk-reason-row  { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.risk-reason-row:last-child { border-bottom: none; }
.risk-reason-icon { font-size: 14px; flex-shrink: 0; }
.risk-reason-text { flex: 1; font-size: 12.5px; }
.risk-reason-pts  { font-family: var(--font-m); font-size: 11.5px; color: var(--red); flex-shrink: 0; }

/* ── DONUT CHART ─────────────────────────────────────── */
.donut-wrap   { display: flex; align-items: center; gap: 16px; }
.donut-svg    { flex-shrink: 0; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.donut-item   { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.donut-dot    { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ── BAR CHART ───────────────────────────────────────── */
.bar-chart    { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding: 0 2px; }
.bar-col      { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; }
.bar-val      { font-family: var(--font-m); font-size: 10px; color: var(--muted2); }
.bar-fill     { width: 100%; border-radius: 3px 3px 0 0; background: var(--accent); min-height: 2px; transition: height .3s; }
.bar-label    { font-size: 9px; color: var(--muted); font-family: var(--font-m); white-space: nowrap; }

/* ── DUE DATE COLORS ─────────────────────────────────── */
.due-overdue { color: var(--red); font-weight: 600; }
.due-soon    { color: var(--amber); }
.due-ok      { color: var(--muted2); }

/* ── CRm/CONV FILTER BAR ─────────────────────────────── */
.conv-filters   { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.crm-tab-bar    { display: flex; gap: 2px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; margin-bottom: 16px; width: fit-content; }
.crm-tab        { padding: 6px 16px; border-radius: calc(var(--r-sm) - 2px); background: transparent; border: none; color: var(--muted2); font-size: 13px; cursor: pointer; transition: all .12s; }
.crm-tab.on     { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.2); }

/* ── SEARCH INPUT ────────────────────────────────────── */
.search-wrap    { position: relative; flex: 1; max-width: 280px; }
.search-wrap svg{ position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted2); }
.search-input   { width: 100%; padding: 7px 10px 7px 32px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--r-sm); color: var(--text); font-size: 13px; }
.search-input:focus { outline: none; border-color: var(--accent); }
.filter-select  { padding: 7px 10px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--r-sm); color: var(--text); font-size: 13px; cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--accent); }

/* ── AI COACHING PANEL ─────────────────────────────── */
.coaching-card {
  border-color: rgba(107,92,255,.25);
  background: linear-gradient(135deg,rgba(107,92,255,.04) 0%,var(--surface) 100%);
}
.coaching-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 4px;
}
.coaching-positive { background: rgba(29,184,145,.08); color: var(--text); }
.coaching-positive span:first-child { color: var(--green); font-weight:700; flex-shrink:0; }
.coaching-improve  { background: rgba(245,158,11,.08); color: var(--text); }
.coaching-improve  span:first-child { color: var(--amber); font-weight:700; flex-shrink:0; }
.coaching-missed   { background: rgba(232,85,85,.06); color: var(--text); }
.coaching-missed   span:first-child { color: var(--red); font-weight:700; flex-shrink:0; }

/* ═══════════════════════════════════════════════════════════════════
   PHASE 1 — MOBILE RESPONSIVE (iOS & Android web)
   Full mobile experience: bottom nav, slide drawer, card views
   ═══════════════════════════════════════════════════════════════════ */

/* ── Safe area support for iPhone notch / home indicator ── */
:root {
  --mobile-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ── BOTTOM NAV BAR (mobile only) ── */
#mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--mobile-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  flex-direction: row;
  align-items: stretch;
}
.mob-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--muted2);
  cursor: pointer;
  padding: 6px 2px;
  transition: color var(--trans);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.mob-nav-btn.on { color: var(--accent2); }
.mob-nav-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.mob-nav-btn span { font-size: 9.5px; font-family: var(--font-m); letter-spacing: .02em; }
.mob-nav-btn.on::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}
.mob-nav-more-badge {
  position: absolute;
  top: 6px; right: calc(50% - 16px);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--surface);
  display: none;
}
.mob-nav-more-badge.on { display: block; }

/* ── SLIDE DRAWER (full nav on mobile) ── */
#mob-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 300;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 200ms ease;
}
#mob-drawer-overlay.open { opacity: 1; }

#mob-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 310;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 240ms cubic-bezier(.4,0,.2,1);
  padding-top: var(--safe-top);
}
#mob-drawer.open { transform: translateX(0); }

.mob-drawer-head {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mob-drawer-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-h);
  font-weight: 800; font-size: 17px;
}
.mob-drawer-close {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--muted2);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 16px;
}

.mob-drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  -webkit-overflow-scrolling: touch;
}
.mob-drawer-nav .nav {
  padding: 11px 20px;
  font-size: 14px;
  border-radius: 0;
}

.mob-drawer-foot {
  padding: 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: calc(14px + var(--safe-bottom));
}

/* ── MOBILE TOPBAR ── */
#mob-topbar-menu {
  display: none;
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--muted2);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
#mob-topbar-menu svg { width: 18px; height: 18px; }

/* ── MOBILE VIEW PADDING (above bottom nav) ── */
@media (max-width: 640px) {
  :root { --sidebar: 0px; }
  #sidebar { display: none !important; }
  #main { margin-left: 0; }
  #mobile-nav { display: flex; }
  #mob-topbar-menu { display: flex; }

  #view {
    padding: 16px 14px;
    padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 16px);
  }

  #topbar { padding: 0 14px; }

  /* Page headers */
  .ph { flex-wrap: wrap; gap: 10px; }
  .pt { font-size: 18px; }

  /* Stats stack to 2 col */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .three-col  { grid-template-columns: 1fr; }
  .kpi-row    { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Tables become scrollable horizontally */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-wrap table { min-width: 520px; }

  /* Cards fill width */
  .crm-grid { grid-template-columns: 1fr; }

  /* Deal detail / task detail stack */
  .deal-detail-grid  { grid-template-columns: 1fr !important; }
  .task-detail-grid  { grid-template-columns: 1fr !important; }
  .analytics-grid    { grid-template-columns: 1fr !important; }
  .analytics-grid-3  { grid-template-columns: 1fr !important; }
  .two-col           { grid-template-columns: 1fr !important; }

  /* Conversation filters wrap */
  .conv-filters { flex-wrap: wrap; gap: 8px; }
  .search-wrap  { max-width: 100%; flex: 1 1 100%; }
  .filter-select { flex: 1; min-width: 120px; }

  /* Section cards */
  .section-card { padding: 14px; }

  /* Modals full-width on mobile */
  .modal-box {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    margin: 12px !important;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  /* Pipeline board horizontal scroll */
  .pipeline-board { grid-template-columns: repeat(4,240px) !important; overflow-x: auto; padding-bottom: 8px; }

  /* Manager pipeline rep grid */
  .rep-grid { grid-template-columns: 1fr !important; }

  /* AI assistant chat height reduced */
  #repChatMessages { min-height: 320px; }

  /* Kanban 1 col */
  .kanban-board { grid-template-columns: 1fr !important; }

  /* Topbar context badge hidden on mobile (shown in drawer) */
  .ctx-badge { display: none; }

  /* KPI row 2 col */
  .kpi-row { display: grid !important; grid-template-columns: 1fr 1fr; }

  /* Table action buttons smaller */
  .btn-sm { padding: 5px 10px; font-size: 11px; }

  /* Rep assistant grid stack */
  #repAssistantGrid { grid-template-columns: 1fr !important; }

  /* Touch-friendly tap targets */
  .nav, .btn, button { min-height: 40px; }

  /* Section title font size */
  .section-title { font-size: 13px; }

  /* Chart cards */
  .chart-card { padding: 14px; }

  /* Deal stage track scroll */
  .deal-stage-track { gap: 2px; }
  .stage-btn { padding: 6px 10px; font-size: 11px; flex-shrink: 0; }
}

/* ── TABLET (641–860px) ── */
@media (min-width: 641px) and (max-width: 860px) {
  :root { --sidebar: 200px; }
  .nav span, .s-section { font-size: 12px; }
  #view { padding: 20px 20px; }
}

/* ── PULL-TO-REFRESH indicator ── */
#pull-indicator {
  display: none;
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-family: var(--font-m);
  padding: 4px 12px;
  border-radius: 20px;
  z-index: 500;
  opacity: 0;
  transition: opacity 200ms;
}
#pull-indicator.show { opacity: 1; }

/* ── MOBILE SWIPE HINT (first time) ── */
.mob-swipe-hint {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 8px;
  font-family: var(--font-m);
}

/* ── TOAST position above bottom nav on mobile ── */
@media (max-width: 640px) {
  #toast {
    bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 12px) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   BATCH B CSS — Fonts, Mobile Purple, Layout Fixes
   ═══════════════════════════════════════════════════════════════════ */

/* ── Dashboard metric boxes — premium number font ── */
/* Import a sharp monospaced display font for numbers */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@700;800&family=Outfit:wght@700;800;900&display=swap');

.stat-v,
.kpi-val,
.kpi-value,
.stat .stat-v {
  font-family: 'Outfit', 'Space Grotesk', var(--font-h), sans-serif !important;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.kpi-label,
.stat-l,
.stat-s {
  font-family: var(--font-m);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Rep pipeline numbers */
.rep-row [style*="font-size:16px"][style*="font-weight:700"],
.rep-row [style*="font-size:18px"] {
  font-family: 'Outfit', var(--font-h), sans-serif !important;
  font-weight: 800;
}

/* ── MOBILE ONLY — Purple bottom nav + topbar ── */
@media (max-width: 640px) {

  /* Bottom nav bar — purple active */
  #mobile-nav {
    background: var(--surface) !important;
    border-top: 1px solid var(--accent) !important;
  }

  .mob-nav-btn.on {
    color: var(--accent2) !important;
  }
  .mob-nav-btn.on::before {
    background: var(--accent) !important;
  }
  .mob-nav-btn svg {
    width: 22px;
    height: 22px;
  }

  /* Topbar — purple tint on mobile */
  #topbar {
    background: linear-gradient(135deg, #0d0b1a 0%, #120f24 100%) !important;
    border-bottom: 1px solid rgba(107,92,255,.35) !important;
  }

  /* Topbar title area purple accent */
  .ctx-badge {
    background: rgba(107,92,255,.2) !important;
    border-color: rgba(107,92,255,.45) !important;
    color: var(--accent2) !important;
  }

  /* Mob drawer head purple */
  .mob-drawer-head {
    background: linear-gradient(135deg, #0d0b1a 0%, #120f24 100%);
    border-bottom: 1px solid rgba(107,92,255,.3);
  }

  /* ── Mobile layout overflow fixes ── */

  /* No horizontal overflow anywhere */
  #view, #main, body { overflow-x: hidden; }

  /* Page header wraps properly */
  .ph {
    flex-wrap: wrap;
    gap: 10px;
  }
  .ph .flex-r {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Buttons don't overflow on mobile */
  .btn { max-width: 100%; white-space: nowrap; }

  /* Section cards full width */
  .section-card { width: 100%; box-sizing: border-box; }

  /* Deal detail / account detail stack */
  .deal-detail-grid,
  .task-detail-grid { grid-template-columns: 1fr !important; }

  /* Analytics grid single col */
  .analytics-grid,
  .analytics-grid-3 { grid-template-columns: 1fr !important; }

  /* KPI row — 2 wide */
  .kpi-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
  }

  /* Stat grid 2 col */
  .stat-grid { grid-template-columns: 1fr 1fr !important; }

  /* Tables scroll horizontally, never push layout */
  .card .tbl-wrap,
  .tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Pipeline board horizontal scroll */
  .pipeline-board {
    display: flex !important;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .pipeline-col {
    min-width: 220px;
    flex-shrink: 0;
  }

  /* Chat bubbles */
  .chat-bubble { max-width: 90vw; word-break: break-word; }

  /* Modals full width */
  .modal-box {
    width: calc(100vw - 16px) !important;
    max-width: 100% !important;
    margin: 8px !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Rep assistant grid stack */
  [id="repAssistantGrid"] { grid-template-columns: 1fr !important; }

  /* Manager pipeline grid */
  [style*="grid-template-columns:1fr 320px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1fr 260px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1fr 300px"] { grid-template-columns: 1fr !important; }

  /* Dial pad centered */
  [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }

  /* CRM grid single col */
  .crm-grid { grid-template-columns: 1fr !important; }

  /* Text sizes more readable */
  .pt { font-size: 17px !important; }
  .ps { font-size: 12px !important; }

  /* Topbar super admin badge */
  .b.b-pink { font-size: 10px; }

  /* Notif panel full width */
  #notifPanel { width: calc(100vw - 20px) !important; right: 10px !important; }

  /* Dialpad center */
  .dial-key { touch-action: manipulation; }
}

/* ── TABLET tweaks ── */
@media (min-width: 641px) and (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr) !important; }
  .analytics-grid-3 { grid-template-columns: 1fr 1fr !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE CONV DETAIL — sidebar moves above transcript
   KNOWLEDGE BASE — accordion on mobile, sidebar on desktop
   ═══════════════════════════════════════════════════════════════════ */

/* ── Knowledge Base — show/hide by viewport ── */
.kb-mobile-only  { display: none; }
.kb-desktop-only { display: grid; }

@media (max-width: 640px) {
  .kb-mobile-only  { display: block; }
  .kb-desktop-only { display: none !important; }

  /* ── Conv detail — move sidebar above main content on mobile ── */
  #convDetailGrid {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }

  /* Sidebar appears first (order: -1) above transcript */
  #convDetailSidebar {
    order: -1;
  }

  /* Sidebar meta card horizontal row layout on mobile */
  #convDetailSidebar .task-meta-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
  }
  #convDetailSidebar .task-meta-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 8px;
    background: var(--surface2);
    border-radius: var(--r-sm);
    border-bottom: none;
  }
  #convDetailSidebar .task-meta-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
  }

  /* Status + link account buttons become a row */
  #convDetailSidebar > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin-top: 0 !important;
  }

  /* ── KB Accordion ── */
  .kb-accord-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color .15s;
  }
  .kb-accord-item.open {
    border-color: var(--accent);
  }
  .kb-accord-head {
    width: 100%;
    background: none;
    border: none;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
  }
  .kb-accord-head:active { background: var(--surface2); }
  .kb-accord-icon { font-size: 20px; flex-shrink: 0; }
  .kb-accord-body {
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--text);
  }

  /* KB pill filter */
  .kb-pill.on {
    background: rgba(107,92,255,.2) !important;
    border-color: var(--accent) !important;
    color: var(--accent2) !important;
  }
}

/* ── Dashboard mobile fixes ─────────────────────────────────────── */
@media (max-width: 600px) {
  /* Stack dashboard bottom grid vertically on mobile */
  .dash-bottom-grid {
    grid-template-columns: 1fr !important;
  }
  /* Task rows — allow full text to show, no truncation */
  .dash-task-row {
    align-items: flex-start !important;
    flex-wrap: nowrap;
    min-height: 44px;
    padding: 10px 12px !important;
  }
  .dash-task-row > div:first-child span:last-child {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    word-break: break-word;
  }
  /* Right column stacks below tasks */
  .dash-right-col {
    width: 100%;
  }
  /* Stat grid — 2 columns on mobile */
  .stat-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .stat-v {
    font-size: 24px !important;
  }
  /* Section cards full width */
  .dash-tasks-card {
    width: 100%;
    box-sizing: border-box;
  }
}

/* ── Action item rows — never clip text ─────────────────────────── */
.action-item-row {
  flex-wrap: nowrap;
}
.action-item-row > div:first-child {
  min-width: 0;
  flex: 1;
}


/* ═══════════════════════════════════════════
   THEME TOGGLE BUTTON
═══════════════════════════════════════════ */
.theme-toggle {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--muted2);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--trans);
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); background: var(--surface4); border-color: var(--border2); }
.theme-toggle svg { width: 15px; height: 15px; }

/* ── Light mode specific fixes ── */
[data-theme="light"] .stat { background: #fff; }
[data-theme="light"] .card { background: #fff; }
[data-theme="light"] .section-card { background: #fff; }
[data-theme="light"] .fi, [data-theme="light"] .fs { background: #fff; border-color: #e5e5e5; }
[data-theme="light"] tr:hover td { background: #f9f9f9; }
[data-theme="light"] .nav.on { background: rgba(124,58,237,.08); color: var(--accent); }
[data-theme="light"] .nav:hover { background: #f0f0f0; }
[data-theme="light"] .u-chip { background: #f5f5f5; }
[data-theme="light"] .ctx-badge { background: #f0f0f0; border-color: #e5e5e5; }
[data-theme="light"] code, [data-theme="light"] .font-m { background: #f5f5f5; }

/* ── SLIDE UP ANIMATION ── */
@keyframes slideUp {
  from { opacity:0; transform:translateX(-50%) translateY(20px); }
  to   { opacity:1; transform:translateX(-50%) translateY(0); }
}
@keyframes slideUpFixed {
  from { opacity:0; transform:translateY(20px); }
  to   { opacity:1; transform:translateY(0); }
}
