* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); }
body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; font-weight: 400; }


/* ------------------------------------------------------------------
   Stage 9C4D — global premium checkbox control
   Keep native form semantics while removing browser/OS-specific gray
   checkbox rendering. Shared by all CRM and portal pages via app.css.
   ------------------------------------------------------------------ */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    margin: 0;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background-color: var(--surface);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 11px 11px;
    box-shadow: 0 1px 2px rgba(24, 37, 62, .04);
    cursor: pointer;
    vertical-align: middle;
    flex: 0 0 auto;
    transition: border-color .14s ease, background-color .14s ease, box-shadow .14s ease;
}

input[type="checkbox"]:hover:not(:disabled) {
    border-color: var(--primary);
    background-color: var(--primary-soft);
}

input[type="checkbox"]:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

input[type="checkbox"]:checked {
    border-color: var(--primary);
    background-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.2 6.6 11l5.9-6.2' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

input[type="checkbox"]:indeterminate {
    border-color: var(--primary);
    background-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

input[type="checkbox"]:disabled {
    border-color: var(--border);
    background-color: var(--surface-3);
    box-shadow: none;
    cursor: not-allowed;
    opacity: .72;
}

input[type="checkbox"]:checked:disabled,
input[type="checkbox"]:indeterminate:disabled {
    border-color: color-mix(in srgb, var(--primary) 62%, var(--border));
    background-color: color-mix(in srgb, var(--primary) 62%, var(--surface-3));
}
button { color: inherit; }
h1, h2, h3, h4, strong, b { font-weight: 500; }
a { color: inherit; text-decoration: none; }
.sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 228px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 18px 14px 16px;
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.sidebar-brand {
    height: 48px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 10px 12px;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -.2px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 0 10px;
    display: grid;
    gap: 3px;
    align-content: start;
}

.nav-group { min-width: 0; }

.nav-item {
    width: 100%;
    min-height: 40px;
    display: grid;
    grid-template-columns: 24px minmax(0,1fr) 18px;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.nav-item:hover { background: var(--surface-3); }

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    color: currentColor;
    flex: 0 0 auto;
}

.nav-chevron {
    justify-self: end;
    color: var(--muted);
    display: grid;
    place-items: center;
}
.nav-chevron .ui-svg {
    width: 14px;
    height: 14px;
}

.nav-children {
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    padding: 0 0 0 42px;
    transition:
        max-height .22s ease,
        opacity .16s ease,
        padding .18s ease,
        visibility 0s linear .22s;
}

.nav-children-inner {
    display: grid;
    gap: 1px;
}

.nav-group.is-open > .nav-children {
    max-height: 340px;
    opacity: 1;
    visibility: visible;
    padding: 4px 0 6px 42px;
    transition:
        max-height .22s ease,
        opacity .16s ease,
        padding .18s ease,
        visibility 0s;
}

.nav-children a {
    color: var(--muted);
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 14px;
    line-height: 1.35;
    transition: color .14s ease, background .14s ease;
}

.nav-children a:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.nav-children a.active {
    color: var(--primary);
    background: var(--primary-soft);
}

.nav-group.is-open > .nav-parent .nav-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

.nav-chevron {
    transition: transform .18s ease, color .18s ease;
}

.nav-parent.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.nav-item-spacer {
    width: 18px;
    height: 18px;
}

.sidebar-logout {
    margin-top: auto;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
}

.sidebar-logout:hover { background: var(--surface-3); }

.workspace {
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.workspace > .page-content {
    flex: 1 0 auto;
}

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 24px 0 18px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 500; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 13px;
}

.theme-segment {
    min-height: 36px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    background: var(--surface-3);
    border-radius: 11px;
    padding: 3px;
}

.theme-segment button {
    border: 0;
    background: transparent;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--muted);
}

html[data-theme="light"] .theme-segment button[data-theme-set="light"],
html[data-theme="dark"] .theme-segment button[data-theme-set="dark"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.theme-moon { color: var(--muted); padding: 0 1px; }

.icon-btn {
    position: relative;
    border: 0;
    background: transparent;
    min-width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    cursor: pointer;
}

.icon-btn:hover { background: var(--surface-3); }

.icon-btn .ui-svg {
    width: 18px;
    height: 18px;
}

.notification-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 17px;
    height: 17px;
    background: var(--red);
    color: white;
    border: 2px solid var(--surface);
    border-radius: 99px;
    display: grid;
    place-items: center;
    font-size: 11px;
}

.profile-menu {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-left: 3px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--muted);
    display: grid;
    place-items: center;
}

.profile-copy { display: grid; line-height: 1.15; min-width: 65px; }
.profile-copy strong { font-size: 14px; }
.profile-copy span { color: var(--muted); font-size: 13px; margin-top: 3px; }
.profile-arrow {
    color: var(--muted);
    display: grid;
    place-items: center;
}
.profile-arrow .ui-svg {
    width: 14px;
    height: 14px;
}

.page-content { padding: 20px; }

.panel,
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.primary-btn,
.secondary-btn {
    min-height: 38px;
    border-radius: 8px;
    padding: 8px 13px;
    border: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
}

.primary-btn {
    background: var(--action-primary, #4b7be5);
    border-color: var(--action-primary, #4b7be5);
    color: #fff;
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .12s ease;
}

.primary-btn:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--action-primary-hover, #3f6bd1);
    border-color: var(--action-primary-hover, #3f6bd1);
}

.primary-btn:active:not(:disabled):not([aria-disabled="true"]) {
    background: var(--action-primary-active, #355fbe);
    border-color: var(--action-primary-active, #355fbe);
    transform: translateY(1px);
}

.primary-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--action-primary, #4b7be5) 22%, transparent);
}

.secondary-btn {
    background: var(--surface);
    color: var(--text);
}

.secondary-btn:hover { background: var(--surface-3); }

.mobile-menu { display: none; }
.mobile-backdrop { display: none; }

/* Stage 2 shared footer + authentication */
.app-footer {
    min-height: 54px;
    border-top: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
    background: var(--surface);
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.auth-shell { width: min(430px, 100%); }

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 34px;
}

.auth-card h1 { margin: 12px 0 4px; font-size: 26px; }
.auth-card > p { margin: 0 0 24px; }
.auth-card form { display: grid; gap: 9px; }
.auth-card label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.auth-card input {
    width: 100%;
    height: 42px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    outline: none;
}
.auth-card input:focus { border-color: var(--primary); }
.auth-logo { width: 46px; height: 46px; }
.auth-submit { margin-top: 8px; }
.theme-link {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 16px 0 0;
}

.alert, .notice {
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 13px;
}
.alert, .notice.error {
    border: 1px solid rgba(226,85,85,.28);
    background: var(--red-soft);
    color: var(--red);
}
.notice.success {
    border: 1px solid rgba(56,165,107,.28);
    background: var(--green-soft);
    color: var(--green);
}
.notice { margin-bottom: 14px; }

.ui-svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    flex: 0 0 auto;
    display: block;
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        width: 228px;
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .mobile-menu { display: grid; }
    .mobile-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 45;
    }
    body.sidebar-open .mobile-backdrop { display: block; }
}

@media (max-width: 620px) {
    .topbar { padding: 0 12px; }
    .page-content { padding: 12px; }
    .profile-copy, .profile-arrow { display:none; }
    .theme-segment button { padding-inline: 7px; }
    .app-footer { align-items: flex-start; flex-direction: column; }
}


/* ------------------------------------------------------------------
   Stage 7A — shared sidebar scrollbar + notification dropdown
   These components live in the shared layout, so their styling must
   live in app.css and not only on notification-specific pages.
   ------------------------------------------------------------------ */

/* Premium sidebar scrollbar: subtle in both light and dark mode. */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-gutter: stable;
}

.sidebar-nav::-webkit-scrollbar {
    width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    min-height: 48px;
    background: var(--border-strong);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--muted-2);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.sidebar-nav::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* Notification dropdown belongs to the global topbar. */
.notification-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.notification-dropdown {
    position: absolute;
    right: -8px;
    top: calc(100% + 10px);
    width: 390px;
    max-width: calc(100vw - 28px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 52px rgba(20, 30, 50, .16);
    overflow: hidden;
    display: none;
    z-index: 120;
}

html[data-theme="dark"] .notification-dropdown {
    box-shadow: 0 22px 58px rgba(0, 0, 0, .38);
}

.notification-dropdown.is-open {
    display: block;
}

.notification-dropdown::before {
    content: "";
    position: absolute;
    right: 19px;
    top: -6px;
    width: 11px;
    height: 11px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: rotate(45deg);
}

.notification-dropdown-head {
    position: relative;
    z-index: 1;
    min-height: 62px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.notification-dropdown-head > div {
    display: grid;
    gap: 2px;
}

.notification-dropdown-head strong {
    font-size: 14px;
    font-weight: 500;
}

.notification-dropdown-head span {
    color: var(--muted);
    font-size: 12px;
}

.notification-dropdown-head a {
    min-height: 30px;
    padding: 6px 9px;
    border-radius: 7px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
}

.notification-mini-list {
    display: grid;
    max-height: 360px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.notification-mini-list > a {
    min-height: 72px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr);
    gap: 10px;
    color: var(--text);
    background: var(--surface);
}

.notification-mini-list > a:hover {
    background: var(--surface-2);
}

.notification-mini-list > a.unread {
    background: var(--primary-soft);
}

.notification-mini-list > a:last-child {
    border-bottom: 0;
}

.notification-mini-list > a > div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.notification-mini-list strong {
    display: block;
    font-size: 12px;
    line-height: 1.35;
    font-weight: 500;
}

.notification-mini-list span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-mini-list small {
    display: block;
    color: var(--muted-2);
    font-size: 10px;
}

.notification-mini-empty {
    min-height: 118px;
    padding: 20px;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

.notification-severity {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 4px;
}

.notification-severity.info { background: var(--primary); }
.notification-severity.success { background: var(--green); }
.notification-severity.warning { background: var(--amber); }
.notification-severity.critical { background: var(--red); }

.notification-settings-link {
    min-height: 40px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--primary);
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-settings-link:hover {
    background: var(--primary-soft);
}

@media (max-width: 620px) {
    .notification-dropdown {
        position: fixed;
        top: 68px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }

    .notification-dropdown::before {
        display: none;
    }
}


/* ------------------------------------------------------------------
   Stage 8A2 — Global typography standard
   Keep the approved light-weight visual language, but eliminate micro
   text so all modules remain comfortably readable at desktop scale.
   ------------------------------------------------------------------ */
body {
    font-size: 15px;
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font-size: 13px;
    line-height: 1.4;
}

.sidebar-brand { font-size: 20px; }
.nav-item { font-size: 14px; }
.nav-children a { font-size: 13px; }
.topbar h1 { font-size: 19px; }

.page-intro h1,
.page-intro h2 { font-size: 21px; }
.page-intro p { font-size: 13px; }

.section-heading-pro h3,
.mini-heading h3 { font-size: 15px; }
.section-heading-pro p { font-size: 12px; }

.directory-table th {
    font-size: 12px;
    line-height: 1.35;
}
.directory-table td {
    font-size: 13px;
    line-height: 1.4;
}
.cell-stack strong { font-size: 13px; }
.cell-stack small { font-size: 11px; }
.record-count { font-size: 12px; }
.status-pill { font-size: 11px; }

.toolbar-search input,
.panel-toolbar input,
.panel-toolbar select,
.form-grid input,
.form-grid select,
.form-grid textarea {
    font-size: 13px;
}

.primary-btn,
.secondary-btn {
    font-size: 13px;
}

/* Shared compact secondary control. Previously some pages rendered
   text-link-button as an unstyled native gray browser button. */
.text-link-button {
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--primary);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.text-link-button:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.app-footer {
    font-size: 12px;
}


/* ------------------------------------------------------------------
   Stage 8A4 — Global in-app toast system
   success = green, error = red, warning = amber, info = primary blue.
   ------------------------------------------------------------------ */
.rpm-toast-seed {
    display: none !important;
}

.rpm-toast-stack {
    position: fixed;
    top: 76px;
    right: 18px;
    z-index: 250;
    width: min(390px, calc(100vw - 28px));
    display: grid;
    gap: 10px;
    pointer-events: none;
}

.rpm-toast {
    position: relative;
    min-height: 68px;
    padding: 12px 42px 13px 12px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(18, 28, 48, .16);
    opacity: 0;
    transform: translateY(-8px) translateX(10px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: auto;
}

html[data-theme="dark"] .rpm-toast {
    box-shadow: 0 22px 58px rgba(0, 0, 0, .38);
}

.rpm-toast.is-visible {
    opacity: 1;
    transform: translateY(0) translateX(0);
}

.rpm-toast.is-leaving {
    opacity: 0;
    transform: translateX(18px);
}

.rpm-toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 600;
}

.rpm-toast-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.rpm-toast-copy strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}

.rpm-toast-copy span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.rpm-toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
}

.rpm-toast-close:hover {
    background: var(--surface-3);
    color: var(--text);
}

.rpm-toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    transform-origin: left center;
    animation: rpm-toast-countdown linear forwards;
}

.rpm-toast-success {
    border-color: color-mix(in srgb, var(--green) 28%, var(--border));
}
.rpm-toast-success .rpm-toast-icon {
    background: var(--green-soft);
    color: var(--green);
}
.rpm-toast-success .rpm-toast-progress {
    background: var(--green);
}

.rpm-toast-error {
    border-color: color-mix(in srgb, var(--red) 30%, var(--border));
}
.rpm-toast-error .rpm-toast-icon {
    background: var(--red-soft);
    color: var(--red);
}
.rpm-toast-error .rpm-toast-progress {
    background: var(--red);
}

.rpm-toast-warning {
    border-color: color-mix(in srgb, var(--amber) 30%, var(--border));
}
.rpm-toast-warning .rpm-toast-icon {
    background: var(--amber-soft);
    color: var(--amber);
}
.rpm-toast-warning .rpm-toast-progress {
    background: var(--amber);
}

.rpm-toast-info {
    border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
}
.rpm-toast-info .rpm-toast-icon {
    background: var(--primary-soft);
    color: var(--primary);
}
.rpm-toast-info .rpm-toast-progress {
    background: var(--primary);
}

@keyframes rpm-toast-countdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.field-manage-modal {
    width: min(680px, 100%);
}

.field-governance-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.field-governance-strip > div {
    min-height: 62px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    display: grid;
    align-content: center;
    gap: 3px;
}

.field-governance-strip span {
    color: var(--muted);
    font-size: 11px;
}

.field-governance-strip strong {
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.field-governance-note {
    margin-bottom: 13px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 11px;
    line-height: 1.45;
}

.field-manage-modal .form-grid small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

@media (max-width: 680px) {
    .rpm-toast-stack {
        top: 68px;
        right: 12px;
        left: 12px;
        width: auto;
    }

    .field-governance-strip {
        grid-template-columns: 1fr 1fr;
    }
}


/* ------------------------------------------------------------------
   Stage 8A7 — CRM-wide KPI and status visual standard
   ------------------------------------------------------------------ */

/* All non-icon KPI cards use the same vertical rhythm and typography. */
html body :is(
    .mini-admin-kpi,
    .report-kpi,
    .verify-kpi,
    .notification-kpi,
    .form-setting-kpi,
    .mini-kpi
) {
    min-height: 108px;
    padding: 16px 18px;
    align-content: center;
}

html body :is(
    .mini-admin-kpi,
    .report-kpi,
    .verify-kpi,
    .notification-kpi,
    .form-setting-kpi,
    .mini-kpi
) > span:first-child {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.3;
}

html body :is(
    .mini-admin-kpi,
    .report-kpi,
    .verify-kpi,
    .notification-kpi,
    .form-setting-kpi,
    .mini-kpi
) > strong {
    margin: 4px 0 3px;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.08;
}

html body :is(
    .mini-admin-kpi,
    .report-kpi,
    .verify-kpi,
    .notification-kpi,
    .form-setting-kpi,
    .mini-kpi
) > small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

/* One standard status-pill geometry across every module. */
html body .status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 25px;
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
}

/* Qualification and Verification status colors are shared everywhere. */
html body .status-pill:is(.qualification-qualified, .verification-verified) {
    background: var(--green-soft);
    color: var(--green);
    border-color: color-mix(in srgb, var(--green) 20%, transparent);
}

html body .status-pill:is(.qualification-disqualified, .verification-disqualified) {
    background: var(--red-soft);
    color: var(--red);
    border-color: color-mix(in srgb, var(--red) 20%, transparent);
}

html body .status-pill:is(.qualification-pending, .verification-pending) {
    background: var(--amber-soft);
    color: var(--amber);
    border-color: color-mix(in srgb, var(--amber) 20%, transparent);
}

html body .status-pill.verification-needs_followup {
    background: var(--purple-soft);
    color: var(--purple);
    border-color: color-mix(in srgb, var(--purple) 20%, transparent);
}

/* Shared status controls should never look like raw text highlighting. */
html body :is(
    .status-pill.active,
    .status-pill.form-published,
    .status-pill.form-received,
    .status-pill.form-reviewed,
    .status-pill.form-promoted
) {
    border-radius: 999px;
}



/* Stage 8A8B — GLOBAL sidebar icon standard. All portals inherit this. */
.nav-icon .ui-svg {
    width: 18px;
    height: 18px;
    display: block;
}


/* ------------------------------------------------------------------
   Stage 8A10 — GLOBAL premium back navigation
   One component for every Admin and Affiliate page.
   ------------------------------------------------------------------ */
.crm-back-link {
    width: max-content;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 3px 9px 3px 3px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 400;
    line-height: 1;
    transition:
        color .15s ease,
        background .15s ease,
        border-color .15s ease,
        transform .15s ease;
}

.crm-back-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    transition:
        color .15s ease,
        background .15s ease,
        border-color .15s ease;
}

.crm-back-icon .ui-svg {
    width: 15px;
    height: 15px;
    display: block;
}

.crm-back-label {
    display: block;
    white-space: nowrap;
}

.crm-back-link:hover {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: color-mix(in srgb, var(--primary) 20%, var(--border));
    transform: translateX(-1px);
}

.crm-back-link:hover .crm-back-icon {
    color: var(--primary);
    background: var(--surface);
    border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
}

.crm-back-link:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--primary) 52%, transparent);
    outline-offset: 2px;
}

@media (max-width: 560px) {
    .crm-back-link {
        max-width: 100%;
    }

    .crm-back-label {
        overflow: hidden;
        text-overflow: ellipsis;
    }
}


/* ------------------------------------------------------------------
   Stage 8A11 — GLOBAL account menu
   Used by Super Admin, Admin, Manager, Agent, Verifier and Affiliate.
   ------------------------------------------------------------------ */
.account-menu { position: relative; }

.account-menu .profile-menu {
    min-height: 46px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-align: left;
    padding: 5px 7px 5px 3px;
}

.account-menu .profile-menu:hover,
.account-menu .profile-menu[aria-expanded="true"] {
    background: var(--surface-3);
}

.account-menu .profile-arrow {
    transition: transform .15s ease;
}

.account-menu .profile-menu[aria-expanded="true"] .profile-arrow {
    transform: rotate(180deg);
}

.account-dropdown {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    z-index: 190;
    width: 310px;
    display: none;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 20px 52px rgba(10, 22, 40, .16);
}

html[data-theme="dark"] .account-dropdown {
    box-shadow: 0 24px 64px rgba(0, 0, 0, .44);
}

.account-dropdown.is-open { display: block; }

.account-dropdown-head {
    min-height: 82px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.account-dropdown-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
}

.account-dropdown-head > div:last-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.account-dropdown-head strong {
    overflow: hidden;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-dropdown-head span {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-dropdown-head small {
    color: var(--primary);
    font-size: 10px;
}

.account-dropdown-list {
    padding: 7px;
    display: grid;
    gap: 2px;
}

.account-dropdown-list > a,
.account-dropdown-foot > a {
    min-height: 52px;
    padding: 8px 9px;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 9px;
    align-items: center;
    color: var(--text);
    text-decoration: none;
}

.account-dropdown-list > a:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.account-dropdown-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
}

.account-dropdown-icon .ui-svg {
    width: 16px;
    height: 16px;
}

.account-dropdown-list > a:hover .account-dropdown-icon {
    border-color: color-mix(in srgb, var(--primary) 26%, var(--border));
    background: var(--surface);
    color: var(--primary);
}

.account-dropdown-list > a > span:last-child,
.account-dropdown-foot > a > span:last-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.account-dropdown-list strong,
.account-dropdown-foot strong {
    font-size: 12px;
    font-weight: 500;
}

.account-dropdown-list small,
.account-dropdown-foot small {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.3;
}

.account-dropdown-foot {
    padding: 7px;
    border-top: 1px solid var(--border);
}

.account-dropdown-foot .account-logout { color: var(--red); }
.account-dropdown-foot .account-logout:hover { background: var(--red-soft); }
.account-dropdown-foot .account-logout .account-dropdown-icon { color: var(--red); }

/* Shared My Account page */
.account-page-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
    gap: 14px;
    margin-bottom: 14px;
}

.account-profile-card,
.account-security-card,
.account-access-panel { overflow: hidden; }

.account-profile-identity {
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 13px;
    border-bottom: 1px solid var(--border);
}

.account-page-avatar {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 18px;
    font-weight: 500;
}

.account-profile-identity > div:last-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.account-profile-identity h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 500;
}

.account-profile-identity span {
    color: var(--muted);
    font-size: 12px;
}

.account-profile-identity small {
    color: var(--primary);
    font-size: 11px;
}

.account-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.account-detail-grid > div {
    min-height: 72px;
    padding: 13px 16px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: grid;
    align-content: center;
    gap: 4px;
}

.account-detail-grid > div:nth-child(2n) { border-right: 0; }
.account-detail-grid span { color: var(--muted); font-size: 11px; }
.account-detail-grid strong { font-size: 12px; font-weight: 500; }

.account-shortcuts { display: grid; }

.account-shortcuts > a {
    min-height: 68px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 24px;
    gap: 10px;
    align-items: center;
    color: var(--text);
    text-decoration: none;
}

.account-shortcuts > a:last-child { border-bottom: 0; }
.account-shortcuts > a:hover { background: var(--primary-soft); }

.account-shortcut-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--primary);
}

.account-shortcut-icon .ui-svg { width: 17px; height: 17px; }

.account-shortcuts > a > span:nth-child(2) {
    display: grid;
    gap: 3px;
}

.account-shortcuts strong { font-size: 12px; font-weight: 500; }
.account-shortcuts small { color: var(--muted); font-size: 10px; }
.account-shortcut-arrow { color: var(--muted); text-align: right; }

.account-permission-modules {
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.account-permission-modules > div {
    min-height: 66px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    display: grid;
    align-content: center;
    gap: 4px;
}

.account-permission-modules span { color: var(--muted); font-size: 11px; }
.account-permission-modules strong { font-size: 18px; font-weight: 500; }

@media (max-width: 1050px) {
    .account-page-grid { grid-template-columns: 1fr; }
    .account-permission-modules { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .account-dropdown {
        position: fixed;
        top: 68px;
        right: 12px;
        left: 12px;
        width: auto;
    }

    .account-detail-grid,
    .account-permission-modules { grid-template-columns: 1fr; }

    .account-detail-grid > div { border-right: 0; }
}


/* ------------------------------------------------------------------
   Stage 8A12 — GLOBAL premium forward navigation
   Mirror of the approved global back-navigation component.
   ------------------------------------------------------------------ */
.crm-forward-link {
    width: max-content;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 3px 3px 3px 9px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 400;
    line-height: 1;
    transition:
        color .15s ease,
        background .15s ease,
        border-color .15s ease,
        transform .15s ease;
}

.crm-forward-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    transition:
        color .15s ease,
        background .15s ease,
        border-color .15s ease;
}

.crm-forward-icon .ui-svg {
    width: 15px;
    height: 15px;
    display: block;
}

.crm-forward-label {
    display: block;
    white-space: nowrap;
}

.crm-forward-link:hover {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: color-mix(in srgb, var(--primary) 20%, var(--border));
    transform: translateX(1px);
}

.crm-forward-link:hover .crm-forward-icon {
    color: var(--primary);
    background: var(--surface);
    border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
}

.crm-forward-link:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--primary) 52%, transparent);
    outline-offset: 2px;
}

.crm-forward-icon.compact {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
}

/* Account shortcuts now use the same global forward control. */
.account-shortcuts > a {
    grid-template-columns: 36px minmax(0, 1fr) 32px;
}

.account-shortcuts > a > .crm-forward-icon {
    justify-self: end;
}

/* My Account — aligned Current Access header and module register. */
.account-access-panel {
    overflow: hidden;
}

.account-access-head {
    min-height: 82px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.account-access-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.account-access-copy h3 {
    margin: 0;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.25;
}

.account-access-copy p {
    margin: 0;
    max-width: 900px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.account-access-count {
    min-height: 30px;
    padding: 6px 10px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.account-permission-modules {
    padding: 14px 16px 16px;
    align-items: stretch;
}

.account-permission-modules > div {
    min-height: 68px;
    padding: 11px 12px;
}

.account-security-card .section-heading-pro {
    min-height: 72px;
    padding: 15px 18px;
    display: flex;
    align-items: center;
}

@media (max-width: 620px) {
    .crm-forward-link {
        max-width: 100%;
    }

    .crm-forward-label {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .account-access-head {
        min-height: 0;
        flex-direction: column;
        align-items: stretch;
    }

    .account-access-count {
        width: max-content;
    }
}


/* Stage 8A12A — icon-only forward actions */
.crm-forward-action {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    text-decoration: none;
}

.crm-forward-action:hover .crm-forward-icon {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
}

/* ------------------------------------------------------------------
   Stage 8A14 — Lead Edit / My Account / Appointment alignment
   ------------------------------------------------------------------ */

/* 1) Lead Edit
   Keep the minimum-intake notice aligned with the 24px form/header grid. */
.lead-form-card > .minimum-edit-note {
    margin: 16px 24px 0;
    padding: 10px 12px;
    border-radius: 8px;
}

.lead-form-card > .minimum-edit-note + form .dynamic-form-grid {
    padding-top: 16px;
}

/* Keep the note comfortable on compact screens. */
@media (max-width: 620px) {
    .lead-form-card > .minimum-edit-note {
        margin-left: 16px;
        margin-right: 16px;
    }
}

/* 2) My Account
   Remove the old full-width table/divider appearance and use premium
   information tiles inside one profile panel. */
.account-page-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
    align-items: stretch;
}

.account-page-grid > .panel {
    min-width: 0;
}

.account-profile-card,
.account-security-card {
    height: 100%;
}

.account-detail-grid {
    padding: 14px;
    gap: 10px;
    background: transparent;
}

.account-detail-grid > div {
    min-height: 68px;
    padding: 11px 12px;
    border: 1px solid var(--border) !important;
    border-radius: 9px;
    background: var(--surface-2);
}

.account-detail-grid > div:nth-child(2n) {
    border-right: 1px solid var(--border) !important;
}

.account-detail-grid span {
    margin: 0;
}

.account-detail-grid strong {
    margin: 0;
    overflow-wrap: anywhere;
}

/* Security side now aligns to the same top/bottom rhythm. */
.account-security-card {
    display: flex;
    flex-direction: column;
}

.account-security-card .account-shortcuts {
    flex: 1;
    align-content: start;
}

.account-security-card .account-shortcuts > a {
    min-height: 72px;
}

/* Current Access keeps one clean panel, not a second table treatment. */
.account-access-panel .account-permission-modules {
    background: transparent;
}

.account-access-panel .account-permission-modules > div {
    border-radius: 9px;
}

/* 3) Appointment Manage
   Make the form panel use a real contained content area plus a full-width
   premium save footer instead of a floating left-aligned button. */
.page-content .appointment-manage-grid > .panel {
    min-width: 0;
    overflow: hidden;
}

.page-content .appointment-manage-grid .appointment-edit-form {
    padding: 0;
}

.page-content .appointment-manage-grid .appointment-edit-form > .form-grid {
    padding: 16px;
}

.page-content .appointment-manage-grid .appointment-edit-form > .inline-save {
    min-height: 64px;
    margin: 0;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* Save button follows the normal CRM control height. */
.page-content .appointment-manage-grid .appointment-edit-form > .inline-save .primary-btn {
    min-height: 38px;
}

/* Keep Notes aligned with the two-column inputs. */
.page-content .appointment-manage-grid .appointment-edit-form textarea {
    width: 100%;
    resize: vertical;
}

@media (max-width: 1050px) {
    .account-page-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 650px) {
    .account-detail-grid {
        grid-template-columns: 1fr;
    }

    .page-content .appointment-manage-grid .appointment-edit-form > .form-grid {
        padding: 14px;
    }

    .page-content .appointment-manage-grid .appointment-edit-form > .inline-save {
        padding: 12px 14px;
    }
}

/* ------------------------------------------------------------------
   Stage 8A15 — GLOBAL premium access denied page
   ------------------------------------------------------------------ */
.crm-access-page {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 8%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 32%),
        radial-gradient(circle at 82% 85%, color-mix(in srgb, var(--purple) 7%, transparent), transparent 30%),
        var(--bg);
    color: var(--text);
}

.crm-access-shell {
    min-height: 100vh;
    padding: 34px 24px 18px;
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 28px;
    align-items: center;
}

.crm-access-card {
    width: min(680px, 100%);
    margin: auto;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    box-shadow: 0 28px 85px rgba(9, 20, 38, .13);
    position: relative;
    overflow: hidden;
}

html[data-theme="dark"] .crm-access-card {
    box-shadow: 0 32px 95px rgba(0, 0, 0, .42);
}

.crm-access-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(
        90deg,
        var(--primary),
        color-mix(in srgb, var(--primary) 48%, var(--purple))
    );
}

.crm-access-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.crm-access-brand-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    color: var(--primary);
}

.crm-access-brand-mark svg {
    width: 26px;
    height: 26px;
}

.crm-access-status {
    width: max-content;
    margin-top: 24px;
    padding: 6px 10px;
    border: 1px solid color-mix(in srgb, var(--red) 24%, var(--border));
    border-radius: 999px;
    background: var(--red-soft);
    color: var(--red);
    font-size: 10px;
    letter-spacing: .06em;
}

.crm-access-icon {
    width: 78px;
    height: 78px;
    margin: 26px 0 20px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
    border-radius: 20px;
    background: var(--primary-soft);
    color: var(--primary);
}

.crm-access-icon svg {
    width: 48px;
    height: 48px;
}

.crm-access-copy {
    display: grid;
    gap: 7px;
}

.crm-access-eyebrow {
    color: var(--primary);
    font-size: 11px;
}

.crm-access-copy h1 {
    margin: 0;
    font-size: clamp(26px, 4vw, 34px);
    font-weight: 500;
    letter-spacing: -.03em;
}

.crm-access-copy p {
    max-width: 590px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.crm-access-security-note {
    margin-top: 22px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.crm-access-note-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
}

.crm-access-security-note > div {
    display: grid;
    gap: 3px;
}

.crm-access-security-note strong {
    font-size: 12px;
    font-weight: 500;
}

.crm-access-security-note div span {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.crm-access-meta {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.crm-access-meta > div {
    min-height: 62px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    display: grid;
    align-content: center;
    gap: 3px;
}

.crm-access-meta span {
    color: var(--muted);
    font-size: 10px;
}

.crm-access-meta strong {
    font-size: 12px;
    font-weight: 500;
}

.crm-access-actions {
    margin-top: 20px;
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
}

.crm-access-actions .primary-btn,
.crm-access-actions .secondary-btn {
    min-height: 39px;
}

.crm-access-help {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.45;
}

.crm-access-footer {
    width: min(920px, 100%);
    margin: auto;
    padding: 0 6px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 10px;
}

@media (max-width: 620px) {
    .crm-access-shell {
        padding: 18px 12px 14px;
    }

    .crm-access-card {
        padding: 20px;
        border-radius: 14px;
    }

    .crm-access-meta {
        grid-template-columns: 1fr;
    }

    .crm-access-actions {
        flex-direction: column;
    }

    .crm-access-actions .primary-btn,
    .crm-access-actions .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    .crm-access-footer {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* ------------------------------------------------------------------
   Stage 8A17A — GLOBAL search icon standard
   One left-aligned magnifier for every Admin and Affiliate search field.
   ------------------------------------------------------------------ */
.crm-search-control .crm-search-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    display: inline-grid;
    place-items: center;
    color: var(--muted);
    pointer-events: none;
}

.crm-search-control .crm-search-icon .ui-svg {
    width: 16px;
    height: 16px;
    display: block;
    stroke-width: 1.8;
}

/* Existing flex-based CRM searches: icon naturally sits at the left. */
.toolbar-search.crm-search-control,
.lead-search.crm-search-control,
.audit-search.crm-search-control {
    gap: 9px;
}

.toolbar-search.crm-search-control input,
.lead-search.crm-search-control input,
.audit-search.crm-search-control input {
    padding-left: 0 !important;
}

/* Dashboard has a visible label above its input, so place the same icon
   inside the left side of the 40px input row. */
.search-field.crm-search-control {
    position: relative;
}

.search-field.crm-search-control > .crm-search-icon {
    position: absolute;
    left: 12px;
    right: auto;
    bottom: 11px;
    z-index: 2;
}

.search-field.crm-search-control input {
    padding-left: 38px !important;
    padding-right: 11px !important;
}

/* Field Builder uses an outer padded container; keep the icon inside
   the actual input, aligned to the same 12px visual inset. */
.field-library-search.crm-search-control {
    position: relative;
}

.field-library-search.crm-search-control > .crm-search-icon {
    position: absolute;
    left: 23px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.field-library-search.crm-search-control input {
    padding-left: 36px !important;
}

/* No legacy corner-positioned search glyph should affect the standard. */
.search-field.crm-search-control .field-icon {
    display: none !important;
}

/* ------------------------------------------------------------------
   Stage 8A18 — notification badge + premium theme toggle
   Shared globally by Internal and Affiliate topbars.
   ------------------------------------------------------------------ */

/* Notification count stays fully visible above the bell. */
.notification-menu,
.notification-btn {
    overflow: visible;
}

.notification-btn {
    position: relative;
}

.notification-badge {
    top: -6px;
    right: -7px;
    z-index: 5;
    width: auto;
    min-width: 19px;
    height: 19px;
    padding: 0 4px;
    box-sizing: border-box;
    border: 2px solid var(--surface);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0;
    white-space: nowrap;
}

/* One premium light/dark switch across every portal. */
.theme-toggle-pro {
    width: 86px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-3);
    color: var(--muted);
    display: inline-grid;
    grid-template-columns: 18px 32px 18px;
    gap: 5px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        border-color .15s ease,
        background .15s ease,
        box-shadow .15s ease;
}

.theme-toggle-pro:hover {
    border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
    background: var(--surface-2);
}

.theme-toggle-pro:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--primary) 50%, transparent);
    outline-offset: 2px;
}

.theme-toggle-icon {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    transition: color .15s ease, opacity .15s ease;
}

.theme-toggle-icon svg {
    width: 15px;
    height: 15px;
    display: block;
}

.theme-toggle-track {
    width: 32px;
    height: 18px;
    padding: 2px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.theme-toggle-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
    transform: translateX(0);
    transition: transform .18s ease;
}

html[data-theme="light"] .theme-toggle-sun {
    color: var(--primary);
    opacity: 1;
}

html[data-theme="light"] .theme-toggle-moon {
    color: var(--muted);
    opacity: .55;
}

html[data-theme="dark"] .theme-toggle-sun {
    color: var(--muted);
    opacity: .55;
}

html[data-theme="dark"] .theme-toggle-moon {
    color: var(--primary);
    opacity: 1;
}

html[data-theme="dark"] .theme-toggle-thumb {
    transform: translateX(14px);
}

/* Legacy segmented theme control is retired. */
.theme-segment {
    display: none !important;
}

@media (max-width: 620px) {
    .theme-toggle-pro {
        width: 78px;
        grid-template-columns: 16px 30px 16px;
        gap: 4px;
        padding: 0 6px;
    }
}

/* ------------------------------------------------------------------
   Stage 8A19 — authoritative global modal foundation
   Reasserted at the END of app.css so later UI packages cannot cause
   closed modals to render as normal page content.
   ------------------------------------------------------------------ */
.modal-shell {
    position: fixed !important;
    inset: 0 !important;
    z-index: 220 !important;
    display: none !important;
    place-items: center;
    padding: 20px;
}

.modal-shell.is-open {
    display: grid !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 12, 22, .64);
    backdrop-filter: blur(3px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(590px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 28px 90px rgba(0, 0, 0, .30);
}

html[data-theme="dark"] .modal-card {
    box-shadow: 0 30px 96px rgba(0, 0, 0, .50);
}

body.modal-open {
    overflow: hidden;
}

/* Stage 8A19 — Affiliate directory action extension */
.lead-action-btn.status-toggle {
    color: var(--amber);
}

.lead-action-btn.status-toggle:hover {
    border-color: color-mix(in srgb, var(--amber) 34%, var(--border));
    background: var(--amber-soft);
    color: var(--amber);
}

/* Stage 9C — Dynamic CRM brand logo */
.brand-logo { overflow: hidden; }
.brand-logo-image { display: block; width: 30px; height: 30px; max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; }
.brand-logo-fallback { display: block; width: 30px; height: 30px; }
.auth-logo .brand-logo-image { width: 42px; height: 42px; }
.auth-logo .brand-logo-fallback { width: 42px; height: 42px; }
.public-brand-mark .brand-logo-image { width: 28px; height: 28px; object-fit: contain; }
.public-brand-mark .brand-logo-fallback { width: 24px; height: 24px; }
.crm-access-brand-mark .brand-logo-image { width: 28px; height: 28px; object-fit: contain; }
.crm-access-brand-mark .brand-logo-fallback { width: 26px; height: 26px; }

/* Stage 9C4 — configurable Qualification / Verification status tones. */
html body .status-pill.status-tone-green {
    background: var(--green-soft); color: var(--green);
    border-color: color-mix(in srgb, var(--green) 20%, transparent);
}
html body .status-pill.status-tone-red {
    background: var(--red-soft); color: var(--red);
    border-color: color-mix(in srgb, var(--red) 20%, transparent);
}
html body .status-pill.status-tone-amber {
    background: var(--amber-soft); color: var(--amber);
    border-color: color-mix(in srgb, var(--amber) 20%, transparent);
}
html body .status-pill.status-tone-purple {
    background: var(--purple-soft); color: var(--purple);
    border-color: color-mix(in srgb, var(--purple) 20%, transparent);
}
html body .status-pill.status-tone-blue {
    background: var(--primary-soft); color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 20%, transparent);
}
html body .status-pill.status-tone-gray {
    background: var(--surface-2); color: var(--muted); border-color: var(--border);
}

/* ==================================================================
   Stage 9C5G1 — Global checkbox state integrity
   A checked/indeterminate checkbox must remain visibly selected while
   hovered, focused or pressed. This prevents the light-mode hover surface
   from visually replacing the selected state across CRM and portal pages.
   ================================================================== */
input[type="checkbox"]:checked:hover:not(:disabled),
input[type="checkbox"]:checked:active:not(:disabled) {
    border-color: var(--primary);
    background-color: var(--primary);
}

input[type="checkbox"]:checked:focus-visible:not(:disabled) {
    border-color: var(--primary);
    background-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

input[type="checkbox"]:indeterminate:hover:not(:disabled),
input[type="checkbox"]:indeterminate:active:not(:disabled) {
    border-color: var(--primary);
    background-color: var(--primary);
}

input[type="checkbox"]:indeterminate:focus-visible:not(:disabled) {
    border-color: var(--primary);
    background-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ==================================================================
   Stage 9C5I6 — Global premium number-input stepper
   Replace browser-native spinner chrome with a theme-aware CRM control.
   ================================================================== */
.crm-number-stepper {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
}

.crm-number-stepper > input[type="number"] {
    width: 100%;
    padding-right: 42px !important;
    appearance: textfield;
    -moz-appearance: textfield;
}

.crm-number-stepper > input[type="number"]::-webkit-outer-spin-button,
.crm-number-stepper > input[type="number"]::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
}

.crm-number-stepper-controls {
    position: absolute;
    top: 1px;
    right: 1px;
    bottom: 1px;
    z-index: 2;
    width: 32px;
    display: grid;
    grid-template-rows: 1fr 1fr;
    overflow: hidden;
    border-left: 1px solid var(--border);
    border-radius: 0 7px 7px 0;
    background: var(--surface-2);
    pointer-events: auto;
}

.crm-number-stepper-button {
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.crm-number-stepper-button + .crm-number-stepper-button {
    border-top: 1px solid var(--border);
}

.crm-number-stepper-button::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.crm-number-stepper-button[data-number-step="up"]::before {
    border-bottom: 5px solid currentColor;
}

.crm-number-stepper-button[data-number-step="down"]::before {
    border-top: 5px solid currentColor;
}

.crm-number-stepper-button:hover:not(:disabled) {
    background: var(--primary-soft);
    color: var(--primary);
}

.crm-number-stepper-button:active:not(:disabled) {
    background: color-mix(in srgb, var(--primary) 15%, var(--surface-2));
    color: var(--primary);
}

.crm-number-stepper-button:focus-visible {
    position: relative;
    z-index: 3;
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.crm-number-stepper-button:disabled {
    opacity: .34;
    cursor: not-allowed;
}

.crm-number-stepper:focus-within .crm-number-stepper-controls {
    border-left-color: color-mix(in srgb, var(--primary) 55%, var(--border));
}

/* Compact numeric controls used by Form Builder keep their governed width. */
.sort-control .crm-number-stepper {
    width: 100%;
}

@media (max-width: 520px) {
    .crm-number-stepper-controls {
        width: 34px;
    }

    .crm-number-stepper > input[type="number"] {
        padding-right: 44px !important;
    }
}
