/* ==========================================================================
   TeamSpeak 3 Status & Analytics Portal — Premium Dark Design System v5
   Cyber Obsidian & Aurora Glass | Interactive Tabs | High-Res Charts | Tree
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@500;600;700;800&display=swap');

/* =====================================================================
   CSS CUSTOM PROPERTIES / DESIGN TOKENS
   ===================================================================== */
:root {
    --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;

    /* Palette — Deep Obsidian & Nebula Dark */
    --bg-main:           #06080e;
    --bg-surface:        #0b0f19;
    --bg-card:           rgba(12, 17, 30, 0.78);
    --bg-card-hover:     rgba(18, 25, 44, 0.88);
    --bg-elevated:       rgba(19, 27, 46, 0.65);
    --bg-input:          rgba(5, 7, 14, 0.6);
    --bg-overlay:        rgba(6, 8, 14, 0.85);

    --border-subtle:  rgba(255, 255, 255, 0.055);
    --border-mid:     rgba(255, 255, 255, 0.09);
    --border-active:  rgba(59, 130, 246, 0.45);
    --border-glow:    rgba(59, 130, 246, 0.18);

    --text-main:      #e6ecf8;
    --text-secondary: #9cb0cf;
    --text-muted:     #5e7394;
    --text-dim:       #374760;

    /* Accent Palette */
    --accent-blue:      #3b82f6;
    --accent-cyan:      #06b6d4;
    --accent-purple:    #8b5cf6;
    --accent-amber:     #f59e0b;
    --accent-emerald:   #10b981;
    --accent-rose:      #f43f5e;

    --status-online:      #10b981;
    --status-online-soft: rgba(16, 185, 129, 0.12);
    --status-online-glow: rgba(16, 185, 129, 0.35);
    --status-offline:     #ef4444;
    --status-away:        #f59e0b;

    /* Radii */
    --radius-xs:   4px;
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   16px;
    --radius-xl:   22px;
    --radius-full: 9999px;

    /* Shadows & Glow */
    --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md:   0 8px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg:   0 16px 48px -6px rgba(0, 0, 0, 0.6);
    --shadow-card: 0 12px 36px -4px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);

    /* Transitions */
    --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
    --transition:  all 0.2s var(--ease-out);
    --trans-slow:  all 0.35s var(--ease-out);
}

/* =====================================================================
   RESET & BASE STYLES
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Animated Ambient Gradient Background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle 900px at 15% 10%, rgba(59, 130, 246, 0.12) 0%, transparent 60%),
        radial-gradient(circle 800px at 85% 85%, rgba(139, 92, 246, 0.1) 0%, transparent 55%),
        radial-gradient(circle 700px at 50% 50%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: aurora-mesh 25s ease-in-out infinite alternate;
}

@keyframes aurora-mesh {
    0%   { transform: scale(1) translate(0, 0); }
    50%  { transform: scale(1.05) translate(-10px, 15px); }
    100% { transform: scale(1) translate(15px, -10px); }
}

/* Subtle grid lines background overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-size: 40px 40px;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    pointer-events: none;
    z-index: 0;
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }

/* Container */
.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* =====================================================================
   HEADER & TOP NAVIGATION
   ===================================================================== */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: var(--text-main);
    transition: var(--transition);
}
.brand-badge:hover { opacity: 0.9; }

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.38), inset 0 1px 0 rgba(255,255,255,0.25);
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.brand-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 60%);
    pointer-events: none;
}

.brand-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: #fff;
}

.brand-subtitle {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
    font-family: var(--font-primary);
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    color: #fff;
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-mid);
    backdrop-filter: blur(8px);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.btn-hero {
    padding: 0.75rem 1.5rem;
    font-size: 0.92rem;
    border-radius: var(--radius-md);
    box-shadow: 0 6px 25px rgba(37, 99, 235, 0.42);
}

.btn-large {
    padding: 0.85rem 1.75rem;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    width: 100%;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
}

.btn-text-action {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}
.btn-text-action:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Refresh spin animation */
.spinning svg {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* =====================================================================
   HERO / SERVER STATUS BANNER CARD
   ===================================================================== */
.hero-card {
    background: var(--bg-card);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-xl);
    padding: 1.85rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(59, 130, 246, 0.6) 50%, transparent 100%);
    pointer-events: none;
}

.hero-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
}

.server-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.server-status-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.server-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: var(--status-online-soft);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--status-online);
}

.server-status-pill.offline {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--status-offline);
}

/* Radar Beacon Dot */
.status-beacon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 8px;
    height: 8px;
}
.beacon-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--status-online);
    box-shadow: 0 0 10px var(--status-online);
}
.beacon-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1.5px solid var(--status-online);
    animation: beacon-ripple 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}
@keyframes beacon-ripple {
    0%   { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

.hero-badge-slot {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-weight: 500;
}

.server-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.7rem;
    letter-spacing: -0.03em;
    color: #fff;
    line-height: 1.25;
}

.server-address-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent-cyan);
    cursor: pointer;
    transition: var(--transition);
    width: fit-content;
}
.server-address-badge:hover {
    background: rgba(6, 182, 212, 0.08);
    border-color: rgba(6, 182, 212, 0.3);
}
.copy-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-left: 0.35rem;
}

/* =====================================================================
   HERO STAT GRID (4 METRIC CARDS)
   ===================================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-mid);
    transform: translateY(-2px);
}

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

.stat-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-mini-pill {
    font-size: 0.68rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-weight: 600;
}
.stat-mini-pill.success {
    background: var(--status-online-soft);
    color: var(--status-online);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.stat-subtext {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Slot Bar */
.slots-bar-wrapper {
    height: 5px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.4rem;
}
.slots-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
    border-radius: 999px;
    transition: width 0.6s var(--ease-out);
}

/* Extra Server Meta Bar */
.server-extra-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.74rem;
    color: var(--text-muted);
}
.extra-stat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.extra-label { color: var(--text-muted); }
.extra-val { color: var(--text-secondary); font-family: var(--font-mono); font-weight: 500; }

/* =====================================================================
   PORTAL NAVIGATION TABS (5 MODULES)
   ===================================================================== */
.portal-nav-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.35rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 1.15rem;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
}
.nav-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}
.nav-tab.active {
    background: rgba(59, 130, 246, 0.15);
    color: #fff;
    border: 1px solid rgba(59, 130, 246, 0.35);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.15);
}

.tab-badge {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 0.12rem 0.45rem;
    border-radius: var(--radius-full);
    font-size: 0.68rem;
    font-family: var(--font-mono);
}
.nav-tab.active .tab-badge {
    background: var(--accent-blue);
}

/* Tab panes switching */
.tab-pane {
    display: none;
    animation: tab-fade-in 0.3s var(--ease-out);
}
.tab-pane.active {
    display: block;
}

@keyframes tab-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================================
   VIEWER CARD (CHANNEL TREE & CLIENTS)
   ===================================================================== */
.viewer-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: 2rem;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
}

.viewer-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.viewer-header-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
}

.viewer-count-badge {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-blue);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-full);
}

.viewer-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-box {
    position: relative;
    width: 260px;
}
.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem 0.45rem 2rem;
    font-size: 0.78rem;
    color: #fff;
    outline: none;
    transition: var(--transition);
}
.search-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Tree Container */
.tree-container {
    padding: 0.85rem 1rem;
    min-height: 250px;
}

.tree-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    padding: 3.5rem 1rem;
    color: var(--text-muted);
}
.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Channel Row */
.channel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-xs);
    margin: 1px 0;
    transition: var(--transition);
    cursor: default;
    user-select: none;
}
.channel-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.channel-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.channel-icon {
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.channel-name {
    font-weight: 500;
    font-size: 0.84rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-topic {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.channel-badge {
    font-size: 0.68rem;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}
.channel-badge.has-users {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    font-weight: 600;
}

/* TS3 Spacers */
.spacer-row {
    padding: 0.35rem 0.6rem;
    user-select: none;
}
.spacer-center { text-align: center; font-weight: 700; color: #cbd5e1; font-size: 0.8rem; }
.spacer-line {
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    margin: 0.45rem 0;
    height: 1px;
}

/* Spacer Category Section Headers */
.spacer-category-block {
    margin: 0.4rem 0 0.2rem 0;
}
.spacer-category-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.09) 0%, rgba(139, 92, 246, 0.05) 50%, rgba(59, 130, 246, 0.09) 100%);
    border: 1px solid rgba(255, 255, 255, 0.07);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}
.spacer-category-row:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.16) 0%, rgba(139, 92, 246, 0.1) 50%, rgba(59, 130, 246, 0.16) 100%);
    border-color: rgba(59, 130, 246, 0.35);
    box-shadow: 0 2px 14px rgba(59, 130, 246, 0.12);
}
.spacer-category-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    min-width: 0;
}
.spacer-category-toggle {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    flex-shrink: 0;
}
.spacer-category-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #e2e8f0;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.spacer-category-title.is-center {
    flex: 1;
    text-align: center;
    color: #f1f5f9;
}
.spacer-category-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

/* Subchannel Tree Hierarchy Branch & Guidelines */
.subchannel-branch {
    margin-left: 1.15rem;
    padding-left: 0.75rem;
    border-left: 1px dashed rgba(255, 255, 255, 0.12);
    margin-top: 2px;
    margin-bottom: 3px;
    position: relative;
    transition: var(--transition);
}
.channel-row.is-expandable {
    cursor: pointer;
}

/* Client Row */
.client-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-xs);
    margin: 1px 0;
    cursor: pointer;
    transition: var(--transition);
}
.client-row:hover {
    background: rgba(59, 130, 246, 0.08);
}

.client-left {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.client-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.client-nick {
    font-weight: 600;
    font-size: 0.82rem;
    color: #fff;
}

.client-flag {
    font-size: 0.85rem;
    line-height: 1;
}

.client-right {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.tag-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}
.tag-root  { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.tag-admin { background: rgba(245, 158, 11, 0.2); color: #fde68a; border: 1px solid rgba(245, 158, 11, 0.3); }
.tag-mod   { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.3); }
.tag-vip   { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.3); }

.status-icon {
    color: var(--text-muted);
    display: flex;
    align-items: center;
}
.status-icon.muted { color: var(--accent-rose); }
.status-icon.away  { color: var(--accent-amber); }

/* Subchannels tree nesting */
.subchannel-branch {
    padding-left: 1.4rem;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    margin-left: 0.6rem;
}

/* =====================================================================
   TAB 2: ANALYTICS & CHARTS
   ===================================================================== */
.analytics-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-card.highlight {
    border-color: rgba(245, 158, 11, 0.4);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(12, 17, 30, 0.9) 100%);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.kpi-icon.gold    { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.kpi-icon.blue    { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.kpi-icon.purple  { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.kpi-icon.emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

.kpi-label {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.kpi-value {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}
.kpi-sub {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* Chart Card */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-xl);
    padding: 1.6rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 1.75rem;
}

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

.chart-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}
.chart-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chart-period-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.2rem;
}
.period-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.35rem 0.85rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
}
.period-btn:hover { color: #fff; }
.period-btn.active {
    background: var(--accent-blue);
    color: #fff;
}

.chart-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
}
#analytics-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.chart-tooltip {
    position: absolute;
    display: none;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-mid);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 10;
    box-shadow: var(--shadow-md);
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-clients { background: var(--accent-blue); }
.dot-ping    { background: var(--accent-amber); }
.dot-loss    { background: var(--accent-rose); }

/* Heatmap Card */
.heatmap-card {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-xl);
    padding: 1.6rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 2rem;
}
.heatmap-header { margin-bottom: 1.25rem; }

.heatmap-bars {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 4px;
    height: 140px;
    align-items: flex-end;
    padding-top: 20px;
    position: relative;
}

.heatmap-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    gap: 6px;
    position: relative;
}
.heatmap-bar {
    width: 100%;
    background: linear-gradient(180deg, #3b82f6 0%, #1e40af 100%);
    border-radius: 3px 3px 0 0;
    transition: height 0.5s var(--ease-out);
    min-height: 4px;
}
.heatmap-col:hover .heatmap-bar {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
}
.heatmap-hour {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* =====================================================================
   TAB 3: CLIENTS TABLE & GROUPS
   ===================================================================== */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}
.data-table th {
    padding: 0.85rem 1.25rem;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-subtle);
}
.data-table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    vertical-align: middle;
}
.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.table-client-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.table-empty {
    text-align: center;
    padding: 3rem 1rem !important;
    color: var(--text-muted);
}

/* Server Groups Directory Grid */
.group-directory-card {
    margin-top: 1.5rem;
}
.server-groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.85rem;
    padding: 1.25rem;
}
.group-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}
.group-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-mid);
}
.group-card-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: #fff;
}
.group-card-type {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* =====================================================================
   TAB 4: RULES & FAQ
   ===================================================================== */
.rules-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2rem;
}
.section-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.35rem;
}
.section-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: var(--transition);
}
.rule-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.rule-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.rule-num {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-xs);
}
.rule-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
}
.rule-body {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* FAQ Accordion */
.faq-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}
.faq-question {
    padding: 1.15rem 1.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    user-select: none;
}
.faq-question:hover {
    background: rgba(255, 255, 255, 0.02);
}
.faq-chevron {
    color: var(--text-muted);
    transition: transform 0.25s var(--ease-out);
}
.faq-item.open .faq-chevron {
    transform: rotate(180deg);
}
.faq-answer {
    display: none;
    padding: 0 1.4rem 1.25rem 1.4rem;
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.65;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.faq-item.open .faq-answer {
    display: block;
}

/* =====================================================================
   TAB 5: CONNECT & WIDGET TOOLS
   ===================================================================== */
.connect-tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.connect-card, .widget-card {
    padding: 1.75rem;
}
.connect-card-header {
    margin-bottom: 1.5rem;
}

.connect-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.connect-address-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-subtle);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.addr-label { color: var(--text-muted); font-size: 0.72rem; }

/* QR Code Section */
.qr-box {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 1.25rem;
    border-radius: var(--radius-md);
}
.qr-code-wrapper {
    width: 90px;
    height: 90px;
    background: #fff;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.qr-code-wrapper svg { width: 100%; height: 100%; }
.qr-info h4 { font-size: 0.88rem; color: #fff; margin-bottom: 0.25rem; }
.qr-info p { font-size: 0.75rem; color: var(--text-muted); line-height: 1.5; }

/* Mini Status Widget Preview */
.widget-preview-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
}
.widget-preview-title { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.mini-status-widget {
    background: #0a0e18;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mini-widget-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
}
.mini-widget-badge .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-online);
}
.mini-widget-info {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.widget-code-box {
    margin-bottom: 1rem;
}
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.btn-copy-code {
    background: transparent;
    border: none;
    color: var(--accent-blue);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.72rem;
}
.btn-copy-code:hover { text-decoration: underline; }

.widget-textarea {
    width: 100%;
    height: 60px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.5rem;
    resize: none;
    outline: none;
}

/* =====================================================================
   INTERACTIVE CLIENT MODAL
   ===================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal-overlay.open {
    display: flex;
    animation: modal-fade-in 0.25s var(--ease-out);
}
@keyframes modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-card {
    background: #0f1526;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(59, 130, 246, 0.2);
    overflow: hidden;
}

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

.modal-user-identity {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.modal-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.95rem;
}
.modal-nick {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}
.modal-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}
.modal-close-btn:hover { color: #fff; }

.modal-body {
    padding: 1.5rem;
}
.modal-stat-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
}
.modal-stat-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.m-label { color: var(--text-muted); }
.m-val { color: #fff; font-weight: 500; }

.modal-groups-section {
    margin-top: 0.5rem;
}
.modal-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

/* =====================================================================
   FOOTER & TOAST
   ===================================================================== */
.app-footer {
    margin-top: auto;
    padding: 2rem 0;
    text-align: center;
    font-size: 0.74rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}
.footer-title { color: var(--text-muted); font-weight: 600; }
.cache-info { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-dim); }

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(18, 24, 40, 0.95);
    backdrop-filter: blur(16px);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-active);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(59, 130, 246, 0.2);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.83rem;
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    transition: var(--trans-slow);
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* =====================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ===================================================================== */
@media (max-width: 960px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .analytics-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .connect-tools-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .container { padding: 1.25rem 1rem; }
    .hero-main { flex-direction: column; }
    .hero-actions { width: 100%; }
    .hero-actions .btn { width: 100%; }
    .stat-grid { grid-template-columns: 1fr; }
    .analytics-kpi-grid { grid-template-columns: 1fr; }
    .viewer-header { flex-direction: column; align-items: stretch; gap: 0.85rem; }
    .viewer-controls { flex-direction: column; align-items: stretch; }
    .search-box { width: 100%; }
    .top-nav { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .nav-actions { width: 100%; justify-content: flex-end; }
    .portal-nav-tabs { justify-content: flex-start; }
}
