/* KVM Orchestrator Panel — Custom styles (Bootstrap 5 supplement) */

/* ── Sidebar ─────────────────────────────────────────────── */
#kvo-sidebar {
    width: 250px;
    min-height: 100vh;
    background: #0d1117;
    transition: width 0.2s ease, transform 0.25s ease;
    overflow-x: hidden;
    flex-shrink: 0;
}

#kvo-sidebar.collapsed {
    width: 60px;
}

#kvo-sidebar.collapsed .nav-link span,
#kvo-sidebar.collapsed .fs-5,
#kvo-sidebar.collapsed .dropdown > a > span {
    display: none;
}

#kvo-sidebar.collapsed .nav-link {
    padding-left: 0.75rem;
    justify-content: center;
}

#kvo-sidebar .nav-link {
    border-radius: 8px;
    font-size: 0.85rem;
    position: relative;
    transition: background 0.15s, padding-left 0.15s;
}

#kvo-sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.07);
}

#kvo-sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(13, 110, 253, 0.28), rgba(13, 110, 253, 0.1));
    color: #8bb9fe !important;
    font-weight: 600;
}

/* Active-item accent bar — a small visual anchor so the current section
   reads clearly at a glance, even when many nav items share the same
   pill-highlight style. */
#kvo-sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 15%;
    bottom: 15%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #6ea8fe;
    box-shadow: 0 0 8px rgba(110, 168, 254, 0.7);
}

#kvo-sidebar.collapsed .nav-link.active::before {
    left: 0;
}

#kvo-sidebar a.navbar-brand,
#kvo-sidebar > a {
    padding-bottom: 0.75rem;
}

/* Sidebar dropdown menu (e.g. nav submenus) always matches the sidebar's
   permanently-dark background, regardless of the light/dark theme toggle. */
#kvo-sidebar .dropdown-menu {
    background: #161b22;
    border-color: rgba(255, 255, 255, 0.1);
}
#kvo-sidebar .dropdown-item {
    color: #e6edf3;
}
#kvo-sidebar .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* ── Topbar ──────────────────────────────────────────────── */
.kvo-topbar {
    height: 52px;
    background: var(--bs-body-bg);
    box-shadow: 0 1px 0 rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
    position: relative;
    z-index: 10;
}

/* ── Main area ───────────────────────────────────────────── */
#kvo-main {
    background: var(--bs-tertiary-bg, var(--bs-body-bg));
    min-width: 0; /* prevent flex blowout on narrow screens */
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    border-radius: 12px;
}

/* Depth system: cards using shadow-sm get a slightly richer, layered
   shadow plus a hairline border so they read as raised surfaces against
   the tinted page background instead of flat rectangles. */
.card.shadow-sm {
    border: 1px solid var(--bs-border-color-translucent, rgba(0,0,0,0.06)) !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 6px 16px -8px rgba(0,0,0,0.12) !important;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

/* Cards that act as navigable/clickable summaries lift slightly on hover
   to signal interactivity; plain data cards (tables, logs) opt out via
   .kvo-static so hovering a table row doesn't jitter the whole card. */
.card.shadow-sm:not(.kvo-static):hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.06), 0 12px 28px -10px rgba(0,0,0,0.18) !important;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0,0,0,0.08));
}

/* ── Stat cards ──────────────────────────────────────────── */
.kvo-stat-card {
    overflow: hidden;
    position: relative;
}
.kvo-stat-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--kvo-stat-color, #0d6efd), transparent 85%);
    opacity: 0.9;
}
.kvo-stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    flex-shrink: 0;
    /* Fallback for browsers without color-mix() support; overridden below. */
    background: rgba(13, 110, 253, 0.15);
    color: var(--kvo-stat-color, #0d6efd);
}
@supports (background: color-mix(in srgb, red, transparent)) {
    .kvo-stat-icon {
        background: linear-gradient(155deg, color-mix(in srgb, var(--kvo-stat-color, #0d6efd) 22%, transparent), color-mix(in srgb, var(--kvo-stat-color, #0d6efd) 8%, transparent));
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--kvo-stat-color, #0d6efd) 18%, transparent);
    }
}

/* ── Tables ──────────────────────────────────────────────── */
.table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    border-bottom-width: 1px;
}

.table > :not(caption) > * > * {
    background: transparent;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: color-mix(in srgb, var(--bs-primary) 5%, transparent);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    font-weight: 500;
}
.btn-primary {
    box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--bs-primary) 55%, transparent);
}
.btn-primary:hover {
    box-shadow: 0 4px 14px -3px color-mix(in srgb, var(--bs-primary) 65%, transparent);
    transform: translateY(-1px);
}
.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-primary {
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active {
    transform: translateY(0) !important;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
    padding-top: 0.4em;
    padding-bottom: 0.4em;
}

/* ── Scrollbars (webkit) ─────────────────────────────────── */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--bs-secondary-color) 35%, transparent);
    border-radius: 6px;
    border: 2px solid var(--bs-body-bg);
}
::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--bs-secondary-color) 55%, transparent);
}

/* ── Resource bars ───────────────────────────────────────── */
.kvo-resource-bar .progress {
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
}

/* ── Compact live-usage ring (node list) ─────────────────── */
.kvo-ring {
    --kvo-ring-size: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--kvo-ring-size);
    height: var(--kvo-ring-size);
    border-radius: 50%;
    background: conic-gradient(
        var(--kvo-ring-color) calc(var(--kvo-ring-pct) * 1%),
        rgba(255, 255, 255, 0.1) 0
    );
    position: relative;
    flex-shrink: 0;
}
.kvo-ring::before {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--bs-body-bg, #1a1d24);
}
.kvo-ring-value {
    position: relative;
    z-index: 1;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1;
}
.kvo-ring-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Poll-button spin animation */
@keyframes kvo-spin { to { transform: rotate(360deg); } }
.kvo-spin { display: inline-block; animation: kvo-spin .7s linear infinite; }

/* ── VM status dot ───────────────────────────────────────── */
.kvo-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.kvo-dot.running  { background: #198754; box-shadow: 0 0 6px #198754; }
.kvo-dot.stopped  { background: #6c757d; }
.kvo-dot.error    { background: #dc3545; }
.kvo-dot.creating { background: #ffc107; }
.kvo-dot.migrating{ background: #0d6efd; }
.kvo-dot.suspended{ background: #0dcaf0; }
.kvo-dot.deleting { background: #ffc107; }

/* ── Code / log output ───────────────────────────────────── */
.kvo-log {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.78rem;
    background: #0d1117;
    color: #c9d1d9;
    border-radius: 8px;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── VNC frame ───────────────────────────────────────────── */
#kvo-vnc-frame {
    width: 100%;
    height: 600px;
    border: none;
    border-radius: 8px;
    background: #000;
}

/* ── Login page ──────────────────────────────────────────── */
.kvo-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at top, #0d2137 0%, #0d1117 70%);
    padding: 1rem;
}

.kvo-login-card {
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(22, 33, 48, 0.95);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    padding: 2.5rem;
}

/* ── Animations ──────────────────────────────────────────── */
.kvo-fade-in {
    animation: kvoFadeIn 0.3s ease;
}

@keyframes kvoFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile sidebar backdrop ─────────────────────────────── */
#kvo-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1044;
    cursor: pointer;
}
#kvo-sidebar-backdrop.show { display: block; }

/* ── Mobile responsive sidebar ───────────────────────────── */
@media (max-width: 767.98px) {
    #kvo-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 1045;
        width: 250px !important;    /* full width on mobile, just show/hide */
        transform: translateX(-100%);
    }
    #kvo-sidebar.collapsed {
        width: 250px !important;    /* suppress icon-mode on mobile */
        transform: translateX(-100%);
    }
    #kvo-sidebar.mobile-open {
        transform: translateX(0) !important;
    }
    /* Sidebar collapsed spans should always be visible on mobile */
    #kvo-sidebar.collapsed .nav-link span,
    #kvo-sidebar.collapsed .fs-5,
    #kvo-sidebar.collapsed .dropdown > a > span {
        display: unset;
    }
    #kvo-sidebar.collapsed .nav-link {
        padding-left: 1rem;
        justify-content: flex-start;
    }
    #kvo-main {
        width: 100%;
    }
}

/* ── Light mode overrides ────────────────────────────────── */
/* Sidebar intentionally stays dark (#0d1117, white text) in both themes —
   only the main content area switches with data-bs-theme. See app.css's
   base #kvo-sidebar rules above; no light-mode override is applied here. */

[data-bs-theme="light"] .kvo-log {
    background: #f6f8fa;
    color: #1e293b;
    border: 1px solid #dee2e6;
}

[data-bs-theme="light"] .kvo-login-wrap {
    background: radial-gradient(ellipse at top, #dbeafe 0%, #f1f5f9 70%);
}

[data-bs-theme="light"] .kvo-login-card {
    background: rgba(255,255,255,0.97);
    border-color: rgba(0,0,0,0.1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

[data-bs-theme="light"] .kvo-resource-bar .progress {
    background: rgba(0, 0, 0, 0.08);
}

/* Topbar separator visible on light */
[data-bs-theme="light"] .kvo-topbar {
    border-bottom-color: #dee2e6 !important;
    box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 2px 10px rgba(0,0,0,0.03);
}

/* Slightly tinted page background so raised cards have contrast to sit on
   top of, instead of matching the body color exactly (which is what made
   the admin area look flat). */
[data-bs-theme="light"] #kvo-main {
    background: #f4f6f9;
}
[data-bs-theme="dark"] #kvo-main {
    background: #0b0f14;
}
[data-bs-theme="light"] .card.shadow-sm {
    background: #ffffff;
}
[data-bs-theme="dark"] .card.shadow-sm {
    background: #151b23;
    border-color: rgba(255,255,255,0.06) !important;
}
[data-bs-theme="dark"] .card.shadow-sm {
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 6px 20px -8px rgba(0,0,0,0.55) !important;
}
[data-bs-theme="dark"] .card.shadow-sm:not(.kvo-static):hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.35), 0 14px 32px -10px rgba(0,0,0,0.6) !important;
}

/* ── Light theme contrast pass ───────────────────────────────
   Bootstrap's default light-mode "secondary"/"tertiary" text tokens
   (used by .text-muted, .form-text, table headers, placeholders,
   disabled inputs, and small print) are legible but low-contrast on
   this panel's white cards — fine at Bootstrap's own default body size,
   but this app renders most of that text small (0.72rem-0.85rem), and
   small + faint compounds into genuinely hard-to-read UI. Darkening the
   tokens themselves (rather than one-off classes) fixes every consumer
   at once — badges, form hints, table headers, secondary buttons, etc. */
[data-bs-theme="light"] {
    /* was rgba(33,37,41,.75) ≈ 4.6:1 on white; this is ≈ 7:1 */
    --bs-secondary-color: rgba(33, 37, 41, 0.88);
    /* was rgba(33,37,41,.5) ≈ 2.9:1 on white; this is ≈ 4.6:1, meeting
       AA even though tertiary/disabled text is technically exempt */
    --bs-tertiary-color: rgba(33, 37, 41, 0.62);
    --bs-secondary-bg: #e9ecef;
}

/* Table headers: small + uppercase + letter-spaced text needs more
   weight, not just more contrast, to stay readable at that size. */
[data-bs-theme="light"] .table th {
    color: #3d4348;
    font-weight: 700;
}

/* .form-text hints are often a full explanatory sentence, not a caption
   — they need body-text-adjacent contrast, not caption-level fade. */
[data-bs-theme="light"] .form-text {
    color: #4b5157;
}

/* Placeholder + disabled input text default to the same faint tertiary
   tone above; nudge both a shade darker so labels/hints inside empty or
   locked fields stay legible against white inputs. */
[data-bs-theme="light"] ::placeholder {
    color: rgba(33, 37, 41, 0.55) !important;
}
[data-bs-theme="light"] .form-control:disabled,
[data-bs-theme="light"] .form-select:disabled {
    color: rgba(33, 37, 41, 0.65);
}

/* Subtle badges (bg-*-subtle / text-*-emphasis pairs used throughout for
   plan/status/tag chips) render fine in dark mode but the *-emphasis
   tokens skew lighter than expected against a *-subtle background on a
   white page — reassert a solid, unambiguous emphasis color per variant. */
[data-bs-theme="light"] .badge.text-bg-secondary,
[data-bs-theme="light"] .badge.bg-secondary-subtle { color: #41474d !important; }
[data-bs-theme="light"] .badge.bg-primary-subtle   { color: #0a3f8f !important; }
[data-bs-theme="light"] .badge.bg-info-subtle      { color: #055160 !important; }
[data-bs-theme="light"] .badge.bg-success-subtle   { color: #0a5c33 !important; }
[data-bs-theme="light"] .badge.bg-warning-subtle   { color: #6b4a04 !important; }
[data-bs-theme="light"] .badge.bg-danger-subtle    { color: #7d1a26 !important; }

/* Outline/secondary buttons default to the same faint secondary tone for
   their border+text; darken so "Cancel"/utility actions don't look
   disabled next to a solid primary button. */
[data-bs-theme="light"] .btn-outline-secondary {
    --bs-btn-color: #41474d;
    --bs-btn-border-color: #9aa1a8;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #5c6369;
    --bs-btn-hover-border-color: #5c6369;
}

/* Sidebar dropdown text (e.g. nav submenus) already forces a dark
   background regardless of theme — its light text needs no change. */

/* ── Light theme contrast pass, part 2 ────────────────────────────
   The first pass (above) tinted the page background and darkened text
   tokens, but several component types were never touched: any card
   that isn't `.shadow-sm`, a card nested inside another card, list
   groups, modals, dropdown menus, nav-tabs/pills, and plain (non
   `.kvo-resource-bar`) progress bars. All of these default to
   Bootstrap's own `--bs-body-bg`/`--bs-border-color-translucent`
   tokens, which on this panel's near-white body background render as
   white-on-near-white with almost no visible edge. */

/* Any card without .shadow-sm (e.g. node_view.php's plain summary
   cards) still needs an explicit white surface + visible border so it
   doesn't blend into the #f4f6f9 page tint. */
[data-bs-theme="light"] .card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.09);
}

/* Nested cards — a card placed inside another card's body (e.g. a
   sub-summary panel) must read as a distinct, slightly recessed
   surface, not a second identical white rectangle glued to the first. */
[data-bs-theme="light"] .card .card {
    background: #f6f8fb;
    border-color: rgba(0, 0, 0, 0.1);
}
[data-bs-theme="light"] .card .card.shadow-sm {
    background: #f6f8fb;
    box-shadow: none !important;
}

/* List groups (e.g. Update Manager's file/step list) — give items a
   visible border and a hover state, instead of borderless white text
   rows indistinguishable from the card body around them. */
[data-bs-theme="light"] .list-group-item {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}
[data-bs-theme="light"] .list-group-item-action:hover,
[data-bs-theme="light"] .list-group-item-action:focus {
    background: #f1f4f8;
}

/* Modal dialogs — the dialog itself sits on a dimmed backdrop so it
   already reads as a distinct layer, but its header/footer dividers
   and any bg-body-secondary code blocks inside (see the copyable
   command modal) need a firmer, visible line than the default
   translucent-black-at-8% border. */
[data-bs-theme="light"] .modal-content {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
}
[data-bs-theme="light"] .modal-header,
[data-bs-theme="light"] .modal-footer {
    border-color: rgba(0, 0, 0, 0.12);
}
[data-bs-theme="light"] .bg-body-secondary {
    background-color: #eef1f5 !important;
}

/* Dropdown menus (e.g. activity log filters, VM row actions) — force a
   solid surface + visible border/hover instead of the default
   near-invisible translucent border on white. */
[data-bs-theme="light"] .dropdown-menu:not(.dropdown-menu-dark) {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.14);
    box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.18);
}
[data-bs-theme="light"] .dropdown-menu:not(.dropdown-menu-dark) .dropdown-item:hover,
[data-bs-theme="light"] .dropdown-menu:not(.dropdown-menu-dark) .dropdown-item:focus {
    background: #eef1f5;
}
[data-bs-theme="light"] .dropdown-menu:not(.dropdown-menu-dark) .dropdown-divider {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Nav tabs / pills in the page body (not the permanently-dark sidebar)
   — inactive tabs default to the same faint secondary tone as other
   muted text, making the active/inactive distinction the only signal;
   give inactive items a visible label color and tabs a visible
   underline/border so the whole strip doesn't look like plain text. */
[data-bs-theme="light"] .nav-tabs {
    border-bottom-color: rgba(0, 0, 0, 0.14);
}
[data-bs-theme="light"] .nav-tabs .nav-link {
    color: #41474d;
}
[data-bs-theme="light"] .nav-tabs .nav-link:hover {
    border-color: rgba(0, 0, 0, 0.1);
    background: #f1f4f8;
}
[data-bs-theme="light"] .nav-tabs .nav-link.active {
    color: #0a3f8f;
    border-color: rgba(0, 0, 0, 0.14) rgba(0, 0, 0, 0.14) #fff;
}
[data-bs-theme="light"] #kvo-main .nav-pills .nav-link:not(.active) {
    color: #41474d;
}
[data-bs-theme="light"] #kvo-main .nav-pills .nav-link:not(.active):hover {
    background: #eef1f5;
}

/* Plain progress bars (e.g. per-subscription CPU/RAM/disk mini-bars on
   Cloud Resources, which don't use .kvo-resource-bar) — the track
   already darkened slightly via --bs-secondary-bg above, but bump it
   further so the filled portion has a clearly visible track to sit in
   at the 4-6px heights used throughout the panel. */
[data-bs-theme="light"] .progress {
    background-color: #e3e7ec;
}

/* Table header row + striping — reinforce the header/body boundary and
   give table-striped (used in a couple of log/report views) a visible
   alternate row instead of one indistinguishable from card-body white. */
[data-bs-theme="light"] .table thead {
    border-bottom: 2px solid rgba(0, 0, 0, 0.12);
}
[data-bs-theme="light"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: #f6f8fb;
}

/* Card headers/footers inside cards nested per the rule above should
   still contrast with their own (tinted) card, not the outer white. */
[data-bs-theme="light"] .card .card > .card-header,
[data-bs-theme="light"] .card .card > .card-footer {
    border-color: rgba(0, 0, 0, 0.1);
}

/* ══════════════════════════════════════════════════════════════════
   Client Portal Design System (VirtFusion-inspired)
   Scoped to body.kvo-client-body so the admin panel — which shares the
   same #kvo-sidebar/#kvo-main/.card/.table/.badge markup and base rules
   above — is never affected by these premium refinements. Anything that
   should also improve the admin panel belongs in the shared rules above
   this section instead.
   ══════════════════════════════════════════════════════════════════ */

/* Slightly larger, softer corners than the admin panel's 12px default —
   this is the client portal's signature "premium" card shape. */
body.kvo-client-body .card {
    border-radius: 18px;
}
body.kvo-client-body .modal-content {
    border-radius: 18px;
}
body.kvo-client-body .btn {
    border-radius: 10px;
}
body.kvo-client-body .form-control,
body.kvo-client-body .form-select {
    border-radius: 8px;
}

/* Sidebar: subtle vertical gradient instead of a flat fill, plus a
   brand-row divider that reads as a distinct "header" band. */
body.kvo-client-body #kvo-sidebar {
    background: linear-gradient(180deg, #0d1117 0%, #090c10 100%);
}
body.kvo-client-body .kvo-client-brand {
    padding-bottom: 1rem;
}

/* ── Page header (icon chip + title + subtitle) ─────────────────── */
.kvo-client-page-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: linear-gradient(155deg, color-mix(in srgb, var(--bs-primary) 22%, transparent), color-mix(in srgb, var(--bs-primary) 6%, transparent));
    color: var(--bs-primary);
    flex-shrink: 0;
}

/* ── Topbar page title (client portal only — admin already shows this
   in the page body itself via kvo_page_header()) ───────────────────── */
.kvo-client-body .kvo-page-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--bs-emphasis-color);
}

/* ── Sidebar user box: avatar + name, replacing the plain icon+text
   footer row so the signed-in identity reads as a real account chip. */
.kvo-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(155deg, #3b82f6, #1d4ed8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
}
.kvo-client-userbox {
    border-radius: 10px;
    padding: 0.45rem 0.5rem;
    color: #e6edf3;
}

/* ── Empty states: icon + message, replacing bare "No X yet." text ── */
.kvo-empty-state {
    color: var(--bs-secondary-color);
}
.kvo-empty-state i {
    font-size: 2.1rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.45;
}
.kvo-empty-state p {
    font-size: 0.9rem;
}

/* ── VPS dashboard cards / VM detail resource bars ──────────────── */
.kvo-usage-progress {
    height: 6px;
}
.kvo-vm-card .card-header {
    background: transparent;
}
.kvo-vm-specs dt {
    color: var(--bs-secondary-color);
    font-weight: 400;
}
.kvo-vm-header-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: linear-gradient(155deg, color-mix(in srgb, var(--bs-primary) 22%, transparent), color-mix(in srgb, var(--bs-primary) 6%, transparent));
    color: var(--bs-primary);
    flex-shrink: 0;
}

/* ── Impersonation banner: a clear, brand-neutral warning strip rather
   than a flat solid-yellow bar. */
.kvo-impersonation-banner {
    background: linear-gradient(90deg, #ffc107, #ffd65c);
}

/* ── Table row spacing: a touch more breathing room than the admin's
   denser data-grid tables, since client tables are shorter lists. */
body.kvo-client-body .table > :not(caption) > * > * {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}
body.kvo-client-body .table > thead > tr > * {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

/* ── Mobile: page title hides in the cramped topbar (still shown in the
   page body itself via kvo_client_page_header()), so the toggle and
   theme buttons stay reachable without crowding. ─────────────────── */
@media (max-width: 575.98px) {
    .kvo-client-body .kvo-page-title {
        display: none;
    }
}

/* ── Real distro/OS logos (kvo_os_logo_icon()) ──────────────────────
   Vendored colored SVGs, not a Bootstrap glyph — .kvo-os-logo just
   keeps them from stretching to their intrinsic size when a caller
   forgets width/height, plus a light drop-shadow so light-colored
   logos (e.g. Fedora, AlmaLinux) still read on a dark row background. */
.kvo-os-logo {
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

/* ── Flag + location badge (kvo_client_location_badge()) ────────── */
.kvo-location-badge span:first-child {
    font-size: 1.05em;
    line-height: 1;
}

/* ── "List VPS" table (client/index.php via kvo_client_vm_row()) ──── */
.kvo-vm-list-card .table {
    margin-bottom: 0;
}
.kvo-vm-row-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--bs-body-color) 6%, transparent);
    flex-shrink: 0;
}
.kvo-vm-row-info {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 0.15rem 1.25rem;
}
.kvo-vm-row-info span {
    white-space: nowrap;
}

/* Virtualizor-style compact multi-IP summary. The popover is positioned by
   app.js on document.body so it is not clipped by responsive tables/cards. */
.kvo-ip-summary {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
}
.kvo-ip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 .32rem;
    border-radius: .32rem;
    background: #111;
    color: #fff !important;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: background-color .15s ease, transform .15s ease;
}
.kvo-ip-count:hover,
.kvo-ip-count:focus-visible {
    background: #343a40;
    color: #fff !important;
    transform: translateY(-1px);
}
.kvo-ip-hover-card {
    position: fixed;
    z-index: 1080;
    min-width: 190px;
    max-width: min(360px, calc(100vw - 1rem));
    padding: .55rem .7rem;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: .45rem;
    background: #111820;
    color: #f2f4f7;
    box-shadow: 0 .45rem 1.25rem rgba(0,0,0,.35);
    font-size: .78rem;
    pointer-events: none;
}
.kvo-ip-hover-card strong {
    display: block;
    margin-bottom: .3rem;
    color: #adb5bd;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.kvo-ip-hover-card ul {
    margin: 0;
    padding-left: 1rem;
}
.kvo-ip-hover-card li {
    font-family: var(--bs-font-monospace);
    white-space: nowrap;
}

/* ── Client VPS card grid ─────────────────────────────────────────── */
.kvo-vps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}
.kvo-vps-card {
    background: linear-gradient(145deg,
        color-mix(in srgb, var(--bs-body-bg) 100%, transparent) 0%,
        color-mix(in srgb, var(--bs-body-bg) 96%, var(--bs-body-color) 4%) 100%);
    border: 1px solid var(--bs-border-color);
    border-radius: 14px;
    padding: 1.1rem 1.25rem 1rem;
    position: relative;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.18), 0 4px 14px -6px rgba(0,0,0,.28);
}
.kvo-vps-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(0,0,0,.28), 0 10px 30px -10px rgba(0,0,0,.35);
    border-color: rgba(255,255,255,.14);
}
/* Status accent stripe at top */
.kvo-vps-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    border-radius: 14px 14px 0 0;
    background: var(--bs-secondary-bg);
}
.kvo-vps-card[data-status="running"]::before    { background: #198754; box-shadow: 0 0 10px #19875460; }
.kvo-vps-card[data-status="stopped"]::before    { background: #dc3545; }
.kvo-vps-card[data-status="suspended"]::before  { background: #fd7e14; }
.kvo-vps-card[data-status="creating"]::before,
.kvo-vps-card[data-status="rebuilding"]::before,
.kvo-vps-card[data-status="migrating"]::before  { background: #0d6efd; animation: kvoCardPulse 1.4s ease-in-out infinite; }
@keyframes kvoCardPulse { 0%,100%{opacity:1} 50%{opacity:.55} }

/* Card header */
.kvo-vps-card-head {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    margin-bottom: .85rem;
}
.kvo-vps-card-os {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--bs-body-color) 7%, transparent);
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.kvo-vps-card-info {
    flex: 1; min-width: 0;
}
.kvo-vps-card-name {
    font-weight: 700;
    font-size: .95rem;
    text-decoration: none;
    color: var(--bs-body-color);
    display: flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.kvo-vps-card-name:hover { color: var(--bs-primary); }
.kvo-vps-card-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem .5rem;
    margin-top: .25rem;
    font-size: .78rem;
    color: var(--bs-secondary-color);
}
/* Specs row */
.kvo-vps-specs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .4rem;
    margin: .75rem 0;
}
.kvo-spec-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .15rem;
    padding: .5rem .25rem;
    border-radius: 8px;
    background: color-mix(in srgb, var(--bs-body-color) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--bs-border-color) 60%, transparent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.kvo-spec-item i {
    font-size: .9rem;
    color: var(--bs-secondary-color);
}
.kvo-spec-val {
    font-size: .75rem;
    font-weight: 700;
    color: var(--bs-body-color);
    line-height: 1.15;
}
.kvo-spec-lbl {
    font-size: .62rem;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: .04em;
    line-height: 1;
}
/* Card footer actions */
.kvo-vps-card-footer {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--bs-border-color);
}
.kvo-vps-card-footer .btn { flex: 1; min-width: 70px; font-size: .8rem; padding: .3rem .5rem; }
/* Speed-throttle notice strip — shown between specs and footer when
   bw_throttle_active_mbps IS NOT NULL on a client's VM. */
.kvo-vps-throttle-notice {
    display: block;
    margin-top: .6rem;
    padding: .3rem .55rem;
    border-radius: .35rem;
    background: rgba(255, 193, 7, .12);
    border: 1px solid rgba(255, 193, 7, .4);
    color: #856404;
    font-size: .78rem;
    font-weight: 500;
}
.kvo-vps-throttle-notice:hover { background: rgba(255, 193, 7, .2); color: #856404; }
@media (max-width: 480px) {
    .kvo-vps-grid { grid-template-columns: 1fr; }
}

/* ── Circular power buttons (Linux client VM) ──────────────────────── */
.kvo-linux-power-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1.6rem;
    padding: 1.25rem 0 .75rem;
    flex-wrap: wrap;
}
.kvo-linux-power-row form,
.kvo-linux-power-row div { margin: 0; }
.kvo-circ-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}
.kvo-circ-btn {
    width: 58px; height: 58px;
    border-radius: 50%;
    border: 2px solid transparent;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .2s ease, opacity .15s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    text-decoration: none;
}
.kvo-circ-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.kvo-circ-btn:disabled { opacity: .35; cursor: not-allowed; }
button.kvo-circ-btn { -webkit-appearance: none; padding: 0; background: transparent; }
a.kvo-circ-btn { color: inherit; }
.kvo-circ-label {
    font-size: .68rem;
    text-align: center;
    color: var(--bs-secondary-color);
    white-space: nowrap;
}
.kvo-circ-stop     { background: rgba(220,53,69,.18);   border-color: rgba(220,53,69,.7);    color: #dc3545; }
.kvo-circ-restart  { background: rgba(13,110,253,.18);  border-color: rgba(13,110,253,.7);   color: #4d90fe; }
.kvo-circ-start    { background: rgba(25,135,84,.18);   border-color: rgba(25,135,84,.7);    color: #28c76f; }
.kvo-circ-vnc      { background: rgba(220,53,69,.18);   border-color: rgba(220,53,69,.7);    color: #f87171; }
.kvo-circ-shutdown { background: rgba(253,126,20,.18);  border-color: rgba(253,126,20,.7);   color: #fd7e14; }
.kvo-circ-reinstall { background: rgba(108,117,125,.18); border-color: rgba(108,117,125,.7); color: #adb5bd; }
.kvo-circ-connect  { background: rgba(32,201,151,.18);  border-color: rgba(32,201,151,.7);   color: #20c997; }

/* ── Windows credential card ─────────────────────────────────────── */
.kvo-cred-card { overflow: hidden; }
.kvo-cred-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.kvo-cred-cell {
    padding: .9rem 1.1rem;
    border-right: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
}
.kvo-cred-cell:last-child { border-right: 0; }
@media (max-width: 767px) {
    .kvo-cred-cell { border-right: 0; }
}
.kvo-cred-label {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
    margin-bottom: .35rem;
}
.kvo-cred-value {
    font-size: .88rem;
    font-weight: 500;
    color: var(--bs-body-color);
    word-break: break-all;
}
.kvo-copy-btn {
    background: none;
    border: none;
    padding: .15rem .3rem;
    color: var(--bs-secondary-color);
    cursor: pointer;
    border-radius: 4px;
    font-size: .78rem;
    flex-shrink: 0;
    transition: color .15s, background .15s;
    line-height: 1;
}
.kvo-copy-btn:hover { color: var(--bs-primary); background: rgba(13,110,253,.1); }
.kvo-copy-btn.copied { color: #28c76f; }

/* ── Linux VM hero cards ─────────────────────────────────────────── */
.kvo-os-hero-card,
.kvo-loc-hero-card    { min-height: 140px; }
.kvo-os-hero-card img { object-fit: contain; }
.kvo-vm-status-bar    { font-size: .84rem; }
.kvo-vm-status-bar .btn-outline-secondary { font-size: .75rem; line-height: 1.4; }

/* ── Status bars — thicker + visible track + min nub ─────────────── */
.kvo-status-progress {
    height: 8px;
    background: rgba(255,255,255,.13);  /* visible track even at 0% */
    border-radius: 4px;
}
.kvo-status-progress .progress-bar {
    border-radius: 4px;
    min-width: 4px;                     /* always shows a nub, even at 0% */
    transition: width .4s ease;
}

/* OS-specific bar colors */
.kvo-bar-teal   { background-color: #0dcaf0 !important; }   /* Linux disk  */
.kvo-bar-orange { background-color: #fd7e14 !important; }   /* Linux bw    */

/* ── VM detail hero header ─────────────────────────────────────────── */
.kvo-vm-hero-name {
    font-size: 1.5rem;
}
.kvo-vm-hero-flag {
    font-size: 1.3rem;
    line-height: 1;
}

/* ── Power Options: fixed 3-column / 2-row action grid, matching the
   reference "Power Options" panel shape exactly regardless of viewport
   width down to small tablets, where it collapses to 2 columns. ──── */
.kvo-power-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}
@media (max-width: 480px) {
    .kvo-power-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Status card: label+value+bar stacked rows ───────────────────── */
.kvo-status-row {
    margin-bottom: 0.85rem;
}
.kvo-status-row-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.kvo-status-row-label i {
    color: var(--bs-secondary-color);
}
.kvo-status-row-value {
    float: right;
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
}
.kvo-status-progress {
    height: 6px;
    clear: both;
    margin-top: 0.35rem;
}
.progress-bar.bg-cyan {
    background-color: #00b4d8;
}

