/*
 * Leadsensy theme on top of Bootstrap 5.3 (loaded from the CDN in App.razor, no build step).
 * Replaced Tailwind on 2026-09-29 because the dev machine has no Node.js to rebuild Tailwind.
 * Conventions for markup: docs/engineering/ui-styling.md.
 *
 *   1. Bootstrap variable overrides (brand, font, colors, radius)
 *   2. Base + fonts
 *   3. Small utilities Bootstrap lacks (fs-10..fs-15, text/bg palette, sizes, shadows)
 *   4. crm-* components (page, card, table, badge, modal, dropdown, forms, nav)
 *   5. App shell (sidebar, top bar)
 *   6. Carried over from the Tailwind input.css: scrollbars, toasts, DataTables skin
 */

/* ---------- 1. Bootstrap overrides ---------- */
:root {
  /* Leadsensy palette (Figma "Leadsensy", 23 Oct 2026): sky #1AC1FE, blue #0385E6, purple #7C37CC, teal #1ABFA6,
     navy #001B40, grey #E3E8EC. Blue is the brand; teal means success / live; purple marks AI; navy is the ink. */
  --ls-sky: #1ac1fe;
  --ls-blue: #0385e6;
  --ls-purple: #7c37cc;
  --ls-teal: #1abfa6;
  --ls-navy: #001b40;
  --ls-grey: #e3e8ec;
  --crm-brand: #0385e6;
  --crm-brand-dark: #026bba;
  --crm-brand-soft: #e6f3fd;
  --crm-ink: #001b40;
  --crm-text: #374151;
  --crm-muted: #6b7280;
  --crm-subtle: #9ca3af;
  --crm-border: #e3e8ec;
  --crm-border-soft: #f1f5f9;
  --crm-surface: #f8fafc;
  --crm-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04);
  --crm-shadow-lift: 0 10px 28px -10px rgba(15, 23, 42, 0.2), 0 4px 10px -4px rgba(15, 23, 42, 0.08);
  --crm-shadow-toast: 0 16px 40px rgba(15, 23, 42, 0.12);
  --crm-shadow-auth: 0 12px 32px rgba(15, 23, 42, 0.06);
  --crm-sidebar-width: 240px;

  --bs-primary: #0385e6;
  --bs-primary-rgb: 3, 133, 230;
  /* Success text / buttons use a darker shade of the palette teal so it reads on white; fills use --ls-teal. */
  --bs-success: #08806d;
  --bs-success-rgb: 8, 128, 109;
  --bs-success-bg-subtle: #e6f8f5;
  --bs-success-border-subtle: #a6e8dd;
  --bs-success-text-emphasis: #08806d;
  --bs-primary-bg-subtle: #e6f3fd;
  --bs-primary-border-subtle: #b3dcfa;
  --bs-primary-text-emphasis: #026bba;
  --bs-link-color: #026bba;
  --bs-link-color-rgb: 2, 107, 186;
  --bs-link-hover-color: #01589a;
  --bs-body-font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-font-size: 0.875rem;
  --bs-body-color: #001b40;
  --bs-body-bg: #f8fafc;
  --bs-secondary-color: #6b7280;
  --bs-tertiary-color: #9ca3af;
  --bs-border-color: #e3e8ec;
  --bs-border-radius: 0.5rem;
  --bs-border-radius-sm: 0.375rem;
  --bs-border-radius-lg: 0.75rem;
  --bs-focus-ring-color: rgba(3, 133, 230, 0.2);
}

.btn-primary {
  --bs-btn-bg: #0385e6;
  --bs-btn-border-color: #0385e6;
  --bs-btn-hover-bg: #026bba;
  --bs-btn-hover-border-color: #026bba;
  --bs-btn-active-bg: #01589a;
  --bs-btn-active-border-color: #01589a;
  --bs-btn-disabled-bg: #cbd5e1;
  --bs-btn-disabled-border-color: #cbd5e1;
  --bs-btn-focus-shadow-rgb: 3, 133, 230;
}

.btn-outline-secondary {
  --bs-btn-color: #4b5563;
  --bs-btn-border-color: #e2e8f0;
  --bs-btn-bg: #fff;
  --bs-btn-hover-color: #111827;
  --bs-btn-hover-bg: #f8fafc;
  --bs-btn-hover-border-color: #cbd5e1;
  --bs-btn-active-color: #111827;
  --bs-btn-active-bg: #f1f5f9;
  --bs-btn-active-border-color: #cbd5e1;
}

.btn-outline-danger {
  --bs-btn-color: #dc2626;
  --bs-btn-border-color: #fca5a5;
  --bs-btn-bg: #fff;
  --bs-btn-hover-bg: #fef2f2;
  --bs-btn-hover-color: #b91c1c;
  --bs-btn-hover-border-color: #f87171;
}

.btn {
  --bs-btn-font-weight: 600;
  --bs-btn-font-size: 0.875rem;
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-padding-x: 1rem;
  --bs-btn-border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-sm {
  --bs-btn-font-size: 0.75rem;
  --bs-btn-padding-y: 0.25rem;
  --bs-btn-padding-x: 0.625rem;
  --bs-btn-border-radius: 0.375rem;
}

.form-control,
.form-select {
  border-color: var(--crm-border);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--crm-ink);
  padding: 0.5rem 0.75rem;
}

.form-control::placeholder { color: var(--crm-subtle); }

.form-control:focus,
.form-select:focus {
  border-color: var(--crm-brand);
  box-shadow: 0 0 0 3px rgba(3, 133, 230, 0.12);
}

.form-control-sm,
.form-select-sm { font-size: 0.75rem; padding: 0.25rem 0.5rem; }

/* Every dropdown (form-select, a select styled as form-control, one inside an input group): the same thin chevron,
   with room on the right so the text never runs under it (28 Oct 2026). */
select:not([multiple]):not([size]) {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='m4 6 4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 0.9rem 0.9rem;
  padding-right: 2.1rem;
  cursor: pointer;
  text-overflow: ellipsis;
}
select.form-select-sm:not([multiple]):not([size]), select.form-control-sm:not([multiple]):not([size]) { background-position: right 0.5rem center; background-size: 0.75rem 0.75rem; padding-right: 1.6rem; }
select:not([multiple]):not([size]):disabled { cursor: default; opacity: 0.75; }

.form-check-input:checked { background-color: var(--crm-brand); border-color: var(--crm-brand); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(3, 133, 230, 0.15); border-color: var(--crm-brand); }

.progress { --bs-progress-bar-bg: var(--crm-brand); --bs-progress-height: 0.5rem; background: var(--crm-border-soft); }

/* ---------- 2. Base ---------- */
@font-face { font-family: "Inter"; src: url("/fonts/inter-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter-500.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter-600.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter-700.ttf") format("truetype"); font-weight: 700; font-display: swap; }

html, body { min-height: 100%; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
h1:focus { outline: none; } /* Blazor FocusOnNavigate focuses the page h1 */
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn:hover, .nav-link:hover, .crm-nav-link:hover, .crm-menu-item:hover { text-decoration: none; }
table { caption-side: bottom; }

/* ---------- 3. Utilities ---------- */
.fs-10 { font-size: 0.625rem !important; }
.fs-11 { font-size: 0.6875rem !important; }
.fs-12 { font-size: 0.75rem !important; }
.fs-13 { font-size: 0.8125rem !important; }
.fs-14 { font-size: 0.875rem !important; }
.fs-15 { font-size: 0.9375rem !important; }
.fs-16 { font-size: 1rem !important; }
.fs-18 { font-size: 1.125rem !important; }
.fs-20 { font-size: 1.25rem !important; }
.fs-24 { font-size: 1.5rem !important; }
.fs-30 { font-size: 1.875rem !important; }

.text-brand { color: var(--crm-brand) !important; }
.text-brand-dark { color: var(--crm-brand-dark) !important; }
.text-ink { color: var(--crm-ink) !important; }
.text-body-2 { color: var(--crm-text) !important; }
.text-slate { color: #4b5563 !important; }
.text-muted-2 { color: var(--crm-muted) !important; }
.text-subtle { color: var(--crm-subtle) !important; }
.text-success-2 { color: #08806d !important; }
.text-warning-2 { color: #92400e !important; }
.text-danger-2 { color: #dc2626 !important; }
.text-info-2 { color: #026bba !important; }
.text-violet { color: #7c37cc !important; }

.bg-brand { background-color: var(--crm-brand) !important; color: #fff; }
.bg-brand-soft { background-color: var(--crm-brand-soft) !important; }
.bg-surface { background-color: var(--crm-surface) !important; }
.bg-success-soft { background-color: #e6f8f5 !important; }
.bg-warning-soft { background-color: #fffbeb !important; }
.bg-danger-soft { background-color: #fef2f2 !important; }
.bg-info-soft { background-color: #e6f3fd !important; }
.bg-violet-soft { background-color: #f3ecfb !important; }
.bg-slate-soft { background-color: #f3f4f6 !important; }

.border-soft { border-color: var(--crm-border-soft) !important; }
.border-crm { border-color: var(--crm-border) !important; }

.shadow-card { box-shadow: var(--crm-shadow-card) !important; }
.shadow-lift { box-shadow: var(--crm-shadow-lift) !important; }
.shadow-toast { box-shadow: var(--crm-shadow-toast) !important; }
.shadow-auth { box-shadow: var(--crm-shadow-auth) !important; }

.min-w-0 { min-width: 0 !important; }
.flex-1 { flex: 1 1 0% !important; min-width: 0; }
.tabular-nums { font-variant-numeric: tabular-nums; }
.cursor-pointer { cursor: pointer; }
.lh-tight { line-height: 1.25 !important; }
.tracking-wide { letter-spacing: 0.03em; }
.uppercase-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--crm-muted); }

.icon-24, .icon-28, .icon-32, .icon-36, .icon-40 { display: inline-grid; place-items: center; flex-shrink: 0; }
.icon-24 { width: 1.5rem; height: 1.5rem; }
.icon-28 { width: 1.75rem; height: 1.75rem; }
.icon-32 { width: 2rem; height: 2rem; }
.icon-36 { width: 2.25rem; height: 2.25rem; }
.icon-40 { width: 2.5rem; height: 2.5rem; }

.avatar { display: inline-grid; place-items: center; flex-shrink: 0; border-radius: 999px; background: var(--crm-brand); color: #fff; font-weight: 600; }

.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 999px; flex-shrink: 0; }

.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.hide-scrollbar::-webkit-scrollbar { display: none; }

/* ---------- 4. Components ---------- */

/* Page scaffold: <main class="crm-page"> ... */
.crm-page { padding: 1.25rem 1rem 2.5rem; }
@media (min-width: 576px) { .crm-page { padding: 1.75rem 2rem 2.5rem; } }

.crm-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; margin: 0; font-size: 0.8125rem; font-weight: 500; color: var(--crm-muted); }
.crm-breadcrumb .sep { color: var(--crm-subtle); }
.crm-breadcrumb .current { color: var(--crm-ink); }

.crm-page-header { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.25rem; }
@media (min-width: 576px) { .crm-page-header { flex-direction: row; align-items: center; justify-content: space-between; } }
.crm-page-title { margin: 0.25rem 0 0; font-size: 1.5rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; color: var(--crm-ink); }
.crm-page-subtitle { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--crm-muted); }

/* Cards / panels */
.crm-card { background: #fff; border: 1px solid var(--crm-border); border-radius: 1rem; box-shadow: var(--crm-shadow-lift); }
.crm-card-flat { background: #fff; border: 1px solid var(--crm-border); border-radius: 0.75rem; }
.crm-card-body { padding: 1.25rem; }
.crm-card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 1rem; border-bottom: 1px solid var(--crm-border); }
.crm-section-title { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; color: var(--crm-ink); }
.crm-list-row { padding: 0.875rem 1rem; border-bottom: 1px solid var(--crm-border-soft); }
.crm-list-row:last-child { border-bottom: 0; }

/* States */
.crm-empty { padding: 4rem 1.25rem; text-align: center; font-size: 0.875rem; color: var(--crm-muted); }
.crm-loading { margin-top: 2rem; font-size: 0.875rem; color: var(--crm-muted); }
.crm-error { display: flex; align-items: center; gap: 0.75rem; margin-top: 2rem; }
.crm-error p { margin: 0; font-size: 0.875rem; color: #dc2626; }

/* Tables: wrap in <TableScroll>, give the <table> class="crm-table" */
.crm-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: 0.875rem; }
.crm-table thead th { white-space: nowrap; padding: 0.75rem 1rem; background: var(--crm-surface); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--crm-muted); }
.crm-table tbody td { padding: 0.875rem 1rem; border-top: 1px solid var(--crm-border); background: #fff; vertical-align: middle; color: #4b5563; }
.crm-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.crm-table .strong { font-weight: 600; color: var(--crm-ink); }

/* Badges / pills */
.crm-badge { display: inline-flex; align-items: center; gap: 0.25rem; border-radius: 999px; padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 500; line-height: 1.4; white-space: nowrap; background: #f3f4f6; color: #374151; }
.crm-badge-success { background: #e6f8f5; color: #08806d; }
.crm-badge-warning { background: #fffbeb; color: #92400e; }
.crm-badge-danger { background: #fef2f2; color: #b91c1c; }
.crm-badge-info { background: #eff6ff; color: #1d4ed8; }
.crm-badge-violet { background: #f5f3ff; color: #6d28d9; }
.crm-badge-neutral { background: #f3f4f6; color: #6b7280; }
.crm-badge-brand { background: var(--crm-brand-soft); color: var(--crm-brand-dark); }
.crm-badge-solid { background: var(--crm-brand); color: #fff; font-weight: 700; }

.crm-pill { display: inline-flex; align-items: center; border: 1px solid var(--crm-border); background: #fff; color: #4b5563; border-radius: 999px; padding: 0.375rem 0.875rem; font-size: 0.875rem; font-weight: 600; cursor: pointer; }
.crm-pill.active, .crm-pill[aria-selected="true"] { background: var(--crm-ink); border-color: var(--crm-ink); color: #fff; }

/* Tabs (underline style, e.g. lead detail) */
.crm-tabs { display: flex; gap: 1.25rem; overflow-x: auto; border-bottom: 1px solid var(--crm-border); }
.crm-tab { position: relative; padding: 0.75rem 0; border: 0; background: none; font-size: 0.875rem; font-weight: 500; color: var(--crm-muted); white-space: nowrap; cursor: pointer; }
.crm-tab.active { color: var(--crm-brand-dark); font-weight: 600; }
.crm-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--crm-brand); }

/* Forms */
.crm-label { display: block; margin-bottom: 0.375rem; font-size: 0.8125rem; font-weight: 600; color: var(--crm-ink); }
.crm-hint { margin-top: 0.25rem; font-size: 0.75rem; color: var(--crm-muted); }
.crm-field-error { margin-top: 0.25rem; font-size: 0.75rem; color: #dc2626; }
.crm-form { display: flex; flex-direction: column; gap: 1rem; }
.crm-form-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 576px) { .crm-form-grid { grid-template-columns: 1fr 1fr; } }

/* Auth-style input group (FormField): border wraps the input and any trailing button */
.crm-input-group { display: flex; align-items: center; height: 42px; overflow: hidden; background: #fff; border: 1px solid var(--crm-border); border-radius: 0.5rem; transition: border-color .15s, box-shadow .15s; }
.crm-input-group:focus-within { border-color: var(--crm-brand); box-shadow: 0 0 0 3px rgba(3, 133, 230, 0.1); }
.crm-input-group.is-invalid { border-color: #ef4444; }
.crm-input-group input, .crm-input-group select { flex: 1 1 auto; min-width: 0; height: 100%; border: 0; background: transparent; padding: 0 0.75rem; font-size: 0.8125rem; color: var(--crm-ink); outline: none; }
.crm-input-group input::placeholder { color: var(--crm-subtle); }
.crm-input-group .crm-input-action { margin-right: 0.75rem; border: 0; background: none; font-size: 0.75rem; font-weight: 500; color: #4b5563; }
/* PhoneInput (Components/Forms/PhoneInput.razor) inside a FormField: one border, a divider between code and number. */
.crm-input-group .phone-input { flex: 1 1 auto; height: 100%; }
.crm-input-group .phone-input .form-select, .crm-input-group .phone-input .form-control { height: 100%; border: 0; border-radius: 0; box-shadow: none; background-color: transparent; font-size: 0.8125rem; }
.crm-input-group .phone-input .form-select { border-right: 1px solid var(--crm-border); }

/* Modal (Components/UI/Modal.razor) */
.crm-modal-backdrop { position: fixed; inset: 0; z-index: 1050; display: grid; place-items: center; padding: 1rem; background: rgba(15, 23, 42, 0.4); }
.crm-modal { display: flex; flex-direction: column; gap: 1.25rem; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 1.5rem; background: #fff; border-radius: 0.75rem; box-shadow: 0 12px 24px rgba(15, 23, 42, 0.15); }
.crm-modal-sm { max-width: 420px; }
.crm-modal-md { max-width: 520px; }
.crm-modal-lg { max-width: 680px; }
.crm-modal-xl { max-width: 880px; }
.crm-modal-title { margin: 0; font-size: 1.125rem; font-weight: 700; color: var(--crm-ink); }
.crm-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.crm-modal-close { border: 0; background: none; color: var(--crm-subtle); padding: 0.25rem; }
.crm-modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; }

/* Dropdown panels (menus anchored to a button) */
.crm-dropdown { position: absolute; z-index: 1030; overflow: hidden; background: #fff; border: 1px solid var(--crm-border); border-radius: 0.75rem; box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12); }
.crm-menu-item { display: flex; width: 100%; align-items: center; gap: 0.625rem; padding: 0.5rem 0.625rem; border: 0; border-radius: 0.5rem; background: none; text-align: left; font-size: 0.875rem; color: var(--crm-text); }
.crm-menu-item:hover { background: var(--crm-surface); color: var(--crm-ink); }
.crm-menu-item.danger { color: #dc2626; font-weight: 500; }
.crm-menu-item.danger:hover { background: #fef2f2; }

/* Stat tiles */
.crm-stat-label { margin: 0; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--crm-muted); }
.crm-stat-value { margin: 0.5rem 0 0; font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; color: var(--crm-ink); }

/* Icon-only buttons (top bar, sidebar) */
.crm-icon-btn { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 0; border-radius: 0.5rem; background: transparent; color: #64748b; }
.crm-icon-btn:hover, .crm-icon-btn.active { background: var(--crm-surface); color: #334155; }

/* ---------- 5. App shell ---------- */
.crm-shell { display: flex; min-height: 100vh; background: var(--crm-surface); }
.crm-main { flex: 1 1 0%; min-width: 0; }
@media (min-width: 992px) { .crm-main { margin-left: var(--crm-sidebar-width); } }

.crm-sidebar-backdrop { position: fixed; inset: 0; z-index: 1040; border: 0; background: rgba(2, 6, 23, 0.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
.crm-sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
@media (min-width: 992px) { .crm-sidebar-backdrop { display: none; } }

.crm-sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 1045; display: flex; flex-direction: column; width: var(--crm-sidebar-width); overflow: hidden; background: #fff; border-right: 1px solid var(--crm-border); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); transform: translateX(-100%); transition: transform .2s; }
.crm-sidebar.open { transform: translateX(0); }
@media (min-width: 992px) { .crm-sidebar { z-index: 1020; transform: none; box-shadow: none; } }
.crm-sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 0.5rem; }
.crm-nav-group { margin: 0; padding: 0.75rem 0.5rem 0.25rem; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; }
.crm-nav-link { display: flex; align-items: center; gap: 0.625rem; width: 100%; min-height: 2.25rem; padding: 0.5rem 0.625rem; border: 0; border-radius: 0.5rem; background: none; font-size: 0.8125rem; font-weight: 500; color: #475569; text-align: left; }
.crm-nav-link:hover { background: var(--crm-surface); color: var(--crm-ink); }
.crm-nav-link.active { background: var(--crm-brand-soft); color: var(--crm-brand-dark); font-weight: 600; }
.crm-nav-link svg { flex-shrink: 0; }
.crm-nav-children { margin: 0.125rem 0 0.25rem 1.125rem; padding: 0.25rem 0 0.25rem 0.75rem; border-left: 1px solid var(--crm-border); }
.crm-nav-child { display: block; padding: 0.375rem 0.625rem; border-radius: 0.375rem; font-size: 0.8125rem; color: #64748b; }
.crm-nav-child:hover { background: var(--crm-surface); color: var(--crm-ink); text-decoration: none; }
.crm-nav-child.active { color: var(--crm-brand-dark); font-weight: 600; background: var(--crm-brand-soft); }
.crm-nav-count { margin-left: auto; min-width: 1.5rem; padding: 0.125rem 0.375rem; border-radius: 999px; text-align: center; font-size: 0.75rem; font-weight: 700; color: #fff; background: var(--crm-brand); }

/* The layout like the user's reference (docs/engineering/navigation.md): the top bar across the whole width, the menu
   under it with the workspace card, every area by name with a bigger icon, the current one tinted with a left bar. */
:root { --crm-topbar-h: 4.5rem; }
.crm-main { padding-top: var(--crm-topbar-h); }
.crm-topbar.crm-topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--crm-topbar-h); z-index: 1035; }
@media (min-width: 992px) { .crm-sidebar { top: var(--crm-topbar-h); } }
.crm-topbar-brand { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; min-width: 0; }
.crm-topbar-brand { margin-right: 0.75rem; }
@media (min-width: 992px) { .crm-topbar-brand { min-width: calc(var(--crm-sidebar-width) - 1.5rem); } .crm-shell.sidebar-collapsed .crm-topbar-brand { min-width: 0; } }
.crm-brand { display: inline-flex; align-items: center; gap: 0.6rem; min-width: 0; color: inherit; text-decoration: none; }
.crm-brand:hover { text-decoration: none; }
.crm-brand img { flex-shrink: 0; border-radius: 10px; }
.crm-brand-line { display: flex; align-items: center; gap: 0.45rem; }
.crm-brand-name { font-size: 1.375rem; font-weight: 800; letter-spacing: -0.02em; color: var(--crm-ink); line-height: 1.1; }
.crm-brand-badge { padding: 0.05rem 0.45rem; border: 1px solid #b3dcfa; border-radius: 999px; background: var(--crm-brand-soft); color: var(--crm-brand-dark); font-size: 0.625rem; font-weight: 800; letter-spacing: 0.05em; }
.crm-brand-tag { display: block; font-size: 0.75rem; font-weight: 500; color: var(--crm-muted); white-space: nowrap; }
.crm-topbar .crm-search { flex: 1 1 auto; max-width: 34rem; }
.crm-search-kbd { padding: 0.1rem 0.4rem; border: 1px solid var(--crm-border); border-radius: 0.375rem; background: #fff; color: var(--crm-muted); font-size: 0.6875rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.crm-shell { --crm-sidebar-width: 256px; }
.crm-sidebar-head { padding: 1rem 0.875rem 0.75rem; border-bottom: 1px solid var(--crm-border); }
.crm-org-card { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--crm-border); border-radius: 1rem; background: var(--crm-surface); color: inherit; }
.crm-org-card:hover { border-color: #b3dcfa; }
.crm-org-icon { display: inline-grid; place-items: center; flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; background: var(--crm-brand); color: #fff; font-size: 1rem; }
.crm-org-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; font-weight: 700; color: var(--crm-ink); }
.crm-org-sub { display: block; font-size: 0.75rem; font-weight: 600; color: var(--crm-brand-dark); }
.crm-sidebar .crm-sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.75rem; }
.crm-sidebar .crm-nav-link { position: relative; gap: 0.85rem; min-height: 2.6rem; padding: 0.55rem 0.9rem; border-radius: 0.65rem; font-size: 0.84375rem; font-weight: 500; color: #334155; }
.crm-sidebar .crm-nav-link svg { color: #475569; }
.crm-sidebar .crm-nav-link:hover { background: var(--crm-surface); color: var(--crm-ink); }
.crm-sidebar .crm-nav-link.active { background: var(--crm-brand-soft); color: var(--crm-brand-dark); font-weight: 700; box-shadow: inset 4px 0 0 var(--crm-brand); }
.crm-sidebar .crm-nav-link.active svg { color: var(--crm-brand); }

/* The user's chip in the top bar. */
.crm-user-chip { display: inline-flex; align-items: center; gap: 0.6rem; max-width: 15rem; padding: 0.25rem 0.75rem 0.25rem 0.25rem; border: 1px solid var(--crm-border); border-radius: 999px; background: var(--crm-surface); color: inherit; }
.crm-user-chip:hover { border-color: #b3dcfa; }
.crm-user-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8125rem; font-weight: 700; color: var(--crm-ink); line-height: 1.2; }
.crm-user-role { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.6875rem; font-weight: 600; color: var(--crm-brand-dark); }

/* Icons only (☰ on wide screens; open with names by default). */
@media (min-width: 992px) {
  .crm-shell.sidebar-collapsed { --crm-sidebar-width: 80px; }
  .sidebar-collapsed .crm-sidebar .crm-nav-label { display: none !important; }
  .sidebar-collapsed .crm-sidebar-head { padding: 0.75rem 0.5rem; }
  .sidebar-collapsed .crm-org-card { justify-content: center; padding: 0.4rem; border-radius: 0.875rem; }
  .sidebar-collapsed .crm-sidebar .crm-sidebar-nav { padding: 0.75rem 0.5rem; }
  .sidebar-collapsed .crm-sidebar .crm-nav-link { justify-content: center; padding: 0.7rem 0; }
  .sidebar-collapsed .crm-sidebar .crm-nav-count { position: absolute; top: 3px; right: 6px; min-width: 1.1rem; margin: 0; padding: 0 0.25rem; font-size: 0.625rem; line-height: 1.1rem; }}

/* The tab row above a page whose menu item has several pages (HubTabs). */
.crm-hub-tabs { display: flex; align-items: center; gap: 0.75rem; padding: 0 1rem; background: #fff; border-bottom: 1px solid var(--crm-border); overflow-x: auto; scrollbar-width: thin; }
@media (min-width: 992px) { .crm-hub-tabs { padding: 0 1.5rem; } }
.crm-hub-back { display: inline-flex; align-items: center; gap: 0.4rem; flex-shrink: 0; padding: 0.35rem 0.6rem; border-radius: 0.5rem; font-size: 0.8125rem; font-weight: 600; color: var(--crm-muted); text-decoration: none; }
.crm-hub-back:hover { background: var(--crm-surface); color: var(--crm-ink); text-decoration: none; }
.crm-hub-group { flex-shrink: 0; padding-right: 0.75rem; border-right: 1px solid var(--crm-border); font-size: 0.8125rem; font-weight: 700; color: var(--crm-ink); white-space: nowrap; }
.crm-hub-tablist { display: flex; gap: 0.25rem; }
.crm-hub-tab { position: relative; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.8rem 0.75rem; font-size: 0.875rem; font-weight: 500; color: var(--crm-muted); white-space: nowrap; text-decoration: none; }
.crm-hub-tab:hover { color: var(--crm-ink); text-decoration: none; }
.crm-hub-tab.active { color: var(--crm-brand-dark); font-weight: 600; }
.crm-hub-tab.active::after { content: ""; position: absolute; left: 0.5rem; right: 0.5rem; bottom: -1px; height: 2px; border-radius: 2px; background: var(--crm-brand); }
.crm-hub-count { min-width: 1.25rem; padding: 0 0.35rem; border-radius: 999px; font-size: 0.6875rem; font-weight: 700; line-height: 1.25rem; text-align: center; color: #fff; background: var(--crm-brand); }

/* Settings (/settings): one card per group. */
.crm-settings-search { width: 100%; max-width: 22rem; }
.crm-settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; }
.crm-settings-card { display: flex; flex-direction: column; }
.crm-settings-icon { display: inline-grid; place-items: center; flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; background: var(--crm-brand-soft); color: var(--crm-brand); }
.crm-settings-card[data-settings-group="whatsapp-ai"] .crm-settings-icon { background: #f3ecfb; color: var(--ls-purple); }
.crm-settings-card[data-settings-group="access"] .crm-settings-icon { background: #e6f8f5; color: #08806d; }
.crm-settings-card[data-settings-group="account"] .crm-settings-icon { background: #eef1f4; color: var(--ls-navy); }
.crm-settings-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.25rem 0.75rem; }
.crm-settings-link { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.45rem 0.6rem; border-radius: 0.5rem; font-size: 0.8125rem; font-weight: 500; color: var(--crm-text); text-decoration: none; }
.crm-settings-link i { font-size: 0.625rem; color: var(--crm-subtle); }
.crm-settings-link:hover { background: var(--crm-brand-soft); color: var(--crm-brand-dark); text-decoration: none; }

/* The line under every CRM page. */
.crm-app-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-top: 1.5rem; padding: 0.9rem 1rem; border-top: 1px solid var(--crm-border); font-size: 0.75rem; color: var(--crm-muted); }
@media (min-width: 992px) { .crm-app-footer { padding: 0.9rem 1.5rem; } }
.crm-app-status { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-weight: 600; }
.crm-app-status .dot { width: 0.45rem; height: 0.45rem; }
.crm-app-status.ok { background: #e6f8f5; color: #08806d; }
.crm-app-status.ok .dot { background: var(--ls-teal); }
.crm-app-status.down { background: #fef2f2; color: #b91c1c; }
.crm-app-status.down .dot { background: #ef4444; }
.crm-app-version { padding: 0.15rem 0.6rem; border: 1px solid var(--crm-border); border-radius: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; color: var(--crm-brand-dark); }

.crm-topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; height: 4rem; padding: 0 0.75rem; background: #fff; border-bottom: 1px solid var(--crm-border); }
@media (min-width: 576px) { .crm-topbar { gap: 1rem; padding: 0 1rem; } }
@media (min-width: 992px) { .crm-topbar { padding: 0 1.5rem; } }
.crm-search { display: flex; flex: 1 1 auto; align-items: center; gap: 0.5rem; min-width: 0; height: 38px; padding: 0 0.75rem; background: var(--crm-surface); border: 1px solid var(--crm-border); border-radius: 0.5rem; }
@media (min-width: 576px) { .crm-search { max-width: 28rem; } }
.crm-search input { width: 100%; border: 0; outline: none; background: transparent; font-size: 0.875rem; color: #334155; }

/* ---------- 6. Carried over from Tailwind input.css ---------- */
.sidebar-scrollbar { scrollbar-width: thin; scrollbar-color: #e2e8f0 transparent; }
.sidebar-scrollbar::-webkit-scrollbar { width: 6px; }
.sidebar-scrollbar::-webkit-scrollbar-track { background: transparent; }
.sidebar-scrollbar::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 999px; }
.sidebar-scrollbar::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

.table-scroll { overflow-x: auto; scrollbar-width: thin; scrollbar-color: #e2e8f0 transparent; }
.table-scroll::-webkit-scrollbar { height: 6px; width: 6px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 999px; }
.table-scroll tbody tr:hover td { background: #f8fafc; }
.table-scroll[data-scrolled-start] [data-pin="start"] { box-shadow: 8px 0 16px -10px rgba(15, 23, 42, 0.18); }
.table-scroll[data-scrolled-end] [data-pin="end"] { box-shadow: -8px 0 16px -10px rgba(15, 23, 42, 0.18); }

.toast-enter { animation: toast-in 480ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.toast-leave { animation: toast-out 260ms cubic-bezier(0.4, 0, 1, 1) both; }
.toast-progress { animation-name: toast-progress; animation-timing-function: linear; animation-fill-mode: forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translate3d(18px, -24px, 0) scale(0.96); filter: blur(4px); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); filter: blur(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translate3d(0, 0, 0) scale(1); filter: blur(0); }
  to { opacity: 0; transform: translate3d(12px, -14px, 0) scale(0.98); filter: blur(3px); }
}
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .toast-enter, .toast-leave, .toast-progress { animation: none; } }

@media (max-width: 991px) {
  html { -ms-overflow-style: none; scrollbar-width: none; }
  html::-webkit-scrollbar { display: none; }
}

#blazor-error-ui { background: #fefce8; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); display: none; left: 0; padding: 0.6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }

div.dt-container { font-family: inherit; color: inherit; }
div.dt-container .dt-layout-row:not(.dt-layout-table) { padding: 12px 16px; }
div.dt-container .dt-search { position: relative; display: inline-block; }
div.dt-container .dt-search input { border: 1px solid #e2e8f0; border-radius: 8px; height: 36px; min-width: 180px; max-width: 100%; padding: 0 12px 0 36px; font-size: 13px; color: #111827; background: #fff; }
div.dt-container .dt-search input:focus { outline: none; border-color: #0385e6; }
div.dt-container .dt-search::before { content: "\f002"; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: #94a3b8; pointer-events: none; z-index: 1; }
div.dt-container .dt-length { position: relative; display: inline-flex; align-items: center; }
div.dt-container .dt-length select { -webkit-appearance: none; appearance: none; border: 1px solid #e2e8f0; border-radius: 8px; height: 36px; min-width: 72px; padding: 0 32px 0 12px; font-size: 13px; color: #111827; background: #fff; cursor: pointer; }
div.dt-container .dt-length::after { content: "\f078"; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 11px; color: #64748b; pointer-events: none; }
div.dt-container .dt-info { font-size: 13px; color: #6b7280; }
div.dt-container .dt-paging .dt-paging-button { border-radius: 8px !important; border: 1px solid #e2e8f0 !important; background: #fff !important; color: #334155 !important; min-width: 36px; padding: 0.375rem 0.75rem; font-size: 13px; }
div.dt-container .dt-paging .dt-paging-button.current { background: #0385e6 !important; border-color: #0385e6 !important; color: #fff !important; }
div.dt-container .dt-paging .dt-paging-button.disabled { opacity: 0.4; }
table.dataTable thead > tr > th.dt-orderable-asc .dt-column-order,
table.dataTable thead > tr > th.dt-orderable-desc .dt-column-order,
table.dataTable thead > tr > th.dt-ordering-asc .dt-column-order,
table.dataTable thead > tr > th.dt-ordering-desc .dt-column-order { width: 12px; }
table.dataTable thead > tr > th.dt-orderable-asc .dt-column-order:before,
table.dataTable thead > tr > th.dt-orderable-desc .dt-column-order:before,
table.dataTable thead > tr > th.dt-ordering-asc .dt-column-order:before,
table.dataTable thead > tr > th.dt-ordering-desc .dt-column-order:before,
table.dataTable thead > tr > th.dt-orderable-asc .dt-column-order:after,
table.dataTable thead > tr > th.dt-orderable-desc .dt-column-order:after,
table.dataTable thead > tr > th.dt-ordering-asc .dt-column-order:after,
table.dataTable thead > tr > th.dt-ordering-desc .dt-column-order:after { border: 0 !important; height: auto !important; width: auto !important; left: 0; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 9px; line-height: 1; color: #94a3b8; opacity: 0.7; }
table.dataTable thead > tr > th.dt-orderable-asc .dt-column-order:before,
table.dataTable thead > tr > th.dt-orderable-desc .dt-column-order:before,
table.dataTable thead > tr > th.dt-ordering-asc .dt-column-order:before,
table.dataTable thead > tr > th.dt-ordering-desc .dt-column-order:before { content: "\f0de" !important; bottom: calc(50% - 1px); }
table.dataTable thead > tr > th.dt-orderable-asc .dt-column-order:after,
table.dataTable thead > tr > th.dt-orderable-desc .dt-column-order:after,
table.dataTable thead > tr > th.dt-ordering-asc .dt-column-order:after,
table.dataTable thead > tr > th.dt-ordering-desc .dt-column-order:after { content: "\f0dd" !important; top: calc(50% + 1px); }
table.dataTable thead > tr > th.dt-ordering-asc .dt-column-order:before,
table.dataTable thead > tr > th.dt-ordering-desc .dt-column-order:after { color: #0385e6; opacity: 1; }
@media (max-width: 767px) {
  div.dt-container .dt-layout-row:not(.dt-layout-table) { padding: 12px; flex-wrap: wrap; gap: 10px; }
  div.dt-container .dt-search, div.dt-container .dt-search input { width: 100%; min-width: 0; }
  table.dataTable thead th.sticky, table.dataTable tbody td.sticky, table.dataTable thead th.position-sticky, table.dataTable tbody td.position-sticky { position: static !important; left: auto !important; right: auto !important; min-width: 0 !important; }
}
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before { border: 0 !important; width: 18px; height: 18px; margin-right: 10px; border-radius: 999px; background: #e6f3fd; color: #026bba; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 10px; line-height: 18px; text-align: center; content: "\f067" !important; vertical-align: middle; }
table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > th.dtr-control:before { content: "\f068" !important; background: #0385e6; color: #fff; }
table.dataTable > tbody > tr.child ul.dtr-details { display: grid; gap: 0; padding: 8px 12px 12px 48px; margin: 0; }
table.dataTable > tbody > tr.child ul.dtr-details > li { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
table.dataTable > tbody > tr.child ul.dtr-details > li:last-child { border-bottom: 0; }
table.dataTable > tbody > tr.child span.dtr-title { min-width: 110px; color: #6b7280; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
table.dataTable > tbody > tr.child span.dtr-data { color: #111827; font-size: 13px; }

/* ---------- 7. Added during the page migration ---------- */
/* Leads list: sticky toolbar under the top bar (desktop) and its view tabs. */
@media (min-width: 992px) { .crm-leads-toolbar { position: sticky; top: var(--crm-topbar-h, 4rem); z-index: 1020; } }
.crm-lead-tab { display: flex; flex-shrink: 0; align-items: center; gap: 0.375rem; padding: 0 1rem; border: 0; border-bottom: 2px solid transparent; background: none; font-size: 0.875rem; font-weight: 500; color: var(--crm-muted); }
.crm-lead-tab:hover { background: var(--crm-surface); }
.crm-lead-tab.active { border-bottom-color: var(--crm-brand); background: #f0f8fe; color: var(--crm-brand); }

/* Stat tile rows: one column on phones, as many 180px+ columns as fit. */
.crm-stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.text-pre-wrap { white-space: pre-wrap !important; }

/* Lead detail header: sticks under the top bar on desktop only (on a phone it would cover a third of the screen).
   Its "more" menu opens to the right on phones, where the button wraps to the start of a line. */
.crm-lead-header { position: relative; z-index: 20; }
.crm-lead-more-menu { left: 0; }
@media (min-width: 768px) { .crm-lead-more-menu { left: auto; right: 0; } }
@media (min-width: 992px) { .crm-lead-header { position: sticky; top: var(--crm-topbar-h, 4rem); } }

/* Lead WhatsApp tab: like WhatsApp, only the messages scroll (newest at the bottom), not the page.
   column-reverse keeps the list pinned to the newest message as messages arrive. */
.crm-chat-card { display: flex; flex-direction: column; height: 75dvh; min-height: 420px; }
.crm-chat-card > :not(.crm-chat-scroll) { flex-shrink: 0; }
.crm-chat-scroll { flex: 1 1 0%; min-height: 0; overflow-y: auto; display: flex; flex-direction: column-reverse; background: #eee7de; }
@media (min-width: 992px) {
  .crm-lead-chat-mode { display: flex; flex-direction: column; height: calc(100dvh - 4rem); overflow: hidden; }
  /* The page does not scroll here, so the lead header need not stick (its top:4rem would leave a gap over the tabs). */
  .crm-lead-chat-mode > .crm-lead-header { position: relative; top: 0; }
  .crm-lead-chat-mode > .crm-lead-body { flex: 1 1 0%; min-height: 0 !important; }
  .crm-lead-chat-mode .crm-lead-aside { overflow-y: auto; }
  .crm-lead-chat-mode .crm-lead-content { display: flex; flex-direction: column; min-height: 0; padding-bottom: 1rem !important; }
  .crm-lead-chat-mode .crm-lead-tab-body { flex: 1 1 0%; min-height: 0; }
  .crm-lead-chat-mode .crm-chat-card { height: 100%; min-height: 0; }
}

/* ---- Lists like the user's reference (Users & Access, 26 Oct 2026): figures, toolbar, filters, pages ---- */
.crm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 1rem; }
.crm-kpi { position: relative; padding: 1.1rem 1.25rem; border: 1px solid var(--crm-border); border-left: 4px solid var(--crm-brand); border-radius: 1rem; background: #fff; box-shadow: var(--crm-shadow-card); }
.crm-kpi-label { margin: 0 3rem 0 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--crm-text); }
.crm-kpi-value { margin: 0.5rem 0 0; font-size: 2rem; font-weight: 800; line-height: 1; color: var(--crm-ink); }
.crm-kpi-icon { position: absolute; top: 1rem; right: 1rem; display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; background: var(--crm-brand-soft); color: var(--crm-brand); }
.crm-kpi-purple { border-left-color: var(--ls-purple); }
.crm-kpi-purple .crm-kpi-icon { background: #f3ecfb; color: var(--ls-purple); }
.crm-kpi-teal { border-left-color: var(--ls-teal); }
.crm-kpi-teal .crm-kpi-icon { background: #e6f8f5; color: #08806d; }

.crm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding: 0.9rem 1rem; }
.crm-toolbar-search { display: flex; align-items: center; gap: 0.6rem; flex: 1 1 13rem; max-width: 19rem; height: 2.75rem; margin: 0; padding: 0 0.9rem; border: 1px solid var(--crm-border); border-radius: 0.75rem; background: #fff; color: var(--crm-subtle); }
.crm-toolbar-search:focus-within { border-color: var(--crm-brand); box-shadow: 0 0 0 3px rgba(3, 133, 230, 0.12); }
.crm-toolbar-search input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--crm-ink); font-size: 0.875rem; }

.crm-filter { position: relative; display: inline-flex; align-items: center; width: 11.5rem; height: 2.75rem; border: 1px solid var(--crm-border); border-radius: 0.75rem; background: #fff; }
.crm-filter.open { border-color: var(--crm-brand); box-shadow: 0 0 0 3px rgba(3, 133, 230, 0.12); }
.crm-filter-field { display: flex; align-items: center; gap: 0.5rem; width: 100%; min-width: 0; height: 100%; padding: 0 0.75rem 0 0.9rem; border: 0; border-radius: inherit; background: transparent; color: var(--crm-ink); font-size: 0.875rem; font-weight: 600; text-align: left; cursor: pointer; }
.crm-filter.has-value .crm-filter-value { padding-right: 1.75rem; }
.crm-filter-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-filter-clear { position: absolute; top: 50%; right: 1.9rem; transform: translateY(-50%); display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border: 0; border-radius: 50%; background: transparent; color: var(--crm-muted); }
.crm-filter-clear:hover { background: var(--crm-surface); color: var(--crm-ink); }
.crm-filter-caret { flex-shrink: 0; color: var(--crm-muted); }
.crm-filter-menu { position: absolute; z-index: 40; top: calc(100% + 0.4rem); left: 0; width: max(100%, 14rem); padding: 0.6rem; border: 1px solid var(--crm-border); border-radius: 1rem; background: #fff; box-shadow: 0 20px 40px -16px rgba(15, 23, 42, 0.3); }
.crm-filter-search { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; padding: 0.55rem 0.75rem; border: 1px solid var(--crm-border); border-radius: 0.75rem; color: var(--crm-brand); }
.crm-filter-search input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--crm-ink); font-size: 0.875rem; }
.crm-filter-list { max-height: 15rem; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.crm-filter-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.15rem; padding: 0.6rem 0.75rem; border: 1px solid transparent; border-radius: 0.75rem; cursor: pointer; font-size: 0.875rem; font-weight: 600; color: var(--crm-ink); }
.crm-filter-list li.active { background: var(--crm-surface); }
.crm-filter-list li.chosen { border-color: var(--crm-brand); background: var(--crm-brand-soft); color: var(--crm-brand-dark); }
.crm-filter-list li.chosen i { color: var(--crm-brand); font-size: 1.05rem; }
.crm-filter-list .crm-filter-empty { cursor: default; font-weight: 500; color: var(--crm-muted); }

.crm-view-toggle { display: inline-flex; gap: 0.25rem; padding: 0.25rem; border: 1px solid var(--crm-border); border-radius: 0.75rem; background: var(--crm-surface); }
.crm-view-toggle button { display: inline-flex; align-items: center; gap: 0.45rem; height: 2.2rem; padding: 0 0.9rem; border: 0; border-radius: 0.55rem; background: transparent; color: var(--crm-text); font-size: 0.8125rem; font-weight: 700; }
.crm-view-toggle button.on { background: var(--crm-brand); color: #fff; }

.crm-user-avatar { display: inline-grid; place-items: center; flex-shrink: 0; width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--crm-brand-soft); color: var(--crm-brand-dark); font-size: 0.75rem; font-weight: 800; }
.crm-users-table td { vertical-align: middle; }
.crm-menu-open .table-scroll { padding-bottom: 14rem; }

.crm-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.9rem 1.25rem; border-top: 1px solid var(--crm-border); font-size: 0.875rem; color: var(--crm-text); }
.crm-pager-btn { display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border: 1px solid var(--crm-border); border-radius: 50%; background: #fff; color: var(--crm-ink); font-size: 0.75rem; }
.crm-pager-btn:disabled { opacity: 0.4; }
.crm-pager-current { display: inline-grid; place-items: center; min-width: 2.1rem; height: 2.1rem; border-radius: 0.6rem; background: var(--crm-brand); color: #fff; font-weight: 700; }

.crm-user-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 1rem; align-items: start; }
.crm-user-column { display: grid; gap: 0.6rem; padding: 0.9rem; border: 1px solid var(--crm-border); border-radius: 1rem; background: var(--crm-surface); }
.crm-user-column-title { display: flex; justify-content: space-between; margin: 0 0 0.25rem; font-size: 0.8125rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--crm-text); }
.crm-user-column-title span { min-width: 1.5rem; padding: 0 0.4rem; border-radius: 999px; background: #fff; text-align: center; }
.crm-user-card { padding: 0.75rem; border: 1px solid var(--crm-border); border-radius: 0.75rem; background: #fff; }
@media (max-width: 575.98px) {
  .crm-toolbar-search, .crm-filter { flex: 1 1 100%; width: 100%; max-width: none; }
}
.crm-pager-size { width: 5rem; padding-right: 1.75rem; }

/* ==== Forms in a side drawer (docs/plans/drawer-forms-plan.md, 27 Oct 2026) ====
   Components/UI/Modal.razor adds crm-drawer to every dialog except the small centre box (crm-modal-sm / -center). */
.crm-drawer-backdrop { display: flex; justify-content: flex-end; align-items: stretch; padding: 0; background: rgba(0, 27, 64, 0.32); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: crm-fade-in 0.15s ease-out; }
.crm-modal.crm-drawer { width: 50vw; min-width: min(100vw, 560px); max-width: 960px; height: 100vh; max-height: none; gap: 1rem; padding: 0; border-radius: 1.25rem 0 0 1.25rem; overflow-y: auto; overscroll-behavior: contain; box-shadow: -24px 0 60px -24px rgba(0, 27, 64, 0.35); animation: crm-drawer-in 0.2s ease-out; }
@keyframes crm-drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes crm-fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 767.98px) { .crm-modal.crm-drawer { width: 100vw; min-width: 0; border-radius: 0; } }

/* Header (DrawerHeader, or a plain crm-modal-header / title) stays at the top. */
.crm-drawer > .crm-modal-header, .crm-drawer > .crm-modal-title:first-child { position: sticky; top: 0; z-index: 3; margin: 0; padding: 1.1rem 1.5rem; background: #fff; border-bottom: 1px solid var(--crm-border); }
.crm-drawer-header { gap: 0.9rem; align-items: center; }
.crm-drawer-icon { display: inline-grid; place-items: center; flex-shrink: 0; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--crm-brand); color: #fff; font-size: 1.05rem; box-shadow: 0 6px 14px -6px rgba(3, 133, 230, 0.6); }
.crm-drawer-icon-teal { background: var(--ls-teal); box-shadow: 0 6px 14px -6px rgba(26, 191, 166, 0.6); }
.crm-drawer-icon-purple { background: var(--ls-purple); box-shadow: 0 6px 14px -6px rgba(124, 55, 204, 0.6); }
.crm-drawer-icon-amber { background: #f59e0b; box-shadow: 0 6px 14px -6px rgba(245, 158, 11, 0.6); }
.crm-drawer-icon-danger { background: #dc2626; box-shadow: 0 6px 14px -6px rgba(220, 38, 38, 0.6); }
.crm-drawer .crm-modal-title { font-size: 1.2rem; font-weight: 800; }
.crm-drawer-subtitle { margin: 0.15rem 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8125rem; color: var(--crm-muted); }
.crm-drawer .crm-modal-close { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--crm-surface); color: var(--crm-muted); }
.crm-drawer .crm-modal-close:hover { color: var(--crm-ink); background: var(--crm-border-soft); }

/* Body: everything between the header and the footer, with the side margins. */
.crm-drawer > :not(.crm-modal-header):not(.crm-modal-footer):not(.crm-modal-title:first-child) { margin-inline: 1.5rem; }
.crm-drawer > form, .crm-drawer > .crm-form { flex: 1 0 auto; display: flex; flex-direction: column; gap: 0.95rem; }
.crm-drawer > div:last-child:not(.crm-modal-footer):not(.crm-modal-header) { flex: 1 0 auto; display: flex; flex-direction: column; }
.crm-drawer .crm-form { gap: 0.95rem; }
.crm-drawer .crm-form-grid { gap: 0.95rem 1rem; }
@media (min-width: 576px) { .crm-drawer .crm-form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Footer stays at the bottom: Cancel on the left, the main button on the right. */
.crm-drawer .crm-modal-footer { position: sticky; bottom: 0; z-index: 3; margin-top: auto; padding: 0.9rem 1.5rem; background: #fff; border-top: 1px solid var(--crm-border); align-items: center; }
.crm-drawer > form > .crm-modal-footer, .crm-drawer > .crm-form > .crm-modal-footer, .crm-drawer > div > .crm-modal-footer { margin-inline: -1.5rem; }
.crm-drawer .crm-modal-footer > .btn-outline-secondary:first-child { margin-right: auto; border-color: transparent; background: transparent; }
.crm-drawer .crm-modal-footer > .btn-outline-secondary:first-child:hover { background: var(--crm-surface); }
.crm-drawer .crm-modal-footer .btn { min-height: 2.6rem; padding-inline: 1.25rem; font-weight: 700; }

/* Labels on the border of the box (like the reference): label.d-flex.flex-column > span.crm-label + the field. */
.crm-drawer label:has(> .crm-label:first-child):has(:is(input:not([type=checkbox]):not([type=radio]), select, textarea, .crm-input-group)), .crm-drawer .crm-field { position: relative; margin: 0; }
.crm-drawer label:has(> .crm-label:first-child):has(:is(input:not([type=checkbox]):not([type=radio]), select, textarea, .crm-input-group)) > .crm-label:first-child, .crm-drawer .crm-field > label.crm-label:first-child { position: absolute; top: -0.5rem; left: 0.7rem; z-index: 2; margin: 0; padding: 0 0.35rem; background: #fff; font-size: 0.7rem; font-weight: 700; line-height: 1rem; color: var(--crm-text); pointer-events: none; }
.crm-drawer .crm-form .form-control:not(.form-control-sm), .crm-drawer .crm-form .form-select:not(.form-select-sm), .crm-drawer .crm-field .crm-input-group { min-height: 2.75rem; border-radius: 0.6rem; }
.crm-drawer .crm-form textarea.form-control { min-height: 4.5rem; }
.crm-drawer .crm-form .form-control:focus, .crm-drawer .crm-form .form-select:focus { border-color: var(--crm-brand); box-shadow: 0 0 0 3px rgba(3, 133, 230, 0.12); }

/* Option cards (2-4 choices), a two-way toggle and an info box. */
.crm-option-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.crm-option-card { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 0.9rem 0.75rem; border: 1.5px solid var(--crm-border); border-radius: 0.9rem; background: #fff; color: var(--crm-ink); text-align: center; cursor: pointer; }
.crm-option-card i { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 0.6rem; background: var(--crm-surface); color: var(--crm-muted); }
.crm-option-card strong { font-size: 0.875rem; }
.crm-option-card small { font-size: 0.72rem; color: var(--crm-muted); }
.crm-option-card.on { border-color: var(--crm-brand); background: var(--crm-brand-soft); }
.crm-option-card.on i { background: var(--crm-brand); color: #fff; }
.crm-segmented { display: inline-flex; gap: 0.25rem; padding: 0.25rem; border-radius: 0.75rem; background: var(--crm-surface); border: 1px solid var(--crm-border); }
.crm-segmented button { padding: 0.4rem 0.9rem; border: 0; border-radius: 0.55rem; background: transparent; color: var(--crm-text); font-size: 0.8125rem; font-weight: 600; }
.crm-segmented button.on { background: #fff; color: var(--crm-brand-dark); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }
.crm-info-box { display: flex; gap: 0.75rem; padding: 0.85rem 1rem; border: 1px solid #b3dcfa; border-radius: 0.9rem; background: var(--crm-brand-soft); font-size: 0.8125rem; color: var(--crm-text); }
.crm-info-box > i { margin-top: 0.15rem; color: var(--crm-brand); }
.crm-info-box strong { display: block; color: var(--crm-ink); }
.crm-info-box.warn { border-color: #fde68a; background: #fffbeb; }
.crm-info-box.warn > i { color: #d97706; }
.crm-info-box.danger { border-color: #fecaca; background: #fef2f2; }
.crm-info-box.danger > i { color: #dc2626; }

/* Steps of a long form. */
.crm-drawer-steps { display: flex; align-items: center; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.crm-drawer-steps li { display: flex; align-items: center; gap: 0.5rem; }
.crm-drawer-steps li + li::before { content: ""; width: 2rem; height: 2px; border-radius: 2px; background: var(--crm-border); }
.crm-drawer-steps li.done + li::before, .crm-drawer-steps li.on::before { background: var(--crm-brand); }
.crm-drawer-steps button { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0; border: 0; background: none; font-size: 0.8125rem; font-weight: 700; color: var(--crm-muted); }
.crm-drawer-steps button:disabled { opacity: 0.7; }
.crm-drawer-step-dot { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid var(--crm-border); background: var(--crm-surface); font-size: 0.75rem; }
.crm-drawer-steps li.on button, .crm-drawer-steps li.done button { color: var(--crm-ink); }
.crm-drawer-steps li.on .crm-drawer-step-dot, .crm-drawer-steps li.done .crm-drawer-step-dot { border-color: var(--crm-brand); background: var(--crm-brand); color: #fff; }

/* A long list inside a form scrolls in its own box (permission table, offerings, members). */
.crm-drawer-list { max-height: 15rem; overflow-y: auto; border: 1px solid var(--crm-border); border-radius: 0.75rem; padding: 0.5rem; }
