* { box-sizing: border-box; }

:root {
    --glass-bg: rgba(255, 255, 255, 0.16);
    --glass-border: rgba(255, 255, 255, 0.62);
    --glass-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), inset 0 1px 1px rgba(255, 255, 255, 0.85), inset 0 -1px 1px rgba(255, 255, 255, 0.25);
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --accent-blue: #005fe7;
    --accent-green: #1fb416;
    --accent-red: #b41616;
}

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

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-main);
    background: #f5f7fa;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

.bg-mesh {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 15% 25%, rgba(0, 95, 231, 0.14) 0%, transparent 35%),
        radial-gradient(circle at 85% 15%, rgba(31, 180, 22, 0.11) 0%, transparent 30%),
        radial-gradient(circle at 75% 85%, rgba(180, 22, 22, 0.09) 0%, transparent 30%),
        radial-gradient(circle at 40% 90%, rgba(0, 95, 231, 0.09) 0%, transparent 35%),
        linear-gradient(135deg, #e0e7ff 0%, #f0f4ff 40%, #f5f7fa 70%, #e0f2fe 100%);
    background-size: cover;
    animation: meshMove 24s ease-in-out infinite alternate;
}

@keyframes meshMove {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.06) translate(-1.5%, -1%); }
}

.container {
    position: relative;
    max-width: 1320px;
    margin: 0 auto;
    margin-left: 240px;
    padding: 28px 24px 40px;
    transition: margin-left .3s ease;
}

.container.shifted {
    margin-left: 320px;
}

/* Liquid glass */
.liquid-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(44px) saturate(240%) brightness(1.06);
    -webkit-backdrop-filter: blur(44px) saturate(240%) brightness(1.06);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
}

.liquid-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    right: -40%;
    height: 55%;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0.15) 45%, transparent 70%);
    pointer-events: none;
}

.liquid-glass::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.4) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.glass-header {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    padding: 28px 22px;
    margin-bottom: 0;
    border-radius: 0;
    z-index: 90;
}

.glass-header h1 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    position: relative;
    line-height: 1.3;
}

.glass-header p {
    margin: 0;
    color: var(--text-sub);
    font-size: 12px;
    position: relative;
    line-height: 1.5;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 0 0 rgba(31, 180, 22, 0.5);
    animation: pulse 1.8s infinite;
    position: relative;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(31, 180, 22, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(31, 180, 22, 0); }
    100% { box-shadow: 0 0 0 0 rgba(31, 180, 22, 0); }
}

.pulse-dot.disconnected {
    background: var(--accent-red);
    animation: none;
    box-shadow: 0 0 0 0 rgba(180, 22, 22, 0.5);
}

/* Hero cards */
.hero {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.hero-card {
    padding: 20px 24px;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.hero-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.9), inset 0 -1px 1px rgba(255, 255, 255, 0.3);
}

.hero-card.active {
    border-width: 2px;
}

.hero-card.all.active { border-color: var(--accent-blue); }
.hero-card.online.active { border-color: var(--accent-green); }
.hero-card.offline.active { border-color: var(--accent-red); }

.hero-title {
    font-size: 14px;
    color: var(--text-sub);
    margin-bottom: 14px;
    font-weight: 500;
    position: relative;
}

.hero-value {
    display: flex;
    align-items: center;
    position: relative;
}

.hero-dot {
    width: 8px;
    height: 8px;
    border-radius: 10px;
    margin-right: 8px;
}

.hero-num {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
}

.hero-num-small {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Nodes grid */
.nodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.node-card {
    padding: 0;
    transition: transform .15s, box-shadow .15s;
    border-left: 4px solid var(--accent-green);
}

.node-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.11), inset 0 1px 1px rgba(255, 255, 255, 0.9), inset 0 -1px 1px rgba(255, 255, 255, 0.3);
}

.node-card.offline {
    opacity: .72;
    border-left-color: var(--accent-red);
}

.node-card.waiting {
    text-align: center;
    color: var(--text-sub);
    padding: 48px;
    grid-column: 1 / -1;
    border-left-color: transparent;
}

.node-inner {
    padding: 20px;
    position: relative;
}

.node-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.node-name {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    word-break: break-all;
    line-height: 1.3;
}

.node-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
    margin-left: 10px;
    position: relative;
    flex-shrink: 0;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.node-status.online {
    background: rgba(31, 180, 22, 0.12);
    color: #158a0d;
}
.node-status.online .status-dot { background: var(--accent-green); }

.node-status.offline {
    background: rgba(180, 22, 22, 0.12);
    color: #9a1212;
}
.node-status.offline .status-dot { background: var(--accent-red); }

.node-meta {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 14px;
    line-height: 1.5;
    position: relative;
}

.node-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
    position: relative;
}

.stat-item {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    padding: 8px 10px;
    text-align: center;
}

.stat-value {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.stat-label {
    font-size: 11px;
    color: var(--text-sub);
    margin-top: 2px;
}

.metric {
    margin-bottom: 10px;
    position: relative;
}

.metric-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.metric-name {
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
}

.metric-icon.cpu { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
.metric-icon.mem { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.metric-icon.swap { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.metric-icon.disk { background: linear-gradient(135deg, #10b981, #34d399); }

.metric-value {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
    color: #374151;
    font-weight: 600;
}

.metric-bar {
    height: 7px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.metric-bar > div {
    height: 100%;
    border-radius: 4px;
    transition: width .4s ease;
}

.metric-bar > div.low { background: linear-gradient(90deg, #22c55e, #4ade80); }
.metric-bar > div.mid { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.metric-bar > div.high { background: linear-gradient(90deg, #ef4444, #f87171); }

.network-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
}

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

.network-box {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 14px;
    padding: 12px 8px;
    text-align: center;
    transition: background .15s;
}

.network-box:hover {
    background: rgba(0, 0, 0, 0.05);
}

.network-icon {
    width: 28px;
    height: 28px;
    margin: 0 auto 6px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.network-icon.up { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
.network-icon.down { background: linear-gradient(135deg, #10b981, #34d399); }

.network-rate {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    margin-bottom: 3px;
}

.network-total {
    font-size: 11px;
    color: #6b7280;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Responsive */
@media (max-width: 1200px) {
    .hero {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        margin-left: 0;
    }
    .container.shifted {
        margin-left: 300px;
    }
    .hero {
        grid-template-columns: repeat(2, 1fr);
    }
    .nodes-grid {
        grid-template-columns: 1fr;
    }
    .glass-header {
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 18px 22px;
        margin-bottom: 20px;
        border-radius: 24px;
        gap: 12px;
    }
    .header-actions {
        flex-direction: row;
        width: auto;
    }
    .settings-btn {
        width: auto;
    }
    .node-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    .settings-panel {
        width: 85%;
        max-width: 300px;
    }
}

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

/* Header actions */
.header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    position: relative;
}

.settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.45);
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.12);
    transform: translateX(2px);
}

/* Settings panel - left sidebar */
.settings-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    z-index: 100;
    border-radius: 0;
    margin: 0;
    padding: 22px 20px;
    overflow-y: auto;
    animation: slideRight .3s ease;
}

.settings-panel.open {
    display: block;
}

@keyframes slideRight {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

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

.settings-header h3 {
    margin: 0;
    font-size: 18px;
    color: #111827;
}

.settings-close {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    color: #4b5563;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s;
}

.settings-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.settings-body {
    position: relative;
}

.settings-group {
    margin-bottom: 18px;
}

.settings-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.settings-segment {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.settings-segment button {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.4);
    color: #6b7280;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all .15s;
}

.settings-segment button.active {
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    border-color: #005fe7;
    box-shadow: 0 2px 8px rgba(0, 95, 231, 0.12);
}

.settings-group input[type="text"],
.settings-group input[type="password"],
.settings-group textarea,
.settings-group input[type="file"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.5);
    color: #111827;
    font-size: 13px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.settings-group input:focus,
.settings-group textarea:focus {
    border-color: #005fe7;
    box-shadow: 0 0 0 3px rgba(0, 95, 231, 0.1);
}

.settings-group textarea {
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.settings-hint {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 5px;
}

.settings-upload {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.settings-upload input[type="file"] {
    width: 100%;
    padding: 8px 10px;
}

.settings-upload button {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: #005fe7;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

.settings-upload button:hover {
    background: #004fc2;
}

input[type="range"]#glass-opacity {
    width: 100%;
    accent-color: #005fe7;
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 22px;
    width: 100%;
}

.settings-save,
.settings-reset {
    width: 100%;
    padding: 11px 20px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .1s, box-shadow .15s;
}

.settings-save {
    background: linear-gradient(135deg, #005fe7, #3b82f6);
    color: #fff;
}

.settings-reset {
    background: rgba(0, 0, 0, 0.05);
    color: #4b5563;
}

.settings-save:hover,
.settings-reset:hover {
    transform: translateY(-1px);
}

.settings-status,
.upload-status {
    margin-top: 10px;
    font-size: 12px;
    min-height: 18px;
}

.settings-status.success,
.upload-status.success {
    color: #158a0d;
}

.settings-status.error,
.upload-status.error {
    color: #b41616;
}

@media (max-width: 768px) {
    .container {
        margin-left: 0;
    }
    .container.shifted {
        margin-left: 300px;
    }
    .glass-header {
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 18px 22px;
        margin-bottom: 20px;
        border-radius: 24px;
    }
    .header-actions {
        flex-direction: row;
        width: auto;
    }
    .settings-btn {
        width: auto;
    }
    .settings-panel {
        width: 85%;
        max-width: 300px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg-mesh, .pulse-dot {
        animation: none;
    }
}

/* Expandable detail inside card */
.node-card {
    cursor: pointer;
}

.node-card.expanded {
    transform: scale(1.01);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), inset 0 1px 1px rgba(255, 255, 255, 0.9), inset 0 -1px 1px rgba(255, 255, 255, 0.3);
}

.expand-hint {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    transition: transform .3s ease, color .15s;
    pointer-events: none;
}

.node-card.expanded .expand-hint {
    transform: rotate(180deg);
    color: #6b7280;
}

.node-detail {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height .4s cubic-bezier(0.4, 0, 0.2, 1), opacity .3s ease, margin-top .3s ease;
    position: relative;
}

.node-card.expanded .node-detail {
    max-height: 1200px;
    opacity: 1;
    margin-top: 16px;
}

.detail-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
}

.detail-section {
    margin-bottom: 18px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.detail-item {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    padding: 10px 12px;
}

.detail-item.full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 3px;
}

.detail-value {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.detail-value.sub {
    font-size: 12px;
    color: #4b5563;
    font-weight: 500;
}

.detail-metric {
    margin-bottom: 12px;
}

.detail-metric:last-child {
    margin-bottom: 0;
}

.detail-metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.detail-metric-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.detail-metric-value {
    font-size: 12px;
    font-weight: 700;
    color: #111827;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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