/* =========================================================
   Subscription plan visual system
   A quiet, category-based accent per plan: use the color to
   identify a plan, not to suggest status or urgency.
   ========================================================= */
.cg-plan-theme {
    --cg-plan-accent: #2563eb;
    --cg-plan-accent-dark: #1d4ed8;
    --cg-plan-tint: #eff6ff;
    --cg-plan-border: #bfdbfe;
    --cg-plan-header-fill: rgba(37, 99, 235, .18);
    --cg-plan-header-border: rgba(147, 197, 253, .58);
}

.cg-plan-theme[data-plan="FOUNDATION"] {
    --cg-plan-accent: #2563eb;
    --cg-plan-accent-dark: #1d4ed8;
    --cg-plan-tint: #eff6ff;
    --cg-plan-border: #bfdbfe;
    --cg-plan-header-fill: rgba(37, 99, 235, .20);
    --cg-plan-header-border: rgba(147, 197, 253, .68);
}

.cg-plan-theme[data-plan="MY_BUSINESS"] {
    --cg-plan-accent: #0f766e;
    --cg-plan-accent-dark: #115e59;
    --cg-plan-tint: #f0fdfa;
    --cg-plan-border: #99f6e4;
    --cg-plan-header-fill: rgba(15, 118, 110, .20);
    --cg-plan-header-border: rgba(94, 234, 212, .65);
}

.cg-plan-theme[data-plan="SALES"] {
    --cg-plan-accent: #0284c7;
    --cg-plan-accent-dark: #075985;
    --cg-plan-tint: #f0f9ff;
    --cg-plan-border: #bae6fd;
    --cg-plan-header-fill: rgba(2, 132, 199, .20);
    --cg-plan-header-border: rgba(125, 211, 252, .68);
}

.cg-plan-theme[data-plan="PURCHASE"] {
    --cg-plan-accent: #0f766e;
    --cg-plan-accent-dark: #115e59;
    --cg-plan-tint: #f0fdfa;
    --cg-plan-border: #99f6e4;
    --cg-plan-header-fill: rgba(15, 118, 110, .20);
    --cg-plan-header-border: rgba(94, 234, 212, .65);
}

.cg-plan-theme[data-plan="INVENTORY"] {
    --cg-plan-accent: #7c3aed;
    --cg-plan-accent-dark: #5b21b6;
    --cg-plan-tint: #f5f3ff;
    --cg-plan-border: #ddd6fe;
    --cg-plan-header-fill: rgba(124, 58, 237, .20);
    --cg-plan-header-border: rgba(196, 181, 253, .70);
}

.cg-plan-theme[data-plan="MANUFACTURING"] {
    --cg-plan-accent: #c2410c;
    --cg-plan-accent-dark: #9a3412;
    --cg-plan-tint: #fff7ed;
    --cg-plan-border: #fed7aa;
    --cg-plan-header-fill: rgba(194, 65, 12, .21);
    --cg-plan-header-border: rgba(253, 186, 116, .70);
}

.cg-plan-theme[data-plan="COMPLETE"] {
    --cg-plan-accent: #a16207;
    --cg-plan-accent-dark: #854d0e;
    --cg-plan-tint: #fefce8;
    --cg-plan-border: #fde68a;
    --cg-plan-header-fill: rgba(161, 98, 7, .22);
    --cg-plan-header-border: rgba(253, 224, 71, .72);
}

/* Header plan chip */
.craftgrid-authenticated-shell .cg-subscription-badge.cg-plan-theme {
    background: var(--cg-plan-header-fill);
    border-color: var(--cg-plan-header-border);
    color: #f8fbff;
}

.craftgrid-authenticated-shell .cg-subscription-badge.cg-plan-theme i {
    color: #fff1a8;
}

/* Keep the profile dropdown compact and prevent the plan details
   from inheriting low-contrast or translucent dropdown text. */
.craftgrid-authenticated-shell .cg-user-menu {
    width: min(354px, calc(100vw - 16px));
    min-width: min(300px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    padding-top: .35rem;
    padding-bottom: .35rem;
    overflow: hidden;
}

.craftgrid-authenticated-shell .cg-subscription-menu-card {
    width: 100%;
    min-width: 0;
    padding: 10px 11px;
    border: 1px solid var(--cg-plan-border, #dbe7ef) !important;
    border-left: 4px solid var(--cg-plan-accent, #2563eb) !important;
    border-radius: 11px;
    background: linear-gradient(125deg, var(--cg-plan-tint, #eff6ff) 0%, #fff 82%) !important;
    color: #142b43 !important;
    box-shadow: 0 2px 5px rgba(15, 40, 70, .045);
}

.craftgrid-authenticated-shell .cg-plan-menu-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.craftgrid-authenticated-shell .cg-plan-menu-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--cg-plan-border, #bfdbfe);
    border-radius: 10px;
    background: #fff;
    color: var(--cg-plan-accent, #2563eb);
    font-size: 1.05rem;
}

.craftgrid-authenticated-shell .cg-plan-menu-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.craftgrid-authenticated-shell .cg-plan-overline {
    margin-bottom: 2px;
    color: #61758a !important;
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .075em;
    line-height: 1.25;
    opacity: 1 !important;
}

.craftgrid-authenticated-shell .cg-plan-menu-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 8px;
}

.craftgrid-authenticated-shell .cg-plan-menu-title {
    min-width: 0;
    color: #102a43 !important;
    font-size: .93rem;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.craftgrid-authenticated-shell .cg-plan-menu-price {
    margin-top: 2px;
    color: #526a80 !important;
    font-size: .73rem;
    font-weight: 600;
    line-height: 1.35;
}

.craftgrid-authenticated-shell .cg-plan-status {
    padding: .24rem .48rem;
    background: #f1f5f9;
    color: #475569;
    font-size: .64rem;
    font-weight: 800;
    white-space: nowrap;
}

.craftgrid-authenticated-shell .cg-plan-status[data-status="Active"],
.craftgrid-authenticated-shell .cg-plan-status[data-status="ACTIVE"] {
    background: #dcfce7;
    color: #166534;
}

.craftgrid-authenticated-shell .cg-plan-status[data-status="Trial"],
.craftgrid-authenticated-shell .cg-plan-status[data-status="TRIAL"] {
    background: #dbeafe;
    color: #1d4ed8;
}

.craftgrid-authenticated-shell .cg-plan-status[data-status="PastDue"],
.craftgrid-authenticated-shell .cg-plan-status[data-status="Past Due"],
.craftgrid-authenticated-shell .cg-plan-status[data-status="PAST_DUE"] {
    background: #ffedd5;
    color: #9a3412;
}

.craftgrid-authenticated-shell .cg-plan-status[data-status="Cancelled"],
.craftgrid-authenticated-shell .cg-plan-status[data-status="CANCELLED"] {
    background: #e2e8f0;
    color: #334155;
}

.craftgrid-authenticated-shell .cg-plan-menu-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 5px 8px;
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px solid var(--cg-plan-border, #dbe7ef);
    color: #64748b !important;
    font-size: .67rem;
    line-height: 1.3;
}

.craftgrid-authenticated-shell .cg-plan-menu-footer > span {
    color: #64748b !important;
}

.craftgrid-authenticated-shell .cg-plan-menu-footer i {
    color: var(--cg-plan-accent, #2563eb);
}

.craftgrid-authenticated-shell .cg-plan-autorenew {
    padding: 2px 5px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: #fff;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .craftgrid-authenticated-shell .cg-user-menu {
        width: min(324px, calc(100vw - 12px));
        min-width: min(270px, calc(100vw - 12px));
        max-width: calc(100vw - 12px);
    }

    .craftgrid-authenticated-shell .cg-subscription-menu-card {
        padding: 9px;
    }

    .craftgrid-authenticated-shell .cg-plan-menu-footer {
        font-size: .64rem;
    }
}

/* Subscription management: compact current-plan summary. */
.cg-subscription-current-plan.cg-plan-theme {
    border-top: 4px solid var(--cg-plan-accent, #2563eb) !important;
    background: linear-gradient(115deg, var(--cg-plan-tint, #eff6ff) 0%, #fff 42%);
}

.cg-subscription-current-plan .card-body {
    padding: 1rem !important;
}

.cg-subscription-current-plan h2 {
    color: #102a43;
    font-size: clamp(1.3rem, 1.8vw, 1.65rem);
    line-height: 1.2;
}

.cg-current-plan-icon,
.cg-upgrade-plan-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--cg-plan-border, #bfdbfe);
    border-radius: 12px;
    background: var(--cg-plan-tint, #eff6ff);
    color: var(--cg-plan-accent, #2563eb);
    font-size: 1.15rem;
}

.cg-subscription-current-plan .cg-plan-overline {
    color: var(--cg-plan-accent-dark, #1d4ed8) !important;
}

.cg-subscription-current-plan hr {
    margin-top: .8rem !important;
    margin-bottom: .8rem !important;
    border-color: var(--cg-plan-border, #bfdbfe);
    opacity: .85;
}

.cg-subscription-current-plan .row.g-4 {
    --bs-gutter-x: .85rem;
    --bs-gutter-y: .65rem;
}

.cg-subscription-current-plan .alert {
    margin-top: .85rem !important;
}

/* Upgrade cards use a thin color accent and a soft plan tint.
   Keep the primary action color consistent with CraftGrid. */
.cg-subscription-upgrade-card.cg-plan-theme {
    position: relative;
    overflow: hidden;
    border: 1px solid #dce5ef !important;
    border-top: 4px solid var(--cg-plan-accent, #2563eb) !important;
    border-radius: 14px;
    background: #fff;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.cg-subscription-upgrade-card .card-body {
    padding: 1rem !important;
}

.cg-subscription-upgrade-card:hover {
    transform: translateY(-2px);
    border-color: var(--cg-plan-border, #bfdbfe) !important;
    box-shadow: 0 .65rem 1.5rem rgba(17, 40, 70, .095) !important;
}

.cg-subscription-upgrade-card .cg-upgrade-plan-icon {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-color: var(--cg-plan-border, #bfdbfe);
    background: var(--cg-plan-tint, #eff6ff);
    color: var(--cg-plan-accent, #2563eb);
}

.cg-subscription-upgrade-card h3 {
    color: #102a43;
    line-height: 1.2;
}

.cg-subscription-upgrade-card .cg-plan-module-count {
    flex: 0 0 auto;
    border: 1px solid var(--cg-plan-border, #bfdbfe);
    background: var(--cg-plan-tint, #eff6ff);
    color: var(--cg-plan-accent-dark, #1d4ed8);
    font-size: .67rem;
    font-weight: 800;
}

.cg-subscription-upgrade-card .cg-plan-price-panel {
    border-color: var(--cg-plan-border, #bfdbfe) !important;
    background: linear-gradient(125deg, var(--cg-plan-tint, #eff6ff), #fff 90%);
}

.cg-subscription-upgrade-card .cg-plan-price-panel .fs-3 {
    color: #102a43;
    font-size: clamp(1.35rem, 1.7vw, 1.7rem) !important;
    line-height: 1.2;
}

.cg-subscription-upgrade-card .btn {
    min-height: 42px;
    border-radius: 9px;
    font-weight: 750;
}

@media (max-width: 575.98px) {
    .cg-subscription-upgrade-card .card-body {
        padding: .9rem !important;
    }

    .cg-subscription-upgrade-card .cg-plan-price-panel {
        padding: .75rem !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cg-subscription-upgrade-card.cg-plan-theme {
        transition: none;
    }

    .cg-subscription-upgrade-card:hover {
        transform: none;
    }
}

/* Initial plan picker: mirror the same tier colors used on upgrades and
   the account-menu subscription summary. */
.cg-plan-card.cg-plan-theme {
    border: 1px solid var(--cg-plan-border, #bfdbfe) !important;
    border-top: 4px solid var(--cg-plan-accent, #2563eb) !important;
    background: linear-gradient(135deg, var(--cg-plan-tint, #eff6ff) 0%, #fff 48%);
    border-radius: 14px;
    transition: transform .16s ease, box-shadow .16s ease;
}

.cg-plan-card.cg-plan-theme:hover {
    transform: translateY(-2px);
    box-shadow: 0 .65rem 1.5rem rgba(17, 40, 70, .09) !important;
}

.cg-plan-card .cg-plan-card-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--cg-plan-border, #bfdbfe);
    border-radius: 11px;
    background: var(--cg-plan-tint, #eff6ff);
    color: var(--cg-plan-accent, #2563eb);
    font-size: 1.05rem;
}

.cg-plan-card .cg-plan-module-count {
    border: 1px solid var(--cg-plan-border, #bfdbfe);
    background: var(--cg-plan-tint, #eff6ff);
    color: var(--cg-plan-accent-dark, #1d4ed8);
    font-size: .67rem;
    font-weight: 800;
}

.cg-plan-card .cg-plan-price-option {
    border-color: var(--cg-plan-border, #bfdbfe);
    background: linear-gradient(145deg, var(--cg-plan-tint, #eff6ff), #fff 85%);
}

@media (prefers-reduced-motion: reduce) {
    .cg-plan-card.cg-plan-theme {
        transition: none;
    }

    .cg-plan-card.cg-plan-theme:hover {
        transform: none;
    }
}

/* =========================================================
   Multi-role account identity and responsive account menu
   ========================================================= */
.craftgrid-authenticated-shell .cg-user-role-count {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    margin-top: 2px;
    padding: 2px 7px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    color: #fff !important;
    font-size: .64rem;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: .035em;
    white-space: nowrap;
}

.craftgrid-authenticated-shell .cg-user-role-count-mobile {
    position: absolute;
    top: -3px;
    right: -3px;
    display: grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    border: 2px solid var(--cg-pro-header, #172b4d);
    border-radius: 999px;
    background: #f3c64e;
    color: #17334d;
    font-size: .58rem;
    font-weight: 900;
    line-height: 1;
    z-index: 2;
}

.craftgrid-authenticated-shell .cg-assigned-roles-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.craftgrid-authenticated-shell .cg-assigned-role-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 5px 8px;
    border: 1px solid #dce5ed;
    border-radius: 8px;
    background: #f5f8fb;
    color: #31475c;
    font-size: .75rem;
    font-weight: 650;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.craftgrid-authenticated-shell .cg-assigned-role-chip i {
    flex: 0 0 auto;
    color: #58718a;
}

.craftgrid-authenticated-shell .cg-user-menu {
    max-height: calc(100vh - 92px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

@media (max-width: 767.98px) {
    .craftgrid-authenticated-shell .cg-user-menu {
        width: min(354px, calc(100vw - 12px));
        min-width: min(280px, calc(100vw - 12px));
        max-width: calc(100vw - 12px);
        max-height: calc(100dvh - 84px);
        margin-top: 5px !important;
    }

    .craftgrid-authenticated-shell .cg-assigned-role-chip {
        font-size: .73rem;
    }
}

/* Account dropdown lives inside the dark top bar, but its menu surface is
   light. Reset top-bar muted text colors within the menu and keep the context
   section compact so invisible labels cannot create an apparent blank gap. */
.craftgrid-authenticated-shell .craftgrid-topbar .cg-user-menu {
    color: #243b53;
}

.craftgrid-authenticated-shell .craftgrid-topbar .cg-user-menu .text-muted {
    color: #64748b !important;
}

.craftgrid-authenticated-shell .cg-user-menu > .cg-user-context {
    padding-top: .35rem !important;
    padding-bottom: .4rem !important;
    border-bottom: 1px solid #e2e8f0;
    overflow-wrap: anywhere;
}

.craftgrid-authenticated-shell .cg-user-menu .cg-user-context-name {
    color: #142b43;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.craftgrid-authenticated-shell .cg-user-menu .cg-user-tenant-name {
    display: block;
    margin-top: .15rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.craftgrid-authenticated-shell .cg-user-menu > .cg-user-roles {
    padding-top: .4rem !important;
    padding-bottom: .55rem !important;
}

