/* Persistent MCPHP application shell */
.dashboard-page {
    overflow-x: clip;
}

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

.app-sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    color: #ffffff;
    background:
        radial-gradient(circle at 10% 5%, rgba(78, 104, 224, .24), transparent 32%),
        linear-gradient(165deg, #17233f 0%, #111a31 100%);
    box-shadow: 14px 0 38px rgba(17, 26, 49, .12);
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .8rem;
    min-height: 52px;
    padding: .25rem .45rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.app-sidebar-brand .brand-mark {
    flex: 0 0 auto;
}

.app-sidebar-brand div,
.app-sidebar-user div {
    min-width: 0;
    display: grid;
    gap: .16rem;
}

.app-sidebar-brand strong {
    font-size: 1.02rem;
    letter-spacing: -.01em;
}

.app-sidebar-brand small,
.app-sidebar-user small {
    color: #9eacc9;
    font-size: .72rem;
}

.app-navigation {
    flex: 1;
    min-height: 0;
    overflow-y: scroll;
    padding: 1.15rem 0;
    scrollbar-gutter: stable;
    scrollbar-width: auto;
    scrollbar-color: #91a4d5 rgba(255, 255, 255, .09);
}

.app-navigation::-webkit-scrollbar {
    width: 12px;
}

.app-navigation::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, .09);
    border-radius: 999px;
}

.app-navigation::-webkit-scrollbar-thumb {
    min-height: 44px;
    border: 3px solid transparent;
    border-radius: 999px;
    background: #91a4d5;
    background-clip: content-box;
}

.app-navigation::-webkit-scrollbar-thumb:hover {
    background: #b2c0e6;
    background-clip: content-box;
}

.app-shell {
    position: relative;
}

.app-scrollbar {
    position: absolute;
    z-index: 70;
    display: block;
    overflow: hidden;
    border: 1px solid rgba(94, 109, 134, .3);
    border-radius: 999px;
    box-shadow: 0 1px 4px rgba(23, 35, 59, .16);
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

.app-scrollbar-content {
    top: 6px;
    right: 4px;
    bottom: 6px;
    width: 14px;
    background: #dce3ed;
}

.app-scrollbar-navigation {
    right: 3px;
    width: 12px;
    background: rgba(255, 255, 255, .13);
    border-color: rgba(255, 255, 255, .18);
    box-shadow: none;
}

.app-scrollbar-thumb {
    position: absolute;
    top: 0;
    right: 2px;
    left: 2px;
    border-radius: 999px;
    background: #687891;
    box-shadow: 0 1px 3px rgba(23, 35, 59, .3);
    cursor: grab;
}

.app-scrollbar-navigation .app-scrollbar-thumb {
    background: #9fb2e1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.app-scrollbar-thumb:hover,
.app-scrollbar.is-dragging .app-scrollbar-thumb {
    background: #465875;
}

.app-scrollbar-navigation .app-scrollbar-thumb:hover,
.app-scrollbar-navigation.is-dragging .app-scrollbar-thumb {
    background: #c2cff0;
}

.app-scrollbar.is-dragging .app-scrollbar-thumb {
    cursor: grabbing;
}

.app-scrollbar:focus-visible {
    outline: 3px solid rgba(50, 105, 216, .35);
    outline-offset: 2px;
}

@media (max-width: 900px) {
    .app-scrollbar-content {
        display: none;
    }
}

.app-nav-group + .app-nav-group {
    margin-top: 1.25rem;
}

.app-nav-label {
    margin: 0 .7rem .42rem;
    color: #7789b2;
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.app-nav-link {
    position: relative;
    display: grid;
    grid-template-columns: 1.2rem minmax(0, 1fr) auto;
    align-items: center;
    gap: .72rem;
    min-height: 46px;
    margin: .18rem 0;
    padding: .68rem .78rem;
    border: 1px solid transparent;
    border-radius: 11px;
    color: #bdc8df;
    text-decoration: none;
    font-size: .91rem;
    font-weight: 650;
    transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease;
}

.app-nav-link i {
    width: 1.2rem;
    color: #8fa2ca;
    text-align: center;
}

.app-nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, .07);
    transform: translateX(2px);
}

.app-nav-link:hover i {
    color: #ffffff;
}

.app-nav-link-active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(66, 101, 222, .42), rgba(96, 76, 203, .28));
    border-color: rgba(132, 153, 239, .25);
    box-shadow: inset 3px 0 #6f8dff;
}

.app-nav-link-active i {
    color: #9fb2ff;
}

.app-nav-link small {
    padding: .15rem .38rem;
    border-radius: 999px;
    color: #9eacc9;
    background: rgba(255, 255, 255, .07);
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.app-nav-link-disabled {
    cursor: not-allowed;
    opacity: .52;
}

.app-nav-link-disabled:hover {
    color: #bdc8df;
    background: transparent;
    transform: none;
}

.app-sidebar-footer {
    display: grid;
    gap: .72rem;
    padding-top: .95rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.app-sidebar-user {
    display: flex;
    align-items: center;
    gap: .68rem;
    padding: .5rem .55rem;
    border-radius: 10px;
    color: #fff;
    text-decoration: none;
}

.app-sidebar-user:hover,
.app-sidebar-user:focus-visible {
    background: rgba(255, 255, 255, .08);
    outline: none;
}

.app-sidebar-user > i:last-child {
    margin-left: auto;
    color: #91a4cc;
    font-size: .72rem;
}

.app-sidebar-user > span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 10px;
    color: #c7d1ff;
    background: rgba(111, 141, 255, .16);
}

.app-sidebar-user strong {
    overflow: hidden;
    font-size: .84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-signout-button {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    padding: .65rem .8rem;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 10px;
    color: #cbd4e7;
    background: rgba(255, 255, 255, .045);
    font: inherit;
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
}

.app-signout-button:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, .09);
}

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

.app-content > .topbar {
    display: none;
}

.app-content > main {
    width: 100%;
    flex: 1;
    box-sizing: border-box;
    padding-inline: clamp(1.25rem, 3vw, 3.5rem);
}

@media (min-width: 901px) {
    html,
    body.dashboard-page {
        height: auto;
        min-height: 100%;
    }

    body.dashboard-page,
    .app-shell,
    .app-content {
        overflow: visible;
    }

    .app-shell,
    .app-content {
        height: auto;
        min-height: 100vh;
    }

    .app-scrollbar-content {
        display: none;
    }
}

.app-mobile-bar,
.app-sidebar-overlay {
    display: none;
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 244px minmax(0, 1fr);
    }

    .app-sidebar {
        padding-inline: .8rem;
    }
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(292px, 86vw);
        transform: translateX(-104%);
        transition: transform .22s ease;
    }

    .app-shell.is-sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 35;
        width: 100%;
        height: 100%;
        border: 0;
        background: rgba(10, 16, 31, .55);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }

    .app-shell.is-sidebar-open .app-sidebar-overlay {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .app-mobile-bar {
        position: sticky;
        top: 0;
        z-index: 30;
        min-height: 68px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: .75rem 1rem;
        border-bottom: 1px solid #dce3ef;
        background: rgba(255, 255, 255, .94);
        box-shadow: 0 8px 24px rgba(18, 32, 61, .06);
        backdrop-filter: blur(12px);
    }

    .app-mobile-bar .brand-inline {
        gap: .65rem;
    }

    .app-sidebar-toggle {
        width: 42px;
        height: 42px;
        display: grid;
        place-items: center;
        border: 1px solid #d7deeb;
        border-radius: 10px;
        color: #17233f;
        background: #ffffff;
        font-size: 1rem;
        cursor: pointer;
    }

    body.app-navigation-open {
        overflow: hidden;
    }

    .app-content > main {
        padding: 1rem 1rem 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar,
    .app-sidebar-overlay,
    .app-nav-link {
        transition: none;
    }
}

[hidden] {
    display: none !important;
}

.session-timeout-dialog {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgb(10 20 39 / 68%);
    backdrop-filter: blur(4px);
}

.session-timeout-card {
    width: min(460px, 100%);
    padding: clamp(28px, 5vw, 40px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 28px 80px rgb(10 20 39 / 28%);
    text-align: center;
}

.session-timeout-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin: 0 auto 1.15rem;
    color: var(--blue);
    background: var(--blue-soft);
    border-radius: 18px;
    font-size: 1.45rem;
}

.session-timeout-card h2 {
    margin-bottom: .65rem;
    font-size: 1.65rem;
}

.session-timeout-card > p:not(.eyebrow) {
    margin: 0 auto;
    max-width: 340px;
}

.session-timeout-countdown {
    display: inline-block;
    min-width: 3.2rem;
    color: var(--red);
    font-variant-numeric: tabular-nums;
}

.session-timeout-actions {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: .75rem;
    margin-top: 1.5rem;
}

@media (max-width: 480px) {
    .session-timeout-actions {
        grid-template-columns: 1fr;
    }
}

.app-nav-project-center{padding-top:.15rem}
.app-nav-project-center .app-nav-label{color:#a9bdf2}
.app-nav-submenu{display:grid;gap:.25rem;padding-left:.55rem;border-left:2px solid rgba(126,155,232,.28)}
.app-nav-submenu .app-nav-link{min-height:40px;padding:.65rem .75rem}
.project-ai-default {
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.project-ai-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, auto);
    align-items: center;
    gap: 1.25rem;
}

.project-ai-default .section-heading {
    margin: 0;
}

.project-ai-default .locked-policy {
    min-width: 320px;
}

.project-ai-actions {
    display: flex;
    justify-content: flex-end;
}

.project-ai-inline-form {
    display: grid;
    gap: 1rem;
}

.project-ai-inline-form .form-actions {
    margin: 0;
}

.credential-dialog {
    width: min(620px, calc(100% - 2rem));
    padding: 0;
    color: var(--navy);
    background: #fff;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 28px 80px rgb(15 32 68 / 32%);
}

.credential-dialog::backdrop {
    background: rgb(9 21 48 / 64%);
    backdrop-filter: blur(3px);
}

.credential-dialog form {
    display: grid;
    gap: 1.25rem;
    padding: 1.6rem;
}

.credential-dialog-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.credential-dialog-heading h2 {
    margin: .15rem 0 .35rem;
}

.credential-dialog-heading p:last-child {
    margin: 0;
}

.credential-dialog-close {
    display: grid;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    place-items: center;
    color: var(--muted);
    background: var(--blue-soft);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.credential-dialog-close:hover,
.credential-dialog-close:focus-visible {
    color: var(--navy);
    background: #dce7fb;
}

.credential-dialog label {
    display: grid;
    gap: .5rem;
    color: var(--navy);
    font-size: .86rem;
    font-weight: 760;
}

.credential-dialog label small {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 500;
    line-height: 1.45;
}

.credential-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding-top: .25rem;
}

body:has(.credential-dialog[open]) {
    overflow: hidden;
}

@media (max-width: 760px) {
    .project-ai-overview {
        grid-template-columns: 1fr;
    }

    .project-ai-default .locked-policy {
        min-width: 0;
    }

    .project-ai-actions,
    .project-ai-inline-form .form-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 520px) {
    .credential-dialog form {
        padding: 1.25rem;
    }

    .credential-dialog-actions {
        display: grid;
        grid-template-columns: 1fr;
    }
}

.app-sidebar .app-nav-submenu a[href="/projects/new"]{display:none}


/* MCPHP modal standard: use for all confirmations, prompts, and alerts. */
.mcphp-dialog{width:min(92vw,520px);padding:0;border:0;border-radius:20px;background:transparent;box-shadow:0 28px 80px rgba(16,24,40,.3)}
.mcphp-dialog::backdrop{background:rgba(15,23,42,.62);backdrop-filter:blur(4px)}
.mcphp-dialog-card{display:grid;grid-template-columns:auto 1fr;gap:1rem;padding:1.5rem;background:#fff;border:1px solid #d7dfeb;border-radius:20px}
.mcphp-dialog-icon{display:grid;place-items:center;width:48px;height:48px;color:#2f65d8;background:#edf4ff;border-radius:14px;font-size:1.15rem}
.mcphp-dialog[data-tone="danger"] .mcphp-dialog-icon{color:#b42318;background:#fff0ee}
.mcphp-dialog[data-tone="danger"] [data-dialog-confirm]{color:#fff;background:#b42318;border-color:#b42318;box-shadow:0 1px 2px rgba(16,24,40,.12)}
.mcphp-dialog[data-tone="danger"] [data-dialog-confirm]:hover:not(:disabled){color:#fff;background:#912018;border-color:#912018}
.mcphp-dialog[data-tone="danger"] [data-dialog-confirm]:disabled{color:#fff;background:#b42318;border-color:#b42318;opacity:.5}
.mcphp-dialog[data-tone="success"] .mcphp-dialog-icon{color:#138a61;background:#eaf8f2}
.mcphp-dialog-copy{display:grid;gap:.45rem;min-width:0}
.mcphp-dialog-copy .eyebrow,.mcphp-dialog-copy h2,.mcphp-dialog-copy p{margin:0}
.mcphp-dialog-copy p:last-of-type{color:#5f6f85;line-height:1.55}
.mcphp-dialog-copy label{display:grid;gap:.4rem;margin-top:.55rem;font-weight:750}
.mcphp-dialog-copy input{width:100%;min-height:44px;padding:.7rem .8rem;border:1px solid #bdc9d9;border-radius:10px;font:inherit}
.mcphp-dialog-card footer{grid-column:1/-1;display:flex;justify-content:flex-end;gap:.7rem;padding-top:.5rem}
.mcphp-dialog-card footer button{min-width:120px}
@media(max-width:560px){.mcphp-dialog-card{grid-template-columns:1fr}.mcphp-dialog-icon{width:42px;height:42px}.mcphp-dialog-card footer{flex-direction:column-reverse}.mcphp-dialog-card footer button{width:100%}}

/* Professional application shell */
@media (min-width: 961px) {
    .app-shell {
        grid-template-columns: 248px minmax(0, 1fr);
    }
}

.app-sidebar {
    background:
        linear-gradient(180deg, rgb(255 255 255 / 3%), transparent 32%),
        #111c35;
}

.app-sidebar-brand {
    padding: 1.15rem 1.1rem;
}

.app-navigation {
    gap: 1.05rem;
    padding: .8rem .8rem 1rem;
}

.app-nav-group {
    gap: .25rem;
}

.app-nav-label {
    padding-inline: .65rem;
    font-size: .66rem;
    letter-spacing: .13em;
}

.app-nav-link {
    min-height: 42px;
    padding: .55rem .65rem;
    border-radius: 9px;
}

.app-nav-link-active {
    box-shadow: inset 3px 0 #789bff;
}

.app-sidebar-footer {
    gap: .65rem;
    padding: .85rem;
}

.app-theme-button {
    display: flex;
    width: 100%;
    min-height: 42px;
    align-items: center;
    gap: .7rem;
    padding: .6rem .75rem;
    color: #dbe6ff;
    background: rgb(255 255 255 / 5%);
    border: 1px solid rgb(255 255 255 / 13%);
    border-radius: 10px;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
}

.app-theme-button:hover,
.app-theme-button:focus-visible {
    color: #fff;
    background: rgb(255 255 255 / 10%);
    border-color: rgb(255 255 255 / 24%);
}

.app-theme-button i {
    width: 1rem;
    color: #91b1ff;
}

.app-content > main {
    width: min(100%, 1540px);
    margin-inline: auto;
    padding: clamp(1.5rem, 3vw, 2.75rem);
}

.app-scrollbar {
    width: 11px;
}

.app-scrollbar-thumb {
    border: 3px solid transparent;
    background-clip: padding-box;
}

.mcphp-dialog-card,
.credential-dialog form,
.session-timeout-card {
    color: var(--text);
    background: var(--surface-raised);
    border-color: var(--border);
    box-shadow: var(--shadow-raised);
}

.mcphp-dialog-copy p:last-of-type {
    color: var(--muted);
}

.project-management-nav-toggle {
    display: none;
}

html[data-theme="dark"] .credential-dialog-close {
    color: var(--text);
    background: var(--surface-tint);
}

html[data-theme="dark"] .app-mobile-bar {
    color: var(--text);
    background: rgb(13 21 37 / 92%);
    border-color: var(--border);
}

@media (max-width: 1000px) {
    .project-management-layout {
        margin-top: 1rem;
    }

    .project-management-nav-toggle {
        display: flex;
        width: 100%;
        min-height: 48px;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        margin-bottom: .75rem;
        padding: .75rem 1rem;
        color: var(--text);
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: var(--shadow);
        font: inherit;
        font-weight: 760;
        cursor: pointer;
    }

    .project-management-nav {
        display: none;
        padding: .75rem;
        gap: .65rem;
        box-shadow: var(--shadow);
    }

    .project-management-nav.is-mobile-open {
        display: grid;
    }

    .project-management-nav > div:first-child {
        padding-bottom: .65rem;
    }
}

@media (max-width: 760px) {
    .app-content > main {
        padding: 1.1rem .85rem 2rem;
    }

    .app-mobile-bar {
        min-height: 58px;
    }
}

/* Clean desktop navigation */
@media (min-width: 961px) {
    .app-shell {
        grid-template-columns: 276px minmax(0, 1fr);
    }

    .app-sidebar {
        padding: 0;
        box-shadow: 10px 0 30px rgb(6 13 29 / 10%);
    }

    .app-sidebar-brand {
        min-height: 76px;
        padding: 1rem 1.15rem;
    }

    .app-sidebar-brand .brand-mark {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .app-navigation {
        padding: .85rem .8rem 1rem;
        scrollbar-gutter: stable;
        scrollbar-width: thin;
        scrollbar-color: rgb(145 164 213 / 68%) transparent;
    }

    .app-navigation::-webkit-scrollbar {
        width: 7px;
    }

    .app-navigation::-webkit-scrollbar-track {
        background: transparent;
    }

    .app-navigation::-webkit-scrollbar-thumb {
        border: 2px solid transparent;
        background: rgb(145 164 213 / 68%);
        background-clip: padding-box;
    }

    .app-scrollbar-navigation {
        display: none !important;
    }

    .app-nav-group {
        gap: .15rem;
    }

    .app-nav-group + .app-nav-group {
        margin-top: .15rem;
    }

    .app-nav-label {
        padding: 0 .7rem;
        margin: 0 0 .25rem;
        font-size: .62rem;
        letter-spacing: .14em;
    }

    .app-nav-link {
        min-height: 39px;
        gap: .7rem;
        padding: .5rem .7rem;
        border-radius: 8px;
        font-size: .84rem;
        line-height: 1.2;
        white-space: nowrap;
    }

    .app-nav-link span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-nav-submenu {
        padding-left: .35rem;
        border-left-color: rgb(145 177 255 / 32%);
    }

    .app-nav-link-active {
        background: rgb(113 139 255 / 15%);
        box-shadow: inset 3px 0 #789bff;
    }

    .app-sidebar-footer {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: .55rem;
        padding: .75rem .9rem .85rem;
        border-top: 1px solid rgb(255 255 255 / 9%);
        background: rgb(6 13 29 / 14%);
    }

    .app-theme-button {
        grid-column: 1 / -1;
        min-height: 38px;
        padding: .45rem .65rem;
        border: 0;
        background: transparent;
    }

    .app-sidebar-user {
        min-width: 0;
        padding: .25rem .15rem;
        border: 0;
        background: transparent;
    }

    .app-sidebar-user > span {
        width: 32px;
        height: 32px;
    }

    .app-sidebar-user strong,
    .app-sidebar-user small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-sidebar-footer form {
        align-self: center;
    }

    .app-signout-button {
        width: 40px;
        min-width: 40px;
        height: 40px;
        padding: 0;
        border: 0;
        background: transparent;
        font-size: 0;
    }

    .app-signout-button i {
        margin: 0;
        font-size: .9rem;
    }

    .app-signout-button::after {
        content: "Sign out";
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}
