:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-darker);
    color: var(--text-primary);
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
}

.commit-footer {
    position: fixed;
    right: 12px;
    bottom: 8px;
    z-index: 1000;
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1;
    opacity: 0.75;
    pointer-events: none;
}

button, input, .servers-list {
    -webkit-app-region: no-drag;
}

/* Safari falls back to Times for buttons/inputs without a font (Chrome doesn't) */
button, input, select, textarea {
    font-family: inherit;
}

/* Particles Background */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.particle {
    position: absolute;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    border-radius: 50%;
    animation: float 20s infinite;
    opacity: 0.1;
}

@keyframes float {
    0%, 100% { transform: translateY(0) translateX(0); }
    25% { transform: translateY(-100px) translateX(100px); }
    50% { transform: translateY(-200px) translateX(-100px); }
    75% { transform: translateY(-100px) translateX(-150px); }
}

/* Screens */
.screen {
    display: none;
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

.screen.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

/* FIXED: Logo sizing */
.logo-large {
    width: 120px !important;
    height: 120px !important;
    max-width: 120px !important;
    max-height: 120px !important;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 1.5rem;
    animation: logoGlow 3s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(99, 102, 241, 0.6));
}

@keyframes logoGlow {
    0%, 100% { filter: drop-shadow(0 0 30px rgba(99, 102, 241, 0.6)); }
    50% { filter: drop-shadow(0 0 50px rgba(99, 102, 241, 0.9)); }
}

.app-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.login-form {
    width: 100%;
    max-width: 400px;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group select {
    width: 100%;
    padding: 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

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

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

.checkbox-group label {
    margin: 0;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

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

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

.btn-secondary:hover {
    background: var(--bg-dark);
}

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
}

.btn-text:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Navbar */
.navbar {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    object-fit: cover;
    border-radius: 50%;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.logo-text {
    font-size: 1.2rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.security-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1rem 1.25rem;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 0.75rem;
}

.security-banner[hidden] {
    display: none;
}

.security-banner strong {
    display: block;
    color: #fbbf24;
    margin-bottom: 0.35rem;
}

.security-banner ul {
    margin-left: 1rem;
}

.security-banner li {
    color: var(--text-secondary);
    line-height: 1.45;
    margin-top: 0.25rem;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.page-header h1 {
    font-size: 2rem;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* User Management */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.user-card:hover {
    border-color: var(--primary);
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.user-details h3 {
    margin-bottom: 0.3rem;
}

.user-details p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.admin {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge.user {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

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

/* Servers */
.servers-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.server-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.server-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
}

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

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--danger);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* Server Token Section */
.server-token-section {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

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

.token-header strong {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.token-display {
    margin: 0.5rem 0;
}

.token-value {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--primary);
    word-break: break-all;
    max-height: 60px;
    overflow-y: auto;
}

.token-usage {
    margin-top: 0.5rem;
}

.token-usage small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.server-card code {
    background: var(--bg-darker);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--secondary);
}

/* Clients */
.clients-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.client-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.client-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.client-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

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

/* Settings */
.settings-container {
    max-width: 600px;
}

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.settings-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.settings-help {
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 1rem;
}

.quick-code-panel {
    margin-top: 1rem;
}

.quick-code-panel[hidden] {
    display: none;
}

.quick-code-panel textarea {
    width: 100%;
    min-height: 7rem;
    margin-bottom: 0.75rem;
    padding: 0.875rem;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.system-status-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.system-summary {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.system-status-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.system-status-row p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 1rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: all 0.3s ease;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.config-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.config-steps {
    margin: 1rem 0 0;
    padding: 0.75rem 1rem 0.75rem 2rem;
    text-align: left;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
    background: var(--bg-darker);
    border-radius: 0.5rem;
}
.config-steps li + li { margin-top: 0.35rem; }
.config-steps b { color: var(--text-primary, #fff); }

/* Error Message */
.error-message {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-top: 1rem;
    display: none;
}

.error-message.show {
    display: block;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Login Hint */
.login-hint {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-hint code {
    background: var(--bg-card);
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-family: monospace;
    color: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 15px;
    }

    .login-container {
        justify-content: flex-start;
        padding: 1.25rem;
    }

    .logo-large {
        width: 84px !important;
        height: 84px !important;
        max-width: 84px !important;
        max-height: 84px !important;
        margin-bottom: 1rem;
    }

    .app-title {
        font-size: 2rem;
        text-align: center;
    }

    .app-subtitle {
        margin-bottom: 1.25rem;
    }

    .nav-container {
        align-items: stretch;
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .logo-container,
    .user-info {
        justify-content: space-between;
    }

    .nav-links {
        overflow-x: auto;
        padding-bottom: 0.25rem;
        scrollbar-width: thin;
    }

    .nav-link {
        flex: 0 0 auto;
    }

    .main-content {
        padding: 1rem;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .servers-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .user-card,
    .client-card {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }

    .security-banner {
        align-items: stretch;
        flex-direction: column;
    }
    
    .user-actions,
    .client-actions {
        width: 100%;
        justify-content: stretch;
    }

    .client-actions .btn,
    .user-actions .btn,
    .tab-header .btn,
    .config-actions .btn {
        flex: 1 1 auto;
        min-width: 0;
    }

    .server-tabs {
        flex-wrap: nowrap;
    }

    .tab-content {
        padding: 1rem;
    }

    .tab-header {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }

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

    .modal {
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-height: 92vh;
        border-radius: 1rem 1rem 0 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .modal-footer,
    .config-actions {
        flex-direction: column;
    }

    .host-card,
    .server-hosts-header,
    .system-status-row {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }
}

/* Server Selection Modal */
.server-select-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.server-select-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.server-select-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.2);
}

.server-select-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.server-select-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.server-select-card .status-dot {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

/* Server Tabs for Clients Page */
.server-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-wrap: wrap;
}

.server-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.server-tab:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
    border-color: var(--primary);
}

.server-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: transparent;
    color: white;
}

.server-tab .tab-location {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-left: 0.25rem;
}

.status-dot-small {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot-small.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot-small.offline {
    background: var(--danger);
}

.tab-content {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.tab-server-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tab-server-info #currentServerName {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tab-server-info #currentServerLocation {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.client-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.client-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.client-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.client-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 0.75rem;
}

.client-details h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.client-details p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.empty-state, .error-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state p, .error-state p {
    font-size: 1rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Hosts Page */
.hosts-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.server-hosts-section {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

.server-hosts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.server-hosts-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.server-location {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.hosts-count {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.hosts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.host-card {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.host-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.host-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.host-info {
    flex: 1;
    min-width: 0;
}

.host-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.host-ip {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.host-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-icon {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
}

.btn-icon .icon {
    font-size: 1rem;
}

.btn-smb {
    background: var(--secondary);
}

.btn-smb:hover {
    background: #7c3aed;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .server-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }
    
    .server-tab {
        flex-shrink: 0;
    }
    
    .tab-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .clients-grid {
        grid-template-columns: 1fr;
    }
    
    .client-card {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .client-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    /* Hosts responsive */
    .hosts-grid {
        grid-template-columns: 1fr;
    }
    
    .server-hosts-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .host-card {
        flex-wrap: wrap;
    }
    
    .host-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ===================== Network / Hosts view ===================== */
.network-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.85rem 0 1.1rem;
    background: var(--bg-dark);
}
.network-search {
    flex: 1;
    min-width: 240px;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.network-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
.network-totals { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.pill-online { color: #d1fae5; background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.4); }

/* Subnet tabs — one per discovered network, plus an "All" tab. */
.network-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
}
.net-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: 0.65rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.net-tab:hover { background: var(--bg-hover, rgba(255, 255, 255, 0.06)); }
.net-tab.active {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.5);
}
.net-tab-sub { opacity: 0.6; font-weight: 500; font-size: 0.82em; }
.net-tab-count {
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.28);
    font-size: 0.8em;
    font-variant-numeric: tabular-nums;
}
.net-tab.active .net-tab-count { background: rgba(245, 158, 11, 0.22); }

/* Bluetooth block within a network section. */
.pill-bt { color: #bfdbfe; background: rgba(59, 130, 246, 0.16); border-color: rgba(59, 130, 246, 0.4); }
.bt-section {
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px dashed var(--border);
}
.bt-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}
.bt-count {
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.18);
    color: #bfdbfe;
    font-size: 0.8em;
}
.bt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.6rem;
}
.bt-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
}
.bt-dot { font-size: 0.9rem; }
.bt-info { min-width: 0; }
.bt-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bt-mac { font-size: 0.8rem; color: var(--text-secondary); font-family: monospace; }
.bt-rssi { opacity: 0.7; }
.bt-count-off { background: rgba(148, 163, 184, 0.18); color: var(--text-secondary); }
.bt-hint { font-size: 0.78em; font-weight: 400; opacity: 0.55; margin-left: 0.4rem; }
.bt-scan-btn {
    margin-left: auto;
    padding: 0.3rem 0.75rem;
    font-size: 0.82rem;
    background: rgba(59, 130, 246, 0.16);
    color: #bfdbfe;
    border: 1px solid rgba(59, 130, 246, 0.4);
}
.bt-scan-btn:hover:not(:disabled) { background: rgba(59, 130, 246, 0.28); }
.bt-scan-btn:disabled { opacity: 0.6; cursor: default; }
.bt-mac-row { font-size: 0.8rem; color: var(--text-secondary); font-family: monospace; margin-top: 0.1rem; }
.bt-rename {
    margin-left: auto;
    padding: 0.25rem 0.4rem;
    background: transparent;
    border: none;
    opacity: 0.55;
    cursor: pointer;
    font-size: 0.9rem;
}
.bt-rename:hover { opacity: 1; }

.network-section {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.network-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.network-title h2 { font-size: 1.2rem; display: flex; align-items: center; gap: 0.5rem; }
.network-meta { margin-top: 0.4rem; font-size: 0.82rem; color: var(--text-secondary); }
.network-counts { display: flex; gap: 0.5rem; flex-shrink: 0; }
.network-empty { padding: 0.5rem; color: var(--text-secondary); font-size: 0.9rem; }

.hosts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.9rem;
    padding: 1.25rem;
}

/* Override the old flex-row host card with a richer vertical layout */
.host-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: stretch;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    padding: 0.9rem 1rem;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.host-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(99, 102, 241, 0.18); }
.host-card.host-down { opacity: 0.6; }
.host-card.host-up { border-left: 3px solid var(--success); }

.host-top { display: flex; align-items: center; gap: 0.7rem; }
.host-info { flex: 1; min-width: 0; }
.host-name { font-weight: 700; font-size: 1.02rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host-ip { margin-top: 0.15rem; font-size: 0.82rem; color: var(--text-secondary); font-family: 'Courier New', monospace; }
.host-mac { color: var(--secondary); }
.host-vendor { font-size: 0.82rem; color: var(--text-secondary); }

.host-ports { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.port-chip {
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.18rem 0.5rem;
    border-radius: 0.4rem;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.16);
    border: 1px solid rgba(99, 102, 241, 0.35);
}
.host-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-top: 0.1rem; }
.host-seen { font-size: 0.74rem; color: var(--text-secondary); }

@media (max-width: 640px) {
    .network-header { flex-direction: column; }
    .hosts-grid { grid-template-columns: 1fr; }
}

/* Live tunnels (dashboard panel + per-card status lines) */
.live-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.live-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.live-header h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.live-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    animation: live-pulse 2s infinite;
}

@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.live-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.live-servers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.live-server-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
}

.live-server-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.live-server-count {
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.live-big {
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--primary);
}

.live-server-sub {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.live-server-warn {
    color: var(--warning);
    font-size: 0.8rem;
    margin-top: 0.35rem;
}

.live-row {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr 0.9fr 2.4fr 1.6fr;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.live-row:last-child {
    border-bottom: none;
}

.live-row.is-on {
    background: rgba(16, 185, 129, 0.06);
}

.live-row-head {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.live-client {
    font-weight: 600;
}

.live-tag {
    font-weight: normal;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 0.4rem;
    margin-left: 0.25rem;
}

.live-detail, .live-traffic, .live-server {
    color: var(--text-secondary);
}

.live-detail code, .client-live code {
    background: var(--bg-darker);
    padding: 0.05rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
}

.live-rate {
    color: var(--text-primary);
}

.live-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.live-badge.live-on {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.live-badge.live-idle {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
}

.live-badge.live-warn, .live-warn {
    color: var(--warning);
}

.live-badge.live-warn {
    background: rgba(245, 158, 11, 0.15);
}

.live-unknown, .live-badge.live-unknown {
    color: var(--text-secondary);
    font-style: italic;
}

.client-live, .server-live {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    line-height: 1.5;
}

.client-live:empty, .server-live:empty {
    display: none;
}

@media (max-width: 800px) {
    .live-row {
        grid-template-columns: 1fr auto;
    }
    .live-row-head {
        display: none;
    }
    .live-row .live-server, .live-row .live-detail, .live-row .live-traffic {
        grid-column: 1 / -1;
    }
}
