.sideBox {
    position: fixed;
    top: var(--header-height, 64px);
    margin-top: 0;
    right: 0;
    bottom: 0;
    /* Abaixo do header azul (800) e da nav (799); acima do header de página (750). */
    z-index: 790;
    width: var(--detail-opcoes-side-width, 280px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

.sideBoxLeft {
    /* Após a sidebar (expandida 250px ou rail recolhida via --sidebar-rail-reserve). */
    left: var(--sidebar-rail-reserve, 250px);
    right: auto;
    border-left: none;
    border-right: 1px solid #e5e7eb;
}

.sideBoxBody {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 12px 0 16px;
    background: #fff;
}

.railChildrenSection {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.railChildrenTitle {
    display: block;
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
}

.railChildren {
    padding: 4px 16px 12px;
    min-width: 0;

    :global(.ant-form-item) {
        margin-bottom: 12px;
    }

    :global(.ant-form-item:last-child) {
        margin-bottom: 0;
    }

    :global(.ant-form-item-label) {
        padding-bottom: 2px !important;

        > label {
            height: auto;
            font-size: 12px;
            font-weight: 600;
            color: #64748b;
        }
    }

    :global(.ant-form-item-control-input) {
        min-height: 32px;
    }

    :global(.ant-select),
    :global(.ant-picker),
    :global(.ant-input),
    :global(.ant-input-affix-wrapper),
    :global(.ant-btn:not(.ant-btn-link)) {
        width: 100%;
    }

    :global(.ant-btn-link) {
        width: auto;
        padding-inline: 0;
        height: auto;
        font-size: 12px;
    }
}

.railList {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: none;
    border: none;
}

.railGroup + .railGroup {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #e5e7eb;
}

.railGroupTitle {
    display: block;
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
}

.railItem {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 8px 16px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #000;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    box-sizing: border-box;

    &:hover:not(:disabled) {
        background: rgba(37, 99, 235, 0.06);
        color: var(--primary, #2563eb);
        text-decoration: none;
    }

    &:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }
}

.railItemDanger {
    color: var(--color-error, #cf1322);

    &:hover:not(:disabled) {
        background: color-mix(in srgb, var(--color-error, #cf1322) 8%, transparent);
        color: var(--color-error, #cf1322);
    }

    &:disabled {
        color: var(--color-error, #cf1322);
    }
}

.railItemPrimary {
    font-weight: 600;
}

.railItemIcon {
    display: inline-flex;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    color: inherit;

    :global(svg) {
        width: 16px;
        height: 16px;
    }
}

.railItemLabel {
    min-width: 0;
    flex: 1;
}

.railDisabledWrap {
    display: block;
    width: 100%;
}

:global(.dark) .sideBox,
:global(.dark) .sideBoxBody {
    background: var(--surface, #141414);
    border-left-color: var(--border, #2d3748);
}

:global(.dark) .sideBoxLeft {
    border-left: none;
    border-right-color: var(--border, #2d3748);
}

:global(.dark) .railChildrenSection {
    border-bottom-color: var(--border, #2d3748);
}

:global(.dark) .railChildrenTitle {
    color: #94a3b8;
}

:global(.dark) .railChildren {
    :global(.ant-form-item-label) > label {
        color: #94a3b8;
    }
}

:global(.dark) .railGroup + .railGroup {
    border-top-color: var(--border, #2d3748);
}

:global(.dark) .railItem {
    color: var(--text, #e5e7eb);

    &:hover:not(:disabled) {
        color: var(--primary, #2563eb);
    }
}

:global(.dark) .railItemDanger {
    color: var(--color-error, #cf1322);

    &:hover:not(:disabled),
    &:disabled {
        color: var(--color-error, #cf1322);
    }
}

/* ProjetoLayout: o rail é portal no body — recua abaixo da nav secundária. */
:global(html.projeto-layout) .sideBox {
    margin-top: calc(
        var(--projeto-secondary-nav-h, 56px) + env(safe-area-inset-top, 0px)
    );
    bottom: auto;
    height: calc(
        100dvh - var(--header-height, 64px) - var(--projeto-secondary-nav-h, 56px) -
            env(safe-area-inset-top, 0px)
    );
}

.floatTrigger {
    position: fixed;
    z-index: 790;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--border, #e5e7eb);
    background: var(--surface, #fff);
    color: var(--text, rgba(0, 0, 0, 0.88));
    cursor: pointer;
}

.floatTriggerRight {
    right: 0;
    border-radius: 10px 0 0 10px;
    box-shadow: -2px 0 12px rgba(15, 12, 20, 0.08);
}

.floatTriggerLeft {
    left: var(--sidebar-rail-reserve, 0px);
    border-radius: 0 10px 10px 0;
    box-shadow: 2px 0 12px rgba(15, 12, 20, 0.08);
}

.overlayMask {
    position: fixed;
    inset: 0;
    z-index: 789;
    border: 0;
    padding: 0;
    background: rgba(15, 12, 20, 0.35);
    cursor: pointer;
}

@media (max-width: 768px) {
    .floatTrigger {
        top: auto;
        bottom: 88px;
        transform: none;
    }
}

:global(.dark) .floatTrigger {
    background: var(--surface, #1f1f1f);
    border-color: var(--border, #2d3748);
    color: var(--text, #e5e7eb);
}
