.df-custom-dashboard-page {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}

.df-custom-dashboard-page.is-presentation {
    width: 100%;
    height: 100%;
    gap: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.df-custom-dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--df-border, rgba(148, 163, 184, .24));
    border-radius: 10px;
    background: color-mix(in srgb, var(--df-surface, #101827) 94%, transparent);
    box-shadow: 0 16px 38px rgba(15, 23, 42, .12);
}

.df-custom-dashboard-toolbar-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.df-custom-dashboard-selector {
    width: min(300px, 32vw);
    min-width: 220px;
}

.df-custom-dashboard-title-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.df-custom-dashboard-title-stack strong {
    color: var(--df-text, #e5edf7);
    font-size: 15px;
    font-weight: 900;
    line-height: 1.2;
}

.df-custom-dashboard-title-stack span {
    color: var(--df-muted, #8da2bc);
    font-size: 12px;
    line-height: 1.25;
}

.df-custom-dashboard-name-input {
    width: min(360px, 38vw);
}

.df-custom-dashboard-description-input {
    width: min(520px, 46vw);
}

.df-custom-dashboard-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.df-custom-dashboard-widget-picker {
    width: min(300px, 34vw);
    min-width: 220px;
}

.df-custom-dashboard-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--df-muted, #8da2bc);
    font-size: 12px;
    font-weight: 800;
    user-select: none;
}

.df-custom-dashboard-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 620px;
    overflow: auto;
    border-radius: 10px;
}

.df-custom-dashboard-page.is-presentation .df-custom-dashboard-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border-radius: 0;
}

.df-custom-dashboard-grid {
    min-height: 100%;
    padding: 2px;
}

.df-custom-dashboard-page.is-presentation .df-custom-dashboard-grid {
    height: 100%;
    min-height: 100%;
    padding: 0;
}

.df-custom-dashboard-grid.is-editing {
    background-image:
        linear-gradient(rgba(148, 163, 184, .08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, .08) 1px, transparent 1px);
    background-size: calc(100% / 12) calc(var(--df-custom-dashboard-cell-height, 78px) + 10px);
    cursor: default;
}

.df-custom-dashboard-grid.is-editing .grid-stack-item {
    touch-action: none;
}

.df-custom-dashboard-grid.is-editing .grid-stack-item.ui-draggable-dragging,
.df-custom-dashboard-grid.is-editing .grid-stack-item.ui-resizable-resizing {
    z-index: 50 !important;
}

.df-custom-dashboard-grid.is-editing .ui-resizable-handle {
    z-index: 8;
}

.df-custom-widget {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--df-border, rgba(148, 163, 184, .2));
    border-radius: 10px;
    background: var(--df-card, #111c2d);
    box-shadow: 0 18px 42px rgba(2, 8, 23, .22);
}

.df-custom-dashboard-page.is-presentation .df-custom-widget {
    border-radius: 8px;
}

.df-custom-widget-editbar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--df-border, rgba(148, 163, 184, .2));
    background: color-mix(in srgb, var(--df-card, #111c2d) 92%, #18d6e8 8%);
    cursor: grab;
    user-select: none;
    z-index: 4;
}

.df-custom-widget-editbar:active {
    cursor: grabbing;
}

.df-custom-widget-editbar > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.df-custom-widget-editbar strong {
    overflow: hidden;
    color: var(--df-text, #e5edf7);
    font-size: 12px;
    font-weight: 900;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.df-custom-widget-editbar span {
    color: var(--df-muted, #8da2bc);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.15;
    text-transform: uppercase;
}

.df-custom-widget-drag,
.df-custom-widget-remove {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border: 0;
    border-radius: 8px;
    color: var(--df-muted, #8da2bc);
    background: rgba(148, 163, 184, .13);
    z-index: 5;
}

.df-custom-widget-drag {
    cursor: grab;
}

.df-custom-widget-drag:active {
    cursor: grabbing;
}

.df-custom-widget-remove {
    color: #fb7185;
    cursor: pointer;
}

.df-custom-widget-frame {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    border: 0;
    background: var(--df-bg, #07111f);
}

.df-custom-dashboard-grid.is-editing .df-custom-widget-frame {
    pointer-events: none;
}

.df-custom-widget-edit-overlay {
    position: absolute;
    inset: 38px 0 0;
    z-index: 3;
    display: grid;
    place-items: center;
    border: 1px dashed rgba(24, 214, 232, .22);
    background:
        linear-gradient(135deg, rgba(24, 214, 232, .08), transparent 36%),
        rgba(2, 8, 23, .08);
    color: color-mix(in srgb, var(--df-text, #e5edf7) 82%, #18d6e8 18%);
    cursor: grab;
    opacity: .42;
    pointer-events: auto;
    touch-action: none;
    transition: opacity .16s ease, background .16s ease, border-color .16s ease;
}

.df-custom-widget-edit-overlay:active {
    cursor: grabbing;
}

.df-custom-widget-edit-overlay span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid rgba(148, 163, 184, .2);
    border-radius: 999px;
    background: color-mix(in srgb, var(--df-card, #111c2d) 80%, transparent);
    box-shadow: 0 10px 24px rgba(2, 8, 23, .24);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.df-custom-widget:hover .df-custom-widget-edit-overlay,
.df-custom-dashboard-grid.is-dragging .df-custom-widget-edit-overlay {
    border-color: rgba(24, 214, 232, .42);
    background:
        linear-gradient(135deg, rgba(24, 214, 232, .13), transparent 38%),
        rgba(2, 8, 23, .16);
    opacity: .9;
}

.df-custom-dashboard-grid.is-editing .df-custom-widget {
    outline: 1px solid rgba(24, 214, 232, .12);
    outline-offset: -2px;
}

.df-custom-dashboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    gap: 8px;
    border: 1px dashed var(--df-border, rgba(148, 163, 184, .3));
    border-radius: 10px;
    color: var(--df-muted, #8da2bc);
    text-align: center;
}

.df-custom-dashboard-empty.compact {
    height: 100%;
    min-height: 420px;
}

.df-custom-dashboard-empty.error {
    border-color: rgba(244, 63, 94, .45);
    color: #fb7185;
}

.df-custom-dashboard-empty .rz-icon {
    font-size: 38px;
}

.df-custom-dashboard-empty strong {
    color: var(--df-text, #e5edf7);
    font-size: 16px;
    font-weight: 900;
}

.df-custom-dashboard-empty span {
    max-width: 460px;
    font-size: 13px;
    line-height: 1.45;
}

/* Custom dashboard pure mode uses a smart row height. The page can scroll
   when the saved layout is taller than the viewport, but rows never stretch
   endlessly on 2K/4K monitoring screens. */
.df-pure-layout.df-pure-custom-dashboard {
    overflow: auto !important;
}

.df-pure-layout.df-pure-custom-dashboard .df-page.df-custom-dashboard-page,
.df-pure-layout.df-pure-custom-dashboard .df-custom-dashboard-page.is-presentation {
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
}

.df-pure-layout.df-pure-custom-dashboard .df-custom-dashboard-stage,
.df-custom-dashboard-page.is-presentation .df-custom-dashboard-stage {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
}

.df-pure-layout.df-pure-custom-dashboard .df-custom-dashboard-grid,
.df-custom-dashboard-page.is-presentation .df-custom-dashboard-grid {
    min-height: 0 !important;
    padding: 0;
}

.df-pure-layout.df-pure-custom-dashboard .df-custom-dashboard-grid.is-viewport-fit {
    min-height: calc(100dvh - var(--df-pure-fit-pad, 8px) - var(--df-pure-fit-pad, 8px));
}

.df-pure-layout.df-pure-custom-dashboard .df-custom-widget {
    box-shadow: 0 10px 24px rgba(2, 8, 23, .2);
}

@media (max-width: 1100px) {
    .df-custom-dashboard-toolbar,
    .df-custom-dashboard-toolbar-main {
        align-items: stretch;
        flex-direction: column;
    }

    .df-custom-dashboard-actions {
        justify-content: flex-start;
    }

    .df-custom-dashboard-selector,
    .df-custom-dashboard-name-input,
    .df-custom-dashboard-description-input,
    .df-custom-dashboard-widget-picker {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 760px) {
    .df-custom-dashboard-stage {
        min-height: 520px;
    }

    .df-custom-dashboard-actions .rz-button {
        flex: 1 1 auto;
    }
}
