:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Background Gradients */
.bg-gradient {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    animation: float 20s infinite ease-in-out;
}

.bg-grad-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,0.2) 0%, rgba(0,0,0,0) 70%);
    top: -100px;
    left: -100px;
}

.bg-grad-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(16,185,129,0.15) 0%, rgba(0,0,0,0) 70%);
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}

.bg-grad-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(239,68,68,0.1) 0%, rgba(0,0,0,0) 70%);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
    100% { transform: translate(0, 0) scale(1); }
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* View Management */
.view {
    display: flex;
    min-height: 100vh;
    width: 100%;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.view.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

/* Login Screen */
#login-view {
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 3rem;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.logo-box {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem auto;
    font-size: 2rem;
    color: white;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.5);
}

.login-container h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    width: auto;
}

.error-msg {
    color: var(--danger);
    margin-top: 1rem;
    font-size: 0.875rem;
    min-height: 20px;
}

/* Dashboard Layout */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--primary);
}

.nav-links {
    list-style: none;
    padding: 0 1rem;
    flex: 1;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-links a:hover, .nav-links li.active a {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-links li.active a {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.sidebar-footer {
    padding: 1.5rem;
}

.content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-area {
    padding: 0 2rem 2rem 2rem;
    flex: 1;
}

.section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.cpu-icon { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.ram-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.uptime-icon { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-info .value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Cards & Tables */
.card {
    padding: 1.5rem;
}

.card-header {
    margin-bottom: 1.5rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }

.action-buttons {
    display: flex;
    gap: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 100%;
    max-width: 450px;
    padding: 2rem;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal {
    transform: scale(0.95);
}

.modal-lg {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.configs-list {
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.config-item {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.config-item h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.config-item code {
    display: block;
    word-break: break-all;
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

/* --- Config QR + download feature --- */
.modal-header-actions { display: flex; gap: 10px; align-items: center; }
.config-row { display: flex; gap: 14px; align-items: flex-start; margin-top: 8px; }
.config-uri { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.qr-box { flex: 0 0 auto; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center;
          background: #fff; border-radius: 10px; padding: 6px; box-sizing: border-box; color: #555; }
.qr-box img { width: 100%; height: 100%; display: block; }
.copy-btn { align-self: flex-start; }
@media (max-width: 560px) { .config-row { flex-direction: column; align-items: center; } }
