:root {
    --crm-sidebar-expanded: 240px;
    --crm-topbar-height: 64px;
    --crm-sidebar-collapsed: 72px;
    --crm-sidebar-bg: #1f2937;
    --crm-sidebar-hover: #374151;
    --crm-sidebar-text: #d1d5db;
    --crm-sidebar-muted: #94a3b8;
}

* { box-sizing: border-box; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; margin: 0; }

.crm-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--crm-sidebar-expanded) minmax(0, 1fr);
    background: #f8fafc;
    width: 100%;
}
.crm-shell.sidebar-collapsed,
html.crm-sidebar-collapsed .crm-shell {
    grid-template-columns: var(--crm-sidebar-collapsed) minmax(0, 1fr);
}
.crm-sidebar {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    background: var(--crm-sidebar-bg);
    color: #fff;
    overflow: visible;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 20;
}
.crm-sidebar.collapsed {
    width: 100%;
    min-width: 0;
}

.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; }
.sidebar-toggle {
    width: 32px; height: 32px; border: 0; border-radius: 8px;
    background: transparent; color: #cbd5e1; display: inline-flex;
    align-items: center; justify-content: center; cursor: pointer;
}
.sidebar-toggle:hover { background: var(--crm-sidebar-hover); color: #fff; }
.crm-sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; }
.crm-sidebar.collapsed .sidebar-brand { display: none; }

.crm-nav { padding: 18px 10px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.nav-section-label {
    color: var(--crm-sidebar-muted); text-transform: uppercase; font-size: .7rem;
    letter-spacing: .06em; font-weight: 600; padding: 0 10px 7px;
    white-space: nowrap;
}
.service-label { margin-top: 24px; }
.crm-nav-link {
    color: var(--crm-sidebar-text); text-decoration: none; border-radius: 8px;
    height: 42px; display: flex; align-items: center; gap: 12px;
    padding: 0 10px; margin-bottom: 3px; white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}
.crm-nav-link:hover { background: var(--crm-sidebar-hover); color: #fff; }
.crm-nav-link.active { background: #334155; color: #fff; font-weight: 600; }
.nav-icon { width: 24px; min-width: 24px; text-align: center; font-size: 1.05rem; }
.nav-text { opacity: 1; transition: opacity .1s ease; }
.crm-sidebar.collapsed .crm-nav { padding-left: 10px; padding-right: 10px; }
.crm-sidebar.collapsed .nav-section-label { display: none; }
.crm-sidebar.collapsed .crm-nav-link { justify-content: center; padding: 0; gap: 0; }
.crm-sidebar.collapsed .nav-text { display: none; }

.crm-main { grid-column: 2; grid-row: 1; min-width: 0; width: 100%; }
.crm-topbar {
    min-height: var(--crm-topbar-height); background: #fff; border-bottom: 1px solid #e5e7eb;
    padding: 0 24px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1040;
}
.crm-content { padding: 24px; }
.user-name { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-shell { min-height: 100vh; display:flex; align-items:center; justify-content:center; background:#f3f4f6; padding:2rem; }
.auth-card { width:100%; max-width:480px; border:0; }
.divider { display:flex; align-items:center; gap:1rem; margin:1.5rem 0; color:#9ca3af; font-size:.8rem; }
.divider::before,.divider::after { content:""; height:1px; background:#dee2e6; flex:1; }

@media (max-width: 768px) {
    :root { --crm-sidebar-collapsed: 64px; }
    .crm-shell, .crm-shell.sidebar-collapsed, html.crm-sidebar-collapsed .crm-shell { grid-template-columns: var(--crm-sidebar-collapsed) minmax(0, 1fr); }
    .crm-sidebar { width: 100%; min-width: 0; }
    .crm-sidebar .sidebar-brand, .crm-sidebar .nav-text, .crm-sidebar .nav-section-label { display: none; }
    .sidebar-header { justify-content: center; padding: 0; }
    .crm-nav-link { justify-content: center; padding: 0; gap: 0; }
    .crm-content { padding: 16px; }
    .crm-topbar { padding: 0 16px; }
    .user-name { display: none; }
}

.crm-sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.crm-sort-link:hover { color: var(--bs-primary); }
.crm-sort-link i { font-size: .75rem; margin-left: .25rem; opacity: .65; }
.crm-grid thead th { background: #f8fafc; color: #475569; font-size: .78rem; text-transform: uppercase; letter-spacing: .025em; white-space: nowrap; border-bottom-width: 1px; }
.crm-grid tbody td { border-color: #eef2f7; }
.crm-grid tbody tr { cursor: default; }

.crm-command-bar { min-height: 56px; }
.crm-command-bar .btn.disabled, .crm-command-bar .btn:disabled { pointer-events: none; opacity: .5; }
.crm-command-bar form { margin: 0; }

/* Dashboard / Settings */
.crm-sidebar { background: #1f293b; }
.crm-nav { padding: 12px 10px 14px; }
.crm-nav-link.active { background: #0d6efd; color: #fff; box-shadow: 0 3px 10px rgba(13,110,253,.22); }
.settings-nav-wrap { border-top: 1px solid rgba(255,255,255,.16); }
.topbar-icon { font-size: 1.2rem; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #0d6efd; color: #fff; font-size: .8rem; font-weight: 700; }

.dashboard-header { display:flex; align-items:center; justify-content:space-between; gap:1rem; }
.dashboard-title { font-size:2rem; font-weight:700; letter-spacing:-.03em; color:#17233f; }
.dashboard-period { display:inline-flex; align-items:center; border:1px solid #d7dee9; background:#fff; border-radius:.5rem; padding:.55rem .8rem; color:#334155; font-size:.9rem; }
.dashboard-kpi { min-height:112px; border:1px solid #e1e7ef; border-radius:.65rem; padding:1rem; display:flex; align-items:center; gap:.9rem; background:#fff; box-shadow:0 2px 8px rgba(15,23,42,.03); }
.dashboard-kpi .kpi-icon { width:52px; height:52px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:1.35rem; flex:0 0 auto; }
.kpi-blue { background:#f5f9ff; border-color:#cfe1ff; }.kpi-blue .kpi-icon { background:#dceaff; color:#0d6efd; }
.kpi-green { background:#f5fffb; border-color:#cfeee1; }.kpi-green .kpi-icon { background:#d8f5e7; color:#16a34a; }
.kpi-purple { background:#fbf8ff; border-color:#e6d8ff; }.kpi-purple .kpi-icon { background:#eadcff; color:#7c3aed; }
.kpi-orange { background:#fffaf2; border-color:#f4dfbc; }.kpi-orange .kpi-icon { background:#ffebc5; color:#d97706; }
.kpi-label { color:#475569; font-size:.86rem; }.kpi-value { font-size:1.8rem; font-weight:700; line-height:1.15; color:#17233f; }.kpi-sub { color:#94a3b8; font-size:.72rem; margin-top:.15rem; }
.dashboard-card { background:#fff; border:1px solid #e0e6ee; border-radius:.65rem; box-shadow:0 2px 8px rgba(15,23,42,.025); overflow:hidden; }
.dashboard-card-header { min-height:48px; padding:.85rem 1rem; border-bottom:1px solid #e6ebf1; display:flex; align-items:center; justify-content:space-between; gap:1rem; }.dashboard-card-header h2 { font-size:1rem; font-weight:650; margin:0; color:#17233f; }.dashboard-card-header a { font-size:.82rem; text-decoration:none; color:#0d6efd; }
.dashboard-card-body { padding:1rem; }.status-row + .status-row { margin-top:1rem; }.status-row .progress { background:#eef2f7; }.dashboard-bar-blue { background:#0d6efd; }.dashboard-bar-green { background:#22c55e; }.dashboard-bar-yellow { background:#f59e0b; }.dashboard-bar-red { background:#ef4444; }
.trend-chart { min-height:228px; display:flex; align-items:flex-end; }.trend-bars { width:100%; height:185px; display:flex; align-items:flex-end; justify-content:space-around; gap:.8rem; border-bottom:1px solid #e5e7eb; padding:0 .4rem; }.trend-column { height:100%; flex:1; max-width:56px; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; position:relative; }.trend-value { font-size:.72rem; color:#64748b; margin-bottom:.25rem; }.trend-bar { width:100%; min-height:8px; background:#0d6efd; border-radius:5px 5px 0 0; }.trend-label { font-size:.72rem; color:#64748b; margin-top:.45rem; }
.activity-row { display:flex; align-items:center; gap:.75rem; padding:.75rem 1rem; border-bottom:1px solid #eef2f7; }.activity-row:last-child { border-bottom:0; }.activity-icon { width:32px; height:32px; border-radius:50%; background:#eef5ff; color:#0d6efd; display:flex; align-items:center; justify-content:center; flex:0 0 auto; }.empty-state { padding:2rem 1rem; text-align:center; color:#94a3b8; font-size:.85rem; }
.dashboard-table { font-size:.82rem; }.dashboard-table thead th { background:#f8fafc; color:#475569; font-size:.72rem; text-transform:uppercase; letter-spacing:.025em; white-space:nowrap; }.dashboard-table td,.dashboard-table th { padding:.65rem .75rem; vertical-align:middle; border-color:#eef2f7; }.dashboard-table td a { color:#0d6efd; text-decoration:none; font-weight:600; }
.settings-card { transition:transform .15s ease, box-shadow .15s ease; }.settings-card:not(.settings-card-disabled):hover { transform:translateY(-2px); box-shadow:0 8px 24px rgba(15,23,42,.08)!important; }.settings-card-disabled { opacity:.72; }.settings-icon { width:42px; height:42px; border-radius:10px; background:#edf4ff; color:#0d6efd; display:flex; align-items:center; justify-content:center; font-size:1.15rem; flex:0 0 auto; }

@media (max-width: 900px) { .dashboard-header { align-items:flex-start; flex-direction:column; }.dashboard-title { font-size:1.7rem; } }
.crm-form-header { display:flex; justify-content:space-between; align-items:center; gap:1rem; margin-bottom:1rem; }
@media (max-width: 900px) { .crm-form-header { align-items:flex-start; flex-direction:column; } }

/* Polymorphic User / Team owner lookup */
.owner-lookup { position: relative; }
.owner-lookup-control { min-height: 38px; display:flex; align-items:center; justify-content:space-between; background:#fff; }
.owner-lookup-panel { position:absolute; z-index:1050; top:calc(100% + 4px); left:0; right:0; min-width:320px; background:#fff; border:1px solid #cbd5e1; border-radius:.5rem; box-shadow:0 12px 30px rgba(15,23,42,.16); overflow:hidden; }
.owner-lookup-tabs { display:flex; gap:.25rem; padding:.5rem; border-bottom:1px solid #e5e7eb; background:#f8fafc; }
.owner-tab { border:0; background:transparent; border-radius:.35rem; padding:.35rem .75rem; color:#475569; font-size:.82rem; }
.owner-tab.active { background:#0d6efd; color:#fff; }
.owner-lookup-list { max-height:280px; overflow:auto; padding:.25rem; }
.owner-option { width:100%; border:0; background:#fff; display:flex; align-items:center; gap:.65rem; padding:.55rem .6rem; border-radius:.4rem; text-align:left; }
.owner-option:hover { background:#eef5ff; }
.owner-avatar { width:32px; height:32px; border-radius:50%; background:#dceaff; color:#0d6efd; display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; }
.owner-avatar.team { background:#eadcff; color:#7c3aed; }
.owner-option.selected { background:#e8f1ff; }

.settings-header { display:flex; justify-content:space-between; align-items:flex-end; gap:1rem; }
.settings-search { width:330px; }
.settings-tabs { display:flex; gap:1.4rem; flex-wrap:wrap; background:#fff; border:1px solid #e0e6ee; border-radius:.6rem; padding:.7rem 1rem; }
.settings-tabs a { color:#475569; text-decoration:none; padding:.35rem .15rem; border-bottom:3px solid transparent; }
.settings-tabs a.active { color:#0d6efd; border-bottom-color:#0d6efd; font-weight:600; }
.settings-tile { min-height:112px; display:flex; align-items:center; gap:1rem; background:#fff; border:1px solid #e0e6ee; border-radius:.65rem; padding:1.1rem; box-shadow:0 2px 8px rgba(15,23,42,.025); }
.settings-tile.disabled { opacity:.7; }
.settings-quick-link { min-width:220px; flex:1 1 220px; display:flex; align-items:center; gap:.75rem; padding:.8rem; border:1px solid #e5e7eb; border-radius:.5rem; color:#17233f; text-decoration:none; background:#fff; }
.settings-quick-link:hover { background:#f8fbff; border-color:#bfd8ff; }
.settings-quick-link > i { width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:#edf4ff; color:#0d6efd; }
.settings-quick-link span { display:flex; flex-direction:column; }
.settings-quick-link small { color:#64748b; margin-top:.1rem; }
.settings-link-list { padding:.25rem 1rem 1rem; }
.settings-link-list a { display:flex; align-items:center; gap:.65rem; padding:.75rem .25rem; border-bottom:1px solid #eef2f7; color:#17233f; text-decoration:none; }
.settings-link-list a > i:first-child { color:#0d6efd; width:22px; }
.owner-cell { white-space:nowrap; }
.owner-cell i { color:#64748b; }
@media (max-width: 900px) { .settings-header { align-items:flex-start; flex-direction:column; } .settings-search { width:100%; } }

/* Lead grid owner filter (compact Option A) */
.crm-owner-filter-menu { width: 360px; max-width: min(360px, calc(100vw - 2rem)); }
.crm-owner-filter-tabs { display:flex; gap:.25rem; padding:.5rem; border-bottom:1px solid #e5e7eb; background:#f8fafc; }
.owner-filter-tab { border:0; background:transparent; border-radius:.35rem; padding:.35rem .8rem; color:#475569; font-size:.82rem; flex:1; }
.owner-filter-tab:hover { background:#eef5ff; color:#0d6efd; }
.owner-filter-tab.active { background:#0d6efd; color:#fff; }
.crm-owner-filter-list { max-height:280px; overflow:auto; padding:.25rem; }
.owner-filter-option { border-radius:.4rem; margin:.1rem 0; }
.owner-filter-option:hover, .owner-filter-option.selected { background:#eaf2ff; }
.owner-filter-icon { width:28px; height:28px; border-radius:50%; background:#dceaff; color:#0d6efd; display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; }
.owner-filter-icon.team { background:#eadcff; color:#7c3aed; }

/* Final three-area A2 navigation: dark blended area switcher. */
.area-switcher-wrap { border-top: 1px solid rgba(255,255,255,.12); flex: 0 0 auto; padding: .75rem 10px .9rem; background: #1f293b; position: relative; z-index: 1060; }
.area-switcher-button {
    width: 100%; border: 1px solid #334155; background: #26364a; color: #f9fafb;
    border-radius: 8px; min-height: 50px; padding: .45rem .55rem; display:flex; align-items:center;
    gap:.65rem; text-align:left; transition: background .15s ease, border-color .15s ease;
}
.area-switcher-button:hover, .area-switcher-button:focus { background:#30445c; border-color:#475569; color:#fff; }
.area-current-text { flex:1; min-width:0; }
.area-current-text strong { display:block; font-size:.86rem; line-height:1.1; }
.area-chevron { color:#94a3b8; font-size:.75rem; }
.area-icon { width:30px; height:30px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; }
.area-sales { background:#3b82f6; color:#fff; }
.area-service { background:#10b981; color:#fff; }
.area-admin { background:#8b5cf6; color:#fff; }
.area-switcher-menu {
    min-width: 310px; padding:.5rem; background:#26364a; border:1px solid #334155; border-radius:10px;
    box-shadow:0 14px 35px rgba(15,23,42,.35); color:#f9fafb;
    margin-bottom: .45rem !important;
}
.area-switcher-wrap .dropup .dropdown-menu {
    bottom: calc(100% + .45rem);
    top: auto;
    left: 0;
    right: auto;
    transform: none !important;
    z-index: 1070;
}
.area-switcher-title { color:#9ca3af; font-size:.75rem; text-transform:uppercase; letter-spacing:.05em; padding:.35rem .55rem .5rem; }
.area-option {
    display:flex; align-items:center; gap:.65rem; position:relative; color:#f9fafb; text-decoration:none;
    padding:.65rem .55rem; border-radius:8px;
}
.area-option:hover, .area-option.selected { background:#30445c; color:#fff; }
.area-option > span:nth-child(2) { flex:1; min-width:0; }
.area-option strong { display:block; font-size:.86rem; }
.area-option small { display:block; color:#9ca3af; margin-top:.12rem; line-height:1.25; }
.area-check { color:#3b82f6; font-size:1rem; }
.crm-sidebar.collapsed .area-label,
.crm-sidebar.collapsed .area-current-text,
.crm-sidebar.collapsed .area-chevron { display:none; }
.crm-sidebar.collapsed .area-switcher-button { justify-content:center; padding:.5rem; }
.crm-sidebar.collapsed .area-switcher-wrap { padding-left: 8px; padding-right: 8px; }
.crm-sidebar.collapsed .area-switcher-menu { left: calc(100% + .5rem) !important; bottom: 0 !important; top: auto !important; right: auto !important; transform: none !important; }
.dashboard-period-btn { min-width: 150px; justify-content:space-between; }
.dashboard-period-menu { min-width: 190px; }
.dashboard-period-menu .dropdown-item { display:flex; align-items:center; justify-content:space-between; }
.dashboard-period-menu .dropdown-item.active { background:#eaf2ff; color:#0d6efd; }

.kpi-yellow { background:#fffaf2; border-color:#f4dfbc; }.kpi-yellow .kpi-icon { background:#ffebc5; color:#d97706; }

/* Searchable country/state reference-data lookups */
.location-lookup { position: relative; }
.location-lookup-control { min-height: 38px; display:flex; align-items:center; justify-content:space-between; background:#fff; }
.location-lookup-control:disabled { background:#f8fafc; color:#94a3b8; cursor:not-allowed; }
.location-lookup-panel { position:absolute; z-index:1060; top:calc(100% + 4px); left:0; right:0; min-width:280px; background:#fff; border:1px solid #cbd5e1; border-radius:.5rem; box-shadow:0 12px 30px rgba(15,23,42,.16); overflow:hidden; }
.location-lookup-list { max-height:280px; overflow:auto; padding:.25rem; }
.location-option { width:100%; border:0; background:#fff; border-radius:.35rem; padding:.55rem .65rem; text-align:left; display:flex; align-items:center; justify-content:space-between; gap:.5rem; }
.location-option:hover, .location-option.selected { background:#eff6ff; color:#0f172a; }
.location-empty { padding:.75rem; color:#64748b; font-size:.875rem; }


/* Hybrid grid filtering: global search + per-column sort/filter menus. */
.crm-grid-toolbar { background:#f8fafc; }
.crm-column-head { position:relative; display:inline-flex; align-items:center; gap:.15rem; white-space:nowrap; }
.crm-column-filter-button { color:#64748b; padding:.05rem .2rem; line-height:1; text-decoration:none; }
.crm-column-filter-button:hover,.crm-column-filter-button.active { color:#0d6efd; }
.crm-column-filter-button.active { font-weight:700; }
.crm-column-menu { position:absolute; z-index:1080; top:calc(100% + 6px); left:0; min-width:250px; max-width:320px; padding:.75rem; background:#fff; border:1px solid #cbd5e1; border-radius:.55rem; box-shadow:0 14px 35px rgba(15,23,42,.18); text-transform:none; letter-spacing:normal; font-size:.875rem; color:#0f172a; font-weight:400; }
.crm-column-menu .dropdown-item { display:block; padding:.35rem .5rem; border-radius:.35rem; color:#334155; text-decoration:none; }
.crm-column-menu .dropdown-item:hover { background:#f1f5f9; }
.crm-grid thead th { position:relative; overflow:visible; }
.crm-grid thead { position:relative; z-index:5; }
.crm-grid .crm-sort-link { display:inline-flex; align-items:center; gap:.15rem; }
@media (max-width: 768px) { .crm-column-menu { position:fixed; left:50%; transform:translateX(-50%); top:20%; width:min(320px,calc(100vw - 24px)); } }
.crm-column-menu { min-width: 320px; max-height: 70vh; overflow:auto; }
.crm-menu-sort-links .dropdown-item { padding:.35rem .5rem; }
.crm-filter-search-wrap { position:relative; margin-bottom:.5rem; }
.crm-filter-search-wrap > i { position:absolute; left:.65rem; top:50%; transform:translateY(-50%); color:#64748b; z-index:2; }
.crm-filter-search-wrap > input { padding-left:2rem; }
.crm-filter-values { max-height:190px; overflow:auto; border:1px solid #e2e8f0; border-radius:.4rem; padding:.25rem; }
.crm-filter-check { display:flex; align-items:center; gap:.5rem; padding:.35rem .45rem; border-radius:.3rem; cursor:pointer; font-size:.875rem; }
.crm-filter-check:hover { background:#f8fafc; }
.crm-filter-check input { accent-color:#0d6efd; }


/* Reusable CRM entity lookup */
.crm-lookup { position: relative; }
.crm-lookup-control { position: relative; }
.crm-lookup-control > input { padding-right: 2.5rem; }
.crm-lookup-record-link { position:absolute; left:.75rem; right:auto; top:50%; transform:translateY(-50%); z-index:5; display:inline-block; width:max-content; max-width:calc(100% - 3.4rem); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; background:#fff; color:#0d6efd; text-decoration:none; border-radius:.2rem; padding-right:.25rem; pointer-events:auto; }
.crm-lookup-record-link:hover { text-decoration:underline; }
.crm-lookup-clear { position:absolute; right:.35rem; top:50%; transform:translateY(-50%); z-index:2; padding:.25rem .45rem; }
.crm-lookup-panel { position:absolute; z-index:1060; top:calc(100% + 4px); left:0; right:0; min-width:320px; max-height:320px; overflow:auto; background:#fff; border:1px solid #cbd5e1; border-radius:.5rem; box-shadow:0 12px 30px rgba(15,23,42,.16); }
.crm-lookup-result { width:100%; border:0; background:#fff; display:flex; align-items:center; gap:.65rem; padding:.65rem .75rem; text-align:left; }
.crm-lookup-result:hover,.crm-lookup-result.active { background:#eef5ff; }
.crm-lookup-results { padding:.2rem; }
.crm-lookup-empty { padding:.8rem .75rem; color:#64748b; font-size:.82rem; text-align:left; background:#fff; }
.crm-lookup-result-icon { width:30px; height:30px; border-radius:.4rem; display:inline-flex; align-items:center; justify-content:center; background:#edf4ff; color:#0d6efd; flex:0 0 auto; }
.crm-global-search { max-width:650px; flex:0 1 650px !important; }

/* Shared entity grid/form standards */
.crm-global-search { flex: 0 1 650px !important; max-width: 650px; min-width: 280px; }
.crm-grid-toolbar { min-height: 68px; }
.crm-grid th { white-space: nowrap; }
.crm-column-menu .dropdown-item { cursor: pointer; }
.crm-column-menu { min-width: 320px; max-height: 70vh; overflow:auto; }

.crm-bpf{background:#fff;border:1px solid #dee2e6;border-radius:.5rem;padding:.7rem .9rem;box-shadow:0 .125rem .25rem rgba(0,0,0,.04)}
.crm-bpf-track{display:flex;align-items:flex-start;gap:0;overflow-x:auto;padding:0 .8rem .15rem}.crm-bpf-stage{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;min-width:150px;white-space:nowrap;padding:.05rem .35rem .35rem;color:#596273;font-size:.82rem;text-align:center}.crm-bpf-stage::before{content:"";position:absolute;top:.8rem;left:0;right:0;height:2px;background:#cfd6df;z-index:0}.crm-bpf-stage:first-child::before{left:50%}.crm-bpf-stage:last-child::before{right:50%}.crm-bpf-index{position:relative;z-index:1;width:1.8rem;height:1.8rem;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:#fff;border:2px solid #728096;color:#536174;font-size:.72rem;font-weight:600;margin-bottom:.45rem}.crm-bpf-stage.active{color:#0d6efd;font-weight:700}.crm-bpf-stage.active .crm-bpf-index{background:#0d6efd;border-color:#0d6efd;color:#fff;box-shadow:0 0 0 3px rgba(13,110,253,.12)}.crm-bpf-stage.active::before,.crm-bpf-stage.completed::before{background:#0d6efd}.crm-bpf-stage.completed .crm-bpf-index{background:#0d6efd;border-color:#0d6efd;color:#fff}.crm-bpf-stage.completed{color:#0d6efd;font-weight:600}
.crm-loading-overlay{position:fixed;inset:0;background:rgba(255,255,255,.82);display:flex;align-items:center;justify-content:center;z-index:2000}.crm-loading-card{background:#fff;border:1px solid #dee2e6;border-radius:.75rem;padding:2rem 2.5rem;text-align:center;box-shadow:0 .5rem 2rem rgba(0,0,0,.15)}

/* Final CRM content containment: prevent navigation/floating UI from clipping form content. */
.crm-main { position: relative; overflow-x: hidden; min-width: 0; }
.crm-content { min-width: 0; max-width: 100%; overflow-x: visible; overflow-y: visible; }
.crm-form-header { position: relative; z-index: 2; }

/* WhatsApp + AI import */
.nav-new-badge{display:inline-flex;align-items:center;padding:.08rem .35rem;margin-left:.3rem;border-radius:999px;background:#22c55e;color:#fff;font-size:.62rem;font-weight:700;vertical-align:middle}.crm-sidebar.collapsed .nav-new-badge{display:none}
.whatsapp-card,.ai-import-card{background:#fff;border:1px solid #e2e8f0;border-radius:.6rem;box-shadow:0 .125rem .25rem rgba(0,0,0,.04)}
.feature-card-header{display:flex;align-items:center;gap:.7rem;padding:1rem 1.1rem;border-bottom:1px solid #e5e7eb}.feature-icon{width:42px;height:42px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:1.35rem}.feature-icon.whatsapp{background:#dcfce7;color:#16a34a}.feature-icon.ai{background:#f0e7ff;color:#7c3aed}.feature-tabs{display:flex;border-bottom:1px solid #e5e7eb}.feature-tab{border:0;background:#fff;padding:.7rem 1rem;font-weight:600;color:#475569;border-bottom:2px solid transparent}.feature-tab.active{color:#0d6efd;border-bottom-color:#0d6efd}.message-preview{background:#f8fafc;border:1px solid #e2e8f0;border-radius:.45rem;padding:.85rem;white-space:pre-wrap;min-height:190px;font-size:.92rem;line-height:1.55}.ai-stepper{display:flex;align-items:flex-start;gap:0;margin:1rem 0}.ai-step{position:relative;flex:1;text-align:center;color:#64748b;font-size:.78rem}.ai-step:not(:last-child)::after{content:"";position:absolute;top:14px;left:50%;width:100%;height:2px;background:#cbd5e1;z-index:0}.ai-step-number{position:relative;z-index:1;width:29px;height:29px;border:2px solid #94a3b8;background:#fff;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-weight:700}.ai-step.active{color:#0d6efd;font-weight:700}.ai-step.active .ai-step-number{background:#0d6efd;border-color:#0d6efd;color:#fff}.ai-upload{border:1.5px dashed #60a5fa;border-radius:.6rem;background:#f8fbff;padding:2rem 1rem;text-align:center}.ai-upload-icon{font-size:2rem;color:#0d6efd}.ai-table-wrap{overflow:auto;max-height:360px}.ai-table td,.ai-table th{white-space:nowrap;vertical-align:middle}.ai-table input{min-width:110px}.ai-tip{background:#eff6ff;border:1px solid #bfdbfe;border-radius:.5rem;padding:.85rem}.ai-provider{color:#64748b;font-size:.78rem}.ai-empty{padding:2rem;text-align:center;color:#64748b}

/* Lookup selected-record navigation links (D365-style). */
.crm-lookup-control.has-selection > input[data-lookup-search] { color: transparent; caret-color: transparent; pointer-events: none; }
.crm-lookup-record-link:hover { text-decoration: underline; }
.owner-lookup-control { position: relative; display: flex; align-items: center; cursor: pointer; }
.owner-lookup-control .owner-lookup-record-link { color: #0d6efd; text-decoration: none; flex: 0 1 auto; width: max-content; max-width: calc(100% - 2rem); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: .5rem; }
.owner-lookup-control .owner-lookup-record-link:hover { text-decoration: underline; }
.owner-lookup-control [data-owner-selected] { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owner-lookup-control:has([data-owner-link]:not([hidden])) [data-owner-selected] { display: none; }

.crm-global-flash { margin-bottom: 1rem; box-shadow: 0 .125rem .25rem rgba(0,0,0,.06); }

/* AI Data Import - intelligent mapping workflow */
.ai-import-section{border:1px solid #e2e8f0;border-radius:.65rem;padding:1rem 1.1rem;background:#fff;margin-top:1rem}.ai-import-section.active{border-color:#dbeafe}.ai-section-heading{display:flex;align-items:flex-start;gap:.75rem}.ai-section-number{width:34px;height:34px;border-radius:50%;background:#0d6efd;color:#fff;display:inline-flex;align-items:center;justify-content:center;font-weight:700;flex:0 0 auto}.ai-file-control{max-width:520px}.ai-progress-panel{border-top:1px solid #e5e7eb;padding-top:1.15rem}.ai-progress{height:10px;border-radius:999px;background:#e5e7eb;overflow:hidden}.ai-progress .progress-bar{background:#0d6efd;transition:width .25s ease}.ai-progress-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.75rem}.ai-progress-stage{display:flex;align-items:center;gap:.5rem;color:#64748b;font-size:.85rem}.ai-progress-stage .ai-stage-icon{width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center}.ai-progress-stage.done{color:#15803d}.ai-progress-stage.done .ai-stage-icon{color:#15803d}.ai-progress-stage.current{color:#0d6efd;font-weight:600}.ai-progress-stage.current .ai-stage-icon{color:#0d6efd}.ai-progress-stage.current .ai-stage-icon i{animation:aiSpin 1s linear infinite}.ai-wait-note{padding:.75rem .9rem;border:1px solid #bfdbfe;background:#eff6ff;border-radius:.5rem;color:#1e3a5f;font-size:.85rem}.ai-detected-card{display:grid;grid-template-columns:1.2fr .7fr 1.2fr;gap:1rem;align-items:center;border:1px solid #dbeafe;background:#f8fbff;border-radius:.55rem;padding:.9rem 1rem}.ai-confidence strong,.ai-mapping-count strong{font-size:1.05rem}.ai-mapping-wrap{max-height:320px;overflow:auto}.ai-mapping-wrap th{white-space:nowrap}.ai-mapping-wrap td{min-width:170px}.ai-mapping-wrap td:first-child{min-width:190px}.ai-tip{margin-top:1rem}.ai-import-card{background:#fff}.ai-table-wrap{overflow:auto;max-height:390px}.ai-table td,.ai-table th{white-space:nowrap;vertical-align:middle}.ai-table input{min-width:120px}.ai-empty{padding:2rem;text-align:center;color:#64748b}.ai-import-section .form-text{font-size:.75rem}.ai-import-section .alert{margin-top:.75rem}.ai-upload-row .form-label{margin-bottom:.4rem}.ai-upload-row .form-control,.ai-upload-row .form-select{height:38px}.ai-upload-row .ai-extract-col{padding-top:1.85rem;display:flex;align-items:flex-start}.ai-upload-row .ai-extract-col #extractButton{width:180px !important;max-width:180px;flex:0 0 180px}.ai-upload-row > [class*="col-lg-"]{min-width:0}.ai-upload-row .form-select,.ai-upload-row .ai-file-control{width:100%;max-width:none}.ai-file-control{max-width:none;width:100%}@keyframes aiSpin{to{transform:rotate(360deg)}}
@media (max-width: 992px){.ai-progress-grid{grid-template-columns:1fr 1fr}.ai-detected-card{grid-template-columns:1fr}.ai-file-control{max-width:none}.ai-upload-row .ai-extract-col #extractButton{width:100% !important;max-width:100%;flex:1 1 auto}}
@media (max-width: 576px){.ai-progress-grid{grid-template-columns:1fr}.ai-import-section{padding:.85rem}.ai-section-heading{gap:.6rem}}

/* Common record navigation */
.crm-record-navigation { white-space: nowrap; }
.crm-record-nav-btn { min-width: 104px; }
.crm-record-nav-position { min-width: 68px; text-align: center; font-variant-numeric: tabular-nums; }
.crm-record-navigation.is-loading .crm-record-nav-btn { pointer-events: none; opacity: .65; }
@media (max-width: 992px) {
    .crm-record-navigation { order: 3; width: 100%; justify-content: flex-start; margin-top: .25rem; }
}

/* Global CRM notifications: consistent Bootstrap UI instead of browser-native alerts. */
.crm-notification-host {
    position: fixed;
    top: 4.5rem;
    right: 1.25rem;
    width: min(420px, calc(100vw - 2rem));
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    pointer-events: none;
}
.crm-notification-host .crm-notification {
    pointer-events: auto;
    box-shadow: 0 .5rem 1.25rem rgba(0,0,0,.12);
}

/* Global CRM operation/loading screen. Reused by forms, navigation and API/fetch calls. */
.crm-operation-loader {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .34);
    backdrop-filter: blur(1.5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .16s ease, visibility .16s ease;
}
.crm-operation-loader.is-visible {
    opacity: 1;
    visibility: visible;
}
.crm-operation-loader[hidden] { display: none !important; }
.crm-operation-loader-card {
    min-width: 260px;
    max-width: min(420px, calc(100vw - 2rem));
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1rem 1.15rem;
    border: 1px solid #dce5ef;
    border-radius: .65rem;
    background: #fff;
    box-shadow: 0 .75rem 2rem rgba(15,23,42,.18);
}
.crm-operation-loader-card .spinner-border { width: 1.8rem; height: 1.8rem; flex: 0 0 auto; }
.crm-operation-loader-title { font-weight: 600; color: #1e293b; }
.crm-operation-loader-text { margin-top: .1rem; color: #64748b; font-size: .875rem; }

/* Shared entity-grid visual standard: use the Lead grid layout across all entities. */
.crm-grid-toolbar .crm-global-search { flex: 1 1 auto; min-width: 260px; max-width: 620px; }
.crm-grid-empty-state { min-height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.crm-grid-empty-state .display-6 { color: #64748b; }

/* Dynamics-style compact form header cards (frozen UI standard) */
.crm-header-cards {
    display:flex;
    justify-content:flex-end;
    align-items:stretch;
    gap:.55rem;
    margin:0 0 .75rem;
    width:100%;
}
.crm-header-card {
    flex:0 1 180px;
    min-width:150px;
    min-height:56px;
    height:56px;
    display:flex;
    align-items:center;
    gap:.55rem;
    padding:.45rem .6rem;
    border:1px solid #dce5ef;
    border-radius:.55rem;
    background:#fff;
    box-shadow:0 2px 8px rgba(15,23,42,.03);
    transition:background .18s ease,border-color .18s ease,box-shadow .18s ease;
}
.crm-header-card-icon {
    width:34px;
    height:34px;
    flex:0 0 34px;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    background:#edf4ff;
    color:#0d6efd;
    font-size:.95rem;
}
.crm-header-card-body { min-width:0; flex:1; }
.crm-header-card-label { font-size:.68rem; line-height:1.1; color:#475569; font-weight:600; margin-bottom:.18rem; }
.crm-header-input, .crm-header-select {
    height:27px;
    min-height:27px;
    padding:.08rem .45rem;
    font-size:.72rem;
    line-height:1.2;
    border-radius:.3rem;
}
.crm-header-select { padding-right:1.65rem; }
.crm-header-card-status { background:#f3fff8; border-color:#cdeedc; }
.crm-header-card-status .crm-header-card-icon { background:#dff6e8;color:#16a34a; }
.crm-header-card-source { background:#fffaf0; border-color:#f2dfb4; }
.crm-header-card-source .crm-header-card-icon { background:#ffedc7;color:#d97706; }
.crm-header-card-owner { background:#f4f8ff; border-color:#cfe0ff; }
.crm-header-card-owner .crm-header-card-icon { background:#dceaff;color:#0d6efd; }
.crm-header-card-owner .owner-lookup { width:100%; }
.crm-record-status-card { background:#f8fafc; border-color:#dbe4ee; }
.crm-record-status-card .crm-header-card-icon { background:#e9eef5; color:#475569; }
.crm-record-status-card .crm-header-select:disabled { opacity:1; background-color:#fff; color:#334155; cursor:not-allowed; }
.crm-form-section > .row > .col-md-6 { width:50%; }
@media (max-width:700px) { .crm-form-section > .row > .col-md-6 { width:100%; } }
.crm-header-card-owner .owner-lookup-control { min-height:27px; height:27px; border:1px solid #d7e0eb; border-radius:.3rem; padding:.15rem .4rem; font-size:.72rem; }
.crm-rating-card { background:#eff7ff; border-color:#cfe0ff; }
.crm-rating-card .crm-header-card-icon { background:#dceaff;color:#0d6efd; }
.crm-rating-card.rating-cold { background:#f1fff6; border-color:#bfe8cf; }
.crm-rating-card.rating-cold .crm-header-card-icon { background:#d9f5e3;color:#16a34a; }
.crm-rating-card.rating-warm { background:#eff7ff; border-color:#cfe0ff; }
.crm-rating-card.rating-warm .crm-header-card-icon { background:#dceaff;color:#0d6efd; }
.crm-rating-card.rating-hot { background:#fff1f2; border-color:#fecdd3; }
.crm-rating-card.rating-hot .crm-header-card-icon { background:#ffe0e5;color:#dc2626; }
.crm-header-cards .crm-lookup { width:100%; }
.crm-header-cards .crm-lookup > .form-label { display:none; }
.crm-header-cards .crm-lookup-control { min-height:27px; height:27px; font-size:.72rem; padding:.15rem .4rem; }
.crm-header-cards .location-lookup-control { min-height:27px; height:27px; font-size:.72rem; padding:.15rem .4rem; }
@media (max-width:1100px) {
    .crm-header-card { flex-basis:170px; }
}
@media (max-width:800px) {
    .crm-header-cards { flex-wrap:wrap; }
    .crm-header-card { flex:1 1 calc(50% - .3rem); min-width:0; }
    .crm-header-card-owner { flex:1 1 calc(50% - .3rem); width:auto; min-width:0; max-width:none; }
}
@media (max-width:480px) {
    .crm-header-card { flex-basis:100%; }
    .crm-header-card-owner { flex:1 1 100%; width:auto; min-width:0; max-width:none; }
}

/* Frozen two-level CRM header + global search */
.crm-global-header {
    min-height:64px;
    padding:0 24px;
    background:#0b3b78;
    border-bottom:0;
    color:#fff;
    gap:1rem;
}
.crm-global-brand { display:flex; align-items:center; gap:.75rem; flex:0 0 auto; }
.crm-global-brand .navbar-brand { color:#fff; font-weight:700; letter-spacing:.01em; }
.crm-brand-mark { width:34px; height:34px; border-right:1px solid rgba(255,255,255,.3); padding-right:.75rem; box-sizing:content-box; display:inline-flex; align-items:center; color:#38bdf8; font-size:1.25rem; }
.crm-global-search-wrap { position:relative; flex:1 1 620px; max-width:620px; margin:0 auto; }
.crm-global-search-wrap > i { position:absolute; left:.9rem; top:50%; transform:translateY(-50%); z-index:2; color:#173b68; }
.crm-global-search-input { height:40px; padding-left:2.55rem; padding-right:5.5rem; border:0; border-radius:.45rem; background:#fff; color:#17233f; box-shadow:0 2px 8px rgba(0,0,0,.12); }
.crm-global-search-input:focus { box-shadow:0 0 0 3px rgba(56,189,248,.35); }
.crm-search-shortcut { position:absolute; right:.65rem; top:50%; transform:translateY(-50%); font-size:.68rem; color:#64748b; background:#f1f5f9; border:1px solid #dbe3ec; border-radius:.25rem; padding:.18rem .4rem; pointer-events:none; }
.crm-global-search-results { position:absolute; left:0; right:0; top:calc(100% + 8px); z-index:1080; background:#fff; color:#17233f; border:1px solid #dbe3ec; border-radius:.55rem; box-shadow:0 16px 40px rgba(15,23,42,.2); overflow:hidden; max-height:430px; overflow-y:auto; }
.crm-global-search-result { display:flex; align-items:center; gap:.7rem; width:100%; padding:.7rem .85rem; border:0; background:#fff; text-align:left; color:#17233f; text-decoration:none; }
.crm-global-search-result:hover,.crm-global-search-result.active { background:#eff6ff; }
.crm-global-search-result-icon { width:32px; height:32px; flex:0 0 32px; border-radius:.45rem; display:inline-flex; align-items:center; justify-content:center; background:#eaf2ff; color:#0d6efd; }
.crm-global-search-result-main { min-width:0; flex:1; }
.crm-global-search-result-name { font-size:.84rem; font-weight:650; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.crm-global-search-result-detail { font-size:.72rem; color:#64748b; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.crm-global-search-result-type { font-size:.65rem; color:#64748b; background:#f8fafc; border:1px solid #e2e8f0; border-radius:999px; padding:.12rem .4rem; }
.crm-global-search-empty { padding:1rem; text-align:center; color:#64748b; font-size:.82rem; }
.crm-global-actions { flex:0 0 auto; }
.crm-profile-button { display:flex; align-items:center; gap:.5rem; color:#fff; border:0; background:transparent; padding:.25rem .2rem; }
.crm-profile-button:hover,.crm-profile-button:focus { color:#fff; background:rgba(255,255,255,.08); }
.crm-profile-button::after { margin-left:.15rem; }
.crm-profile-menu { min-width:280px; padding:.5rem; border:1px solid #dbe3ec; box-shadow:0 14px 32px rgba(15,23,42,.18); }
.crm-profile-summary { display:flex; gap:.7rem; align-items:center; padding:.55rem .5rem; }
.crm-profile-summary > div { min-width:0; }
.crm-profile-summary strong,.crm-profile-summary small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.crm-profile-summary small { color:#64748b; font-size:.72rem; margin-top:.1rem; }
.crm-profile-menu form { margin:0; }

.crm-form-action-bar { display:flex; align-items:center; justify-content:space-between; gap:1rem; min-height:56px; padding:.65rem .8rem; margin-bottom:.9rem; background:#fff; border:1px solid #dfe6ef; border-radius:.55rem; box-shadow:0 2px 8px rgba(15,23,42,.04); position:relative; z-index:1; }
.crm-form-action-left,.crm-form-action-right { display:flex; align-items:center; gap:.45rem; min-width:0; }
.crm-form-action-right { flex-wrap:wrap; justify-content:flex-end; }
.crm-form-action-bar .btn { white-space:nowrap; }
/* The complete record header is sticky as one unit: command bar + title/header cards + BPF.
   The Details/Notes area below remains the scrolling content. */
.crm-record-fixed-header {
    flex: 0 0 auto;
    position: relative;
    z-index: 1035;
    background: #f8fafc;
    padding: 16px 24px 10px;
    box-shadow: 0 8px 14px rgba(15,23,42,.04);
}
.crm-record-fixed-header .crm-form-action-bar {
    position: relative;
    top: auto;
    z-index: auto;
    margin-bottom: .65rem;
}
.crm-record-fixed-header .crm-bpf {
    margin-bottom: 0 !important;
}
.crm-record-fixed-header .crm-form-title-header-row {
    margin-bottom: .65rem;
}

/* Record forms use a dedicated viewport. Only the area beginning at Details/Notes
   scrolls; the CRM header, command bar, record cards and BPF remain stationary. */
.crm-main:has(.crm-record-page) {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.crm-main:has(.crm-record-page) .crm-content {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: hidden;
    padding: 0;
}
.crm-record-page {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.crm-record-scroll-region {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 24px 28px;
    scrollbar-gutter: stable;
}
@media (max-width: 768px) {
    .crm-record-fixed-header { padding: 12px 16px 8px; }
    .crm-record-scroll-region { padding: 0 16px 24px; }
}

.crm-form-title-header-row { display:flex; align-items:center; gap:1rem; width:100%; margin-bottom:.75rem; min-width:0; }
.crm-form-title-header-row .crm-form-title-row { flex:0 1 auto; min-width:max-content; margin-bottom:0; }
.crm-form-title-header-row .crm-header-cards { flex:1 1 auto; min-width:0; width:auto; margin:0; justify-content:flex-end; }
.crm-responsive-header-details { flex:1 1 auto; min-width:0; }
.crm-responsive-header-toggle { display:none; }
.crm-responsive-header-panel { min-width:0; }
.crm-responsive-header-summary { display:none; }
.crm-form-title-row { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:.2rem; }
.crm-form-title-row h1 { color:#17233f; font-weight:700; }
.crm-form-title-row a { color:#46627f; }
.crm-assign-modal-dialog { max-width:470px; }
.crm-assign-modal-dialog .modal-content { border:0; border-radius:.7rem; box-shadow:0 20px 50px rgba(15,23,42,.25); }
.crm-assign-modal-dialog .modal-footer .crm-record-navigation { margin-right:auto; }

@media (max-width:1100px) {
    .crm-form-title-header-row { flex-wrap:wrap; align-items:center; }
    .crm-form-title-header-row .crm-responsive-header-details { flex-basis:100%; }
}

/* Mobile/tablet form-header compression: keep only a compact Record Summary visible
   until the user explicitly expands the header fields. Desktop remains unchanged. */
@media (max-width:1024px) {
    .crm-form-title-header-row { align-items:stretch; }
    .crm-form-title-header-row .crm-form-title-row { flex:1 1 100%; min-width:0; }
    .crm-responsive-header-details { flex:1 1 100%; width:100%; }
    .crm-responsive-header-toggle {
        width:100%;
        display:flex;
        align-items:center;
        justify-content:space-between;
        gap:.75rem;
        min-height:52px;
        padding:.55rem .7rem;
        border:1px solid #d7e2ee;
        border-radius:.55rem;
        background:#fff;
        color:#17233f;
        box-shadow:0 2px 7px rgba(15,23,42,.04);
        text-align:left;
        cursor:pointer;
    }
    .crm-responsive-header-toggle:hover { background:#f8fbff; }
    .crm-responsive-header-toggle-main {
        min-width:0;
        display:flex;
        align-items:center;
        gap:.5rem;
        flex:1 1 auto;
    }
    .crm-responsive-header-toggle-main > .bi:first-child {
        width:30px; height:30px; flex:0 0 30px;
        display:inline-flex; align-items:center; justify-content:center;
        border-radius:50%; background:#eaf2ff; color:#0d6efd;
    }
    .crm-responsive-header-summary {
        display:block;
        min-width:0;
        flex:1 1 auto;
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
        color:#64748b;
        font-size:.72rem;
        font-weight:500;
    }
    .crm-responsive-header-chevron { flex:0 0 auto; color:#64748b; transition:transform .18s ease; }
    .crm-responsive-header-details.is-expanded .crm-responsive-header-chevron { transform:rotate(180deg); }
    .crm-responsive-header-panel {
        display:none;
        padding-top:.55rem;
    }
    .crm-responsive-header-details.is-expanded .crm-responsive-header-panel { display:block; }
    .crm-responsive-header-panel .crm-header-cards {
        flex-wrap:wrap;
        width:100%;
        margin:0;
        justify-content:stretch;
    }
}

@media (max-width:600px) {
    .crm-responsive-header-toggle { min-height:48px; padding:.45rem .6rem; }
    .crm-responsive-header-toggle-main > .bi:first-child { width:28px; height:28px; flex-basis:28px; }
    .crm-responsive-header-summary { font-size:.68rem; }
}

@media (max-width: 1000px) {
    .crm-global-search-wrap { max-width:420px; }
    .crm-form-action-bar { align-items:flex-start; flex-direction:column; }
    .crm-form-action-left,.crm-form-action-right { width:100%; }
    .crm-form-action-right { justify-content:flex-start; }
}
@media (max-width: 700px) {
    .crm-global-header { padding:0 12px; }
    .crm-global-brand .navbar-brand { display:none; }
    .crm-global-search-wrap { min-width:0; max-width:none; }
    .crm-global-actions .topbar-icon { display:none; }
    .crm-profile-button .user-name { display:none; }
    .crm-form-action-bar { padding:.55rem; }
    .crm-form-action-left,.crm-form-action-right { flex-wrap:wrap; }
    .crm-global-search-results { position:fixed; left:12px; right:12px; top:68px; }
}

/* Global search functional-state styling */
.crm-global-search-summary { padding:.48rem .85rem; font-size:.68rem; font-weight:700; color:#64748b; background:#f8fafc; border-bottom:1px solid #e2e8f0; }
.crm-global-search-loading { padding:1rem; text-align:center; color:#475569; font-size:.82rem; }

/* Notes - uses the existing frozen CRM form/card language without changing the global UI. */
.crm-notes-panel { overflow:visible; }
.crm-notes-panel .card-header { min-height:58px; }
.crm-notes-search-wrap { position:relative; width:min(360px, 42vw); }
.crm-notes-search-wrap > i { position:absolute; left:.75rem; top:50%; transform:translateY(-50%); color:#64748b; z-index:2; pointer-events:none; }
.crm-notes-search-wrap input { padding-left:2.15rem; padding-right:2.2rem; height:36px; }
.crm-notes-search-clear { position:absolute; right:.35rem; top:50%; transform:translateY(-50%); border:0; background:transparent; color:#64748b; padding:.25rem .4rem; z-index:3; }
.crm-notes-composer { border:1px solid #dfe6ef; border-radius:.5rem; background:#f8fafc; padding:.75rem; }
.crm-notes-editor { min-height:118px; resize:vertical; line-height:1.5; border-color:#d7e0eb; background:#fff; }
.crm-notes-editor:focus { border-color:#86b7fe; box-shadow:0 0 0 .2rem rgba(13,110,253,.12); }
.crm-notes-character-count { font-variant-numeric:tabular-nums; }
.crm-note-item { display:flex; gap:.8rem; padding:1rem .25rem; border-top:1px solid #e8edf3; }
.crm-note-item:first-child { border-top:0; }
.crm-note-avatar { width:38px; height:38px; flex:0 0 38px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:#e7f0ff; color:#0d6efd; font-weight:700; font-size:.85rem; }
.crm-note-content { min-width:0; flex:1; }
.crm-note-author { color:#17233f; font-size:.9rem; }
.crm-note-date { color:#64748b; font-size:.75rem; margin-left:.55rem; }
.crm-note-text { white-space:pre-wrap; overflow-wrap:anywhere; color:#334155; font-size:.9rem; line-height:1.55; margin-top:.35rem; }
.crm-note-menu { line-height:1; }
.crm-note-item .dropdown-menu { min-width:130px; }
.crm-notes-empty,.crm-notes-search-empty { padding:2rem 1rem; text-align:center; color:#64748b; }
.crm-notes-empty > i,.crm-notes-search-empty > i { font-size:1.75rem; color:#94a3b8; }
@media (max-width:700px) { .crm-notes-panel .card-header { align-items:flex-start!important; flex-direction:column; } .crm-notes-search-wrap { width:100%; } .crm-note-date { display:block; margin:.15rem 0 0; } }


/* Dynamics-style form sections and same-form tabs. */
.crm-form-sections-grid {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:1rem;
  align-items:start;
}

/* Lead form layout: keep Contact Information and Connection & Follow-up in
   the same right column so connection fields sit directly below contact. */
.crm-lead-form-grid {
  grid-template-areas:
    "lead contact"
    "interest followup"
    "description description";
}
.crm-lead-details-section { grid-area:lead; }
.crm-lead-contact-section { grid-area:contact; }
.crm-lead-followup-section { grid-area:followup; }
.crm-lead-interest-section { grid-area:interest; }
.crm-lead-description-section { grid-area:description; }

/* Keep the lead details block compact without changing its fields. */
.crm-lead-form-grid .crm-lead-details-section > .row {
  padding-top:.7rem;
  padding-bottom:.7rem;
  row-gap:.65rem;
}
.crm-lead-form-grid .crm-lead-details-section .form-label { margin-bottom:.2rem; }
.crm-lead-form-grid .crm-lead-details-section .form-control {
  min-height:36px;
  padding-top:.3rem;
  padding-bottom:.3rem;
}
.crm-form-section {
  margin:0;
  padding:0;
  border:1px solid #dfe7f1;
  border-radius:10px;
  background:#fff;
  box-shadow:0 1px 3px rgba(18,38,63,.06);
  overflow:hidden;
  min-width:0;
}
.crm-form-section-title {
  display:flex;
  align-items:center;
  gap:.55rem;
  min-height:46px;
  margin:0;
  padding:.65rem .9rem;
  border-bottom:1px solid #e5ebf3;
  background:#fbfcfe;
  color:#17233f;
  font-weight:650;
  font-size:.95rem;
}
.crm-form-section-title::after {
  content:none;
  display:none;
}
.crm-form-section-title i {
  width:28px;
  height:28px;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#edf4ff;
  color:#0d6efd;
  font-size:.82rem;
  flex:0 0 28px;
}
.crm-form-section > .row { padding:.9rem; margin:0; }
.crm-form-section > .row > [class*='col-'] { padding-left:.45rem; padding-right:.45rem; }
@media (max-width: 992px) {
  .crm-form-sections-grid { grid-template-columns:1fr; }
  .crm-lead-form-grid {
    grid-template-areas:
      "lead"
      "contact"
      "followup"
      "interest"
      "description";
  }
}
.crm-form-tabs { display:flex; align-items:center; gap:.15rem; border-bottom:1px solid #dfe6ef; margin-bottom:.85rem; background:#fff; }
.crm-form-tab { border:0; border-bottom:3px solid transparent; background:transparent; color:#475569; padding:.72rem 1rem; font-weight:600; font-size:.88rem; display:inline-flex; align-items:center; gap:.45rem; }
.crm-form-tab:hover { color:#0d6efd; background:#f8fbff; }
.crm-form-tab.active { color:#0d6efd; border-bottom-color:#0d6efd; background:#fff; }
.crm-form-tab-count { min-width:22px; height:20px; padding:0 .4rem; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; background:#edf4ff; color:#0d6efd; font-size:.68rem; }
.crm-form-tab-pane { display:none; }
.crm-form-tab-pane.active { display:block; }
@media (max-width:700px) { .crm-form-tabs { overflow-x:auto; } .crm-form-tab { white-space:nowrap; } }

/* Owner lookup in the header must stay inside the viewport when the Owner card
   is close to the right edge. Keep the normal lookup positioning elsewhere. */
.crm-header-card-owner .owner-lookup-panel {
    left: auto;
    right: 0;
    width: min(360px, calc(100vw - 24px));
    min-width: 0;
    max-width: calc(100vw - 24px);
}

@media (max-width: 576px) {
    .crm-header-card-owner .owner-lookup-panel {
        right: 0;
        width: min(320px, calc(100vw - 16px));
        max-width: calc(100vw - 16px);
    }
}


/* Owner header cards must show the complete selected User/Team name. */
.crm-header-card-owner {
    flex: 0 1 260px;
    width: 260px;
    min-width: 260px;
    max-width: 260px;
}
.crm-header-card-owner .owner-lookup-control [data-owner-selected],
.crm-header-card-owner .owner-lookup-control .owner-lookup-record-link {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}
.crm-header-card-owner .owner-lookup-control .owner-lookup-record-link {
    max-width: calc(100% - 2.1rem);
}

/* Description uses the complete width of its entity form section. */
.crm-form-section .crm-description-textarea {
    display: block;
    width: 100%;
    min-width: 100%;
    min-height: 150px;
    resize: vertical;
}

/* Lead form refinements: explicit lookup search action and full-width description within its section. */
.crm-lookup-control { padding-right:2.45rem; }
.crm-lookup-search-button { position:absolute; right:.2rem; top:50%; transform:translateY(-50%); z-index:3; width:34px; height:34px; padding:0; display:inline-flex; align-items:center; justify-content:center; border-radius:.35rem; }
.crm-owner-search-button { position:absolute; right:.2rem; top:50%; transform:translateY(-50%); z-index:4; width:34px; height:34px; padding:0; display:inline-flex; align-items:center; justify-content:center; border-radius:.35rem; }
.owner-lookup-control { position:relative; padding-right:2.55rem !important; cursor:default !important; }
.crm-lookup-search-button + .crm-lookup-clear { right:2.25rem; }
.crm-lookup-control:has(.crm-lookup-search-button) > input { padding-right:2.55rem; }
.crm-description-textarea { width:100%; min-height:150px; resize:vertical; }
.crm-lead-description-section .row { padding-bottom:1rem; }
.crm-lead-description-section { min-height:100%; }
@media (max-width:700px) {
  .crm-lookup-search-button { width:32px; height:32px; }
}


/* Dashboard and entity grids use the same viewport model as record forms:
   the global CRM header remains outside the scroll container, while page content
   scrolls independently. Command/view/filter bars remain available while rows/cards scroll. */
.crm-main.crm-dashboard-page,
.crm-main.crm-list-page {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.crm-main.crm-dashboard-page .crm-content,
.crm-main.crm-list-page .crm-content {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}
.crm-main.crm-dashboard-page .dashboard-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #f8fafc;
    padding-top: 2px;
    padding-bottom: 12px;
}
.crm-main.crm-list-page .crm-command-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: #f8fafc;
    padding-top: 0;
    padding-bottom: 8px;
    margin-bottom: 0;
}
.crm-main.crm-list-page .crm-view-selector {
    position: sticky;
    top: 66px;
    z-index: 35;
}
.crm-main.crm-list-page .crm-grid-toolbar {
    position: sticky;
    top: 108px;
    z-index: 34;
}
@media (max-width: 768px) {
    .crm-main.crm-list-page .crm-view-selector { top: 104px; }
    .crm-main.crm-list-page .crm-grid-toolbar { top: 148px; }
    .crm-main.crm-list-page .crm-command-bar { padding-bottom: 8px; }
    .crm-main.crm-dashboard-page .crm-content,
    .crm-main.crm-list-page .crm-content { padding-top: 2px; }
}

/* Dashboard/list top spacing: keep page content close to the global header. */
.crm-main.crm-dashboard-page .crm-content,
.crm-main.crm-list-page .crm-content {
    padding-top: 2px;
}

/* Dashboard sticky-header overlap fix: the sticky header extends into the
   reduced content padding so the page title sits close to the global header
   while scrolled KPI/content remains covered. */
.crm-main.crm-dashboard-page .crm-content {
    position: relative;
}
.crm-main.crm-dashboard-page .dashboard-header {
    margin-top: -2px;
    padding-top: 4px;
    padding-bottom: 12px;
    box-shadow: 0 8px 14px rgba(15,23,42,.04);
    isolation: isolate;
}

/* Opaque cover above the sticky dashboard header. The KPI row is before the
   sticky header in the scroll flow, so this cover prevents scrolled KPI cards
   from appearing in the strip above the header while scrolling. */
.crm-main.crm-dashboard-page .dashboard-header::before {
    content: "";
    position: absolute;
    left: -24px;
    right: -24px;
    top: -120px;
    height: 120px;
    background: #f8fafc;
    z-index: -1;
    pointer-events: none;
}

/* Contact form compact spacing - keep the approved Dynamics-style layout while reducing vertical whitespace. */
.crm-contact-form > .card { margin-bottom: .5rem !important; }
.crm-contact-form .card-body { padding: .75rem !important; }
.crm-contact-form .crm-form-sections-grid { gap: .55rem; }
.crm-contact-form .crm-form-section-title { padding: .5rem .75rem; }
.crm-contact-form .crm-form-section > .row { padding: .6rem .7rem; row-gap: .55rem; }
.crm-contact-form .crm-form-section > .row > [class*="col-"] { padding-left: .35rem; padding-right: .35rem; }
.crm-contact-form .form-label { margin-bottom: .2rem; }
.crm-contact-form .form-control, .crm-contact-form .form-select { min-height: 34px; padding-top: .3rem; padding-bottom: .3rem; }
.crm-contact-form .text-danger { font-size: .72rem; }

/* Dynamics-style Project related Towers subgrid */
.crm-related-subgrid{background:#fff;border:1px solid #dfe7f2;border-radius:12px;overflow:hidden;box-shadow:0 1px 3px rgba(20,45,80,.04);margin-top:1rem}.crm-related-subgrid .table{margin:0}.crm-related-subgrid th{font-size:.78rem;text-transform:uppercase;letter-spacing:.03em;color:#5b6b7f;background:#f8fafc;white-space:nowrap}.crm-related-subgrid td{font-size:.9rem}.crm-related-subgrid a{color:#0d6efd;text-decoration:none}.crm-related-subgrid a:hover{text-decoration:underline}

/* Project lookup - intentionally mirrors the working Owner lookup interaction. */
.project-lookup { position:relative; }
.project-lookup-control { position:relative; min-height:38px; display:flex; align-items:center; background:#fff; }

.crm-project-search-button { position:absolute; right:.2rem; top:50%; transform:translateY(-50%); z-index:4; width:36px; height:36px; padding:0; display:inline-flex; align-items:center; justify-content:center; border-radius:.35rem; }
.project-lookup-clear { position:absolute; right:2.25rem; top:50%; transform:translateY(-50%); z-index:4; padding:.25rem .45rem; }
.project-lookup-control > input { padding-right:5rem; }
.project-lookup-control > .crm-project-search-button { flex:0 0 44px; }
.project-lookup-panel { position:absolute; left:0; top:calc(100% + 4px); width:100%; min-width:320px; max-height:360px; overflow:auto; z-index:2100; background:#fff; border:1px solid #cbd5e1; border-radius:.5rem; box-shadow:0 12px 30px rgba(15,23,42,.18); }
.project-lookup-panel-open { display:block; }
.project-lookup-title { padding:.65rem .75rem; font-weight:600; border-bottom:1px solid #e5e7eb; background:#f8fafc; }
.project-lookup-option { width:100%; border:0; background:#fff; display:flex; align-items:center; gap:.65rem; padding:.65rem .75rem; text-align:left; }
.project-lookup-option:hover,.project-lookup-option:focus { background:#eef5ff; outline:none; }
.project-lookup-avatar { width:30px; height:30px; border-radius:.4rem; display:inline-flex; align-items:center; justify-content:center; background:#edf4ff; color:#0d6efd; flex:0 0 auto; }

/* Compact, scrollable Notes rows aligned with the Android CRM list pattern. */
.crm-notes-list-scroll { max-height: 360px; overflow-y: auto; overscroll-behavior: contain; padding: 1px 4px 1px 1px; scrollbar-gutter: stable; }
.crm-note-item { display:flex; align-items:flex-start; gap:.55rem; padding:.45rem .55rem; margin-bottom:.35rem; border:1px solid #e2e8f0; border-radius:.5rem; background:#fff; }
.crm-note-avatar { width:28px; height:28px; min-width:28px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:#eef2ff; color:#4338ca; font-size:.72rem; font-weight:700; }
.crm-note-content { min-width:0; flex:1; }
.crm-note-author { font-size:.78rem; }
.crm-note-date { color:#64748b; font-size:.7rem; margin-left:.4rem; }
.crm-note-text { font-size:.82rem; line-height:1.35; white-space:pre-wrap; overflow-wrap:anywhere; margin-top:.15rem; }
.crm-notes-editor { min-height:72px; }
@media (max-width:700px) { .crm-notes-list-scroll { max-height:320px; } .crm-note-item { padding:.4rem; } }
