/* Shared app layout: left sidebar + constrained main */

.company-shell .app-frame {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.app-sidebar {
    width: var(--appSidebarWidth);
    flex: 0 0 var(--appSidebarWidth);
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 12px 16px;
    border-right: 1px solid var(--border-subtle, #e2e8f0);
    background: var(--surface-elevated, #ffffff);
    box-shadow: 4px 0 18px rgba(15, 23, 42, 0.05);
    position: sticky;
    top: 0;
    align-self: flex-start;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Brand zone */
.app-sidebar__logo-wrap {
    padding: 0;
    display: block;
    border-bottom: none;
}

.app-sidebar__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.app-sidebar__brand {
    position: relative;
    display: block;
    width: 100%;
    text-decoration: none;
    line-height: 0;
    padding: 12px 10px 10px;
    border-radius: var(--radius-card, 8px);
    overflow: hidden;
    background:
        radial-gradient(circle at top right, rgba(249, 115, 22, 0.18), transparent 30%),
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.28), transparent 35%),
        linear-gradient(180deg, #0f172a 0%, #020617 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 20px 40px rgba(2, 6, 23, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 36px rgba(59, 130, 246, 0.10);
}

.app-sidebar__brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 18px 18px;
    opacity: 0.16;
    pointer-events: none;
}

.app-sidebar__brand::after {
    content: "";
    position: absolute;
    width: 120px;
    height: 120px;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 999px;
    background: radial-gradient(circle,
            rgba(59, 130, 246, 0.28) 0%,
            rgba(249, 115, 22, 0.16) 38%,
            transparent 72%);
    filter: blur(18px);
    pointer-events: none;
}

.app-sidebar__logo {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 220px;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    padding: 5px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.03);
    box-shadow:
        0 14px 30px rgba(0, 0, 0, 0.42),
        0 0 22px rgba(59, 130, 246, 0.14);
}

/* Theme-specific logo assets (theme-boot sets html[data-theme] before paint) */
.app-sidebar__brand .appSidebarLogoDark {
    display: none;
}

html[data-theme="dark"] .app-sidebar__brand .appSidebarLogoLight {
    display: none;
}

html[data-theme="dark"] .app-sidebar__brand .appSidebarLogoDark {
    display: block;
}

/* Light theme: single polished card frame — brand-tint border, inset depth, quiet texture */
html:not([data-theme="dark"]) .app-sidebar__brand {
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.1), transparent 44%),
        radial-gradient(circle at top left, rgba(249, 115, 22, 0.06), transparent 42%),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(37, 99, 235, 0.16);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -1px 0 rgba(15, 23, 42, 0.03),
        0 10px 28px rgba(15, 23, 42, 0.08),
        0 2px 8px rgba(15, 23, 42, 0.05);
}

html:not([data-theme="dark"]) .app-sidebar__brand::before {
    background:
        linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.07;
}

html:not([data-theme="dark"]) .app-sidebar__brand::after {
    opacity: 0.13;
}

html:not([data-theme="dark"]) .app-sidebar__logo {
    padding: 3px;
    border-radius: calc(var(--radius-card, 8px) - 3px);
    background: transparent;
    box-shadow: none;
}

/* Close button */
.app-sidebar__close {
    display: none;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line, #e2e8f0);
    border-radius: var(--radius-input, 8px);
    background: var(--control-bg, #ffffff);
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-soft, #475569);
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.app-sidebar__close:hover {
    background: var(--control-bg-hover, #f8fafc);
    color: var(--brand-1, #2563eb);
    border-color: rgba(37, 99, 235, 0.22);
}

/* Nav: grows to fill sidebar so Instructions can sit above the footer */
.app-sidebar .app-nav {
    flex: 1;
    min-height: 0;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: var(--appNavGap, 5px);
    padding: 2px 0;
}

#appNavInstructions {
    margin-top: auto;
}

.app-nav__link {
    position: relative;
    display: block;
    padding: var(--appNavLink-padding-y, 9px) var(--appNavLink-padding-x, 12px);
    border-radius: var(--radius-input, 8px);
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-soft, #475569);
    text-decoration: none;
    transition:
        transform 0.18s ease,
        background 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
}

.app-nav__link:hover {
    transform: translateX(4px);
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.app-nav__link[aria-current="page"] {
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(59, 130, 246, 0.10));
    color: #2563eb;
    box-shadow:
        inset 0 0 0 1px rgba(37, 99, 235, 0.14),
        0 10px 20px rgba(37, 99, 235, 0.10);
}

.app-nav__link[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, #3b82f6, #f97316);
}

/* Sub-items under Companies (Company Workspace, Demand Engine, …) */
.app-nav__link--nested {
    padding-inline-start: calc(var(--appNavLink-padding-x, 12px) + 14px);
}

.app-nav__link--nested[aria-current="page"]::before {
    left: calc(7px + 14px);
}

/* Footer */
.app-sidebar__footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.app-sidebar__footer .btn {
    width: 100%;
    justify-content: center;
}

/* Theme first, Sign out below (see markup order in app sidebar footer) */
.app-sidebar__footer #logoutBtn {
    margin-top: 20px;
}

/* Sidebar theme toggle — compact settings card (see theme-toggle.js for copy sync) */
.app-sidebar__footer .themeToggle {
    margin-top: 0;
}

.themeToggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition:
        transform 140ms ease,
        box-shadow 140ms ease,
        background 140ms ease;
}

html:not([data-theme="dark"]) .themeToggle {
    border: none;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.98) 0%, rgba(239, 246, 255, 0.94) 100%);
    color: #0f172a;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.75),
        0 8px 20px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] .themeToggle {
    border: none;
    background: linear-gradient(180deg, rgba(10, 19, 40, 0.96) 0%, rgba(12, 24, 50, 0.88) 100%);
    color: #f8fafc;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 8px 20px rgba(0, 0, 0, 0.22),
        0 0 28px rgba(37, 99, 235, 0.18);
}

html:not([data-theme="dark"]) .themeToggle:hover {
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        0 12px 26px rgba(37, 99, 235, 0.14);
}

html[data-theme="dark"] .themeToggle:hover {
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        0 12px 26px rgba(37, 99, 235, 0.14),
        0 0 32px rgba(56, 189, 248, 0.12);
}

.themeToggle:active {
    transform: translateY(0);
}

.themeToggle:focus-visible {
    outline: none;
}

.themeToggleLeft {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.themeToggleIcon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

html:not([data-theme="dark"]) .themeToggleIcon {
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.2) 0%, rgba(245, 158, 11, 0.12) 100%);
    border: 1px solid rgba(251, 191, 36, 0.34);
}

html[data-theme="dark"] .themeToggleIcon {
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.18) 0%, rgba(30, 64, 175, 0.14) 100%);
    border: 1px solid rgba(96, 165, 250, 0.32);
}

.themeToggleText {
    display: flex;
    flex-direction: column;
    min-width: 0;
    text-align: left;
}

.themeToggleLabel {
    font-size: 0.68rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

html:not([data-theme="dark"]) .themeToggleLabel {
    color: rgba(71, 85, 105, 0.78);
}

html[data-theme="dark"] .themeToggleLabel {
    color: rgba(148, 163, 184, 0.86);
}

.themeToggleValue {
    margin-top: 4px;
    font-size: 0.95rem;
    line-height: 1.15;
    font-weight: 750;
}

html:not([data-theme="dark"]) .themeToggleValue {
    color: #0f172a;
}

html[data-theme="dark"] .themeToggleValue {
    color: #f8fafc;
}

/* Refresh Workday data — same chrome as Theme toggle; single title line (Demand Engine, Labor Demand). */
.de-v2RefreshWorkdayToggle .themeToggleValue.de-v2RefreshWorkdayToggle__title {
    margin-top: 0;
}

/* Main */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-main__topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line, #e2e8f0);
    background: color-mix(in srgb, var(--surface-elevated, #ffffff) 92%, transparent);
    position: sticky;
    top: 0;
    z-index: 95;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.app-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line, #e2e8f0);
    border-radius: var(--radius-input, 8px);
    background: var(--control-bg, #fff);
    cursor: pointer;
    color: var(--text, #0f172a);
}

.app-menu-toggle:hover {
    border-color: var(--brand-2, #3b82f6);
    background: var(--control-bg-hover, #f8fafc);
}

.app-menu-toggle__bars,
.app-menu-toggle__bars::before,
.app-menu-toggle__bars::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    position: relative;
}

.app-menu-toggle__bars::before,
.app-menu-toggle__bars::after {
    content: "";
    position: absolute;
    left: 0;
}

.app-menu-toggle__bars::before {
    top: -6px;
}

.app-menu-toggle__bars::after {
    top: 6px;
}

.app-sidebar-overlay {
    display: none;
}

.app-main__inner {
    width: 100%;
    max-width: min(var(--appPageMaxWidth, 1120px), 100%);
    margin-left: var(--appMainMarginLeft, 30px);
    margin-right: auto;
    box-sizing: border-box;
}

.app-main__inner.wrap.wrap-wide {
    max-width: min(var(--appPageWideMaxWidth, 1360px), 100%);
}

.app-main__inner.demand-engine-wrap {
    max-width: min(var(--appPageWideMaxWidth, 1360px), 100%);
    margin-left: var(--appMainMarginLeft, 30px);
    margin-right: auto;
}

@media (min-width: 1600px) {

    .app-main__inner.wrap.wrap-wide,
    .app-main__inner.demand-engine-wrap {
        max-width: min(var(--appPageWideMaxWidth, 1360px), calc(100vw - var(--page-gutter, 32px) * 2));
    }
}

@media (max-width: 1180px) and (min-width: 769px) {
    :root {
        --appSidebarWidth: 248px;
        --page-gutter: 18px;
    }
}

body.app-shell-menu-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .app-sidebar {
        width: min(var(--appSidebarWidth), 88vw);
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 101;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: none;
    }

    .app-sidebar.app-sidebar--open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(15, 23, 42, 0.18);
    }

    .app-sidebar__close {
        display: inline-flex;
    }

    .app-sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 90;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
        border: none;
        padding: 0;
        margin: 0;
        cursor: pointer;
    }

    .app-sidebar-overlay.app-sidebar-overlay--visible {
        opacity: 1;
        pointer-events: auto;
    }

    .app-main__topbar {
        display: flex;
    }
}