:root {
    --bg-0: #040915;
    --bg-1: #07111f;
    --bg-2: #0b1729;
    --bg-3: #0f1e35;

    --panel: rgba(12, 22, 39, 0.82);
    --panel-2: rgba(18, 31, 54, 0.92);
    --card: rgba(25, 40, 67, 0.90);
    --card-2: rgba(35, 57, 92, 0.92);
    --card-3: rgba(43, 70, 112, 0.94);

    --text: #eef5ff;
    --text-soft: #d9e5f8;
    --muted: #99acc9;
    --muted-2: #7d91b3;

    --line: rgba(255,255,255,0.08);
    --line-2: rgba(255,255,255,0.12);

    --blue: #4f8cff;
    --blue-2: #3b82f6;
    --green: #22c55e;
    --green-2: #16a34a;
    --red: #ef4444;
    --red-2: #dc2626;
    --amber: #f59e0b;
    --amber-2: #d97706;
    --slate: #64748b;
    --slate-2: #475569;
    --cyan: #06b6d4;
    --purple: #8b5cf6;

    --shadow-xl: 0 28px 80px rgba(0,0,0,0.40);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.30);
    --shadow-md: 0 12px 28px rgba(0,0,0,0.24);

    --r-2xl: 28px;
    --r-xl: 22px;
    --r-lg: 18px;
    --r-md: 14px;
    --r-sm: 10px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: Inter, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 0% 0%, rgba(79,140,255,0.15), transparent 24%),
        radial-gradient(circle at 100% 0%, rgba(6,182,212,0.12), transparent 22%),
        radial-gradient(circle at 50% 100%, rgba(139,92,246,0.10), transparent 22%),
        linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 30%, var(--bg-2) 70%, var(--bg-3) 100%);
}

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

img {
    max-width: 100%;
}

button,
input,
textarea,
select {
    font: inherit;
}

.page-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 290px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 18px;
    background: rgba(8, 15, 28, 0.82);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.brand-box {
    padding: 18px;
    border-radius: var(--r-xl);
    background:
        linear-gradient(180deg, rgba(79,140,255,0.10), rgba(79,140,255,0.03)),
        rgba(17, 29, 49, 0.90);
    border: 1px solid rgba(79,140,255,0.14);
    box-shadow: var(--shadow-md);
}

.brand-mini {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(79,140,255,0.12);
    color: #dbeafe;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 12px;
}

.brand-title {
    margin: 0;
    font-size: 30px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.04em;
}

.brand-subtitle {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.nav-section {
    margin-top: 22px;
}

.nav-caption {
    color: var(--muted-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
    padding: 0 10px 10px;
}

.nav-list {
    display: grid;
    gap: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px;
    border-radius: 14px;
    color: #dde8fb;
    font-weight: 800;
    border: 1px solid transparent;
    transition: 0.18s ease;
}

.nav-link::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.20);
    flex: 0 0 8px;
}

.nav-link:hover {
    background: rgba(79,140,255,0.08);
    border-color: rgba(79,140,255,0.10);
    transform: translateX(2px);
}

.nav-link.active {
    background: linear-gradient(180deg, rgba(79,140,255,0.18), rgba(79,140,255,0.08));
    border-color: rgba(79,140,255,0.14);
}

.nav-link.active::before {
    background: var(--blue);
    box-shadow: 0 0 0 4px rgba(79,140,255,0.10);
}

.sidebar-user {
    margin-top: 24px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(17, 29, 49, 0.92);
    border: 1px solid var(--line);
}

.sidebar-user-label {
    color: var(--muted-2);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.sidebar-user-name {
    font-size: 16px;
    font-weight: 900;
}

.sidebar-user-email {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    word-break: break-word;
}

.main-content {
    padding: 24px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px 18px;
    border-radius: 22px;
    background: rgba(13, 22, 38, 0.72);
    border: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.topbar-breadcrumbs {
    color: var(--muted-2);
    font-size: 13px;
    margin-bottom: 8px;
}

.page-title {
    margin: 0;
    font-size: 36px;
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 1.06;
}

.page-subtitle {
    margin-top: 8px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.65;
    max-width: 860px;
}

.topbar-actions,
.user-actions,
.client-actions,
.inline-actions,
.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.flash {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    font-weight: 800;
    border: 1px solid transparent;
    backdrop-filter: blur(10px);
}

.flash.success {
    background: rgba(34,197,94,0.12);
    color: #bbf7d0;
    border-color: rgba(34,197,94,0.22);
}

.flash.error {
    background: rgba(239,68,68,0.12);
    color: #fecaca;
    border-color: rgba(239,68,68,0.20);
    word-break: break-word;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 16px;
    margin-bottom: 20px;
}

.hero-panel,
.quick-panel {
    border-radius: var(--r-2xl);
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)),
        rgba(19, 31, 53, 0.95);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
}

.hero-panel {
    padding: 22px;
    background:
        radial-gradient(circle at top right, rgba(79,140,255,0.18), transparent 28%),
        linear-gradient(180deg, rgba(22,36,61,0.96), rgba(18,31,53,0.96));
}

.hero-kicker {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(79,140,255,0.12);
    color: #dbeafe;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 12px;
}

.hero-title {
    margin: 0;
    font-size: 34px;
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 1.06;
}

.hero-text {
    margin-top: 10px;
    color: var(--muted);
    line-height: 1.65;
    max-width: 740px;
}

.quick-panel {
    padding: 22px;
}

.quick-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 900;
}

.quick-subtitle {
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 18px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)),
        rgba(18, 31, 54, 0.94);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
}

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

.stat-value {
    font-size: 30px;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.card {
    margin-bottom: 20px;
    border-radius: var(--r-2xl);
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)),
        rgba(19, 31, 53, 0.95);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
}

.card-head {
    padding: 22px 24px 12px;
}

.card-body {
    padding: 0 24px 24px;
}

.card-title {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.card-subtitle {
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.6;
}

.info-strip {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(10,18,33,0.88);
    border: 1px solid rgba(79,140,255,0.10);
    color: #dbeafe;
    line-height: 1.6;
}

.form-grid-2,
.form-grid-3,
.form-grid-4 {
    display: grid;
    gap: 12px;
}

.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: 1.2fr 1fr 0.8fr 0.8fr; }

.input,
textarea,
select {
    width: 100%;
    padding: 14px 15px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(54, 73, 104, 0.82);
    color: var(--text);
    outline: none;
    transition: 0.18s ease;
}

.input::placeholder,
textarea::placeholder {
    color: #95aacb;
}

.input:focus,
textarea:focus,
select:focus {
    border-color: rgba(79,140,255,0.35);
    box-shadow: 0 0 0 4px rgba(79,140,255,0.10);
}

.form-actions {
    margin-top: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 16px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    color: #fff;
    transition: 0.18s ease;
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn.full {
    width: 100%;
}

.btn.blue { background: linear-gradient(180deg, #5d9bff, #3b82f6); }
.btn.green { background: linear-gradient(180deg, #2dd46d, #16a34a); }
.btn.red { background: linear-gradient(180deg, #f46565, #dc2626); }
.btn.amber { background: linear-gradient(180deg, #f8be4f, #d97706); }
.btn.slate { background: linear-gradient(180deg, #7a8ca7, #475569); }

.server-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.server-card,
.user-row,
.inbound-card {
    margin-top: 16px;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(49,69,101,0.88), rgba(39,57,86,0.90));
    border: 1px solid rgba(255,255,255,0.06);
}

.server-card {
    margin-top: 0;
}

.server-head,
.user-row-head,
.inbound-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.server-name {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.server-url,
.inline-meta {
    margin-top: 6px;
    color: var(--muted);
    line-height: 1.6;
    word-break: break-all;
}

.server-health {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(10,18,33,0.55);
    border: 1px solid var(--line);
    color: var(--text-soft);
    font-size: 14px;
}

.button-row-2,
.button-row-3 {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

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

.section-divider {
    margin: 18px 0;
    height: 1px;
    background: var(--line);
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.badge.blue { background: rgba(79,140,255,0.16); color: #bfdbfe; }
.badge.green { background: rgba(34,197,94,0.16); color: #bbf7d0; }
.badge.red { background: rgba(239,68,68,0.16); color: #fecaca; }
.badge.amber { background: rgba(245,158,11,0.16); color: #fde68a; }
.badge.gray { background: rgba(148,163,184,0.16); color: #e2e8f0; }
.badge.purple { background: rgba(139,92,246,0.18); color: #ddd6fe; }

.table-wrap {
    overflow-x: auto;
    margin-top: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(10,18,33,0.55);
}

.table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.table th {
    background: rgba(17, 27, 46, 0.72);
    color: #d4e4ff;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.table td {
    color: #f2f7ff;
}

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

.mono-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mono-text {
    display: inline-block;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(8,14,26,0.72);
    border: 1px solid rgba(255,255,255,0.06);
    font-family: "Courier New", monospace;
    font-size: 12px;
    color: #d9e7ff;
    word-break: break-all;
}

.code-box {
    background: rgba(8, 14, 26, 0.96);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 18px;
    padding: 16px;
    color: #d9e7ff;
    font-family: "Courier New", monospace;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
}

.copy-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.copy-row .code-box {
    flex: 1;
    min-width: 280px;
}

.qr-box {
    display: inline-block;
    padding: 16px;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: var(--shadow-md);
}

.qr-box img {
    display: block;
    max-width: 280px;
    width: 100%;
}

.empty-state {
    padding: 20px;
    border-radius: 18px;
    background: rgba(14,22,37,0.7);
    color: var(--muted);
    border: 1px dashed rgba(255,255,255,0.10);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 620px;
    border-radius: 30px;
    padding: 30px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)),
        rgba(18, 29, 49, 0.96);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: var(--shadow-xl);
}

.login-title {
    margin: 0;
    font-size: 40px;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.login-subtitle {
    margin-top: 10px;
    margin-bottom: 18px;
    color: var(--muted);
    line-height: 1.65;
}

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

.hero-mini {
    padding: 14px;
    border-radius: 18px;
    background: rgba(37, 56, 85, 0.80);
    border: 1px solid rgba(255,255,255,0.06);
}

.hero-mini-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.hero-mini-value {
    font-size: 18px;
    font-weight: 900;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 14, 0.74);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 460px;
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)),
        rgba(19, 31, 53, 0.98);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-head {
    padding: 20px 22px 10px;
}

.modal-title {
    margin: 0;
    font-size: 22px;
    font-weight: 900;
}

.modal-body {
    padding: 0 22px 22px;
    color: var(--muted);
    line-height: 1.65;
}

.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.toast-wrap {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10000;
    display: grid;
    gap: 10px;
}

.toast {
    min-width: 240px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(18, 29, 49, 0.96);
    color: #e5efff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
}

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

    .sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

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

@media (max-width: 980px) {
    .server-grid,
    .stats-grid,
    .hero-strip,
    .form-grid-2,
    .form-grid-3,
    .form-grid-4,
    .button-row-2,
    .button-row-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .main-content {
        padding: 16px;
    }

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

    .topbar,
    .server-head,
    .user-row-head,
    .inbound-head {
        flex-direction: column;
    }

    .topbar-actions,
    .user-actions,
    .client-actions,
    .inline-actions,
    .quick-actions {
        width: 100%;
        flex-direction: column;
    }

    .topbar-actions .btn,
    .user-actions .btn,
    .client-actions .btn,
    .inline-actions .btn,
    .quick-actions .btn {
        width: 100%;
    }

    .copy-row {
        flex-direction: column;
    }
}
