/*
 * PAX CRM Enterprise Interface V3
 * Structural redesign: navigation, application shell, responsive system,
 * content hierarchy, forms, cards, tables, dashboards and mobile layouts.
 */

:root {
    --ui-primary: #4f46e5;
    --ui-primary-hover: #4338ca;
    --ui-primary-strong: #3730a3;
    --ui-primary-soft: #eef2ff;
    --ui-accent: #06b6d4;
    --ui-success: #059669;
    --ui-warning: #d97706;
    --ui-danger: #dc2626;
    --ui-bg: #f4f6fb;
    --ui-surface: #ffffff;
    --ui-surface-subtle: #f8fafc;
    --ui-surface-muted: #f1f5f9;
    --ui-border: #e2e8f0;
    --ui-border-strong: #cbd5e1;
    --ui-text: #0f172a;
    --ui-muted: #64748b;
    --ui-muted-2: #94a3b8;
    --ui-sidebar: #07111f;
    --ui-sidebar-2: #0b172a;
    --ui-sidebar-width: 292px;
    --ui-sidebar-collapsed: 88px;
    --ui-topbar-height: 82px;
    --ui-control-height: 44px;
    --ui-page-gap: 22px;
    --ui-radius-sm: 10px;
    --ui-radius: 13px;
    --ui-radius-lg: 18px;
    --ui-radius-xl: 22px;
    --ui-shadow: 0 1px 2px rgba(15, 23, 42, .035), 0 10px 28px rgba(15, 23, 42, .045);
    --ui-shadow-hover: 0 18px 44px rgba(15, 23, 42, .10);
    --ui-shadow-popover: 0 24px 60px rgba(15, 23, 42, .20);
}

html { font-size: 16px !important; }
body {
    background:
        radial-gradient(circle at 78% -12%, rgba(79, 70, 229, .07), transparent 26rem),
        var(--ui-bg) !important;
    color: var(--ui-text) !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
}

/* --------------------------------------------------------------------------
   APPLICATION SHELL
   -------------------------------------------------------------------------- */
.crm-shell {
    min-height: 100dvh !important;
    --crm-sidebar-width: var(--ui-sidebar-width) !important;
}

html[data-crm-sidebar="collapsed"] .crm-shell {
    --crm-sidebar-width: var(--ui-sidebar-collapsed) !important;
}

.crm-sidebar-v3 {
    width: var(--crm-sidebar-width) !important;
    background:
        radial-gradient(circle at 20% 0%, rgba(99, 102, 241, .25), transparent 18rem),
        linear-gradient(180deg, var(--ui-sidebar) 0%, var(--ui-sidebar-2) 48%, #081321 100%) !important;
    border-right: 1px solid rgba(148, 163, 184, .13) !important;
    box-shadow: 16px 0 44px rgba(2, 6, 23, .10) !important;
}

.crm-sidebar-brandbar {
    min-height: 92px !important;
    padding: 18px 16px 14px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    border-bottom: 0 !important;
    background: transparent !important;
}

.crm-brand-lockup {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.crm-brand-logo {
    width: 48px !important;
    height: 48px !important;
    flex: 0 0 48px;
    border-radius: 15px !important;
    display: grid !important;
    place-items: center !important;
    overflow: hidden;
    color: #fff !important;
    background: linear-gradient(145deg, #6366f1, #4338ca) !important;
    border: 1px solid rgba(255, 255, 255, .20) !important;
    box-shadow: 0 12px 28px rgba(79, 70, 229, .35), inset 0 1px 0 rgba(255,255,255,.18) !important;
    font-size: 14px !important;
    font-weight: 850 !important;
}

.crm-brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 6px !important; }
.crm-brand-copy { min-width: 0; flex: 1; }
.crm-brand-kicker {
    margin-bottom: 2px;
    color: #818cf8;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.crm-brand-title {
    max-width: 176px !important;
    overflow: hidden;
    color: #f8fafc !important;
    font-size: 15px !important;
    font-weight: 760 !important;
    line-height: 1.25;
    letter-spacing: -.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.crm-brand-subtitle { display: none !important; }

.crm-sidebar-collapse {
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px;
    border: 1px solid rgba(148, 163, 184, .18) !important;
    border-radius: 10px !important;
    color: #a5b4fc !important;
    background: rgba(255, 255, 255, .055) !important;
    box-shadow: none !important;
}
.crm-sidebar-collapse:hover { color: #fff !important; background: rgba(99, 102, 241, .20) !important; border-color: rgba(129, 140, 248, .35) !important; }

.crm-sidebar-workspace {
    min-height: 66px;
    margin: 0 12px 12px;
    padding: 11px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(148, 163, 184, .14);
    border-radius: 14px;
    background: rgba(255, 255, 255, .045);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.crm-workspace-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: #c7d2fe;
    background: rgba(99, 102, 241, .16);
}
.crm-workspace-mark svg { width: 17px; height: 17px; }
.crm-workspace-copy { min-width: 0; flex: 1; }
.crm-workspace-copy span {
    display: block;
    color: #718198;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
}
.crm-workspace-copy strong {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: #e5e7eb;
    font-size: 11.5px;
    font-weight: 680;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.crm-workspace-status {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border: 2px solid rgba(16, 185, 129, .24);
    border-radius: 999px;
    background: #34d399;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .08);
}

.crm-sidebar-quick-actions { padding: 0 12px 8px; }
.crm-sidebar-create {
    min-height: 44px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(129, 140, 248, .30);
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    box-shadow: 0 10px 26px rgba(79, 70, 229, .24);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 720;
    transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.crm-sidebar-create:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 14px 30px rgba(79, 70, 229, .32); }
.crm-sidebar-create svg { width: 17px; height: 17px; }
.crm-sidebar-create span { min-width: 0; flex: 1; }
.crm-sidebar-create kbd {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 7px;
    color: #e0e7ff;
    background: rgba(255,255,255,.09);
    font: inherit;
    font-size: 13px;
}

.sidebar-scroll {
    padding: 4px 10px 18px !important;
    scrollbar-color: rgba(148, 163, 184, .30) transparent !important;
}
.crm-nav-group { margin-top: 12px; }
.crm-nav-group:first-child { margin-top: 4px; }
.sidebar-section-label {
    height: 26px;
    margin: 0 9px 5px !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    color: #687890 !important;
    font-size: 9px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    letter-spacing: .13em !important;
    text-transform: uppercase;
}
.sidebar-section-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-nav-items { display: grid; gap: 3px; }
.sidebar-link {
    position: relative;
    min-height: 43px !important;
    margin: 0 !important;
    padding: 0 12px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    border: 1px solid transparent !important;
    border-radius: 11px !important;
    color: #b8c3d3 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 12.5px !important;
    font-weight: 590 !important;
    line-height: 1.2 !important;
    transition: color .15s ease, background .15s ease, border-color .15s ease, transform .15s ease !important;
}
.sidebar-link::after {
    content: "";
    position: absolute;
    right: 10px;
    width: 5px;
    height: 5px;
    border-radius: 99px;
    background: transparent;
}
.sidebar-link svg {
    width: 18px !important;
    height: 18px !important;
    flex: 0 0 18px;
    color: #8190a6 !important;
    opacity: 1 !important;
}
.sidebar-link:hover {
    color: #f8fafc !important;
    background: rgba(255,255,255,.055) !important;
    border-color: rgba(148, 163, 184, .10) !important;
    transform: translateX(2px) !important;
}
.sidebar-link:hover svg { color: #c7d2fe !important; }
.sidebar-link.active {
    color: #fff !important;
    background: linear-gradient(90deg, rgba(79, 70, 229, .34), rgba(79, 70, 229, .13)) !important;
    border-color: rgba(129, 140, 248, .25) !important;
    box-shadow: inset 3px 0 0 #818cf8, 0 8px 20px rgba(2,6,23,.12) !important;
    font-weight: 700 !important;
}
.sidebar-link.active svg { color: #a5b4fc !important; }
.sidebar-link.active::after { background: #818cf8; box-shadow: 0 0 0 4px rgba(129, 140, 248, .10); }

.sidebar-footer {
    padding: 12px !important;
    border-top: 1px solid rgba(148, 163, 184, .11) !important;
    background: rgba(2, 6, 23, .18) !important;
}
.crm-sidebar-account {
    min-height: 58px;
    padding: 8px !important;
    gap: 10px !important;
    border: 1px solid rgba(148, 163, 184, .15) !important;
    border-radius: 14px !important;
    background: rgba(255,255,255,.045) !important;
}
.crm-sidebar-account:hover { background: rgba(255,255,255,.075) !important; border-color: rgba(129, 140, 248, .24) !important; }
.crm-sidebar-account-avatar {
    width: 38px !important;
    height: 38px !important;
    flex: 0 0 38px !important;
    border: 2px solid rgba(255,255,255,.12);
    border-radius: 11px !important;
    background: linear-gradient(145deg, #6366f1, #4338ca) !important;
    font-size: 12px !important;
}
.crm-sidebar-account-name { color: #f8fafc !important; font-size: 12px !important; font-weight: 700 !important; }
.crm-sidebar-account-role { margin-top: 2px !important; color: #7f8da1 !important; font-size: 9.5px !important; }
.crm-sidebar-signout { width: 34px !important; height: 34px !important; flex: 0 0 34px !important; border-radius: 10px !important; color: #fda4af !important; }
.crm-sidebar-signout:hover { background: rgba(244,63,94,.13) !important; color: #fecdd3 !important; }
.crm-sidebar-security {
    margin-top: 8px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    gap: 7px;
    color: #58677c;
    font-size: 8.5px;
    font-weight: 650;
    letter-spacing: .035em;
}
.crm-sidebar-security span { width: 6px; height: 6px; border-radius: 99px; background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.10); }

/* Collapsed desktop navigation */
html[data-crm-sidebar="collapsed"] .crm-sidebar-brandbar { justify-content: center !important; padding: 16px 12px !important; }
html[data-crm-sidebar="collapsed"] .crm-brand-lockup { flex: 0 0 auto; }
html[data-crm-sidebar="collapsed"] .crm-brand-logo { width: 46px !important; height: 46px !important; flex-basis: 46px; }
html[data-crm-sidebar="collapsed"] .crm-brand-copy,
html[data-crm-sidebar="collapsed"] .crm-sidebar-workspace .crm-workspace-copy,
html[data-crm-sidebar="collapsed"] .crm-sidebar-workspace .crm-workspace-status,
html[data-crm-sidebar="collapsed"] .crm-sidebar-create span,
html[data-crm-sidebar="collapsed"] .crm-sidebar-create kbd,
html[data-crm-sidebar="collapsed"] .sidebar-section-label,
html[data-crm-sidebar="collapsed"] .sidebar-link-label,
html[data-crm-sidebar="collapsed"] .crm-sidebar-account-copy,
html[data-crm-sidebar="collapsed"] .crm-sidebar-security { display: none !important; }
html[data-crm-sidebar="collapsed"] .crm-sidebar-collapse {
    position: absolute !important;
    top: 70px !important;
    right: -14px !important;
    color: #475569 !important;
    background: #fff !important;
    border-color: #dbe3ee !important;
    box-shadow: 0 8px 22px rgba(15,23,42,.16) !important;
    transform: rotate(180deg);
}
html[data-crm-sidebar="collapsed"] .crm-sidebar-workspace { justify-content: center; margin-inline: 12px; padding: 10px !important; }
html[data-crm-sidebar="collapsed"] .crm-sidebar-quick-actions { padding-inline: 12px; }
html[data-crm-sidebar="collapsed"] .crm-sidebar-create { justify-content: center; padding: 0 !important; }
html[data-crm-sidebar="collapsed"] .sidebar-scroll { padding-inline: 12px !important; }
html[data-crm-sidebar="collapsed"] .crm-nav-group { margin-top: 8px; }
html[data-crm-sidebar="collapsed"] .sidebar-link { justify-content: center !important; padding: 0 !important; }
html[data-crm-sidebar="collapsed"] .sidebar-link::after { right: 5px; }
html[data-crm-sidebar="collapsed"] .sidebar-link:hover { transform: none !important; }
html[data-crm-sidebar="collapsed"] .crm-sidebar-account { justify-content: center !important; padding: 8px !important; }
html[data-crm-sidebar="collapsed"] .crm-sidebar-signout { display: none !important; }

/* --------------------------------------------------------------------------
   TOP BAR
   -------------------------------------------------------------------------- */
.crm-main {
    width: calc(100% - var(--crm-sidebar-width)) !important;
    margin-left: var(--crm-sidebar-width) !important;
    padding-top: var(--ui-topbar-height) !important;
    transition: width .22s ease, margin-left .22s ease !important;
}
.crm-topbar {
    left: var(--crm-sidebar-width) !important;
    height: var(--ui-topbar-height) !important;
    background: rgba(255,255,255,.88) !important;
    border-bottom: 1px solid rgba(203, 213, 225, .78) !important;
    box-shadow: 0 8px 28px rgba(15,23,42,.025) !important;
    backdrop-filter: blur(20px) saturate(1.25) !important;
    transition: left .22s ease !important;
}
.crm-topbar-inner {
    height: 100% !important;
    padding: 0 28px !important;
    gap: 22px !important;
}
.crm-title-zone { min-width: 0; display: flex !important; align-items: center !important; gap: 13px !important; }
.crm-page-heading { min-width: 0; }
.crm-page-breadcrumb {
    height: 18px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    color: #94a3b8;
    font-size: 9.5px;
    font-weight: 650;
    white-space: nowrap;
}
.crm-page-breadcrumb svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.crm-page-breadcrumb strong { overflow: hidden; color: #64748b; font-weight: 700; text-overflow: ellipsis; }
.crm-title-row { min-width: 0; gap: 10px !important; }
.crm-page-title {
    max-width: min(34vw, 520px) !important;
    overflow: hidden;
    color: #0f172a !important;
    font-size: 19px !important;
    font-weight: 760 !important;
    line-height: 1.25 !important;
    letter-spacing: -.03em !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.crm-scope-pill {
    min-height: 25px !important;
    max-width: 190px;
    padding: 0 9px !important;
    gap: 7px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 999px !important;
    color: #475569 !important;
    background: #f8fafc !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
}
.crm-scope-icon { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 99px; background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.11); }
.crm-topbar-actions { gap: 8px !important; }
.crm-topbar-search-wrap { position: relative; }
.crm-search-icon { position: absolute; z-index: 1; left: 14px; top: 50%; display: grid; place-items: center; color: #94a3b8; transform: translateY(-50%); pointer-events: none; }
.crm-topbar-search {
    width: min(360px, 27vw) !important;
    height: 44px !important;
    padding: 0 42px 0 42px !important;
    border: 1px solid #dbe3ee !important;
    border-radius: 12px !important;
    color: #0f172a !important;
    background: #f8fafc !important;
    box-shadow: inset 0 1px 1px rgba(15,23,42,.015) !important;
    font-size: 12.5px !important;
    transition: border .15s ease, box-shadow .15s ease, background .15s ease !important;
}
.crm-topbar-search:focus { border-color: #818cf8 !important; background: #fff !important; box-shadow: 0 0 0 4px rgba(99,102,241,.11) !important; }
.crm-search-shortcut {
    position: absolute;
    right: 11px;
    top: 50%;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    color: #94a3b8;
    background: #fff;
    font: inherit;
    font-size: 11px;
    transform: translateY(-50%);
}
.crm-topbar-primary-action {
    height: 44px;
    padding: 0 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid #4338ca;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    box-shadow: 0 8px 20px rgba(79,70,229,.20);
    text-decoration: none;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}
.crm-topbar-primary-action:hover { filter: brightness(1.05); box-shadow: 0 12px 25px rgba(79,70,229,.27); }
.crm-topbar-primary-action span:first-child { font-size: 18px; font-weight: 400; line-height: 1; }
.crm-icon-button, .crm-mobile-menu-button, .crm-preferences-button, .crm-mobile-search-button {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border: 1px solid #dbe3ee !important;
    border-radius: 12px !important;
    color: #64748b !important;
    background: #fff !important;
}
.crm-icon-button:hover, .crm-mobile-menu-button:hover, .crm-preferences-button:hover, .crm-mobile-search-button:hover { color: #4338ca !important; border-color: #c7d2fe !important; background: #eef2ff !important; }
.crm-user-card {
    min-width: 0;
    min-height: 48px !important;
    padding: 4px 7px 4px 5px !important;
    display: flex !important;
    align-items: center !important;
    gap: 9px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px !important;
    color: #0f172a !important;
    background: #fff !important;
    text-decoration: none;
}
.crm-user-card:hover { border-color: #c7d2fe !important; background: #fafaff !important; box-shadow: 0 8px 22px rgba(15,23,42,.055) !important; }
.crm-user-avatar { width: 38px !important; height: 38px !important; flex: 0 0 38px; border-radius: 11px !important; background: linear-gradient(145deg,#6366f1,#4338ca) !important; font-size: 11px !important; }
.crm-user-copy { min-width: 0; width: 142px; }
.crm-user-name { overflow: hidden; color: #0f172a !important; font-size: 11.5px !important; font-weight: 750 !important; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.crm-user-meta { margin-top: 2px; display: flex; align-items: center; gap: 5px; overflow: hidden; color: #64748b; font-size: 9px; line-height: 1.2; }
.crm-user-meta span { flex: 0 0 auto; color: #4f46e5; font-weight: 750; }
.crm-user-meta small { min-width: 0; overflow: hidden; font-size: inherit; text-overflow: ellipsis; white-space: nowrap; }
.crm-user-chevron { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: #94a3b8; stroke-width: 1.8; }
.crm-notification-dropdown { width: min(420px, calc(100vw - 24px)) !important; overflow: hidden; border: 1px solid #dbe3ee !important; border-radius: 16px !important; box-shadow: var(--ui-shadow-popover) !important; }
.crm-notification-head { min-height: 70px; padding: 15px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #e2e8f0; background: #fff; }
.crm-notification-title { color: #0f172a; font-size: 13px; font-weight: 780; }
.crm-notification-subtitle { margin-top: 2px; color: #64748b; font-size: 10px; }
.crm-notification-readall { color: #4f46e5; font-size: 10px; font-weight: 720; }
.crm-notification-footer { padding: 11px; border-top: 1px solid #e2e8f0; background: #f8fafc; text-align: center; }
.crm-notification-footer a { color: #4f46e5; font-size: 10.5px; font-weight: 720; }

/* --------------------------------------------------------------------------
   WORKSPACE CONTENT
   -------------------------------------------------------------------------- */
.page-wrapper, .invoice-page-padding {
    width: 100% !important;
    max-width: 1760px !important;
    margin-inline: auto !important;
    padding: 28px 30px 48px !important;
}
.crm-page-wrapper, .crm-page-content { width: 100%; min-width: 0; }
.crm-page-content { color: #334155; }
.crm-page-content .space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: var(--ui-page-gap) !important; }
.crm-page-content h1, .crm-page-content h2, .crm-page-content h3 { color: #0f172a; letter-spacing: -.025em; }
.crm-page-content h1 { font-weight: 780 !important; }
.crm-page-content h2, .crm-page-content h3 { font-weight: 730 !important; }
.crm-page-content p { line-height: 1.65 !important; }

/* Raise the readability floor throughout legacy screens. */
.crm-page-content .text-\[8px\], .crm-page-content .text-\[8\.5px\],
.crm-page-content .text-\[9px\], .crm-page-content .text-\[9\.5px\] { font-size: 11px !important; line-height: 1.45 !important; }
.crm-page-content .text-\[10px\], .crm-page-content .text-\[10\.5px\] { font-size: 12px !important; line-height: 1.5 !important; }
.crm-page-content .text-\[11px\], .crm-page-content .text-\[11\.5px\] { font-size: 13px !important; line-height: 1.55 !important; }
.crm-page-content .text-\[12px\], .crm-page-content .text-\[12\.5px\] { font-size: 13.5px !important; line-height: 1.55 !important; }
.crm-page-content .text-\[13px\], .crm-page-content .text-\[13\.5px\], .crm-page-content .text-\[14px\] { font-size: 14px !important; }
.crm-page-content .text-\[18px\], .crm-page-content .text-\[20px\], .crm-page-content .text-\[21px\], .crm-page-content .text-\[22px\] { font-size: 22px !important; line-height: 1.25 !important; }
.crm-page-content .text-\[24px\], .crm-page-content .text-\[25px\], .crm-page-content .text-\[26px\], .crm-page-content .text-\[28px\] { font-size: 26px !important; line-height: 1.18 !important; }

/* Enterprise page intros */
.ui-page-intro, .audit-hero, .roles-hero, .pax-settings-hero, .pax-company-hero, .pax-form-hero {
    position: relative !important;
    overflow: hidden !important;
    padding: 24px 26px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 20px !important;
    color: #0f172a !important;
    background:
        radial-gradient(circle at 92% 10%, rgba(99,102,241,.12), transparent 17rem),
        linear-gradient(135deg, #fff, #f8faff) !important;
    box-shadow: var(--ui-shadow) !important;
}
.ui-page-intro::after, .audit-hero::after, .roles-hero::after, .pax-settings-hero::after, .pax-company-hero::after, .pax-form-hero::after {
    content: "";
    position: absolute;
    top: -34px;
    right: -30px;
    width: 120px;
    height: 120px;
    border: 1px solid rgba(99,102,241,.11);
    border-radius: 30px;
    transform: rotate(20deg);
    pointer-events: none;
}

/* Dashboard's lead hero intentionally uses a richer dark surface. */
.crm-dashboard .ent-hero {
    min-height: 132px;
    padding: 26px 28px !important;
    border: 1px solid rgba(129,140,248,.24) !important;
    border-radius: 22px !important;
    color: #fff !important;
    background:
        radial-gradient(circle at 88% -20%, rgba(6,182,212,.30), transparent 20rem),
        radial-gradient(circle at 20% 120%, rgba(99,102,241,.28), transparent 22rem),
        linear-gradient(135deg, #101a34 0%, #172554 52%, #312e81 100%) !important;
    box-shadow: 0 18px 50px rgba(30,41,89,.18) !important;
}
.crm-dashboard .ent-hero h1 { color: #fff !important; font-size: 25px !important; }
.crm-dashboard .ent-hero p { color: rgba(255,255,255,.68) !important; }
.crm-dashboard .ent-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(to left, #000, transparent 70%);
    pointer-events: none;
}

/* Cards and panels */
.ent-card, .ent-stat-card, .audit-panel, .roles-panel, .pax-panel,
.crm-page-content .bg-white.rounded-xl,
.crm-page-content .bg-white.rounded-2xl,
.crm-page-content section.bg-white,
.crm-page-content div[class*="shadow-sm"][class*="border"][class*="bg-white"] {
    border-color: #e2e8f0 !important;
    border-radius: 17px !important;
    background: #fff !important;
    box-shadow: var(--ui-shadow) !important;
}
.ent-card, .audit-panel, .roles-panel, .pax-panel { overflow: hidden; }
.ent-card-hover, .crm-page-content a.ent-card, .crm-page-content .hover\:shadow-md { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease !important; }
.ent-card-hover:hover, .crm-page-content a.ent-card:hover { transform: translateY(-2px) !important; border-color: #c7d2fe !important; box-shadow: var(--ui-shadow-hover) !important; }
.ent-stat-card {
    position: relative;
    min-height: 132px !important;
    padding: 19px !important;
    overflow: hidden;
}
.ent-stat-card::after {
    content: "";
    position: absolute;
    right: -25px;
    bottom: -40px;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: rgba(99,102,241,.035);
    pointer-events: none;
}
.ent-stat-card > div { position: relative; z-index: 1; }
.crm-dashboard-kpis { gap: 14px !important; }
.crm-page-content .rounded-2xl { border-radius: 16px !important; }
.crm-page-content .rounded-xl { border-radius: 13px !important; }

/* Buttons */
.ent-btn-primary, .enterprise-primary, .pax-btn-primary,
.crm-page-content button[type="submit"]:not(.crm-notification-readall):not(.ui-filter-toggle),
.crm-page-content a[class*="bg-blue-600"], .crm-page-content a[class*="bg-indigo-600"] {
    min-height: 42px !important;
    padding-inline: 15px !important;
    border: 1px solid #4338ca !important;
    border-radius: 11px !important;
    color: #fff !important;
    background: linear-gradient(135deg, #4f46e5, #4338ca) !important;
    box-shadow: 0 7px 17px rgba(79,70,229,.16) !important;
    font-size: 12px !important;
    font-weight: 720 !important;
}
.ent-btn-primary:hover, .enterprise-primary:hover, .pax-btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.crm-page-content button, .crm-page-content a[class*="inline-flex"], .audit-btn, .roles-btn, .pax-btn {
    border-radius: 11px !important;
}

/* Forms */
.crm-page-content label, .pax-field > span, .pax-logo-field > span, .pax-toggle > span {
    color: #334155 !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
}
.crm-page-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.crm-page-content select, .crm-page-content textarea,
.pax-field input, .pax-field select, .pax-field textarea {
    min-height: 44px !important;
    border: 1px solid #d7e0eb !important;
    border-radius: 11px !important;
    color: #0f172a !important;
    background: #fff !important;
    box-shadow: inset 0 1px 2px rgba(15,23,42,.02) !important;
    font-size: 13px !important;
    line-height: 1.45 !important;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease !important;
}
.crm-page-content textarea { min-height: 112px !important; padding-top: 11px !important; }
.crm-page-content input:focus, .crm-page-content select:focus, .crm-page-content textarea:focus,
.pax-field input:focus, .pax-field select:focus, .pax-field textarea:focus {
    border-color: #818cf8 !important;
    background: #fff !important;
    box-shadow: 0 0 0 4px rgba(99,102,241,.11) !important;
    outline: none !important;
}
.crm-page-content input::placeholder, .crm-page-content textarea::placeholder { color: #94a3b8 !important; }
.crm-filter-panel { padding: 17px !important; border-radius: 16px !important; }
.ui-filter-toggle { min-height: 40px !important; border-radius: 10px !important; font-size: 11.5px !important; }

/* Tables */
.crm-responsive-table, .crm-page-content .overflow-x-auto {
    border-radius: 16px !important;
    scrollbar-color: #cbd5e1 transparent;
}
.crm-page-content table { width: 100%; border-collapse: separate !important; border-spacing: 0 !important; }
.crm-page-content table thead { background: #f8fafc !important; }
.crm-page-content table th {
    padding: 13px 15px !important;
    border-bottom: 1px solid #dfe7f0 !important;
    color: #64748b !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    line-height: 1.35 !important;
    letter-spacing: .075em !important;
    text-transform: uppercase;
}
.crm-page-content table td {
    padding: 15px !important;
    border-bottom-color: #edf1f6 !important;
    color: #334155 !important;
    font-size: 12.5px !important;
    line-height: 1.5 !important;
    vertical-align: middle !important;
}
.crm-page-content table tbody tr { transition: background-color .14s ease, box-shadow .14s ease; }
.crm-page-content table tbody tr:hover { background: #fafbff !important; }
.enterprise-data-head { padding: 13px 15px !important; color: #64748b !important; font-size: 10px !important; }
.enterprise-data-row { padding: 16px 15px !important; border-color: #edf1f6 !important; }
.enterprise-data-row:hover { background: #fafbff !important; }
.ent-badge, .lead-pill, .crm-page-content span[class*="rounded-full"] { min-height: 25px !important; padding-inline: 9px !important; font-size: 10.5px !important; font-weight: 700 !important; }

/* Kanban */
.kanban-board { gap: 16px !important; padding-bottom: 12px !important; }
.kanban-column { min-width: 316px !important; width: 316px !important; border: 1px solid #e2e8f0 !important; border-radius: 17px !important; background: #f8fafc !important; }
.kanban-card { border: 1px solid #e2e8f0 !important; border-radius: 14px !important; background: #fff !important; box-shadow: 0 3px 12px rgba(15,23,42,.045) !important; }
.kanban-card:hover { transform: translateY(-2px) !important; border-color: #c7d2fe !important; box-shadow: var(--ui-shadow-hover) !important; }

/* Drawers */
.crm-preferences-drawer { width: min(420px, 100vw) !important; background: #fff !important; }
.crm-drawer-header { min-height: 78px !important; padding: 0 22px !important; border-bottom-color: #e2e8f0 !important; }
.crm-drawer-body { padding: 22px !important; }
.crm-setting-group { padding: 20px 0 !important; }
.crm-setting-title { color: #0f172a !important; font-size: 13px !important; }
.crm-setting-description { color: #64748b !important; font-size: 11px !important; }
.crm-segmented { padding: 4px !important; border-radius: 12px !important; background: #f1f5f9 !important; }
.crm-segmented button { min-height: 38px !important; border-radius: 9px !important; font-size: 11px !important; }
.crm-segmented button[aria-pressed="true"] { color: #3730a3 !important; background: #fff !important; box-shadow: 0 3px 10px rgba(15,23,42,.08) !important; }

/* Authentication */
.crm-auth-page {
    padding: 28px !important;
    background:
        radial-gradient(circle at 12% 10%, rgba(79,70,229,.14), transparent 26rem),
        radial-gradient(circle at 92% 84%, rgba(6,182,212,.11), transparent 22rem),
        #eef2f8 !important;
}
.crm-auth-page > .relative.w-full {
    max-width: 1120px !important;
    min-height: 660px !important;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.7) !important;
    border-radius: 28px !important;
    box-shadow: 0 36px 90px rgba(15,23,42,.20) !important;
}
.crm-auth-page > .relative.w-full > .bg-white { padding: 54px !important; }
.crm-auth-page input:not([type="checkbox"]) { height: 50px !important; border-radius: 12px !important; font-size: 14px !important; }
.crm-auth-page .ent-btn-primary { height: 50px !important; font-size: 13px !important; }

/* --------------------------------------------------------------------------
   DARK THEME
   -------------------------------------------------------------------------- */
html[data-crm-theme="dark"] {
    --ui-bg: #07101d;
    --ui-surface: #101a2b;
    --ui-surface-subtle: #152136;
    --ui-surface-muted: #1b2940;
    --ui-border: #26364d;
    --ui-border-strong: #3a4b65;
    --ui-text: #edf2f8;
    --ui-muted: #a4b1c3;
}
html[data-crm-theme="dark"] body { background: radial-gradient(circle at 80% -10%, rgba(79,70,229,.12), transparent 30rem), #07101d !important; }
html[data-crm-theme="dark"] .crm-topbar { background: rgba(16,26,43,.90) !important; border-bottom-color: #26364d !important; }
html[data-crm-theme="dark"] .crm-page-title, html[data-crm-theme="dark"] .crm-user-name, html[data-crm-theme="dark"] .crm-page-content h1, html[data-crm-theme="dark"] .crm-page-content h2, html[data-crm-theme="dark"] .crm-page-content h3 { color: #f1f5f9 !important; }
html[data-crm-theme="dark"] .crm-page-breadcrumb strong, html[data-crm-theme="dark"] .crm-user-meta, html[data-crm-theme="dark"] .crm-page-content { color: #a4b1c3 !important; }
html[data-crm-theme="dark"] .crm-topbar-search, html[data-crm-theme="dark"] .crm-user-card, html[data-crm-theme="dark"] .crm-icon-button, html[data-crm-theme="dark"] .crm-preferences-button, html[data-crm-theme="dark"] .crm-mobile-search-button { color: #dbe6f3 !important; background: #152136 !important; border-color: #2b3b54 !important; }
html[data-crm-theme="dark"] .crm-scope-pill { color: #cbd5e1 !important; background: #152136 !important; border-color: #2b3b54 !important; }
html[data-crm-theme="dark"] .ui-page-intro, html[data-crm-theme="dark"] .audit-hero, html[data-crm-theme="dark"] .roles-hero, html[data-crm-theme="dark"] .pax-settings-hero, html[data-crm-theme="dark"] .pax-company-hero, html[data-crm-theme="dark"] .pax-form-hero,
html[data-crm-theme="dark"] .ent-card, html[data-crm-theme="dark"] .ent-stat-card, html[data-crm-theme="dark"] .audit-panel, html[data-crm-theme="dark"] .roles-panel, html[data-crm-theme="dark"] .pax-panel,
html[data-crm-theme="dark"] .crm-page-content .bg-white.rounded-xl, html[data-crm-theme="dark"] .crm-page-content .bg-white.rounded-2xl, html[data-crm-theme="dark"] .crm-page-content section.bg-white { color: #dce5ef !important; background: #101a2b !important; border-color: #26364d !important; }
html[data-crm-theme="dark"] .crm-page-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]), html[data-crm-theme="dark"] .crm-page-content select, html[data-crm-theme="dark"] .crm-page-content textarea { color: #edf2f8 !important; background: #101a2b !important; border-color: #30415a !important; }
html[data-crm-theme="dark"] .crm-page-content table thead, html[data-crm-theme="dark"] .crm-page-content table tbody tr:hover, html[data-crm-theme="dark"] .enterprise-data-row:hover { background: #152136 !important; }
html[data-crm-theme="dark"] .crm-page-content table th { color: #9fb0c5 !important; border-bottom-color: #2b3b54 !important; }
html[data-crm-theme="dark"] .crm-page-content table td { color: #d7e0eb !important; border-bottom-color: #223149 !important; }
html[data-crm-theme="dark"] .crm-notification-head, html[data-crm-theme="dark"] .crm-notification-footer, html[data-crm-theme="dark"] .crm-preferences-drawer { background: #101a2b !important; border-color: #26364d !important; }

/* --------------------------------------------------------------------------
   RESPONSIVE SYSTEM
   -------------------------------------------------------------------------- */
@media (max-width: 1450px) {
    :root { --ui-sidebar-width: 272px; }
    .crm-topbar-inner { padding-inline: 22px !important; }
    .crm-topbar-search { width: min(300px, 23vw) !important; }
    .crm-user-copy { width: 118px; }
    .crm-dashboard-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@media (max-width: 1180px) {
    .crm-topbar-search { width: 250px !important; }
    .crm-user-copy, .crm-user-chevron { display: none !important; }
    .crm-user-card { padding: 4px !important; border-color: transparent !important; }
    .crm-topbar-primary-action { padding-inline: 12px; }
}

@media (max-width: 1023px) {
    :root { --ui-topbar-height: 74px; }
    .crm-shell { --crm-sidebar-width: 0px !important; }
    .crm-sidebar-v3 {
        width: min(326px, calc(100vw - 34px)) !important;
        transform: translateX(-104%) !important;
        box-shadow: 24px 0 60px rgba(2,6,23,.34) !important;
        transition: transform .24s ease !important;
    }
    html[data-crm-mobile-nav="open"] .crm-sidebar-v3 { transform: translateX(0) !important; }
    .crm-sidebar-collapse { display: none !important; }
    .crm-main { width: 100% !important; margin-left: 0 !important; }
    .crm-topbar { left: 0 !important; }
    .crm-mobile-menu-button { display: inline-flex !important; }
    .crm-topbar-inner { padding-inline: 18px !important; }
    .crm-topbar-search-wrap { display: none !important; }
    .crm-mobile-search-button { display: inline-flex !important; }
    .page-wrapper, .invoice-page-padding { padding: 24px 20px 40px !important; }
    .crm-mobile-search-panel { top: var(--ui-topbar-height) !important; min-height: 68px !important; padding: 11px 18px !important; border-bottom-color: #e2e8f0 !important; }
    .crm-mobile-search-panel input { height: 44px !important; border-radius: 11px !important; font-size: 13px !important; }
    .crm-mobile-backdrop { background: rgba(2,6,23,.58) !important; backdrop-filter: blur(3px); }
}

@media (max-width: 767px) {
    :root { --ui-topbar-height: 68px; --ui-page-gap: 16px; }
    .crm-sidebar-brandbar { min-height: 82px !important; }
    .crm-sidebar-v3 { width: min(318px, calc(100vw - 22px)) !important; }
    .crm-sidebar-workspace { margin-bottom: 10px; }
    .sidebar-link { min-height: 46px !important; font-size: 13px !important; }
    .crm-topbar-inner { padding-inline: 11px !important; gap: 8px !important; }
    .crm-title-zone { gap: 8px !important; }
    .crm-page-breadcrumb { display: none; }
    .crm-page-title { max-width: 34vw !important; font-size: 17px !important; }
    .crm-scope-pill { display: none !important; }
    .crm-topbar-actions { gap: 5px !important; }
    .crm-icon-button, .crm-mobile-menu-button, .crm-preferences-button, .crm-mobile-search-button { width: 40px !important; height: 40px !important; min-width: 40px !important; border-radius: 10px !important; }
    .crm-preferences-button { display: none !important; }
    .crm-topbar-primary-action { height: 40px; padding: 0 11px; border-radius: 10px; }
    .crm-topbar-primary-action span:last-child { display: none; }
    .crm-topbar-primary-action span:first-child { font-size: 20px; }
    .crm-user-card { min-height: 40px !important; padding: 2px !important; display: flex !important; border-color: transparent !important; background: transparent !important; }
    .crm-user-avatar { width: 36px !important; height: 36px !important; flex-basis: 36px; }
    .page-wrapper, .invoice-page-padding { padding: 16px 11px 32px !important; }
    .ui-page-intro, .audit-hero, .roles-hero, .pax-settings-hero, .pax-company-hero, .pax-form-hero { padding: 18px !important; border-radius: 16px !important; }
    .crm-dashboard .ent-hero { min-height: 0; padding: 20px !important; border-radius: 18px !important; }
    .crm-dashboard .ent-hero h1 { font-size: 22px !important; }
    .crm-dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
    .ent-stat-card { min-height: 118px !important; padding: 15px !important; }
    .crm-page-content .p-6 { padding: 18px !important; }
    .crm-page-content .p-5 { padding: 16px !important; }
    .crm-page-content .p-4 { padding: 14px !important; }
    .crm-responsive-table tr { padding: 11px 13px !important; border: 1px solid #e2e8f0 !important; border-radius: 14px !important; background: #fff !important; box-shadow: 0 4px 14px rgba(15,23,42,.035); }
    .crm-responsive-table td { grid-template-columns: minmax(105px, 34%) minmax(0, 1fr) !important; min-height: 40px !important; padding: 8px 0 !important; font-size: 12.5px !important; }
    .crm-responsive-table td::before { font-size: 9.5px !important; font-weight: 800 !important; letter-spacing: .04em; }
    .kanban-column { min-width: min(304px, calc(100vw - 42px)) !important; width: min(304px, calc(100vw - 42px)) !important; }
    .crm-notification-dropdown { position: fixed !important; top: 62px !important; right: 8px !important; left: 8px !important; width: auto !important; }
    .crm-auth-page { padding: 12px !important; }
    .crm-auth-page > .relative.w-full { min-height: 0 !important; border-radius: 20px !important; }
    .crm-auth-page > .relative.w-full > .bg-white { padding: 32px 22px !important; }
}

@media (max-width: 520px) {
    .crm-page-title { max-width: 30vw !important; font-size: 16px !important; }
    .crm-dashboard-kpis { grid-template-columns: 1fr !important; }
    .ent-stat-card { min-height: 108px !important; }
    .crm-page-content .enterprise-actions { width: 100%; display: grid !important; grid-template-columns: 1fr !important; gap: 8px !important; }
    .crm-page-content .enterprise-actions > * { width: 100% !important; justify-content: center !important; }
    .crm-page-content .flex.items-center.justify-between { align-items: flex-start !important; }
}

@media (max-width: 390px) {
    .crm-page-title { max-width: 27vw !important; }
    .crm-topbar-primary-action { display: none !important; }
    .crm-user-card { display: flex !important; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-link, .crm-sidebar-create, .ent-card-hover, .kanban-card { transition: none !important; }
    .sidebar-link:hover, .crm-sidebar-create:hover, .ent-card-hover:hover, .kanban-card:hover { transform: none !important; }
}
