/* LeadLink Pro - design system (ported from LeadLink mockup tokens) */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eef0f4;
  --text: #1f2129;
  --text-muted: #676e7c;
  --text-faint: #9aa3b2;
  --text-dim: #c4cad4;
  --border: #e6e9ef;
  --border-strong: #dcdfe4;
  --hover: #f6f7fb;
  --accent: #0073ea;
  --accent-hover: #0060b9;
  --accent-tint: #e6f4ff;
  --danger: #e2445c;
  --success: #00c875;
  --sidebar-bg: #ffffff;
  --shadow-card: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --shadow-pop: 0 12px 32px -8px rgba(15,23,42,.18), 0 4px 10px rgba(15,23,42,.08);
  --shadow-drawer: 24px 0 48px -12px rgba(15,23,42,.18);
}
html[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #1f222c;
  --surface-3: #2a2f3c;
  --text: #e6e9ef;
  --text-muted: #b8c0cc;
  --text-faint: #8891a1;
  --text-dim: #6e7787;
  --border: #2a2f3c;
  --border-strong: #3a4050;
  --hover: #222632;
  --accent: #4c8df6;
  --accent-hover: #6aa0fa;
  --accent-tint: rgba(76,141,246,.15);
  --sidebar-bg: #14161c;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: Heebo, ui-sans-serif, system-ui, -apple-system, sans-serif;
}
button { font-family: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== buttons / inputs ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s; user-select: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-outline:hover { background: var(--danger); color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.btn-icon {
  width: 34px; height: 34px; padding: 0; border-radius: 8px;
  display: grid; place-items: center; color: var(--text-muted);
  border: 1px solid var(--border-strong); background: var(--surface);
}
.btn-icon:hover { background: var(--hover); color: var(--text); }

.input {
  height: 36px; width: 100%; border-radius: 8px; padding: 0 12px; font-size: 14px;
  outline: none; background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
textarea.input { height: auto; padding: 8px 12px; min-height: 64px; resize: vertical; }
select.input { cursor: pointer; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 12px 0 5px; }

/* ===== login ===== */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background: linear-gradient(135deg, #0073ea 0%, #00c875 130%);
}
.login-card {
  width: min(380px, calc(100vw - 32px)); background: var(--surface);
  border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow-pop);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.logo-mark {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #0073ea, #00c875);
  color: #fff; font-weight: 800; font-size: 20px;
}
.logo-title { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.logo-title span { color: var(--accent); }
.logo-sub { font-size: 12px; color: var(--text-faint); }
.login-btn { width: 100%; margin-top: 18px; height: 42px; font-size: 15px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; font-weight: 600; }

/* ===== app shell ===== */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
.sidebar-logo .logo-mark { width: 32px; height: 32px; flex-basis: 32px; font-size: 16px; border-radius: 8px; }
.sidebar-logo .logo-title { font-size: 16px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px;
  border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--text-muted);
  transition: background .12s, color .12s; text-align: start;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-tint); color: var(--accent); font-weight: 700; }
.sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.user-chip { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 999px;
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
}
.user-chip-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-role { font-size: 11px; color: var(--text-faint); }
.btn-logout {
  width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center;
  color: var(--text-faint);
}
.btn-logout:hover { background: var(--hover); color: var(--danger); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex: 0 0 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; flex-wrap: wrap; }
.search-wrap { position: relative; }
.search-wrap .input { width: 210px; padding-inline-start: 32px; }
.search-wrap svg { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.filter-select { width: auto; min-width: 120px; }

.view { flex: 1; overflow: auto; padding: 18px 20px; }

/* ===== board groups ===== */
.group { margin-bottom: 22px; }
.group-bar {
  display: flex; align-items: center; gap: 8px; height: 34px; cursor: pointer; user-select: none;
  font-weight: 700; font-size: 15px;
}
.group-bar .chev { transition: transform .15s; display: grid; place-items: center; }
.group.collapsed .chev { transform: rotate(-90deg); }
.group-count { font-size: 12px; font-weight: 600; color: var(--text-faint); }
.group-table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  overflow-x: auto; box-shadow: var(--shadow-card);
}
.group.collapsed .group-table-wrap { display: none; }

table.board { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; }
.board th, .board td {
  height: 38px; padding: 0 10px; vertical-align: middle; text-align: start;
  border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative;
  background: var(--surface);
}
.board th:last-child, .board td:last-child { border-inline-end: 0; }
.board tr:last-child td { border-bottom: 0; }
.board th {
  height: 34px; font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: var(--surface-2); user-select: none;
}
.board tbody tr:hover td { background: var(--hover); }
.board td.cell-chip { padding: 3px 5px; }
.board .group-edge { width: 5px; min-width: 5px; max-width: 5px; padding: 0; border-inline-end: 0; }

.th-add { width: 44px; text-align: center; }
.th-add button {
  width: 24px; height: 24px; border-radius: 6px; display: inline-grid; place-items: center;
  color: var(--text-faint); font-size: 16px; font-weight: 700;
}
.th-add button:hover { background: var(--hover); color: var(--accent); }
.th-actions { width: 96px; }

/* chips */
.m-chip {
  display: flex; align-items: center; justify-content: center; width: 100%;
  height: 30px; padding: 0 10px; border-radius: 6px; color: #fff;
  font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; transition: filter .12s;
  border: 0; min-width: 0;
}
.m-chip:hover { filter: brightness(1.08); }
.m-chip.empty { background: var(--surface-3); color: var(--text-faint); }
.person-chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  height: 30px; padding: 0 8px; border-radius: 6px; max-width: 100%;
}
.person-chip:hover { background: var(--surface-3); }
.person-chip .avatar { width: 24px; height: 24px; flex-basis: 24px; font-size: 10px; }
.person-chip span.nm { overflow: hidden; text-overflow: ellipsis; }
.person-chip.empty { color: var(--text-faint); }

/* row actions */
.row-actions { display: inline-flex; align-items: center; gap: 2px; }
.row-action {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px;
  color: var(--text-muted); transition: background .12s, color .12s;
}
.row-action:hover { background: var(--hover); color: var(--text); }
.row-action.wa { color: #25d366; }
.row-action.wa:hover { background: rgba(37,211,102,.14); }
.row-action.call { color: var(--accent); }
.row-action.call:hover { background: var(--accent-tint); }
.row-action.danger { color: var(--danger); opacity: 0; }
tr:hover .row-action.danger { opacity: 1; }
.row-action.danger:hover { background: rgba(226,68,92,.14); }

/* inline cell editing */
.cell-text { cursor: text; display: block; min-height: 18px; }
.cell-text.faint { color: var(--text-faint); }
.cell-input {
  width: 100%; outline: none; border: 0; font-size: 13px; color: var(--text);
  background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 4px; padding: 3px 6px; caret-color: var(--accent);
}
.lead-name { font-weight: 600; cursor: pointer; color: var(--text); }
.lead-name:hover { color: var(--accent); text-decoration: underline; }
.name-cell { padding: 0 6px 0 10px; }
.name-cell-inner { display: flex; align-items: center; gap: 2px; min-width: 0; }
.name-cell-inner .lead-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-cell-inner .row-actions { flex: 0 0 auto; }

.add-row td { color: var(--text-faint); cursor: pointer; font-weight: 500; }
.add-row:hover td { color: var(--accent); background: var(--hover); }

/* ===== custom select (replaces native <select>) ===== */
.ll-select {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: 8px; width: 100%;
  background: var(--surface); border: 1px solid var(--border-strong);
  cursor: pointer; font-size: 14px; text-align: start; user-select: none;
  transition: border-color .12s, box-shadow .12s;
}
.ll-select:hover { border-color: var(--accent); }
.ll-select.open, .ll-select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.ll-select .sel-label {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500;
}
.ll-select .sel-label.placeholder { color: var(--text-faint); font-weight: 400; }
.ll-select .sel-caret { color: var(--text-faint); flex: 0 0 auto; display: grid; place-items: center; transition: transform .18s; }
.ll-select.open .sel-caret { transform: rotate(180deg); }
.ll-select.compact { width: auto; min-width: 132px; }
.pop-option.selected { background: var(--accent-tint); color: var(--accent); font-weight: 700; }
.pop-option .pop-check { margin-inline-start: auto; color: var(--accent); display: grid; place-items: center; }

/* ===== custom checkbox ===== */
input[type="checkbox"].chk {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px; flex: 0 0 18px;
  border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; margin: 0;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
input[type="checkbox"].chk:hover { border-color: var(--accent); }
input[type="checkbox"].chk:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-tint); }
input[type="checkbox"].chk:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"].chk:checked::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg);
}

/* native date field - subtle branded indicator */
input[type="date"].input { position: relative; }
input[type="date"].input::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
input[type="date"].input::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* ===== popover ===== */
.popover {
  position: fixed; z-index: 600; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-pop); padding: 6px; min-width: 170px; max-width: 280px;
  max-height: 60vh; overflow: auto;
}
.popover .pop-option {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px;
  border-radius: 6px; font-size: 13px; font-weight: 500; text-align: start;
}
.popover .pop-option:hover { background: var(--hover); }
.pop-swatch { width: 14px; height: 14px; flex: 0 0 14px; border-radius: 4px; }
.pop-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.pop-link { color: var(--accent); font-weight: 600; }

/* ===== modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300; background: rgba(15,23,42,.45);
  display: grid; place-items: center; padding: 18px;
  animation: fadeIn .14s ease;
}
.modal {
  width: min(480px, 100%); max-height: 88vh; overflow: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-pop);
  padding: 22px;
  animation: popIn .16s cubic-bezier(.22,1,.36,1);
}
.modal.wide { width: min(620px, 100%); }
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--text-faint); margin-bottom: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(6px); } }

/* ===== drawer ===== */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(8, 11, 20, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadeIn .14s ease;
}
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 260;
  width: min(420px, 92vw); background: var(--surface);
  border-inline-end: 1px solid var(--border-strong);
  box-shadow: 24px 0 60px -8px rgba(0, 0, 0, .45), 4px 0 16px rgba(0, 0, 0, .25);
  display: flex; flex-direction: column;
  animation: drawerIn .2s cubic-bezier(.22,1,.36,1);
}
/* brand edge so the card reads as its own layer */
.drawer::before {
  content: ""; position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: 4px;
  background: linear-gradient(180deg, #0073ea, #00c875); z-index: 1;
}
@keyframes drawerIn { from { transform: translateX(-100%); } }
html[dir="rtl"] .drawer { } /* inset-inline-start in RTL = right; slide handled by transform */
.drawer-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-tint), transparent 70%), var(--surface-2);
}
.drawer-head .drawer-title::before { content: "👤 "; font-size: 15px; }
.drawer .input { background: var(--surface-2); }
.drawer .input:focus { background: var(--surface); }
.drawer-field .lbl { color: var(--text-faint); }
.drawer-title { font-size: 17px; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.drawer-body { flex: 1; overflow: auto; padding: 14px 18px; }
.drawer-field { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; margin-bottom: 10px; }
.drawer-field .lbl { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.drawer-section-title { font-size: 13px; font-weight: 700; margin: 18px 0 8px; color: var(--text); }
.note-input-row { display: flex; gap: 8px; margin-bottom: 12px; }
.timeline-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.timeline-item:last-child { border-bottom: 0; }
.timeline-icon {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 999px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-muted); font-size: 12px;
}
.timeline-meta { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.timeline-note { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-top: 4px; white-space: pre-wrap; }

/* ===== dashboard ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow-card); position: relative; overflow: hidden;
}
.kpi-card::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--kpi, var(--accent)); }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow-card);
}
.dash-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.hbar-row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.hbar-track { height: 14px; border-radius: 7px; background: var(--surface-3); overflow: hidden; display: flex; justify-content: flex-start; }
.hbar-fill { height: 100%; border-radius: 7px; min-width: 2px; transition: width .4s ease; }
.hbar-count { font-weight: 700; font-size: 12px; text-align: end; }
.mini-list-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.mini-list-item:last-child { border-bottom: 0; }
.mini-chip { padding: 2px 9px; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 700; margin-inline-start: auto; white-space: nowrap; }

/* ===== automations ===== */
.auto-list { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.auto-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow-card);
}
.auto-card-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.auto-sentence { flex: 1; min-width: 220px; font-size: 14px; line-height: 1.9; }
.auto-token {
  display: inline-block; padding: 1px 9px; border-radius: 6px; font-weight: 700; font-size: 13px;
  background: var(--accent-tint); color: var(--accent); margin: 0 2px;
}
.auto-token.value-token { color: #fff; }
.auto-token.url { direction: ltr; unicode-bidi: embed; background: var(--surface-3); color: var(--text-muted); font-size: 11.5px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.auto-meta { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.auto-runs { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; font-size: 12px; }
.run-row { display: flex; gap: 10px; padding: 3px 0; color: var(--text-muted); }
.run-ok { color: var(--success); font-weight: 700; }
.run-fail { color: var(--danger); font-weight: 700; }
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-faint);
}
.empty-state .big { font-size: 38px; margin-bottom: 10px; }
.empty-state p { margin-bottom: 14px; }

/* toggle */
.ll-toggle {
  position: relative; display: inline-flex; width: 38px; height: 22px; flex: 0 0 38px;
  border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong);
  cursor: pointer; transition: background .16s, border-color .16s;
}
.ll-toggle::after {
  content: ""; position: absolute; top: 50%; inset-inline-start: 2px; width: 16px; height: 16px;
  border-radius: 999px; background: #fff; transform: translateY(-50%);
  transition: inset-inline-start .18s cubic-bezier(.22,1,.36,1);
  box-shadow: 0 1px 2px rgba(15,23,42,.2);
}
.ll-toggle[data-on="true"] { background: var(--success); border-color: var(--success); }
.ll-toggle[data-on="true"]::after { inset-inline-start: 18px; }

/* ===== users page ===== */
.users-table-wrap, .settings-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-card); overflow: hidden; max-width: 920px;
}
.settings-card { padding: 18px; margin-bottom: 16px; overflow: visible; }
.settings-card h3 { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.settings-card .sub { font-size: 12.5px; color: var(--text-faint); margin-bottom: 12px; }
table.flat { width: 100%; border-collapse: collapse; font-size: 13px; }
.flat th { text-align: start; font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); }
.flat td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.flat tr:last-child td { border-bottom: 0; }
.flat tr:hover td { background: var(--hover); }
.role-badge { padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.role-badge.admin { background: var(--accent-tint); color: var(--accent); }
.role-badge.agent { background: var(--surface-3); color: var(--text-muted); }
.perm-chip { display: inline-block; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-muted); font-size: 10.5px; font-weight: 600; margin: 1px; }
.inactive-row td { opacity: .5; }

.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; margin-top: 8px; }
.perm-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.perm-item input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* options editor */
.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.opt-row .input { flex: 1; }
.color-dot { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px; cursor: pointer; border: 2px solid var(--border-strong); }
.palette { display: grid; grid-template-columns: repeat(8, 22px); gap: 6px; padding: 4px; }
.palette button { width: 22px; height: 22px; border-radius: 6px; }
.palette button:hover { transform: scale(1.15); }
.opt-del { color: var(--text-faint); width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; }
.opt-del:hover { color: var(--danger); background: rgba(226,68,92,.1); }

/* columns manager */
.col-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.col-row:last-child { border-bottom: 0; }
.col-row .col-label { flex: 1; font-weight: 600; }
.col-type-badge { font-size: 11px; color: var(--text-faint); background: var(--surface-3); padding: 2px 8px; border-radius: 99px; }
.col-move { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--text-faint); }
.col-move:hover { background: var(--hover); color: var(--text); }
.col-move:disabled { opacity: .3; cursor: default; }

/* webhook box */
.code-box {
  direction: ltr; text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre; color: var(--text-muted);
}
.copy-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.copy-row .code-box { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 8px 12px; }

/* ===== toasts ===== */
.toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 400; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-pop);
  animation: toastIn .2s cubic-bezier(.22,1,.36,1);
  display: flex; align-items: center; gap: 8px;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* misc */
.muted { color: var(--text-faint); }
.spacer { flex: 1; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 760px) {
  .topbar { height: auto; flex: 0 0 auto; flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .topbar-title { width: 100%; font-size: 17px; }
  .topbar-actions { margin-inline-start: 0; width: 100%; justify-content: flex-start; }
  .search-wrap { flex: 1; min-width: 140px; }
  .search-wrap .input { width: 100%; }
  .view { padding: 12px; }
  .sidebar { width: 64px; flex-basis: 64px; padding: 12px 8px; }
  .sidebar-logo .logo-title, .nav-item > :not(svg):not(.nav-ico), .user-chip-name, .user-chip-role { display: none; }
  .nav-item { justify-content: center; font-size: 0; gap: 0; }
  .nav-item svg { width: 20px; height: 20px; }
  .sidebar-logo { justify-content: center; }
  .user-chip { justify-content: center; }
  .search-wrap .input { width: 130px; }
  .drawer-field { grid-template-columns: 1fr; gap: 3px; }
}

/* ===== nav + bell badges ===== */
.nav-badge, .bell-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; line-height: 1;
}
.bell-wrap { position: relative; }
.bell-badge { position: absolute; top: -6px; inset-inline-end: -6px; }
#bellBtn { position: relative; }
.notif-panel {
  position: absolute; top: 42px; inset-inline-end: 0; z-index: 350;
  width: 330px; max-height: 420px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-pop); padding: 6px;
}
.notif-item {
  display: flex; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer;
  align-items: flex-start;
}
.notif-item:hover { background: var(--hover); }
.notif-item.unread { background: var(--accent-tint); }
.notif-item.unread:hover { background: var(--accent-tint); filter: brightness(.97); }
.notif-icon { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); font-size: 14px; }
.notif-title { font-weight: 700; font-size: 13px; }
.notif-body { font-size: 12.5px; color: var(--text-muted); }
.notif-time { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 4px; font-weight: 800; font-size: 14px; }

/* ===== bulk bar ===== */
.bulk-bar {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 150;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px;
  box-shadow: var(--shadow-pop); animation: toastIn .2s cubic-bezier(.22,1,.36,1);
  max-width: calc(100vw - 24px);
}
.bulk-count { font-weight: 800; font-size: 14px; white-space: nowrap; }
.bulk-bar .btn { height: 32px; font-size: 13px; }
.bulk-bar .ll-select { height: 32px; width: auto; min-width: 130px; background: var(--surface); color: var(--text); font-size: 13px; }
.row-check, .group-check {
  width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer;
  appearance: none; -webkit-appearance: none; border-radius: 4px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: inline-grid; place-items: center; margin: 0; vertical-align: middle;
}
.row-check:checked, .group-check:checked { background: var(--accent); border-color: var(--accent); }
.row-check:checked::after, .group-check:checked::after {
  content: ""; width: 8px; height: 4px; margin-top: -1px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg);
}
.board .th-check, .board td.td-check { width: 36px; min-width: 36px; text-align: center; padding: 0 8px; }

/* ===== header sort / filter ===== */
.th-inner { display: flex; align-items: center; gap: 4px; }
.th-inner .th-label { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; cursor: pointer; }
.th-btn {
  width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center;
  color: var(--text-faint); opacity: 0; transition: opacity .12s, background .12s; flex: 0 0 auto;
}
.board th:hover .th-btn { opacity: 1; }
.th-btn:hover { background: var(--surface-3); color: var(--text); }
.th-btn.active { opacity: 1; color: var(--accent); }
.filters-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: 99px; background: var(--accent-tint); color: var(--accent);
  font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.pop-filter { padding: 8px; min-width: 210px; }
.pop-filter .field-label { margin-top: 8px; }
.pop-filter .row2 { display: flex; gap: 6px; }

/* ===== notes popover ===== */
.popover { overflow-x: hidden; }
.popover:has(.notes-pop) { max-width: 340px; width: 320px; }
.notes-pop { width: 100%; padding: 10px; }
.notes-pop .note-input-row .btn { flex: 0 0 auto; }
.notes-pop .notes-list { max-height: 240px; overflow: auto; margin-bottom: 8px; }
.note-bubble { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; white-space: pre-wrap; }
.note-bubble .nb-meta { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.row-action .ra-badge {
  position: absolute; top: -3px; inset-inline-end: -3px; min-width: 14px; height: 14px;
  border-radius: 99px; background: var(--accent); color: #fff; font-size: 9px; font-weight: 700;
  display: grid; place-items: center; padding: 0 3px;
}
.row-action { position: relative; }

/* ===== tasks page ===== */
.tasks-wrap { max-width: 760px; }
.task-section-title { font-size: 14px; font-weight: 800; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.task-section-title.overdue { color: var(--danger); }
.task-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 6px; box-shadow: var(--shadow-card);
}
.task-item.done .task-title { text-decoration: line-through; color: var(--text-faint); }
.task-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; }
.task-due { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.task-due.late { color: var(--danger); font-weight: 700; }
.task-lead-link { font-size: 12px; color: var(--accent); cursor: pointer; white-space: nowrap; }
.task-lead-link:hover { text-decoration: underline; }

/* ===== calendar ===== */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-title { font-size: 17px; font-weight: 800; min-width: 140px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--text-muted); padding: 4px 0; }
.cal-cell {
  min-height: 96px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px; font-size: 12px; overflow: hidden;
}
.cal-cell.other { opacity: .45; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.cal-daynum { font-weight: 700; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.cal-cell.today .cal-daynum { color: var(--accent); }
.cal-item {
  display: block; width: 100%; text-align: start; padding: 2px 6px; border-radius: 5px;
  font-size: 11px; font-weight: 600; margin-bottom: 3px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.cal-item.task { background: var(--accent); }
.cal-item.task.done-task { background: var(--text-faint); text-decoration: line-through; }
.cal-item.followup { background: #a25ddc; }
.cal-more { font-size: 10.5px; color: var(--text-faint); }

/* ===== reports ===== */
.report-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.report-range .input { width: 150px; }
.range-chip {
  height: 30px; padding: 0 12px; border-radius: 99px; font-size: 12.5px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-muted);
}
.range-chip:hover, .range-chip.active { background: var(--accent-tint); color: var(--accent); border-color: transparent; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.funnel-pct { font-size: 11px; color: var(--text-faint); }

/* ===== audit ===== */
.audit-row { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
.audit-row:last-child { border-bottom: 0; }
.audit-type { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.audit-time { font-size: 11px; color: var(--text-faint); margin-inline-start: auto; white-space: nowrap; }

/* ===== import mapping ===== */
.import-map-row { display: grid; grid-template-columns: 1fr 24px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.import-map-row .csv-col { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-arrow { color: var(--text-faint); text-align: center; }
.import-preview { font-size: 11px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-zone {
  border: 2px dashed var(--border-strong); border-radius: 12px; padding: 28px; text-align: center;
  color: var(--text-muted); cursor: pointer; transition: border-color .12s, background .12s;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--accent); background: var(--accent-tint); }

/* rr settings */
.rr-row { display: grid; grid-template-columns: 1fr 110px 110px; gap: 8px; align-items: center; margin-bottom: 8px; }
.rr-row .rr-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.rr-grid-head { display: grid; grid-template-columns: 1fr 110px 110px; gap: 8px; font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }

/* ===== centered cells + resize + sum rows ===== */
.board th, .board td { text-align: center; }
.board .th-inner { justify-content: center; }
.board .th-inner .th-label { flex: 0 1 auto; }
.name-cell-inner { display: flex; align-items: center; justify-content: center; gap: 8px; }
.name-cell-inner .lead-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-chip { max-width: 100%; }

.col-resize {
  position: absolute; top: 0; bottom: 0; inset-inline-end: -3px; width: 7px;
  cursor: col-resize; user-select: none; touch-action: none; z-index: 7;
}
.col-resize:hover { background: var(--accent); opacity: .5; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

.sum-row td {
  background: var(--surface-2) !important;
  font-weight: 800; font-size: 12.5px;
  border-top: 2px solid var(--border-strong);
  color: var(--text);
}
.sum-row .sum-label { color: var(--text-faint); font-weight: 700; font-size: 11px; }
