:root {

    color-scheme: dark;

    --bg: #080b10;
    --panel: #0e131a;
    --panel-2: #111820;
    --panel-3: #151d26;

    --border: #202b36;
    --border-light: #2b3946;

    --text: #edf3f8;
    --muted: #82909d;
    --muted-2: #64727e;

    --accent: #54a8ff;
    --accent-hover: #70b8ff;

    --green: #36d399;
    --red: #ff647c;
    --yellow: #e8c66a;

    --radius: 10px;

}


* {

    box-sizing: border-box;

}


html,
body {

    margin: 0;

    min-height: 100%;

    background:
        radial-gradient(
            circle at top right,
            rgba(38, 92, 140, 0.10),
            transparent 32%
        ),
        var(--bg);

    color: var(--text);

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

}


button,
input {

    font: inherit;

}


button {

    cursor: pointer;

}


.hidden {

    display: none !important;

}


/* ==========================================================
   APP
========================================================== */

.app {

    min-height: 100vh;

}


/* ==========================================================
   TOPBAR
========================================================== */

.topbar {

    height: 74px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding:
        0 28px;

    border-bottom:
        1px solid var(--border);

    background:
        rgba(10, 14, 19, 0.94);

    backdrop-filter:
        blur(16px);

}


.brand {

    font-size: 20px;

    font-weight: 700;

    letter-spacing: -0.03em;

}


.subtitle {

    margin-top: 3px;

    color: var(--muted);

    font-size: 12px;

}


.status {

    display: flex;

    align-items: center;

    gap: 8px;

    color: var(--muted);

    font-size: 12px;

}


.status-dot {

    width: 7px;

    height: 7px;

    border-radius: 50%;

    background: var(--green);

    box-shadow:
        0 0 10px
        rgba(54, 211, 153, 0.65);

}


/* ==========================================================
   WORKSPACE
========================================================== */

.workspace {

    display: grid;

    grid-template-columns:
        330px minmax(0, 1fr);

    min-height:
        calc(100vh - 74px);

}


/* ==========================================================
   PANELS
========================================================== */

.keys-panel,
.details-panel {

    min-width: 0;

}


.keys-panel {

    border-right:
        1px solid var(--border);

    background:
        rgba(13, 18, 24, 0.78);

}


.details-panel {

    padding: 30px;

    background:
        rgba(8, 11, 16, 0.82);

}


/* ==========================================================
   PANEL HEADER
========================================================== */

.panel-header {

    min-height: 82px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 14px;

    padding:
        18px 18px;

    border-bottom:
        1px solid var(--border);

}


.panel-title {

    font-size: 15px;

    font-weight: 700;

}


.panel-subtitle {

    margin-top: 4px;

    color: var(--muted-2);

    font-size: 11px;

}


/* ==========================================================
   BUTTONS
========================================================== */

.primary-button,
.secondary-button,
.danger-button {

    height: 36px;

    border-radius: 8px;

    padding:
        0 13px;

    border:
        1px solid transparent;

    font-size: 12px;

    font-weight: 600;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease;

}


.primary-button {

    color: #07111b;

    background:
        var(--accent);

}


.primary-button:hover {

    background:
        var(--accent-hover);

}


.secondary-button {

    color: var(--text);

    background:
        var(--panel-3);

    border-color:
        var(--border-light);

}


.secondary-button:hover {

    border-color:
        #3d4d5c;

}


.danger-button {

    color:
        #ff8a9a;

    background:
        rgba(255, 100, 124, 0.08);

    border-color:
        rgba(255, 100, 124, 0.18);

}


.danger-button:hover {

    background:
        rgba(255, 100, 124, 0.14);

}


/* ==========================================================
   KEY LIST
========================================================== */

.keys-list {

    padding:
        8px;

}


.key-item {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;

    padding:
        13px 12px;

    margin-bottom: 4px;

    border:
        1px solid transparent;

    border-radius: 8px;

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease;

}


.key-item:hover {

    background:
        rgba(255, 255, 255, 0.035);

}


.key-item.selected {

    background:
        rgba(84, 168, 255, 0.10);

    border-color:
        rgba(84, 168, 255, 0.24);

}


.key-main {

    min-width: 0;

}


.key-name {

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    font-size: 13px;

    font-weight: 600;

}


.key-prefix {

    margin-top: 4px;

    color: var(--muted-2);

    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;

    font-size: 10px;

}


.key-meta {

    display: flex;

    align-items: center;

    gap: 5px;

    flex-shrink: 0;

}


.key-status,
.superadmin {

    display: inline-flex;

    align-items: center;

    height: 20px;

    padding:
        0 6px;

    border-radius: 5px;

    font-size: 9px;

    font-weight: 700;

    letter-spacing: 0.04em;

}


.key-status.enabled {

    color:
        var(--green);

    background:
        rgba(54, 211, 153, 0.10);

}


.key-status.disabled {

    color:
        var(--red);

    background:
        rgba(255, 100, 124, 0.10);

}


.superadmin {

    color:
        var(--yellow);

    background:
        rgba(232, 198, 106, 0.10);

}


/* ==========================================================
   EMPTY
========================================================== */

.empty-state {

    height:
        100%;

    min-height:
        500px;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    text-align: center;

}


.empty-icon {

    width: 52px;

    height: 52px;

    display: flex;

    align-items: center;

    justify-content: center;

    margin-bottom: 18px;

    border:
        1px solid var(--border-light);

    border-radius: 14px;

    color:
        var(--muted);

    background:
        var(--panel);

    font-size: 22px;

}


.empty-title {

    font-size: 17px;

    font-weight: 700;

}


.empty-text {

    max-width: 330px;

    margin-top: 8px;

    color: var(--muted);

    font-size: 12px;

    line-height: 1.6;

}


/* ==========================================================
   DETAILS
========================================================== */

.details-header {

    display: flex;

    align-items: flex-start;

    justify-content: space-between;

    gap: 20px;

    margin-bottom: 22px;

}


.details-title {

    font-size: 22px;

    font-weight: 700;

    letter-spacing: -0.025em;

}


.details-description {

    margin-top: 5px;

    color: var(--muted);

    font-size: 12px;

}


.header-actions,
.editor-actions {

    display: flex;

    gap: 8px;

    flex-shrink: 0;

}


/* ==========================================================
   KEY INFO
========================================================== */

.key-info {

    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 10px;

    margin-bottom: 28px;

}


.info-card {

    padding:
        14px;

    border:
        1px solid var(--border);

    border-radius: var(--radius);

    background:
        var(--panel);

}


.info-card span {

    display: block;

    margin-bottom: 7px;

    color: var(--muted-2);

    font-size: 10px;

    text-transform: uppercase;

    letter-spacing: 0.05em;

}


.info-card strong {

    font-size: 12px;

}


.green {

    color: var(--green);

}


.red {

    color: var(--red);

}


/* ==========================================================
   GRANTS
========================================================== */

.grants-section {

    max-width: 900px;

}


.section-title {

    margin-bottom: 10px;

    font-size: 13px;

    font-weight: 700;

}


.grants-list {

    display: flex;

    flex-direction: column;

    gap: 5px;

}


.grant-row {

    padding:
        11px 13px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background:
        var(--panel);

}


.grant-permission {

    font-size: 12px;

    font-weight: 600;

}


.grant-object {

    margin-top: 4px;

    color: var(--muted-2);

    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;

    font-size: 10px;

}


.root-message,
.no-grants,
.permission-empty {

    padding:
        18px;

    border:
        1px dashed var(--border-light);

    border-radius: 9px;

    color: var(--muted);

    background:
        rgba(255, 255, 255, 0.015);

    font-size: 12px;

}


/* ==========================================================
   EDITOR
========================================================== */

.editor {

    height:
        calc(100vh - 134px);

    min-height:
        520px;

}


.permission-editor {

    display: grid;

    grid-template-columns:
        360px minmax(0, 1fr);

    height:
        calc(100% - 74px);

    min-height:
        420px;

    overflow: hidden;

    border:
        1px solid var(--border);

    border-radius:
        var(--radius);

    background:
        var(--panel);

}


.object-tree-panel,
.permission-panel {

    min-width: 0;

    overflow: auto;

}


.object-tree-panel {

    border-right:
        1px solid var(--border);

}


.editor-title {

    position: sticky;

    top: 0;

    z-index: 2;

    padding:
        13px 15px;

    border-bottom:
        1px solid var(--border);

    background:
        var(--panel-2);

    color:
        var(--muted);

    font-size: 10px;

    font-weight: 700;

    text-transform: uppercase;

    letter-spacing: 0.06em;

}


.object-tree {

    padding:
        8px;

}


.tree-folder {

    margin-bottom: 4px;

}


.tree-folder-title {

    display: flex;

    align-items: center;

    gap: 7px;

    padding:
        9px 9px;

    color:
        var(--text);

    font-size: 12px;

    font-weight: 600;

}


.tree-arrow {

    color:
        var(--muted-2);

    font-size: 10px;

}


.tree-vms {

    padding-left:
        18px;

}


.tree-vm {

    display: flex;

    align-items: center;

    gap: 8px;

    padding:
        8px 10px;

    border:
        1px solid transparent;

    border-radius: 7px;

    color:
        var(--muted);

    cursor: pointer;

    font-size: 11px;

    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;

}


.tree-vm:hover {

    color:
        var(--text);

    background:
        rgba(255, 255, 255, 0.035);

}


.tree-vm.selected {

    color:
        var(--text);

    background:
        rgba(84, 168, 255, 0.10);

    border-color:
        rgba(84, 168, 255, 0.24);

}


.vm-tree-dot {

    width: 5px;

    height: 5px;

    flex-shrink: 0;

    border-radius: 50%;

    background:
        var(--muted-2);

}


.tree-vm.selected
.vm-tree-dot {

    background:
        var(--accent);

    box-shadow:
        0 0 8px
        rgba(84, 168, 255, 0.7);

}


/* ==========================================================
   PERMISSION PANEL
========================================================== */

.permission-panel {

    background:
        rgba(8, 11, 16, 0.45);

}


.selected-object {

    position: sticky;

    top: 0;

    z-index: 2;

    padding:
        18px 20px;

    border-bottom:
        1px solid var(--border);

    background:
        rgba(17, 24, 32, 0.96);

    font-size: 14px;

    font-weight: 700;

}


.permission-list {

    padding:
        14px;

}


.permission {

    position: relative;

    display: flex;

    align-items: flex-start;

    gap: 11px;

    padding:
        12px;

    margin-bottom: 6px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background:
        var(--panel);

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease;

}


.permission:hover {

    background:
        var(--panel-3);

    border-color:
        var(--border-light);

}


.permission input {

    position: absolute;

    opacity: 0;

    pointer-events: none;

}


.permission-check {

    width: 17px;

    height: 17px;

    flex-shrink: 0;

    margin-top: 1px;

    border:
        1px solid #3a4855;

    border-radius: 5px;

    background:
        #0a0f14;

}


.permission
input:checked
+
.permission-check {

    border-color:
        var(--accent);

    background:
        var(--accent);

    box-shadow:
        0 0 10px
        rgba(84, 168, 255, 0.22);

}


.permission
input:checked
+
.permission-check::after {

    content: "✓";

    display: flex;

    align-items: center;

    justify-content: center;

    height: 100%;

    color: #07111b;

    font-size: 11px;

    font-weight: 900;

}


.permission-text {

    display: flex;

    flex-direction: column;

    gap: 4px;

}


.permission-text strong {

    font-size: 12px;

}


.permission-text small {

    color:
        var(--muted);

    font-size: 10px;

    line-height: 1.5;

}


/* ==========================================================
   OBJECT TREE · TABS · PERMISSION TAGS
========================================================== */

.tree-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 10px 4px;
}

.tree-tab {
    height: 28px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 7px;
    background: var(--panel-3);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.tree-tab:hover {
    color: var(--text);
}

.tree-tab.active {
    color: #07111b;
    background: var(--accent);
    border-color: var(--accent);
}

.tn-children {
    margin-left: 15px;
    padding-left: 6px;
    border-left: 1px solid var(--border);
}

.tn-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    margin-bottom: 1px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.tn-row:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.tn-row.selected {
    color: var(--text);
    background: rgba(84, 168, 255, 0.16);
    border-color: rgba(84, 168, 255, 0.50);
    box-shadow: inset 3px 0 0 var(--accent);
}

.tn-arrow {
    width: 16px;
    flex-shrink: 0;
    text-align: center;
    color: var(--muted-2);
    font-size: 11px;
    cursor: pointer;
}

.tn-arrow:hover {
    color: var(--text);
}

.tn-arrow.empty {
    cursor: default;
}

.tn-check {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.tn-icon {
    flex-shrink: 0;
    width: 14px;
    text-align: center;
    color: var(--muted-2);
    font-size: 10px;
}

.tn-row.selected .tn-icon {
    color: var(--accent);
}

.tn-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tn-empty {
    padding: 18px;
    color: var(--muted);
    font-size: 12px;
}

.permission input:indeterminate + .permission-check {
    border-color: var(--accent);
    background: var(--accent);
}

.permission input:indeterminate + .permission-check::after {
    content: "−";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #07111b;
    font-size: 12px;
    font-weight: 900;
}

.permission-all {
    border-color: var(--border-light);
    margin-bottom: 12px;
}

.permission-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.permission-tag.inherited {
    color: var(--accent);
    background: rgba(84, 168, 255, 0.12);
}

.permission-tag.exception {
    color: var(--red);
    background: rgba(255, 100, 124, 0.12);
}

.selected-object small {
    display: block;
    margin-top: 4px;
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}


.grant-row.deny {

    border-color: rgba(255, 100, 124, 0.28);

}


.grant-effect {

    display: inline-block;

    margin-left: 8px;

    padding: 1px 6px;

    border-radius: 5px;

    color: var(--red);

    background: rgba(255, 100, 124, 0.12);

    font-size: 9px;

    font-weight: 700;

    letter-spacing: 0.04em;

    text-transform: uppercase;

}


/* ==========================================================
   RESPONSIVE
========================================================== */

@media (
    max-width: 900px
) {

    .workspace {

        grid-template-columns:
            250px minmax(0, 1fr);

    }


    .key-info {

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

    }


    .permission-editor {

        grid-template-columns:
            280px minmax(0, 1fr);

    }

}


@media (
    max-width: 700px
) {

    .topbar {

        padding:
            0 16px;

    }


    .workspace {

        grid-template-columns:
            1fr;

    }


    .keys-panel {

        border-right:
            none;

        border-bottom:
            1px solid var(--border);

    }


    .keys-list {

        max-height:
            280px;

        overflow:
            auto;

    }


    .details-panel {

        padding:
            18px;

    }


    .details-header {

        flex-direction:
            column;

    }


    .permission-editor {

        grid-template-columns:
            1fr;

        overflow:
            auto;

    }


    .object-tree-panel {

        border-right:
            none;

        border-bottom:
            1px solid var(--border);

        max-height:
            300px;

    }

}


/* ==========================================================
   PORTAL · TOP BAR, USER MENU
   (общий стиль всех страниц портала)
========================================================== */

.topbar-left {
    display: flex;
    align-items: center;
    gap: 18px;
}

a.brand-block {
    display: block;
    color: inherit;
    text-decoration: none;
}

.user-menu {
    position: relative;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 12px 0 6px;
    border: 1px solid var(--border-light);
    border-radius: 24px;
    background: var(--panel-3);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.user-chip:hover {
    border-color: #3d4d5c;
}

.user-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-arrow {
    color: var(--muted);
    font-size: 9px;
    transition: transform .12s ease;
}

.user-menu.open .chip-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 10000;
    min-width: 240px;
    padding: 6px;
    border: 1px solid #444;
    border-radius: 10px;
    background: #1e2025;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity .12s ease, transform .12s ease, visibility .12s ease;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-head {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px 12px;
    border-bottom: 1px solid #333;
    margin-bottom: 4px;
}

.menu-head small {
    color: var(--muted);
    font-size: 11px;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #ddd;
    font-size: 13px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu-item:hover {
    background: rgba(255, 255, 255, .10);
    color: #fff;
}

.menu-sep {
    height: 1px;
    margin: 4px 0;
    background: #333;
}


/* ==========================================================
   AVATAR
========================================================== */

.avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #07111b;
    font-size: 12px;
    font-weight: 800;
}

.avatar-small {
    width: 30px;
    height: 30px;
    font-size: 11px;
}

.avatar-large {
    width: 72px;
    height: 72px;
    font-size: 24px;
}


/* ==========================================================
   FORMS, MODAL
========================================================== */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.field > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.field input[type="text"],
.field input[type="password"],
.field select,
.search-input,
.ad-test input {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: #0a0f14;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.field input:focus,
.field select:focus,
.search-input:focus,
.ad-test input:focus {
    border-color: var(--accent);
}

.field input:disabled,
.field select:disabled {
    opacity: .55;
}

.checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.checkbox-field > span {
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}

.checkbox-field input {
    accent-color: var(--accent);
}

.form-error {
    min-height: 18px;
    margin-bottom: 8px;
    color: var(--red);
    font-size: 12px;
}

.hint {
    color: var(--muted-2);
    font-size: 11px;
    line-height: 1.5;
}

.hint code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--panel-3);
    color: var(--muted);
}

.muted {
    color: var(--muted-2);
}

.small {
    font-size: 11px;
}

.spacer {
    flex: 1;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, .6);
}

.modal {
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 22px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--panel);
}

.modal-title {
    margin-bottom: 18px;
    font-size: 17px;
    font-weight: 700;
}

.modal-subtitle {
    margin: 6px 0 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.profile-avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-button {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.small-button {
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
}

.primary-button:disabled {
    opacity: .6;
    cursor: default;
}


/* ==========================================================
   LOGIN
========================================================== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 32px;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: var(--panel);
}

.login-brand {
    margin-bottom: 26px;
    text-align: center;
}

.login-brand .brand {
    font-size: 26px;
}

.login-submit {
    width: 100%;
    height: 42px;
    margin: 4px 0 14px;
    font-size: 13px;
}


/* ==========================================================
   PAGES (пользователи)
========================================================== */

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px;
}

.page-section {
    margin-bottom: 36px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-align: left;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.row-disabled {
    opacity: .5;
}

.row-actions {
    text-align: right;
}

.cell-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
    max-width: 760px;
}

.ad-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin: 6px 0 10px;
}

.ad-test {
    display: inline-flex;
    gap: 8px;
}


/* ==========================================================
   BADGES
========================================================== */

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    background: rgba(255, 255, 255, .06);
    font-size: 11px;
    font-weight: 600;
}

.badge.source-ad {
    color: var(--accent);
    background: rgba(84, 168, 255, .12);
}

.badge.tools-ok {
    color: var(--green);
    background: rgba(54, 211, 153, .12);
}

.badge.tools-warn {
    color: var(--yellow);
    background: rgba(232, 198, 106, .12);
}

.badge.tools-bad {
    color: var(--red);
    background: rgba(255, 100, 124, .12);
}


/* ==========================================================
   VM PAGE
========================================================== */

.vm-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    height: calc(100vh - 74px);
}

.vm-tree-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: rgba(13, 18, 24, .78);
}

.vm-tree-head {
    padding: 14px 12px 8px;
    border-bottom: 1px solid var(--border);
}

.vm-tree-head .search-input {
    width: 100%;
}

.vm-tree-head .tree-tabs {
    padding: 10px 0 6px;
}

.vm-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    color: var(--muted-2);
    font-size: 10px;
}

.vm-tree {
    flex: 1;
    overflow: auto;
    padding: 8px;
}

.vm-detail {
    min-width: 0;
    overflow: auto;
    padding: 30px;
    background: rgba(8, 11, 16, .82);
}

/* индикатор питания VM */
.pwr {
    display: inline-block;
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    border-radius: 50%;
    box-sizing: border-box;
}

.pwr-on {
    background: var(--green);
    box-shadow: 0 0 8px rgba(54, 211, 153, .75);
}

.pwr-off {
    border: 2px solid var(--red);
    background: transparent;
}

.pwr-suspended {
    background: #ff9830;
    clip-path: polygon(0 0, 38% 0, 38% 100%, 0 100%, 0 0, 62% 0, 100% 0, 100% 100%, 62% 100%, 62% 0);
}

.tn-row.vm-off .tn-name {
    color: var(--muted-2);
}

.tn-row.vm-off.selected .tn-name {
    color: var(--text);
}

.tn-count {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--muted-2);
    font-size: 10px;
}

.vm-controls {
    align-items: center;
}

.vm-detail .details-header {
    align-items: center;
}

.vm-detail .actions {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
}

.card-wide {
    grid-column: span 3;
}

.card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.card-note {
    color: var(--muted-2);
    font-size: 12px;
}

.info-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .04);
    font-size: 12px;
}

.info-row:last-child {
    border-bottom: 0;
}

.info-row > span {
    color: var(--muted);
}

.info-row strong {
    min-width: 0;
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

.nic-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.nic,
.ds {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(255, 255, 255, .02);
}

.nic-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 13px;
}

/* полоса загрузки: цвет по порогу (WARN 70% / CRIT 90%, см. vm.js) */
.meter {
    position: relative;
    height: 20px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 6px;
    background: rgba(255, 255, 255, .07);
}

.meter-fill {
    height: 100%;
    border-radius: 6px;
    transition: width .3s ease;
}

.meter-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.meter.lvl-ok .meter-fill {
    background: rgba(86, 166, 75, .75);
}

.meter.lvl-warn .meter-fill {
    background: rgba(255, 152, 48, .85);
}

.meter.lvl-crit .meter-fill {
    background: rgba(224, 47, 68, .9);
}

.toast-host {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 30000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    max-width: 380px;
    padding: 11px 14px;
    border: 1px solid var(--border-light);
    border-radius: 9px;
    background: #1e2025;
    font-size: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}

.toast-error {
    border-color: rgba(255, 100, 124, .5);
    color: #ff8a9a;
}


/* ==========================================================
   VM TABLE (стиль Grafana-панели)
========================================================== */

.vm-name {
    max-width: 220px;
    color: #fff;
    font-weight: 600;
    word-break: break-word;
}

.vm-folder {
    color: #777;
    font-size: 11px;
}

.power {
    display: inline-block;
    min-width: 70px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.power.on {
    background: rgba(86, 166, 75, .25);
}

.power.off {
    background: rgba(224, 47, 68, .25);
}

.power.suspended {
    background: rgba(255, 152, 48, .25);
}

.action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-right: 5px;
    border: 1px solid #555;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    user-select: none;
    transition: transform .15s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}

.action:hover {
    transform: scale(1.18);
    border-color: #aaa;
    background: rgba(255, 255, 255, .12);
}

.action-on { border-color: rgba(80, 200, 120, .5); }
.action-off { border-color: rgba(220, 50, 70, .5); }
.action-reset { border-color: rgba(255, 180, 0, .5); }
.action-reboot { border-color: rgba(80, 160, 255, .5); }
.action-shutdown { border-color: rgba(220, 80, 80, .5); }
.action-suspend { border-color: rgba(255, 180, 0, .5); }

.action.action-disabled {
    opacity: .25;
    cursor: not-allowed;
    pointer-events: none;
}

.vm-refresh-spinner {
    display: inline-block;
    font-size: 20px;
    line-height: 1;
    cursor: default;
    animation: cl-vm-spin 1s linear infinite;
    opacity: .9;
}

.vm-refresh-spinner.small {
    margin-left: auto;
    font-size: 13px;
}

@keyframes cl-vm-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


/* ==========================================================
   CONSOLE MENU
========================================================== */

.console-menu {
    position: relative;
    display: inline-block;
}

.console-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 105px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #555;
    border-radius: 8px;
    background: rgba(255, 255, 255, .04);
    color: #ddd;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.console-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, .10);
    border-color: #888;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
}

.console-menu.open .console-button {
    background: rgba(255, 255, 255, .12);
    border-color: #aaa;
}

.console-button-disabled,
.console-button:disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}

.console-arrow {
    color: #999;
    font-size: 9px;
    transition: transform .12s ease;
}

.console-menu.open .console-arrow {
    transform: rotate(180deg);
}

.console-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 9999;
    min-width: 155px;
    padding: 5px;
    border: 1px solid #444;
    border-radius: 9px;
    background: #1e2025;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px) scale(.98);
    transform-origin: top right;
    transition: opacity .12s ease, transform .12s ease, visibility .12s ease;
}

.console-menu.open .console-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.console-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 6px;
    color: #ddd;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.console-item:hover {
    background: rgba(255, 255, 255, .10);
    color: #fff;
}

.console-item-icon {
    width: 18px;
    color: #aaa;
    font-size: 15px;
    text-align: center;
}


/* ==========================================================
   CONSOLE PAGE
========================================================== */

.console-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.console-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 14, 19, .94);
}

.console-title {
    font-size: 14px;
    font-weight: 700;
}

.console-status {
    color: var(--muted);
    font-size: 11px;
}

.console-status.ok { color: var(--green); }
.console-status.bad { color: var(--red); }

.console-screen {
    flex: 1;
    min-height: 0;
    background: #000;
}

.console-message {
    position: fixed;
    top: 90px;
    left: 50%;
    max-width: 480px;
    padding: 18px 22px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--panel);
    font-size: 13px;
    line-height: 1.6;
    transform: translateX(-50%);
}


/* ==========================================================
   RESPONSIVE (портал)
========================================================== */

@media (max-width: 1100px) {

    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .card-wide {
        grid-column: span 2;
    }

}

@media (max-width: 800px) {

    .vm-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .vm-tree-panel {
        max-height: 340px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .vm-detail {
        padding: 18px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .card-wide {
        grid-column: auto;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .page {
        padding: 18px;
    }

    .user-name {
        display: none;
    }

}


/* ==========================================================
   PORTAL v5 · USER CHIP, POWER BUTTONS, CONTEXT MENU,
   HOST CARDS, WIZARD
========================================================== */

/* пользователь слева: аватар с зелёным индикатором online */
.avatar-wrap {
    position: relative;
    display: inline-flex;
}

.online-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border: 2px solid var(--panel-3);
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(54, 211, 153, .7);
}

.icon-button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    background: var(--panel-3);
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
}

.icon-button:hover {
    color: var(--text);
    border-color: #3d4d5c;
}

.icon-button:disabled {
    cursor: default;
}

.icon-button.spinning {
    animation: cl-vm-spin 1s linear infinite;
}


/* кнопки питания в стиле портала */
.pbtn-group {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--panel-2);
}

.pbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}

.pbtn-icon {
    font-size: 13px;
}

.pbtn:hover:not(:disabled) {
    background: rgba(255, 255, 255, .07);
    color: var(--text);
}

.pbtn:disabled {
    opacity: .3;
    cursor: not-allowed;
}

.pbtn-on:not(:disabled) .pbtn-icon { color: var(--green); }
.pbtn-off:not(:disabled) .pbtn-icon,
.pbtn-shutdown:not(:disabled) .pbtn-icon { color: var(--red); }
.pbtn-reset:not(:disabled) .pbtn-icon,
.pbtn-suspend:not(:disabled) .pbtn-icon { color: var(--yellow); }
.pbtn-reboot:not(:disabled) .pbtn-icon { color: var(--accent); }

.pbtn-group .vm-refresh-spinner {
    padding: 0 12px;
}

.vm-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
}


/* вкладка "из шаблона" */
.deploy-tab {
    margin-left: auto;
    color: var(--accent);
}


/* контекстное меню */
.ctx-menu {
    position: fixed;
    z-index: 40000;
    min-width: 230px;
    padding: 5px;
    border: 1px solid #444;
    border-radius: 10px;
    background: #1e2025;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
    font-size: 13px;
}

.ctx-menu .ctx-menu {
    position: absolute;
    top: -6px;
    left: 100%;
    display: none;
    margin-left: 2px;
}

.ctx-menu.flip .ctx-menu {
    left: auto;
    right: 100%;
    margin-right: 2px;
}

.ctx-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    color: #ddd;
    cursor: pointer;
    user-select: none;
}

.ctx-item:hover {
    background: rgba(255, 255, 255, .10);
    color: #fff;
}

.ctx-item:hover > .ctx-menu {
    display: block;
}

.ctx-item.disabled {
    opacity: .35;
    cursor: not-allowed;
}

.ctx-item.disabled:hover {
    background: transparent;
}

.ctx-item.danger {
    color: #ff8a9a;
}

.ctx-icon {
    width: 18px;
    color: var(--muted);
    text-align: center;
}

.ctx-label {
    flex: 1;
    white-space: nowrap;
}

.ctx-arrow {
    color: var(--muted);
}

.ctx-sep {
    height: 1px;
    margin: 4px 2px;
    background: #333;
}


/* карточки: миниатюра консоли, хосты */
.card-preview {
    grid-column: span 1;
}

.preview-box {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #000;
}

.preview-box img {
    display: block;
    width: 100%;
    height: auto;
}

.preview-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preview-buttons button {
    width: 100%;
    height: 38px;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.card-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.usage-row {
    margin-bottom: 16px;
}

.usage-head,
.usage-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
}

.usage-head strong {
    font-size: 14px;
}

.usage-foot {
    margin-top: 5px;
    color: var(--muted);
}

.host-hint {
    margin-top: 14px;
}

.warn-hint {
    margin-bottom: 12px;
    color: var(--yellow);
}

.danger-hint {
    margin-bottom: 12px;
    color: var(--red);
}


/* диалоги */
.modal-wide {
    max-width: 720px;
}

.steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.step {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 600;
}

.step.active {
    border-color: var(--accent);
    color: var(--accent);
}

.step.done {
    color: var(--green);
}

.choice-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 340px;
    margin: 10px 0 14px;
    overflow: auto;
}

.choice {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel-2);
    cursor: pointer;
}

.choice:hover {
    border-color: var(--border-light);
}

.choice.selected {
    border-color: var(--accent);
    background: rgba(84, 168, 255, .08);
}

.choice input {
    margin-top: 3px;
    accent-color: var(--accent);
}

.choice span {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 13px;
}

.check {
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 12px;
    line-height: 1.6;
}

.check strong {
    display: block;
    margin-bottom: 3px;
}

.check-ok {
    border-color: rgba(54, 211, 153, .45);
    background: rgba(54, 211, 153, .08);
    color: var(--green);
}

.check-bad {
    border-color: rgba(255, 100, 124, .45);
    background: rgba(255, 100, 124, .08);
    color: #ff8a9a;
}

.check-wait {
    color: var(--muted);
}

.check-warn {
    color: var(--yellow);
}

.map-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    font-size: 13px;
}

.map-table th {
    padding: 6px 8px;
    color: var(--muted);
    font-size: 11px;
    text-align: left;
}

.map-table td {
    padding: 8px;
    border-top: 1px solid var(--border);
    vertical-align: top;
}

.map-table select {
    width: 100%;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: #0a0f14;
    color: var(--text);
}

.map-arrow {
    width: 28px;
    color: var(--muted);
    text-align: center;
}

.snap-list {
    max-height: 280px;
    overflow: auto;
}

.snap-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.snap-row.current {
    background: rgba(54, 211, 153, .05);
}

.snap-main {
    flex: 1;
    min-width: 0;
}

.field input[type="number"] {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: #0a0f14;
    color: var(--text);
    font-size: 13px;
}

.online-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.online-badge i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted-2);
}

.online-badge.on i {
    background: var(--green);
    box-shadow: 0 0 8px rgba(54, 211, 153, .7);
}

@media (max-width: 1100px) {

    .card-grid-2 {
        grid-template-columns: 1fr;
    }

}


/* ==========================================================
   CONSOLE PAGE · key menu, paste dialog
========================================================== */

.console-keys {
    position: relative;
}

.console-keys-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 100;
    display: none;
    gap: 4px;
    padding: 6px;
    border: 1px solid #444;
    border-radius: 8px;
    background: #1e2025;
}

.console-keys-menu.open {
    display: flex;
}

.console-keys-menu button {
    padding: 4px 8px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--panel-3);
    color: var(--text);
    font-size: 11px;
    cursor: pointer;
}

.paste-area {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: #0a0f14;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 12px;
    resize: vertical;
}

.console-bar {
    flex-wrap: wrap;
}
