/* ========== layout.css ========== */

#mainApp {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: transparent;
}

.sidebar {
    width: var(--sidebar-width);
    box-sizing: border-box;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(4, 10, 19, .94) 0%, rgba(5, 12, 22, .99) 100%);
    border-right: 1px solid rgba(255, 255, 255, .05);
    padding: 20px 14px;
    padding-top: max(20px, calc(var(--safe-top) + 16px));
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow: auto;
    z-index: 50;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, .03), 8px 0 28px rgba(0, 0, 0, .18);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    color: #f8fbff;
    position: relative;
}

.brand-chip {
    position: relative;
    min-height: 60px;
    padding: 10px 14px;
    border-radius: 16px;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 22%, rgba(98, 150, 255, .11), transparent 34%),
        radial-gradient(circle at 82% 78%, rgba(18, 208, 255, .07), transparent 34%),
        linear-gradient(135deg, rgba(10, 25, 47, .92) 0%, rgba(8, 18, 35, .96) 100%);
    border: 1px solid rgba(91, 151, 255, .10);
    box-shadow:
        0 10px 22px rgba(0, 0, 0, .14),
        0 0 0 1px rgba(255, 255, 255, .01) inset,
        inset 0 1px 0 rgba(255, 255, 255, .025);
    isolation: isolate;
}

.brand-chip::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(
        135deg,
        rgba(102, 170, 255, .22),
        rgba(18, 208, 255, .16),
        rgba(120, 184, 255, .07)
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: .55;
    pointer-events: none;
}

.brand-chip::after {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    top: 7px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0));
    filter: blur(2px);
    opacity: .28;
    pointer-events: none;
}

.brand-chip-glow {
    position: absolute;
    inset: -12px;
    background:
        radial-gradient(circle at 16% 48%, rgba(84, 134, 255, .10), transparent 28%),
        radial-gradient(circle at 82% 52%, rgba(18, 208, 255, .07), transparent 24%);
    filter: blur(18px);
    opacity: .56;
    pointer-events: none;
    z-index: -1;
}

.sidebar-brand-chip {
    width: 100%;
    min-height: 48px;
    gap: 9px;
    padding: 8px 12px;
    margin-bottom: 16px;
}

.login-brand-chip {
    width: 100%;
    justify-content: center;
    gap: 12px;
    margin-bottom: 18px;
}

/* ===== 图标：停止伪元素造型，直接显示 index.html 里的 SVG ===== */
.logo-icon,
.brand-logo-icon {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    margin-right: 2px;
}

.logo-icon::before,
.brand-logo-icon::before,
.logo-icon::after,
.brand-logo-icon::after {
    content: none !important;
    display: none !important;
}

/* 让真实 SVG 图标显示并放大 */
.logo-icon-core {
    position: relative !important;
    inset: auto !important;
    width: 46px !important;
    height: 46px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    filter: none !important;
    opacity: 1 !important;
    overflow: visible !important;
}

.logo-icon-core svg {
    width: 46px !important;
    height: 46px !important;
    display: block;
    overflow: visible;
    filter:
        drop-shadow(0 0 6px rgba(79, 127, 255, .18))
        drop-shadow(0 0 12px rgba(24, 212, 255, .08));
}

/* 旧的另一套图标方案禁用 */
.brand-logo-mark {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ===== 字标 ===== */
.logo-text,
.brand-logo-text {
    display: inline-flex;
    align-items: center;
    gap: 0;
    font-family:
        "Avenir Next",
        "SF Pro Rounded",
        "SF Pro Display",
        "Helvetica Neue",
        "Arial Rounded MT Bold",
        "PingFang SC",
        "Segoe UI",
        sans-serif;
    font-size: 31px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1.08px;
    color: #f7fbff;
    position: relative;
    z-index: 1;
    white-space: nowrap;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transform: translateY(-.2px);
}

.logo-text .sync-word,
.brand-logo-text .sync-word,
.sync-word {
    position: relative;
    display: inline-block;
    padding-right: .1px;
    background: linear-gradient(
        90deg,
        #4f80ff 0%,
        #4f89ff 16%,
        #4b97ff 32%,
        #43a7ff 49%,
        #35bfff 68%,
        #24d5ff 84%,
        #19e2ff 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow:
        0 0 5px rgba(79, 131, 255, .10),
        0 0 12px rgba(18, 208, 255, .04);
    letter-spacing: -1.2px;
    font-weight: 820;
}

.logo-text .ctrl-word,
.brand-logo-text .ctrl-word,
.ctrl-word {
    position: relative;
    display: inline-block;
    margin-left: 0;
    background: linear-gradient(
        180deg,
        #ffffff 0%,
        #f8fcff 34%,
        #edf7ff 68%,
        #deebff 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow:
        0 0 4px rgba(255, 255, 255, .08),
        0 0 10px rgba(117, 179, 255, .05);
    letter-spacing: -1.12px;
    font-weight: 820;
}

.logo-text .sync-word::after,
.brand-logo-text .sync-word::after,
.logo-text .ctrl-word::after,
.brand-logo-text .ctrl-word::after {
    content: none;
}

/* 侧边栏顶部品牌压缩：只影响左侧菜单，不影响登录页品牌 */
.sidebar-brand-chip .logo-icon,
.sidebar-brand-chip .brand-logo-icon,
.sidebar-brand-chip .logo-icon-core,
.sidebar-brand-chip .logo-icon-core svg {
    width: 38px !important;
    height: 38px !important;
    margin-right: 0 !important;
}

.sidebar-brand-chip .logo-text,
.sidebar-brand-chip .brand-logo-text {
    font-size: 27px;
    letter-spacing: -.92px;
    line-height: 1;
    transform: translateY(-.1px);
}


.main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: var(--app-height);
    overflow: hidden;
    position: relative;
    background: transparent;
    max-width: 100vw;
}

.topbar {
    position: absolute;
    left: var(--sidebar-width);
    right: 0;
    top: 0;
    min-height: var(--topbar-height);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 18px 12px;
    padding-top: max(16px, calc(var(--safe-top) + 10px));
    padding-right: max(18px, calc(var(--safe-right) + 14px));
    z-index: 35;
    background: linear-gradient(180deg, rgba(6, 12, 21, .84) 0%, rgba(6, 12, 21, .66) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, .04);
    backdrop-filter: blur(10px);
}

.topbar-minimal {
    align-items: center;
    min-height: 72px;
    padding-top: max(12px, calc(var(--safe-top) + 8px));
    padding-bottom: 10px;
    background: linear-gradient(180deg, rgba(6, 12, 21, .80) 0%, rgba(6, 12, 21, .54) 100%);
}

.content-scroll {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: calc(var(--topbar-height) + var(--safe-top) + 12px) 18px max(18px, calc(var(--safe-bottom) + 12px));
    padding-right: max(18px, calc(var(--safe-right) + 14px));
    background: transparent;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.content-scroll.locked {
    overflow: hidden !important;
    touch-action: none;
    overscroll-behavior: none;
}

.content-scroll::-webkit-scrollbar {
    width: 10px;
}

.content-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
}

.top-left {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
    flex: 1;
}

.top-left-minimal {
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    min-width: auto;
}

.menu-btn {
    display: none;
    position: relative;
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 18px;
    border: 1px solid rgba(102, 150, 255, .20);
    background:
        radial-gradient(circle at 50% 32%, rgba(18, 200, 255, .12), transparent 54%),
        linear-gradient(180deg, rgba(20, 36, 60, .98) 0%, rgba(12, 27, 46, .98) 100%);
    box-shadow:
        0 10px 24px rgba(0, 0, 0, .24),
        inset 0 1px 0 rgba(255, 255, 255, .05),
        inset 0 0 0 1px rgba(79, 131, 255, .06);
    flex-shrink: 0;
    color: #eef5ff;
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
}

.menu-btn::before {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, rgba(79, 131, 255, .92), rgba(18, 200, 255, .92)) border-box;
    -webkit-mask:
        linear-gradient(#fff 0 0) padding-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: .78;
    pointer-events: none;
}

.menu-btn:hover {
    transform: translateY(-1px);
    background:
        radial-gradient(circle at 50% 32%, rgba(18, 200, 255, .18), transparent 54%),
        linear-gradient(180deg, rgba(22, 40, 67, .98) 0%, rgba(14, 31, 53, .98) 100%);
    box-shadow:
        0 14px 28px rgba(0, 0, 0, .28),
        inset 0 1px 0 rgba(255, 255, 255, .06),
        inset 0 0 0 1px rgba(79, 131, 255, .08);
}

.page-title {
    font-size: 30px;
    line-height: 1.08;
    font-weight: 900;
    letter-spacing: -.4px;
    margin-top: 0;
    word-break: break-word;
}

.page-sub {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}

.top-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    position: relative;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    flex-shrink: 0;
    min-width: 0;
    max-width: 56%;
    overflow: visible;
}

.icon-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 15px;
    border: 1px solid rgba(88, 120, 168, .10);
    background: #0f1b2d;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: #7edfff;
    overflow: hidden;
    flex-shrink: 0;
}

.icon-btn::before {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 999px;
    border: 1.5px solid transparent;
    background: linear-gradient(135deg, rgba(79, 131, 255, .92), rgba(18, 200, 255, .92)) border-box;
    -webkit-mask:
        linear-gradient(#fff 0 0) padding-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: .88;
    pointer-events: none;
}

.icon-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 38%, rgba(18, 200, 255, .08), transparent 40%);
    pointer-events: none;
}

.icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, .16);
    background: #122038;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.9;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    position: relative;
    z-index: 1;
}

.icon-btn.active {
    background: linear-gradient(135deg, rgba(79, 131, 255, .16) 0%, rgba(18, 200, 255, .14) 100%);
    border-color: rgba(79, 131, 255, .18);
    color: #c8f4ff;
    box-shadow: 0 10px 20px rgba(0, 0, 0, .14);
}

.menu-pop {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 172px;
    background: rgba(11, 20, 34, .98);
    border: 1px solid rgba(97, 129, 177, .12);
    border-radius: 18px;
    box-shadow: 0 18px 46px rgba(0, 0, 0, .32);
    padding: 8px;
    display: none;
    z-index: 200;
    backdrop-filter: blur(10px);
}

.menu-pop.show {
    display: block;
}

.menu-pop button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border-radius: 14px;
    padding: 12px 12px;
    background: transparent;
    box-shadow: none;
    border: 0;
    font-size: 15px;
    font-weight: 700;
    color: #e6eefc;
    position: relative;
    text-align: center;
}

.menu-pop button:hover {
    transform: none;
    background: rgba(79, 131, 255, .10);
}

.menu-pop button svg {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.9;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.menu-pop button.warning-item {
    color: #ffd48a;
}

.menu-pop button.danger-item {
    color: #ffb1b4;
}

.nav-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .9px;
    text-transform: uppercase;
    color: #6f84a3;
    padding: 10px 10px 8px;
}

.nav-btn {
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 800;
    background: transparent;
    color: #dce6f5;
    border: 1px solid transparent;
    box-shadow: none;
}

.nav-btn:hover {
    transform: none;
    background: rgba(79, 131, 255, .08);
    border-color: rgba(79, 131, 255, .08);
}

.nav-btn.active {
    background: linear-gradient(135deg, rgba(79, 131, 255, .16) 0%, rgba(18, 200, 255, .12) 100%);
    border-color: rgba(79, 131, 255, .14);
    color: #fff;
}

/* 侧边栏版本号贴底：覆盖 index.html 内联样式，让版本固定贴近左侧栏底部 */
.sidebar > .app-version-sidebar {
    margin-top: auto !important;
    margin-right: 16px !important;
    margin-bottom: 0 !important;
    margin-left: 16px !important;
    flex: 0 0 auto !important;
    align-self: stretch !important;
    position: sticky;
    bottom: 0;
    z-index: 2;
}


.mobile-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .36);
    display: none;
    z-index: 45;
    backdrop-filter: blur(2px);
}

.mobile-mask.show {
    display: block;
}

@media (max-width: 980px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .24s ease;
        width: min(86vw, 320px);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        width: 100%;
    }

    .topbar {
        left: 0;
    }

    .menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .top-right {
        max-width: calc(100vw - 92px);
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: visible;
        scrollbar-width: none;
    }

    .top-right::-webkit-scrollbar {
        display: none;
    }

    .logo-text,
    .brand-logo-text {
        font-size: 28px;
    }

    .logo-icon,
    .brand-logo-icon,
    .logo-icon-core,
    .logo-icon-core svg {
        width: 42px !important;
        height: 42px !important;
    }
}

@media (max-width: 520px) {
    .topbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .top-left {
        width: auto;
        flex: 0 0 auto;
    }

    .top-right {
        width: auto;
        max-width: none;
        justify-content: flex-end;
        overflow: visible;
        flex-wrap: nowrap;
        padding-bottom: 0;
    }

    .top-right::-webkit-scrollbar {
        display: none;
    }

    .menu-pop {
        right: 0;
        left: auto;
        width: min(172px, calc(100vw - 40px));
    }

    .sidebar-brand-chip {
        padding: 10px 12px;
    }

    .logo-text,
    .brand-logo-text {
        font-size: 26px;
        letter-spacing: -.82px;
    }

    .logo-icon,
    .brand-logo-icon,
    .logo-icon-core,
    .logo-icon-core svg {
        width: 38px !important;
        height: 38px !important;
    }
}

@media (max-width: 420px) {
    .menu-btn {
        width: 52px;
        height: 52px;
        font-size: 24px;
    }

    .top-right {
        gap: 6px;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
    }

    .logo {
        font-size: 26px;
    }

    .content-scroll {
        padding-top: calc(var(--topbar-height) + var(--safe-top) + 8px);
    }

    .sidebar-brand-chip {
        gap: 8px;
        padding: 9px 11px;
        border-radius: 15px;
    }

    .logo-text,
    .brand-logo-text {
        font-size: 24px;
    }

    .logo-icon,
    .brand-logo-icon,
    .logo-icon-core,
    .logo-icon-core svg {
        width: 34px !important;
        height: 34px !important;
    }
}
