Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

50.6 KB
Raw Blame
// ============================================================
// DASHBOARD WIDGET GRID
// ============================================================
// Everything the configurable dashboard needs: the board bar, the placement
// grid, one widget's chrome, the 13 core widget bodies, the "add a widget"
// drawer, the right-hand inspector, fullscreen + TV mode, and the empty-board
// template picker.
//
// Namespaced `skw-` (ServerKit Widget) so NOTHING here can reach a page that
// did not opt in. That matters more than usual for this file: widget bodies
// render arbitrary app content (tables, logs, lists) whose generic names
// (.table/.list/.alert/.status) already exist elsewhere in the app.
//
// Ported from the design mock (`w-*` / `dash-*` / `wl-*` / `ins-*`), not
// copied: the mock is dark-only and hardcodes surface hexes, so every colour
// here comes from a var() token in _theme-variables.scss and reads correctly
// in both themes. Substitutions made while porting are called out inline.
//
// State classes are published in BOTH forms — the BEM modifier
// (`.skw-frame--selected`) and the repo's `is-` convention
// (`.skw-frame.is-selected`) — because the frame is driven by JSX written
// against the mock's vocabulary. Pick one at the call site; both resolve here.
// ============================================================

// Row height / gap mirror grid/layout.js (GRID_ROW 88, GRID_GAP 12). They are
// duplicated rather than imported because the JS owns the placement maths and
// SCSS only needs them for the responsive stack-down below.
$skw-grid-gap: 12px;
$skw-stack-row-h: 260px;

// Inspector panel width + the gutter the page reserves for it while open.

// The overlay layers sit deliberately ABOVE the app's $z-* scale (which tops
// out at $z-tooltip: 60): a fullscreen widget must cover the page chrome, and
// TV mode must cover everything including toasts.
$skw-z-inspector: 90;
$skw-z-fullscreen: 101;
$skw-z-tv: 200;

// ------------------------------------------------------------
// Dashboard bar — board tabs on the left, board-wide controls on the right.
// ------------------------------------------------------------
.skw-bar {
    display: flex;
    align-items: center;
    gap: $space-4;
    flex-wrap: wrap;
    margin-bottom: $space-4;

    // Range / refresh / variable pickers + edit toggle. `margin-left:auto`
    // rather than a spacer element so the tabs keep their natural width.
    &__ctl {
        display: flex;
        align-items: center;
        gap: $space-2;
        margin-left: auto;
        flex-wrap: wrap;

        // Every control in this row is exactly 32px tall and vertically
        // centred. Without this they came from four different places — a
        // segmented control, a native select, icon buttons and .btn — each with
        // its own padding, and the row read as a ragged line of mismatched
        // pills. Height is asserted here rather than trusted from each source.
        > *,
        .sk-seg,
        .skw-varpick,
        .skw-iconbtn,
        .skw-barbtn {
            height: $control-md;
            flex-shrink: 0;
        }

        .sk-seg {
            display: flex;
            align-items: center;
            box-sizing: border-box;
        }

        // The segmented control's own buttons must fill it, or the fill sits
        // proud of the track.
        .sk-seg__btn {
            display: flex;
            align-items: center;
        }
    }
}

// Text button in the board bar. Matches .skw-iconbtn's shell so Edit, Discard
// and Done sit on the same line as the pickers instead of floating as bare
// labels — the old `.btn.btn-sm` carried different padding and a different
// height, which is what made the row look unaligned.
.skw-barbtn {
    display: inline-flex;
    align-items: center;
    gap: $space-2;
    padding: 0 $space-3;
    border: 1px solid var(--border);
    border-radius: $radius-card;
    background: var(--surface-2);
    color: var(--text-dim);
    font-family: inherit;
    font-size: $text-sm;
    font-weight: $font-weight-medium;
    white-space: nowrap;
    cursor: pointer;
    transition: 0.13s;

    svg { flex-shrink: 0; }

    &:hover {
        color: var(--text);
        border-color: var(--border-strong);
        background: var(--surface-3);
    }

    // The one committing action in the row.
    &--primary {
        border-color: var(--accent);
        background: var(--accent);
        color: #fff;

        &:hover {
            border-color: var(--accent-bright);
            background: var(--accent-bright);
            color: #fff;
        }
    }
}

.skw-tabs {
    display: flex;
    align-items: center;
    gap: $space-1;
    flex-wrap: wrap;
}

.skw-tab {
    display: flex;
    align-items: center;
    gap: $space-2;
    height: $control-md;
    padding: 0 $space-3;
    border: 1px solid transparent;
    border-radius: $radius-control;
    background: none;
    color: var(--text-faint);
    font-family: inherit;
    font-size: $text-sm;
    cursor: pointer;
    transition: 0.13s;

    &:hover {
        color: var(--text);
        background: var(--surface-2);
    }

    // Active board. Set apart by fill + border, never by weight, so switching
    // boards cannot re-flow the row (same rule as .sk-topbar__tab).
    &--on,
    &.is-on,
    &.is-active {
        color: var(--text);
        background: var(--surface-2);
        border-color: var(--border-strong);

        svg { color: var(--accent-bright); }
    }

    // Widget count on the tab.
    &__count {
        padding: 1px $space-tight;
        border-radius: $radius-control;
        background: var(--surface-3);
        color: var(--text-ghost);
        font-size: $text-xs;
    }

    // "+" new-board affordance — icon only, so it drops the label padding.
    &--add {
        padding: $space-2;
        color: var(--text-faint);
    }
}

// Inline board rename. Accent border rather than a focus ring: the input
// replaces the tab in place and has to read as "editing" without growing.
.skw-rename {
    width: 130px;
    padding: $space-hair $space-tight;
    border: 1px solid var(--accent);
    border-radius: $radius-control;
    background: var(--surface-3);
    color: var(--text);
    font-family: var(--sans);
    font-size: $text-sm;
    outline: none;
}

// Variable picker ($server / $env) — a labelled value, not a select.
.skw-varpick {
    display: flex;
    align-items: center;
    gap: $space-2;
    height: $control-md;
    padding: 0 $space-3;
    border: 1px solid var(--border);
    border-radius: $radius-control;
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-size: $text-sm;
    cursor: pointer;
    transition: 0.13s;

    &:hover,
    &--open,
    &.is-open {
        border-color: var(--accent-dim);
        background: var(--surface-3);
    }

    // Static variant: one server, so there is nothing to pick. Reads as a
    // label rather than a dead button.
    &--static {
        cursor: default;
        border-style: dashed;

        &:hover {
            border-color: var(--border);
            background: var(--surface-2);
        }
    }

    &__k {
        color: var(--text-ghost);
        font-size: $text-xs;
    }
    &__v {
        font-family: var(--mono);
        font-size: $text-xs;
    }
}

// Square icon button used across the bar and the widget head.
.skw-iconbtn {
    width: $control-md;
    height: $control-md;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: $radius-control;
    background: var(--surface-2);
    color: var(--text-faint);
    cursor: pointer;
    transition: 0.13s;

    &:hover {
        color: var(--text);
        border-color: var(--border-strong);
        background: var(--surface-3);
    }

    // Head actions are smaller and borderless — they live inside a 30px row.
    &--bare {
        width: 24px;
        height: 24px; // geometry: widget head is sized by the dashboard grid (GRID_ROW 88); 28 would eat 1-row widget bodies
        border-color: transparent;
        background: none;

        &:hover { background: var(--surface-2); }
    }
}

// Edit-mode banner ("drag to move, drag the corner to resize").
.skw-hint {
    display: flex;
    align-items: center;
    gap: $space-2;
    margin-bottom: $space-3;
    padding: $space-2 $space-3;
    border: 1px solid var(--accent-dim);
    border-radius: $radius-card;
    @include status-variant(var(--accent-bright), var(--accent-bg));
    font-size: $text-xs;

    // Same shape, but for a board that failed to save or load.
    &--error {
        border-color: var(--red);
        @include status-variant(var(--red), var(--red-bg));
    }
}

// ------------------------------------------------------------
// Grid host + ghost overlay
// ------------------------------------------------------------
.skw-grid {
    position: relative;
    width: 100%;

    // Placed widgets are absolutely positioned by DashGrid from the cell
    // maths (inline left/top/width/height). Both shapes are supported — a
    // frame dropped straight into the host, or wrapped in an __item
    // positioner — so the grid does not dictate the JSX's element count.
    > .skw-frame,
    &__item {
        position: absolute;
        // Animate settling into a new cell, but only when the pointer is up;
        // during a drag the inline coords must track the cursor exactly.
        transition: left 0.16s ease, top 0.16s ease, width 0.16s ease, height 0.16s ease;
    }

    &--dragging,
    &.is-dragging {
        cursor: grabbing;

        > .skw-frame,
        .skw-grid__item { transition: none; }
    }

    // Column/row guides, shown only while editing. Drawn as two 1px gradients
    // rather than a repeating element so the overlay costs no DOM and no
    // hit-testing. `--accent-bg` replaces the mock's rgba(109,124,255,.09):
    // it is the same periwinkle wash, follows a runtime accent override, and
    // it exists in the light theme.
    &__ghost {
        position: absolute;
        inset: 0;
        pointer-events: none;
        border-radius: $radius-card;
        background-image:
            linear-gradient(to right, var(--accent-bg) 1px, transparent 1px),
            linear-gradient(to bottom, var(--accent-bg) 1px, transparent 1px);
    }

    // Drop placeholder / "this board has no widgets yet" panel that fills the
    // host itself (distinct from .skw-empty, which lives inside one widget).
    &__empty {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: $space-3;
        border: 1.5px dashed var(--border-strong);
        border-radius: var(--radius);
        color: var(--text-faint);
        font-size: $text-sm;
    }
}

// Page/host modifier: reserve the gutter the open inspector occupies so the
// panel never covers the widget being configured.

// ------------------------------------------------------------
// Widget frame — the chrome every widget type shares.
// ------------------------------------------------------------
.skw-frame {
    // `relative` so __resize anchors to the frame even outside the grid
    // (fullscreen, TV mode). Inside .skw-grid this is overridden to absolute.
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;

    // Edit mode: the frame reads as movable, and the head becomes the handle.
    &--edit,
    &.is-edit,
    &.is-editing {
        border-color: var(--border-strong);

        .skw-frame__head { cursor: grab; }
    }

    // The widget the inspector is currently bound to.
    &--selected,
    &.is-selected,
    &.is-sel {
        border-color: var(--accent-bright);
        box-shadow: $focus-ring;
    }

    &__head {
        display: flex;
        align-items: center;
        gap: $space-2;
        flex-shrink: 0;
        padding: $space-2 $space-3 $space-2;
        border-bottom: 1px solid var(--border-soft);
    }

    // Drag grip. Rotated because lucide's GripVertical reads as horizontal
    // rails at this size; the quarter turn makes it a grab target.
    &__grip {
        display: grid;
        place-items: center;
        color: var(--text-ghost);
        transform: rotate(90deg);
    }

    &__title {
        flex: 1;
        min-width: 0;
        font-size: $text-sm;
        font-weight: $font-weight-semibold;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    // "Tailing" indicator on the logs widget head. Sits between the title and
    // the actions, and unlike them it stays visible at rest: whether a stream
    // is still live is state, not an affordance, so hover must not gate it.
    // Shares skw-tick-pulse with the deploy step ribbon, run slower.
    &__live {
        width: 6px;
        height: 6px;
        flex-shrink: 0;
        border-radius: 50%;
        background: var(--green);
        box-shadow: none;
        animation: skw-tick-pulse 1.6s ease-in-out infinite;

        // A paused / disconnected stream keeps the dot but drops the pulse,
        // so "stopped" is never mistaken for "quiet".
        &--off {
            background: var(--text-ghost);
            box-shadow: none;
            animation: none;
        }
    }

    // Head actions stay hidden until the widget is hovered or selected — a
    // board of 12 widgets otherwise shows 36 buttons at rest.
    &__actions {
        display: flex;
        align-items: center;
        gap: 1px;
        flex-shrink: 0;
        opacity: 0;
        transition: opacity 0.13s;
    }

    &:hover &__actions,
    &--selected &__actions,
    &.is-selected &__actions { opacity: 1; }

    // Anchor for the overflow menu. The frame itself clips (overflow:hidden,
    // for the rounded corners), so the menu cannot anchor to it — it anchors
    // to this wrapper around the trigger button instead.
    &__menu-wrap {
        position: relative;
        display: inline-flex;
        flex-shrink: 0;
    }

    // Every renderer fills this box; it never scrolls itself, the body's own
    // scroll region does.
    &__body {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    // A menu anchored inside the head would be sliced off by the frame's own
    // corner clip, so the clip is lifted for exactly as long as a menu is
    // mounted. Safe to do: __body clips itself, and neither head nor body
    // paints a background that could spill past the radius.
    &:has(.skw-menu),
    &--menu-open,
    &.is-menu-open { overflow: visible; }

    // Corner resize grip — two diagonal rules drawn with a gradient so the
    // handle needs no extra markup and no icon payload.
    &__resize {
        position: absolute;
        right: 2px;
        bottom: 2px;
        width: 16px;
        height: 16px;
        cursor: nwse-resize;
        background: linear-gradient(
            135deg,
            transparent 46%,
            var(--border-strong) 46%,
            var(--border-strong) 56%,
            transparent 56%,
            transparent 70%,
            var(--border-strong) 70%,
            var(--border-strong) 80%,
            transparent 80%
        );
    }
}

// Widget overflow menu (configure / duplicate / fullscreen / remove).
// A plain absolutely-positioned popover rather than a Radix dropdown: it is
// anchored by .skw-frame__menu-wrap around its own trigger, so it needs no
// portal and stays inside the frame it belongs to. Surface treatment matches
// .ui-dropdown-content so the app has one menu look.
.skw-menu {
    position: absolute;
    top: calc(100% + 5px);
    // Right-anchored — the trigger is the last control in the head, and a
    // 196px menu opening leftward would hang off a 3-column widget.
    right: 0;
    z-index: $z-tooltip;
    width: 196px;
    padding: $space-1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: $shadow-raised;

    &__item {
        display: flex;
        align-items: center;
        gap: $space-3;
        width: 100%;
        padding: $space-2 $space-3;
        border: none;
        border-radius: $radius-control;
        background: none;
        color: var(--text-dim);
        font-family: inherit;
        font-size: $text-sm;
        text-align: left;
        cursor: pointer;
        transition: 0.12s;

        &:hover {
            background: var(--surface-3);
            color: var(--text);
        }

        &[disabled] { opacity: 0.45; pointer-events: none; }

        &--danger {
            color: var(--red);
            &:hover { @include status-variant(var(--red), var(--red-bg)); }
        }
    }

    // Leading icon slot. Fixed box so the labels line up whether or not a
    // given row has an icon.
    &__ic {
        display: grid;
        place-items: center;
        width: 16px;
        height: 16px;
        flex-shrink: 0;
        color: var(--text-faint);
    }

    &__item:hover &__ic { color: var(--text-dim); }
    &__item--danger:hover &__ic { color: var(--red); }

    // Negative margins pull the rule to the panel edges, past the 4px pad.
    &__sep {
        height: 1px;
        margin: $space-1 -4px;
        background: var(--border-soft);
    }
}

// Unknown widget type / no data. Deliberately plain: an unrecognised type is
// a config problem, not an error, and the frame around it already names it.
.skw-empty {
    padding: $space-4;
    color: var(--text-faint);
    font-size: $text-sm;

    // In-flight, not a message. Quieter than the resting note and pulsing on
    // the shared tick, so a frame that is still fetching cannot be misread as
    // one that came back with nothing.
    &--loading {
        color: var(--text-ghost);
        animation: skw-tick-pulse 1.4s ease-in-out infinite;
    }

    // A failure stays a coloured line rather than a red panel: one widget on a
    // board of twelve failing is not a page-level error, and the frame around
    // it already names which widget it is.
    &--error { color: var(--red); }
}

// ============================================================
// WIDGET INTERNALS — one block per core type.
// ============================================================

// ---- stat: big number + delta + bottom-bled sparkline -------
.skw-stat {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    // Top-aligned, NOT centred. Once the spark row became flexible it competed
    // with the value for height, and centring pushed the number up out of the
    // tile — the reading is the point of this widget, so it is pinned first and
    // the chart gets whatever is left.
    justify-content: flex-start;
    padding: $space-3 $space-3;

    &__value {
        flex: 0 0 auto;
        color: var(--text);
        font-size: $text-2xl;
        font-weight: $font-weight-semibold;
        line-height: 1.1;
        letter-spacing: -0.01em;
        // Even digit columns, and an ellipsis instead of a burst tile when a
        // metric returns something unexpectedly long.
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    &__meta {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: $space-2;
        margin-top: $space-tight;
        color: var(--text-faint);
        font-size: $text-xs;
    }

    &__delta {
        display: inline-flex;
        align-items: center;
        gap: $space-hair;

        &--up,
        .up { color: var(--green); }
        &--down,
        .dn { color: var(--red); }
    }

    // Negative side margins cancel the padding so the series bleeds to the
    // frame edge rather than floating in a box (same trick as .sk-kpi__spark).
    &__spark {
        // Takes the tile's leftover height rather than a fixed sliver, so a
        // taller stat widget grows its trend line instead of banking dead
        // space under the value. `min-height: 0` lets it shrink in a 2-row
        // tile without pushing the meta row out.
        margin-top: $space-2;
        margin-left: -2px;
        margin-right: -2px;
        line-height: 0;
        // Grows into leftover height but never demands any: a hard min-height
        // here is what previously overflowed the tile and clipped the value.
        flex: 1 1 0;
        min-height: 0;
        display: flex;
        overflow: hidden;

        > svg { flex: 1; min-height: 0; }
    }
}

// ---- timeseries: area chart + legend ------------------------
.skw-ts {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: $space-2 $space-3 $space-tight;

    &__chart {
        flex: 1;
        min-height: 0;
        display: flex;

        // The chart component ships a fixed height attribute; the widget's
        // cell span decides the real one, so the flex box wins.
        svg {
            flex: 1;
            height: 100% !important;
        }
    }
}

.skw-legend {
    display: flex;
    flex-wrap: wrap;
    gap: $space-3;
    padding-top: $space-2;
    color: var(--text-faint);
    font-size: $text-xs;

    &__item {
        display: flex;
        align-items: center;
        gap: $space-tight;

        b { color: var(--text); font-weight: $font-weight-semibold; }
    }

    // Series swatch — colour comes inline from the metric catalog.
    &__swatch,
    .sw {
        width: 8px;
        height: 8px;
        border-radius: $radius-badge;
        flex-shrink: 0;
    }
}

// ---- gauge: half-circle radial ------------------------------
.skw-gauge {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: $space-tight;
    padding: $space-3;

    &__sub {
        color: var(--text-faint);
        font-size: $text-xs;
    }

    &__svg {
        width: 100%;
        max-width: 200px;

        text {
            font: $font-weight-semibold $text-xl var(--sans);
        }
    }
}

// ---- topn: ranked bars --------------------------------------
.skw-topn {
    display: flex;
    flex-direction: column;
    gap: $space-2;
    padding: $space-3 $space-3;
    overflow: auto;
    @include custom-scrollbar;

    // label | track | value. The 1fr/2fr split keeps the bar the dominant
    // element while long names still truncate instead of squeezing it.
    &__row {
        display: grid;
        grid-template-columns: 1fr 2fr auto;
        align-items: center;
        gap: $space-2;
    }

    &__label {
        font-size: $text-xs;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    &__track {
        height: 7px;
        border-radius: $radius-badge;
        background: var(--surface-3);
        overflow: hidden;
    }

    // Fill width + colour are the only inline values here.
    &__fill,
    &__track i {
        display: block;
        height: 100%;
        border-radius: $radius-badge;
        transition: width 0.4s ease;
    }

    &__value {
        color: var(--text-dim);
        font-size: $text-xs;
    }
}

// ---- table: apps / servers / containers / deploys -----------
// The one list table that is not a DataTable (listed in check-tables.mjs
// OWNERS): a widget can be three rows tall, so it keeps compact rows instead
// of the 40px DataTable minimum, and its header sticks inside the widget body.
// Everything else follows the .sk-dtable spec — 32px unfilled header (the
// frame's own surface, so scrolled rows slide under it), faint labels,
// horizontal separators only, $space-4 outer edges.
.skw-table-wrap {
    flex: 1;
    overflow: auto;
    @include custom-scrollbar;
}

.skw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: $text-xs;

    th {
        position: sticky;
        top: 0;
        z-index: 1;
        height: $control-md;
        padding: 0 $space-3;
        border-bottom: 1px solid var(--border);
        background: var(--surface);
        color: var(--text-faint);
        font-size: $text-xs;
        font-weight: $font-weight-medium;
        text-align: left;
        white-space: nowrap;
    }

    td {
        max-width: 180px;
        padding: $space-2 $space-3;
        border-bottom: 1px solid var(--border-soft);
        color: var(--text-dim);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        &.nm { color: var(--text); font-weight: $font-weight-medium; }
        &.mono { font-family: var(--mono); font-size: $text-xs; }
    }

    th:first-child,
    td:first-child { padding-inline-start: $space-4; }

    th:last-child,
    td:last-child { padding-inline-end: $space-4; }

    tbody tr {
        cursor: pointer;
        transition: background 0.12s;

        &:hover { background: var(--surface-2); }
        &:last-child td { border-bottom: none; }
    }
}

// Mono status chip used by the table and list widgets. Kept local rather than
// @extend-ing %sk-state: this one is lowercase and sized for a 12px row.
.skw-pill {
    padding: $space-hair $space-2;
    border-radius: $radius-control;
    background: var(--surface-3);
    color: var(--text-faint);
    font-size: $text-xs;

    &--ok,
    &.ok { color: var(--green); background: var(--green-bg); }
    &--bad,
    &.bad { color: var(--red); background: var(--red-bg); }
    &--warn,
    &.warn { color: var(--amber); background: var(--amber-bg); }
}

// ---- logs: tailing lines ------------------------------------
.skw-logs {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;

    &__bar {
        display: flex;
        align-items: center;
        gap: $space-3;
        flex-shrink: 0;
        padding: $space-tight $space-3;
        border-bottom: 1px solid var(--border-soft);
        color: var(--text-faint);
        font-size: $text-xs;

        .lv-err { color: var(--red); }
        .lv-warn { color: var(--amber); }
    }

    // `--bg-code` replaces the mock's hardcoded #0a0c11. It is the app's
    // terminal/code surface token and is defined in both themes, so the log
    // pane stays an inset "console" without being a black slab on light.
    &__body {
        flex: 1;
        overflow: auto;
        padding: $space-tight 0;
        background: var(--bg-code);
        font-family: var(--mono);
        font-size: $text-xs;
        line-height: 1.65;
        @include custom-scrollbar;
    }

    &__line {
        display: flex;
        gap: $space-2;
        padding: 0 $space-3;
        color: var(--text-dim);
        white-space: pre-wrap;
        word-break: break-all;

        // Timestamp gutter.
        .t {
            flex-shrink: 0;
            color: var(--text-ghost);
        }

        &.lv-dim { color: var(--text-faint); }
        &.lv-warn { color: var(--amber); }
        &.lv-err {
            color: var(--red);
            // Compile-time rgba of the raw hex: the semantic reds are
            // theme-independent, and --red-bg (0.12) is too loud behind a
            // whole line of text.
            background: rgba($danger-raw, 0.06);
        }
    }
}

// ---- shared scroll list (deploys / alerts / feed) -----------
.skw-list {
    flex: 1;
    overflow: auto;
    padding: $space-tight 0;
    @include custom-scrollbar;
}

// ---- deploys: recent deployment jobs ------------------------
.skw-dep {
    padding: $space-2 $space-3;
    border-bottom: 1px solid var(--border-soft);
    cursor: pointer;
    transition: background 0.12s;

    &:hover { background: var(--surface-2); }

    &__top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: $space-3;
    }

    &__name { font-size: $text-sm; font-weight: $font-weight-semibold; }
    &__state { font-size: $text-xs; }

    // Step ribbon: one segment per pipeline stage, so progress reads at a
    // glance without a percentage.
    &__steps {
        display: flex;
        gap: $space-1;
        margin: $space-2 0 $space-tight;

        .st {
            flex: 1;
            height: 4px;
            border-radius: $radius-badge;
            background: var(--surface-3);

            &.done { background: var(--green); }
            &.failed { background: var(--red); }
            &.running {
                background: var(--amber);
                animation: skw-tick-pulse 1.2s ease-in-out infinite;
            }
        }
    }

    &__meta {
        color: var(--text-ghost);
        font-size: $text-xs;
    }
}

// ---- alerts: open monitoring alerts -------------------------
.skw-alert {
    display: flex;
    align-items: center;
    gap: $space-3;
    padding: $space-3 $space-3;
    border-bottom: 1px solid var(--border-soft);
    cursor: pointer;
    transition: background 0.12s;

    &:hover { background: var(--surface-2); }

    // Severity dot — colour set inline from the alert's severity.
    &__sev {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    // Middle column between the severity dot and the state pill. `min-width:0`
    // is what actually lets __title ellipsise — without it the flex item takes
    // its content's width and pushes the pill out of the row.
    &__body {
        flex: 1;
        min-width: 0;
    }

    &__title {
        font-size: $text-sm;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    &__meta {
        margin-top: $space-hair;
        color: var(--text-faint);
        font-size: $text-xs;
    }
}

// ---- status: monitor up/down matrix -------------------------
.skw-status {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    align-content: start;
    gap: $space-2;
    padding: $space-3 $space-3;
    overflow: auto;
    @include custom-scrollbar;

    &__cell {
        padding: $space-2 $space-3;
        border: 1px solid var(--border-soft);
        border-radius: $radius-card;
        background: var(--surface-2);
        cursor: pointer;
        transition: 0.12s;

        &:hover { border-color: var(--border-strong); }
    }

    &__dot {
        display: block;
        width: 7px;
        height: 7px;
        margin-bottom: $space-tight;
        border-radius: 50%;
    }

    &__name {
        font-size: $text-xs;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    &__meta {
        margin-top: $space-hair;
        color: var(--text-faint);
        font-size: $text-xs;
    }
}

// ---- feed: audit / activity trail ---------------------------
// An audit row is one sentence with a timestamp under it, so the block gives
// the column the two things the text cannot: a marker rail to scan down, and a
// rule between rows. Shares .skw-list's scroll, like deploys and alerts.
.skw-feed {
    &__item {
        display: flex;
        align-items: flex-start;
        gap: $space-2;
        padding: $space-2 $space-3;
        border-bottom: 1px solid var(--border-soft);
        cursor: pointer;
        transition: background 0.12s;

        &:hover { background: var(--surface-2); }
    }

    // Marker rather than a per-action icon: the feed carries arbitrary audit
    // actions and inventing a glyph per action would be guessing. Nudged down
    // so it sits on the first text line, not above it.
    &__dot {
        width: 6px;
        height: 6px;
        margin-top: $space-tight;
        flex-shrink: 0;
        border-radius: 50%;
        background: var(--text-ghost);
        transition: background 0.12s;
    }

    &__item:hover &__dot { background: var(--accent-bright); }

    &__body { flex: 1; min-width: 0; }

    // Wraps rather than truncates — unlike a name in a table this IS the row's
    // content, and a clipped audit line is worthless. `anywhere` so a long
    // target id breaks instead of widening the widget.
    &__text {
        color: var(--text-dim);
        font-size: $text-xs;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

    &__time {
        margin-top: $space-hair;
        color: var(--text-ghost);
        font-size: $text-xs;
    }
}

// ---- actions: shortcut buttons ------------------------------
.skw-actions {
    display: flex;
    flex-direction: column;
    gap: $space-2;
    padding: $space-3 $space-3;
    overflow: auto;
    @include custom-scrollbar;

    // Full-width rows, not a tile grid: the labels are route names of very
    // uneven length ("Jobs" next to "Docker containers"), which a grid of
    // fixed cells renders as ragged whitespace.
    &__row {
        display: flex;
        align-items: center;
        gap: $space-3;
        width: 100%;
        min-height: $control-md;
        padding: 0 $space-3;
        border: 1px solid var(--border);
        border-radius: $radius-control;
        background: var(--surface-2);
        color: var(--text-dim);
        font-family: inherit;
        font-size: $text-sm;
        text-align: left;
        cursor: pointer;
        transition: 0.13s;

        &:hover {
            color: var(--text);
            border-color: var(--accent-dim);
            background: var(--surface-3);
        }
    }

    &__label {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    // Trailing chip. Fixed box so every row's glyph lands on the same column
    // however long its label is.
    &__icon {
        display: grid;
        place-items: center;
        width: 24px;
        height: 24px; // geometry: fixed glyph chip, not a control
        flex-shrink: 0;
        border-radius: $radius-control;
        background: var(--surface-3);
        color: var(--text-faint);
        transition: 0.13s;
    }

    &__row:hover &__icon {
        @include status-variant(var(--accent-bright), var(--accent-bg));
    }
}

// ---- specs: key/value host details --------------------------
.skw-kv {
    padding: $space-1 $space-3 $space-2;
    overflow: auto;
    @include custom-scrollbar;

    // Own rows…
    &__row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: $space-3;
        min-height: 0;
        padding: $space-tight 0;
        border-top: 1px solid var(--border-soft);

        &:first-child { border-top: none; }
    }
    &__k { color: var(--text-faint); font-size: $text-xs; }
    &__v { color: var(--text); font-size: $text-xs; text-align: right; overflow-wrap: anywhere; }

    // …and a density override when the renderer reuses the shared
    // .sk-info-row primitive instead, which is spaced for a drawer.
    .sk-info-row {
        padding: $space-tight 0;
        min-height: 0;

        .k { font-size: $text-xs; }
    }
}

// ---- note: markdown-ish text --------------------------------
.skw-note {
    padding: $space-3;
    overflow: auto;
    color: var(--text-dim);
    font-size: $text-sm;
    line-height: 1.6;
    @include custom-scrollbar;

    code {
        padding: 1px $space-tight;
        border-radius: $radius-badge;
        background: var(--surface-3);
        font-family: var(--mono);
        font-size: $text-xs;
    }
}

// ============================================================
// WIDGET LIBRARY — "add a widget" drawer, thumbnail-first.
// ============================================================
// A name and a description do not tell you what a widget looks like, so each
// card leads with a miniature SVG of the real thing.
.skw-lib {
    // The library owns its own padding rather than leaning on the drawer's:
    // .sk-drawer__body deliberately has none (it is the scroll region), and
    // the sticky filter bar below cancels this padding with negative margins
    // to span the panel edge to edge. Both numbers therefore live here.
    padding: $space-4 $space-4 $space-5;

    // Search + category chips. The library renders inside the shared
    // ds/Drawer, whose .sk-drawer__body owns the scroll — so this bar has to
    // stick to the top of THAT scroller or the search box leaves the screen
    // as soon as you scroll to the widget you were searching for. Sticky
    // demands an opaque background (it scrolls over the cards) and the
    // negative top/side margins let it span the drawer's padding edge to edge.
    &__filters {
        position: sticky;
        top: 0;
        z-index: 2;
        display: flex;
        flex-direction: column;
        gap: $space-3;
        margin: -14px -16px $space-4;
        padding: $space-4 $space-4 $space-3;
        background: var(--surface);
        border-bottom: 1px solid var(--border-soft);
    }

    // SearchField merges `className` onto its own root, so this selector IS
    // the .sk-searchfield element — NOT a wrapper around one. Styling it as a
    // parent (`&__search .sk-searchfield`) matched nothing, leaving the shared
    // `flex: 1 1 240px` in force; inside a column-direction filter bar that
    // 240px basis is a HEIGHT, and the box rendered 240px tall.
    &__search {
        flex: 0 0 auto;
        max-width: none;
        min-width: 0;
    }

    &__chips {
        display: flex;
        flex-wrap: wrap;
        gap: $space-tight;
    }

    &__chip {
        padding: $space-1 $space-3;
        border: 1px solid var(--border);
        border-radius: $radius-full;
        background: var(--surface-2);
        color: var(--text-dim);
        font-family: inherit;
        font-size: $text-xs;
        white-space: nowrap;
        cursor: pointer;
        transition: 0.13s;

        &:hover {
            color: var(--text);
            border-color: var(--border-strong);
        }

        &--on,
        &.is-on {
            @include status-variant(var(--accent-bright), var(--accent-bg));
            border-color: var(--accent-dim);
            font-weight: $font-weight-semibold;
        }
    }

    // "No widget matches that search."
    &__empty {
        padding: $space-10 $space-4;
        color: var(--text-faint);
        font-size: $text-sm;
        text-align: center;
    }

    &__grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
        gap: $space-3;
    }

    &__card {
        position: relative;
        display: flex;
        flex-direction: column;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface-2);
        cursor: pointer;
        overflow: hidden;
        transition: 0.14s;

        &:hover {
            border-color: var(--accent-dim);
            background: var(--surface-3);
            transform: translateY(-1px);
        }
    }

    // `--bg-sidebar` replaces the mock's #0d0f14: it is within a hair of that
    // value in dark, and in light it is one step darker than the card, so the
    // preview still reads as an inset well instead of a black rectangle.
    &__thumb {
        position: relative;
        height: 88px;
        display: flex;
        align-items: stretch;
        padding: $space-tight;
        border-bottom: 1px solid var(--border-soft);
        background: var(--bg-sidebar);
    }

    &__thumb-svg {
        display: block;
        width: 100%;
        height: 100%;
    }

    // Hover scrim over the thumbnail. Built from --surface at full opacity and
    // faded in as a whole, rather than the mock's rgba(13,15,20,.74) + #fff
    // text — that pairing is a black slab with white text on a light board.
    &__add {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: $space-tight;
        background: var(--surface);
        color: var(--accent-bright);
        font-size: $text-xs;
        font-weight: $font-weight-semibold;
        opacity: 0;
        transition: opacity 0.14s;
    }

    &__card:hover &__add { opacity: 0.94; }

    &__meta { padding: 10px 11px 12px; }

    &__icon {
        display: inline-grid;
        place-items: center;
        flex-shrink: 0;
        color: var(--accent-bright);
    }

    &__name {
        display: flex;
        align-items: center;
        gap: $space-2;
        font-size: $text-sm;
        font-weight: $font-weight-semibold;
    }

    // Default cell span ("3×2"), pushed to the right edge of the name row.
    &__size {
        margin-left: auto;
        padding: 1px $space-tight;
        border-radius: $radius-badge;
        background: var(--surface-3);
        color: var(--text-ghost);
        font-size: $text-xs;
    }

    &__desc {
        margin-top: $space-tight;
        color: var(--text-faint);
        font-size: $text-xs;
        line-height: 1.45;
    }
}

// Numeric stepper (widget span, top-N count, refresh seconds).

// ============================================================
// FULLSCREEN WIDGET + TV MODE
// ============================================================
// One widget, blown up, still driven by the same renderer — so "expand" costs
// no second implementation.
.skw-full {
    position: fixed;
    top: 5vh;
    left: 50%;
    z-index: $skw-z-fullscreen;
    width: min(1280px, 92vw);
    height: min(760px, 86vh);
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: $shadow-overlay;
    overflow: hidden;
    animation: skw-modal-in 0.18s cubic-bezier(0.2, 0.7, 0.3, 1);

    // Backdrop behind the expanded widget. Same treatment as .modal-overlay /
    // .ui-dialog-overlay so a fullscreened widget dims the page exactly like
    // every other modal surface — a neutral scrim, not a themed one, because
    // it must read as "the board is still there, just behind this".
    // Sits one layer under .skw-full and above everything the board draws.
    &__scrim {
        position: fixed;
        inset: 0;
        z-index: $skw-z-fullscreen - 1;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        animation: skw-scrim-in 0.18s ease;
    }

    // The frame inside gets a roomier head and always-visible actions: there
    // is no hover-to-reveal affordance when the widget IS the page.
    .skw-frame {
        position: static;
        flex: 1;
        min-height: 0;
        border: none;
        border-radius: 0;
        background: none;
    }
    .skw-frame__head { padding: 13px 16px; }
    .skw-frame__actions { opacity: 1; }
    .skw-frame__resize { display: none; }
}

// TV mode: the board on a wall display. `--bg-body` replaces the mock's
// var(--bg,#0a0c11) — same intent (the app's page background), real token.
.skw-tv {
    position: fixed;
    inset: 0;
    z-index: $skw-z-tv;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-body);

    &__bar {
        display: flex;
        align-items: center;
        gap: $space-4;
        flex-shrink: 0;
        padding: $space-3 $space-5;
        border-bottom: 1px solid var(--border-soft);
    }

    &__body {
        flex: 1;
        overflow: auto;
        padding: $space-5 $space-5;
        @include custom-scrollbar;
    }

    // Wall-display bar: board name, live dot, what the board is scoped to, and
    // the time. Larger than the normal chrome because this is read at distance.
    &__name {
        font-size: $text-base;
        font-weight: $font-weight-semibold;
        color: var(--text);
    }

    &__meta {
        color: var(--text-faint);
        font-size: $text-xs;
    }

    &__clock {
        margin-left: auto;
        font-size: $text-md;
        font-weight: $font-weight-semibold;
        color: var(--text);
        font-variant-numeric: tabular-nums;
    }
}

// ============================================================
// EMPTY BOARD — template picker
// ============================================================
// A blank 12-column grid is not a starting point, so a new board offers
// ready-made layouts before it offers an "add widget" button.
.skw-empty-board {
    padding: $space-16 $space-5;
    border: 1.5px dashed var(--border-strong);
    border-radius: $radius-card;
    text-align: center;

    &__title { margin: 0 0 6px; color: var(--text); font-size: $text-base; font-weight: $font-weight-semibold; }
    &__desc { margin: 0 auto 24px; max-width: 460px; color: var(--text-dim); font-size: $text-sm; }

    &__acts {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: $space-2;
        margin-top: $space-5;
    }
}

.skw-tpl {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: $space-3;
    max-width: 900px;
    margin: 0 auto;
    text-align: left;

    &__card {
        padding: $space-4;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface-2);
        cursor: pointer;
        transition: 0.14s;

        &:hover {
            border-color: var(--accent-dim);
            background: var(--surface-3);
            transform: translateY(-1px);
        }
    }

    &__icon {
        width: 34px;
        height: 34px; // geometry: icon tile
        margin-bottom: $space-3;
        display: grid;
        place-items: center;
        border-radius: $radius-card;
        background: var(--surface-3);
        color: var(--accent-bright);
    }

    &__name { font-size: $text-sm; font-weight: $font-weight-semibold; }
    &__desc { margin-top: 4px; color: var(--text-faint); font-size: $text-xs; line-height: 1.5; }
}

// ============================================================
// ANIMATIONS  (prefixed — the mock's insIn/modalIn/tickPulse are global)
// ============================================================

@keyframes skw-modal-in {
    from { transform: translateX(-50%) translateY(10px); opacity: 0; }
    to { transform: translateX(-50%); opacity: 1; }
}

@keyframes skw-tick-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes skw-scrim-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@include respond-to($breakpoint-lg) {
    // Board controls wrap under the tabs rather than fighting them for width.
    .skw-bar__ctl {
        margin-left: 0;
        width: 100%;
    }

    .skw-lib__grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
}

@include respond-to($breakpoint-md) {
    // Below tablet the 12-column cell maths produces columns too narrow to
    // read anything in, so absolute placement is dropped and widgets stack in
    // document order at a fixed height. DashGrid writes left/top/width/height
    // as inline styles, so these overrides need !important — the collapse
    // point lives here, in CSS, rather than being duplicated in JS.
    .skw-grid {
        height: auto !important;
        min-height: 0 !important;
        display: flex;
        flex-direction: column;
        gap: $skw-grid-gap;

        &__ghost { display: none; }

        > .skw-frame,
        &__item {
            position: relative !important;
            left: auto !important;
            top: auto !important;
            width: 100% !important;
            height: $skw-stack-row-h !important;
            transition: none;
        }
    }

    // Dragging and resizing are pointer-precision gestures; neither survives
    // a stacked column, and both are meaningless once placement is implicit.
    .skw-frame__resize,
    .skw-frame__grip { display: none; }

    .skw-frame--edit .skw-frame__head,
    .skw-frame.is-edit .skw-frame__head { cursor: default; }

    .skw-full {
        top: 0;
        width: 100vw;
        height: 100vh;
        border: none;
        border-radius: 0;
    }

    .skw-empty-board { padding: 40px 16px; }
    .skw-tpl { grid-template-columns: 1fr; }
}

// ============================================================
// CLOCK — the wall time, as a widget.
// ============================================================
// The dashboard used to carry a fixed clock in its header. That header is gone
// (one control row now), so the time is opt-in: add it if you want it, put it
// on a second timezone if that's what you need.
.skw-clock {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: $space-hair;
    padding: $space-3 $space-3;
    text-align: center;

    &__time {
        color: var(--text);
        font-size: $text-2xl;
        font-weight: $font-weight-semibold;
        line-height: 1.05;
        font-variant-numeric: tabular-nums;
    }

    &__date {
        color: var(--text-dim);
        font-size: $text-sm;
    }

    &__zone {
        color: var(--text-ghost);
        font-size: $text-xs;
    }
}

// ============================================================
// CHART HOVER — crosshair, per-series dots, readout.
// ============================================================
// Overlay is HTML, not SVG: the chart is drawn with
// `preserveAspectRatio="none"`, which stretches the viewBox to the container
// and would turn every circle into an ellipse. Percentage-positioned elements
// sit on the same coordinates without inheriting the distortion.
.skw-chart {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;

    > svg { flex: 1; min-height: 0; }

    // Also used bare (outside .skw-chart) by the stat widget's sparkline,
    // where the svg fills the tile on its own.
    &__svg {
        display: block;
        width: 100%;
    }

    &__cross {
        position: absolute;
        top: 0;
        bottom: 0;
        width: 0;
        border-left: 1px dashed var(--border-strong);
        pointer-events: none;
    }

    &__dot {
        position: absolute;
        width: 7px;
        height: 7px;
        margin: -3.5px 0 0 -3.5px;
        border: 1.5px solid var(--surface);
        border-radius: 50%;
        pointer-events: none;
    }

    // Readout. Offset from the crosshair so the dots stay visible, and flipped
    // to the other side once it would run past the right edge.
    &__tip {
        position: absolute;
        top: 8px;
        z-index: 2;
        min-width: 132px;
        margin-left: $space-3;
        padding: $space-2 $space-3;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface-2);
        box-shadow: $shadow-raised;
        pointer-events: none;

        &--flip {
            margin-left: 0;
            transform: translateX(calc(-100% - 12px));
        }
    }

    &__tip-when {
        margin-bottom: $space-tight;
        color: var(--text-faint);
        font-size: $text-xs;
        text-align: center;
    }

    &__tip-row {
        display: flex;
        align-items: center;
        gap: $space-2;
        padding: $space-hair 0;
        font-size: $text-xs;
    }

    &__tip-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    &__tip-label {
        color: var(--text-dim);
        white-space: nowrap;
    }

    // Values right-aligned in their own column so a stack of them reads down.
    &__tip-value {
        margin-left: auto;
        font-weight: $font-weight-semibold;
        font-variant-numeric: tabular-nums;
    }
}