/* ═══════════════════════════════════════════════════════════════════════════
   CRM UI  —  Global Design System  v1.0
   Covers: design tokens · toolbar · buttons · badges · tables · cards
           modals · forms · column-toggle · export menu · empty/load states
           print styles · dark-mode · responsive
   Primary colours are set dynamically in app.blade.php :root via PHP.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. DESIGN TOKENS ────────────────────────────────────────────────────── */
:root {
  /* Sizing */
  --crm-toolbar-h:      44px;
  --crm-th-h:           36px;
  --crm-row-h:          46px;
  --crm-btn-sz:         32px;
  --crm-btn-sz-sm:      26px;
  --crm-btn-sz-lg:      38px;

  /* Radii */
  --crm-r-xs:    4px;
  --crm-r-sm:    6px;
  --crm-r-md:   10px;
  --crm-r-lg:   16px;
  --crm-r-xl:   20px;
  --crm-r-pill: 999px;

  /* Shadows */
  --crm-sh-xs: 0 1px 3px rgba(0,0,0,.06);
  --crm-sh-sm: 0 2px 8px rgba(0,0,0,.08);
  --crm-sh-md: 0 4px 16px rgba(0,0,0,.10);
  --crm-sh-lg: 0 8px 32px rgba(0,0,0,.14);

  /* Type scale */
  --crm-fs-xs:   .68rem;
  --crm-fs-sm:   .76rem;
  --crm-fs-base: .86rem;
  --crm-fs-md:   .92rem;

  /* Motion */
  --crm-tx: .14s ease;

  /* Status palette */
  --s-success:  #15803d;  --s-bg-success:  #dcfce7;  --s-br-success:  #86efac;
  --s-warning:  #b45309;  --s-bg-warning:  #fef3c7;  --s-br-warning:  #fcd34d;
  --s-danger:   #b91c1c;  --s-bg-danger:   #fee2e2;  --s-br-danger:   #fca5a5;
  --s-info:     #1d4ed8;  --s-bg-info:     #dbeafe;  --s-br-info:     #93c5fd;
  --s-purple:   #6d28d9;  --s-bg-purple:   #ede9fe;  --s-br-purple:   #c4b5fd;
  --s-neutral:  #6b7280;  --s-bg-neutral:  #f3f4f6;  --s-br-neutral:  #d1d5db;
  --s-orange:   #c2410c;  --s-bg-orange:   #ffedd5;  --s-br-orange:   #fdba74;
  --s-teal:     #0f766e;  --s-bg-teal:     #ccfbf1;  --s-br-teal:     #5eead4;

  /* Table */
  --crm-stripe: rgba(0,0,0,.015);
  --crm-hover:  var(--crm-primary-soft, rgba(83,3,131,.06));
}


/* ── 2. CSS-ONLY TOOLTIP  (for dropdown-toggle buttons where Bootstrap  ──── */
/*    data-bs-toggle="tooltip" would conflict with data-bs-toggle="dropdown") */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,10,25,.85);
  color: #fff;
  font-size: .65rem;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9000;
  letter-spacing: .02em;
}
[data-tip]:hover::after { opacity: 1; }

/* Card headers have overflow:hidden on the parent .crm-card — tooltip must
   appear BELOW the button so it is never clipped by the card boundary.     */
.crm-card-header [data-tip]::after {
  bottom: auto;
  top: calc(100% + 6px);
}


/* ── 2b. HELP TIP "?" BADGE — replaces all inline form-field descriptions ─ */
/* Usage: <span class="crm-help-tip" data-tip="Description here">?</span>    */
.crm-help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--crm-primary, #530383);
  color: var(--crm-on-primary, #fff);
  font-size: .58rem;
  font-weight: 700;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 5px;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
  text-decoration: none;
  transition: background .15s;
}
.crm-help-tip:hover { background: var(--crm-primary-dark, #3d0260); }
.crm-help-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,10,25,.93);
  color: #fff;
  font-size: .72rem;
  font-weight: 400;
  padding: 7px 11px;
  border-radius: 7px;
  width: max-content;
  max-width: 260px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
  letter-spacing: .01em;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
}
.crm-help-tip:hover::after { opacity: 1; }
/* Keep badge on same baseline as label text */
.form-label .crm-help-tip,
label .crm-help-tip { margin-bottom: 2px; }
/* Standalone tip below an input: add top margin */
.mb-3 > .crm-help-tip,
.mb-2 > .crm-help-tip { margin-top: 4px; margin-left: 0; }


/* ── Date field labels inside filter bars ───────────────────────────────── */
/* Every date input-group must be preceded by a .crm-filter-date-label span
   showing the column header name (Created, Due Date, Period, etc.)          */
.crm-filter-date-label,
.crm-filter-wrap span[style*="font-weight:500"] {
  font-size: .75rem;
  color: #9ca3af;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .02em;
  text-transform: none;
}

/* ── 3. STANDARD FILTER BAR — universal across CRM, super-admin, addons ─── */
/*
 * Usage: add class="crm-filter-bar" to any filter container div.
 * Children: .form-select-sm (auto-width), input-group date pickers,
 *           .crm-icon-btn apply/clear buttons — all auto-aligned.
 */
.crm-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f9fafb;
  border-bottom: 1px solid var(--crm-border, #e8eaef);
}
/* Hides crm-filter-left even when d-flex is present — !important needed to beat Bootstrap */
.crm-filter-left--hidden { display: none !important; }

/* ── 3a. ACTIVE-FILTER COUNT ON THE FUNNEL — a corner badge ─────────────────
   The funnel (.crm-filter-toggle, built by crm-table.js) is a fixed 30px square
   in the app layout. A count laid INSIDE it as a second flex item shared the
   square with the glyph and pushed the funnel half out of its own button
   (Leads list, 12/10/2026). So the count sits on the button's top-right corner,
   outside the flow — the glyph keeps its centre whatever the number says.
   Guarded by FilterBarOffersOneClickClearTest. */
.crm-filter-toggle { position: relative; overflow: visible; }
.crm-filter-toggle .crm-filter-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  margin: 0 !important;
  border-radius: 999px;
  background: var(--crm-primary, #530383);
  color: var(--crm-on-primary, #fff);
  border: 2px solid #fff;
  font-size: .6rem;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
  pointer-events: none;
}

/* The one-click clear beside the funnel (crm-table.js). Words kept on purpose:
   a bare × beside a funnel reads as "close", and the whole point of the button
   is that the operator can find it. Hidden while no filter is on. */
.crm-filter-bar .crm-filter-clear {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
}
.crm-filter-bar .crm-filter-clear.d-none { display: none !important; }
.crm-filter-bar .crm-filter-clear i { font-size: .95rem; }

/* All selects inside any filter bar: auto-width, consistent height */
.crm-filter-bar .form-select,
.crm-filter-bar .form-select-sm,
.crm-filter-wrap .form-select,
.crm-filter-wrap .form-select-sm,
.card-header .form-select-sm,
.crm-card-header .form-select-sm {
  width: auto !important;
  min-width: 110px;
  max-width: 220px;
  height: 32px;
  border-radius: 8px !important;
  font-size: .8rem;
  border-color: var(--crm-border, #e8eaef);
  background-color: #fff;
}

/* Search inputs inside filter bars */
.crm-filter-bar .form-control,
.crm-filter-bar .form-control-sm {
  height: 32px;
  border-radius: 8px !important;
  font-size: .8rem;
  border-color: var(--crm-border, #e8eaef);
}

/* Date input-group inside filter bars */
.crm-filter-bar .input-group .form-control { border-radius: 0 8px 8px 0 !important; }
.crm-filter-bar .input-group .input-group-text {
  border-radius: 8px 0 0 8px !important;
  background: transparent;
  border-right: 0;
  color: #9ca3af;
  font-size: .82rem;
  padding: 0 8px;
}

/* Separator */
.crm-filter-bar .crm-filter-sep {
  width: 1px; height: 20px;
  background: var(--crm-border, #e8eaef);
  flex-shrink: 0;
}

/* ── SECTION CARD ────────────────────────────────────────────────────────── */
/* ── 3. SECTION CARD ────────────────────────────────────────────────────── */
.crm-card {
  background: #fff;
  border: 1px solid var(--crm-border, #e8eaef);
  border-radius: var(--crm-card-radius, 20px);
  box-shadow: var(--crm-card-shadow, 0 2px 12px rgba(0,0,0,.06));
  overflow: hidden;
}

.crm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  border-bottom: 1px solid var(--crm-border, #e8eaef);
  background: #fff;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 54px;
}

.crm-card-title {
  font-size: var(--crm-fs-md);
  font-weight: 700;
  color: #2d2d3a;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.crm-card-title > i { font-size: 1.05rem; color: var(--crm-primary, #530383); }

.crm-card-body  { padding: 20px; }
.crm-card-flush { padding: 0; }

/* Round table top corners inside a card.
   crm-table-wrap has overflow-x:auto which breaks the parent overflow:hidden clip,
   so we round the th cells directly instead of relying on the card's border-radius. */
.crm-card .crm-table-wrap table.crm-table thead tr:first-child th:first-child {
  border-top-left-radius: calc(var(--crm-card-radius, 20px) - 2px);
}
.crm-card .crm-table-wrap table.crm-table thead tr:first-child th:last-child {
  border-top-right-radius: calc(var(--crm-card-radius, 20px) - 2px);
}
/* When table is the very first child (no card-header above it) */
.crm-card > .crm-table-wrap:first-child { overflow: hidden; }
.crm-card > .crm-table-wrap:first-child .crm-table-inner { overflow-x: auto; }


/* ── 4. TOOLBAR ─────────────────────────────────────────────────────────── */
.crm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--crm-border, #e8eaef);
  background: #fff;
  flex-wrap: wrap;
  gap: 8px;
  min-height: var(--crm-toolbar-h);
}

.crm-toolbar-left,
.crm-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.crm-toolbar-right { margin-left: auto; }

/* Search — global, works in .crm-toolbar, .crm-card-header, .crm-btn-group */
.crm-search { position: relative; display: flex; align-items: center; }
.crm-search-icon {
  position: absolute; left: 9px;
  font-size: .82rem; color: #9ca3af;
  pointer-events: none; z-index: 1;
}
.crm-search-input {
  padding-left: 28px !important;
  border-radius: var(--crm-r-pill) !important;
  font-size: var(--crm-fs-sm);
  height: 32px;
  border: 1px solid var(--crm-border, #e8eaef);
  background: #f9f9fb;
  transition: border-color var(--crm-tx), box-shadow var(--crm-tx), width var(--crm-tx), background var(--crm-tx);
  width: 200px;
}
.crm-search-input:focus {
  background: #fff;
  border-color: var(--crm-primary, #530383);
  box-shadow: 0 0 0 3px rgba(83,3,131,.08);
  outline: none;
  width: 240px;
}

.crm-toolbar-sep {
  width: 1px; height: 20px;
  background: var(--crm-border, #e8eaef);
  margin: 0 2px;
}


/* ── 5. ICON-ONLY BUTTONS ───────────────────────────────────────────────── */
/* Rule: ALL toolbar/table action buttons are icon-only. Tooltip explains action. */

.crm-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width:  var(--crm-btn-sz);
  height: var(--crm-btn-sz);
  border-radius: var(--crm-r-sm);
  border: 1px solid var(--crm-border, #e8eaef);
  background: #fff;
  color: #5a5a72;
  font-size: .9rem;
  cursor: pointer;
  padding: 0;
  transition: all var(--crm-tx);
  flex-shrink: 0;
  text-decoration: none;
  line-height: 1;
}
.crm-btn-icon:hover {
  border-color: var(--crm-primary, #530383);
  color: var(--crm-primary, #530383);
  background: var(--crm-hover);
  transform: translateY(-1px);
  box-shadow: var(--crm-sh-xs);
}
.crm-btn-icon:active {
  transform: translateY(0);
  box-shadow: none;
}
.crm-btn-icon:focus-visible {
  outline: 2px solid var(--crm-primary, #530383);
  outline-offset: 2px;
}
/* Sizes */
.crm-btn-icon.sz-sm { width: var(--crm-btn-sz-sm); height: var(--crm-btn-sz-sm); font-size: .75rem; border-radius: var(--crm-r-xs); }
.crm-btn-icon.sz-lg { width: var(--crm-btn-sz-lg); height: var(--crm-btn-sz-lg); font-size: 1rem;   border-radius: var(--crm-r-md); }

/* Colour modifiers */
.crm-btn-icon.v-primary {
  background: var(--crm-primary, #530383);
  border-color:  var(--crm-primary, #530383);
  color: var(--crm-on-primary, #fff);
}
.crm-btn-icon.v-primary:hover {
  background: var(--crm-primary-light, #7a12b8);
  border-color:  var(--crm-primary-light, #7a12b8);
  color: var(--crm-on-primary, #fff);
  box-shadow: 0 3px 12px rgba(83,3,131,.35);
}
.crm-btn-icon.v-success { background: var(--s-bg-success); border-color: var(--s-br-success); color: var(--s-success); }
.crm-btn-icon.v-success:hover { background: var(--s-success); border-color: var(--s-success); color: #fff; }
.crm-btn-icon.v-danger  { background: var(--s-bg-danger);  border-color: var(--s-br-danger);  color: var(--s-danger);  }
.crm-btn-icon.v-danger:hover  { background: var(--s-danger);  border-color: var(--s-danger);  color: #fff; }
.crm-btn-icon.v-warning { background: var(--s-bg-warning); border-color: var(--s-br-warning); color: var(--s-warning); }
.crm-btn-icon.v-warning:hover { background: var(--s-warning); border-color: var(--s-warning); color: #fff; }
.crm-btn-icon.v-info    { background: var(--s-bg-info);    border-color: var(--s-br-info);    color: var(--s-info);    }
.crm-btn-icon.v-info:hover    { background: var(--s-info);    border-color: var(--s-info);    color: #fff; }

/* Strip Bootstrap's dropdown caret — icon-only buttons need no text/arrow */
.crm-btn-icon.dropdown-toggle::after,
.crm-btn-icon.dropdown-toggle::before { display: none !important; }

/* Active (toggled-on) state */
.crm-btn-icon.is-active {
  background: var(--crm-primary, #530383);
  border-color: var(--crm-primary, #530383);
  color: var(--crm-on-primary, #fff);
}

/* Button group */
.crm-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

/* Ensure filter panel selects are consistent height */
.crm-card-header .form-select-sm,
.crm-card-header .form-control-sm { height: 32px; }


/* ── 6. TABLE ROW ACTION BUTTONS (smaller, inside td) ───────────────────── */
.crm-ab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--crm-r-xs);
  border: 1px solid transparent;
  background: transparent;
  font-size: .8rem;
  cursor: pointer;
  padding: 0;
  color: #9ca3af;
  transition: all var(--crm-tx);
}
.crm-ab:hover { transform: translateY(-1px); }

.crm-ab.ab-edit:hover     { background: var(--s-bg-info);    color: var(--s-info);    border-color: var(--s-br-info);    }
.crm-ab.ab-view:hover     { background: var(--s-bg-purple);  color: var(--s-purple);  border-color: var(--s-br-purple);  }
.crm-ab.ab-open:hover     { background: var(--s-bg-success); color: var(--s-success); border-color: var(--s-br-success); }
.crm-ab.ab-delete:hover   { background: var(--s-bg-danger);  color: var(--s-danger);  border-color: var(--s-br-danger);  }
.crm-ab.ab-settings:hover { background: var(--s-bg-warning); color: var(--s-warning); border-color: var(--s-br-warning); }
.crm-ab.ab-print:hover    { background: var(--s-bg-teal);    color: var(--s-teal);    border-color: var(--s-br-teal);    }
.crm-ab.ab-download:hover { background: var(--s-bg-info);    color: var(--s-info);    border-color: var(--s-br-info);    }

.crm-ab-group { display: inline-flex; align-items: center; gap: 3px; }

/* ── 6b. THREE-DOTS TRIGGER + ACTION POPUP ──────────────────────────────── */
/* Single ⋮ button shown in every action cell; other buttons hidden until click */
.crm-dots-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--crm-r-xs);
  border: 1px solid transparent;
  background: transparent;
  font-size: .88rem;
  cursor: pointer;
  padding: 0;
  color: #9ca3af;
  transition: all var(--crm-tx);
  vertical-align: middle;
}
.crm-dots-trigger:hover,
.crm-dots-trigger.crm-ap-open {
  background: var(--s-bg-neutral, #f3f4f6);
  color: #374151;
  border-color: var(--crm-border, #e5e7eb);
}
/* Floating popup panel — position:fixed so it escapes overflow:hidden containers */
.crm-action-popup {
  position: fixed;
  z-index: 10500;
  background: #fff;
  border: 1px solid var(--crm-border, #e5e7eb);
  border-radius: var(--crm-r-md);
  box-shadow: 0 6px 24px rgba(0,0,0,.13);
  min-width: 148px;
  padding: 4px 0;
  overflow: hidden;
}
/* Menu items inside popup */
.crm-ap-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 14px;
  font-size: .8rem;
  font-weight: 500;
  color: #374151;
  background: transparent;
  border: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--crm-tx), color var(--crm-tx);
}
.crm-ap-item:hover { background: var(--crm-hover, rgba(83,3,131,.06)); color: var(--crm-primary, #530383); }
.crm-ap-item i { font-size: .82rem; width: 16px; flex-shrink: 0; opacity: .7; }
.crm-ap-item:hover i { opacity: 1; }
.crm-ap-item.crm-ap-danger { color: var(--s-danger, #b91c1c); }
.crm-ap-item.crm-ap-danger:hover { background: var(--s-bg-danger, #fee2e2); color: var(--s-danger, #b91c1c); }
.crm-ap-sep { margin: 3px 10px; border: none; border-top: 1px solid var(--crm-border, #e5e7eb); }

/* ── 6c. DATATABLES "PROCESSING" — slim top bar, never a spinner "donut" ───── */
/* DataTables' bootstrap5 default renders four border-radius:50% dots (a circular
   "donut" loader) centred over the table — on a narrow action column it reads as a
   stray circle inside the action cell. Replace it with a slim top progress bar. */
div.dataTables_processing {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: transparent !important;
  height: 3px !important;
  padding: 0 !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  margin: 0 !important;
  overflow: hidden;
}
div.dataTables_processing > div { display: none !important; }
div.dataTables_processing::after {
  content: '';
  position: absolute;
  left: 0; top: 0;
  height: 3px; width: 40%;
  background: var(--crm-primary, #530383);
  border-radius: 3px;
  animation: crm-dt-progress 1.1s ease-in-out infinite;
}
@keyframes crm-dt-progress { 0% { left: -40%; } 100% { left: 100%; } }


/* ── 7. EXPORT MENU DROPDOWN ────────────────────────────────────────────── */
.crm-export-menu {
  min-width: 164px;
  padding: 4px;
  border-radius: var(--crm-r-md);
  border: 1px solid var(--crm-border, #e8eaef);
  box-shadow: var(--crm-sh-md);
}
.crm-export-menu .exp-section {
  font-size: var(--crm-fs-xs);
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 5px 12px 3px;
}
.crm-export-menu .dropdown-item {
  border-radius: var(--crm-r-sm);
  font-size: var(--crm-fs-sm);
  padding: 7px 12px;
  color: #444;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background var(--crm-tx), color var(--crm-tx);
}
.crm-export-menu .dropdown-item i { font-size: .9rem; width: 15px; text-align: center; }
.crm-export-menu .dropdown-item:hover {
  background: var(--crm-hover);
  color: var(--crm-primary, #530383);
}
.crm-export-menu hr.dropdown-divider { margin: 4px 0; border-color: var(--crm-border, #e8eaef); }


/* ── 8. COLUMN VISIBILITY PANEL ─────────────────────────────────────────── */
.crm-col-panel {
  min-width: 185px;
  padding: 6px 4px 4px;
  border-radius: var(--crm-r-md);
  border: 1px solid var(--crm-border, #e8eaef);
  box-shadow: var(--crm-sh-md);
}
.crm-col-panel .cp-title {
  font-size: var(--crm-fs-xs);
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 12px 5px;
  border-bottom: 1px solid var(--crm-border, #e8eaef);
  margin-bottom: 3px;
}
.crm-col-panel .cp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--crm-r-sm);
  cursor: pointer;
  font-size: var(--crm-fs-sm);
  color: #444;
  user-select: none;
  transition: background var(--crm-tx);
}
.crm-col-panel .cp-item:hover { background: var(--crm-hover); color: var(--crm-primary, #530383); }
.crm-col-panel .cp-eye { font-size: .8rem; width: 15px; text-align: center; color: var(--crm-primary, #530383); }
.crm-col-panel .cp-item.cp-off { color: #b0b0b8; }
.crm-col-panel .cp-item.cp-off .cp-eye { color: #d1d5db; }


/* ── 9. TABLE ───────────────────────────────────────────────────────────── */
/* Outer wrapper: overflow:hidden so th border-radius is clipped by the card corners.
   Inner wrapper: overflow-x:auto — the actual horizontal scroll container. */
.crm-table-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: 12px 12px 0 0;  /* rounded purple header corners */
}
.crm-table-inner {
  width: 100%;
  overflow: hidden;               /* needed so border-radius clips in-flow content */
  overflow-x: auto;
  border-radius: 12px 12px 0 0;
  -webkit-overflow-scrolling: touch;
}

table.crm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--crm-fs-base);
  color: #3a3a4a;
}

/* Header — !important beats Bootstrap's .table > :not(caption) > * > * specificity */
table.crm-table thead th {
  background: var(--crm-primary, #530383) !important;
  color: var(--crm-on-primary, #fff) !important;
  font-size: var(--crm-fs-xs);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 9px 14px;
  height: var(--crm-th-h);
  white-space: nowrap;
  border: none;
  position: relative;
  cursor: default;
}
/* Sort indicators via DataTables classes */
table.crm-table thead th.sorting,
table.crm-table thead th.sorting_asc,
table.crm-table thead th.sorting_desc { cursor: pointer; padding-right: 26px; }
table.crm-table thead th.sorting::after,
table.crm-table thead th.sorting_asc::after,
table.crm-table thead th.sorting_desc::after {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  font-family: 'Phosphor-Light'; font-size: .75rem;
  opacity: .5;
}
table.crm-table thead th.sorting::after      { content: '\e5d8'; }
table.crm-table thead th.sorting_asc::after  { content: '\e5ca'; opacity: 1; }
table.crm-table thead th.sorting_desc::after { content: '\e5c4'; opacity: 1; }

/* Column pin/freeze toggle button (added per scrollable header by crm-table.js) */
.crm-th-pin {
  background: transparent;
  border: 0;
  padding: 0 2px;
  margin-left: 5px;
  cursor: pointer;
  color: inherit;
  font-size: .82rem;
  line-height: 1;
  vertical-align: middle;
  opacity: .55;
  transition: opacity .12s ease, color .12s ease;
}
.crm-th-pin:hover   { opacity: 1; }
.crm-th-pin.pinned  { opacity: 1; color: #fbbf24; }

/* Body */
table.crm-table tbody tr {
  transition: background var(--crm-tx), box-shadow var(--crm-tx);
}
table.crm-table tbody tr:nth-child(even)  { background: var(--crm-stripe); }
table.crm-table tbody tr:hover            { background: var(--crm-hover) !important; box-shadow: inset 3px 0 0 var(--crm-primary, #530383); }
table.crm-table tbody tr.dt-selected,
table.crm-table tbody tr.crm-row-selected { background: var(--s-bg-purple) !important; }

table.crm-table tbody td {
  padding: 9px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f5;
  color: #3a3a4a;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.crm-table tbody tr:last-child td { border-bottom: none; }

/* Action (last) column */
table.crm-table tbody td.crm-td-actions { white-space: nowrap; text-align: right; padding: 5px 10px; }

/* ── BOTTOM SCROLLBAR GUTTER — keep the horizontal scrollbar off the last row ──
   WHY: .table-responsive (overflow-x:auto) draws its horizontal scrollbar at the
   container's bottom edge. When the last row is the only/short content, that bar
   sits right over the row's action ⋮ button and visually hides it ("hidden under
   the table's lower bar"). Reserve a small bottom gutter so the scrollbar always
   drops BELOW the row content, clear of the action button.                      */
.table-responsive { padding-bottom: 16px; }
.table-responsive > table.crm-table { margin-bottom: 0; }

/* ── STICKY ACTION (LAST) COLUMN — keep row actions reachable ────────────────
   WHY: every table lives in .table-responsive (overflow-x:auto). When the table
   is wider than its card the LAST column — in this CRM that is the action button
   group — scrolls off the right edge and Edit/Delete become unreachable. Pinning
   the last column to the right edge keeps it visible no matter the scroll. It is
   a no-op when the table fits (the column already sits at the right edge).
   Row stripe/hover colours are semi-transparent, so a pinned cell needs an
   OPAQUE background or scrolled content bleeds through: we composite the overlay
   over the solid card colour with a gradient layer over a solid base.          */
.table-responsive > table.crm-table > thead > tr > th:last-child {
  position: -webkit-sticky;
  position: sticky;
  right: 0;
  z-index: 3;
  background: var(--crm-primary, #530383) !important;
}
.table-responsive > table.crm-table > tbody > tr:not(.dtrg-group) > td:last-child {
  position: -webkit-sticky;
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--crm-card-bg, #fff);
  /* Breathing room: keep the ⋮ trigger off the right edge/scrollbar so it never
     reads as clipped or "tucked under" the table border. */
  min-width: 52px;
  padding-right: 14px;
  /* Left-cast divider so the pinned cell visually separates from content that
     scrolls underneath it (only noticeable once the table actually overflows). */
  box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .18);
}
.table-responsive > table.crm-table > tbody > tr:not(.dtrg-group):nth-child(even) > td:last-child {
  background: linear-gradient(var(--crm-stripe), var(--crm-stripe)), var(--crm-card-bg, #fff);
}
.table-responsive > table.crm-table > tbody > tr:not(.dtrg-group):hover > td:last-child {
  background: linear-gradient(var(--crm-hover), var(--crm-hover)), var(--crm-card-bg, #fff) !important;
}
.table-responsive > table.crm-table > tbody > tr.dt-selected > td:last-child,
.table-responsive > table.crm-table > tbody > tr.crm-row-selected > td:last-child {
  background: var(--s-bg-purple) !important;
}
/* Dark theme: same composition over the dark card surface */
[data-bs-theme="dark"] .table-responsive > table.crm-table > tbody > tr:not(.dtrg-group) > td:last-child {
  background: var(--crm-card-bg, #1e1e2d);
}
[data-bs-theme="dark"] .table-responsive > table.crm-table > tbody > tr:not(.dtrg-group):nth-child(even) > td:last-child {
  background: linear-gradient(rgba(255,255,255,.03), rgba(255,255,255,.03)), var(--crm-card-bg, #1e1e2d);
}
[data-bs-theme="dark"] .table-responsive > table.crm-table > tbody > tr:not(.dtrg-group):hover > td:last-child {
  background: linear-gradient(var(--crm-hover), var(--crm-hover)), var(--crm-card-bg, #1e1e2d) !important;
}

/* Row-group header — transparent cell, oval pill label inside */
table.crm-table tr.dtrg-group td {
  background: transparent !important;
  border-bottom: 1px solid var(--crm-border, #e5e7eb) !important;
  padding: 7px 14px !important;
}
.crm-rg-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--crm-primary, #530383);
  color: var(--crm-on-primary, #fff);
  padding: 4px 14px 4px 11px;
  border-radius: var(--crm-r-pill);
  font-size: var(--crm-fs-xs);
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.4;
}
.crm-rg-pill .crm-rg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.22);
  border-radius: var(--crm-r-pill);
  font-size: .62rem;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-weight: 700;
}

/* ── Oval / pill table-section headers (inline tables in modals/forms) ── */
/* Wrap any plain <table> in a .crm-tbl-wrap to get oval headers           */
.crm-tbl-wrap {
  border-radius: var(--crm-r-lg);
  overflow: hidden;
  border: 1px solid var(--crm-border, #e5e7eb);
}
.crm-tbl-wrap table {
  border-collapse: separate !important;
  border-spacing: 0;
  width: 100%;
  margin-bottom: 0;
}
.crm-tbl-wrap thead tr:first-child th {
  background: var(--crm-primary, #530383) !important;
  color: var(--crm-on-primary, #fff) !important;
  font-size: var(--crm-fs-xs);
  font-weight: 700;
  letter-spacing: .04em;
  border: none !important;
  padding: 9px 12px;
}
.crm-tbl-wrap thead tr:first-child th:first-child {
  border-top-left-radius: calc(var(--crm-r-lg) - 1px);
}
.crm-tbl-wrap thead tr:first-child th:last-child {
  border-top-right-radius: calc(var(--crm-r-lg) - 1px);
}
.crm-tbl-wrap tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--crm-r-lg) - 1px); }
.crm-tbl-wrap tbody tr:last-child td:last-child  { border-bottom-right-radius: calc(var(--crm-r-lg) - 1px); }
.crm-tbl-wrap tbody tr:hover { background: var(--crm-hover, rgba(83,3,131,.04)); }
.crm-tbl-wrap tbody td { border-bottom: 1px solid var(--crm-border, #e5e7eb); padding: 7px 12px; vertical-align: middle; font-size: var(--crm-fs-sm); }
.crm-tbl-wrap tbody tr:last-child td { border-bottom: none; }

/* Hide native number spinners inside compact inline tables — too narrow */
.crm-tbl-wrap input[type=number]::-webkit-outer-spin-button,
.crm-tbl-wrap input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.crm-tbl-wrap input[type=number] { -moz-appearance: textfield; }

/* Checkbox column */
table.crm-table th.crm-th-chk,
table.crm-table td.crm-td-chk {
  width: 36px; min-width: 36px;
  padding: 8px 8px 8px 14px;
  text-align: center;
}

/* Empty cell */
table.crm-table tbody td.dataTables_empty {
  text-align: center;
  padding: 52px 20px;
  color: #bbb;
  font-size: var(--crm-fs-md);
  font-style: italic;
}


/* ── 9. FUNNEL-TOGGLE FILTER WRAP — see section 9c below for the canonical rule */

/* ── 9a. BULK ACTION BAR ────────────────────────────────────────────────────
   Rule: right-aligned, flat (no inner wrapper), bell first, apply last.
   justify-content:flex-end keeps the group tight on the right.
   min-height:42px + padding:4px 8px gives breathing room.                   */
.crm-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
  padding: 4px 8px;
  background: #fff;
  border-bottom: 1px solid var(--crm-border, #e8eaef);
}
.crm-bulk-bar .vr { margin: 0 2px; }

/* ── 9b. ROUNDED TABLE HEADER — clip-path approach (the only reliable method) ──
   WHY: overflow:hidden on .table-responsive clips the DataTables length-control
        injected ABOVE the header, not the header itself. The only reliable fix
        is clip-path on the thead tr — it clips the tr's painted background
        directly to a rounded shape, independent of any parent container.     */
table thead tr:first-child {
  clip-path: inset(0 round 12px 12px 0 0);
}
/* Keep border-collapse:separate so per-table border-radius overrides work   */
.crm-table-container table,
.card .table-responsive table,
.card-body .table-responsive table {
  border-collapse: separate !important;
  border-spacing: 0;
}

/* ── 9c. FILTER WRAP — always horizontal, max-height animation ──────────────
   WHY: jQuery slideToggle() sets display:block, breaking flex layout.
   FIX: keep display:flex always; animate via max-height instead.
   Show/hide by adding/removing class 'open' — never touch display directly.  */
.crm-filter-wrap {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: #f9fafb;
  max-height: 0;
  overflow: hidden;
  padding: 0 16px;
  border-bottom: 1px solid transparent;
  transition: max-height .22s ease, padding .2s ease, border-color .2s ease;
}
.crm-filter-wrap.open {
  /* Room for a GROUPED row (see 9c-i): the groups wrap onto two or three lines
     on a laptop, and a cap that clips them would hide controls with nothing on
     screen to say so — the row is overflow:visible when open, so a short row is
     unaffected by the larger cap. */
  max-height: 520px;
  padding: 10px 16px;
  border-bottom-color: var(--crm-border, #e8eaef);
  overflow: visible; /* allow absolute dropdowns inside to render outside the bar bounds */
}

/* ── 9c-i. FILTER GROUPS — a wide filter row read in one glance ──────────────
   WHY: a row of twelve bare dropdowns is a wall. Nothing says which control
   answers which question, so the operator reads every one of them every time,
   and two controls that mean almost the same thing (Next call due / Last call)
   sit side by side with nothing to tell them apart. Reported 02/09/2026 on the
   Tele Call queue: "the table has many filters which must be grouped".
   HOW: each group is a bordered chip carrying a small caption and its own
   controls. Purely presentational — the controls keep their ids, so every
   reader, every guard and crm-filter-multi's pills are untouched. */
.crm-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px 5px 8px;
  border: 1px solid var(--crm-border, #e8eaef);
  border-radius: 10px;
  background: #fff;
}
.crm-filter-group-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #8b93a1;
  white-space: nowrap;
  padding-right: 2px;
}
/* The actions group is the end of the sentence — push it to the right edge so
   the tick is always in the same place however the groups above it wrap. */
.crm-filter-group.crm-filter-actions {
  margin-left: auto;
  border-color: transparent;
  background: transparent;
  padding-right: 0;
}
@media (max-width: 640px) {
  .crm-filter-group { width: 100%; flex-wrap: wrap; }
  .crm-filter-group.crm-filter-actions { margin-left: 0; justify-content: flex-end; }
}

/* Filter wrap date input-groups: shrink to icon + compact text area */
.crm-filter-wrap .input-group:has(input.flatpickr-input) {
  width: 115px !important;
}
.crm-filter-wrap .input-group input.flatpickr-input {
  cursor: pointer;
  padding-left: 2px;
}

/* Filter wrap selects: match filter-bar height + radius */
.crm-filter-wrap .form-select,
.crm-filter-wrap .form-select-sm {
  height: 32px;
  border-radius: 8px !important;
  font-size: .8rem;
  border-color: var(--crm-border, #e8eaef);
  background-color: #fff;
}

/* ── 9d. STATUS BADGES — global, all layouts ────────────────────────────────
   Both .crm-inline-status (clickable, has arrow) and .crm-status-badge (read-only)
   share the same pill shape: white bg, colored border + dot, text in status color.
   Arrow is always pinned to the right end via margin-left:auto.
   Set color + border-color via inline style from PHP/JS — currentColor handles the rest. */

.crm-inline-status,
.crm-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 100px;
  padding: 3px 7px 3px 8px;
  border-radius: 20px;
  background: #fff;
  border: 1.5px solid;
  font-size: .74rem !important;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1.3;
  box-sizing: border-box;
}
.crm-inline-status { cursor: pointer; user-select: none; }
.crm-inline-status:hover { filter: brightness(.96); }
.crm-inline-status--unset {
  border-color: #d1d5db !important;
  color: #9ca3af !important;
}

/* Colored dot on left — inherits currentColor from parent inline style */
.crm-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}

/* Status text — grows to fill space */
.crm-status-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* Caret arrow — always pinned to right */
.crm-status-arrow {
  font-size: .58rem; opacity: .55; flex-shrink: 0; margin-left: auto;
}

/* ── 9d2. STATUS CHANGE POPUP — global, body-level fixed overlay ────────────
   Used by leads (and any future module). Append to <body>, position:fixed.
   Uses .crm-sp-item (NOT Bootstrap .dropdown-item) to avoid color conflicts. */
.crm-status-popup {
  position: fixed; z-index: 9999;
  background: #fff;
  border: 1px solid var(--crm-border, #e8eaef);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
  padding: 5px 0;
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}
.crm-status-popup .crm-sp-title {
  font-size: .70rem; font-weight: 700; color: #9ca3af;
  padding: 5px 14px 4px; letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid var(--crm-border, #e8eaef); margin-bottom: 3px;
}
.crm-sp-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: pointer;
  font-size: .82rem; font-weight: 500; color: #374151;
  border-radius: 0; transition: background .1s;
  text-decoration: none; border: none; background: none; width: 100%;
}
.crm-sp-item:hover { background: var(--crm-primary-soft, #f3e8ff); color: var(--crm-primary, #530383); }
.crm-sp-item.active { font-weight: 700; }
.crm-sp-item .crm-sp-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.crm-sp-item .crm-sp-check {
  margin-left: auto; font-size: .8rem;
  color: var(--crm-primary, #530383); flex-shrink: 0;
}

/* ── 9d3. INLINE ASSIGNEE — clickable cell + user-picker popup ──────────────
   Avatar-only display: name text is hidden globally; name visible on hover
   via title="" on the avatar circle. Click → floating picker → PATCH.      */
.crm-inline-assignee {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px 2px 2px;
  border-radius: 20px;
  border: 1.5px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--crm-tx), background var(--crm-tx);
  white-space: nowrap;
  vertical-align: middle;
  max-width: 56px;
}
.crm-inline-assignee:hover {
  border-color: var(--crm-border, #e5e7eb);
  background: var(--s-bg-neutral, #f3f4f6);
}
.crm-inline-assignee.crm-ia--unset {
  color: #9ca3af;
  font-size: .74rem;
  font-weight: 600;
  max-width: 80px;
}
.crm-inline-assignee .crm-ia-label { font-size: .74rem; }
.crm-inline-assignee .crm-ia-arrow { font-size: .55rem; opacity: .5; flex-shrink: 0; }
/* Avatar-only: name text hidden globally — name shown via title="" tooltip */
.crm-inline-assignee .small { display: none !important; }

/* User-picker popup */
.crm-assignee-popup {
  position: fixed; z-index: 10400;
  background: #fff;
  border: 1px solid var(--crm-border, #e5e7eb);
  border-radius: var(--crm-r-md);
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
  padding: 0;
  min-width: 220px;
  max-width: 260px;
  display: none;
  overflow: hidden;
}
.crm-assignee-popup .crm-ap-title {
  font-size: .70rem; font-weight: 700; color: #9ca3af;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 12px 5px;
  border-bottom: 1px solid var(--crm-border, #e5e7eb);
}
.crm-ai-search-wrap { padding: 6px 10px 4px; }
.crm-ai-search {
  width: 100%; padding: 4px 8px;
  border: 1px solid var(--crm-border, #e5e7eb);
  border-radius: var(--crm-r-sm);
  font-size: .78rem; outline: none;
}
.crm-ai-search:focus { border-color: var(--crm-primary, #530383); }
.crm-ai-list { max-height: 260px; overflow-y: auto; padding: 2px 0; }
.crm-ai-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 12px;
  background: none; border: none; cursor: pointer;
  font-size: .8rem; font-weight: 500; color: #374151;
  text-align: left; transition: background var(--crm-tx);
}
.crm-ai-item:hover { background: var(--crm-hover, rgba(83,3,131,.06)); color: var(--crm-primary, #530383); }
.crm-ai-item.active { font-weight: 700; }
.crm-ai-avatar {
  width: 26px; height: 26px; border-radius: 50%; overflow: hidden;
  background: var(--crm-primary, #530383); color: var(--crm-on-primary, #fff);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700; flex-shrink: 0;
}
.crm-ai-avatar img { width: 100%; height: 100%; object-fit: cover; }
.crm-ai-avatar-none { background: #e5e7eb; color: #9ca3af; }
.crm-ai-unassign .crm-ai-avatar { background: #f3f4f6; color: #9ca3af; }
.crm-ai-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }


/* ── 9e. AVATAR CIRCLES — global, all layouts ───────────────────────────── */
.avatar-circle-sm {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--crm-primary, #530383); color: var(--crm-on-primary, #fff);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--crm-primary, #530383); color: var(--crm-on-primary, #fff);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.crm-avatar-img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block;
}
/* Crisp, defined edge on every avatar circle (reduces the "soft/blurry" look
   of compressed staff photos). Subtle inner ring, no layout shift. */
.avatar-circle-sm, .avatar-circle, .crm-avatar {
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
/* ── 9e-i. DAYS-SINCE-CONTACT CHIP — Tele Call queue Days + Leads Last Contact ──
   Built ONLY by TelecallService::daysChip(). Lived inline on the Tele Call page
   until 17/09/2026; shared here so the Leads table draws the identical pill.
   The four class tokens are the words the service emits (colourBand) —
   DynamicCssClassEnumSweepTest holds this file to that vocabulary. Deliberately
   NOT named .ad-* or anything an ad-blocker list matches: EasyList hides such
   nodes outright and the column would silently render blank. */
.tc-band {
  display: inline-block; min-width: 30px; padding: 2px 7px;
  border-radius: 11px; font-size: .74rem; font-weight: 600;
  text-align: center; color: #fff; vertical-align: middle;
}
.tc-band-green  { background: #16A34A; }
.tc-band-orange { background: #EA8A0B; }
.tc-band-red    { background: #DC2626; }
.tc-band-grey   { background: #C3C7CE; }
/* The call-outcome pill (TelecallService::outcomeBadge) — Tele Call queue
   Outcome + Leads Tele Call Status. Background is the outcome's own colour. */
.tc-outcome {
  display: inline-block; padding: 2px 9px; border-radius: 11px;
  font-size: .73rem; font-weight: 600; color: #fff; white-space: nowrap;
}
/* ── 9e-ii. REMARKS POPOVER — eye icon in Follow-ups / Leads tables ──────── */
.crm-remarks-btn { color: #6c757d; text-decoration: none; }
.crm-remarks-btn:hover { color: var(--crm-primary, #530383); }
.crm-remarks-cell { text-align: center; white-space: nowrap; }
.crm-remarks-popover .popover-body {
  max-width: 300px; max-height: 200px; overflow-y: auto;
  word-wrap: break-word; white-space: pre-wrap; font-size: .875rem;
}

/* ── 9f. CRM-AVATAR generic circle (stat icons, show-page headers) ────────── */
.crm-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--crm-on-primary, #fff); font-weight: 700; flex-shrink: 0; overflow: hidden;
  background: var(--crm-primary, #530383);
}
.crm-avatar-xs { width: 22px; height: 22px; font-size: .63rem; }
.crm-avatar-sm { width: 28px; height: 28px; font-size: .70rem; }
.crm-avatar-md { width: 34px; height: 34px; font-size: .78rem; }
.crm-avatar-lg { width: 44px; height: 44px; font-size: 1.0rem; }
.crm-avatar-xl { width: 60px; height: 60px; font-size: 1.4rem; }

/* ── 9g. CRM-AVS — rounded-avatar dropdown (user / assignee selects) ──────── */
/* Enhances <select data-avatar-select>; native select is moved inside & hidden. */
.crm-avs { position: relative; }
.crm-avs > select[data-avatar-select] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0;
}
.crm-avs-control {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 38px; padding: 5px 10px; text-align: left;
  background: #fff; border: 1px solid var(--crm-border, #d7dae0);
  border-radius: 8px; font-size: .82rem; color: #1f2937; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.crm-avs-control:hover { border-color: #c2c6cf; }
.crm-avs.open .crm-avs-control {
  border-color: var(--crm-primary, #530383);
  box-shadow: 0 0 0 3px rgba(83, 3, 131, .12);
}
.crm-avs-ctrl-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-avs-caret { margin-left: auto; color: #9ca3af; font-size: .9rem; transition: transform .15s; }
.crm-avs.open .crm-avs-caret { transform: rotate(180deg); }
.crm-avs-ava { width: 24px; height: 24px; font-size: .64rem; }
.crm-avs-none { background: #eef0f3; color: #9ca3af; }
.crm-avs-none i { font-size: .8rem; }

.crm-avs-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 1080;
  background: #fff; border: 1px solid var(--crm-border, #e2e5ea); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15, 10, 25, .16); padding: 6px;
  display: none; max-height: 280px; overflow: hidden;
}
.crm-avs.open .crm-avs-panel { display: flex; flex-direction: column; }
.crm-avs-search {
  width: 100%; border: 1px solid var(--crm-border, #e2e5ea); border-radius: 7px;
  padding: 6px 10px; font-size: .8rem; margin-bottom: 6px; flex-shrink: 0;
}
.crm-avs-search:focus { outline: none; border-color: var(--crm-primary, #530383); }
.crm-avs-options { overflow-y: auto; }
.crm-avs-opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 7px; cursor: pointer; font-size: .82rem; color: #1f2937;
}
.crm-avs-opt:hover { background: #f5f3f9; }
.crm-avs-opt.is-selected { background: rgba(83, 3, 131, .08); font-weight: 600; }
.crm-avs-opt-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 10. DATATABLE FOOTER (length + info + pagination — all bottom-right) ── */
/* Spacer pushes the right group to the far right */
.crm-dt-spacer { flex: 1; }

.crm-dt-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--crm-border, #e8eaef);
  background: #fafafa;
  font-size: var(--crm-fs-xs);
}

/* ── Length menu (rows per page selector) ── */
.crm-dt-footer .dataTables_length label {
  display: flex; align-items: center; gap: 5px;
  color: #9ca3af; margin: 0; white-space: nowrap;
}
.crm-dt-footer .dataTables_length select {
  border: 1px solid var(--crm-border, #e8eaef);
  border-radius: var(--crm-r-sm);
  padding: 2px 6px;
  font-size: var(--crm-fs-xs);
  color: #555;
  background: #fff;
  height: 26px;
  cursor: pointer;
}

/* ── Info text ("1–25 of 120") ── */
.crm-dt-footer .dataTables_info {
  color: #9ca3af;
  font-size: var(--crm-fs-xs);
  margin: 0; padding: 0;
  white-space: nowrap;
}

/* ── Pagination ── */
.crm-dt-footer .dataTables_paginate { margin: 0; }
.crm-dt-footer .paginate_button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px;
  border-radius: var(--crm-r-sm);
  border: 1px solid transparent;
  font-size: var(--crm-fs-xs);
  cursor: pointer;
  transition: all var(--crm-tx);
  color: #555; background: transparent;
  margin: 0 1px; padding: 0 6px;
}
.crm-dt-footer .paginate_button:hover:not(.disabled):not(.current) {
  background: var(--crm-hover);
  color: var(--crm-primary);
}
.crm-dt-footer .paginate_button.current {
  background: var(--crm-primary, #530383);
  color: var(--crm-on-primary, #fff) !important;
  border-color: var(--crm-primary);
  font-weight: 700;
}
.crm-dt-footer .paginate_button.current:hover { background: var(--crm-primary-light, #7a12b8); }
.crm-dt-footer .paginate_button.disabled,
.crm-dt-footer .paginate_button.disabled:hover { color: #d1d5db !important; cursor: default; }

/* ── Suppress the default DataTables length control appearing above the table ── */
/* DataTables v1.x default renders .dataTables_length above the table when not in dom */
.dataTables_wrapper > .dataTables_length { display: none !important; }
.dataTables_wrapper > .dataTables_filter { display: none !important; }
.dataTables_wrapper > .dataTables_info   { display: none !important; }
/* Only show these when inside our .crm-dt-footer wrapper */
.crm-dt-footer .dataTables_length,
.crm-dt-footer .dataTables_info,
.crm-dt-footer .dataTables_paginate { display: block; }


/* ── 11. STATUS / TYPE BADGES ───────────────────────────────────────────── */
.crm-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: var(--crm-r-pill);
  font-size: var(--crm-fs-xs);
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  min-width: 68px;
  justify-content: center;
  border: 1px solid transparent;
  line-height: 1.5;
}
/* Dot prefix variant */
.crm-badge.has-dot::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
  background: currentColor;
}

/* Variants */
.crm-b-success  { background: var(--s-bg-success);  color: var(--s-success);  border-color: var(--s-br-success);  }
.crm-b-warning  { background: var(--s-bg-warning);  color: var(--s-warning);  border-color: var(--s-br-warning);  }
.crm-b-danger   { background: var(--s-bg-danger);   color: var(--s-danger);   border-color: var(--s-br-danger);   }
.crm-b-info     { background: var(--s-bg-info);     color: var(--s-info);     border-color: var(--s-br-info);     }
.crm-b-primary  { background: var(--s-bg-purple);   color: var(--s-purple);   border-color: var(--s-br-purple);   }
.crm-b-neutral  { background: var(--s-bg-neutral);  color: var(--s-neutral);  border-color: var(--s-br-neutral);  }
.crm-b-orange   { background: var(--s-bg-orange);   color: var(--s-orange);   border-color: var(--s-br-orange);   }
.crm-b-teal     { background: var(--s-bg-teal);     color: var(--s-teal);     border-color: var(--s-br-teal);     }


/* ── 12. EMPTY STATE ────────────────────────────────────────────────────── */
.crm-empty {
  text-align: center;
  padding: 60px 20px 48px;
}
.crm-empty-icon {
  font-size: 2.8rem;
  color: #d1d5db;
  display: block;
  margin-bottom: 14px;
}
.crm-empty-title {
  font-size: var(--crm-fs-md);
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 6px;
}
.crm-empty-sub {
  font-size: var(--crm-fs-sm);
  color: #9ca3af;
  margin-bottom: 20px;
}


/* ── 13. LOADING STATE ─────────────────────────────────────────────────── */
.crm-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 52px 20px;
  color: #9ca3af; font-size: var(--crm-fs-sm);
}


/* ── 14. STAT / KPI CARD ────────────────────────────────────────────────── */
.crm-stat {
  background: #fff;
  border: 1px solid var(--crm-border, #e8eaef);
  border-radius: var(--crm-r-lg);
  padding: 18px 20px;
  box-shadow: var(--crm-sh-xs);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow var(--crm-tx), transform var(--crm-tx);
}
.crm-stat:hover { box-shadow: var(--crm-sh-sm); transform: translateY(-2px); }
.crm-stat-icon {
  width: 44px; height: 44px; border-radius: var(--crm-r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.crm-stat-body { flex: 1; min-width: 0; }
.crm-stat-val   { font-size: 1.8rem; font-weight: 800; line-height: 1.1; color: #2d2d3a; }
.crm-stat-label { font-size: var(--crm-fs-xs); color: #888; margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.crm-stat-delta { font-size: var(--crm-fs-xs); margin-top: 7px; display: flex; align-items: center; gap: 3px; }
.crm-stat-delta.up   { color: var(--s-success); }
.crm-stat-delta.down { color: var(--s-danger);  }


/* ── 15. MODAL STANDARDS ────────────────────────────────────────────────── */
.crm-modal-hdr {
  background: linear-gradient(135deg, var(--crm-primary, #530383) 0%, var(--crm-primary-light, #7a12b8) 100%);
  color: var(--crm-on-primary, #fff);
  padding: 13px 20px;
  border-radius: calc(var(--crm-r-md) - 1px) calc(var(--crm-r-md) - 1px) 0 0;
}
.crm-modal-hdr .modal-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--crm-on-primary, #fff);
  display: flex; align-items: center; gap: 8px;
}
.crm-modal-hdr .btn-close { filter: invert(1); opacity: .75; }
.crm-modal-hdr .btn-close:hover { opacity: 1; }

.crm-modal-ftr {
  border-top: 1px solid var(--crm-border, #e8eaef);
  padding: 12px 20px;
  background: #fafafa;
  border-radius: 0 0 calc(var(--crm-r-md) - 1px) calc(var(--crm-r-md) - 1px);
}

/* ── Comfortable minimum width for pop-up forms (add category / status / etc.) ─
   Small quick-add modals used the Bootstrap default (~500px), .modal-sm (~300px)
   or an inline max-width:360px, which felt cramped ("very narrow to fill data").
   A CSS min-width floor grows every under-sized dialog to a comfortable width;
   because the used max-width is clamped UP to min-width, this also overrides
   inline max-width:###px WITHOUT any per-file change, and NEVER shrinks
   modal-lg / modal-xl / modal-fullscreen (their width already exceeds the floor).
   Phones keep their own full-width rule (crm-mobile.css, ≤768px). */
@media (min-width: 768px) {
  .modal-dialog:not(.modal-fullscreen):not(.modal-fullscreen-keep) {
    min-width: 600px;
  }
}
@media (min-width: 576px) and (max-width: 767.98px) {
  .modal-dialog:not(.modal-sm):not(.modal-fullscreen):not(.modal-fullscreen-keep) {
    min-width: 520px;
  }
}


/* ── 16. FORM SECTION ───────────────────────────────────────────────────── */
.crm-form-sep {
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px dashed var(--crm-border, #e8eaef);
}
.crm-form-sec-title {
  font-size: var(--crm-fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--crm-primary, #530383);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}


/* ── 17a. FILTER PANEL TOGGLE ───────────────────────────────────────────── */
/* Container that collapses/expands when funnel button is clicked.           */
/* JS sets max-height / opacity inline; this just supplies the transition.   */
.crm-fp-wrap {
  transition: max-height .26s ease, opacity .2s ease, margin-bottom .2s ease;
  overflow: hidden;
}
/* Pill style for standalone (non-.crm-filter-bar) filter controls */
.crm-fp-wrap select.form-select,
.crm-fp-wrap select.form-select-sm {
  border-radius: 20px !important;
  border: 1.5px solid var(--crm-border, #e8eaef);
  font-size: .79rem; font-weight: 500; color: #555;
  background: #f7f8fc; padding: 4px 28px 4px 12px;
  height: auto; cursor: pointer;
  transition: border-color .14s, box-shadow .14s;
}
.crm-fp-wrap select.form-select:focus,
.crm-fp-wrap select.form-select-sm:focus {
  border-color: var(--crm-primary, #530383);
  box-shadow: 0 0 0 3px rgba(83,3,131,.08);
}
.crm-fp-wrap input.form-control,
.crm-fp-wrap input.form-control-sm {
  border-radius: 20px !important;
  border: 1.5px solid var(--crm-border, #e8eaef);
  font-size: .79rem; background: #f7f8fc; padding: 4px 12px;
  height: auto;
  transition: border-color .14s, box-shadow .14s;
}
.crm-fp-wrap input.form-control:focus,
.crm-fp-wrap input.form-control-sm:focus {
  border-color: var(--crm-primary, #530383);
  box-shadow: 0 0 0 3px rgba(83,3,131,.08);
}


/* ── 17. RESPONSIVE ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .crm-toolbar { flex-direction: column; align-items: stretch; gap: 6px; }
  .crm-toolbar-left, .crm-toolbar-right { width: 100%; justify-content: flex-start; }
  .crm-toolbar-right { justify-content: flex-end; }
  .crm-search-input,
  .crm-search-input:focus { width: 100%; }
  .crm-stat-val { font-size: 1.4rem; }
}


/* ── 18. DARK MODE ──────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .crm-card,
[data-bs-theme="dark"] .crm-toolbar       { background: var(--crm-card-bg, #1e1e2d); border-color: #2d2d40; }
[data-bs-theme="dark"] .crm-card-header   { background: var(--crm-card-bg, #1e1e2d); border-color: #2d2d40; }
[data-bs-theme="dark"] table.crm-table tbody td { color: #d1d5db; border-color: #2a2a3a; }
[data-bs-theme="dark"] table.crm-table tbody tr:nth-child(even) { background: rgba(255,255,255,.03); }
[data-bs-theme="dark"] .crm-dt-footer     { background: #1a1a2e; border-color: #2d2d40; }
[data-bs-theme="dark"] .crm-btn-icon      { background: #2a2a3a; border-color: #3a3a4a; color: #c4c4d4; }
[data-bs-theme="dark"] .crm-btn-icon:hover { background: var(--crm-hover); }
[data-bs-theme="dark"] .crm-export-menu,
[data-bs-theme="dark"] .crm-col-panel     { background: #1e1e2d; border-color: #2d2d40; }
[data-bs-theme="dark"] .crm-export-menu .dropdown-item,
[data-bs-theme="dark"] .crm-col-panel .cp-item { color: #c4c4d4; }
[data-bs-theme="dark"] .crm-stat          { background: var(--crm-card-bg, #1e1e2d); border-color: #2d2d40; }
[data-bs-theme="dark"] .crm-badge.crm-b-neutral { background: #2a2a3a; color: #9ca3af; border-color: #3a3a4a; }


/* ── 19. PRINT ──────────────────────────────────────────────────────────── */
@media print {
  .crm-toolbar,
  .crm-bulk-bar,
  .crm-filter-bar,
  .sidebar,
  .topbar,
  .crm-dt-footer,
  .crm-ab-group,
  .crm-btn-icon,
  .modal-footer,
  #btn-add-template,
  .btn-export,
  .btn-print { display: none !important; }

  .crm-card { border: none !important; box-shadow: none !important; border-radius: 0 !important; }

  table.crm-table { font-size: 9pt; }
  table.crm-table thead th {
    background: #f3f4f6 !important;
    color: #333 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  table.crm-table tbody tr:nth-child(even) {
    background: #f9f9fb !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   FORM TYPOGRAPHY HIERARCHY
   Level 1 – Card/section headers : .95rem  700  #111827
   Level 2 – Field labels         : .84rem  600  #374151
   Level 3 – Input content        : .82rem  400  #1f2937
   ───────────────────────────────────────────────────────────────────────── */
.form-label,
label.col-form-label {
  font-size: .84rem !important;
  font-weight: 600 !important;
  color: #374151 !important;
  margin-bottom: .3rem;
}
.form-control,
.form-select,
textarea.form-control {
  font-size: .82rem !important;
  color: #1f2937 !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   RULE: NO PLACEHOLDER TEXT — globally hide all input/textarea placeholders
   Applied via CSS so all 300+ files are covered without touching each blade
   ───────────────────────────────────────────────────────────────────────── */
input::placeholder,
textarea::placeholder {
  opacity: 0 !important;
  color: transparent !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   PHONE INPUT — intlTelInput Geex style
   Carrier: intlTelInput.css already loaded, these override/extend it
   ───────────────────────────────────────────────────────────────────────── */
.iti { width: 100%; }
.iti__flag-container { z-index: 9999 !important; }

/* Selected flag + dial-code button */
.iti--separate-dial-code .iti__selected-flag {
  background: #f5f5f8 !important;
  border-right: 1px solid var(--crm-border, #e8eaef) !important;
  border-radius: 8px 0 0 8px !important;
  padding: 0 10px !important;
  min-width: 80px;
  cursor: pointer;
  transition: background .13s;
}
.iti--separate-dial-code .iti__selected-flag:hover {
  background: #eeeef6 !important;
}
.iti--separate-dial-code .iti__selected-dial-code {
  font-size: .83rem;
  font-weight: 600;
  color: #464255;
  margin-left: 6px;
}

/* Dropdown */
.iti__dropdown-content {
  border-radius: 12px !important;
  border: 1px solid var(--crm-border, #e8eaef) !important;
  box-shadow: 0 8px 28px rgba(0,0,0,.13) !important;
  overflow: hidden;
}
.iti__search-input {
  border-bottom: 1px solid var(--crm-border, #e8eaef) !important;
  padding: 8px 12px !important;
  font-size: .82rem !important;
}
.iti__country-name { font-size: .82rem; }
.iti__dial-code    { font-size: .78rem; color: #888; }
.iti__country.iti__highlight,
.iti__country:hover { background: var(--crm-primary-soft, #f3eeff) !important; }

/* Digit-limit hint displayed below the field */
.crm-phone-limit {
  font-size: .72rem;
  color: #aaa;
  margin-top: 2px;
  display: none;
}
.crm-phone-limit.visible { display: block; }

/* ═══════════════════════════════════════════════════════════════════════
   Password show / hide toggle (auto-applied globally)
   ══════════════════════════════════════════════════════════════════════ */
.crm-pwd-wrap {
    position: relative;
    display: block;
}
.crm-pwd-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    color: #aaa;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    z-index: 5;
    transition: color .15s;
}
.crm-pwd-toggle:hover,
.crm-pwd-toggle:focus-visible { color: var(--crm-primary, #530383); outline: none; }
/* Variant for Bootstrap input-group (appended as input-group-text) */
.crm-pwd-toggle-ig {
    background: #f8f8fc;
    border-color: #e0e0e8;
    color: #aaa;
    cursor: pointer;
    transition: color .15s;
}
.crm-pwd-toggle-ig:hover,
.crm-pwd-toggle-ig:focus-visible { color: var(--crm-primary, #530383); outline: none; }

/* ═══════════════════════════════════════════════════════════════════════
   FIELD REARRANGE + MANDATORY TOGGLE  (crm-field-layout.js)
   Shared across all add/edit modals that support drag-to-rearrange and
   mandatory-field marking. DO NOT duplicate these rules in blade files.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Drag handle (top-right, shown only in rearrange mode) ── */
.lf-drag-handle {
    position: absolute; top: 6px; right: 6px;
    width: 24px; height: 24px;
    background: rgba(83, 3, 131, .09); border: none;
    border-radius: 6px; padding: 0;
    display: none; align-items: center; justify-content: center;
    cursor: grab; z-index: 10;
    color: var(--crm-primary, #530383); font-size: .8rem;
    transition: background .12s;
}
.lf-drag-handle:hover  { background: rgba(83, 3, 131, .22); }
.lf-drag-handle:active { cursor: grabbing; }

/* ── Mandatory toggle (top-left, shown only in rearrange mode) ── */
.lf-req-toggle {
    position: absolute; top: 6px; left: 6px;
    width: 24px; height: 24px;
    background: rgba(83, 3, 131, .09); border: none;
    border-radius: 6px; padding: 0;
    display: none; align-items: center; justify-content: center;
    cursor: pointer; z-index: 10;
    color: var(--crm-primary, #530383); font-size: .78rem;
    transition: background .15s, color .15s;
}
.lf-req-toggle:hover { background: rgba(83, 3, 131, .22); }
.lf-field-required > .lf-req-toggle              { background: #dc3545; color: #fff; }
.lf-field-required > .lf-req-toggle:hover        { background: #b91c1c; }

/* ── Sortable field wrapper in rearrange mode ── */
.crm-sort-active > .lf-sortable-field {
    position: relative;
    border: 1.5px dashed rgba(83, 3, 131, .25);
    border-radius: 10px; padding: 10px !important;
    background: rgba(83, 3, 131, .025);
    transition: border-color .15s, background .15s;
}
.crm-sort-active > .lf-sortable-field:hover {
    border-color: var(--crm-primary, #530383);
    background: rgba(83, 3, 131, .06);
}

/* Show controls only in rearrange mode */
.crm-sort-active > .lf-sortable-field > .lf-drag-handle,
.crm-sort-active > .lf-sortable-field > .lf-req-toggle { display: flex; }

/* Required field highlight in rearrange mode */
.crm-sort-active > .lf-field-required {
    border-color: #dc3545 !important;
    background: rgba(220, 53, 69, .04) !important;
}

/* ── Sortable ghost (placeholder during drag) ── */
.lf-ghost {
    opacity: .35;
    background: rgba(83, 3, 131, .08) !important;
    border: 2px dashed var(--crm-primary, #530383) !important;
}

/* ── Chosen item (being dragged) ── */
.lf-chosen {
    box-shadow: 0 8px 28px rgba(83, 3, 131, .22), 0 2px 8px rgba(0, 0, 0, .1) !important;
    border-color: var(--crm-primary, #530383) !important;
    transform: rotate(1.5deg) scale(1.03);
    z-index: 50;
}

/* ── Rearrange button — active state ── */
.lf-active,
.crm-reorder-btn.lf-active {
    background:    var(--crm-primary, #530383) !important;
    color:         var(--crm-on-primary, #fff) !important;
    border-color:  var(--crm-primary, #530383) !important;
    border-style:  solid !important;
}

/* ── Required star on label (always visible when field is required) ── */
.lf-req-star { font-weight: 700; }

/* ═══════════════════════════════════════════════════════════════════════
   FIELD REARRANGE v4 — flatten grid, hide + show-in-table toggles
   ═══════════════════════════════════════════════════════════════════════ */

/* Fields disabled from the form (persisted hide) — gone from the live form,
   but shown (dimmed) inside the flatten tray so they can be re-enabled. */
.lf-field-hidden { display: none !important; }
.lf-flatten .lf-field-hidden { display: block !important; opacity: .55; }

/* Flatten container replaces the tabbed view during rearrange. */
.lf-flatten { animation: crmLayoutBannerIn .2s ease; }
.lf-flat-section { margin-bottom: 14px; }
.lf-flat-head {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--crm-primary, #530383);
    padding: 6px 10px; margin-bottom: 8px;
    background: rgba(83, 3, 131, .06); border-radius: 8px;
    border-left: 3px solid var(--crm-primary, #530383);
}
.lf-flat-head--muted {
    color: #6b7280; background: #f3f4f6; border-left-color: #9ca3af;
}
.lf-flat-grid {
    min-height: 48px; border: 1.5px dashed transparent;
    border-radius: 10px; padding: 4px; transition: border-color .15s, background .15s;
}
.lf-flat-tray-grid {
    border-color: rgba(156, 163, 175, .5); background: rgba(243, 244, 246, .5);
}
.lf-flat-grid:empty::after,
.lf-flat-tray-grid:empty::after {
    content: 'Drag fields here'; display: block; width: 100%;
    text-align: center; color: #9ca3af; font-size: .78rem; padding: 12px 0;
}

/* Field cards inside the flatten grid (mirror the old crm-sort-active look). */
.lf-flatten .lf-sortable-field {
    position: relative;
    border: 1.5px dashed rgba(83, 3, 131, .25);
    border-radius: 10px; padding: 12px 10px !important;
    background: rgba(83, 3, 131, .025);
    transition: border-color .15s, background .15s;
}
.lf-flatten .lf-sortable-field:hover {
    border-color: var(--crm-primary, #530383);
    background: rgba(83, 3, 131, .06);
}
.lf-flatten .lf-field-required {
    border-color: #dc3545 !important; background: rgba(220, 53, 69, .04) !important;
}

/* Show the control buttons only inside the flatten view. */
.lf-flatten .lf-sortable-field > .lf-drag-handle,
.lf-flatten .lf-sortable-field > .lf-req-toggle,
.lf-flatten .lf-sortable-field > .lf-hide-toggle,
.lf-flatten .lf-sortable-field > .lf-table-toggle { display: flex; }

/* Right-side control cluster: table (▦), hide (👁), grip (⠿). */
.lf-hide-toggle, .lf-table-toggle {
    position: absolute; top: 6px;
    width: 24px; height: 24px;
    background: rgba(83, 3, 131, .09); border: none;
    border-radius: 6px; padding: 0;
    display: none; align-items: center; justify-content: center;
    cursor: pointer; z-index: 10;
    color: var(--crm-primary, #530383); font-size: .78rem;
    transition: background .15s, color .15s;
}
.lf-drag-handle  { right: 6px; }
.lf-hide-toggle  { right: 34px; }
.lf-table-toggle { right: 62px; }
.lf-hide-toggle:hover, .lf-table-toggle:hover { background: rgba(83, 3, 131, .22); }

/* Field currently hidden → eye toggle highlighted amber. */
.lf-field-hidden > .lf-hide-toggle { background: #f59e0b; color: #fff; }

/* Field marked show-in-table → table toggle highlighted green + card badge. */
.lf-in-table > .lf-table-toggle { background: #16a34a; color: #fff; }
.lf-table-toggle.lf-disabled {
    opacity: .35; cursor: not-allowed; background: rgba(0, 0, 0, .05);
    color: #9ca3af;
}
.lf-flatten .lf-in-table::before {
    content: 'In table'; position: absolute; bottom: 6px; right: 8px;
    font-size: .6rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .03em; color: #16a34a;
}

/* ── Banner slide-in animation ── */
@keyframes crmLayoutBannerIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}
[id$="reorder-banner"]:not([style*="display: none"]),
[id$="ReorderBanner"]:not([style*="display: none"]) {
    animation: crmLayoutBannerIn .22s ease;
}

/* ═══════════════════════════════════════════════════════════════════════
   LIST / DASHBOARD VIEW TOGGLE — universal for all table card headers
   ══════════════════════════════════════════════════════════════════════ */
.crm-view-btn { transition: all var(--crm-tx); }
.crm-view-btn.active {
  background: var(--crm-primary, #530383);
  color: var(--crm-on-primary, #fff) !important;
  border-color: var(--crm-primary, #530383);
}
.crm-view-btn.active:hover {
  background: var(--crm-primary-dark, #3d0260);
  border-color: var(--crm-primary-dark, #3d0260);
}

/* ═══════════════════════════════════════════════════════════════════════
   DASHBOARD PANEL — inline analytics panel inside .crm-card
   ══════════════════════════════════════════════════════════════════════ */
.crm-dash-panel {
  padding: 20px 20px 24px;
  border-bottom: 1px solid var(--crm-border, #e8eaef);
  background: #f9fafb;
}

/* Date range row at top of dashboard panel */
.crm-dash-date-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.crm-dash-date-bar .crm-filter-date-label {
  font-size: .74rem;
  color: #6b7280;
  font-weight: 600;
}

/* Stat summary cards */
.crm-dash-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.crm-dash-stat {
  flex: 1 1 120px;
  background: #fff;
  border: 1px solid var(--crm-border, #e8eaef);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 110px;
  position: relative;
  overflow: hidden;
}
.crm-dash-stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--crm-primary, #530383);
  opacity: .6;
}
.crm-dash-stat.accent-green::before  { background: #15803d; }
.crm-dash-stat.accent-red::before    { background: #b91c1c; }
.crm-dash-stat.accent-orange::before { background: #b45309; }
.crm-dash-stat-val {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--crm-primary, #530383);
  line-height: 1;
}
.crm-dash-stat.accent-green .crm-dash-stat-val  { color: #15803d; }
.crm-dash-stat.accent-red .crm-dash-stat-val    { color: #b91c1c; }
.crm-dash-stat.accent-orange .crm-dash-stat-val { color: #b45309; }
.crm-dash-stat-label {
  font-size: .7rem;
  color: #9ca3af;
  font-weight: 500;
  margin-top: 4px;
  white-space: nowrap;
}

/* Chart grid */
.crm-dash-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.crm-dash-chart-box {
  background: #fff;
  border: 1px solid var(--crm-border, #e8eaef);
  border-radius: 12px;
  padding: 16px;
}
.crm-dash-chart-title {
  font-size: .76rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-dash-chart-title i { color: var(--crm-primary, #530383); font-size: .85rem; }
.crm-dash-chart-canvas-wrap {
  position: relative;
  height: 200px;
}
.crm-dash-chart-canvas-wrap.tall { height: 240px; }

/* Loading spinner inside dashboard */
.crm-dash-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #9ca3af;
  gap: 8px;
  font-size: .8rem;
}

/* ── CALENDAR & FULLCALENDAR STANDARDIZED STYLING ───────────────────────── */
/* Applied globally to all FullCalendar instances for consistency */

/* FullCalendar button group — add gaps between month/week/list buttons */
.fc .fc-button-group {
  gap: 6px !important;
  display: inline-flex !important;
}

/* Ensure button group buttons have proper spacing */
.fc .fc-button-group > .fc-button {
  border-radius: 6px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Remove negative margins from individual buttons since gap handles spacing */
.fc-direction-ltr .fc-button-group > .fc-button:not(:first-child) {
  margin-left: 0 !important;
  border-top-left-radius: 6px !important;
  border-bottom-left-radius: 6px !important;
}

.fc-direction-ltr .fc-button-group > .fc-button:not(:last-child) {
  border-top-right-radius: 6px !important;
  border-bottom-right-radius: 6px !important;
}

/* FullCalendar toolbar styling — consistent with CRM design */
.fc .fc-toolbar {
  padding: 12px 0;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.fc .fc-toolbar-title {
  font-size: 1.2em;
  font-weight: 600;
  color: #374151;
}

/* FullCalendar buttons — match CRM primary color scheme */
.fc .fc-button-primary {
  background-color: #fff !important;
  border-color: #ddd !important;
  color: #666 !important;
  border-radius: 6px !important;
  padding: 6px 12px !important;
  font-size: .86rem !important;
  transition: all 0.14s ease !important;
}

.fc .fc-button-primary:hover:not(:disabled) {
  background-color: #f9fafb !important;
  border-color: var(--crm-primary, #530383) !important;
  color: var(--crm-primary, #530383) !important;
}

.fc .fc-button-primary.fc-button-active,
.fc .fc-button-primary:not(:disabled).fc-button-active {
  background-color: var(--crm-primary, #530383) !important;
  border-color: var(--crm-primary, #530383) !important;
  color: var(--crm-on-primary, #fff) !important;
}

/* Generic view-toggle class for non-FullCalendar implementations */
.view-toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.view-toggle .btn {
  border-radius: 6px;
  padding: 5px 10px;
  color: #666;
  border-color: var(--crm-border, #e8eaef);
  background: #fff;
  font-size: .85rem;
  transition: all 0.14s ease;
}

.view-toggle .btn:hover {
  border-color: var(--crm-primary, #530383);
  color: var(--crm-primary, #530383);
}

.view-toggle .btn.active {
  background: var(--crm-primary, #530383);
  color: var(--crm-on-primary, #fff);
  border-color: var(--crm-primary, #530383);
}
}

/* Package line-item editor — proposal "no-tax" mode hides VAT columns/rows (quote = gov + service only) */
.pli-no-tax .pli-col-disc,
.pli-no-tax .pli-col-vat,
.pli-no-tax .pli-col-vatamt,
.pli-no-tax .pli-tax-row { display: none !important; }

/* ── Native date / time inputs — one consistent Geex look across the whole CRM ──
   Browsers render <input type="date|time|datetime-local|month"> with their own
   chrome; left raw they clash with the styled controls everywhere else (the
   "weird" Accounts HUB filter bars). Normalise the field + brand the picker icon
   so every date control matches the rest of the UI. */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 38px;
  border: 1px solid var(--crm-border, #e8eaef);
  border-radius: 8px;
  background-color: #fff;
  color: #1f2430;
  font-size: .85rem;
  line-height: 1.2;
  padding: .4rem .65rem;
}
input[type="date"].form-control-sm,
input[type="datetime-local"].form-control-sm,
input[type="time"].form-control-sm,
input[type="month"].form-control-sm {
  min-height: 32px;
  font-size: .8rem;
  padding: .25rem .55rem;
  /* Compact date controls (filter bars) size to their content instead of stretching
     the row — fixes the over-wide, wrapping inputs on the Accounts HUB filters. */
  width: auto;
  max-width: 190px;
}
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
input[type="month"]:focus {
  border-color: var(--crm-primary, #530383);
  box-shadow: 0 0 0 .15rem var(--crm-primary-soft, rgba(83,3,131,.14));
  outline: none;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .55;
  padding: 2px;
  border-radius: 4px;
  transition: opacity .15s ease, background .15s ease;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  background: var(--crm-hover, rgba(83,3,131,.06));
}

/* Selects in compact filter bars pick up the brand focus ring too (Bootstrap
   defaults to blue), so date inputs and dropdowns read as one set. */
.form-select:focus,
.form-select-sm:focus {
  border-color: var(--crm-primary, #530383);
  box-shadow: 0 0 0 .15rem var(--crm-primary-soft, rgba(83,3,131,.14));
}

/* ── VISIBLE, GRABBABLE SCROLLBARS ────────────────────────────────────────
   WHY: tall side panels hid their vertical scrollbar (scrollbar-width:none +
   ::-webkit-scrollbar{width:0}) or fell back to the OS default, which on a dark
   sidebar is effectively invisible. A long menu then gave no cue that it scrolls
   and nothing to drag with a mouse. These two utilities put a visible, rounded,
   grabbable bar back on the surfaces that scroll VERTICALLY:

     .crm-scroll-dark   white thumb  — dark surfaces (the sidebar)
     .crm-scroll-light  grey thumb on a white track — light panels

   Apply the class instead of restyling each panel, so every scroll surface stays
   one consistent control (E4) — do NOT copy these rules into a page's <style>.

   Deliberately NOT applied to horizontal tab strips (.chp-tabs, .crm-subtab-row,
   .crm-primary-tabs …) which hide their bar by design — a bar under a tab row
   reads as broken.

   Scoped to >=769px to stay clear of crm-mobile.css §2.22 (touch devices swipe;
   its `*::-webkit-scrollbar` hide rule would LOSE to these class selectors on
   specificity, so the media query — not source order — is what keeps mobile clean). */
@media (min-width: 769px) {
  .crm-scroll-dark,
  .crm-scroll-light { scrollbar-width: thin; }
  .crm-scroll-dark  { scrollbar-color: rgba(255,255,255,.45) transparent; }
  .crm-scroll-light { scrollbar-color: #c3c8d4 #fff; }

  .crm-scroll-dark::-webkit-scrollbar,
  .crm-scroll-light::-webkit-scrollbar { width: 11px; height: 11px; }

  .crm-scroll-dark::-webkit-scrollbar-track  { background: transparent; }
  .crm-scroll-light::-webkit-scrollbar-track { background: #fff; }

  /* Transparent border + background-clip keeps a slim thumb inside a wide,
     easy-to-hit lane — the whole 11px is grabbable, the thumb just looks light. */
  .crm-scroll-dark::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.45);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: 8px;
  }
  .crm-scroll-dark::-webkit-scrollbar-thumb:hover,
  .crm-scroll-dark::-webkit-scrollbar-thumb:active {
    background: rgba(255,255,255,.8);
    background-clip: content-box;
  }

  .crm-scroll-light::-webkit-scrollbar-thumb {
    background: #c3c8d4;
    border: 3px solid #fff;
    background-clip: content-box;
    border-radius: 8px;
  }
  .crm-scroll-light::-webkit-scrollbar-thumb:hover,
  .crm-scroll-light::-webkit-scrollbar-thumb:active {
    background: #98a0b3;
    background-clip: content-box;
  }
}

/* ── Dashboard drill-down note (CrmDrill / public/js/crm-dash-drill.js) ──────
   Rendered into #drill-note on any list a dashboard tile can open. A narrowed
   list that does not SAY it is narrowed reads as a list that lost rows — this
   bar and its Clear link are what stop that. */
.crm-drill-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    row-gap: 6px;
    min-height: 34px;
    margin: 0 0 10px;
    padding: 7px 12px;
    border: 1px solid rgba(83, 3, 131, .18);
    border-left: 3px solid var(--crm-primary, #530383);
    border-radius: 8px;
    background: rgba(83, 3, 131, .045);
    font-size: .78rem;
    color: #4b5262;
}
.crm-drill-note .crm-drill-lead { font-weight: 600; color: var(--crm-primary, #530383); }
.crm-drill-chip {
    display: inline-block;
    max-width: 100%;
    min-width: 0;
    padding: 2px 9px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(83, 3, 131, .22);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-drill-clear {
    margin-left: auto;
    font-weight: 600;
    color: var(--crm-primary, #530383);
    text-decoration: none;
    white-space: nowrap;
}
.crm-drill-clear:hover { text-decoration: underline; }

/* ── a record's own name, inside a table cell ────────────────────────────────
   Bootstrap underlines every <a>, so the Leads list drew a blue underline under
   all ten company names on every page — the row already reads as clickable
   (cursor, hover, a whole column of them), so the rule only adds noise to the
   one column people scan most. Reported 18/08/2026.

   Declared here rather than in one blade because the cell is built in PHP by
   LeadService and shared by every table that renders it; a rule living in one
   page's <style> would be right on that page and wrong on the next.

   The underline comes BACK on hover: losing it entirely would take away the only
   remaining affordance for someone who navigates by keyboard. */
.crm-cell-link {
    text-decoration: none;
    color: var(--crm-primary, #530383);
    font-weight: 500;
}
.crm-cell-link:hover,
.crm-cell-link:focus-visible { text-decoration: underline; }

/* The GOLDEN STAR beside a lead's number — the one the customer answers on
   (App\Support\Leads\LeadPhoneBook::star, 03/10/2026). Drawn as a ★ / ☆
   character, not an icon-font glyph: only the light Phosphor weight ships, and
   text survives exports and the list search. Shared because the Leads list,
   the Tele Call queue and the lead page all draw it. */
.crm-num-star {
    color: #f5b301;
    font-size: 1rem;
    line-height: 1;
}
button.crm-num-star {
    background: none;
    border: 0;
    padding: 0 2px;
    cursor: pointer;
}
button.crm-num-star:not(.is-starred) { color: #b8bcc8; }
button.crm-num-star:not(.is-starred):hover,
button.crm-num-star:not(.is-starred):focus-visible { color: #f5b301; }

/* An option/row for somebody who is no longer someone work can be given to —
   a leaver, a deactivated login, an administrator the company excluded. It is
   rendered `hidden` by the server and revealed by CRM.syncIneligible ONLY when
   the record already holds it, so this style is what "this assignment is to
   someone who is no longer on the team" looks like. Greyed and italic, never
   removed: removing it is how a real assignment gets silently cleared on the
   next unrelated save. */
.crm-opt-ineligible { color: #9aa0a6; font-style: italic; }

/* ── a <form> inside a scrollable modal ──────────────────────────────────────
   Bootstrap's .modal-dialog-scrollable expects .modal-header / .modal-body /
   .modal-footer to be DIRECT flex children of .modal-content: the content gets
   max-height + overflow:hidden, the body gets overflow-y:auto, and the footer
   stays pinned. Nearly every compose modal here wraps body + footer in a <form>
   (it has to — the submit button lives in the footer), and that one extra
   element breaks the chain: the form is a flex item with min-height:auto, so it
   grows past the clipped .modal-content and the FOOTER IS CUT OFF — reported
   19/08/2026 as "the Send button is hiding" on Send Final Confirmation the
   moment the WhatsApp section expanded. ~80 modals pair the class with a form,
   so the fix lives HERE, at the one layer they all share, not per blade.

   The form becomes its own flex column that may not exceed its parent; the
   body inside it scrolls exactly as Bootstrap intended. Harmless where the
   content is short — flex:column with min-height:0 changes nothing visible. */
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}
.modal-dialog-scrollable .modal-content > form > .modal-body {
    overflow-y: auto;
}
