:root {
    --bg: #070912;
    --panel: rgba(16, 20, 36, .88);
    --panel-soft: #101528;
    --line: rgba(255,255,255,.08);
    --text: #f5f7ff;
    --muted: #8f98b3;
    --primary: #7c5cff;
    --primary-2: #5b8cff;
    --green: #38d996;
    --red: #ff5d76;
    --blue: #48a8ff;
    --shadow: 0 25px 70px rgba(0,0,0,.38);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Tahoma, Arial, sans-serif;
    background:
        radial-gradient(circle at 75% 0%, rgba(103,76,255,.13), transparent 33%),
        radial-gradient(circle at 20% 90%, rgba(45,127,255,.08), transparent 30%),
        var(--bg);
    color: var(--text);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.login-body {
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 24px;
}

.login-glow {
    position: fixed;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(110px);
    opacity: .22;
    pointer-events: none;
}

.glow-one {
    background: #7255ff;
    top: -180px;
    right: -120px;
}

.glow-two {
    background: #168fff;
    bottom: -220px;
    left: -120px;
}

.login-card {
    position: relative;
    z-index: 2;
    width: min(440px, 100%);
    padding: 40px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: rgba(13, 16, 30, .86);
    backdrop-filter: blur(22px);
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    margin-bottom: 27px;
    border-radius: 20px;
    font-size: 30px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 14px 35px rgba(105,83,255,.35);
}

.brand-mark.small {
    width: 43px;
    height: 43px;
    margin: 0;
    border-radius: 13px;
    font-size: 20px;
}

.login-heading {
    margin-bottom: 28px;
}

.mini-label {
    display: block;
    margin-bottom: 8px;
    color: #9584ff;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.6px;
}

.login-heading h1,
.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.login-heading p,
.topbar p,
.section-head p,
.modal-heading p {
    margin: 9px 0 0;
    color: var(--muted);
    line-height: 1.8;
}

.login-card label,
.field label {
    display: block;
    margin: 17px 0 8px;
    color: #c7cee2;
    font-size: 13px;
    font-weight: bold;
}

.input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
    transition: .2s ease;
}

.input-wrap:focus-within {
    border-color: rgba(124,92,255,.75);
    box-shadow: 0 0 0 4px rgba(124,92,255,.1);
}

.input-wrap input,
.field input {
    width: 100%;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.input-wrap input {
    padding: 15px 0;
}

.primary-btn,
.secondary-btn,
.action-btn {
    border: 0;
    border-radius: 13px;
    color: #fff;
    font-weight: bold;
    transition: .2s ease;
}

.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 13px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 11px 26px rgba(95,79,255,.25);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 35px rgba(95,79,255,.34);
}

.login-btn {
    width: 100%;
    margin-top: 25px;
}

.secure-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    color: var(--muted);
    font-size: 12px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
}

.alert {
    padding: 13px 16px;
    margin: 0 0 20px;
    border-radius: 13px;
    font-size: 13px;
}

.alert-success {
    border: 1px solid rgba(56,217,150,.25);
    color: #82f1c0;
    background: rgba(56,217,150,.09);
}

.alert-danger {
    border: 1px solid rgba(255,93,118,.25);
    color: #ff9bac;
    background: rgba(255,93,118,.09);
}

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

.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 10;
    width: 260px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    border-left: 1px solid var(--line);
    background: rgba(9, 12, 23, .9);
    backdrop-filter: blur(18px);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 7px 28px;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-brand strong {
    font-size: 17px;
}

.sidebar-brand small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 1px;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 13px;
    color: #aab2c9;
    text-decoration: none;
    transition: .2s ease;
}

.nav-item:hover,
.nav-item.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(124,92,255,.2), rgba(124,92,255,.06));
}

.nav-item.active::before {
    position: absolute;
    right: -18px;
    width: 3px;
    height: 27px;
    border-radius: 9px;
    content: "";
    background: var(--primary);
    box-shadow: 0 0 14px var(--primary);
}

.nav-item em {
    margin-right: auto;
    color: #6f7690;
    font-size: 9px;
    font-style: normal;
}

.nav-item.disabled {
    opacity: .62;
    cursor: default;
}

.sidebar-footer {
    margin-top: auto;
}

.admin-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255,255,255,.03);
}

.avatar {
    width: 37px;
    height: 37px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, #5040c3, #347fd3);
    font-weight: bold;
}

.admin-chip strong,
.admin-chip small {
    display: block;
}

.admin-chip strong {
    font-size: 13px;
}

.admin-chip small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}

.logout-link {
    display: block;
    padding: 13px;
    margin-top: 9px;
    text-align: center;
    color: #ff8092;
    text-decoration: none;
    font-size: 12px;
}

.main-content {
    width: calc(100% - 260px);
    margin-right: 260px;
    padding: 35px clamp(22px, 4vw, 55px);
}

.topbar,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.topbar {
    margin-bottom: 28px;
}

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 19px;
    background: linear-gradient(145deg, rgba(255,255,255,.046), rgba(255,255,255,.018));
    box-shadow: 0 15px 35px rgba(0,0,0,.14);
}

.stat-icon {
    width: 49px;
    height: 49px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 15px;
    font-weight: bold;
}

.stat-icon.purple {
    color: #b9acff;
    background: rgba(124,92,255,.16);
}

.stat-icon.green {
    color: #6ceab5;
    background: rgba(56,217,150,.13);
}

.stat-icon.red {
    color: #ff8295;
    background: rgba(255,93,118,.13);
}

.stat-icon.blue {
    color: #71bdff;
    background: rgba(72,168,255,.13);
}

.stat-card span,
.stat-card small {
    display: block;
    color: var(--muted);
}

.stat-card span {
    margin-bottom: 6px;
    font-size: 12px;
}

.stat-card strong {
    display: block;
    margin-bottom: 3px;
    font-size: 24px;
}

.stat-card strong small {
    display: inline;
    font-size: 11px;
}

.stat-card > div > small {
    font-size: 10px;
}

.section-head {
    margin-bottom: 17px;
}

.section-head h2 {
    margin: 0;
    font-size: 19px;
}

.section-head p {
    font-size: 12px;
}

.secondary-btn {
    padding: 11px 15px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.045);
}

.secondary-btn:hover {
    background: rgba(255,255,255,.08);
}

.secondary-btn:disabled,
.action-btn:disabled {
    opacity: .6;
    cursor: wait;
}

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

.host-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 21px;
    background:
        linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
    box-shadow: 0 18px 45px rgba(0,0,0,.18);
    transition: .24s ease;
}

.host-card::after {
    position: absolute;
    top: -60px;
    left: -60px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    content: "";
    background: rgba(124,92,255,.1);
    filter: blur(35px);
}

.host-card:hover {
    transform: translateY(-4px);
    border-color: rgba(124,92,255,.32);
    box-shadow: 0 24px 60px rgba(0,0,0,.27);
}

.host-card.is-disabled {
    opacity: .62;
}

.host-card-top,
.host-title,
.host-mode,
.host-actions {
    display: flex;
    align-items: center;
}

.host-card-top {
    position: relative;
    z-index: 1;
    justify-content: space-between;
    gap: 10px;
}

.host-title {
    gap: 11px;
}

.server-logo {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #b8acff;
    background: rgba(124,92,255,.15);
    font-weight: 900;
}

.host-title h3 {
    max-width: 150px;
    overflow: hidden;
    margin: 0 0 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}

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

.status-badge i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-badge.online {
    color: var(--green);
}

.status-badge.online i {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}

.status-badge.offline {
    color: var(--red);
}

.status-badge.offline i {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}

.status-badge.unknown {
    color: var(--muted);
}

.status-badge.unknown i {
    background: #676e82;
}

.priority-badge {
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: #aeb5ca;
    background: rgba(255,255,255,.035);
    font-size: 10px;
}

.host-url {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    margin: 18px 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0,0,0,.17);
}

.host-url code {
    overflow: hidden;
    color: #afb9d4;
    direction: ltr;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.host-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.host-metrics > div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.025);
}

.host-metrics span,
.host-mode span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 10px;
}

.host-metrics strong {
    font-size: 12px;
}

.host-mode {
    justify-content: space-between;
    padding: 14px 2px;
    margin-top: 5px;
}

.host-mode span {
    margin: 0;
}

.enabled-text {
    color: var(--green);
    font-size: 11px;
}

.disabled-text {
    color: var(--red);
    font-size: 11px;
}

.host-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
}

.host-actions form {
    margin: 0;
}

.action-btn {
    width: 100%;
    min-height: 37px;
    padding: 8px 5px;
    font-size: 10px;
}

.action-btn.test {
    color: #79c5ff;
    background: rgba(72,168,255,.12);
}

.action-btn.edit {
    color: #b7aaff;
    background: rgba(124,92,255,.13);
}

.action-btn.toggle {
    color: #ffd072;
    background: rgba(255,184,61,.11);
}

.action-btn.delete {
    color: #ff899a;
    background: rgba(255,93,118,.11);
}

.action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.18);
}

.empty-state {
    padding: 65px 20px;
    border: 1px dashed rgba(255,255,255,.13);
    border-radius: 22px;
    text-align: center;
    background: rgba(255,255,255,.02);
}

.empty-icon {
    margin-bottom: 12px;
    font-size: 40px;
}

.empty-state h3 {
    margin: 0 0 9px;
}

.empty-state p {
    margin: 0 0 21px;
    color: var(--muted);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(2, 4, 12, .78);
    backdrop-filter: blur(8px);
}

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

.modal-card {
    position: relative;
    width: min(560px, 100%);
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: #101426;
    box-shadow: var(--shadow);
    animation: modalIn .22s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: #abb3c9;
    background: rgba(255,255,255,.035);
    font-size: 20px;
}

.modal-heading h2 {
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 22px;
}

.field.full {
    grid-column: 1 / -1;
}

.field input {
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.035);
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124,92,255,.09);
}

.field small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 10px;
}

.switch-field {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.switch {
    position: relative;
    width: 52px;
    height: 28px;
    margin-top: 4px !important;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    inset: 0;
    border-radius: 30px;
    background: #30364b;
    transition: .2s;
}

.slider::before {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    content: "";
    background: #fff;
    transition: .2s;
}

.switch input:checked + .slider {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.switch input:checked + .slider::before {
    transform: translateX(-24px);
}

.modal-submit {
    width: 100%;
    margin-top: 25px;
}

@media (max-width: 1150px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 760px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar nav {
        display: flex;
        overflow-x: auto;
    }

    .sidebar-footer {
        display: none;
    }

    .app-shell {
        display: block;
    }

    .main-content {
        width: 100%;
        margin: 0;
        padding: 24px 15px;
    }

    .topbar,
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar .primary-btn,
    .section-head .secondary-btn {
        width: 100%;
    }

    .stats-grid,
    .hosts-grid {
        grid-template-columns: 1fr;
    }

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

    .field.full {
        grid-column: auto;
    }

    .login-card {
        padding: 30px 22px;
    }
}
