/* ==========================================================================
   Palvion Connect — dashboard stylesheet (v4)
   Dark-only glassmorphism · Outfit headings · Inter body · indigo→violet
   ========================================================================== */

/* ----- Tokens ----- */
:root {
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --bg-primary: #0b0c16;
  --bg-secondary: #121426;
  --bg-raised: #171a30;

  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --accent-gradient-hover: linear-gradient(135deg, #5356e2 0%, #7c4ce7 100%);

  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-bg-hover: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-strong: rgba(255, 255, 255, 0.14);

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --green: #10b981;   --green-soft: rgba(16, 185, 129, 0.13);  --green-text: #34d399;
  --red: #ef4444;     --red-soft: rgba(239, 68, 68, 0.13);     --red-text: #f87171;
  --orange: #f59e0b;  --orange-soft: rgba(245, 158, 11, 0.13); --orange-text: #fbbf24;
  --blue: #3b82f6;    --blue-soft: rgba(59, 130, 246, 0.13);   --blue-text: #60a5fa;
  --cyan: #06b6d4;    --cyan-soft: rgba(6, 182, 212, 0.13);    --cyan-text: #22d3ee;
  --violet-soft: rgba(139, 92, 246, 0.13);                     --violet-text: #a78bfa;
  --indigo-soft: rgba(99, 102, 241, 0.13);                     --indigo-text: #818cf8;
  --gray-soft: rgba(156, 163, 175, 0.13);

  --chart-sent: #818cf8;
  --chart-opened: #22d3ee;
  --chart-replied: #34d399;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-pop: 0 18px 45px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.35);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --sidebar-w: 260px;
}

/* ----- Reset & base ----- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* The ambient gradient lives on a fixed pseudo-layer, NOT background-attachment:
   fixed on body — fixed attachment forces the whole (6000px+) page into a
   single raster layer, which Android Chrome paints BLACK beyond its budget. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.13) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.10) 0%, transparent 40%);
}

h1, h2, h3, h4 { font-family: var(--font-heading); letter-spacing: -0.3px; }

::selection { background: rgba(139, 92, 246, 0.35); color: #fff; }

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.5); background-clip: padding-box; }

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .pill:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.hidden { display: none !important; }

/* ==========================================================================
   Layout chrome
   ========================================================================== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background-color: rgba(18, 20, 38, 0.72);
  border-right: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  /* On short viewports (landscape phones) the 9-item nav overflows the fixed
     sidebar — without this the bottom items are simply unreachable. */
  overflow-y: auto;
  transition: transform 0.28s var(--ease);
}

.brand {
  padding: 6px 12px 20px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(139, 92, 246, 0.3));
}

.logo-dot { color: var(--accent-2); }

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.nav-menu { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}

.nav-item i, .nav-item svg { width: 18px; height: 18px; flex: none; }

.nav-item:hover { background-color: var(--glass-bg-hover); color: var(--text-primary); transform: translateX(2px); }

.nav-item.active {
  background-image: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 3px;
  background: #fff;
  opacity: 0.9;
}

.sidebar-footer { padding-top: 14px; border-top: 1px solid var(--glass-border); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 15, 0.6);
  backdrop-filter: blur(2px);
  z-index: 35;
}

/* ----- Main panel & top bar ----- */
.main-panel {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 40px 48px;
  max-width: 1400px;
  min-width: 0;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 30px;
}

.top-bar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.top-bar h1 {
  font-size: 28px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.icon-btn:hover { background: var(--glass-bg-hover); color: var(--text-primary); }
.icon-btn i, .icon-btn svg { width: 18px; height: 18px; }

.hamburger { display: none; }

.status-panel {
  display: flex;
  gap: 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 8px 16px;
  border-radius: 30px;
  backdrop-filter: blur(10px);
  flex: none;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-dot.green { background-color: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.red { background-color: var(--red); box-shadow: 0 0 8px var(--red); }
.status-dot.orange { background-color: var(--orange); box-shadow: 0 0 8px var(--orange); }
.status-dot.gray { background-color: var(--text-muted); }

/* ----- Tab sections ----- */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s var(--ease); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   Shared components
   ========================================================================== */

/* ----- Cards ----- */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 22px;
}

.card-flush { padding: 0; overflow: hidden; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.card-head h3 { font-size: 17px; font-weight: 600; }

.card-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-top: 12px; }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-body);
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease),
              border-color 0.2s var(--ease), box-shadow 0.25s var(--ease), transform 0.2s var(--ease);
}

.btn i, .btn svg { width: 15px; height: 15px; flex: none; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background-image: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.28);
}
.btn-primary:hover:not(:disabled) {
  background-image: var(--accent-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background-color: var(--glass-bg);
  border-color: var(--glass-border);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) { background-color: var(--glass-bg-hover); border-color: var(--glass-border-strong); }

.btn-outline {
  background-color: transparent;
  border-color: var(--glass-border);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) { background-color: var(--glass-bg); color: var(--text-primary); }

.btn-danger {
  background-color: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red-text);
}
.btn-danger:hover:not(:disabled) { background-color: rgba(239, 68, 68, 0.22); }

.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.99); }

/* ----- Forms ----- */
.input-group { margin-bottom: 18px; display: flex; flex-direction: column; gap: 7px; text-align: left; }
.input-row { display: flex; gap: 14px; }
.flex-1 { flex: 1; min-width: 0; }
.flex-2 { flex: 2; min-width: 0; }

label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

input, select, textarea {
  background-color: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--glass-border);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

select { appearance: none; background-image: none; cursor: pointer; }
select option { background: var(--bg-secondary); color: var(--text-primary); }

textarea { resize: vertical; line-height: 1.5; }

.input-hint { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; text-transform: none; letter-spacing: 0; }

.form-section-title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--indigo-text);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 22px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--glass-border);
}
.form-section-title:first-child, .form-section-title.no-margin { margin-top: 0; }
.builder-header .form-section-title { border: none; padding: 0; margin: 0; }

.checkbox-group { justify-content: flex-end; }

.checkbox-row {
  flex-direction: row;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; flex: none; cursor: pointer; accent-color: var(--accent); }

.checkbox-list-container {
  max-height: 130px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.015);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-item { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-primary); }
.checkbox-item input { width: 15px; height: 15px; flex: none; cursor: pointer; accent-color: var(--accent); }
.checkbox-item label { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; color: var(--text-primary); cursor: pointer; }

.muted-note { font-size: 12.5px; color: var(--text-muted); font-style: italic; }

.select-compact { width: auto; min-width: 180px; }

/* ----- Badges & pills ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-green { background: var(--green-soft); color: var(--green-text); }
.badge-red { background: var(--red-soft); color: var(--red-text); }
.badge-orange { background: var(--orange-soft); color: var(--orange-text); }
.badge-blue { background: var(--blue-soft); color: var(--blue-text); }
.badge-violet { background: var(--violet-soft); color: var(--violet-text); }
.badge-gray { background: var(--gray-soft); color: var(--text-secondary); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

.pill {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-body);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.pill:hover { color: var(--text-primary); border-color: var(--glass-border-strong); }

.pill.active {
  background-image: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ----- Tables ----- */
.table-scroll { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; text-align: left; }

.table th {
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  white-space: nowrap;
}

.table tbody tr { transition: background-color 0.15s var(--ease); }
.table tbody tr:hover { background-color: rgba(255, 255, 255, 0.02); }
.table tbody tr:last-child td { border-bottom: none; }

.row-link { cursor: pointer; }

.cell-strong { font-weight: 600; color: var(--text-primary); }
.cell-muted { color: var(--text-muted); }
.th-actions { width: 44px; }

.table-empty-cell { text-align: center; padding: 48px 20px !important; color: var(--text-muted); }
.table-empty-cell i, .table-empty-cell svg { width: 36px; height: 36px; display: block; margin: 0 auto 12px; color: var(--text-muted); }

/* ----- Row action menu ----- */
.row-menu { position: relative; display: inline-block; }

.row-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 170px;
  background: var(--bg-raised);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 30;
  display: none;
}

.row-menu.open .row-menu-list { display: block; animation: fadeIn 0.15s var(--ease); }

.row-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s var(--ease);
}

.row-menu-item i, .row-menu-item svg { width: 14px; height: 14px; color: var(--text-secondary); }
.row-menu-item:hover { background: var(--glass-bg-hover); }
.row-menu-item.danger { color: var(--red-text); }
.row-menu-item.danger i, .row-menu-item.danger svg { color: var(--red-text); }

/* ----- Empty / error / skeleton states ----- */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 40px;
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius);
  background-color: rgba(255, 255, 255, 0.005);
}

.empty-state i, .empty-state svg { width: 44px; height: 44px; color: var(--text-muted); margin-bottom: 14px; }

.empty-state p { font-size: 14px; color: var(--text-secondary); max-width: 420px; margin: 0 auto; line-height: 1.6; }

.panel-error {
  text-align: center;
  padding: 56px 40px;
  border: 1px dashed rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.03);
}
.panel-error i, .panel-error svg { width: 40px; height: 40px; color: var(--red-text); margin-bottom: 12px; }
.panel-error p { color: var(--text-secondary); margin-bottom: 16px; font-size: 14px; }

.skeleton-block {
  position: relative;
  overflow: hidden;
  min-height: 120px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}
.skeleton-tall { min-height: 320px; }

.skeleton-block::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.05) 50%, transparent 70%);
  animation: shimmer 1.4s infinite;
  transform: translateX(-100%);
}

@keyframes shimmer { to { transform: translateX(100%); } }

.skeleton-row td { padding: 13px 16px; }
.skeleton-line {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
}
.skeleton-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.07) 50%, transparent 70%);
  animation: shimmer 1.4s infinite;
  transform: translateX(-100%);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(99, 102, 241, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.center-pad { display: flex; justify-content: center; padding: 32px; }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(6, 7, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  /* visibility:hidden takes ~20 permanently-stacked full-screen blur layers
     out of the compositor entirely (opacity:0 alone still paints them — the
     cause of black-void rendering on Android). The delayed visibility flip
     preserves the fade-out. */
  visibility: hidden;
  transition: opacity 0.25s var(--ease), visibility 0s 0.25s;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; visibility: visible; transition: opacity 0.25s var(--ease), visibility 0s 0s; }

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-pop);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s var(--ease);
}

.modal-overlay.active .modal-content { transform: none; }

.modal-sm { max-width: 420px; }
.modal-lg { max-width: 820px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 14px;
  flex: none;
}

.modal-header h2 { font-size: 20px; font-weight: 700; }

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.modal-close:hover { background: var(--glass-bg-hover); color: var(--text-primary); }
.modal-close i, .modal-close svg { width: 17px; height: 17px; }

.modal-body { overflow-y: auto; padding-right: 4px; min-height: 0; }

/* ----- Auth card ----- */
.auth-card { text-align: center; max-width: 440px; }

.auth-icon-wrapper {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--indigo-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}
.auth-icon-wrapper i, .auth-icon-wrapper svg { width: 26px; height: 26px; color: var(--indigo-text); }

.auth-card h2 { margin-bottom: 8px; }
.auth-card p { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 22px; line-height: 1.6; }
.auth-error { min-height: 20px; margin-top: 12px; font-size: 13px; color: var(--red-text); font-weight: 500; }

/* ----- Confirm dialog ----- */
.confirm-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--orange-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.confirm-icon-wrap i, .confirm-icon-wrap svg { width: 24px; height: 24px; color: var(--orange-text); }
.confirm-icon-wrap.danger { background: var(--red-soft); }
.confirm-icon-wrap.danger i, .confirm-icon-wrap.danger svg { color: var(--red-text); }

#confirm-modal .modal-content { text-align: center; }
#confirm-title { font-size: 19px; margin-bottom: 8px; }
.confirm-message { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 22px; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }
.confirm-actions .btn { min-width: 110px; }

/* ==========================================================================
   Toasts
   ========================================================================== */
#toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 320; /* above focus mode (200) and focus-raised modals (300) */
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--glass-border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-pop);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-primary);
  animation: toastIn 0.25s var(--ease);
}

.toast.leaving { animation: toastOut 0.2s var(--ease) forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }

.toast i, .toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast-success { border-left-color: var(--green); }
.toast-success i, .toast-success svg { color: var(--green-text); }
.toast-error { border-left-color: var(--red); }
.toast-error i, .toast-error svg { color: var(--red-text); }
.toast-info { border-left-color: var(--blue); }
.toast-info i, .toast-info svg { color: var(--blue-text); }

.toast-msg { flex: 1; word-break: break-word; }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
}
.toast-close:hover { color: var(--text-primary); }
.toast-close i, .toast-close svg { width: 14px; height: 14px; }

/* ==========================================================================
   Overview tab
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.metric-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.metric-card:hover {
  transform: translateY(-2px);
  background-color: var(--glass-bg-hover);
  border-color: var(--glass-border-strong);
}

.metric-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 8px; }
.metric-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.metric-icon-bg {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.metric-icon-bg i, .metric-icon-bg svg { width: 17px; height: 17px; }

.tint-indigo { background: var(--indigo-soft); } .tint-indigo i, .tint-indigo svg { color: var(--indigo-text); }
.tint-cyan { background: var(--cyan-soft); }     .tint-cyan i, .tint-cyan svg { color: var(--cyan-text); }
.tint-green { background: var(--green-soft); }   .tint-green i, .tint-green svg { color: var(--green-text); }
.tint-red { background: var(--red-soft); }       .tint-red i, .tint-red svg { color: var(--red-text); }
.tint-orange { background: var(--orange-soft); } .tint-orange i, .tint-orange svg { color: var(--orange-text); }

.metric-value { font-family: var(--font-heading); font-size: 30px; font-weight: 700; display: block; margin-bottom: 4px; }
.metric-flex { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.metric-flex .metric-value { margin-bottom: 0; }
.metric-value-sub { font-size: 13.5px; color: var(--text-secondary); font-weight: 500; }
.metric-sub { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }

/* ----- Chart ----- */
.chart-card { padding-bottom: 12px; }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch-sent { background: var(--chart-sent); }
.swatch-opened { background: var(--chart-opened); }
.swatch-replied { background: var(--chart-replied); }

.chart-wrap { position: relative; }
#chart-svg-wrap svg { display: block; width: 100%; height: auto; }

.chart-grid-line { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1; }
.chart-axis-label { fill: var(--text-muted); font-size: 11px; font-family: var(--font-body); }

.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.sent { stroke: var(--chart-sent); }
.chart-line.opened { stroke: var(--chart-opened); }
.chart-line.replied { stroke: var(--chart-replied); }

.chart-area.sent { fill: var(--chart-sent); opacity: 0.09; }

.chart-hover-line { stroke: rgba(255, 255, 255, 0.22); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-dot { stroke-width: 2; stroke: var(--bg-secondary); }
.chart-dot.sent { fill: var(--chart-sent); }
.chart-dot.opened { fill: var(--chart-opened); }
.chart-dot.replied { fill: var(--chart-replied); }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-raised);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  min-width: 130px;
  z-index: 5;
  transform: translate(-50%, calc(-100% - 12px));
  white-space: nowrap;
}

.chart-tooltip .tt-date { font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--text-secondary); }
.chart-tooltip .tt-row strong { color: var(--text-primary); font-weight: 600; }
.chart-tooltip .tt-key { display: inline-flex; align-items: center; gap: 6px; }

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ==========================================================================
   Campaigns tab
   ========================================================================== */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.bar-title { font-family: var(--font-heading); font-size: 18px; font-weight: 600; }
.bar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.campaign-grid, .mailbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.campaign-card, .mailbox-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}

.campaign-card:has(.row-menu.open), .mailbox-card:has(.row-menu.open) {
  transform: none !important; /* a transform would become the fixed menu's containing block */
}
.campaign-card:hover, .mailbox-card:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.3);
}

.cc-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }

.cc-card-title {
  font-family: var(--font-heading);
  font-size: 16.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cc-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.meta-item i, .meta-item svg { width: 12px; height: 12px; }

.card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  border-top: 1px solid var(--glass-border);
  padding-top: 14px;
  margin-top: auto;
}

.stat-item { text-align: center; min-width: 0; }
.stat-label { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; display: block; }
.stat-val { font-family: var(--font-heading); font-size: 16px; font-weight: 700; color: var(--text-primary); margin-top: 3px; display: block; }
.stat-val.green { color: var(--green-text); }
.stat-val.red { color: var(--red-text); }
.stat-val.blue { color: var(--blue-text); }

/* ----- Toggle switch ----- */
.switch { position: relative; display: inline-block; width: 42px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.12);
  transition: background-color 0.25s var(--ease);
  border-radius: 24px;
}

.slider::before {
  position: absolute;
  content: "";
  height: 17px;
  width: 17px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: transform 0.25s var(--ease);
  border-radius: 50%;
}

.switch input:checked + .slider { background-color: var(--green); }
.switch input:checked + .slider::before { transform: translateX(19px); }
.switch input:focus-visible + .slider { box-shadow: var(--ring); }

/* ----- Delete icon button on cards ----- */
.delete-card-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  flex: none;
  display: inline-flex;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.delete-card-btn:hover { color: var(--red-text); background-color: var(--red-soft); }
.delete-card-btn i, .delete-card-btn svg { width: 16px; height: 16px; }

/* ----- Sequence step builder ----- */
.sequence-builder { border-top: 1px solid var(--glass-border); padding-top: 18px; margin: 22px 0; }

.builder-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

.steps-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 6px;
}

.step-card {
  background-color: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.step-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }

.step-number {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--indigo-text);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.step-tools { display: flex; gap: 4px; }

.step-tool-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: inline-flex;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.step-tool-btn:hover { color: var(--text-primary); background: var(--glass-bg-hover); }
.step-tool-btn.danger:hover { color: var(--red-text); background: var(--red-soft); }
.step-tool-btn i, .step-tool-btn svg { width: 14px; height: 14px; }
.step-tool-btn:disabled { opacity: 0.3; cursor: default; }

.segmented {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.segmented button i, .segmented button svg { width: 13px; height: 13px; }
.segmented button:hover { color: var(--text-primary); }
.segmented button.active { background-image: var(--accent-gradient); color: #fff; box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3); }

/* subject chips */
.chip-editor { display: flex; flex-direction: column; gap: 8px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 7px; }

.subj-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--indigo-soft);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 8px 5px 11px;
  border-radius: 999px;
  max-width: 100%;
}

.subj-chip .chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.subj-chip .chip-weight { font-size: 10.5px; color: var(--indigo-text); font-weight: 700; }

.chip-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 1px;
  display: inline-flex;
  border-radius: 50%;
}
.chip-remove:hover { color: var(--red-text); }
.chip-remove i, .chip-remove svg { width: 12px; height: 12px; }

.chip-input-row { display: flex; gap: 8px; align-items: center; }
.chip-input-row .subj-input { flex: 1; }
.chip-input-row .subj-weight { width: 76px; flex: none; }

/* merge tag hint bar */
.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 7px; }
.tag-bar-label { font-size: 11px; color: var(--text-muted); margin-right: 2px; }

.tag-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--violet-text);
  font-size: 11px;
  font-family: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', monospace;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.tag-chip:hover { background: var(--violet-soft); border-color: rgba(139, 92, 246, 0.35); }

.step-body-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ----- Import report ----- */
.import-report {
  margin-top: 20px;
  padding: 16px;
  background-color: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  animation: fadeIn 0.3s var(--ease);
}

.import-report h4 {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 8px;
}

.report-summary-flex { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 4px; }

.report-errors-list {
  max-height: 140px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid var(--glass-border);
  margin-top: 10px;
  padding-top: 10px;
}

.report-error-line { margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-error-line strong { color: var(--text-primary); font-weight: 600; }

/* ----- Template picker ----- */
.tpl-list { display: flex; flex-direction: column; gap: 10px; }

.tpl-item {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
  background: rgba(255, 255, 255, 0.015);
}

.tpl-item:hover { border-color: rgba(139, 92, 246, 0.4); background: var(--glass-bg-hover); }

.tpl-item-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.tpl-name { font-weight: 600; font-size: 14px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-meta { display: flex; gap: 8px; flex: none; }
.tpl-body-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   Leads tab
   ========================================================================== */
.leads-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

.search-box i, .search-box svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input { padding-left: 38px; }

.pagination-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-top: 1px solid var(--glass-border);
}

.pagination-total { font-size: 12.5px; color: var(--text-muted); }
.pagination-controls { display: flex; align-items: center; gap: 12px; }
.pagination-info { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; white-space: nowrap; }

/* ==========================================================================
   Mailboxes tab
   ========================================================================== */
.mailbox-usage { margin-top: 14px; }

.progress-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.progress-container { height: 6px; background-color: rgba(255, 255, 255, 0.06); border-radius: 3px; overflow: hidden; }

.progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s var(--ease);
}
.progress-bar.full { background: linear-gradient(135deg, var(--orange) 0%, var(--red) 100%); }

/* ==========================================================================
   WhatsApp tab
   ========================================================================== */
.whatsapp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.wa-col { min-width: 0; }

.wa-status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.wa-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13.5px;
}

.wa-status-badge.connected { background-color: var(--green-soft); color: var(--green-text); }
.wa-status-badge.awaiting { background-color: var(--orange-soft); color: var(--orange-text); }
.wa-status-badge.disconnected { background-color: var(--red-soft); color: var(--red-text); }

.test-feedback { margin-top: 12px; font-size: 13px; font-weight: 500; min-height: 18px; }
.test-feedback.success { color: var(--green-text); }
.test-feedback.error { color: var(--red-text); }
.test-feedback.info { color: var(--text-secondary); }

.qr-code-wrapper {
  width: 250px;
  height: 250px;
  margin: 18px auto;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background-color: #fff;
  position: relative;
}

#wa-qr-canvas { width: 100% !important; height: 100% !important; }

.qr-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(18, 20, 38, 0.92);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
}

.qr-overlay span { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

.wa-guideline-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 10px;
}
.wa-guideline-badge i, .wa-guideline-badge svg { color: var(--green-text); width: 15px; height: 15px; }

.tpl-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px;
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}
.tpl-notice i, .tpl-notice svg { width: 17px; height: 17px; flex: none; color: var(--orange-text); margin-top: 1px; }

/* ==========================================================================
   Settings tab
   ========================================================================== */
.settings-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 22px; align-items: start; }

.sys-list { display: flex; flex-direction: column; }

.sys-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13.5px;
}
.sys-row:last-child { border-bottom: none; }

.sys-label { color: var(--text-secondary); flex: none; }
.sys-value {
  color: var(--text-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', monospace;
  font-size: 12.5px;
}

.warn-chip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--orange-soft);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  color: var(--orange-text);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
}
.warn-chip i, .warn-chip svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ==========================================================================
   Live Inbox tab
   ========================================================================== */
.inbox-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.inbox-filter .pill i, .inbox-filter .pill svg { width: 14px; height: 14px; }

.inbox-container {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  height: calc(100vh - 200px);
  min-height: 420px;
}

.inbox-threads {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-soft);
}

.thread-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thread-item:hover { background-color: var(--glass-bg-hover); }
.thread-item.active { background-color: rgba(99, 102, 241, 0.08); border-left-color: var(--accent); }

.thread-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.thread-name {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.thread-time { font-size: 11px; color: var(--text-muted); font-weight: 500; flex: none; }

.thread-body { display: flex; align-items: center; gap: 7px; min-width: 0; }

.thread-dir { width: 13px; height: 13px; flex: none; color: var(--text-muted); }
.thread-dir.outbound { color: var(--indigo-text); }
.thread-dir.inbound { color: var(--green-text); }

.thread-snippet {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.thread-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.thread-phone { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.inbox-chat-pane {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

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

.chat-pane-empty-state i, .chat-pane-empty-state svg { width: 44px; height: 44px; margin-bottom: 14px; }
.chat-pane-empty-state p { font-size: 13.5px; max-width: 320px; line-height: 1.6; }

.chat-pane-active-state { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background-color: rgba(255, 255, 255, 0.005);
  flex: none;
}

.chat-contact-info { min-width: 0; }
.chat-contact-info h3 { font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#chat-contact-details {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-contact-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.chat-messages {
  flex: 1;
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background-color: rgba(6, 7, 15, 0.2);
  min-height: 0;
}

.message-bubble {
  max-width: 68%;
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 13.5px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

.message-bubble.inbound {
  align-self: flex-start;
  background-color: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-top-left-radius: 3px;
}

.message-bubble.outbound {
  align-self: flex-end;
  background-image: var(--accent-gradient);
  color: #fff;
  border-top-right-radius: 3px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.message-text { word-break: break-word; white-space: pre-wrap; }

.message-info {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 10px;
  margin-top: 6px;
  opacity: 0.72;
  font-weight: 500;
}

.message-sender { font-weight: 600; }

/* Outbound message Meta accepted but later refused to deliver (e.g. 24h
   free-form window expired) — without this it looks identical to a real send. */
.message-bubble.outbound.delivery-failed {
  background-image: none;
  background-color: rgba(239, 68, 68, 0.16);
  box-shadow: none;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.bubble-failed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.25);
  color: #fecaca;
  font-size: 10.5px;
  font-weight: 700;
  align-self: flex-start;
  cursor: help;
}
.bubble-failed i, .bubble-failed svg { width: 11px; height: 11px; flex: none; }

.chat-footer {
  padding: 12px 18px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background-color: rgba(255, 255, 255, 0.005);
  flex: none;
}

.chat-footer textarea {
  resize: none;
  min-height: 46px;
  max-height: 120px;
  padding: 12px 18px;
  border-radius: 23px;
  font-size: 13.5px;
  line-height: 1.4;
  background-color: rgba(255, 255, 255, 0.02);
}

.btn-send {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  padding: 0;
  flex: none;
}
.btn-send i, .btn-send svg { width: 17px; height: 17px; }

/* ----- Unified composer (WhatsApp / Email) ----- */
.compose-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 0;
  border-top: 1px solid var(--glass-border);
  background-color: rgba(255, 255, 255, 0.005);
  flex: none;
}

.segmented-sm button { padding: 5px 11px; font-size: 11.5px; }
.segmented-sm button:disabled { opacity: 0.35; cursor: not-allowed; }

.chat-subject {
  flex: 1;
  padding: 7px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.02);
}

/* the Saved-replies button carries the auto margin so it and the Template
   button sit together on the right (Template hides on the email channel) */
#chat-template-btn { flex: none; }

.compose-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 18px 0;
  font-size: 12px;
  color: var(--orange-text);
  line-height: 1.45;
  flex: none;
}
.compose-hint i, .compose-hint svg { width: 14px; height: 14px; flex: none; margin-top: 1px; }

/* email bubbles */
.message-bubble.email.inbound { border-left: 3px solid var(--blue); }
.message-bubble.email.outbound { background-image: linear-gradient(135deg, #2563eb 0%, #6366f1 100%); }

.bubble-subject {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.bubble-subject i, .bubble-subject svg { width: 12px; height: 12px; flex: none; }

/* ==========================================================================
   Client profile modal
   ========================================================================== */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }

.profile-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background-image: var(--accent-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-size: 21px;
  font-weight: 700;
  flex: none;
}

.profile-name { font-size: 19px; font-weight: 700; }
.profile-sub { color: var(--text-secondary); font-size: 13px; margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.profile-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

.profile-stat {
  flex: 1;
  min-width: 88px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 13px 10px;
  text-align: center;
}

.profile-stat-value { font-family: var(--font-heading); font-size: 22px; font-weight: 800; line-height: 1.1; }
.profile-stat-value.indigo { color: var(--indigo-text); }
.profile-stat-value.cyan { color: var(--cyan-text); }
.profile-stat-value.violet { color: var(--violet-text); }
.profile-stat-value.green { color: var(--green-text); }
.profile-stat-value.red { color: var(--red-text); }
.profile-stat-label { font-size: 10.5px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 20px; }
.profile-grid h4 { font-size: 14px; margin-bottom: 8px; }

.kv-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.kv-table td { padding: 6px 0; vertical-align: top; }
.kv-table td:first-child { color: var(--text-muted); padding-right: 16px; white-space: nowrap; }
.kv-table td:last-child { font-weight: 600; color: var(--text-primary); word-break: break-word; }

.timeline-box {
  max-height: 230px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
}

.timeline-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.timeline-row:last-child { border-bottom: none; }

.tl-dot { margin-top: 4px; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-muted); }
.tl-dot.sent { background: var(--blue); }
.tl-dot.opened { background: var(--cyan); }
.tl-dot.clicked { background: var(--accent-2); }
.tl-dot.replied { background: var(--green); }
.tl-dot.bounced { background: var(--red); }
.tl-dot.unsubscribed { background: var(--orange); }

.tl-main { flex: 1; min-width: 0; }
.tl-type { font-weight: 600; color: var(--text-primary); text-transform: capitalize; font-size: 13px; }
.tl-step { color: var(--text-muted); font-weight: 400; font-size: 11.5px; }
.tl-details { font-size: 12px; color: var(--text-secondary); word-break: break-word; margin-top: 2px; }
.tl-time { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; flex: none; }

.profile-error { color: var(--red-text); padding: 20px; text-align: center; font-size: 13.5px; }

/* ==========================================================================
   v4 additions — checklist, campaign detail, mailbox tools, unread, help
   ========================================================================== */

/* ----- Top bar right cluster (status panel + help button) ----- */
.top-bar-right { display: flex; align-items: center; gap: 10px; flex: none; }

/* ----- Sidebar unread badge ----- */
.nav-badge {
  margin-left: auto;
  background: var(--accent-2);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  flex: none;
}
.nav-item.active .nav-badge { background: #fff; color: var(--accent); }

/* ----- Getting-started checklist ----- */
.setup-card { border-color: rgba(99, 102, 241, 0.35); background: rgba(99, 102, 241, 0.05); }

.setup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.setup-head h3 { font-size: 17px; font-weight: 700; }
.setup-progress { font-size: 12.5px; color: var(--indigo-text); font-weight: 600; display: block; margin-top: 3px; }

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.btn-link:hover { color: var(--text-primary); background: var(--glass-bg-hover); }

.setup-steps { display: flex; flex-direction: column; }

.setup-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.setup-step:last-child { border-bottom: none; }

.setup-step-icon { width: 20px; height: 20px; flex: none; color: var(--text-muted); }
.setup-step.done .setup-step-icon { color: var(--green-text); }

.setup-step-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.setup-step-label { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.setup-step.done .setup-step-label { color: var(--text-muted); text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.25); }
.setup-step-hint { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.setup-step.done .setup-step-hint { color: var(--text-muted); }

/* ----- Campaign card tools (switch + row menu) ----- */
.cc-card-tools { display: flex; align-items: center; gap: 6px; flex: none; }

/* ----- Campaign detail modal ----- */
.detail-head { margin-bottom: 18px; }
.detail-title-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-title { font-family: var(--font-heading); font-size: 20px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.seq-title { font-size: 14px; margin-bottom: 12px; }

.seq-timeline { display: flex; flex-direction: column; }

.seq-step { display: flex; gap: 14px; position: relative; padding-bottom: 18px; }
.seq-step:last-child { padding-bottom: 0; }
.seq-step::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--glass-border);
}
.seq-step:last-child::before { display: none; }

.seq-step-marker {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--indigo-soft);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: var(--indigo-text);
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
  position: relative;
  z-index: 1;
}

.seq-step-main { flex: 1; min-width: 0; padding-top: 3px; }

.seq-step-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.seq-step-channel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.seq-step-channel i, .seq-step-channel svg { width: 14px; height: 14px; color: var(--indigo-text); }

.seq-step-delay {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.seq-step-delay i, .seq-step-delay svg { width: 12px; height: 12px; }

.seq-body-preview {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ----- Mailbox card icon actions + connection-test chips ----- */
.card-icon-actions { display: flex; gap: 2px; flex: none; }

.delete-card-btn.neutral:hover { color: var(--text-primary); background-color: var(--glass-bg-hover); }

.conn-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  line-height: 1.4;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
}
.conn-chip i, .conn-chip svg { width: 13px; height: 13px; flex: none; }
.conn-chip.ok { background: var(--green-soft); color: var(--green-text); border-color: rgba(16, 185, 129, 0.3); }
.conn-chip.fail { background: var(--red-soft); color: var(--red-text); border-color: rgba(239, 68, 68, 0.3); }

/* ----- Table empty-state action button ----- */
.table-empty-action { margin-top: 14px; }

/* ----- Inbox unread cues ----- */
.thread-item.unread .thread-name { font-weight: 700; color: #fff; }
.thread-item.unread .thread-snippet { color: var(--text-primary); font-weight: 500; }

.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 7px rgba(139, 92, 246, 0.7);
  margin-right: 6px;
  vertical-align: middle;
}

/* ----- Help modal ----- */
.modal-header-sub { font-size: 12.5px; font-weight: 500; color: var(--text-muted); margin-left: 8px; font-family: var(--font-body); }

.help-body h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  margin: 20px 0 10px;
}
.help-body h4:first-child { margin-top: 0; }
.help-body h4 i, .help-body h4 svg { width: 16px; height: 16px; color: var(--indigo-text); flex: none; }

.help-list { margin: 0 0 12px 20px; display: flex; flex-direction: column; gap: 7px; }
.help-list li { font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.help-list li strong { color: var(--text-primary); }

.help-note { font-size: 13px; color: var(--text-secondary); line-height: 1.65; margin-bottom: 10px; }
.help-note strong { color: var(--text-primary); }

.help-body code {
  font-family: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', monospace;
  font-size: 12px;
  color: var(--violet-text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
}
.help-table td { white-space: normal; }

/* ==========================================================================
   v5 additions — Pipeline (Kanban), Calls worklist, Contact detail, Log call
   ========================================================================== */

/* ----- Overview: sales-pipeline summary card ----- */
.pipeline-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.pipeline-stat { display: flex; align-items: center; gap: 14px; min-width: 0; }

.ps-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.ps-icon i, .ps-icon svg { width: 20px; height: 20px; }

.ps-body { display: flex; flex-direction: column; min-width: 0; }
.ps-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.ps-value { font-family: var(--font-heading); font-size: 24px; font-weight: 700; line-height: 1.15; }
.ps-value.green { color: var(--green-text); }
.ps-sub { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }

/* ----- Pipeline (Kanban) tab ----- */
.pipeline-totals { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

.pipeline-total-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.pipeline-total-chip strong { font-family: var(--font-heading); font-size: 15px; color: var(--text-primary); font-weight: 700; }
.pipeline-total-chip i, .pipeline-total-chip svg { width: 15px; height: 15px; color: var(--indigo-text); }
.pipeline-total-chip.green i, .pipeline-total-chip.green svg { color: var(--green-text); }
.pipeline-total-chip.green strong { color: var(--green-text); }

.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
  min-height: 200px;
}

.kanban-col {
  flex: 0 0 264px;
  width: 264px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  box-shadow: var(--shadow-soft);
}

.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--glass-border);
  border-top: 3px solid var(--glass-border-strong);
  border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-col.stage-new .kanban-col-head { border-top-color: var(--text-muted); }
.kanban-col.stage-contacted .kanban-col-head { border-top-color: var(--blue); }
.kanban-col.stage-qualified .kanban-col-head { border-top-color: var(--accent-2); }
.kanban-col.stage-proposal .kanban-col-head { border-top-color: var(--orange); }
.kanban-col.stage-won .kanban-col-head { border-top-color: var(--green); }
.kanban-col.stage-lost .kanban-col-head { border-top-color: var(--red); }

.kanban-col-title { font-family: var(--font-heading); font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.kanban-col-count {
  background: var(--gray-soft);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.kanban-col-value { font-size: 11.5px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }

.kanban-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 60px;
}

.kanban-empty { color: var(--text-muted); font-size: 12.5px; text-align: center; padding: 24px 10px; font-style: italic; }

.kanban-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease), transform 0.18s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-card:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-strong); transform: translateY(-1px); }
.kanban-card.stage-new { border-left-color: var(--text-muted); }
.kanban-card.stage-contacted { border-left-color: var(--blue); }
.kanban-card.stage-qualified { border-left-color: var(--accent-2); }
.kanban-card.stage-proposal { border-left-color: var(--orange); }
.kanban-card.stage-won { border-left-color: var(--green); }
.kanban-card.stage-lost { border-left-color: var(--red); }

.kanban-card-name { font-weight: 600; font-size: 13.5px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-company { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-line { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-line i, .kanban-card-line svg { width: 12px; height: 12px; flex: none; }

.kanban-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kanban-card-value { font-family: var(--font-heading); font-size: 13px; font-weight: 700; color: var(--text-primary); }

.src-chip {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--indigo-soft);
  color: var(--indigo-text);
  white-space: nowrap;
}
.src-chip.src-whatsapp { background: var(--green-soft); color: var(--green-text); }
.src-chip.src-email { background: var(--blue-soft); color: var(--blue-text); }
.src-chip.src-call { background: var(--orange-soft); color: var(--orange-text); }
.src-chip.src-import { background: var(--violet-soft); color: var(--violet-text); }

.stage-move {
  width: 100%;
  padding: 5px 8px;
  font-size: 11.5px;
  border-radius: 6px;
  background-color: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.kanban-due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--orange-text);
  background: var(--orange-soft);
  padding: 2px 6px;
  border-radius: 5px;
}
.kanban-due i, .kanban-due svg { width: 11px; height: 11px; }

/* ----- Calls worklist tab ----- */
.calls-stats { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }

.calls-stat {
  flex: 1;
  min-width: 150px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-soft);
}
.calls-stat .ps-icon { width: 38px; height: 38px; }
.calls-stat-value { font-family: var(--font-heading); font-size: 22px; font-weight: 700; line-height: 1.1; }
.calls-stat-label { font-size: 11.5px; color: var(--text-secondary); font-weight: 500; }

.calls-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.calls-toolbar .search-box { max-width: 100%; }

.due-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--orange-text);
  background: var(--orange-soft);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}
.due-pill i, .due-pill svg { width: 11px; height: 11px; }

.call-actions { display: flex; gap: 6px; justify-content: flex-end; }

.tel-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background-image: var(--accent-gradient);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  white-space: nowrap;
}
.tel-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(99, 102, 241, 0.36); }
.tel-btn i, .tel-btn svg { width: 14px; height: 14px; }

/* ----- Contact detail modal (CRM record) ----- */
.contact-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; margin: 4px 0 4px; }

.contact-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 16px 0;
  margin: 16px 0;
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
}
.contact-edit-grid .input-group { margin-bottom: 0; }

.contact-quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

.kv-line { font-size: 13px; color: var(--text-primary); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-line .cell-muted { font-weight: 500; margin-right: 8px; }

.contact-section-title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--indigo-text);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 20px 0 12px;
}

.note-composer { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.note-composer textarea { min-height: 44px; }
.note-composer .btn { align-self: flex-end; }

.notes-timeline { display: flex; flex-direction: column; }

.note-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.note-row:last-child { border-bottom: none; }

.note-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  display: grid;
  place-items: center;
  flex: none;
}
.note-icon i, .note-icon svg { width: 14px; height: 14px; color: var(--text-secondary); }
.note-icon.kind-call i, .note-icon.kind-call svg { color: var(--orange-text); }
.note-icon.kind-stage_change i, .note-icon.kind-stage_change svg { color: var(--violet-text); }
.note-icon.kind-system i, .note-icon.kind-system svg { color: var(--blue-text); }

/* Deals & documents — per-contact money summary + merged doc timeline */
.deal-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.deal-kpi { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.deal-kpi span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); }
.deal-kpi strong { font-size: 15px; color: var(--text-primary); }
.deal-kpi.warn strong { color: var(--orange-text); }
.deal-timeline { display: flex; flex-direction: column; }
.deal-row { display: flex; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); border-radius: 6px; cursor: pointer; }
.deal-row:last-child { border-bottom: none; }
.deal-row:hover { background: var(--glass-bg); }
.deal-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--glass-bg); border: 1px solid var(--glass-border); display: grid; place-items: center; flex: none; }
.deal-icon i, .deal-icon svg { width: 14px; height: 14px; color: var(--text-secondary); }
.deal-icon.kind-quote i, .deal-icon.kind-quote svg { color: var(--blue-text); }
.deal-icon.kind-invoice i, .deal-icon.kind-invoice svg { color: var(--orange-text); }
.deal-icon.kind-doc i, .deal-icon.kind-doc svg { color: var(--violet-text); }
.deal-main { min-width: 0; flex: 1; }
.deal-title { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-sub { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-meta { display: flex; align-items: center; gap: 8px; flex: none; }
.deal-amount { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.deal-time { font-size: 11px; color: var(--text-secondary); min-width: 54px; text-align: right; }

.note-main { flex: 1; min-width: 0; }
.note-body { font-size: 13px; color: var(--text-primary); line-height: 1.5; word-break: break-word; white-space: pre-wrap; }
.note-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.calls-history { display: flex; flex-direction: column; gap: 8px; }

.call-hist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}
.call-hist-main { flex: 1; min-width: 0; }
.call-hist-notes { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; word-break: break-word; }
.call-hist-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex: none; }
.call-hist-dur { font-size: 11px; color: var(--text-muted); }

.disp-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.disp-badge.good { background: var(--green-soft); color: var(--green-text); }
.disp-badge.warn { background: var(--orange-soft); color: var(--orange-text); }
.disp-badge.bad { background: var(--red-soft); color: var(--red-text); }
.disp-badge.neutral { background: var(--gray-soft); color: var(--text-secondary); }
.disp-badge.info { background: var(--blue-soft); color: var(--blue-text); }

.contact-source-chip { margin-left: 4px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .settings-grid { grid-template-columns: 1fr; }
  .whatsapp-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-pop); }
  .sidebar-backdrop.visible { display: block; }

  .hamburger { display: inline-flex; }

  .main-panel { margin-left: 0; padding: 20px 18px 40px; }

  .top-bar { flex-wrap: wrap; margin-bottom: 22px; }
  .top-bar h1 { font-size: 22px; }
  .status-panel { gap: 10px; padding: 7px 12px; }
  .status-indicator span:not(.status-dot) { font-size: 11.5px; }

  .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .metric-value { font-size: 24px; }

  .inbox-container {
    grid-template-columns: 1fr;
    grid-template-rows: 200px 1fr;
    height: calc(100vh - 140px);
  }

  .input-row { flex-direction: column; gap: 0; }
  .checkbox-group { justify-content: flex-start; margin-bottom: 18px; }

  .campaign-grid, .mailbox-grid { grid-template-columns: 1fr; }

  .modal-content { padding: 20px; }
  .profile-grid { grid-template-columns: 1fr; }
  .message-bubble { max-width: 85%; }

  .pipeline-stat-row { grid-template-columns: 1fr; gap: 14px; }
  .contact-edit-grid { grid-template-columns: 1fr 1fr; }
  .contact-facts { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .status-panel { flex-wrap: wrap; border-radius: var(--radius); }
  .bar-actions { width: 100%; }
  .bar-actions .btn { flex: 1; }

  .contact-edit-grid { grid-template-columns: 1fr; }
  .calls-stat { min-width: 100%; }
}

/* ==========================================================================
   v6 additions — edit-steps modal, follow-ups card, detail chart, sys hint
   ========================================================================== */

/* ----- Edit sequence steps modal ----- */
.es-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--orange-soft);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--orange-text);
  line-height: 1.5;
}
.es-notice > i, .es-notice > svg { width: 17px; height: 17px; flex: none; }
.es-notice span { flex: 1; min-width: 0; }
.es-notice strong { color: var(--text-primary); }
.es-notice .btn { flex: none; }

#es-editor.es-locked {
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}

/* ----- Overview: follow-ups due card ----- */
.fu-list { display: flex; flex-direction: column; }

.fu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.fu-row:last-child { border-bottom: none; }

.fu-main { flex: 1; min-width: 0; }
.fu-name { font-weight: 600; font-size: 13.5px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fu-company { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fu-due {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  flex: none;
}
.fu-due.overdue { color: var(--red-text); }
.fu-due i, .fu-due svg { width: 13px; height: 13px; flex: none; }

.fu-actions { display: flex; gap: 8px; flex: none; }

.fu-more { padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.05); }

@media (max-width: 700px) {
  .fu-row { flex-wrap: wrap; }
  .fu-actions { width: 100%; justify-content: flex-end; }
}

/* ----- Campaign-detail modal: compact 30-day chart ----- */
.cd-chart-block { margin-top: 18px; }
.cd-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* ----- Settings: webhook-signature hint ----- */
.sys-hint { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 10px; line-height: 1.5; }

/* ==========================================================================
   v7 additions — saved replies, inbox thread search, notification bell
   ========================================================================== */

/* ----- Inbox filter row: right-aligned tools (search + bell) ----- */
.inbox-filter-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.inbox-search-box { flex: none; width: 240px; min-width: 0; max-width: 100%; }
.inbox-search-box input {
  padding: 7px 12px 7px 34px;
  font-size: 12.5px;
  border-radius: 999px;
}
.inbox-search-box i, .inbox-search-box svg { width: 14px; height: 14px; left: 12px; }

.inbox-filter .bell-btn { width: 33px; height: 33px; border-radius: 999px; flex: none; }
.inbox-filter .bell-btn i, .inbox-filter .bell-btn svg { width: 15px; height: 15px; }

.bell-btn.active {
  background: var(--indigo-soft);
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--indigo-text);
}
.bell-btn.active:hover { background: rgba(99, 102, 241, 0.2); color: var(--indigo-text); }

@media (max-width: 700px) {
  .inbox-filter-tools { width: 100%; margin-left: 0; }
  .inbox-search-box { flex: 1; width: auto; }
}

/* ----- Saved replies: composer picker (opens upward over the chat) ----- */
.saved-replies-wrap {
  position: relative;
  display: inline-flex;
  flex: none;
  margin-left: auto;
}

.saved-replies-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: min(320px, 76vw);
  background: var(--bg-raised);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.15s var(--ease);
}

.saved-replies-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.saved-replies-list {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.saved-reply-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background-color 0.15s var(--ease);
}
.saved-reply-item:hover { background: var(--glass-bg-hover); }

.saved-reply-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-reply-preview {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.saved-replies-empty {
  padding: 16px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}
.saved-replies-empty strong { color: var(--text-secondary); }

/* ----- Saved replies: Settings manager card rows ----- */
.saved-replies-manager { display: flex; flex-direction: column; }

.saved-reply-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.saved-reply-row:last-child { border-bottom: none; }

.saved-reply-main { flex: 1; min-width: 0; }

.saved-reply-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-reply-row-body {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

/* ==========================================================================
   v8 additions — Excel-like leads table, flag stars, row quick actions,
   file-upload contact import
   ========================================================================== */

/* ----- Leads hint line (spreadsheet affordance) ----- */
.leads-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  margin: -4px 0 12px;
}
.leads-hint i, .leads-hint svg { width: 13px; height: 13px; flex: none; }

/* ----- Flag star column ----- */
.th-flag { width: 44px; }
.cell-flag { padding-right: 4px; }

.flag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.flag-btn:hover { color: var(--orange-text); background: var(--glass-bg-hover); }
.flag-btn i, .flag-btn svg { width: 16px; height: 16px; }
.flag-btn.flagged { color: var(--orange-text); }
.flag-btn.flagged svg { fill: currentColor; }

/* Flagged filter pill (star icon) */
#leads-status-pills .pill { display: inline-flex; align-items: center; gap: 6px; }
#leads-status-pills .pill i, #leads-status-pills .pill svg { width: 13px; height: 13px; }
.pill-flag.active svg { fill: currentColor; }

/* ----- Excel-like inline cell editing ----- */
.leads-table td[data-edit] { cursor: text; }
.leads-table td[data-edit].editing { cursor: default; }
.leads-table tbody tr:hover td[data-edit]:not(.editing)::after {
  content: "✎";
  margin-left: 7px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.55;
}

.cell-edit {
  padding: 5px 9px;
  font-size: 13px;
  border-radius: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
  min-width: 110px;
}
select.cell-edit { cursor: pointer; }

/* ----- Row quick actions (Message / Call / ⋮) ----- */
.leads-table .th-actions { width: 132px; }

.row-actions { display: flex; align-items: center; justify-content: flex-start; gap: 2px; }

/* Name + contact buttons together in one cell: name on top, Message/Call/⋮
   directly beneath it — so you never scroll sideways to reach them. */
.cell-name { vertical-align: top; }
.lead-name { margin-bottom: 4px; }
.lead-row-actions { display: flex; }

/* The flag star and the name+contact column stay pinned to the left while the
   rest of the table scrolls horizontally. */
.leads-table .th-flag, .leads-table .cell-flag {
  position: sticky;
  left: 0;
  z-index: 3;
  background-color: #12142a;
}
.leads-table .th-name, .leads-table .cell-name {
  position: sticky;
  left: 44px;
  z-index: 3;
  background-color: #12142a;
  box-shadow: 6px 0 10px -6px rgba(0, 0, 0, 0.55);
}
.leads-table thead .th-flag, .leads-table thead .th-name { z-index: 4; }

/* The ⋮ dropdown sits near the LEFT edge now — open it rightward so it
   never clips outside the scroll container. */
.leads-table .row-menu-list { left: 0; right: auto; }

.row-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.row-action-btn:hover { color: var(--text-primary); background: var(--glass-bg-hover); }
.row-action-btn i, .row-action-btn svg { width: 16px; height: 16px; }

/* ----- Import Contacts modal ----- */
input[type="file"] { padding: 8px 10px; cursor: pointer; }
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: var(--glass-bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}
input[type="file"]::file-selector-button:hover { background: var(--glass-bg-hover); }

.import-preview {
  margin: -6px 0 18px;
  padding: 12px 14px;
  background-color: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  animation: fadeIn 0.2s var(--ease);
}

.import-preview-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}
.import-preview-line i, .import-preview-line svg { width: 15px; height: 15px; color: var(--green-text); flex: none; margin-top: 2px; }
.import-preview-line strong { font-weight: 700; }

.import-preview-rows {
  margin-top: 9px;
  border-top: 1px solid var(--glass-border);
  padding-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.import-preview-row {
  display: flex;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow: hidden;
}
.import-preview-row strong { color: var(--text-primary); font-weight: 600; flex: none; }
.import-preview-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Team / multi-user (v9 additions)
   ========================================================================== */
/* Role visibility: agents don't see admin-only chrome; admins don't see the
   agent-only chip. Toggled by body.role-agent (set in applyRoleVisibility). */
.agent-only { display: none !important; }
body.role-agent .agent-only { display: inline-flex !important; }
body.role-agent .admin-only { display: none !important; }
/* keep table cells as table-cells when shown, not inline-flex */
body:not(.role-agent) .admin-only.col-select,
body:not(.role-agent) .admin-only.th-select { display: table-cell !important; }

.signed-in-as {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 0 4px 12px;
  line-height: 1.4;
  text-align: center;
}
.signed-in-as strong { color: var(--text-primary); }

/* Auth setup note */
.auth-setup-note { font-size: 12px; color: var(--text-muted); margin: -6px 0 14px; text-align: left; }

/* Team members list */
.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--glass-border);
}
.team-row:last-child { border-bottom: none; }
.team-name { font-weight: 600; font-size: 14px; }
.team-sub { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-top: 3px; flex-wrap: wrap; }
.team-actions { display: flex; gap: 6px; flex: none; }
.team-actions .btn-sm { padding: 6px 9px; }

/* Leads select column + bulk bar */
.leads-table .th-select, .leads-table .col-select { width: 34px; text-align: center; }
.leads-table .lead-select, #leads-select-all { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--indigo-soft);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}
.bulk-bar .select-compact { min-width: 150px; }

.cell-assignee { cursor: text; white-space: nowrap; }

/* small chip (My leads) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--indigo-text);
  background: var(--indigo-soft);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}
.chip i, .chip svg { width: 14px; height: 14px; }

/* Admins get a leading select-checkbox column — shift the sticky flag/name
   columns right to make room (agents keep the original left:0 / 44px). */
body:not(.role-agent) .leads-table .th-select,
body:not(.role-agent) .leads-table .col-select {
  position: sticky; left: 0; z-index: 3; background-color: #12142a;
}
body:not(.role-agent) .leads-table .th-flag,
body:not(.role-agent) .leads-table .cell-flag { left: 34px; }
body:not(.role-agent) .leads-table .th-name,
body:not(.role-agent) .leads-table .cell-name { left: 78px; }

/* ----- Live team activity feed (Overview) ----- */
.activity-card .card-head { margin-bottom: 12px; }
.live-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  animation: live-pulse 2s infinite;
  vertical-align: middle;
  margin-left: 4px;
}
.live-dot.offline { background: var(--text-muted); animation: none; box-shadow: none; }
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
#activity-status { font-size: 12px; }
.activity-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; }
.activity-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 8px;
  border-radius: 9px;
  border-left: 2px solid transparent;
  animation: activity-in 0.35s ease;
}
.activity-row:hover { background: var(--bg-raised); }
.activity-row .activity-icon {
  flex: none;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--bg-raised);
}
.activity-row .activity-icon i { width: 15px; height: 15px; }
.activity-row .activity-text { flex: 1; font-size: 13px; line-height: 1.45; color: var(--text-primary); }
.activity-row .activity-text em { font-style: normal; color: var(--text-secondary); }
.activity-row .activity-time { flex: none; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.activity-row.tone-success { border-left-color: var(--green); }
.activity-row.tone-success .activity-icon { background: var(--green-soft); color: var(--green-text); }
.activity-row.tone-error { border-left-color: var(--red); }
.activity-row.tone-error .activity-icon { background: var(--red-soft); color: var(--red-text); }
.activity-row.tone-info .activity-icon { background: var(--blue-soft); color: var(--blue-text); }
@keyframes activity-in {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----- Calling worklist: nav badge, Done button, intake toggle ----- */
/* Scoped to #calling-badge so it doesn't restyle the shared .nav-badge (inbox). */
#calling-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.nav-item.active #calling-badge { background: #fff; color: var(--accent); }

.btn-success {
  background-color: var(--green-soft);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--green-text);
}
.btn-success:hover:not(:disabled) { background-color: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.45); }

.bar-subtitle { font-weight: 400; font-size: 13px; color: var(--text-secondary); }

/* Intake toggle (import / add contact → Calling) */
.intake-toggle {
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  margin-bottom: 14px;
}
.intake-toggle input { margin-top: 2px; flex: none; }
.intake-toggle span { font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.intake-toggle strong { color: var(--text-primary); font-weight: 600; }
.intake-toggle em { font-style: normal; color: var(--green-text); font-weight: 600; }

/* Muted sub-line under a table cell's main value (e.g. city under a business). */
.cell-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ----- Calling: segment filters + pagination ----- */
.calls-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.filter-select {
  appearance: none;
  background: var(--bg-raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 30px 8px 12px;
  border-radius: var(--radius-sm);
  max-width: 200px;
  cursor: pointer;
}
.filter-select:hover { border-color: var(--glass-border-strong); }
.filter-select:focus-visible { outline: none; box-shadow: var(--ring); }
.filter-select option { background: var(--bg-secondary); color: var(--text-primary); }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pager-info { font-size: 13px; color: var(--text-secondary); }
.pager .btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ----- Calling: hand a filtered slice to an employee ----- */
.calls-assign-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(99, 102, 241, 0.28);
  background: rgba(99, 102, 241, 0.09);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}
.calls-assign-bar i { width: 16px; height: 16px; flex: none; color: var(--accent); }
.calls-assign-bar strong { color: var(--text-primary); }
.calls-assign-bar #calls-assign-label { margin-right: auto; }

.assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-text);
  font-size: 11px;
  font-weight: 600;
}
.assignee-chip i { width: 10px; height: 10px; }

/* ----- Backup health card ----- */
.backup-row { display: flex; align-items: center; gap: 12px; }
.backup-icon {
  flex: none; width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}
.backup-icon i { width: 17px; height: 17px; }
.backup-row.tone-good .backup-icon { background: var(--green-soft); color: var(--green-text); }
.backup-row.tone-bad .backup-icon { background: var(--red-soft); color: var(--red-text); }
.backup-row.tone-neutral .backup-icon { background: var(--bg-raised); color: var(--text-muted); }
.backup-state { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.backup-row.tone-bad .backup-state { color: var(--red-text); }
.backup-msg { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* ----- Calling performance metrics ----- */
.metric-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.metric-chip {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--bg-raised); border: 1px solid var(--glass-border); min-width: 78px;
}
.metric-chip .metric-n { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.metric-chip .metric-l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.metric-chip.good .metric-n { color: var(--green-text); }
.metric-chip.bad .metric-n { color: var(--red-text); }
.metric-chip.warn .metric-n { color: #fbbf24; }
.metric-good { color: var(--green-text); font-weight: 600; }
#calling-metrics-card .card-head .filter-select { max-width: 140px; }

/* ==========================================================================
   Focus mode — power-dial one contact at a time
   ========================================================================== */
/* Modals opened FROM Focus mode (Recall picker, Need follow-up, log call,
   contact detail) must stack above the z-200 overlay or they open invisibly
   behind it and the whole flow dead-ends. */
body.focus-open .modal-overlay { z-index: 300; }

.focus-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg-primary);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(99,102,241,0.16) 0%, transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(139,92,246,0.13) 0%, transparent 42%);
  display: flex; flex-direction: column;
  animation: fadeIn 0.2s var(--ease);
}
.focus-overlay.hidden { display: none; }
body.focus-open { overflow: hidden; }

.focus-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--glass-border); flex-wrap: wrap;
}
.focus-progress { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-secondary); min-width: 0; }
.focus-bar-track { width: 180px; max-width: 40vw; height: 6px; border-radius: 4px; background: var(--bg-raised); overflow: hidden; }
.focus-bar-fill { height: 100%; background: var(--accent-gradient); width: 0; transition: width 0.3s var(--ease); }
.focus-scope { color: var(--text-muted); }
.focus-top-actions { display: flex; align-items: center; gap: 14px; }
.focus-hint { font-size: 11.5px; color: var(--text-muted); }
.focus-hint kbd, .focus-mark kbd {
  font-family: var(--font-body); font-size: 11px; padding: 1px 5px; border-radius: 5px;
  background: var(--bg-raised); border: 1px solid var(--glass-border); color: var(--text-secondary);
}
@media (max-width: 640px) { .focus-hint { display: none; } }

.focus-stage { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 22px; }
.focus-card { width: 100%; max-width: 560px; text-align: center; }
.focus-name { font-family: var(--font-heading); font-size: 30px; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); }
.focus-due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--red-text); background: var(--red-soft); padding: 3px 9px; border-radius: 20px; vertical-align: middle; }
.focus-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0 18px; }
.focus-chip { font-size: 12.5px; color: var(--text-secondary); background: var(--bg-raised); border: 1px solid var(--glass-border); padding: 4px 11px; border-radius: 20px; }
.focus-phone {
  display: inline-flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 700;
  color: #fff; background: var(--accent-gradient); padding: 14px 30px; border-radius: 16px;
  text-decoration: none; box-shadow: 0 10px 30px rgba(99,102,241,0.35); transition: transform 0.15s var(--ease);
}
.focus-phone:hover { transform: translateY(-2px); }
.focus-phone i { width: 22px; height: 22px; }
.focus-addr { margin-top: 12px; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; justify-content: center; }
.focus-history { margin-top: 20px; text-align: left; display: flex; flex-direction: column; gap: 7px; }
.focus-hrow { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.focus-hrow i { width: 13px; height: 13px; flex: none; color: var(--text-muted); }

.focus-actions { width: 100%; max-width: 620px; display: flex; flex-direction: column; gap: 12px; }
.focus-mark-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 640px) { .focus-mark-row { grid-template-columns: repeat(2, 1fr); } }
.focus-mark {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 14px 8px;
  border-radius: 12px; border: 1px solid var(--glass-border); background: var(--bg-raised);
  color: var(--text-primary); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s var(--ease);
}
.focus-mark:hover { transform: translateY(-2px); border-color: var(--glass-border-strong); }
.focus-mark.good:hover { border-color: var(--green); }
.focus-mark.bad:hover { border-color: var(--red); }
.focus-mark.warn:hover { border-color: var(--accent-2, var(--accent)); }
.focus-nav { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.focus-done { text-align: center; }
.focus-done-ic { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--green-soft); color: var(--green-text); }
.focus-done-ic i { width: 30px; height: 30px; }
.focus-done h2 { font-size: 24px; margin-bottom: 6px; }
.focus-done p { color: var(--text-secondary); }
.focus-done-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.cb-picks { display: flex; gap: 8px; flex-wrap: wrap; }
.cb-picks .btn { flex: 1; min-width: 110px; }

/* Callback-due feed entries (warn tone) */
.activity-row.tone-warn { border-left-color: var(--accent-2, #f59e0b); }
.activity-row.tone-warn .activity-icon { background: rgba(245, 158, 11, 0.13); color: #fbbf24; }

/* ----- Daily call goal ----- */
.calls-stats-row { display: flex; gap: 14px; align-items: stretch; flex-wrap: wrap; margin-bottom: 14px; }
.calls-stats-row .calls-stats { margin-bottom: 0; }
.focus-goal {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--glass-border); background: var(--bg-raised);
}
.focus-goal.goal-met { color: var(--green-text); border-color: rgba(16,185,129,0.35); }
.goal-ring {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--bg-secondary) 0);
  border: 2px solid var(--bg-secondary);
}
.focus-goal.goal-met .goal-ring { background: var(--green); }
.tint-green { background: var(--green-soft); color: var(--green-text); }

/* ----- Call scripts ----- */
.script-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--glass-border); }
.script-main { flex: 1; min-width: 0; }
.script-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.script-preview { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-actions { display: flex; gap: 6px; flex: none; }

.focus-script { margin-top: 18px; text-align: left; border: 1px solid var(--glass-border); border-radius: 12px; background: var(--bg-raised); }
.focus-script summary {
  cursor: pointer; padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--text-secondary);
  display: flex; align-items: center; gap: 8px; list-style: none;
}
.focus-script summary::-webkit-details-marker { display: none; }
.focus-script summary i { width: 15px; height: 15px; }
.focus-script-body { padding: 0 14px 14px; font-size: 14.5px; line-height: 1.7; color: var(--text-primary); white-space: pre-wrap; }
.sc-tag { background: rgba(99, 102, 241, 0.22); color: var(--text-primary); border-radius: 4px; padding: 0 4px; }

/* ----- Global search (top bar) ----- */
.global-search { position: relative; display: flex; align-items: center; gap: 8px; }
.global-search > i { position: absolute; left: 12px; width: 15px; height: 15px; color: var(--text-muted); pointer-events: none; }
#gs-input {
  width: 210px; max-width: 34vw;
  padding: 8px 12px 8px 34px;
  border-radius: 10px; border: 1px solid var(--glass-border);
  background: var(--bg-raised); color: var(--text-primary); font-size: 13px;
  transition: width 0.2s var(--ease), border-color 0.2s var(--ease);
}
#gs-input:focus { width: 280px; border-color: var(--accent); outline: none; }
@media (max-width: 900px) { #gs-input { width: 140px; } #gs-input:focus { width: 180px; } }
.gs-results {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 90;
  width: 340px; max-width: 90vw; max-height: 380px; overflow-y: auto;
  background: var(--bg-secondary); border: 1px solid var(--glass-border-strong, var(--glass-border));
  border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px;
}
.gs-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 8px; border: none; background: none; cursor: pointer;
}
.gs-row:hover { background: var(--bg-raised); }
.gs-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.gs-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-sub { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-where { flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; padding: 2px 8px; border-radius: 10px; background: var(--bg-raised); color: var(--text-muted); }
.gs-where.calling { background: var(--blue-soft); color: var(--blue-text); }
.gs-empty { padding: 14px; font-size: 13px; color: var(--text-muted); }

/* ==========================================================================
   MOBILE PASS — reps work from their phones; every daily surface must be
   comfortably usable at 360-430px wide.
   ========================================================================== */

/* Row ⋮ menus are position:fixed when open (set by JS) so table overflow and
   sticky columns can never clip or cover them. */
.row-menu.open .row-menu-list { max-height: 60vh; overflow-y: auto; }

@media (max-width: 700px) {
  /* --- top bar: dots-only status, search stretches --- */
  .status-indicator span:not(.status-dot) { display: none; }
  .status-panel { gap: 8px; padding: 7px 10px; }
  /* The search input's INTRINSIC width (~290px at 16px font) propagates up
     through min-width:auto and made .top-bar-right refuse to shrink below
     410px — stretching the body to 420 and every absolutely-positioned modal
     overlay with it (the page "scrolled sideways" on phones). Let the row
     shrink and give it its own full line under the title. */
  .top-bar-right { flex: 1 1 100%; min-width: 0; }
  .global-search { flex: 1; min-width: 0; }
  #gs-input { width: 100%; max-width: none; min-width: 0; }
  #gs-input:focus { width: 100%; }
  /* Search results anchored to the viewport, not the (right-shifted) box —
     review-confirmed: the absolute right:0 dropdown ran past the left edge. */
  .gs-results { position: fixed; left: 10px; right: 10px; width: auto; top: 110px; }

  /* --- forms: 16px stops iOS zooming the page on focus --- */
  input, select, textarea, .filter-select, .select-compact { font-size: 16px !important; }

  /* --- toolbars wrap into full-width rows --- */
  .calls-toolbar { flex-direction: column; align-items: stretch; }
  .calls-toolbar .search-box { max-width: none; }
  .calls-filters { margin-left: 0; width: 100%; }
  .calls-filters .filter-select { flex: 1 1 45%; max-width: none; }
  .calls-assign-bar { padding: 10px; }
  .calls-assign-bar #calls-assign-label { flex-basis: 100%; margin-right: 0; }
  .calls-stats-row { gap: 10px; }
  .calls-stats { flex-wrap: wrap; }

  /* --- action bars: buttons in a 2-col grid instead of one long row --- */
  .bar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .bar-actions .btn { justify-content: center; }

  /* --- tables: tighter cells, comfortable tap targets --- */
  .table th, .table td { padding: 10px 8px; }
  .btn-sm { min-height: 38px; }
  .call-actions { flex-wrap: wrap; }
  .call-actions .btn, .call-actions .tel-btn { min-height: 40px; }

  /* --- bulk bar + pager --- */
  .bulk-bar { flex-wrap: wrap; gap: 8px; }
  .pager .btn { min-height: 40px; padding-left: 16px; padding-right: 16px; }

  /* --- modals: edge-to-edge sheets (login stays centered — a bottom-sheet
     sign-in on an empty screen looks broken) --- */
  .modal-overlay { padding: 10px; align-items: flex-end; }
  #auth-overlay { align-items: center; }
  .modal-content { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; }
  #auth-overlay .modal-content { border-radius: var(--radius-lg); }

  /* --- focus mode: bigger touch targets --- */
  .focus-mark { min-height: 54px; }
  .focus-phone { width: 100%; justify-content: center; min-height: 54px; }
  .focus-actions .btn { min-height: 46px; }
  .focus-top { flex-wrap: wrap; gap: 8px; }

  /* --- overview cards breathe --- */
  #calling-metrics-card .filter-select { max-width: 130px; }
}

@media (max-width: 430px) {
  .main-panel { padding: 14px 10px 96px; }
  .top-bar h1 { font-size: 19px; }
  .bar-title { font-size: 15px; }
  .bar-subtitle { display: none; }
  .calls-filters .filter-select { flex-basis: 100%; }
  .bar-actions { grid-template-columns: 1fr 1fr; }
  .metric-chips { gap: 6px; }
  .activity-row .activity-time { display: none; }
}

/* ----- Invite links (Team) ----- */
.invite-result { margin-top: 14px; border-top: 1px solid var(--glass-border); padding-top: 12px; }
.invite-line { display: flex; gap: 8px; margin-top: 8px; }
.invite-line input {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-secondary);
  background: var(--bg-raised); border: 1px solid var(--glass-border);
  border-radius: 8px; padding: 8px 10px;
}

/* ==========================================================================
   TABLET PASS (701-1080px) + touch ergonomics on ANY touch device.
   Measured at 768: the calling table was 1114px inside a 731px container —
   every row needed sideways scrolling to reach Call/Done.
   ========================================================================== */

/* Niche only appears in the sub-line when its column is hidden. */
.cell-sub .sub-niche { display: none; }
.cell-sub .sub-niche::before { content: "· "; color: var(--text-muted); }

@media (max-width: 1080px) {
  /* Drop Company(3)/Stage(5)/Last-contacted(6) — the niche moves into the
     contact sub-line, stage & history live one tap away in the contact card.
     What remains (contact, phone, actions) fits with NO horizontal scroll. */
  .calls-table th:nth-child(3), .calls-table td:nth-child(3),
  .calls-table th:nth-child(5), .calls-table td:nth-child(5),
  .calls-table th:nth-child(6), .calls-table td:nth-child(6) { display: none; }
  .calls-table th, .calls-table td { padding-left: 8px; padding-right: 8px; }
  .cell-sub .sub-niche { display: inline; }

  /* Action buttons: icon-only (labels via title), full tap size. */
  .call-actions { flex-wrap: nowrap; }
  .call-actions .btn, .call-actions .tel-btn {
    font-size: 0; gap: 0;
    min-width: 42px; min-height: 42px;
    justify-content: center;
    padding: 0 10px;
  }
  .call-actions .btn i, .call-actions .btn svg,
  .call-actions .tel-btn i, .call-actions .tel-btn svg { width: 17px; height: 17px; }
}

/* Phones: the number column goes too (the Call button IS the number) and the
   four action icons stack 2x2, so the whole row fits a 360px screen with no
   sideways scroll. Focus mode stays the primary phone surface. */
@media (max-width: 560px) {
  .calls-table th:nth-child(4), .calls-table td:nth-child(4) { display: none; }
  .call-actions { flex-wrap: wrap; width: 100px; gap: 6px; }
  .call-actions .btn, .call-actions .tel-btn { flex: 1 1 42px; }
  /* Base table cells are nowrap — let the business name wrap on a phone so the
     contact cell's min-width stops forcing horizontal scroll. */
  .calls-table td.cell-strong, .calls-table .cell-sub { white-space: normal; overflow-wrap: anywhere; }
}

/* Tablet band: three filters per row instead of five squeezed pills. */
@media (min-width: 701px) and (max-width: 1080px) {
  .calls-filters .filter-select { flex: 1 1 30%; max-width: none; }
  .calls-toolbar .search-box { flex: 1 1 100%; max-width: none; }
}

/* Touch ergonomics keyed on the DEVICE, not the width — a 1024px iPad is
   touch. Hover-only affordances get real tap sizes. */
@media (pointer: coarse) {
  .btn-sm { min-height: 42px; }
  .tel-btn { min-height: 42px; }
  .row-menu-item { padding: 12px; }
  .filter-select, .select-compact { min-height: 42px; }
  .pill { min-height: 38px; }
  .icon-btn { min-width: 42px; min-height: 42px; }
  .flag-btn { min-width: 40px; min-height: 40px; }
  .lead-row-actions .btn { min-height: 40px; }
  .focus-mark { min-height: 56px; }
  .gs-row { padding: 12px 10px; }
}


/* Android compositor safety: no backdrop-filters on small screens — the
   off-screen (translated) sidebar's blur and the status pill's blur are known
   black-artifact triggers. Slightly more opaque backgrounds instead. */
@media (max-width: 900px) {
  .sidebar { backdrop-filter: none; -webkit-backdrop-filter: none; background-color: rgba(18, 20, 38, 0.97); }
  .status-panel { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .modal-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* The cell hosting an OPEN row menu must out-stack every later sticky cell —
   sticky cells are stacking contexts, so the menu's own z-index can't win
   from inside one. Set by positionRowMenu, swept by closeAllRowMenus. */
.table td.menu-host, .table th.menu-host { z-index: 90 !important; }

/* ----- Ease-of-use bundle ----- */
.toast-action {
  flex: none; border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08);
  color: #fff; font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 8px; cursor: pointer;
}
.toast-action:hover { background: rgba(255,255,255,0.16); }

.pill-need.active { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.5); color: #fbbf24; }

.focus-contact-row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.focus-wa {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; text-decoration: none;
  background: rgba(37, 211, 102, 0.14); border: 1px solid rgba(37, 211, 102, 0.35);
  color: #4ade80; font-weight: 700; font-size: 15px; min-height: 48px;
}
.focus-wa:hover { background: rgba(37, 211, 102, 0.22); }
.focus-wa i, .focus-wa svg { width: 18px; height: 18px; }

/* Tappable stat tile (Due callbacks filter) */
.calls-stat-tap { cursor: pointer; transition: border-color 0.15s var(--ease), background 0.15s var(--ease); }
.calls-stat-tap:hover { border-color: rgba(245, 158, 11, 0.4); }
.calls-stat-tap.active { border-color: rgba(245, 158, 11, 0.55); background: rgba(245, 158, 11, 0.08); }
.row-wa { color: #4ade80 !important; }

/* ==========================================================================
   BILLING (quotations / invoices / catalog / reports)
   ========================================================================== */
.billing-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.billing-toolbar .spacer { flex: 1; }
.quote-status { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.qs-Draft { background: rgba(148,163,184,.15); color: #94a3b8; }
.qs-Sent, .qs-Viewed { background: rgba(59,130,246,.15); color: #60a5fa; }
.qs-Negotiation { background: rgba(245,158,11,.15); color: #fbbf24; }
.qs-Accepted, .qs-Paid, .qs-Signed, .qs-Final { background: rgba(34,197,94,.15); color: #4ade80; }
.qs-Rejected, .qs-Expired { background: rgba(239,68,68,.15); color: #f87171; }
.qs-Converted { background: rgba(167,139,250,.15); color: #a78bfa; }
.qs-Unpaid { background: rgba(148,163,184,.15); color: #94a3b8; }
.qs-Partially { background: rgba(245,158,11,.15); color: #fbbf24; }
.qs-Overdue { background: rgba(239,68,68,.2); color: #f87171; }

/* line-item editor rows */
.q-line { display: grid; grid-template-columns: 1fr 64px 110px 64px 110px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.q-line input { width: 100%; }
.q-line-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.q-line-amt { font-size: 13px; text-align: right; white-space: nowrap; }
.q-line-field { min-width: 0; } /* lets a grid/flex child shrink below its input's intrinsic width */
.q-line-mlbl { display: none; } /* shown only on the stacked mobile layout below — desktop uses the shared .q-line-head row instead */

/* The 6-column grid (1fr + ~380px of fixed columns) doesn't fit a phone screen:
   the name field gets squeezed unreadable and the remove button is pushed off
   the edge. Below 640px each row becomes a labeled card instead. */
@media (max-width: 640px) {
  .q-line.q-line-head { display: none; } /* compound selector: must outrank the plain .q-line { display: flex } rule below at equal source order */
  .q-line {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 10px);
    margin-bottom: 10px;
  }
  .q-line-field { flex: 1 1 100%; }
  .q-line-field:nth-child(2), .q-line-field:nth-child(3), .q-line-field:nth-child(4) { flex: 1 1 calc(33% - 8px); }
  .q-line-mlbl { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin-bottom: 4px; }
  .q-line-amt { flex: 1 1 100%; text-align: left; order: 5; padding-top: 8px; border-top: 1px dashed var(--border); white-space: normal; }
  .q-line-amt .q-line-mlbl { display: inline; margin: 0 6px 0 0; }
  .q-line-amt-val { font-weight: 700; }
  .q-line > button[data-action="q-del-line"] { flex: 0 0 auto; margin-left: auto; order: 6; }
}
.q-totals { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-top: 12px; }
.q-totrow { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13.5px; }
.q-totrow.grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 16px; font-weight: 700; }
.q-mile { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }

/* The LUT guard — deliberately loud (the failure it prevents is invisible until an assessment) */
.lut-bar { border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; line-height: 1.5; }
.lut-bar a { text-decoration: underline; cursor: pointer; font-weight: 600; }
.lut-bar.warn { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.45); color: #fbbf24; }
.lut-bar.bad { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.5); color: #f87171; }
.lut-bar.ok { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.35); color: #93c5fd; }

.doc-preview-scroll { background: #4b5563; border-radius: 10px; max-height: 62vh; overflow: auto; padding: 18px; }
.doc-preview-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pay-qr-wrap { background: #fff; display: inline-block; padding: 14px; border-radius: 14px; }
.report-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }

/* ==========================================================================
   PRINTABLE DOCUMENT — light-theme A4-ish sheet (Palvion Sync visual language)
   ========================================================================== */
#print-area { display: none; }
.pdoc { background: #fff; color: #1e2438; font-family: 'Inter', system-ui, sans-serif; max-width: 800px; margin: 0 auto; padding: 34px 38px; border-radius: 6px; font-size: 13px; line-height: 1.5; }
.pdoc * { box-sizing: border-box; }
.pdoc .pd-head { display: flex; justify-content: space-between; gap: 18px; border-bottom: 3px solid #ff7a1a; padding-bottom: 16px; }
.pdoc .pd-brand { display: flex; gap: 14px; align-items: flex-start; }
.pdoc .pd-logo { max-height: 56px; max-width: 180px; object-fit: contain; }
.pdoc .pd-co { font-size: 19px; font-weight: 800; color: #0a1730; }
.pdoc .pd-tag { color: #7a86ab; font-style: italic; font-size: 12px; }
.pdoc .pd-meta { font-size: 11px; color: #55608a; margin-top: 4px; }
.pdoc .pd-kind { text-align: right; }
.pdoc .pd-kind h1 { margin: 0; font-size: 24px; letter-spacing: .12em; color: #ff7a1a; }
.pdoc .pd-num { font-weight: 700; font-size: 13px; color: #0a1730; }
.pdoc .pd-parties { display: flex; justify-content: space-between; gap: 18px; margin: 18px 0 6px; }
.pdoc h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #ff7a1a; }
.pdoc table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.pdoc th { text-align: left; background: #0a1730; color: #fff; font-size: 11px; padding: 7px 9px; }
.pdoc td { padding: 7px 9px; border-bottom: 1px solid #e6e9f2; vertical-align: top; }
.pdoc td.r, .pdoc th.r { text-align: right; white-space: nowrap; }
.pdoc .pd-totals { margin-left: auto; width: 290px; margin-top: 10px; }
.pdoc .pd-totals td { border: none; padding: 3px 9px; }
.pdoc .pd-grand td { border-top: 2px solid #0a1730; font-weight: 800; font-size: 15px; padding-top: 8px; }
.pdoc .pd-note { font-size: 11.5px; color: #4a5578; }
.pdoc .pd-legend { margin-top: 10px; padding: 9px 12px; background: #f4f6fb; border-left: 3px solid #ff7a1a; font-size: 11.5px; color: #33405c; }
.pdoc .pd-sign { margin-top: 34px; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.pdoc .pd-sign .line { border-top: 1px solid #9aa4c4; padding-top: 6px; font-size: 11.5px; color: #55608a; min-width: 190px; text-align: center; }
.pdoc .pd-sig-slot { text-align: center; }
.pdoc .pd-sig-img { display: block; max-height: 60px; max-width: 200px; margin: 0 auto 2px; object-fit: contain; }
.pdoc .pd-sig-blank { display: block; height: 46px; }
.pdoc .pd-sig-meta { font-size: 10px; color: #7a86ab; margin-top: 3px; }

/* Signature capture modal */
.sig-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.sig-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--text-secondary); background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 9px; cursor: pointer; }
.sig-tab.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft, rgba(124,92,255,.12)); }
.sig-tab i, .sig-tab svg { width: 14px; height: 14px; }
.sig-panel { display: flex; flex-direction: column; gap: 8px; }
.sig-canvas { width: 100%; height: auto; aspect-ratio: 560 / 190; background: #fff; border: 1px dashed var(--border-strong, #333c58); border-radius: 10px; touch-action: none; cursor: crosshair; }
.sig-panel-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#sig-type-input { font-size: 15px; }
.sig-type-preview { min-height: 80px; display: flex; align-items: center; justify-content: center; background: #fff; color: #0a1730; border: 1px solid var(--border); border-radius: 10px; font-family: 'Segoe Script', 'Bradley Hand', 'Snell Roundhand', cursive; font-size: 40px; overflow: hidden; padding: 8px 14px; }
.sig-saved-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
/* E8 — .sig-saved-item is now a wrapper div (pick button + delete button as
   siblings inside it, so the delete control isn't nested inside a button). */
.sig-saved-item { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.sig-saved-item.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft, rgba(124,92,255,.25)); }
.pdoc .pd-upi { display: flex; gap: 16px; align-items: center; margin-top: 8px; }

@media print {
  body * { visibility: hidden !important; }
  body { background: #fff !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area { display: block !important; position: absolute; inset: 0; }
  .pdoc { border-radius: 0; max-width: none; padding: 8mm 10mm; }
}

/* Billing report stat tiles */
.stat-tile { padding: 16px 18px; }
.stat-tile .stat-value { font-family: var(--font-heading); font-size: 21px; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.stat-tile .stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Revenue trend — billed vs collected, 6 months of scaled CSS bars */
.trend-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 8px 4px 0; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.trend-bars { display: flex; align-items: flex-end; justify-content: center; gap: 3px; width: 100%; flex: 1; }
.trend-bar { width: 40%; max-width: 20px; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s ease; }
.trend-bar.billed { background: var(--blue-text, #60a5fa); }
.trend-bar.collected { background: #4ade80; }
.trend-label { font-size: 11px; color: var(--text-secondary); }
.trend-legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11.5px; color: var(--text-secondary); }
.trend-legend .tl-key { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.trend-legend .tl-key.billed { background: var(--blue-text, #60a5fa); }
.trend-legend .tl-key.collected { background: #4ade80; }

/* Channel mix — proportion bars */
.chan-row { margin-bottom: 12px; }
.chan-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; color: var(--text-secondary); }
.chan-head strong { color: var(--text-primary); }
.chan-track { height: 8px; border-radius: 6px; background: var(--glass-bg); overflow: hidden; }
.chan-fill { height: 100%; border-radius: 6px; min-width: 2px; transition: width .3s ease; }

/* ==========================================================================
   BILLING ALERTS (Overview "Needs attention" card)
   ========================================================================== */
.alert-badge {
  margin-left: 8px;
  background: var(--red, #ef4444);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
}
.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}
.alert-row:last-child { border-bottom: none; }
.alert-row .alert-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; margin-right: 8px; display: inline-block; }
.alert-row.tone-bad .alert-dot { background: #f87171; }
.alert-row.tone-warn .alert-dot { background: #fbbf24; }
.alert-row.tone-unset .alert-dot { background: #94a3b8; }
.alert-row .alert-msg { flex: 1; min-width: 0; }

/* Faceted-filter checkbox toggle (Leads toolbar) + follow-up channel chip */
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); cursor: pointer; user-select: none; white-space: nowrap; }
.chip-toggle input { accent-color: var(--orange-text, #ff7a1a); }
.fu-chan { font-size: 10.5px; padding: 1px 7px; border-radius: 10px; background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text-secondary); }

/* WhatsApp Broadcasts */
.bc-audience { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 12px; padding: 14px; margin: 10px 0; }
.bc-count { margin-top: 10px; font-size: 14px; color: var(--text-secondary); }
.bc-count strong { color: var(--text-primary); font-size: 16px; }
.bc-preview { background: var(--bubble, var(--glass-bg)); border: 1px solid var(--glass-border); border-radius: 4px 12px 12px 12px; padding: 10px 13px; font-size: 13.5px; line-height: 1.5; color: var(--text-primary); white-space: pre-wrap; margin: 6px 0 10px; }
.bc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.bc-tile { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 10px; padding: 12px 14px; text-align: center; }
.bc-tile-val { font-family: var(--font-heading, inherit); font-size: 20px; font-weight: 800; color: var(--text-primary); }
.bc-tile-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); margin-top: 3px; }
.bc-tile.good .bc-tile-val { color: #35d07f; }
.bc-tile.bad .bc-tile-val { color: var(--red-text, #f87171); }
.broadcasts-card .card-head h3 { display: flex; align-items: center; gap: 8px; }
.autoreplies-card .card-head h3 { display: flex; align-items: center; gap: 8px; }

/* Auto-reply rules list */
.ar-list { display: flex; flex-direction: column; gap: 8px; }
.ar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 12px; }
.ar-row.ar-off { opacity: .55; }
.ar-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.ar-trig { font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ar-resp { font-size: 12.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }
.ar-name { font-size: 12px; color: var(--faint); }
.ar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ==========================================================================
   DOCUMENT CENTER
   ========================================================================== */
.dc-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; margin-top: 14px; align-items: start; }
@media (max-width: 720px) { .dc-cols { grid-template-columns: 1fr; } }
.dc-group { margin-bottom: 16px; }
.dc-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; margin-bottom: 8px; }
.dc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 560px) { .dc-grid { grid-template-columns: 1fr; } }
.dc-card {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--glass-border); border-radius: 10px; background: rgba(255,255,255,0.02);
}
.dc-card-text { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.dc-card-text span { font-size: 11px; }
.dc-card .btn { align-self: flex-start; }
.dc-hist-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 12.5px;
}
.dc-hist-row:last-child { border-bottom: none; }
.dc-hist-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; text-align: right; }

/* Printable document body — the sec()-composed content from docTemplates.js,
   rendered inside .pdoc alongside quotation/invoice documents. */
.pdoc .sec { margin-bottom: 4px; }
.pdoc .doc-p { color: #4a5578; white-space: pre-wrap; }
.pdoc .doc-cert { text-align: center; margin: 22px 0; }
.pdoc .doc-cert-sub { font-size: 15px; color: #4a5578; }
.pdoc .doc-cert-title { font-size: 22px; font-weight: 800; color: #26304d; margin: 8px 0; }
.pdoc .doc-svc-desc { color: #4a5578; }
.pdoc .doc-svc-unit { color: #8b95b5; }

/* ==========================================================================
   COMMAND PALETTE (Ctrl/Cmd + K)
   ========================================================================== */
.cmd-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(6, 7, 15, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px;
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity 0.18s var(--ease), visibility 0s 0.18s;
}
.cmd-overlay.active { opacity: 1; pointer-events: auto; visibility: visible; transition: opacity 0.18s var(--ease), visibility 0s 0s; }
.cmd-box {
  width: 100%; max-width: 560px; background: var(--bg-secondary);
  border: 1px solid var(--glass-border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5); display: flex; flex-direction: column; max-height: 66vh;
}
.cmd-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.cmd-head i, .cmd-head svg { width: 18px; height: 18px; color: var(--text-muted); flex: none; }
.cmd-head input { flex: 1; background: none; border: none; outline: none; color: var(--text-primary); font-size: 15px; }
.cmd-list { overflow-y: auto; padding: 6px; }
.cmd-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; padding: 8px 10px 4px; }
.cmd-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.cmd-item.sel { background: rgba(99, 102, 241, 0.16); }
.cmd-ic { width: 22px; display: flex; justify-content: center; color: var(--text-muted); flex: none; }
.cmd-ic i, .cmd-ic svg { width: 15px; height: 15px; }
.cmd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-meta { color: var(--text-muted); font-size: 11.5px; flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-empty { padding: 22px; text-align: center; color: var(--text-muted); font-size: 13px; }
.cmd-hint { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid rgba(255,255,255,0.06); font-size: 10.5px; color: var(--text-muted); }

/* Collapsible 'more details' sections on the Add-Contact + contact detail forms */
.ac-more, .contact-billing-details { margin: 8px 0 4px; }
.ac-more > summary, .contact-billing-details > summary {
  cursor: pointer; font-size: 12.5px; color: var(--text-secondary); font-weight: 600;
  padding: 8px 0; user-select: none; list-style: revert;
}
.ac-more > summary:hover, .contact-billing-details > summary:hover { color: var(--text-primary); }

/* Authority & licences editor (contact detail) */
.lic-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.lic-row { display: grid; grid-template-columns: 1.4fr 1fr auto auto; gap: 8px; align-items: center; }
.lic-row .lic-expiry { min-width: 130px; }
.lic-actions { display: flex; gap: 8px; }
@media (max-width: 560px) { .lic-row { grid-template-columns: 1fr 1fr; } }

/* Company-logo upload control in the billing settings form */
.cb-logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cb-logo-preview { max-height: 44px; max-width: 160px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }

/* ===== Website widget & QR generator (AiSensy-N) ===== */
.widget-card .card-desc { margin-bottom: 16px; }
.widget-grid { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.widget-form { display: flex; flex-direction: column; gap: 4px; }
.widget-form .input-color, .widget-form input[type="color"] { width: 48px; height: 40px; padding: 2px; border: 1px solid var(--glass-border); border-radius: var(--radius-sm); background: var(--bg-raised); cursor: pointer; }
.widget-preview { background: var(--bg-primary); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 14px; position: sticky; top: 12px; }
.wp-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.wp-stage { position: relative; height: 210px; border-radius: var(--radius-sm); background: linear-gradient(135deg, #1b2036 0%, #10131f 100%); overflow: hidden; }
.wp-stage::after { content: "Your website"; position: absolute; top: 12px; left: 14px; font-size: 12px; color: var(--text-muted); }
.wp-float { position: absolute; bottom: 16px; display: flex; flex-direction: column; align-items: flex-end; }
.wp-float.wp-right { right: 16px; }
.wp-float.wp-left { left: 16px; align-items: flex-start; }
.wp-bubble { max-width: 190px; margin-bottom: 10px; background: #fff; color: #111; padding: 9px 13px; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.28); font-size: 13px; line-height: 1.4; }
.wp-btn { display: flex; align-items: center; justify-content: center; width: 54px; height: 54px; border-radius: 50%; box-shadow: 0 6px 20px rgba(0,0,0,.32); }
.widget-outputs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.wo-card { background: var(--bg-raised); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.wo-card-wide { grid-column: 1 / -1; }
.wo-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.wo-head > span { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.wo-head i { width: 16px; height: 16px; }
.wo-body { flex: 1; }
.ww-link { display: block; word-break: break-all; font-size: 12.5px; background: var(--bg-primary); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); padding: 9px 11px; color: var(--green-text); }
.wo-qr { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.wo-qr svg { width: 176px; height: 176px; border-radius: 8px; }
.ww-snippet { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.45; background: var(--bg-primary); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text-secondary); resize: vertical; }
.wo-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-top: 10px; }
.wo-hint code { background: var(--bg-primary); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.wo-empty { font-size: 12.5px; color: var(--text-muted); text-align: center; padding: 20px 8px; }
@media (max-width: 900px) {
  .widget-grid { grid-template-columns: 1fr; }
  .widget-preview { position: static; }
  .widget-outputs { grid-template-columns: 1fr; }
}

/* ===== Multi-entity billing manager (F1) ===== */
.entity-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--glass-border); border-radius: var(--radius-sm); background: var(--bg-raised); margin-bottom: 8px; }
.entity-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.entity-main strong { font-size: 14px; }
.entity-main .cell-muted { font-size: 12px; }
.entity-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ===== Smart follow-up nudges (I1) ===== */
.fu-smart-section { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--glass-border); }
.fu-smart-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.fu-smart-head i { width: 13px; height: 13px; color: var(--accent-2); }
.fu-due.warn { color: #fbbf24; }
.fu-row.fu-smart { opacity: .92; }

/* ===== Notification bell (I6) ===== */
.notif-bell-wrap { position: relative; }
#notif-bell-btn { position: relative; }
#notif-bell-btn .nav-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
.notif-bell-panel { position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-height: 420px; overflow-y: auto; background: var(--bg-raised); border: 1px solid var(--glass-border-strong); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.35); z-index: 500; }
.notif-bell-head { padding: 12px 14px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--glass-border); }
.notif-bell-list { padding: 6px; }
.notif-row { display: flex; gap: 10px; padding: 8px 8px; border-radius: var(--radius-sm); align-items: flex-start; }
.notif-row:hover { background: var(--glass-bg-hover); }
.notif-text { font-size: 12.5px; line-height: 1.45; color: var(--text-primary); }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
@media (max-width: 560px) { .notif-bell-panel { width: 280px; right: -60px; } }

/* ===== Lead score dot (G9) ===== */
.score-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.score-dot.score-hot { background: var(--green, #22c55e); box-shadow: 0 0 0 2px rgba(34,197,94,.2); }
.score-dot.score-warm { background: #fbbf24; box-shadow: 0 0 0 2px rgba(251,191,36,.2); }
.score-dot.score-cold { background: var(--text-muted, #6b7280); }

/* ===== Companies (account) grouping (G6) ===== */
.company-contacts { margin-top: 6px; font-size: 12px; }
.company-contact-link { font-size: 12px; padding: 0; }

/* ---------- G5: tasks & reminders (contact detail) ---------- */
.tasks-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.task-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--glass-border); }
.task-row:last-child { border-bottom: none; }
.task-row.task-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-check { flex-shrink: 0; }
.task-title { flex: 1; font-size: 13px; }
.task-due { font-size: 11px; padding: 2px 6px; border-radius: 999px; background: var(--bg-raised); color: var(--text-muted); }
.task-due.task-overdue { background: rgba(239,68,68,.12); color: #ef4444; }
.task-assignee { font-size: 11px; }

/* ---------- E5: multi-select documents (Document Center) ---------- */
.dc-select-check { margin-top: 3px; flex-shrink: 0; }
.dc-bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; margin-bottom: 8px; background: var(--bg-raised); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); font-size: 12.5px; }
.dc-bulk-bar span:first-child { font-weight: 600; margin-right: 4px; }

/* ---------- E6: signature upload tab (Otsu auto-clean) ---------- */
.sig-upload-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 190px; padding: 14px; text-align: center; cursor: pointer;
  background: #fff; border: 1px dashed var(--border-strong, #333c58); border-radius: 10px;
}
.sig-upload-drop img { max-width: 100%; max-height: 170px; object-fit: contain; }
.sig-upload-drop span { color: var(--text-muted); font-size: 12.5px; max-width: 320px; }
.sig-upload-drop span i, .sig-upload-drop span svg { display: block; margin: 0 auto 6px; width: 20px; height: 20px; }

/* ---------- E8: stamp vs signature type in the signature library ---------- */
.sig-saved-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding: 10px; background: none; border: none; cursor: pointer; }
.sig-saved-pick img { max-height: 48px; max-width: 130px; object-fit: contain; }
.sig-saved-pick span { font-size: 11px; color: #55608a; }
.sig-saved-type-badge { font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft, rgba(124,92,255,.15)); color: var(--accent); }
.sig-saved-type-badge.stamp { background: rgba(239,68,68,.12); color: #ef4444; }
.sig-saved-del { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; padding: 0; background: rgba(0,0,0,.55); color: #fff; border: none; border-radius: 50%; cursor: pointer; }
.sig-saved-del i, .sig-saved-del svg { width: 12px; height: 12px; }

/* ---------- H8: invoice/quote PDF themes ---------- */
/* Modern — accent header band + purple accent instead of classic's orange rule. */
.pdoc.theme-modern { padding-top: 0; }
.pdoc.theme-modern .pd-head { margin: 0 -38px 20px; padding: 26px 38px 20px; background: linear-gradient(135deg, #0a1730, #1c2b52); border-bottom: none; border-radius: 6px 6px 0 0; }
.pdoc.theme-modern .pd-co { color: #fff; }
.pdoc.theme-modern .pd-tag { color: #b9c2e6; }
.pdoc.theme-modern .pd-meta { color: #b9c2e6; }
.pdoc.theme-modern .pd-num { color: #fff; }
.pdoc.theme-modern .pd-kind h1 { color: #a78bfa; }
.pdoc.theme-modern h4 { color: #7c5cff; }
.pdoc.theme-modern th { background: #7c5cff; }
.pdoc.theme-modern .pd-grand td { border-top-color: #7c5cff; color: #7c5cff; }
.pdoc.theme-modern .pd-legend { border-left-color: #7c5cff; }
@media print { .pdoc.theme-modern .pd-head { margin: 0 0 20px; padding: 14px 0 16px; background: none; color: inherit; } .pdoc.theme-modern .pd-co, .pdoc.theme-modern .pd-tag, .pdoc.theme-modern .pd-meta, .pdoc.theme-modern .pd-num { color: initial; } .pdoc.theme-modern .pd-head { border-bottom: 3px solid #7c5cff; } }

/* Compact — same palette as classic, tighter spacing for dense line-item invoices. */
.pdoc.theme-compact { padding: 18px 22px; font-size: 11.5px; line-height: 1.35; }
.pdoc.theme-compact .pd-head { padding-bottom: 8px; border-bottom-width: 2px; }
.pdoc.theme-compact .pd-co { font-size: 15px; }
.pdoc.theme-compact .pd-kind h1 { font-size: 17px; }
.pdoc.theme-compact .pd-parties { margin: 10px 0 4px; }
.pdoc.theme-compact h4 { margin: 8px 0 4px; }
.pdoc.theme-compact th, .pdoc.theme-compact td { padding: 4px 6px; }
.pdoc.theme-compact .pd-grand td { font-size: 12.5px; padding-top: 4px; }
.pdoc.theme-compact .pd-sign { margin-top: 18px; }

/* ---------- I3: cross-channel comms analytics rollup (Overview) ---------- */
.comms-channel-row { padding: 10px 0; border-bottom: 1px solid var(--glass-border); }
.comms-channel-row:last-child { border-bottom: none; padding-bottom: 0; }
.comms-channel-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.comms-channel-title i, .comms-channel-title svg { width: 14px; height: 14px; }

/* ---------- Task completion date (doneAt) ---------- */
.task-done-at { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 2px 6px; border-radius: 999px; background: rgba(34,197,94,.12); color: #4ade80; }
.task-done-at i, .task-done-at svg { width: 11px; height: 11px; }

/* ---------- manual inbox poll button ---------- */
#poll-inbox-btn.spinning i, #poll-inbox-btn.spinning svg { animation: spin 0.8s linear infinite; }
#poll-inbox-btn:disabled { opacity: .6; cursor: default; }
