.pageScroll {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg-subtle);
    scrollbar-gutter: stable;
}

.overviewSection {
    min-width: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.sectionHeader {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 22px 12px;
}

.sectionTitleGroup,
.dialogHeading {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.pageTitle {
    margin: 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 780;
    line-height: 1.35;
}

.pageSubtitle,
.summaryLabel {
    color: var(--text-tertiary);
    font-size: 12px;
    line-height: 1.4;
}

.headerActions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.summaryItems {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    gap: 10px;
    padding: 0 22px 14px;
}

.summaryItem {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card-strong);
}

.summaryValue {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.overviewTable {
    flex: none !important;
    min-height: auto !important;
    border: 0 !important;
    border-top: 1px solid var(--border) !important;
    border-radius: 0 !important;
}

.overviewTable :global(.table-scroll) {
    flex: none;
    min-height: auto;
    overflow-x: auto;
    overflow-y: visible;
}

.overviewTable :global(.admin-table) {
    min-height: 0;
}

.overviewTable :global(.admin-row) {
    min-height: 42px;
}

.overviewTable :global(.admin-row--head) {
    position: static;
    min-height: 38px;
}

.levelTableName {
    color: var(--text-primary);
    font-weight: 760;
}

.statusBadge {
    display: inline-flex;
    width: fit-content;
    min-height: 23px;
    align-items: center;
    padding: 0 9px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 720;
}

.statusActive {
    border: 1px solid var(--success-border);
    background: var(--success-surface);
    color: var(--success);
}

.statusDisabled {
    border: 1px solid var(--border);
    background: var(--bg-card-strong);
    color: var(--text-tertiary);
}

.programDialogPaper {
    border-radius: var(--radius-card) !important;
    background: var(--bg-card) !important;
    box-shadow: var(--shadow-dialog) !important;
}

.programDialogForm {
    display: grid;
    max-height: calc(100vh - 48px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.dialogTitle,
.levelsDialogTitle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border);
}

.dialogTitle {
    padding: 18px 20px 14px !important;
}

.dialogTitle > div:first-child {
    display: grid;
    gap: 3px;
}

.dialogTitle h2,
.levelsDialogTitle h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 19px;
    font-weight: 800;
    line-height: 1.35;
}

.dialogTitle span,
.levelsDialogTitle .dialogHeading > span {
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 650;
}

.programDialogContent {
    display: grid;
    gap: 14px;
    min-height: 0;
    overflow: auto;
    padding: 20px !important;
}

.programGrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.inlineNotice {
    padding: 10px 12px;
    border: 1px solid var(--warning-border);
    border-radius: 8px;
    background: var(--warning-surface);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}

.dialogActions,
.levelsDialogActions {
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.dialogActions {
    gap: 8px;
    padding: 12px 20px 16px !important;
}

.levelsDialogPaper {
    width: min(1420px, calc(100vw - 32px)) !important;
    max-width: min(1420px, calc(100vw - 32px)) !important;
    height: min(900px, calc(100vh - 32px));
    max-height: calc(100vh - 32px) !important;
    overflow: hidden;
    border-radius: 12px !important;
    background: var(--bg-card) !important;
    box-shadow: var(--shadow-dialog) !important;
}

.levelsDialogForm {
    display: grid;
    width: 100%;
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.levelsDialogTitle {
    min-height: 68px;
    padding: 13px 18px 12px 20px !important;
}

.dialogHeaderActions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.dialogStat {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    padding: 0 9px;
    border: 1px solid var(--admin-tag-border);
    border-radius: var(--radius-pill);
    background: var(--admin-tag-bg);
    color: var(--admin-tag-color);
    font-size: 11px;
    font-weight: 720;
    white-space: nowrap;
}

.rulesButton {
    min-height: 30px !important;
}

.levelsDialogContent {
    display: grid !important;
    min-width: 0;
    min-height: 0;
    grid-template-columns: 184px minmax(560px, 1fr) 340px;
    overflow: hidden !important;
    padding: 0 !important;
}

.levelRail {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-card-strong) 65%, var(--bg-card));
    scrollbar-width: thin;
}

.levelRailHeading {
    position: sticky;
    top: 0;
    z-index: 1;
    display: grid;
    gap: 2px;
    padding: 14px 12px 10px;
    border-bottom: 1px solid var(--border-soft);
    background: color-mix(in srgb, var(--bg-card-strong) 92%, var(--bg-card));
}

.levelRailHeading strong {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 800;
}

.levelRailHeading span {
    color: var(--text-tertiary);
    font-size: 10px;
}

.levelRailList {
    display: grid;
    gap: 5px;
    padding: 8px;
}

.levelRailItem {
    display: grid;
    width: 100%;
    min-height: 58px;
    gap: 5px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition:
        border-color 120ms ease,
        background 120ms ease,
        box-shadow 120ms ease;
}

.levelRailItem:hover {
    background: var(--bg-hover);
}

.levelRailItem:focus-visible {
    outline: 2px solid var(--primary-border-strong);
    outline-offset: 1px;
}

.levelRailItemActive {
    border-color: var(--primary-border);
    background: var(--primary-surface);
    box-shadow: inset 3px 0 0 var(--primary);
}

.levelRailItemTop,
.levelRailItemMeta {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.levelRailItemTop strong {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 800;
}

.levelRailItemMeta {
    color: var(--text-tertiary);
    font-size: 10px;
}

.levelStatusDot {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.levelStatusDotActive {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-surface);
}

.levelMain {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-page);
    scrollbar-gutter: stable;
}

.levelBaseSection,
.benefitsPanel {
    flex: 0 0 auto;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.035);
}

.levelBaseSection {
    display: grid;
    gap: 13px;
    padding: 14px;
}

.panelHeading {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panelHeading > div:first-child {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.panelEyebrow {
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 760;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.panelHeading h3,
.benefitsTitleBlock h3,
.inspectorHeading h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.4;
}

.levelFields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.levelFields > :nth-child(4) {
    grid-column: span 2;
}

.levelsDialog :global(.MuiTextField-root),
.levelsDialog :global(.MuiFormControl-root),
.programDialogForm :global(.MuiTextField-root),
.programDialogForm :global(.MuiFormControl-root) {
    --admin-control-height: 34px;
    --admin-control-font-size: 12px;
}

.benefitsPanel {
    display: grid;
    overflow: visible;
}

.benefitsToolbar {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 9px;
}

.benefitsTitleBlock {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 8px;
}

.benefitsTitleBlock span {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 650;
}

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

.benefitSearch {
    width: min(210px, 30vw);
}

.selectAllControl {
    margin: 0 !important;
}

.selectAllControl :global(.MuiFormControlLabel-label) {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
}

.filterBar {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--border-soft);
}

.filterChip {
    min-height: 25px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    color: var(--text-secondary);
    font: inherit;
    font-size: 11px;
    font-weight: 680;
    white-space: nowrap;
    cursor: pointer;
}

.filterChip:hover {
    border-color: var(--primary-border);
    color: var(--primary);
}

.filterChip:focus-visible {
    outline: 2px solid var(--primary-border-strong);
    outline-offset: 1px;
}

.filterChipActive {
    border-color: var(--primary-border);
    background: var(--primary-surface);
    color: var(--primary);
}

.benefitGroups {
    display: grid;
    min-width: 0;
    gap: 12px;
    padding: 12px 14px 14px;
}

.benefitGroup {
    display: grid;
    min-width: 0;
    gap: 7px;
}

.benefitGroupHeading {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 800;
}

.benefitGroupHeading span:last-child {
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 680;
}

.benefitMatrix {
    display: grid;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.benefitCard {
    display: grid;
    min-width: 0;
    min-height: 52px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px;
    padding: 3px 7px 3px 3px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
    background: var(--bg-card-strong);
    transition:
        border-color 120ms ease,
        background 120ms ease,
        box-shadow 120ms ease;
}

.benefitCard:hover {
    border-color: var(--primary-border);
}

.benefitCardSelected {
    border-color: var(--primary-border-strong);
    background: var(--primary-surface);
    box-shadow: 0 0 0 1px var(--primary-surface-strong);
}

.benefitCard > button {
    display: grid;
    min-width: 0;
    gap: 2px;
    padding: 6px 4px;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.benefitCard > button:focus-visible {
    border-radius: 4px;
    outline: 2px solid var(--primary-border-strong);
    outline-offset: 1px;
}

.benefitCardName,
.benefitCardSummary {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.benefitCardName {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 730;
}

.benefitCardSummary {
    color: var(--text-tertiary);
    font-size: 10px;
}

.benefitEnabledLabel,
.benefitDisabledLabel {
    display: inline-flex;
    min-height: 20px;
    align-items: center;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    font-size: 9px;
    font-weight: 760;
    white-space: nowrap;
}

.benefitEnabledLabel {
    background: var(--success-surface);
    color: var(--success);
}

.benefitDisabledLabel {
    background: color-mix(in srgb, var(--text-tertiary) 10%, transparent);
    color: var(--text-tertiary);
}

.emptyBenefits,
.inspectorEmpty,
.classicNotice {
    padding: 24px 16px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-tertiary);
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
}

.classicNotice {
    background: var(--bg-card);
}

.inspector {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: var(--bg-card);
    scrollbar-gutter: stable;
}

.inspectorBody,
.rulesPanel {
    display: grid;
    min-width: 0;
    align-content: start;
    gap: 14px;
    padding: 16px;
}

.inspectorHeading {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-soft);
}

.inspectorHeading > div:first-child {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.inspectorHeading code {
    max-width: 220px;
    overflow: hidden;
    color: var(--text-tertiary);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inspectorSection {
    display: grid;
    min-width: 0;
    gap: 10px;
}

.inspectorSection h4 {
    margin: 0;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 800;
}

.switchField {
    display: flex;
    min-height: 34px;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 650;
}

.noExtraFields {
    margin: 0;
    padding: 10px 11px;
    border-radius: 7px;
    background: var(--bg-card-strong);
    color: var(--text-tertiary);
    font-size: 11px;
    line-height: 1.55;
}

.advancedSettings {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card-strong);
}

.advancedSettings > summary {
    padding: 10px 12px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 760;
    cursor: pointer;
    user-select: none;
}

.advancedSettings[open] > summary {
    border-bottom: 1px solid var(--border);
}

.advancedFields {
    display: grid;
    min-width: 0;
    gap: 10px;
    padding: 12px;
}

.rulesPanel ol {
    display: grid;
    gap: 9px;
    margin: 0;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.62;
}

.levelsDialogActions {
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between !important;
    gap: 16px;
    padding: 10px 18px !important;
}

.saveHint {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.saveHint strong {
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 800;
}

.saveHint span {
    min-width: 0;
    overflow: hidden;
    color: var(--text-tertiary);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.footerActions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

@media (max-width: 1240px) {
    .levelsDialogContent {
        grid-template-columns: 164px minmax(500px, 1fr) 300px;
    }

    .levelFields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .levelFields > :nth-child(4) {
        grid-column: auto;
    }
}

@media (max-width: 1020px) {
    .levelsDialogPaper {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px) !important;
    }

    .levelsDialogContent {
        grid-template-columns: 148px minmax(430px, 1fr) 280px;
    }

    .benefitMatrix {
        grid-template-columns: 1fr;
    }

    .dialogStat {
        display: none;
    }
}

@media (max-width: 820px) {
    .summaryItems {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .levelsDialogTitle {
        align-items: flex-start;
    }

    .dialogHeaderActions {
        gap: 4px;
    }

    .levelsDialogContent {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        overflow-y: auto !important;
    }

    .levelRail {
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .levelRailHeading {
        display: none;
    }

    .levelRailList {
        display: flex;
        width: max-content;
        padding: 7px 10px;
    }

    .levelRailItem {
        width: 126px;
        min-height: 50px;
    }

    .levelMain {
        overflow: visible;
    }

    .inspector {
        grid-column: 1;
        overflow: visible;
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .levelsDialogActions {
        min-height: auto;
    }

    .saveHint {
        display: none;
    }
}

@media (max-width: 620px) {
    .sectionHeader {
        align-items: stretch;
        flex-direction: column;
    }

    .headerActions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .summaryItems,
    .programGrid,
    .levelFields,
    .benefitMatrix {
        grid-template-columns: 1fr;
    }

    .summaryItems {
        padding-right: 12px;
        padding-left: 12px;
    }

    .levelsDialogTitle {
        padding-left: 14px !important;
    }

    .levelsDialogTitle .rulesButton,
    .levelsDialogTitle .dialogHeading > span {
        display: none;
    }

    .levelMain,
    .inspectorBody,
    .rulesPanel {
        padding: 12px;
    }

    .benefitsToolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .benefitsToolbarActions,
    .benefitSearch {
        width: 100%;
    }
}
