:root {
    color-scheme: dark;
    --bg: #0b0f14;
    --bg-2: #0e131a;
    --ink: #e6edf3;
    --muted: #9aa7b4;
    --accent: #7ee787;
    --accent-strong: #56d364;
    --accent-warm: #d29922;
    --card: #0f141b;
    --border: #2a323c;
    --shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Mono", monospace;
    color: var(--ink);
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.04),
            rgba(255, 255, 255, 0.04) 1px,
            transparent 1px,
            transparent 28px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.04),
            rgba(255, 255, 255, 0.04) 1px,
            transparent 1px,
            transparent 28px
        );
    opacity: 0.3;
    z-index: 0;
    pointer-events: none;
}

.page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 48px 24px 80px;
    position: relative;
    z-index: 1;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
    animation: none;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.28em;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

h1 {
    font-size: 42px;
    line-height: 1.1;
    margin: 10px 0 12px;
    letter-spacing: -0.02em;
}

.lead {
    font-size: 16px;
    color: var(--muted);
    max-width: 520px;
}

.hero-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    min-width: 220px;
    box-shadow: none;
}

.create-meta {
    position: absolute;
    top: 70px;
    right: 25px;
    width: 260px;
    max-width: 260px;
    z-index: 2;
}

.create-meta.is-subtle {
    opacity: 0.75;
    transform: translateY(2px);
}

.hero-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
}

.hero-card__row:last-child {
    border-bottom: none;
}

.hero-card__label {
    font-size: 12px;
    color: var(--muted);
}

.hero-card__value {
    font-size: 14px;
    font-weight: 600;
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 24px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: none;
    animation: none;
}

.form-panel {
    animation: none;
}

.status-panel {
    animation: none;
}

.field {
    margin-bottom: 20px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.form-actions .primary,
.form-actions .ghost {
    flex: 1;
    width: auto;
    min-width: 180px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.field.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0c1117;
    color: var(--ink);
    font-size: 14px;
    font-family: "IBM Plex Mono", monospace;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: rgba(126, 231, 135, 0.8);
    box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.2);
}

input[type="text"]:-webkit-autofill,
input[type="password"]:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px rgba(36, 36, 38, 0.95) inset;
    -webkit-text-fill-color: var(--ink);
    transition: background-color 9999s ease-out, color 9999s ease-out;
}

select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0c1117;
    color: var(--ink);
    font-size: 14px;
    font-family: "IBM Plex Mono", monospace;
}

select:focus {
    outline: none;
    border-color: rgba(126, 231, 135, 0.8);
    box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.2);
}

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

.inline input {
    flex: 1;
}

.hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.preset-card {
    position: relative;
    cursor: pointer;
}

.preset-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.preset-body {
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border);
    background: #0f141b;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.preset-card:hover .preset-body {
    border-color: rgba(126, 231, 135, 0.35);
}

.preset-card input:checked + .preset-body {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(126, 231, 135, 0.35);
}

.preset-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.preset-note {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
}

.preset-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
}

.primary {
    width: 100%;
    padding: 14px 18px;
    border-radius: 8px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    background: var(--accent);
    color: #0b0f14;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.primary:hover {
    background: var(--accent-strong);
    box-shadow: 0 0 0 1px rgba(126, 231, 135, 0.6);
}

.primary:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.ghost {
    border: 1px solid var(--border);
    background: #0f141b;
    color: var(--ink);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.ghost:hover {
    border-color: rgba(126, 231, 135, 0.6);
    color: #ffffff;
}

.ghost:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ghost-accent {
    border-color: rgba(126, 231, 135, 0.5);
    color: var(--accent);
    box-shadow: 0 0 0 1px rgba(126, 231, 135, 0.2);
}

.ghost-accent:hover {
    border-color: rgba(126, 231, 135, 0.8);
    color: #ffffff;
}

.status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.status-header h2 {
    margin: 0;
    font-size: 20px;
}

.status-pill {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
}

.status-pill.is-running {
    background: rgba(126, 231, 135, 0.18);
    color: var(--accent);
}

.status-pill.is-done {
    background: rgba(126, 231, 135, 0.24);
    color: var(--accent-strong);
}

.status-pill.is-error {
    background: rgba(255, 69, 58, 0.2);
    color: #ff453a;
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0f141b;
}

.step-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.step-title {
    font-size: 13px;
    font-weight: 600;
}

.step-msg {
    font-size: 12px;
    color: var(--muted);
}

.step-state {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.step--running .step-dot {
    background: var(--accent-warm);
}

.step--done .step-dot {
    background: var(--accent);
}

.step--warn .step-dot {
    background: var(--accent-warm);
}

.step--error .step-dot {
    background: #ff453a;
}

.step--skipped .step-dot {
    background: rgba(18, 22, 24, 0.25);
}

.step--running .step-state,
.step--done .step-state {
    color: var(--accent-strong);
}

.step--warn .step-state {
    color: var(--accent-warm);
}

.step--error .step-state {
    color: #ff453a;
}

.step--skipped .step-state {
    color: var(--muted);
}

.result-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    background: #0f141b;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.result-label {
    color: var(--muted);
}

.result-value {
    font-weight: 600;
}

.mono {
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
}

.result-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.result-telegram {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px dashed var(--border);
    background: #0c1117;
    color: var(--ink);
    font-size: 12px;
    font-family: "IBM Plex Mono", monospace;
    resize: vertical;
}

.error-box {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(255, 69, 58, 0.18);
    border: 1px solid rgba(255, 69, 58, 0.5);
    color: #ff453a;
    font-size: 13px;
    display: none;
}

.error-box.is-visible {
    display: block;
}

.error-box.is-success {
    background: rgba(126, 231, 135, 0.18);
    border-color: rgba(126, 231, 135, 0.45);
    color: rgba(200, 255, 215, 0.95);
}

.auth {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-panel {
    max-width: 420px;
    width: 100%;
    text-align: left;
}

.auth-header h1 {
    margin-bottom: 8px;
}

.auth-form {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form label {
    font-size: 13px;
    font-weight: 600;
}

.auth-logout {
    display: inline-flex;
    margin-top: 14px;
    text-decoration: none;
}

.tab-bar {
    display: inline-flex;
    gap: 10px;
    padding: 6px;
    border-radius: 999px;
    background: #0f141b;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.tab-btn.active {
    background: rgba(126, 231, 135, 0.2);
    color: var(--ink);
}

.manage {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.manage-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.manage-header h2 {
    margin: 0;
    font-size: 24px;
}

.manage-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.75fr);
    gap: 20px;
}

.ports-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.ports-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ports-row {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 0.7fr 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0f141b;
    font-size: 12px;
    color: var(--ink);
}

.ports-row > div {
    justify-self: end;
}

.ports-head {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 10px;
    color: var(--muted);
    border-style: dashed;
}

.vm-list-panel {
    padding: 18px;
}

.vm-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

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

.vm-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0f141b;
    padding: 14px;
    text-align: left;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vm-card:hover {
    border-color: rgba(126, 231, 135, 0.35);
}

.vm-card.active {
    border-color: rgba(126, 231, 135, 0.65);
    box-shadow: 0 0 0 1px rgba(126, 231, 135, 0.35);
}

.vm-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vm-card-id {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.vm-card-name {
    font-size: 15px;
    font-weight: 600;
}

.vm-card-ip {
    font-size: 12px;
    color: rgba(200, 255, 215, 0.8);
}

.vm-card-ip:empty {
    display: none;
}

.vm-card-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
}

.vm-card.status--running .status-dot {
    background: rgba(126, 231, 135, 0.9);
}

.vm-card.status--stopped .status-dot {
    background: rgba(148, 148, 160, 0.6);
}

.vm-card.status--paused .status-dot {
    background: rgba(255, 159, 10, 0.8);
}

.vm-card.status--unknown .status-dot {
    background: rgba(255, 255, 255, 0.4);
}

.vm-details-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.vm-details-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.vm-details-eyebrow {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.6);
}

.vm-meta {
    font-size: 13px;
    color: var(--muted);
    margin-top: 6px;
}

.vm-status {
    font-weight: 600;
}

.vm-status--running {
    color: #3fb950;
}

.vm-status--stopped {
    color: #f85149;
}

.vm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.vm-details-empty {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 1000px) {
    .manage-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 960px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero-card {
        width: 100%;
    }

    .create-meta {
        position: static;
        width: 100%;
        max-width: none;
        margin-bottom: 16px;
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 32px;
    }

    .page {
        padding: 36px 18px 60px;
    }

    .inline {
        flex-direction: column;
        align-items: stretch;
    }

    .ports-row {
        grid-template-columns: 1fr 1fr;
    }

    .ports-row span:nth-child(4) {
        grid-column: span 2;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
