/* 与实验平台保持一致的外壳；限定在 sx-app 内，避免影响宿主和其他模块。 */
.sx-app {
    --sx-header-height: 56px;
    --sx-sidebar-width: 224px;
    --sx-brand: #1e40af;
    --sx-primary: #448aff;
    --sx-background: #f9fafb;
    --sx-border: #e5e7eb;
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
    font-size: 14px;
    line-height: 1.75;
}

.sx-shell,
.sx-shell * {
    box-sizing: border-box;
}

.sx-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    background: var(--sx-background);
    color: #1f2937;
}

.sx-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 var(--sx-header-height);
    gap: 16px;
    padding: 0 15px;
    background: var(--sx-brand);
    color: #fff;
    z-index: 6;
}

.sx-brand,
.sx-brand-link,
.sx-header-actions,
.sx-account summary {
    display: flex;
    align-items: center;
}

.sx-brand {
    min-width: 0;
}

.sx-header .sx-brand-link {
    gap: 20px;
    min-width: 0;
    color: #fff;
    text-decoration: none;
}

.sx-logo {
    display: block;
    height: 24px;
    width: auto;
}

.sx-app-name {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}

.sx-header-actions {
    flex-shrink: 0;
    gap: 10px;
}

.sx-header .sx-platform-link {
    padding: 3px 12px;
    border: 1px solid currentColor;
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}

.sx-platform-link:hover {
    background: rgba(255, 255, 255, .12);
}

.sx-account {
    position: relative;
}

.sx-account summary {
    gap: 10px;
    min-height: 44px;
    cursor: pointer;
    list-style: none;
}

.sx-account summary::-webkit-details-marker {
    display: none;
}

.sx-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.sx-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #60a5fa;
    font-size: 18px;
}

.sx-account-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 132px;
    padding: 4px;
    border: 1px solid var(--sx-border);
    border-radius: 6px;
    background: #fff;
    color: #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .08), 0 8px 20px rgba(0, 0, 0, .08);
}

.sx-account-menu button {
    width: 100%;
    padding: 10px 16px;
    border-radius: 4px;
    text-align: left;
}

.sx-account-menu button:hover {
    background: #f3f4f6;
}

.sx-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sx-sidebar {
    flex: 0 0 var(--sx-sidebar-width);
    width: var(--sx-sidebar-width);
    padding: 15px;
    overflow-y: auto;
    border-right: 1px solid var(--sx-border);
    background: #fff;
}

.sx-app .sx-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    margin-bottom: 5px;
    padding: 6px 15px;
    border-radius: 6px;
    color: #4b5563;
    font-size: 14px;
    text-decoration: none;
}

.sx-nav-link .mdi {
    font-size: 16px;
    line-height: 1;
}

.sx-app .sx-nav-link:hover {
    background: #f1f2f5;
}

.sx-app .sx-nav-link.active {
    background: #dbeafe;
    color: #1d4ed8;
}

.sx-content {
    flex: 1;
    min-width: 0;
    padding: 15px;
    overflow: auto;
}

.sx-page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.sx-page-heading h1 {
    position: relative;
    margin: 6px 0 0;
    padding-left: 11px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.5;
}

.sx-page-heading h1::before {
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 0;
    width: 2px;
    background: var(--sx-primary);
    content: "";
}

.sx-page-heading p {
    margin: 8px 0 0 11px;
    color: #6b7280;
    font-size: 14px;
}

.sx-page-heading > .m-btn {
    flex-shrink: 0;
}

.sx-detection-detail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100%;
}

.sx-detection-detail > .sx-page-heading {
    margin-bottom: 0;
}

.sx-detection-summary {
    flex: 0 0 auto;
    padding: 12px 16px;
}

.sx-detection-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.sx-detection-identity {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.sx-detection-message {
    flex: 1;
    min-width: 0;
    color: #6b7280;
    overflow-wrap: anywhere;
}

.sx-detection-status > .m-btn {
    flex-shrink: 0;
}

.sx-detection-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 24px;
    margin: 8px 0 0;
    font-size: 13px;
}

.sx-detection-meta > div {
    display: flex;
    gap: 8px;
    min-width: 0;
}

.sx-detection-detail dt {
    flex-shrink: 0;
    color: #6b7280;
    font-weight: 400;
}

.sx-detection-detail dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.sx-realtime-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--sx-border);
}

.sx-realtime-pulse {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.sx-realtime-pulse h2,
.sx-sampling-toolbar h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
}

.sx-realtime-value {
    min-width: 2ch;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.sx-realtime-pulse > .text--secondary,
.sx-realtime-status {
    font-size: 13px;
}

.sx-realtime-status {
    margin-left: auto;
    overflow-wrap: anywhere;
}

.sx-detection-detail .sx-sampling-card {
    display: flex;
    flex: 1 0 390px;
    flex-direction: column;
    min-width: 0;
}

.sx-sampling-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 12px 16px 0;
}

.sx-sampling-toolbar .sx-channel-select {
    flex: 0 1 280px;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.sx-sampling-card .sx-sampling-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    padding: 8px 16px 12px;
}

.sx-sample-chart {
    flex: 1;
    min-width: 0;
    min-height: 300px;
}

@media (max-width: 767px) {
    .sx-detection-status {
        gap: 8px;
    }

    .sx-detection-message {
        flex-basis: calc(100% - 100px);
    }

    .sx-detection-status > .m-btn {
        min-height: 44px;
        margin-left: auto;
    }

    .sx-realtime-strip {
        gap: 8px 16px;
    }

    .sx-realtime-status {
        flex-basis: 100%;
        margin-left: 0;
    }

    .sx-sampling-toolbar .sx-channel-select {
        flex-basis: 100%;
    }
}

.sx-experiment-qr-image {
    display: block;
    width: 200px;
    max-width: 100%;
    height: auto;
    margin: 8px auto;
}

.sx-add-icon {
    margin-right: 4px;
    font-size: 20px;
    line-height: 1;
}

.sx-app .sx-content .m-card {
    border: 1px solid #eceef1;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 1px 5px rgba(0, 0, 0, .06);
}

.sx-app .sx-content .m-card__title {
    font-size: 16px;
    font-weight: 600;
}

.sx-app .sx-content .m-btn,
.sx-app .sx-edit-modal .m-btn {
    letter-spacing: normal;
}

.sx-app .sx-content .m-btn.primary,
.sx-app .sx-edit-modal .m-btn.primary {
    background-color: var(--sx-primary) !important;
    border-color: var(--sx-primary) !important;
    box-shadow: none;
}

.sx-app .sx-content .primary--text,
.sx-app .sx-edit-modal .primary--text {
    color: #2563eb !important;
    caret-color: #2563eb !important;
}

.sx-shell a:focus-visible,
.sx-shell button:focus-visible,
.sx-shell summary:focus-visible {
    outline: 2px solid #448aff;
    outline-offset: 3px;
}

.sx-header a:focus-visible,
.sx-header button:focus-visible,
.sx-header summary:focus-visible {
    outline-color: #fff;
}

.sx-detection-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.sx-detection-form > section {
    min-width: 0;
}

.sx-form-section-title {
    margin: 0 0 20px;
    font-size: 16px;
    font-weight: 600;
}

.sx-patient-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 800px) {
    .sx-patient-actions .m-btn {
        min-height: 44px;
    }
}

.sx-device-find {
    text-align: center;
}

.sx-device-find-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    min-height: 72px;
    padding: 8px 16px;
    border-radius: 8px;
    background: #33cc44;
    color: #102b16;
    font-size: 32px;
    font-weight: 600;
}

.sx-device-find p {
    margin: 12px 0 0;
}

.sx-skip-link {
    position: fixed;
    top: -60px;
    left: 16px;
    z-index: 10;
    padding: 8px 16px;
    background: #fff;
}

.sx-skip-link:focus {
    top: 8px;
}

.sx-menu-toggle,
.sx-nav-scrim {
    display: none;
}

@media (max-width: 767px) {
    .sx-header {
        gap: 8px;
        padding: 0 12px;
    }

    .sx-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin-left: -8px;
        font-size: 24px;
    }

    .sx-header .sx-brand-link {
        gap: 10px;
    }

    .sx-logo {
        display: none;
    }

    .sx-app-name {
        font-size: 17px;
    }

    .sx-user-name {
        display: none;
    }

    .sx-account summary {
        justify-content: center;
        min-width: 44px;
    }

    .sx-header-actions {
        gap: 4px;
    }

    .sx-header .sx-platform-link {
        padding: 6px 8px;
    }

    .sx-sidebar {
        display: none;
        position: fixed;
        top: var(--sx-header-height);
        bottom: 0;
        left: 0;
        z-index: 5;
    }

    .sx-sidebar.is-open {
        display: block;
    }

    .sx-nav-link {
        min-height: 44px !important;
    }

    .sx-nav-scrim {
        display: block;
        position: fixed;
        inset: var(--sx-header-height) 0 0;
        z-index: 4;
        background: rgba(15, 23, 42, .35);
    }

    .sx-content {
        padding: 12px;
    }

    .sx-page-heading {
        flex-wrap: wrap;
        gap: 12px;
    }
}
