:root {
    --bg: #0f172a;
    --bg-soft: #111827;
    --card: #1e293b;
    --card-light: #263449;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --danger: #ef4444;
    --success: #22c55e;
    --border: rgba(148, 163, 184, 0.2);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: radial-gradient(circle at top, #1e293b 0, #0f172a 45%);
    color: var(--text);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--border);
    padding: 24px 18px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 32px;
}

.logo span {
    color: var(--accent);
}

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

.nav a {
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--muted);
    transition: 0.2s;
}

.nav a:hover,
.nav a.active {
    background: var(--card);
    color: var(--text);
}

.content {
    margin-left: 260px;
    width: calc(100% - 260px);
    padding: 32px;
}

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

.page-title {
    font-size: 28px;
    margin: 0 0 8px;
}

.page-subtitle {
    color: var(--muted);
    margin: 0;
}

.user-box {
    background: var(--card);
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    color: var(--muted);
}

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

.card {
    background: linear-gradient(180deg, var(--card), var(--bg-soft));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

.card-title {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 10px;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
}

.card-hint {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    background: var(--accent);
    color: #00111f;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--card-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.keys-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.key-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.key-name {
    font-size: 18px;
    font-weight: 700;
}

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
    background: rgba(34, 197, 94, 0.14);
    color: #bbf7d0;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge-muted {
    background: rgba(148, 163, 184, 0.12);
    color: var(--muted);
    border-color: var(--border);
}

.key-value {
    background: #020617;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    color: #cbd5e1;
    font-size: 13px;
    overflow-x: auto;
    white-space: nowrap;
    margin-bottom: 14px;
}

.key-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

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

.login-card {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(180deg, var(--card), var(--bg-soft));
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.login-title {
    margin: 0 0 8px;
    font-size: 28px;
}

.login-subtitle {
    margin: 0 0 24px;
    color: var(--muted);
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
}

input {
    width: 100%;
    padding: 13px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #020617;
    color: var(--text);
    outline: none;
}

input:focus {
    border-color: var(--accent);
}

.form-footer {
    margin-top: 20px;
}

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
    }

    .layout {
        flex-direction: column;
    }

    .content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }

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

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

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

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.alert-success {
    background: rgba(34, 197, 94, 0.14);
    color: #bbf7d0;
    border-color: rgba(34, 197, 94, 0.35);
}

.alert-error {
    background: rgba(239, 68, 68, 0.14);
    color: #fecaca;
    border-color: rgba(239, 68, 68, 0.35);
}

.empty-state {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    color: var(--muted);
}
.alerts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.alert-success {
    background: rgba(34, 197, 94, 0.14);
    color: #bbf7d0;
    border-color: rgba(34, 197, 94, 0.35);
}

.alert-error {
    background: rgba(239, 68, 68, 0.14);
    color: #fecaca;
    border-color: rgba(239, 68, 68, 0.35);
}

.empty-state {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    color: var(--muted);
}
/* ===== Mobile optimization ===== */

@media (max-width: 700px) {
    body {
        background: #0f172a;
    }

    .layout {
        display: block;
        min-height: 100vh;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 50;
        width: 100%;
        height: auto;
        padding: 14px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(10px);
    }

    .logo {
        font-size: 20px;
        margin-bottom: 14px;
        text-align: center;
    }

    .nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .nav a {
        text-align: center;
        padding: 10px 8px;
        font-size: 14px;
        border-radius: 10px;
        background: rgba(30, 41, 59, 0.55);
    }

    .content {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 18px;
    }

    .page-title {
        font-size: 24px;
        line-height: 1.2;
    }

    .page-subtitle {
        font-size: 14px;
        line-height: 1.5;
    }

    .user-box {
        width: 100%;
        font-size: 14px;
        text-align: center;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 18px;
    }

    .card {
        padding: 16px;
        border-radius: 16px;
    }

    .card-value {
        font-size: 24px;
        line-height: 1.2;
    }

    .keys-list {
        gap: 14px;
    }

    .key-card {
        padding: 16px;
        border-radius: 16px;
    }

    .key-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
    }

    .key-name {
        font-size: 17px;
    }

    .badge {
        width: fit-content;
    }

    .key-value {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        font-size: 12px;
        line-height: 1.45;
        max-height: 140px;
        overflow-y: auto;
    }

    .key-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .key-actions form,
    .key-actions button,
    .key-actions a {
        width: 100%;
    }

    .btn {
        width: 100%;
        min-height: 44px;
        padding: 12px 14px;
        font-size: 15px;
    }

    .topbar form,
    .topbar button {
        width: 100%;
    }

    .alerts {
        margin-bottom: 14px;
    }

    .alert {
        font-size: 14px;
        line-height: 1.45;
    }

    .empty-state {
        padding: 20px;
        font-size: 14px;
        line-height: 1.5;
    }

    .login-page {
        align-items: flex-start;
        padding: 18px;
        padding-top: 44px;
    }

    .login-card {
        max-width: 100%;
        padding: 24px 18px;
        border-radius: 20px;
    }

    .login-title {
        font-size: 25px;
    }

    .login-subtitle {
        font-size: 14px;
        line-height: 1.5;
    }

    input {
        min-height: 46px;
        font-size: 16px;
    }
}

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

    .content {
        padding: 12px;
    }

    .card,
    .key-card {
        padding: 14px;
    }

    .page-title {
        font-size: 22px;
    }

    .card-value {
        font-size: 22px;
    }

    .key-value {
        font-size: 11.5px;
    }
}
.copy-source {
    width: 100%;
    min-height: 52px;
    resize: vertical;
    font-family: monospace;
    cursor: text;
}

.copy-source:focus {
    outline: 1px solid var(--accent);
}
.server-create-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.server-select {
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #020617;
    color: var(--text);
    padding: 0 14px;
    outline: none;
}

.server-select:focus {
    border-color: var(--accent);
}

@media (max-width: 700px) {
    .server-create-form {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .server-select {
        width: 100%;
        min-height: 46px;
        font-size: 15px;
    }
}
/* ===== Collapsible mobile menu ===== */

.mobile-menu-head {
    display: block;
}

.mobile-menu-btn {
    display: none;
}

@media (max-width: 700px) {
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 100;
        width: 100%;
        padding: 12px 16px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(10px);
    }

    .mobile-menu-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .logo {
        margin-bottom: 0;
        font-size: 20px;
        text-align: left;
    }

    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 38px;
        padding: 8px 12px;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: var(--card);
        color: var(--text);
        font-weight: 700;
        cursor: pointer;
    }

    .sidebar .nav {
        display: none;
        margin-top: 12px;
    }

    .sidebar.menu-open .nav {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .sidebar.menu-open .nav a {
        text-align: center;
        padding: 12px 10px;
        border-radius: 12px;
        background: rgba(30, 41, 59, 0.75);
    }

    .content {
        padding-top: 18px;
    }
}
/* ===== Instructions page ===== */

.instruction-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.instruction-tab {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.instruction-tab:hover {
    background: var(--card-light);
}

.instruction-tab.active {
    background: var(--accent);
    color: #00111f;
    border-color: var(--accent);
}

.instruction-block {
    display: none;
}

.instruction-block.active {
    display: block;
}

.instruction-steps {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.instruction-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.45);
}

.step-number {
    min-width: 34px;
    height: 34px;
    border-radius: 999px;
    background: var(--accent);
    color: #00111f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.instruction-step h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.instruction-step p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.instruction-note {
    margin-top: 18px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.28);
    color: #bae6fd;
    line-height: 1.5;
}

code {
    background: #020617;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 5px;
    color: #e5e7eb;
}

@media (max-width: 700px) {
    .instruction-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .instruction-tab {
        width: 100%;
        min-height: 44px;
        padding: 11px 12px;
    }

    .instruction-step {
        padding: 14px;
        gap: 12px;
    }

    .step-number {
        min-width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .instruction-step h3 {
        font-size: 16px;
    }

    .instruction-step p {
        font-size: 14px;
    }
}
.instruction-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.routing-config-box {
    min-height: 84px;
    margin-bottom: 16px;
}

.instruction-image {
    display: block;
    width: 100%;
    max-width: 360px;
    margin-top: 14px;
    border-radius: 22px;
    border: 1px solid var(--border);
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.25);
}

.instruction-images-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 360px));
    gap: 16px;
    align-items: start;
}

@media (max-width: 700px) {
    .instruction-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .instruction-actions .btn {
        width: 100%;
    }

    .instruction-images-grid {
        grid-template-columns: 1fr;
    }

    .instruction-image {
        max-width: 100%;
        border-radius: 18px;
    }

    .routing-config-box {
        min-height: 110px;
        font-size: 11px;
    }
}
.instruction-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.instruction-actions .btn,
.instruction-actions a.btn,
.instruction-actions button.btn {
    width: auto;
}

.routing-config-box {
    min-height: 76px;
    margin-bottom: 18px;
}

.instruction-image {
    display: block;
    width: 100%;
    max-width: 360px;
    border-radius: 18px;
    border: 1px solid var(--border);
    margin-top: 14px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.25);
}

.instruction-images-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 320px));
    gap: 14px;
    align-items: start;
    margin-top: 14px;
}

.instruction-images-grid .instruction-image {
    margin-top: 0;
}

.instruction-inner-card {
    margin-top: 18px;
    background: rgba(15, 23, 42, 0.35);
}

@media (max-width: 700px) {
    .instruction-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .instruction-actions .btn,
    .instruction-actions a.btn,
    .instruction-actions button.btn {
        width: 100%;
    }

    .instruction-images-grid {
        grid-template-columns: 1fr;
    }

    .instruction-image {
        max-width: 100%;
        border-radius: 14px;
    }

    .routing-config-box {
        min-height: 90px;
        font-size: 11px;
    }
}
