/* Только program-page и его потомки. */
#program-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(176px, 17.6vw, 224px);
    grid-template-rows: 38px minmax(0, 1fr) 34px;
    grid-template-areas: "header header" "main info" "footer info";
    min-width: 0;
    min-height: 0;
    /* Подсказки выходят над панелью; прокрутка задана телам окон, меню и панели сведений. */
    overflow: visible;
    background: #f2f5f8;
    color: #34495e;
    font-size: 13px;
    > header {
        grid-area: header;
        display: flex;
        align-items: center;
        height: 38px;
        gap: 6px;
        padding: 3px 10px;
        border-bottom: 1px solid #dce5ee;
        background: #fff;
        position: relative;
        z-index: 2;
        .main-nav {
            position: relative;
            display: flex;
            height: 100%;
            min-width: 0;
            .icon-button-toggle {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 35px;
                height: 100%;
                padding: 3px;
                border: 1px solid transparent;
                border-radius: 6px;
                background: transparent;
                color: #52677d;
                cursor: pointer;
                transition: background-color .15s, color .15s;
                svg {
                    width: 100%;
                    height: 100%;
                    fill: currentColor;
                    pointer-events: none;
                }
                &:hover {
                    background: #eaf2fa;
                    color: #246b9e;
                    border-color: #d8e6f2;
                }
                &:active {
                    background: #dceaf6;
                }
                &:focus-visible {
                    outline: 2px solid #6a9fc8;
                    outline-offset: -2px;
                }
            }
            .toolip-view-help-info {
                display: none;
                position: absolute;
                bottom: calc(100% + 6px);
                left: 0;
                z-index: 2;
                width: max-content;
                max-width: min(220px, calc(100vw - 20px));
                padding: 5px 9px;
                border-radius: 5px;
                background: #34495e;
                color: #fff;
                font: 12px/1.4 Arial, sans-serif;
                text-align: left;
                pointer-events: none;
            }
            .pdf-icon {
                position: relative;
                top: -.35em;
                margin-left: 5px;
                padding: 1px 4px;
                border-radius: 3px;
                background: #ffe9e7;
                color: #ad3832;
                font-size: 8px;
                font-weight: 700;
                line-height: 0;
                letter-spacing: .3px;
                vertical-align: baseline;
                white-space: nowrap;
            }
            .menu-list {
                display: none;
                position: absolute;
                top: 100%;
                left: 0;
                width: 220px;
                max-width: calc(100vw - 110px);
                max-height: min(320px, calc(100dvh - 145px));
                overflow: auto;
                overscroll-behavior: contain;
                margin: 0;
                padding: 6px;
                list-style: none;
                border: 1px solid #dce5ee;
                border-radius: 8px;
                background: #fff;
                box-shadow: 0 10px 30px #203e5b24;
                li {
                    padding: 7px 10px;
                    line-height: 1.5;
                    font-variant-numeric: tabular-nums;
                    cursor: pointer;
                    &:hover {
                        background: #edf5fc;
                        color: #246b9e;
                    }
                }
            }
            &:hover {
                .toolip-view-help-info, .menu-list {
                    display: block;
                }
            }
            &.general {
                .icon-button-toggle {
                    border-color: #cbd6e1;
                    transition: background-color .15s, color .15s, border-color .15s;
                    svg {
                        stroke: currentColor;
                        stroke-width: 10;
                        stroke-linejoin: round;
                    }
                    &:hover {
                        border-color: #a9c5da;
                    }
                    &:active {
                        border-color: #86abc7;
                    }
                }
            }
            &.passive {
                cursor: not-allowed;
                .icon-button-toggle {
                    background: transparent;
                    border-color: transparent;
                    color: #b3bec9;
                    cursor: not-allowed;
                    pointer-events: none;
                }
                &:hover {
                    .menu-list {
                        display: none;
                    }
                }
            }
            &:nth-last-child(-n + 4) {
                .toolip-view-help-info {
                    left: auto;
                    right: 0;
                }
            }
        }
        .main-fill-empty-space {
            flex: 1 1 20px;
            min-width: 20px;
        }
        .main-text-nav {
            box-sizing: border-box;
            flex: 0 1 auto;
            min-width: 0;
            overflow: hidden;
            color: #b3bec9;
            font-size: 12px;
            font-weight: 600;
            white-space: nowrap;
            text-overflow: ellipsis;
            transition: color .15s;
            &.active:hover {
                color: #246b9e;
            }
        }
        .need-save-ball {
            position: relative;
            padding-left: 11px;
            min-height: 5px;
            &::before {
                content: '';
                position: absolute;
                top: 50%;
                left: 0;
                width: 5px;
                height: 5px;
                transform: translateY(-50%);
                border-radius: 50%;
                background: #c49a59;
            }
        }
        > label:has(> input[type="datetime-local"]) {
            display: flex;
            align-items: center;
            gap: 5px;
            min-width: 0;
            margin-left: 4px;
            > span {
                color: #738395;
                font-size: 12px;
                white-space: nowrap;
            }
            > input {
                box-sizing: border-box;
                width: 140px;
                min-width: 0;
                height: 28px;
                padding: 3px 6px;
                border: 1px solid #cbd6e1;
                border-radius: 5px;
                background: #f7f9fc;
                color: #34495e;
                font: inherit;
                font-size: 12px;
                font-variant-numeric: tabular-nums;
                color-scheme: light;
                transition: border-color .15s, background-color .15s;
                &:hover {
                    border-color: #a9c5da;
                    background: #edf5fc;
                }
                &:focus {
                    outline: 2px solid #6a9fc8;
                    outline-offset: -1px;
                    border-color: #6a9fc8;
                    background: #fff;
                }
                &::-webkit-calendar-picker-indicator {
                    opacity: .65;
                    cursor: pointer;
                    &:hover {
                        opacity: 1;
                    }
                }
            }
        }
        .main-nav-separator {
            flex: 0 0 1px;
            height: 20px;
            margin: 0 5px;
            background: #e1e7ee;
        }
    }
    > .file-info-panel {
        grid-area: info;
        min-width: 0;
        min-height: 0;
        padding: 10px;
        overflow: auto;
        border-left: 1px solid #cbd6e1;
        background: #fff;
        color: #52677d;
        font-size: 12px;
        line-height: 1.4;
        overflow-wrap: anywhere;
        h2 {
            margin: 0;
            color: #34495e;
            font-size: 13px;
            font-weight: 600;
        }
        > p {
            margin: 3px 0 14px;
            color: #8e774e;
            font-size: 11px;
        }
        h3 {
            margin: 16px 0 8px;
            padding-top: 12px;
            border-top: 1px solid #e1e7ee;
            color: #52677d;
            font-size: inherit;
            font-weight: 600;
        }
        dl {
            margin: 0;
        }
        dt {
            margin-top: 8px;
            color: #8795a3;
            font-size: 11px;
        }
        dd {
            margin: 2px 0 0;
        }
    }
    > footer {
        grid-area: footer;
        display: flex;
        height: 34px;
        padding: 0 10px;
        border-top: 1px solid #dce5ee;
        background: #fff;
        overflow: hidden;
        > .tab {
            display: flex;
            align-items: center;
            justify-content: center;
            min-width: 0;
            padding: 0 18px;
            border-top: 2px solid transparent;
            color: #65788b;
            text-decoration: none;
            cursor: pointer;
            transition: background-color .15s, color .15s;
            &:hover {
                background: #edf5fc;
                color: #246b9e;
            }
            &:focus-visible {
                outline: 2px solid #6a9fc8;
                outline-offset: -3px;
            }
            &.active, &[aria-selected="true"] {
                border-top-color: #286fa6;
                background: #edf5fc;
                color: #246b9e;
            }
        }
    }
}
@media (max-width: 900px) {
    #program-page > header {
        > label:has(> input[type="datetime-local"]) > span {
            display: none;
        }
    }
}
@media (max-width: 480px) {
    #program-page {
        > header {
            gap: 2px;
            padding: 3px 6px;
            .main-nav {
                flex: 1 1 0;
                .icon-button-toggle {
                    width: 100%;
                    max-width: 34px;
                    padding: 2px;
                }
            }
            .main-nav-separator {
                margin: 0 2px;
            }
        }
        > footer {
            padding: 0;
            > .tab {
                flex: 1 1 0;
                padding: 0 6px;
                font-size: 11px;
                text-align: center;
            }
        }
    }
}
@media (max-width: 600px) {
    #program-page {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 38px minmax(0, 1fr) 34px minmax(0, 28%);
        grid-template-areas: "header" "main" "footer" "info";
        > .file-info-panel {
            border-left: 0;
            border-top: 1px solid #cbd6e1;
        }
    }
}
