/* Shell-level interaction rules shared by sidebar, tabs and user actions. */
.app-shell.theme-techblue .ant-btn-primary {
    color: #042338;
    font-weight: 600;
}

.app-shell :where(button, a, input, select, [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 2px solid var(--fx-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px var(--fx-focus-ring);
}


body {
    margin: 0;
    overflow-x: hidden;
    background: var(--fx-bg);
    color: var(--fx-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    transition:
        grid-template-columns 0.18s ease,
        background-color var(--fx-theme-transition),
        color var(--fx-theme-transition);
    background: var(--fx-bg);
    color: var(--fx-text);
}



.app-shell.is-collapsed {
    grid-template-columns: 60px minmax(0, 1fr);
}

.mobile-shell-bar,
.mobile-sider-close,
.mobile-sider-mask {
    display: none;
}

.app-sider {
    position: relative;
    background: var(--fx-sider);
    border-right: 1px solid var(--fx-border);
    padding: var(--fx-space-4) var(--fx-space-3);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: visible;
    transition:
        background-color var(--fx-theme-transition),
        border-color var(--fx-theme-transition),
        color var(--fx-theme-transition);
}

.app-brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-height: 34px;
    padding-right: 28px;
    box-sizing: border-box;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 14px;
    white-space: nowrap;
}

.app-brand-title {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 8px;
    overflow: hidden;
}

.app-brand-copy,
.mobile-brand-copy {
    display: grid;
    min-width: 0;
    line-height: 1.15;
    overflow: hidden;
}

.app-brand-copy strong,
.mobile-brand-copy strong {
    color: var(--fx-text);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-brand-copy small,
.mobile-brand-copy small {
    margin-top: 4px;
    color: var(--fx-text-muted);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-brand-mark {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--fx-primary);
    color: #fff;
    font-size: 15px;
}

.app-nav {
    display: grid;
    align-content: start;
    gap: 10px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}

.nav-group {
    display: grid;
    gap: 4px;
}

.nav-group-title {
    padding: 0 10px;
    color: var(--fx-text-muted);
    font-size: 12px;
    font-weight: 600;
}

.app-shell.is-collapsed .app-nav {
    gap: 10px;
}

.app-shell.is-collapsed .app-sider {
    align-items: center;
    padding: 16px 10px;
}

.app-shell.is-collapsed .app-brand {
    justify-content: center;
    margin-bottom: 16px;
    padding-right: 0;
    width: 100%;
}

.app-shell.is-collapsed .app-brand-title {
    display: inline-grid;
    grid-template-columns: 32px;
    flex: none;
    overflow: visible;
}

.app-shell.is-collapsed .app-brand-mark {
    width: 32px;
    height: 32px;
}

.app-shell.is-collapsed .nav-group {
    margin-top: 7px;
    padding-top: 12px;
    border-top: 1px solid var(--fx-border);
    width: 100%;
    justify-items: center;
}

.app-shell.is-collapsed .nav-group:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.app-shell.is-collapsed .nav-item-shell {
    display: grid;
    justify-items: center;
}

.app-shell.is-collapsed .app-nav a {
    width: 36px;
    min-height: 36px;
    justify-content: center;
    padding: 7px;
}

.app-shell.is-collapsed .sider-toggle {
    right: -15px;
}

.app-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--fx-text-muted);
    padding: 7px 10px;
    border-radius: var(--fx-radius-md);
    text-decoration: none;
    min-height: 36px;
    white-space: nowrap;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
    position: relative;
}

.app-nav button {
    font: inherit;
}

.nav-item-shell {
    position: relative;
}

.app-nav a.active {
    background: var(--fx-nav-icon-active);
    color: var(--fx-primary);
    font-weight: 500;
}

.app-nav a.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--fx-primary);
    border-radius: 0 3px 3px 0;
}

.app-nav a:hover {
    background: var(--fx-nav-hover);
    color: var(--fx-primary);
    transform: translateX(2px);
}

.app-nav a:active {
    transform: translateX(1px);
}

.nav-children {
    display: grid;
    gap: 2px;
    margin: 0 0 2px 10px;
    padding: 2px 0 2px 14px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-children a,
.nav-more-button {
    min-height: 28px;
    padding: 4px 8px;
    gap: 8px;
    font-size: 13px;
    position: relative;
    border-radius: 4px;
}

.nav-children a:hover {
    transform: translateX(2px);
}

.nav-children a.active {
    background: var(--fx-nav-hover);
    color: var(--fx-primary);
    font-weight: 500;
}

.nav-children a.active::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 14px;
    background: var(--fx-primary);
    border-radius: 0 2px 2px 0;
}

.nav-more-button {
    width: 100%;
    display: flex;
    align-items: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--fx-text-muted);
    cursor: pointer;
    text-align: left;
}

.nav-more-button:hover {
    background: var(--fx-nav-hover);
    color: var(--fx-primary);
}

.nav-flyout {
    display: none;
    position: absolute;
    top: 0;
    left: calc(100% + 12px);
    width: 190px;
    padding: 10px;
    border: 1px solid var(--fx-border);
    border-radius: 8px;
    background: var(--fx-panel);
    box-shadow: var(--fx-shadow);
    z-index: 80;
}

.nav-item-shell:hover .nav-flyout,
.nav-flyout:hover {
    display: grid;
    gap: 4px;
}

.nav-flyout strong {
    padding: 2px 8px 6px;
    color: var(--fx-text);
    font-size: 13px;
}

.nav-flyout a,
.nav-flyout button {
    min-height: 30px;
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--fx-text-muted);
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}

.nav-flyout a.active,
.nav-flyout a:hover,
.nav-flyout button:hover {
    background: var(--fx-nav-hover);
    color: var(--fx-primary);
}

.nav-icon {
    display: inline-grid;
    place-items: center;
    width: 22px;
    min-width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--fx-nav-icon);
    font-size: 14px;
    font-weight: 700;
}

.app-nav a.active .nav-icon,
.app-nav a:hover .nav-icon {
    background: var(--fx-nav-icon-active);
}

.sider-toggle {
    position: absolute;
    z-index: 3;
    top: 17px;
    right: -16px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--fx-primary) 52%, var(--fx-border));
    border-radius: 999px;
    background: var(--fx-panel);
    color: var(--fx-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.sider-toggle:hover {
    background: var(--fx-nav-hover);
    border-color: var(--fx-primary);
    color: var(--fx-primary);
}

.app-main {
    padding: 10px 14px 16px;
    min-width: 0;
}

.tab-workspace {
    min-height: 40px;
    margin: 0 0 10px;
    border-bottom: 1px solid var(--fx-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.workspace-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.workspace-tabs {
    position: relative;
    flex: 1;
    width: 100%;
    height: 38px;
    min-width: 0;
    overflow: hidden;
}

.workspace-tabs-list {
    display: flex;
    gap: 6px;
    height: 38px;
    min-width: 0;
    padding-top: 4px;
    overflow: hidden;
    box-sizing: border-box;
}

.workspace-tabs-list.has-overflow {
    padding-right: 62px;
}

.workspace-tab {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    height: 34px;
    padding: 0 8px 0 14px;
    border: 1px solid var(--fx-border);
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    background: var(--fx-panel-muted);
    color: var(--fx-text-muted);
    gap: 8px;
}

.workspace-tab a {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.workspace-tab.active {
    background: var(--fx-panel);
    color: var(--fx-primary);
    font-weight: 600;
}

.workspace-tab button {
    width: 22px;
    height: 22px;
    padding: 0;
    box-sizing: border-box;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}

.workspace-tab-measure-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    font-size: 15px;
    line-height: 1;
}

.workspace-tab button:hover {
    background: var(--fx-nav-hover);
}

.tab-context-menu {
    position: fixed;
    z-index: 1000;
    min-width: 120px;
    padding: 4px 0;
    background: var(--fx-panel);
    border: 1px solid var(--fx-line);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tab-context-menu button {
    display: block;
    width: 100%;
    padding: 8px 16px;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--fx-text);
}

.tab-context-menu button:hover:not(:disabled) {
    background: var(--fx-nav-hover);
    color: var(--fx-primary);
}

/* 工作区 Tab 溢出折叠「更多」 */
.workspace-tabs-more {
    position: absolute;
    top: 4px;
    right: 0;
    width: 56px;
    height: 34px;
    visibility: hidden;
}

.workspace-tabs-more.visible {
    visibility: visible;
}

.workspace-tabs-measurer {
    position: absolute;
    top: 4px;
    left: 0;
    display: flex;
    gap: 6px;
    width: max-content;
    height: 34px;
    visibility: hidden;
    pointer-events: none;
}

.tabs-more-trigger {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 34px;
    width: 100%;
    padding: 0 10px;
    border: 1px solid var(--fx-border);
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    background: var(--fx-panel-muted);
    color: var(--fx-text-muted);
    cursor: pointer;
    font-size: 14px;
    letter-spacing: 1px;
}

.tabs-more-trigger:hover {
    background: var(--fx-nav-hover);
    color: var(--fx-text);
}

.tabs-more-count {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--fx-primary);
    color: #fff;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}

.tabs-more-menu {
    position: fixed;
    z-index: 1200;
    min-width: 200px;
    max-width: 320px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px;
    background: var(--fx-panel);
    border: 1px solid var(--fx-line);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tabs-more-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 5px;
}

.tabs-more-item:hover {
    background: var(--fx-nav-hover);
}

.tabs-more-item.active a {
    color: var(--fx-primary);
    font-weight: 600;
}

.tabs-more-item a {
    flex: 1;
    min-width: 0;
    color: var(--fx-text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabs-more-item button {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}

.tabs-more-item button:hover {
    background: var(--fx-nav-hover);
}

.tab-context-menu button:disabled {
    color: var(--fx-text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.workspace-user {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    color: var(--fx-text-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}

.workspace-user a {
    color: var(--fx-primary);
    text-decoration: none;
}

.workspace-user button {
    font: inherit;
}

.workspace-username {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-user-links {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 14px;
    padding: 10px 2px 0;
    border-top: 1px solid var(--fx-border);
    color: var(--fx-text-muted);
    font-size: 12px;
    line-height: 20px;
}

.footer-uptime {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    white-space: nowrap;
    cursor: default;
}

.footer-uptime i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--fx-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-success) 15%, transparent);
}

@media (max-width: 640px) {
    .app-footer {
        gap: 8px;
    }

    .footer-uptime {
        font-size: 0;
    }

    .footer-uptime::after {
        content: "运行中";
        font-size: 12px;
    }
}

.change-password-link {
    border: 0;
    background: transparent;
    color: var(--fx-primary);
    cursor: pointer;
    padding: 0;
    white-space: nowrap;
}

.change-password-link:hover {
    color: var(--fx-text);
}

.logout-icon-form {
    display: inline-block;
    margin: 0;
}

.logout-icon-link {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--fx-border);
    border-radius: 6px;
    color: var(--fx-text-muted);
    background: none;
    cursor: pointer;
    padding: 0;
}

.logout-icon-link:hover {
    color: var(--fx-primary);
    border-color: var(--fx-primary);
    background: var(--fx-nav-hover);
}

.theme-toggle-button {
    display: inline-grid;
    place-items: center;
    width: 30px;
    border: 1px solid var(--fx-border);
    border-radius: 6px;
    background: var(--fx-panel);
    color: var(--fx-text-muted);
    cursor: pointer;
    height: 30px;
    padding: 0;
}

.theme-toggle-button:hover {
    color: var(--fx-primary);
    border-color: var(--fx-primary);
    background: var(--fx-nav-hover);
}


@media (max-width: 920px) {
    .app-shell,
    .app-shell.is-collapsed {
        grid-template-columns: 1fr;
    }

    .mobile-shell-bar {
        position: sticky;
        top: 0;
        z-index: 100;
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 52px;
        padding: 0 12px;
        background: var(--fx-sider);
        border-bottom: 1px solid var(--fx-border);
        box-shadow: var(--fx-elevation-sm);
    }

    .mobile-shell-bar .app-brand-mark {
        width: 30px;
        height: 30px;
        border-radius: 6px;
        font-size: 13px;
    }

    .mobile-shell-bar strong {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-brand-copy {
        flex: 1;
    }

    .mobile-brand-copy strong {
        font-size: 14px;
    }

    .mobile-brand-copy small {
        margin-top: 2px;
        font-size: 9.5px;
    }

    .mobile-menu-toggle,
    .mobile-sider-close {
        display: inline-grid;
        place-items: center;
        width: 36px;
        height: 36px;
        padding: 0;
        border: 1px solid var(--fx-border);
        border-radius: var(--fx-radius-md);
        background: var(--fx-panel);
        color: var(--fx-primary);
        cursor: pointer;
    }

    .mobile-menu-toggle {
        margin-right: 2px;
    }

    .mobile-sider-close {
        margin-left: auto;
    }

    .mobile-sider-mask {
        position: fixed;
        inset: 0;
        z-index: 109;
        display: block;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        background: rgba(15, 23, 42, 0.42);
        backdrop-filter: blur(1px);
    }

    .app-sider {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 110;
        width: min(300px, 86vw);
        height: 100dvh;
        box-sizing: border-box;
        padding: 16px 12px;
        border-right: 1px solid var(--fx-border);
        border-bottom: none;
        box-shadow: var(--fx-shadow);
        overflow: hidden;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .app-sider.mobile-open {
        transform: translateX(0);
    }

    .app-sider.mobile-open .app-brand {
        padding-right: 0;
    }

    .app-shell.is-collapsed .app-sider.mobile-open {
        align-items: stretch;
        padding: 16px 12px;
    }

    .app-shell.is-collapsed .app-sider.mobile-open .app-brand {
        justify-content: flex-start;
        flex-direction: row;
        gap: 8px;
        margin-bottom: 14px;
    }

    .app-shell.is-collapsed .app-sider.mobile-open .app-brand-title {
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr);
        flex: 1;
        overflow: hidden;
    }

    .app-shell.is-collapsed .app-sider.mobile-open .nav-group {
        width: auto;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        justify-items: stretch;
    }

    .app-shell.is-collapsed .app-sider.mobile-open .nav-item-shell {
        display: block;
    }

    .app-shell.is-collapsed .app-sider.mobile-open .app-nav a {
        width: auto;
        min-height: 36px;
        justify-content: flex-start;
        padding: 7px 10px;
    }

    .app-sider .sider-toggle {
        display: none;
    }

    .app-sider .app-nav {
        min-height: 0;
        padding-right: 4px;
        overflow-y: auto;
    }

    .app-main {
        padding: 10px;
    }

    .tab-workspace,
    .thing-panel-toolbar,
    .group-card-header,
    .section-title-row,
    .share-section-title,
    .share-outer-card header {
        align-items: stretch;
        flex-direction: column;
    }

    .group-card-side {
        justify-items: start;
        min-width: 0;
    }

    .group-card-tags {
        justify-content: flex-start;
    }

    .workspace-left,
    .workspace-user {
        width: 100%;
        justify-content: space-between;
    }

    .workspace-tabs {
        flex: 1;
    }

    .thing-global-layout {
        grid-template-columns: 1fr;
    }

    .thing-side-panel {
        position: static;
    }

    .share-card-grid {
        grid-template-columns: 1fr;
    }
}
