:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-hover: rgba(31, 41, 55, 0.85);
    --border-color: rgba(75, 85, 99, 0.4);
    --border-focus: #3b82f6;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    --glow-blue: 0 0 20px rgba(59, 130, 246, 0.35);
    --glow-cyan: 0 0 20px rgba(6, 182, 212, 0.35);
    --glow-emerald: 0 0 15px rgba(16, 185, 129, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: radial-gradient(circle at 10% 20%, #0d1527 0%, #080c16 90%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: all 0.2s;
}

a:hover {
    color: var(--accent-cyan);
}

/* Glassmorphism containers */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.navbar {
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.nav-brand .brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #fff;
    box-shadow: var(--glow-blue);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link:hover, .nav-link.active {
    color: #fff;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.container {
    max-width: 1300px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    flex: 1;
    width: 100%;
}

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

.stat-card {
    padding: 1.5rem;
    border-radius: 14px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: #fff;
    margin-top: 0.75rem;
}

.stat-footer {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
}

.btn-danger {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #fff;
}

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

.btn-secondary {
    background: rgba(55, 65, 81, 0.8);
    color: #d1d5db;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(75, 85, 99, 0.9);
    color: #fff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.775rem;
    border-radius: 6px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 10px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    background: rgba(17, 24, 39, 0.95);
    padding: 14px 18px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(75, 85, 99, 0.2);
    font-size: 0.9rem;
    vertical-align: middle;
}

.custom-table tr:hover {
    background: rgba(31, 41, 55, 0.5);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-online {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-offline {
    background: rgba(244, 63, 94, 0.15);
    color: #fb7185;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-tcp {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-http {
    background: rgba(6, 182, 212, 0.15);
    color: #22d3ee;
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: var(--glow-emerald);
    animation: pulse 2s infinite;
}

.pulse-dot.offline {
    background: #f43f5e;
    box-shadow: none;
    animation: none;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

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

.modal-card {
    background: #111827;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: modalAppear 0.25s ease-out;
}

@keyframes modalAppear {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.form-hint {
    font-size: 0.775rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Code Snippet Block */
.code-box {
    background: #090d16;
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    color: #38bdf8;
    position: relative;
    word-break: break-all;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #1f2937;
    border-left: 4px solid var(--accent-blue);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlide 0.3s ease-out;
}

.toast-success { border-left-color: var(--accent-emerald); }
.toast-error { border-left-color: var(--accent-rose); }
.toast-warning { border-left-color: var(--accent-amber); }

@keyframes toastSlide {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Client Portal Special Styles */
.client-hero {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(6, 182, 212, 0.08));
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 2rem;
}

.connection-pill {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #090d16;
    border: 2px solid #3b82f6;
    padding: 10px 20px;
    border-radius: 9999px;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    box-shadow: var(--glow-blue);
    margin: 1rem 0;
}
