/* =====================================================================
   Prakash Enterprise CRM — UI
   Neutral, minimal design (ElevenLabs-inspired): white surfaces, hairline
   borders, black primary actions, generous whitespace, tight typography.
   Mobile: native-app shell (app bar, large titles, bottom tabs, card lists,
   bottom-sheet dialogs).
   Developed by ApnaLead – A Unit of Navix Technologies
   ===================================================================== */

:root {
    --pe-bg: #ffffff;
    --pe-bg-subtle: #fafafa;
    --pe-bg-muted: #f4f4f5;
    --pe-bg-hover: #f1f1f2;
    --pe-border: #e9e9eb;
    --pe-border-strong: #d6d6da;
    --pe-text: #0a0a0a;
    --pe-text-2: #4b4b4f;
    --pe-muted: #8a8a8f;
    --pe-primary: #0a0a0a;
    --pe-primary-hover: #2a2a2d;
    --pe-accent: #0b6bcb;
    --pe-focus: 0 0 0 3px rgba(10, 10, 10, .08);
    --pe-radius-sm: 8px;
    --pe-radius: 12px;
    --pe-radius-lg: 16px;
    --pe-radius-xl: 20px;
    --pe-shadow-pop: 0 12px 40px -12px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .04);
    --pe-sidebar-w: 252px;
    --pe-sidebar-w-collapsed: 68px;
    --pe-topbar-h: 60px;
    --pe-bottomnav-h: 62px;
    --pe-safe-bottom: env(safe-area-inset-bottom, 0px);

    --bs-body-font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-color: var(--pe-text);
    --bs-body-bg: var(--pe-bg);
    --bs-border-color: var(--pe-border);
    --bs-border-radius: var(--pe-radius-sm);
    --bs-link-color: var(--pe-text);
    --bs-link-color-rgb: 10, 10, 10;
    --bs-link-hover-color: var(--pe-text-2);
    --bs-primary: #0a0a0a;
    --bs-primary-rgb: 10, 10, 10;
    --bs-secondary-color: var(--pe-muted);
    --bs-emphasis-color: var(--pe-text);
}

html, body { height: 100%; }
body {
    font-size: 14px;
    line-height: 1.55;
    background: var(--pe-bg);
    color: var(--pe-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--pe-text); text-decoration: none; }
a:hover { color: var(--pe-text-2); }
.card a:not(.btn):not(.dropdown-item):not(.list-group-item):not(.nav-link):not(.badge) { text-decoration-color: var(--pe-border-strong); }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { letter-spacing: -.02em; font-weight: 600; color: var(--pe-text); }
.text-muted, .text-secondary { color: var(--pe-muted) !important; }
.small, small { font-size: 12.5px; }
.fw-medium { font-weight: 500 !important; }
code, kbd, .font-monospace { font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace; font-size: .92em; }
code { color: var(--pe-text-2); background: var(--pe-bg-muted); padding: .1em .35em; border-radius: 5px; }
hr { border-color: var(--pe-border); opacity: 1; }
::selection { background: #0a0a0a; color: #fff; }

/* ---------- Buttons ---------- */
.btn {
    --bs-btn-font-weight: 500;
    --bs-btn-font-size: 14px;
    --bs-btn-padding-x: 16px;
    --bs-btn-padding-y: 7px;
    --bs-btn-border-radius: 999px;
    --bs-btn-focus-box-shadow: var(--pe-focus);
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    white-space: nowrap; letter-spacing: -.005em; transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn .bi { font-size: 1.05em; }
.btn-sm { --bs-btn-padding-x: 12px; --bs-btn-padding-y: 4px; --bs-btn-font-size: 13px; --bs-btn-border-radius: 999px; }
.btn-lg { --bs-btn-padding-y: 11px; --bs-btn-font-size: 15px; }
.btn-primary {
    --bs-btn-bg: var(--pe-primary); --bs-btn-border-color: var(--pe-primary); --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--pe-primary-hover); --bs-btn-hover-border-color: var(--pe-primary-hover); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #000; --bs-btn-active-border-color: #000;
    --bs-btn-disabled-bg: #3a3a3d; --bs-btn-disabled-border-color: #3a3a3d;
}
.btn-outline-primary, .btn-outline-secondary, .btn-light, .btn-outline-dark {
    --bs-btn-color: var(--pe-text); --bs-btn-bg: #fff; --bs-btn-border-color: var(--pe-border);
    --bs-btn-hover-color: var(--pe-text); --bs-btn-hover-bg: var(--pe-bg-hover); --bs-btn-hover-border-color: var(--pe-border-strong);
    --bs-btn-active-color: var(--pe-text); --bs-btn-active-bg: var(--pe-bg-muted); --bs-btn-active-border-color: var(--pe-border-strong);
    --bs-btn-disabled-color: var(--pe-muted); --bs-btn-disabled-bg: #fff; --bs-btn-disabled-border-color: var(--pe-border);
}
.btn-light { --bs-btn-bg: var(--pe-bg-muted); --bs-btn-border-color: transparent; }
.btn-success { --bs-btn-bg: #16a34a; --bs-btn-border-color: #16a34a; --bs-btn-hover-bg: #15803d; --bs-btn-hover-border-color: #15803d; }
.btn-outline-success { --bs-btn-color: #15803d; --bs-btn-border-color: #bbe5c8; --bs-btn-hover-bg: #f0fbf3; --bs-btn-hover-color: #15803d; --bs-btn-hover-border-color: #86d3a0; --bs-btn-active-bg: #e3f6e9; --bs-btn-active-color: #15803d; }
.btn-danger { --bs-btn-bg: #dc2626; --bs-btn-border-color: #dc2626; --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c; }
.btn-outline-danger { --bs-btn-color: #dc2626; --bs-btn-border-color: #f3c7c7; --bs-btn-hover-bg: #fef2f2; --bs-btn-hover-color: #b91c1c; --bs-btn-hover-border-color: #ef9a9a; --bs-btn-active-bg: #fde4e4; --bs-btn-active-color: #b91c1c; }
.btn-warning { --bs-btn-bg: #f59e0b; --bs-btn-border-color: #f59e0b; --bs-btn-color: #111; --bs-btn-hover-bg: #d97706; --bs-btn-hover-border-color: #d97706; }
.btn-outline-warning { --bs-btn-color: #b45309; --bs-btn-border-color: #f5dcae; --bs-btn-hover-bg: #fffbeb; --bs-btn-hover-color: #92400e; --bs-btn-hover-border-color: #eec27a; }
.btn-link { --bs-btn-color: var(--pe-text-2); --bs-btn-hover-color: var(--pe-text); text-decoration: none; }
.btn-check:checked + .btn-outline-primary { --bs-btn-active-bg: var(--pe-primary); --bs-btn-active-color: #fff; --bs-btn-active-border-color: var(--pe-primary); }

/* Table action icon buttons: quiet squares */
.table-actions .btn { --bs-btn-padding-x: 0; width: 32px; height: 32px; padding: 0; border-radius: 9px; }

.btn-icon {
    width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; color: var(--pe-text-2); border: 0; background: transparent; font-size: 18px; transition: background .15s;
}
.btn-icon:hover { background: var(--pe-bg-hover); color: var(--pe-text); }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: 13px; color: var(--pe-text-2); margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: #dc2626; }
.form-control, .form-select {
    border-color: var(--pe-border); border-radius: 10px; font-size: 14px; min-height: 40px; color: var(--pe-text);
    padding: .5rem .8rem; background-color: #fff; transition: border-color .15s, box-shadow .15s;
}
.form-control::placeholder { color: #a8a8ad; }
.form-control:hover, .form-select:hover { border-color: var(--pe-border-strong); }
.form-control:focus, .form-select:focus { border-color: var(--pe-text); box-shadow: var(--pe-focus); }
.form-control-sm, .form-select-sm { min-height: 34px; font-size: 13px; border-radius: 9px; padding: .35rem .7rem; }
.form-control-lg { min-height: 48px; border-radius: 12px; }
.form-control:disabled, .form-select:disabled { background-color: var(--pe-bg-subtle); color: var(--pe-muted); }
textarea.form-control { min-height: 80px; }
.input-group-text { background: var(--pe-bg-subtle); border-color: var(--pe-border); color: var(--pe-muted); border-radius: 10px; }
.input-group > .form-control, .input-group > .form-select { min-height: 40px; }
.form-text { color: var(--pe-muted); font-size: 12.5px; }
.form-check-input { border-color: var(--pe-border-strong); }
.form-check-input:checked { background-color: var(--pe-primary); border-color: var(--pe-primary); }
.form-check-input:focus { box-shadow: var(--pe-focus); border-color: var(--pe-text); }
.form-switch .form-check-input { width: 2.3em; height: 1.25em; margin-top: .12em; }
.form-switch .form-check-input:focus { --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280,0,0,.35%29'/%3e%3c/svg%3e"); }
.invalid-feedback { font-size: 12.5px; }
.was-validated .form-control:invalid, .form-control.is-invalid, .form-select.is-invalid { border-color: #ef4444; }

/* Select2 */
.select2-container--bootstrap-5 .select2-selection { min-height: 40px; border-color: var(--pe-border); border-radius: 10px; font-size: 14px; }
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection { border-color: var(--pe-text); box-shadow: var(--pe-focus); }
.select2-container--bootstrap-5 .select2-dropdown { border-color: var(--pe-border); border-radius: 12px; box-shadow: var(--pe-shadow-pop); overflow: hidden; }
.select2-container--bootstrap-5 .select2-results__option--highlighted { background: var(--pe-bg-muted) !important; color: var(--pe-text) !important; }
.select2-container--bootstrap-5 .select2-results__option--selected { background: var(--pe-primary) !important; color: #fff !important; }
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered .select2-selection__choice { border-radius: 999px; border-color: var(--pe-border); background: var(--pe-bg-muted); }

/* ---------- Layout (desktop) ---------- */
.app-wrapper { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--pe-sidebar-w); background: var(--pe-bg-subtle); border-right: 1px solid var(--pe-border);
    position: fixed; inset: 0 auto 0 0; z-index: 1040; display: flex; flex-direction: column;
    transition: width .2s ease, transform .28s cubic-bezier(.2, .8, .2, 1);
}
.sidebar-brand { height: var(--pe-topbar-h); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; flex-shrink: 0; }
.brand-link { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--pe-text); }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; object-fit: contain; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; overflow: hidden; }
.brand-text strong { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.brand-text small { color: var(--pe-muted); font-size: 11.5px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; scrollbar-width: thin; scrollbar-color: #ddd transparent; }
.nav-section { font-size: 11.5px; font-weight: 500; color: var(--pe-muted); padding: 16px 10px 6px; white-space: nowrap; }
.sidebar-nav .nav-link {
    color: var(--pe-text-2); border-radius: 8px; padding: 7px 10px; display: flex; align-items: center; gap: 10px;
    font-weight: 450; font-size: 14px; white-space: nowrap; transition: background .12s, color .12s;
}
.sidebar-nav .nav-link i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; color: var(--pe-muted); }
.sidebar-nav .nav-link:hover { background: var(--pe-bg-hover); color: var(--pe-text); }
.sidebar-nav .nav-link.active { background: #fff; color: var(--pe-text); font-weight: 500; box-shadow: 0 0 0 1px var(--pe-border), 0 1px 2px rgba(0, 0, 0, .04); }
.sidebar-nav .nav-link.active i { color: var(--pe-text); }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--pe-border); display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sidebar-user { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; min-width: 0; color: var(--pe-text); font-size: 13.5px; line-height: 1.25; }
.sidebar-user:hover { background: var(--pe-bg-hover); color: var(--pe-text); }

.app-main { flex: 1; margin-left: var(--pe-sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left .2s ease; }
.app-topbar {
    height: var(--pe-topbar-h); background: rgba(255, 255, 255, .86); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--pe-border); display: flex; align-items: center; gap: 10px; padding: 0 24px; position: sticky; top: 0; z-index: 1030;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; color: var(--pe-text); font-size: 15px; min-width: 0; }
.topbar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-search { position: relative; flex: 1; max-width: 460px; }
.topbar-search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--pe-muted); font-size: 14px; }
.topbar-search .form-control { padding-left: 36px; padding-right: 36px; background: var(--pe-bg-muted); border-color: transparent; min-height: 38px; }
.topbar-search .form-control:focus { background: #fff; border-color: var(--pe-border-strong); }
.search-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--pe-muted); background: #fff; border: 1px solid var(--pe-border); border-radius: 5px; padding: 0 6px; box-shadow: none; }
.search-results { width: 100%; max-height: 440px; overflow-y: auto; margin-top: 6px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.user-menu-btn { display: flex; align-items: center; border: 0; background: transparent; padding: 4px; border-radius: 999px; color: var(--pe-text); }
.user-menu-btn:hover { background: var(--pe-bg-hover); }
.notif-dot { position: absolute; top: 5px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; border: 2px solid #fff; box-sizing: content-box; }

.app-content { flex: 1; padding: 28px 32px 40px; width: 100%; max-width: 1440px; margin: 0 auto; }
.app-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; padding: 16px 32px; font-size: 12px; color: var(--pe-muted); border-top: 1px solid var(--pe-border); }
.app-footer a { color: var(--pe-text-2); font-weight: 500; }

.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -.025em; margin: 0; line-height: 1.2; }
.breadcrumb { font-size: 13px; margin-bottom: 4px; --bs-breadcrumb-divider-color: var(--pe-border-strong); --bs-breadcrumb-item-active-color: var(--pe-muted); }
.breadcrumb a { color: var(--pe-muted); }
.breadcrumb a:hover { color: var(--pe-text); }
.page-back { display: inline-flex; align-items: center; gap: 2px; font-size: 15px; color: var(--pe-text-2); margin: -4px 0 6px -4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.section-label { font-size: 13px; font-weight: 600; color: var(--pe-text); margin: 8px 0 12px; letter-spacing: -.01em; }

@media (min-width: 992px) {
    body.sidebar-collapsed .app-sidebar { width: var(--pe-sidebar-w-collapsed); }
    body.sidebar-collapsed .app-main { margin-left: var(--pe-sidebar-w-collapsed); }
    body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-section, body.sidebar-collapsed .sidebar-nav .nav-link span,
    body.sidebar-collapsed .sidebar-user > .min-w-0, body.sidebar-collapsed .sidebar-footer > .btn-icon { display: none; }
    body.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; padding: 9px; }
    body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
    body.sidebar-collapsed .sidebar-footer { justify-content: center; }
    body.sidebar-collapsed .sidebar-nav .nav-section + .nav { border-top: 1px solid var(--pe-border); padding-top: 6px; margin-top: 6px; }
}

/* ---------- Surfaces ---------- */
.card { border: 1px solid var(--pe-border); border-radius: var(--pe-radius-lg); box-shadow: none; background: #fff; --bs-card-cap-bg: transparent; }
.card-header { background: transparent; border-bottom: 1px solid var(--pe-border); padding: 14px 20px; }
.card-header h6, .card-header .h6 { font-size: 14.5px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { background: transparent; border-top: 1px solid var(--pe-border); padding: 12px 20px; }
.card-header-tabs { margin-bottom: -15px; }
.list-group { --bs-list-group-border-color: var(--pe-border); --bs-list-group-action-hover-bg: var(--pe-bg-subtle); --bs-list-group-active-bg: var(--pe-primary); --bs-list-group-active-border-color: var(--pe-primary); }
.list-group-item { padding: 12px 18px; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--pe-border) !important; }
.rounded { border-radius: var(--pe-radius) !important; }
.bg-light { background-color: var(--pe-bg-subtle) !important; }

.welcome-card {
    background: var(--pe-bg-subtle); color: var(--pe-text); border: 1px solid var(--pe-border); border-radius: var(--pe-radius-lg);
    padding: 22px 24px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center;
}
.welcome-card h2 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.welcome-card .text-white-50 { color: var(--pe-muted) !important; }
.welcome-card .btn-light { --bs-btn-bg: var(--pe-primary); --bs-btn-color: #fff; --bs-btn-hover-bg: var(--pe-primary-hover); --bs-btn-hover-color: #fff; }

.stat-card { background: #fff; border: 1px solid var(--pe-border); border-radius: var(--pe-radius-lg); padding: 16px 18px; display: flex; align-items: center; gap: 14px; height: 100%; transition: border-color .15s; }
.stat-card:hover { border-color: var(--pe-border-strong); }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; background: var(--pe-bg-muted) !important; color: var(--pe-text) !important; }
.stat-value { font-size: 24px; font-weight: 600; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--pe-muted); margin-top: 2px; }

a.stat-link { color: inherit; position: relative; }
a.stat-link:hover { border-color: var(--pe-text); color: inherit; }
a.stat-link:active { transform: scale(.985); }
.stat-go { margin-left: auto; color: #c4c4c8; font-size: 14px; align-self: center; }
a.stat-link:hover .stat-go { color: var(--pe-text); }
.stat-hint { font-size: 12px; color: var(--pe-text-2); margin-top: 2px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 6px 0 12px; }
.chart-card .card-header { border-bottom: 0; padding-bottom: 0; }
.chart-card .card-body { padding-top: 12px; }
.chart-box { position: relative; width: 100%; }
.chart-table { max-height: 320px; overflow-y: auto; }

/* ---------- Toasts (Sonner / ElevenLabs style) ---------- */
.toaster { position: fixed; z-index: 2000; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.toast-item {
    pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; background: #0a0a0a; color: #fafafa;
    border-radius: 14px; padding: 12px 14px; font-size: 13.5px; line-height: 1.45; box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .35);
    transform: translateY(12px) scale(.98); opacity: 0; transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .22s; cursor: pointer;
}
.toast-item.show { transform: none; opacity: 1; }
.toast-item.hide { transform: translateY(6px) scale(.98); opacity: 0; }
.toast-item .toast-icon { font-size: 16px; line-height: 1.3; flex-shrink: 0; }
.toast-item .toast-msg { flex: 1; min-width: 0; word-break: break-word; }
.toast-item .toast-x { color: #8a8a8f; font-size: 14px; line-height: 1.3; }
.toast-success .toast-icon { color: #4ade80; }
.toast-error .toast-icon { color: #f87171; }
.toast-warning .toast-icon { color: #fbbf24; }
.toast-info .toast-icon { color: #60a5fa; }
.auth-flash.alert { background: #0a0a0a; color: #fafafa; border: 0; border-radius: 14px; box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .35); font-size: 13.5px; padding: 12px 40px 12px 16px; }
.auth-flash .btn-close { filter: invert(1); opacity: .6; padding: 14px; }

/* FAB (mobile primary action) */
.fab { display: none; }

/* Install (PWA) */
.install-sheet { position: fixed; inset: 0; z-index: 2100; background: rgba(10, 10, 10, .4); display: none; align-items: flex-end; justify-content: center; }
.install-sheet.open { display: flex; }
.install-sheet-card { background: #fff; width: 100%; max-width: 440px; border-radius: 22px 22px 0 0; padding: 22px 22px calc(22px + var(--pe-safe-bottom)); }
@media (min-width: 768px) { .install-sheet { align-items: center; } .install-sheet-card { border-radius: 20px; } }
.install-promo { display: flex; align-items: center; gap: 12px; margin-top: 28px; padding: 12px 14px; border: 1px solid var(--pe-border); border-radius: 16px; cursor: pointer; transition: border-color .15s; }
.install-promo:hover { border-color: var(--pe-border-strong); }
.install-promo img { border-radius: 10px; flex-shrink: 0; }
.install-step { display: flex; gap: 12px; align-items: center; padding: 10px 0; font-size: 14px; }
.install-step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--pe-bg-muted); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12.5px; flex-shrink: 0; }

.bg-soft-primary { background: #eef4fd; color: #1d4ed8; }
.bg-soft-success { background: #ecfdf3; color: #15803d; }
.bg-soft-danger { background: #fef2f2; color: #b91c1c; }
.bg-soft-warning { background: #fffbeb; color: #b45309; }
.bg-soft-info { background: #ecfeff; color: #0e7490; }
.bg-soft-secondary { background: var(--pe-bg-muted); color: var(--pe-text-2); }

/* ---------- Badges (soft pills) ---------- */
.badge { font-weight: 500; font-size: 12px; padding: .28em .7em; border-radius: 999px; letter-spacing: 0; line-height: 1.35; }
.badge-soft-primary { background: #eef4fd; color: #1d4ed8; }
.badge-soft-info { background: #ecfeff; color: #0e7490; }
.badge-soft-warning { background: #fff7e6; color: #b45309; }
.badge-soft-danger { background: #fef0f0; color: #c0262d; }
.badge-soft-success { background: #ecfdf3; color: #15803d; }
.badge-soft-secondary { background: var(--pe-bg-muted); color: var(--pe-text-2); }
.badge-soft-dark { background: #e7e7ea; color: #111; }
.badge-soft-light { background: #fff; color: var(--pe-text-2); box-shadow: inset 0 0 0 1px var(--pe-border); }
.badge-soft-purple { background: #f4f0ff; color: #6d28d9; }
.badge-soft-orange { background: #fff1e8; color: #c2410c; }
.bg-secondary-subtle { background: var(--pe-bg-muted) !important; }
.bg-primary-subtle { background: var(--pe-bg-muted) !important; }
.text-primary { color: var(--pe-text) !important; }

/* ---------- Tables / DataTables ---------- */
.table { --bs-table-hover-bg: var(--pe-bg-subtle); --bs-table-border-color: var(--pe-border); font-size: 13.5px; margin-bottom: 0; color: var(--pe-text); }
.table > thead th { font-size: 12.5px; font-weight: 500; color: var(--pe-muted); background: transparent; border-bottom: 1px solid var(--pe-border); white-space: nowrap; padding-top: 10px; padding-bottom: 10px; }
.table > :not(caption) > * > * { padding: 12px 14px; border-bottom-color: var(--pe-border); }
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table-sm > :not(caption) > * > * { padding: 7px 10px; }
.card > .table-responsive > .table > thead th:first-child, .card > .table-responsive > .table > tbody td:first-child { padding-left: 20px; }
.card > .table-responsive > .table > thead th:last-child, .card > .table-responsive > .table > tbody td:last-child { padding-right: 20px; }
.table-actions { white-space: nowrap; }
table.dataTable { margin-top: 0 !important; margin-bottom: 0 !important; }

/* Big lists (leads / complaints / follow-ups): single-line cells so every row has the same height
   and columns stay aligned; full text is in the title tooltip. */
.table-cards > :not(caption) > * > * { padding: 10px 12px; }
.table-cards .m-card { display: none; }
.cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.table-cards .col-name .cell-clip { max-width: 210px; }
.table-cards .col-mid .cell-clip { max-width: 180px; }
.table-cards .col-wide .cell-clip { max-width: 220px; }
/* optional columns drop out on narrower laptops instead of scrolling sideways */
@media (max-width: 1299.98px) { .table-cards .opt-1 { display: none; } }
@media (max-width: 1099.98px) { .table-cards .opt-2 { display: none; } }
.table-cards .col-sm .cell-clip { max-width: 140px; }
.table-cards td.col-no, .table-cards td.col-act { white-space: nowrap; width: 1%; }
.table-cards .table-actions .btn { width: 30px; height: 30px; }
@media (max-width: 1399.98px) {
    .table-cards .col-name .cell-clip { max-width: 170px; }
    .table-cards .col-wide .cell-clip { max-width: 180px; }
    .table-cards .col-mid .cell-clip { max-width: 140px; }
    .table-cards .col-sm .cell-clip { max-width: 100px; }
    .table-cards > :not(caption) > * > * { padding-left: 9px; padding-right: 9px; }
}
@media (max-width: 1199.98px) {
    .table-cards .col-name .cell-clip { max-width: 130px; }
    .table-cards .col-sm .cell-clip { max-width: 90px; }
    .table-cards .table-actions .btn-wa { display: none; }
    .table-cards .col-wide .cell-clip { max-width: 150px; }
    .table-cards .col-mid .cell-clip { max-width: 110px; }
}
.due-danger { color: #c0262d; font-weight: 500; }
.due-warning { color: #b45309; font-weight: 500; }
.due-info { color: #0e7490; font-weight: 500; }

/* Call / WhatsApp quick buttons */
.btn-call { --bs-btn-color: #15803d; --bs-btn-bg: #ecfdf3; --bs-btn-border-color: #ecfdf3; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #16a34a; --bs-btn-hover-border-color: #16a34a; --bs-btn-active-bg: #15803d; --bs-btn-active-color: #fff; }
.btn-wa { --bs-btn-color: #128c4b; --bs-btn-bg: #fff; --bs-btn-border-color: #cdeed8; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #25d366; --bs-btn-hover-border-color: #25d366; --bs-btn-active-bg: #128c4b; --bs-btn-active-color: #fff; }
.qf-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.qf-dot-danger { background: #dc2626; }

/* Notification centre */
.nc-day { margin: 6px 2px 8px; color: var(--pe-muted); }
.nc-list { overflow: hidden; }
.nc-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; color: var(--pe-text); text-decoration: none; border-bottom: 1px solid var(--pe-border); position: relative; }
.nc-item:last-child { border-bottom: 0; }
.nc-item:hover { background: var(--pe-bg-subtle); color: var(--pe-text); }
.nc-item.unread { background: #fbfbfc; }
.nc-icon { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; background: var(--pe-bg-muted); color: var(--pe-text-2); }
.nc-icon.nc-danger { background: #fef0f0; color: #c0262d; }
.nc-icon.nc-warning { background: #fff7e6; color: #b45309; }
.nc-icon.nc-success { background: #ecfdf3; color: #15803d; }
.nc-icon.nc-primary { background: #eef4fd; color: #1d4ed8; }
.nc-icon.nc-info { background: #ecfeff; color: #0e7490; }
.nc-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.nc-title { font-size: 13.5px; line-height: 1.35; color: var(--pe-text-2); }
.nc-item.unread .nc-title { font-weight: 600; color: var(--pe-text); }
.nc-body { font-size: 12.5px; color: var(--pe-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nc-time { font-size: 11.5px; color: #a1a1a6; margin-top: 2px; }
.nc-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: #2563eb; margin-top: 6px; }

/* Device list (profile) */
.device-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--pe-border); }
.device-row:last-child { border-bottom: 0; }
.device-row .nc-icon { flex-basis: 36px; width: 36px; height: 36px; }

/* Compact list card (mobile rendering of the big lists) */
.lc { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lc-head { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.lc-avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; background: var(--pe-bg-muted); color: var(--pe-text-2); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.lc-main { flex: 1 1 auto; min-width: 0; }
.lc-title { font-weight: 600; font-size: 14.5px; line-height: 1.3; color: var(--pe-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-sub { font-size: 12.5px; color: var(--pe-muted); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-right { flex: 0 0 auto; text-align: right; }
.lc-amt { font-weight: 600; font-size: 14px; color: var(--pe-text); }
.lc-line { font-size: 13px; color: var(--pe-text-2); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-head:has(.lc-avatar) ~ .lc-line { padding-left: 44px; }
.lc-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; min-width: 0; }
.lc-head:has(.lc-avatar) ~ .lc-foot { padding-left: 44px; }
.lc-badges { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.lc-meta { font-size: 12px; color: var(--pe-muted); margin-left: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.lc-meta .badge { font-size: 11px; }
.lc-actions { flex: 0 0 auto; display: flex; gap: 6px; }
.lc-actions .btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
div.dataTables_wrapper div.dataTables_filter { text-align: right; }
div.dataTables_wrapper div.dataTables_filter label { font-size: 0; }
div.dataTables_wrapper div.dataTables_filter input {
    margin-left: 0; width: 240px; min-height: 36px; border-radius: 999px; padding-left: 34px; font-size: 13.5px;
    background: var(--pe-bg-muted) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%238a8a8f' viewBox='0 0 16 16'%3e%3cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3e%3c/svg%3e") no-repeat 12px center;
    border-color: transparent;
}
div.dataTables_wrapper div.dataTables_filter input:focus { background-color: #fff; border-color: var(--pe-border-strong); }
div.dataTables_wrapper div.dataTables_length { font-size: 13px; color: var(--pe-muted); }
div.dataTables_wrapper div.dataTables_length select { width: auto; min-width: 76px; display: inline-block; min-height: 32px; border-radius: 999px; margin-right: 4px; padding: 4px 30px 4px 12px; background-position: right 10px center; }
.filters-toggle { display: none; }
div.dataTables_wrapper div.dataTables_info { font-size: 12.5px; color: var(--pe-muted); padding-top: 0 !important; }
div.dataTables_wrapper div.dataTables_paginate { margin-top: 0 !important; }
div.dataTables_wrapper div.dataTables_paginate ul.pagination { margin: 0; justify-content: flex-end; gap: 4px; }
.page-link { border: 0; border-radius: 999px !important; color: var(--pe-text-2); min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 13px; padding: 0 10px; }
.page-link:hover { background: var(--pe-bg-hover); color: var(--pe-text); }
.page-item.active .page-link { background: var(--pe-primary); color: #fff; }
.page-item.disabled .page-link { background: transparent; color: #c4c4c8; }
.page-link:focus { box-shadow: var(--pe-focus); }
div.dataTables_processing { border: 1px solid var(--pe-border) !important; border-radius: 12px; box-shadow: var(--pe-shadow-pop) !important; background: #fff !important; padding: 10px 16px !important; font-size: 13px; }
div.dataTables_processing > div:last-child { display: none; }
table.dataTable > thead > tr > th.sorting::before, table.dataTable > thead > tr > th.sorting::after,
table.dataTable > thead > tr > th.sorting_asc::before, table.dataTable > thead > tr > th.sorting_asc::after,
table.dataTable > thead > tr > th.sorting_desc::before, table.dataTable > thead > tr > th.sorting_desc::after { font-size: .7em; opacity: .25; }
table.dataTable > thead > tr > th.sorting_asc::before, table.dataTable > thead > tr > th.sorting_desc::after { opacity: .8; }
td.dataTables_empty { color: var(--pe-muted); padding: 40px 14px !important; }

/* Quick filter chips */
.quick-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.quick-filters .btn { --bs-btn-font-size: 13px; --bs-btn-padding-y: 5px; --bs-btn-padding-x: 14px; }
.quick-filters .btn .badge { background: var(--pe-bg-muted) !important; color: var(--pe-text-2) !important; margin-left: 2px; padding: .15em .5em; }
.quick-filters .btn-primary .badge { background: rgba(255, 255, 255, .18) !important; color: #fff !important; }

/* Nav tabs & pills */
.nav-tabs { --bs-nav-tabs-border-color: transparent; gap: 4px; border-bottom: 0; }
.nav-tabs .nav-link { border: 0; border-radius: 999px; color: var(--pe-text-2); font-size: 13.5px; font-weight: 500; padding: 6px 14px; }
.nav-tabs .nav-link:hover { background: var(--pe-bg-hover); color: var(--pe-text); }
.nav-tabs .nav-link.active { background: var(--pe-bg-muted); color: var(--pe-text); }
.card-header:has(.nav-tabs) { padding: 12px 14px; border-bottom: 1px solid var(--pe-border) !important; }
.card-header-tabs { margin: 0; }
.nav-pills { --bs-nav-pills-link-active-bg: var(--pe-primary); --bs-nav-pills-border-radius: 999px; }
.nav-pills .nav-link { color: var(--pe-text-2); font-weight: 500; font-size: 13.5px; background: #fff; border: 1px solid var(--pe-border); padding: 6px 14px; }
.nav-pills .nav-link.active { border-color: var(--pe-primary); }

/* Alerts */
.alert { border-radius: var(--pe-radius); border: 1px solid; padding: 12px 16px; font-size: 13.5px; }
.alert-info { background: #f5f9ff; border-color: #dbe7fb; color: #1e3a8a; }
.alert-success { background: #f2fcf5; border-color: #cdeed8; color: #14532d; }
.alert-warning { background: #fffaf0; border-color: #f6e3b7; color: #78350f; }
.alert-danger { background: #fff5f5; border-color: #f7d4d4; color: #7f1d1d; }
.alert-secondary, .alert-light { background: var(--pe-bg-subtle); border-color: var(--pe-border); color: var(--pe-text-2); }

/* Dropdowns */
.dropdown-menu { --bs-dropdown-border-color: var(--pe-border); --bs-dropdown-border-radius: 14px; --bs-dropdown-link-hover-bg: var(--pe-bg-muted); --bs-dropdown-link-active-bg: var(--pe-primary); --bs-dropdown-font-size: 13.5px; --bs-dropdown-padding-x: 6px; box-shadow: var(--pe-shadow-pop); }
.dropdown-item { border-radius: 8px; padding: 7px 10px; }
.dropdown-header { font-size: 11.5px; font-weight: 500; color: var(--pe-muted); }

/* Modals */
.modal-content { border: 0; border-radius: var(--pe-radius-xl); box-shadow: 0 24px 64px -16px rgba(0, 0, 0, .28); }
.modal-header { border-bottom: 0; padding: 20px 22px 6px; }
.modal-title { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.modal-body { padding: 14px 22px; }
.modal-footer { border-top: 0; padding: 8px 22px 20px; gap: 8px; }
.modal-footer > * { margin: 0; }
.modal-backdrop { --bs-backdrop-bg: #0a0a0a; --bs-backdrop-opacity: .32; }
.btn-close { opacity: .45; }
.btn-close:focus { box-shadow: var(--pe-focus); }

/* Notifications dropdown */
.notif-dropdown { width: 360px; max-width: calc(100vw - 24px); padding: 0 !important; overflow: hidden; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--pe-border); color: inherit; }
.notif-item:hover { background: var(--pe-bg-subtle); color: inherit; }
.notif-item.unread { background: #fafbff; }
.notif-item.unread .notif-title::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pe-accent); margin-right: 7px; vertical-align: middle; }
.notif-title { font-weight: 500; font-size: 13.5px; }
.notif-body { font-size: 12.5px; color: var(--pe-muted); }
.notif-time { font-size: 11.5px; color: #a8a8ad; margin-top: 2px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #e9e9ec; color: var(--pe-text); font-weight: 600; font-size: 12.5px; flex-shrink: 0; letter-spacing: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-xl { width: 80px; height: 80px; font-size: 26px; }

/* SweetAlert2 */
.swal2-popup { font-family: var(--bs-body-font-family); border-radius: 20px !important; padding: 1.6em 1.4em 1.4em !important; }
.swal2-title { font-size: 19px !important; font-weight: 600 !important; letter-spacing: -.02em; color: var(--pe-text) !important; }
.swal2-html-container { font-size: 14px !important; color: var(--pe-text-2) !important; }
.swal2-styled { border-radius: 999px !important; font-weight: 500 !important; font-size: 14px !important; padding: .55em 1.4em !important; box-shadow: none !important; }
.swal2-styled.swal2-cancel { background: var(--pe-bg-muted) !important; color: var(--pe-text) !important; }
.swal2-icon { transform: scale(.8); margin: .6em auto .4em !important; }
.swal2-toast { border-radius: 14px !important; box-shadow: var(--pe-shadow-pop) !important; font-size: 13.5px !important; padding: .7em 1em !important; }
.swal2-toast .swal2-title { font-size: 13.5px !important; font-weight: 500 !important; }
.swal2-timer-progress-bar { background: rgba(0, 0, 0, .15) !important; }

/* Timeline */
.timeline { position: relative; padding-left: 22px; list-style: none; margin: 0; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--pe-border); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -22px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid var(--pe-text); }
.timeline-time { font-size: 12px; color: var(--pe-muted); margin-top: 2px; }

/* Error page */
.error-page { min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.error-page-guest { min-height: 100vh; }
.error-icon { font-size: 2.4rem; color: var(--pe-text); }
.error-code { font-size: 4rem; font-weight: 700; line-height: 1; color: #e4e4e7; letter-spacing: -.04em; margin-bottom: .4rem; }

/* Utilities */
.cursor-pointer { cursor: pointer; }
.min-w-0 { min-width: 0; }
.fs-7 { font-size: 12.5px; }
.text-pre { white-space: pre-line; }
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ---------- Auth ---------- */
.auth-body { background: #fff; min-height: 100vh; }
.auth-wrapper { display: flex; min-height: 100vh; }
.auth-form-side { flex: 1; display: flex; flex-direction: column; padding: 28px 32px; }
.auth-top { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.auth-top img { width: 32px; height: 32px; border-radius: 8px; }
.auth-center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 0; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 28px; letter-spacing: -.035em; margin-bottom: 6px; }
.auth-card .form-control { min-height: 46px; border-radius: 12px; }
.auth-card .btn-primary { min-height: 46px; }
.auth-foot { font-size: 12px; color: var(--pe-muted); }
.auth-visual {
    flex: 1; margin: 12px; border-radius: 24px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
    padding: 44px; color: #fff; background: #0a0a0a;
}
.auth-visual::before {
    content: ''; position: absolute; inset: -20%;
    background:
        radial-gradient(40% 35% at 30% 30%, rgba(99, 102, 241, .55), transparent 70%),
        radial-gradient(35% 30% at 75% 40%, rgba(16, 185, 129, .45), transparent 70%),
        radial-gradient(45% 40% at 55% 80%, rgba(14, 165, 233, .45), transparent 70%);
    filter: blur(40px);
}
.auth-visual > * { position: relative; }
.auth-visual h2 { color: #fff; font-size: 34px; letter-spacing: -.035em; line-height: 1.15; max-width: 460px; }
.auth-visual p { color: rgba(255, 255, 255, .72); max-width: 440px; font-size: 15px; }
.auth-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.auth-pills span { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); border-radius: 999px; padding: 6px 12px; font-size: 13px; backdrop-filter: blur(6px); }
.auth-flash { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2000; width: calc(100% - 32px); max-width: 420px; }

/* ---------- Bottom nav & search overlay (mobile) ---------- */
.bottom-nav { display: none; }
.search-overlay { display: none; }

/* =====================================================================
   Tablet & phone
   ===================================================================== */
@media (max-width: 991.98px) {
    /* Never let the page scroll sideways: wide tables scroll inside their own box */
    /* on <html> only (propagates to the viewport); on body use clip so body never becomes its own scroller */
    html { overflow-x: hidden; }
    body { overflow-x: clip; max-width: 100%; }
    .app-main, .app-content { max-width: 100vw; }
    .table-responsive { max-width: 100%; }
    .app-sidebar {
        width: min(86vw, 320px); transform: translateX(-102%); border-right: 0; border-radius: 0 22px 22px 0;
        background: #fff; box-shadow: none; padding-bottom: var(--pe-safe-bottom);
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); box-shadow: 0 0 60px rgba(0, 0, 0, .25); }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 10, 10, .32); z-index: 1035; opacity: 0; pointer-events: none; transition: opacity .25s; }
    body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    body.sidebar-open { overflow: hidden; }
    .sidebar-nav .nav-link { padding: 11px 12px; font-size: 15px; }
    .sidebar-nav .nav-link i { font-size: 18px; }
    .app-main { margin-left: 0; }

    .app-topbar { height: 56px; padding: 0 12px 0 16px; padding-top: env(safe-area-inset-top, 0px); height: calc(56px + env(safe-area-inset-top, 0px)); }
    .app-content { padding: 14px 16px calc(var(--pe-bottomnav-h) + var(--pe-safe-bottom) + 24px); }
    .app-footer { justify-content: center; text-align: center; padding: 0 16px calc(var(--pe-bottomnav-h) + var(--pe-safe-bottom) + 14px); border-top: 0; margin-top: -10px; }

    .page-header { display: block; margin-bottom: 16px; }
    .page-title { font-size: 24px; letter-spacing: -.03em; }
    .page-actions { flex-wrap: wrap; gap: 8px; margin-top: 12px; }
    .page-actions .btn { --bs-btn-padding-y: 6px; --bs-btn-padding-x: 13px; --bs-btn-font-size: 13.5px; }
    .page-actions > .fab-source { display: none !important; }

    /* Compact title in the app bar once the large title scrolls away (iOS-style) */
    .topbar-title { position: absolute; left: 58px; right: 140px; transform: translateY(6px); font-weight: 600; font-size: 15px;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; }
    body.scrolled .topbar-title { opacity: 1; transform: none; }
    body.scrolled .topbar-brand span { opacity: 0; }
    .topbar-brand span { transition: opacity .18s; }
    .app-topbar { position: sticky; }

    /* Floating action button for the page's main "add" action */
    .fab {
        display: inline-flex; position: fixed; right: 16px; bottom: calc(var(--pe-bottomnav-h) + var(--pe-safe-bottom) + 16px); z-index: 1029;
        height: 52px; min-width: 52px; padding: 0 18px; border-radius: 999px; background: var(--pe-primary); color: #fff; align-items: center; justify-content: center; gap: 6px;
        font-weight: 500; font-size: 14.5px; box-shadow: 0 10px 28px -6px rgba(0, 0, 0, .4); border: 0;
    }
    .fab:hover, .fab:active { color: #fff; background: #000; }
    .fab .bi { font-size: 20px; }
    body.sidebar-open .fab, body.search-open .fab, body.modal-open .fab { display: none; }

    /* Side menus (settings / masters) become swipeable pills */
    .side-nav { border: 0 !important; background: transparent !important; }
    .side-nav .list-group { flex-direction: row; overflow-x: auto; gap: 8px; scrollbar-width: none; padding-bottom: 2px; }
    .side-nav .list-group::-webkit-scrollbar { display: none; }
    .side-nav .list-group-item { border: 1px solid var(--pe-border) !important; border-radius: 999px !important; white-space: nowrap; padding: 7px 14px; font-size: 13.5px; flex-shrink: 0; }
    .side-nav .list-group-item .badge { display: none; }

    .app-content { animation: pe-in .22s ease-out; }
    @keyframes pe-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

    .toaster { left: 50%; right: auto; transform: translateX(-50%); bottom: auto; top: calc(10px + env(safe-area-inset-top, 0px)); }
    .toast-item { transform: translateY(-12px) scale(.98); }
    .app-footer { display: none; }
    .sidebar-credit { display: block !important; }

    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        height: calc(var(--pe-bottomnav-h) + var(--pe-safe-bottom)); padding-bottom: var(--pe-safe-bottom);
        background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
        border-top: 1px solid var(--pe-border);
    }
    .bottom-nav-item {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        color: #9a9a9f; font-size: 10.5px; font-weight: 500; background: none; border: 0; padding: 6px 0 4px; letter-spacing: .01em;
    }
    .bottom-nav-item i { font-size: 21px; line-height: 1; }
    .bottom-nav-item.active { color: var(--pe-text); }
    .bottom-nav-item:active { opacity: .6; }

    .search-overlay { display: flex; flex-direction: column; position: fixed; inset: 0; z-index: 1060; background: #fff; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .18s, transform .18s; }
    body.search-open .search-overlay { opacity: 1; pointer-events: auto; transform: none; }
    body.search-open { overflow: hidden; }
    .search-overlay-bar { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px 16px; border-bottom: 1px solid var(--pe-border); position: relative; }
    .search-overlay-bar > i { position: absolute; left: 30px; color: var(--pe-muted); }
    .search-overlay-bar .form-control { padding-left: 38px; background: var(--pe-bg-muted); border-color: transparent; border-radius: 12px; }
    .search-overlay-results { flex: 1; overflow-y: auto; padding: 8px 0 24px; }
    .search-overlay-results .dropdown-header { padding: 14px 18px 6px; }
    .search-overlay-results a { display: block; padding: 11px 18px; color: var(--pe-text); border-bottom: 1px solid var(--pe-border); }

    .card { border-radius: 18px; }
    .card-body { padding: 16px; }
    .card-header { padding: 13px 16px; }
    .welcome-card { padding: 18px; border-radius: 18px; }
    .stat-card { padding: 14px; gap: 12px; border-radius: 16px; }
    .stat-value { font-size: 21px; }

    .quick-filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 2px; scrollbar-width: none;
        -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
    .quick-filters .btn { --bs-btn-padding-y: 5px; --bs-btn-padding-x: 12px; --bs-btn-font-size: 13px; }
    .quick-filters::-webkit-scrollbar { display: none; }
    .quick-filters .btn { flex-shrink: 0; }
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link { white-space: nowrap; }
    .nav-pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
}

@media (max-width: 767.98px) {
    /* Touch-friendly controls; 16px inputs stop iOS from zooming */
    body { font-size: 14px; }
    .form-control, .form-select, .select2-container--bootstrap-5 .select2-selection { font-size: 16px; min-height: 44px; border-radius: 12px; }
    .form-control-sm, .form-select-sm { font-size: 16px; min-height: 40px; padding-top: .3rem; padding-bottom: .3rem; }
    .form-label { font-size: 13px; }
    .btn { --bs-btn-padding-y: 8px; --bs-btn-font-size: 14px; }
    .btn-sm { --bs-btn-padding-y: 5px; --bs-btn-font-size: 13px; }
    .table-actions .btn { width: 36px; height: 36px; }
    .card-header h6, .card-header .h6 { font-size: 14px; }
    .section-label { font-size: 13px; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 12px; }
    .stat-go { display: none; }
    .welcome-card h2 { font-size: 17px; }
    .welcome-card p { font-size: 12.5px; }
    .badge { font-size: 11.5px; }
    .small, small { font-size: 12px; }
    .row.g-3 { --bs-gutter-x: .65rem; --bs-gutter-y: .65rem; }
    .chart-card .card-header { padding: 12px 14px 0; }
    .chart-card .card-body { padding: 10px 12px 12px; }
    /* tappable list cards: a lone "open" eye button is redundant – show a chevron on the title instead */
    .app-content table.table-hover > tbody > tr > td:last-child:has(> a.btn:only-child > .bi-eye),
    .app-content table.table-hover > tbody > tr > td:last-child:has(> .table-actions > a.btn:only-child > .bi-eye) { display: none; }
    .app-content table.table-hover > tbody > tr:has(> td:first-child a[href]) > td:first-child { padding-right: 22px !important; }
    .app-content table.table-hover > tbody > tr:has(> td:first-child a[href]) > td:first-child::after {
        content: '\F285'; font-family: 'bootstrap-icons'; position: absolute; right: 0; top: 3px; color: #b8b8bd; font-size: 13px;
    }
    .app-content table.table-hover > tbody > tr { cursor: pointer; }
    .breadcrumb { display: none; }

    /* Lists → native cards (labels come from the column headers, see app.js) */
    .app-content table.table-hover { border: 0; }
    .app-content table.table-hover > thead { display: none; }
    .app-content table.table-hover, .app-content table.table-hover > tbody, .app-content table.table-hover > tbody > tr, .app-content table.table-hover > tbody > tr > td { display: block; width: 100% !important; }
    .app-content table.table-hover > tbody > tr {
        border: 1px solid var(--pe-border); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; background: #fff;
        position: relative;
    }
    .app-content table.table-hover > tbody > tr:active { background: var(--pe-bg-subtle); }
    /* label on the left (absolute), value block on the right – multi-line values stack naturally */
    .app-content table.table-hover > tbody > tr > td {
        border: 0 !important; position: relative; padding: 4px 0 4px 36% !important; text-align: right; font-size: 13.5px; min-height: 0; word-break: break-word;
        box-sizing: border-box !important; /* DataTables sets content-box on cells */
    }
    .app-content table.table-hover > tbody > tr { box-sizing: border-box; }
    .app-content .table-responsive:has(> table.table-hover) { overflow: visible; }
    .app-content table.table-hover > tbody > tr > td::before {
        content: attr(data-label); position: absolute; left: 0; top: 4px; width: 34%; color: var(--pe-muted); font-size: 12.5px; text-align: left; line-height: 1.5;
    }
    .app-content table.table-hover > tbody > tr > td[data-label=""] { padding-left: 0 !important; }
    .app-content table.table-hover > tbody > tr > td[data-label=""]::before { display: none; }
    .app-content table.table-hover > tbody > tr > td .d-flex { justify-content: flex-end; }
    /* first cell = card title */
    .app-content table.table-hover > tbody > tr > td:first-child { text-align: left; padding: 0 0 8px !important; margin-bottom: 4px; border-bottom: 1px solid var(--pe-border) !important; font-size: 14.5px; }
    .app-content table.table-hover > tbody > tr > td:first-child .d-flex { justify-content: flex-start; }
    .app-content table.table-hover > tbody > tr > td:first-child::before { display: none; }
    /* action cell */
    .app-content table.table-hover > tbody > tr > td.text-end:last-child { padding: 10px 0 0 !important; }
    .app-content table.table-hover > tbody > tr > td.text-end:last-child::before { display: none; }

    /* Filters fold into a "Filters" button */
    .filters-toggle { display: inline-flex; margin-bottom: 12px; }
    .filters-collapsible:not(.open) { display: none !important; }
    .stat-card { padding: 11px 12px; gap: 10px; border-radius: 14px; align-items: center; }
    .stat-card .stat-label { line-height: 1.25; }
    .welcome-card { padding: 14px 16px; gap: 10px; }
    .welcome-card .btn { --bs-btn-padding-y: 5px; --bs-btn-padding-x: 12px; --bs-btn-font-size: 13px; }
    .section-head { margin: 4px 0 10px; }
    .app-content table.table-hover > tbody > tr > td:empty { display: none; }
    .app-content table.table-hover > tbody > tr > td.dataTables_empty { display: block; text-align: center; padding: 30px 0 !important; border: 0 !important; }
    .app-content table.table-hover > tbody > tr:has(> td.dataTables_empty) { border-style: dashed; }
    .card:has(> .card-body > table.table-hover), .card:has(> .card-body > .dataTables_wrapper) { border: 0; background: transparent; }
    .card:has(> .card-body > table.table-hover) > .card-body, .card:has(> .card-body > .dataTables_wrapper) > .card-body { padding: 0; }
    .card > .table-responsive > table.table-hover { padding: 12px; }
    .card:has(> .table-responsive > table.table-hover) { border: 0; background: transparent; }
    .card:has(> .table-responsive > table.table-hover) > .card-header { border: 0; padding: 4px 2px 10px; }

    div.dataTables_wrapper div.dataTables_length { display: none; }
    div.dataTables_wrapper div.dataTables_filter { text-align: left; }
    div.dataTables_wrapper div.dataTables_filter label { display: block; width: 100%; }
    div.dataTables_wrapper div.dataTables_filter input { width: 100%; min-height: 44px; font-size: 16px; }
    .stat-icon { width: 32px; height: 32px; font-size: 15px; }
    div.dataTables_wrapper .row:first-child > div:first-child { display: none; }
    div.dataTables_wrapper div.dataTables_info { text-align: center; margin-bottom: 4px; }
    div.dataTables_wrapper div.dataTables_paginate ul.pagination { justify-content: center; }

    /* Big lists → one grouped native list (compact rows, hairline separators) */
    .app-content table.table-cards > tbody { background: #fff; border: 1px solid var(--pe-border); border-radius: 16px; overflow: hidden; }
    .app-content table.table-cards > tbody > tr { border: 0; border-bottom: 1px solid var(--pe-border); border-radius: 0; margin: 0; padding: 12px 14px; }
    .app-content table.table-cards > tbody > tr:last-child { border-bottom: 0; }
    .app-content table.table-cards > tbody > tr > td:not(.m-card):not(.dataTables_empty) { display: none !important; }
    .app-content table.table-cards > tbody > tr > td.m-card { display: block; padding: 0 !important; text-align: left; border: 0 !important; margin: 0; font-size: 13.5px; }
    .app-content table.table-cards > tbody > tr > td.m-card::before, .app-content table.table-cards > tbody > tr > td.m-card::after { display: none; }
    .app-content table.table-cards > tbody > tr:has(.lc-accent-danger) { box-shadow: inset 3px 0 0 #dc2626; }
    .app-content table.table-cards > tbody > tr:has(> td.dataTables_empty) { border: 0; }

    /* Dialogs → bottom sheets */
    .modal-dialog:not(.modal-fullscreen-sm-down) {
        position: fixed; left: 0; right: 0; bottom: 0; margin: 0; max-width: none; width: 100%;
        min-height: 0; display: flex; align-items: flex-end; transform: translateY(100%) !important; transition: transform .28s cubic-bezier(.2, .8, .2, 1) !important;
    }
    .modal.show .modal-dialog:not(.modal-fullscreen-sm-down) { transform: none !important; }
    .modal-dialog:not(.modal-fullscreen-sm-down) .modal-content { border-radius: 22px 22px 0 0; max-height: 92vh; padding-bottom: var(--pe-safe-bottom); }
    .modal-dialog:not(.modal-fullscreen-sm-down) .modal-content::before {
        content: ''; display: block; width: 38px; height: 5px; border-radius: 999px; background: #dcdce0; margin: 8px auto 0; flex-shrink: 0;
    }
    .modal-dialog-scrollable:not(.modal-fullscreen-sm-down) { height: auto; max-height: 92vh; }
    .modal-dialog-scrollable:not(.modal-fullscreen-sm-down) .modal-content { overflow: hidden; }
    .modal-dialog-scrollable .modal-body { overflow-y: auto; }
    .modal-header { padding: 14px 18px 4px; }
    .modal-body { padding: 12px 18px; }
    .modal-footer { padding: 8px 18px 16px; }
    .modal-footer > .btn, .modal-footer > div > .btn { flex: 1; }
    .modal-footer.justify-content-between > div { display: flex; gap: 8px; flex: 1; }
    .modal-fullscreen-sm-down .modal-content { border-radius: 0; padding-top: env(safe-area-inset-top, 0px); }

    .dropdown-menu { --bs-dropdown-font-size: 15px; }
    .dropdown-item { padding: 10px 12px; }
    .notif-dropdown { position: fixed !important; inset: calc(56px + env(safe-area-inset-top, 0px)) 8px auto 8px !important; transform: none !important; width: auto; max-width: none; }
    .notif-list { max-height: 60vh; }

    .row.g-4 { --bs-gutter-y: 1rem; }
    .error-code { font-size: 3.2rem; }

    .auth-form-side { padding: calc(18px + env(safe-area-inset-top, 0px)) 22px 22px; }
    .auth-center { align-items: flex-start; padding-top: 12vh; }
    .auth-card h1 { font-size: 30px; }

    /* ---- Compact mobile type scale (ElevenLabs-like): 13px body, 11–12px secondary ----
       The viewport meta has maximum-scale=1, so iOS does not zoom into inputs below 16px. */
    body { font-size: 13px; }
    .small, small { font-size: 11.5px; }
    .badge { font-size: 10.5px; padding: .3em .65em; }
    h5, .h5 { font-size: 15px; } h6, .h6 { font-size: 13.5px; }
    .page-title { font-size: 20px; letter-spacing: -.025em; }
    .page-header { margin-bottom: 12px; }
    .page-actions { margin-top: 10px; gap: 6px; }
    .page-actions .btn { --bs-btn-padding-y: 5px; --bs-btn-padding-x: 12px; --bs-btn-font-size: 12.5px; }
    .topbar-brand span { font-size: 14.5px; }
    .topbar-title { font-size: 14px; }
    .form-control, .form-select, .select2-container--bootstrap-5 .select2-selection { font-size: 14px; min-height: 40px; border-radius: 10px; }
    .form-control-sm, .form-select-sm { font-size: 13px; min-height: 36px; }
    .form-label { font-size: 12px; margin-bottom: 4px; }
    .form-text, .invalid-feedback { font-size: 11.5px; }
    .btn { --bs-btn-padding-y: 7px; --bs-btn-font-size: 13px; }
    .btn-sm { --bs-btn-padding-y: 4px; --bs-btn-font-size: 12px; }
    .table-actions .btn { width: 32px; height: 32px; }
    .quick-filters { margin-bottom: 10px; gap: 6px; }
    .quick-filters .btn { --bs-btn-padding-y: 4px; --bs-btn-padding-x: 11px; --bs-btn-font-size: 12px; }
    .filters-toggle { margin-bottom: 10px; }
    div.dataTables_wrapper div.dataTables_filter input { min-height: 38px; font-size: 13.5px; }
    div.dataTables_wrapper div.dataTables_info { font-size: 11.5px; }
    .card-header h6, .card-header .h6 { font-size: 13px; }
    .section-label { font-size: 12px; }
    .stat-value { font-size: 18px; }
    .stat-label { font-size: 11.5px; }
    .welcome-card h2 { font-size: 15.5px; }
    .welcome-card p { font-size: 12px; }
    .modal-title { font-size: 15.5px; }
    .dropdown-menu { --bs-dropdown-font-size: 13.5px; }
    .dropdown-item { padding: 9px 12px; }
    .sidebar-nav .nav-link { font-size: 14px; padding: 10px 12px; }
    .sidebar-nav .nav-link i { font-size: 17px; }
    .bottom-nav-item { font-size: 10px; }
    .bottom-nav-item i { font-size: 20px; }
    .fab { height: 46px; min-width: 46px; padding: 0 16px; font-size: 13.5px; }
    .fab .bi { font-size: 18px; }
    .alert { font-size: 12.5px; padding: 10px 12px; }
    .nav-tabs .nav-link, .nav-pills .nav-link, .side-nav .list-group-item { font-size: 12.5px; }
    .auth-card h1 { font-size: 24px; }
    /* generic list cards */
    .app-content table.table-hover > tbody > tr > td { font-size: 12.5px; }
    .app-content table.table-hover > tbody > tr > td::before { font-size: 11.5px; }
    .app-content table.table-hover > tbody > tr > td:first-child { font-size: 13.5px; }
    /* compact list cards (leads / complaints / follow-ups) */
    .app-content table.table-cards > tbody > tr { padding: 11px 13px; }
    .app-content table.table-cards > tbody > tr > td.m-card { font-size: 12.5px; }
    .lc { gap: 3px; }
    .lc-head { gap: 9px; }
    .lc-avatar { flex-basis: 30px; width: 30px; height: 30px; font-size: 10.5px; }
    .lc-head:has(.lc-avatar) ~ .lc-line, .lc-head:has(.lc-avatar) ~ .lc-foot { padding-left: 39px; }
    .lc-title { font-size: 13.5px; }
    .lc-sub { font-size: 11.5px; }
    .lc-line { font-size: 12px; }
    .lc-amt { font-size: 13px; }
    .lc-foot { margin-top: 3px; }
    .lc-actions { gap: 5px; }
    .lc-actions .btn { width: 32px; height: 32px; font-size: 13.5px; }
    .nc-item { padding: 11px 13px; gap: 10px; }
    .nc-icon { flex-basis: 30px; width: 30px; height: 30px; font-size: 13.5px; border-radius: 9px; }
    .nc-title { font-size: 13px; }
    .nc-body { font-size: 12px; }
    .nc-time { font-size: 11px; }
    /* tighter chrome */
    .page-back { font-size: 13px; }
    .card { border-radius: 16px; }
    .card-header { padding: 11px 14px; }
    .card-body { padding: 14px; }
    .app-content form .mb-3 { margin-bottom: 12px !important; }
    .app-content form .row.g-3 { --bs-gutter-y: .75rem; }
    .welcome-card { padding: 13px 14px; }
    .welcome-card .btn { --bs-btn-font-size: 12.5px; }
    .stat-card { padding: 10px 12px; gap: 10px; }
    .stat-icon { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }
    .section-head { margin: 2px 0 8px; }
    .fs-1 { font-size: 22px !important; } .fs-2 { font-size: 19px !important; } .fs-3 { font-size: 17px !important; }
    .fs-4 { font-size: 15.5px !important; } .fs-5 { font-size: 14px !important; } .fs-6 { font-size: 13.5px !important; }
    .display-6 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
