:root {
    color-scheme: dark;
    --bg: #071017;
    --bg-soft: #0c1721;
    --panel: rgba(18, 30, 42, 0.92);
    --panel-strong: #132333;
    --text: #f4f8fb;
    --muted: #94a8b8;
    --line: rgba(151, 178, 198, 0.2);
    --primary: #27c4ff;
    --primary-2: #2f7cff;
    --success: #31d18b;
    --warning: #ffd166;
    --error-bg: rgba(255, 92, 92, 0.16);
    --error-text: #ffb7b7;
    --success-bg: rgba(49, 209, 139, 0.14);
    --success-text: #a8f2ce;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 20% 0%, rgba(39, 196, 255, 0.18), transparent 32rem),
        linear-gradient(180deg, #071017 0%, #0a121a 52%, #071017 100%);
    color: var(--text);
}

.shell {
    width: min(1040px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.panel,
.metric-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(18px);
}

.login-panel {
    max-width: 460px;
    margin: 44px auto 0;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.brand-mark.compact {
    margin-bottom: 10px;
}

.brand-logo {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 16px;
    object-fit: cover;
    object-position: center;
    background: #081323;
    box-shadow: 0 10px 28px rgba(39, 196, 255, 0.32);
}

.brand {
    color: var(--text);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0;
    margin-bottom: 2px;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 34px;
    line-height: 1.12;
}

h2 {
    font-size: 18px;
    margin-bottom: 18px;
}

.muted {
    color: var(--muted);
    line-height: 1.55;
}

.actions {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.button,
.telegram-auth-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: auto;
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.button:hover,
.telegram-auth-button:hover {
    transform: translateY(-1px);
    border-color: rgba(39, 196, 255, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.button:focus-visible,
.telegram-auth-button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(39, 196, 255, 0.28);
    outline-offset: 2px;
}

.button.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-color: transparent;
    color: #061018;
    box-shadow: 0 12px 28px rgba(47, 124, 255, 0.32);
}

.button.primary:hover {
    background: linear-gradient(135deg, #50d4ff, #4c91ff);
}

.button.full {
    width: 100%;
    margin-top: 14px;
}

.button.small {
    width: auto;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 14px;
}

.button.ghost {
    opacity: 0.62;
    cursor: default;
}

.button.ghost:hover {
    transform: none;
}

.telegram-auth-button {
    width: 100%;
}

.auth-option {
    width: 100%;
}

.icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
}

.telegram-auth-icon {
    border-radius: 50%;
    background: #229ed9;
}

.telegram-auth-icon::before {
    content: "";
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 12px solid #ffffff;
    transform: translateX(1px) rotate(-22deg);
}

.email-icon {
    border: 2px solid currentColor;
    border-radius: 7px;
}

.email-icon::before,
.email-icon::after {
    content: "";
    position: absolute;
    top: 9px;
    width: 12px;
    height: 2px;
    background: currentColor;
}

.email-icon::before {
    left: 2px;
    transform: rotate(34deg);
}

.email-icon::after {
    right: 2px;
    transform: rotate(-34deg);
}

.id-icon {
    border: 2px solid currentColor;
    border-radius: 8px;
}

.id-icon::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 9px 0 -2px currentColor;
}

.form {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

input {
    width: 100%;
    min-height: 50px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font: inherit;
}

input::placeholder {
    color: #718898;
}

.link {
    display: inline-block;
    margin-top: 18px;
    color: #7fdcff;
    font-weight: 800;
    text-decoration: none;
}

.alert {
    border-radius: 18px;
    margin: 16px 0;
    padding: 13px 14px;
    font-weight: 800;
    line-height: 1.35;
}

.alert.error {
    background: var(--error-bg);
    color: var(--error-text);
}

.alert.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: 18px;
    margin-bottom: 18px;
}

.status-card,
.key-card {
    min-height: 284px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 900;
    margin-bottom: 12px;
}

.status-badge.ok {
    background: rgba(49, 209, 139, 0.16);
    color: #9cf0c9;
}

.status-badge.pending {
    background: rgba(255, 209, 102, 0.16);
    color: #ffe2a0;
}

.status-badge.idle {
    background: rgba(148, 168, 184, 0.14);
    color: #c0ced8;
}

.status-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.status-row span,
.metric-card span {
    color: var(--muted);
}

.status-row strong {
    text-align: right;
}

.copy-input {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qr {
    display: block;
    width: 184px;
    height: 184px;
    margin: 18px auto 0;
    border-radius: 20px;
    background: #ffffff;
    padding: 10px;
}

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

.metric-card {
    min-height: 96px;
    padding: 18px;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 18px;
}

.steps {
    margin: 0 0 22px;
    padding-left: 20px;
    line-height: 1.75;
    color: var(--muted);
}

.server-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.server-list span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #dbe8f0;
    font-weight: 800;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 4px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 720px) {
    .shell {
        width: min(100% - 24px, 960px);
        padding: 18px 0;
    }

    .login-panel {
        margin-top: 14px;
    }

    .panel {
        padding: 20px;
    }

    .grid,
    .topbar,
    .metrics-grid {
        display: grid;
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: stretch;
    }

    h1 {
        font-size: 30px;
    }

    .status-card,
    .key-card {
        min-height: auto;
    }
}
