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

:root {
    --bg-base: #070A0F;
    --bg-surface: rgba(13, 19, 33, 0.75);
    --bg-surface-elevated: rgba(18, 26, 45, 0.85);
    --bg-surface-hover: rgba(26, 36, 60, 0.9);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 242, 254, 0.35);
    --border-subtle: rgba(255, 255, 255, 0.05);

    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --text-dim: #64748B;

    --accent-primary: #00F2FE;
    --accent-secondary: #4FACFE;
    --accent-gradient: linear-gradient(135deg, #00F2FE 0%, #4FACFE 100%);
    --accent-glow: 0 0 20px rgba(0, 242, 254, 0.35);

    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --success-glow: 0 0 15px rgba(16, 185, 129, 0.3);

    --danger: #EF4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --danger-gradient: linear-gradient(135deg, #FF416C 0%, #FF4B2B 100%);

    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, 0.15);

    --info: #38BDF8;
    --info-bg: rgba(56, 189, 248, 0.15);

    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 25px rgba(0, 242, 254, 0.2);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --blur: blur(16px);
}

/* ==========================================================================
   Base & Resets (Prevent default white browser buttons/inputs)
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 242, 254, 0.06), transparent 30%),
        radial-gradient(circle at 90% 80%, rgba(79, 172, 254, 0.06), transparent 35%),
        radial-gradient(circle at 50% 50%, rgba(13, 19, 33, 0.5), transparent 70%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden; /* scroll happens inside .main-content only */
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: #FFFFFF;
    letter-spacing: -0.3px;
}

button {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    outline: none;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

input, select, textarea {
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text-main);
    background: rgba(13, 19, 33, 0.85);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    outline: none;
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 242, 254, 0.15);
    background: rgba(18, 26, 45, 0.95);
}

select option {
    background: #0d1322;
    color: #fff;
    padding: 8px;
}

ul {
    list-style: none;
}

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

a:hover {
    color: #7DF9FF;
}

/* ==========================================================================
   Scrollbar & Animations
   ========================================================================== */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.25);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 242, 254, 0.5);
}

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

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Buttons & Badges
   ========================================================================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent-gradient);
    color: #070A0F;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.3);
    transition: all 0.25s ease;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(0, 242, 254, 0.45);
    filter: brightness(1.08);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.88rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 242, 254, 0.4);
    color: #FFFFFF;
    transform: translateY(-1px);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
    font-weight: 500;
    font-size: 0.88rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #EF4444;
    color: #FFFFFF;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* File Browser */
.fb-quick-btn {
    padding: 5px 10px;
    font-size: 0.77rem;
    border-radius: 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
    white-space: nowrap;
}
.fb-quick-btn:hover {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.4);
    color: #a5b4fc;
}
.fb-row {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.1s;
    cursor: default;
}
.fb-row:hover { background: rgba(255,255,255,0.04); }
.fb-row.fb-dir { cursor: pointer; }
.fb-row.fb-dir:hover { background: rgba(99,102,241,0.08); }
.fb-row td { padding: 7px 6px; font-size: 0.83rem; color: #e2e8f0; }
.fb-icon { font-size: 1.15rem; text-align: center; }
.fb-action-btn {
    padding: 3px 8px;
    font-size: 0.75rem;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: #94a3b8;
    transition: all 0.12s;
}
.fb-action-btn:hover { background: rgba(99,102,241,0.2); border-color: rgba(99,102,241,0.4); color: #a5b4fc; }
.fb-action-btn.del:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.4); color: #f87171; }

/* Remote Shell Terminal */
.terminal-output {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.55;
    background: #030712;
    color: #4ade80;
    padding: 12px 14px;
    border-radius: 8px;
    min-height: 260px;
    max-height: 440px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid rgba(74,222,128,0.15);
}
.terminal-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #030712;
    border: 1px solid rgba(74,222,128,0.25);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 8px 12px;
}
.terminal-prompt { color: #4ade80; font-family: monospace; font-size: 0.85rem; white-space: nowrap; }
.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #f0fdf4;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.84rem;
    caret-color: #4ade80;
}


.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: var(--accent-primary);
}

/* Nav specific buttons */
.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #FCA5A5;
}

.nav-btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
}

.nav-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-main);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

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

.badge-offline {
    background: rgba(148, 163, 184, 0.1);
    color: #94A3B8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-battery {
    background: rgba(56, 189, 248, 0.12);
    color: #38BDF8;
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.badge-time {
    background: rgba(245, 158, 11, 0.12);
    color: #FBBF24;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.confidential-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #EF4444;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    letter-spacing: 0.06em;
}

/* ==========================================================================
   Layout & Navigation
   ========================================================================== */
.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.navbar {
    background: rgba(10, 15, 26, 0.85);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    flex-shrink: 0;
}

.nav-brand-wrap {
    display: flex;
    flex-direction: column;
}

.nav-brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border: 2px solid var(--accent-primary);
    border-radius: 5px;
    position: relative;
    box-shadow: inset 0 0 0 3px rgba(0, 242, 254, 0.15), 0 0 10px rgba(0, 242, 254, 0.3);
}

.brand-mark::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 2px solid var(--accent-secondary);
    border-radius: 2px;
}

.brand-mark-sm {
    width: 18px;
    height: 18px;
}

.nav-brand {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.nav-subtitle {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 1px;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-email {
    font-size: 0.86rem;
    color: var(--text-muted);
    padding-right: 14px;
    border-right: 1px solid var(--border-color);
}

.dashboard-content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ==========================================================================
   Sidebar (Clean, Categorized, No Ugly White Boxes)
   ========================================================================== */
.sidebar {
    width: 260px;
    background: rgba(10, 15, 26, 0.75);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-right: 1px solid var(--border-color);
    padding: 16px 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-brand-block {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 14px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
}

.sidebar-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-dim);
    margin: 14px 0 6px 10px;
    font-weight: 700;
}

.nav-tree {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.88rem;
    border: 1px solid transparent;
}

.menu-link i {
    font-size: 1.15rem;
    color: var(--text-dim);
    transition: color 0.2s ease;
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.06);
    transform: translateX(3px);
}

.menu-link:hover i {
    color: var(--accent-primary);
}

.menu-link.active {
    background: rgba(0, 242, 254, 0.12);
    color: #00F2FE;
    font-weight: 600;
    border-color: rgba(0, 242, 254, 0.25);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.15);
}

.menu-link.active i {
    color: #00F2FE;
}

/* Clean Nav Groups */
.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.88rem;
    transition: all 0.2s ease;
}

.nav-group-toggle span {
    display: flex;
    align-items: center;
    gap: 11px;
}

.nav-group-toggle i {
    font-size: 1.15rem;
    color: var(--text-dim);
}

.nav-group-toggle:hover {
    background: rgba(255, 255, 255, 0.04) !important;
    color: var(--text-main);
}

.nav-caret {
    transition: transform 0.2s ease;
    font-size: 0.85rem !important;
}

.nav-group.open > .nav-group-toggle .nav-caret {
    transform: rotate(180deg);
}

.nav-sub {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 2px 0 6px 8px;
    margin-left: 14px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-group.open > .nav-sub {
    display: flex;
}

.menu-link.sub-link {
    padding: 8px 12px;
    font-size: 0.84rem;
}

/* ==========================================================================
   Main Content Area & Pages
   ========================================================================== */
.main-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 28px 36px 80px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    position: relative;
}


.page {
    display: none;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.page-header h2 {
    font-size: 1.8rem;
    letter-spacing: -0.5px;
}

.page-subtitle {
    color: var(--text-muted);
    margin-top: 4px;
    font-size: 0.9rem;
}

/* ==========================================================================
   Overview Hero Cards & Panels
   ========================================================================== */
.hero-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.hero-stat-card {
    background: var(--bg-surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.hero-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hero-stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(0, 242, 254, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.hero-stat-card:hover::before {
    opacity: 1;
}

.hero-stat-card span {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.hero-stat-card strong {
    font-size: 2.3rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

.ops-panel {
    background: var(--bg-surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease;
}

.ops-panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-header h3 {
    font-size: 1.15rem;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-hint {
    color: var(--text-dim);
    font-size: 0.8rem;
}

.ops-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ==========================================================================
   Primary Device Spotlight & Launchpad
   ========================================================================== */
.device-spotlight-card {
    background: linear-gradient(135deg, rgba(13, 19, 33, 0.9) 0%, rgba(20, 30, 55, 0.8) 100%);
    border: 1px solid rgba(0, 242, 254, 0.25);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    position: relative;
    overflow: hidden;
}

.device-spotlight-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(0, 242, 254, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

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

.spotlight-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.spotlight-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: #FFFFFF;
}

.spotlight-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.spotlight-meta-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.spotlight-meta-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.spotlight-meta-val {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.spotlight-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.action-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.84rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.action-pill-btn:hover {
    background: rgba(0, 242, 254, 0.12);
    border-color: rgba(0, 242, 254, 0.4);
    color: #00F2FE;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 242, 254, 0.2);
}

.action-pill-btn i {
    font-size: 1.1rem;
    color: var(--accent-primary);
}

/* ==========================================================================
   Roster & Activity Feed
   ========================================================================== */
.roster-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.roster-item {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    text-align: left;
}

.roster-item:hover {
    background: rgba(0, 242, 254, 0.06);
    border-color: rgba(0, 242, 254, 0.3);
    transform: translateX(4px);
}

.roster-item-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.roster-item-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: #FFFFFF;
}

.roster-item-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.roster-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.roster-dot.online {
    background: #10B981;
    box-shadow: 0 0 8px #10B981;
    animation: pulseGlow 2s infinite;
}

.roster-dot.offline {
    background: #64748B;
}

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
}

.activity-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.activity-title {
    font-weight: 600;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

.activity-subtitle {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.activity-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.status-pill {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-success {
    background: var(--success-bg);
    color: #34D399;
}

.status-pending {
    background: var(--warning-bg);
    color: #FBBF24;
}

.status-failed {
    background: var(--danger-bg);
    color: #F87171;
}

.empty-state {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.88rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}

/* ==========================================================================
   Devices Grid & Device Cards
   ========================================================================== */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.device-card {
    background: var(--bg-surface);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.device-card:hover {
    transform: translateY(-4px);
    border-color: rgba(0, 242, 254, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.device-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.device-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #FFFFFF;
}

.device-card-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.device-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
}

/* ==========================================================================
   Device Explorer Modal & Tabs
   ========================================================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 13, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: #0d1322;
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 242, 254, 0.15);
}

/* Device Explorer: full-screen dedicated interface */
#deviceExplorerModal {
    padding: 0;
    background: #070a0f;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    align-items: stretch;
    justify-content: stretch;
}

.explorer-modal-content {
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    padding: 20px 24px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden; /* children handle their own scroll */
}

.close {
    position: absolute;
    top: 18px;
    right: 20px;
    font-size: 1.5rem;
    color: var(--text-dim);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close:hover {
    color: #FFFFFF;
}

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

.explorer-header h2 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.explorer-badges {
    display: flex;
    align-items: center;
    gap: 8px;
}

.explorer-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    flex: 1;
    min-height: 0;   /* critical: allows flex child to shrink */
    overflow: hidden; /* children scroll independently */
}

.explorer-sidebar {
    background: rgba(7, 10, 15, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;   /* sidebar scrolls independently */
    overflow-x: hidden;
    min-height: 0;
}

.explorer-sidebar .sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: left;
    border: 1px solid transparent;
}

.explorer-sidebar .sidebar-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.explorer-sidebar .sidebar-item.active {
    background: rgba(0, 242, 254, 0.12);
    color: #00F2FE;
    font-weight: 600;
    border-color: rgba(0, 242, 254, 0.3);
}

.explorer-sidebar .sidebar-item i {
    font-size: 1.05rem;
}

/* Sidebar notification badge (Facebook-style) */
.tab-notif-badge {
    display: none;
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    animation: badgePop 0.25s ease;
    line-height: 1;
    letter-spacing: 0;
}

@keyframes badgePop {
    0%   { transform: scale(0.5); opacity: 0; }
    70%  { transform: scale(1.2); }
    100% { transform: scale(1);   opacity: 1; }
}

.explorer-body {
    background: rgba(7, 10, 15, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    overflow-y: auto;   /* main content area scrolls */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.tab-pane {
    display: none;
    height: 100%;
    flex-direction: column;
}

.tab-pane.active {
    display: flex;
}

/* ==========================================================================
   VNC / Live Screen Controls
   ========================================================================== */
.vnc-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    height: 100%;
}

.vnc-screen-container {
    position: relative;
    border: 2px solid rgba(0, 242, 254, 0.3);
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    max-height: 70vh;
}

.vnc-screen-img {
    display: block;
    max-height: 68vh;
    width: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.vnc-nav-bar {
    display: flex;
    gap: 12px;
    padding: 10px 18px;
    background: rgba(13, 19, 33, 0.85);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    backdrop-filter: var(--blur);
}

.vnc-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
}

.vnc-nav-btn:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: var(--accent-primary);
    color: #00F2FE;
}

/* ==========================================================================
   Tables & Data Views
   ========================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
}

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

/* Toggle Switches */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: 0.3s;
    border-radius: 24px;
}

.slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #FFFFFF;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background: var(--accent-gradient);
}

input:checked + .slider::before {
    transform: translateX(20px);
    background-color: #070A0F;
}

/* Auth Pages */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-form {
    background: rgba(13, 19, 33, 0.85);
    border: 1px solid rgba(0, 242, 254, 0.25);
    border-radius: var(--radius-xl);
    padding: 36px;
    width: 100%;
    max-width: 420px;
    backdrop-filter: var(--blur);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 242, 254, 0.1);
}

.auth-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(0, 242, 254, 0.12);
    border: 1px solid rgba(0, 242, 254, 0.3);
    color: #00F2FE;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 20px;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.form-tabs {
    display: flex;
    gap: 8px;
    margin: 20px 0;
    background: rgba(0, 0, 0, 0.25);
    padding: 4px;
    border-radius: var(--radius-md);
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.tab-btn.active {
    background: rgba(0, 242, 254, 0.15);
    color: #00F2FE;
}

.form-content {
    display: none;
    flex-direction: column;
    gap: 14px;
}

.form-content.active {
    display: flex;
}

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

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    backdrop-filter: var(--blur);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
    border: 1px solid transparent;
}

.toast-success {
    background: rgba(16, 185, 129, 0.9);
    color: #fff;
    border-color: rgba(16, 185, 129, 0.4);
}

.toast-error {
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    border-color: rgba(239, 68, 68, 0.4);
}

.toast-warning {
    background: rgba(245, 158, 11, 0.9);
    color: #fff;
    border-color: rgba(245, 158, 11, 0.4);
}

/* Spinner */
.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(0, 242, 254, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive */
@media (max-width: 1024px) {
    .ops-grid {
        grid-template-columns: 1fr;
    }
    .explorer-layout {
        grid-template-columns: 180px 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-content {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
    }
    .main-content {
        padding: 18px;
    }
    .explorer-layout {
        display: flex;
        flex-direction: column;
    }
    .explorer-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
    }
}

/* ==========================================================================
   Map Containers (Leaflet fix)
   ========================================================================== */
.map-container { width:100%; border-radius:var(--radius-lg); overflow:hidden; background:#0a0f1a; border:1px solid var(--border-color); z-index:0; }
.geo-map { height:480px; min-height:320px; }
.geo-layout { display:grid; grid-template-columns:1fr 320px; gap:20px; align-items:start; }
.geo-map-pane { display:flex; flex-direction:column; gap:10px; }
.geo-side-panel { min-height:480px; }
.geo-stats-bar { display:flex; gap:18px; padding:8px 14px; background:var(--bg-surface); border:1px solid var(--border-color); border-radius:var(--radius-md); font-size:0.82rem; color:var(--text-muted); }
.geo-filters { display:flex; flex-direction:column; gap:14px; padding:4px 0; }
.geo-filters label { display:flex; flex-direction:column; gap:5px; font-size:0.82rem; color:var(--text-muted); }
.leaflet-container { background:#0a0f1a !important; font-family:'Inter',sans-serif !important; }
.leaflet-tile { filter:brightness(0.85) saturate(0.9); }
.leaflet-popup-content-wrapper { background:#1e293b; color:#e2e8f0; border:1px solid rgba(0,242,254,0.3); border-radius:10px; box-shadow:0 8px 32px rgba(0,0,0,0.5); }
.leaflet-popup-tip { background:#1e293b; }

/* ==========================================================================
   AnyDesk-style VNC Toolbar
   ========================================================================== */
.anydeskbar { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 16px; background:rgba(10,15,26,0.95); border:1px solid var(--border-color); border-radius:var(--radius-lg) var(--radius-lg) 0 0; backdrop-filter:var(--blur); flex-wrap:wrap; }
.anydeskbar-group { display:flex; align-items:center; gap:6px; }
.anydeskbar-divider { width:1px; height:24px; background:rgba(255,255,255,0.1); margin:0 4px; }
.anydesk-btn { display:inline-flex; align-items:center; gap:6px; padding:7px 14px; border-radius:var(--radius-md); font-size:0.84rem; font-weight:600; cursor:pointer; border:1px solid transparent; transition:all 0.2s ease; }
.anydesk-btn-primary { background:linear-gradient(135deg,#00F2FE,#4FACFE); color:#070A0F; border-color:#00F2FE; }
.anydesk-btn-primary:hover { filter:brightness(1.1); transform:translateY(-1px); }
.anydesk-btn-danger { background:rgba(239,68,68,0.2); color:#ef4444; border-color:#ef4444; }
.anydesk-btn-danger:hover { background:rgba(239,68,68,0.35); }
.anydesk-btn-refresh { background:rgba(255,255,255,0.05); color:var(--text-muted); border-color:var(--border-color); padding:7px 10px; }
.anydesk-btn-refresh:hover { color:var(--accent-primary); border-color:var(--accent-primary); }
.anydesk-btn-vnc { background:rgba(168,85,247,0.15); color:#a855f7; border-color:rgba(168,85,247,0.4); padding:7px 16px; font-size:0.88rem; }
.anydesk-btn-vnc.active { background:rgba(168,85,247,0.4); box-shadow:0 0 16px rgba(168,85,247,0.4); }
.anydesk-btn-vnc:hover { background:rgba(168,85,247,0.3); }
.anydesk-navbtn { display:inline-flex; align-items:center; justify-content:center; width:34px; height:34px; border-radius:var(--radius-md); font-size:1.05rem; cursor:pointer; background:rgba(255,255,255,0.05); color:var(--text-muted); border:1px solid var(--border-color); transition:all 0.2s ease; }
.anydesk-navbtn:hover { background:rgba(0,242,254,0.12); color:var(--accent-primary); border-color:rgba(0,242,254,0.3); transform:translateY(-1px); }
.anydesk-navbtn-green { color:#22c55e !important; border-color:rgba(34,197,94,0.3) !important; }
.anydesk-navbtn-green:hover { background:rgba(34,197,94,0.15) !important; }
.anydesk-navbtn-yellow { color:#f59e0b !important; border-color:rgba(245,158,11,0.3) !important; }
.anydesk-navbtn-yellow:hover { background:rgba(245,158,11,0.15) !important; }
.anydesk-navbtn-blue { color:#38bdf8 !important; border-color:rgba(56,189,248,0.3) !important; }
.anydesk-navbtn-blue:hover { background:rgba(56,189,248,0.15) !important; }
.anydesk-navbtn-orange { color:#fb923c !important; border-color:rgba(251,146,60,0.3) !important; }
.anydesk-navbtn-orange:hover { background:rgba(251,146,60,0.15) !important; }
.vnc-screen-container { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:520px; background:#000; border:1px solid var(--border-color); border-top:none; border-radius:0 0 var(--radius-lg) var(--radius-lg); padding:16px; position:relative; cursor:crosshair; user-select:none; -webkit-user-select:none; }
.vnc-screen-container.fullscreen-active { position:fixed !important; inset:0 !important; z-index:9998 !important; border-radius:0 !important; min-height:100vh !important; padding:0 !important; border:none !important; }
.vnc-screen-img { max-width:100%; max-height:640px; aspect-ratio:1080/2340; object-fit:contain; border-radius:6px; display:none; user-select:none; -webkit-user-select:none; image-rendering:-webkit-optimize-contrast; image-rendering:crisp-edges; }
.fullscreen-active .vnc-screen-img { max-height:100vh !important; border-radius:0 !important; object-fit:contain; width:100%; }
@keyframes vncRipple { 0%{transform:translate(-50%,-50%) scale(0);opacity:1;} 100%{transform:translate(-50%,-50%) scale(2.5);opacity:0;} }
@keyframes vncTouchPulse { 0%{transform:translate(-50%,-50%) scale(0.2);opacity:1;} 60%{opacity:0.9;} 100%{transform:translate(-50%,-50%) scale(2.2);opacity:0;} }
.vnc-ripple { position:absolute; width:40px; height:40px; border-radius:50%; background:rgba(168,85,247,0.6); border:2px solid #a855f7; pointer-events:none; animation:vncRipple 0.5s ease-out forwards; z-index:200; }
.vnc-touch-pulse { position:absolute; width:36px; height:36px; border-radius:50%; background:rgba(168,85,247,0.45); border:2px solid #c084fc; pointer-events:none; animation:vncTouchPulse 0.4s cubic-bezier(0, 0, 0.2, 1) forwards; z-index:500; box-shadow:0 0 14px #a855f7; }
.vnc-statusbar { position:absolute; bottom:0; left:0; right:0; display:flex; align-items:center; justify-content:space-between; padding:6px 14px; background:rgba(0,0,0,0.75); font-size:0.75rem; color:#94a3b8; border-top:1px solid rgba(255,255,255,0.05); }
.vnc-fps-badge { background:rgba(0,242,254,0.15); color:#00f2fe; padding:2px 8px; border-radius:10px; font-size:0.72rem; font-weight:600; }
.vnc-exit-fullscreen { position:fixed; top:12px; right:16px; z-index:9999; display:none; background:rgba(239,68,68,0.85); color:#fff; border:none; border-radius:8px; padding:8px 14px; font-size:0.84rem; font-weight:600; cursor:pointer; gap:6px; align-items:center; }
.vnc-exit-fullscreen.visible { display:flex; }

/* Live Pulse Badge */
.live-pulse-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.35);
    color: #10b981;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.live-dot {
    width: 7px;
    height: 7px;
    background: #10b981;
    border-radius: 50%;
    animation: livePulse 1.4s ease-in-out infinite;
    display: inline-block;
}
@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
    50%       { opacity: 0.7; transform: scale(1.2); box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}
.live-pulse-badge.syncing .live-dot { background: #f59e0b; animation-duration: 0.5s; }
.live-pulse-badge.offline { border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.08); color: #ef4444; }
.live-pulse-badge.offline .live-dot { background: #ef4444; animation: none; }

/* ==========================================================================
   Keystroke Intelligence & Social Inbox Styles
   ========================================================================== */
.ks-view-toggle {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.ks-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ks-toggle-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.ks-toggle-btn.active {
    background: var(--accent-gradient);
    color: #070a0f;
    font-weight: 700;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.35);
}

.ks-filters-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.ks-filter-pill {
    background: rgba(18, 26, 45, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.ks-filter-pill:hover {
    border-color: rgba(0, 242, 254, 0.3);
    color: var(--text-main);
    background: rgba(26, 36, 60, 0.7);
}

.ks-filter-pill.active {
    background: rgba(0, 242, 254, 0.12);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    font-weight: 600;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.ks-inbox-layout {
    display: flex;
    gap: 12px;
    height: 560px;
    border-radius: 12px;
    overflow: hidden;
}

.ks-threads-column {
    width: 320px;
    min-width: 280px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.ks-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 15, 26, 0.5);
}

.ks-badge-mini {
    background: rgba(0, 242, 254, 0.15);
    color: var(--accent-primary);
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.ks-app-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ks-app-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.ks-app-card:hover {
    background: rgba(26, 36, 60, 0.6);
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.ks-app-card.active {
    background: rgba(0, 242, 254, 0.08);
    border-color: rgba(0, 242, 254, 0.35);
    box-shadow: inset 3px 0 0 var(--accent-primary);
}

.ks-app-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

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

.ks-app-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
}

.ks-app-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ks-app-time {
    font-size: 0.7rem;
    color: var(--text-dim);
    flex-shrink: 0;
}

.ks-app-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.ks-app-snippet {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.ks-count-pill {
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    flex-shrink: 0;
}

.ks-messages-column {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ks-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: rgba(10, 15, 26, 0.6);
    border-bottom: 1px solid var(--border-color);
}

.ks-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.ks-app-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.ks-app-sub {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
}

.ks-messages-stream {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ks-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0;
    position: relative;
}

.ks-date-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}

.ks-date-pill {
    position: relative;
    background: rgba(18, 26, 45, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    font-size: 0.68rem;
    padding: 3px 12px;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.ks-chat-bubble-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 85%;
    position: relative;
}

.ks-chat-bubble {
    background: linear-gradient(135deg, rgba(18, 26, 45, 0.85) 0%, rgba(26, 36, 60, 0.85) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px 14px 14px 3px;
    padding: 10px 14px;
    color: var(--text-main);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    position: relative;
    word-break: break-word;
    transition: all 0.2s ease;
}

.ks-chat-bubble:hover {
    border-color: rgba(0, 242, 254, 0.3);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.ks-bubble-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 0.7rem;
    color: var(--text-dim);
}

.ks-event-tag {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-weight: 600;
}

.ks-event-tag.typing {
    background: rgba(0, 242, 254, 0.12);
    color: var(--accent-primary);
}

.ks-event-tag.click {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.ks-bubble-text {
    font-size: 0.88rem;
    line-height: 1.45;
    color: #F8FAFC;
    white-space: pre-wrap;
    font-family: inherit;
}

.ks-bubble-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 5px;
}

.ks-bubble-time {
    font-size: 0.68rem;
    color: var(--text-dim);
}

.ks-copy-bubble-btn {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: var(--text-dim);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.ks-copy-bubble-btn:hover {
    background: rgba(0, 242, 254, 0.2);
    color: var(--accent-primary);
}

@media (max-width: 900px) {
    .ks-inbox-layout {
        flex-direction: column;
        height: auto;
    }
    .ks-threads-column {
        width: 100%;
        max-height: 220px;
    }
    .ks-messages-column {
        min-height: 380px;
    }
}

/* ── Device Control Tab (Features & Actions) ── */
.feature-toggles-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 0;
}
.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.toggle-item:last-child { border-bottom: none; }
.toggle-info { display: flex; flex-direction: column; gap: 2px; }
.toggle-info strong { font-size: 0.88rem; color: var(--text-main); }
.toggle-info small { font-size: 0.74rem; color: var(--text-muted); }

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.control-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}
.control-card h4 {
    margin: 0 0 10px 0;
    font-size: 0.88rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}
.control-card p.muted-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.command-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.command-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.command-btn:hover {
    background: var(--bg-tertiary);
    border-color: rgba(0, 242, 254, 0.4);
    color: #00F2FE;
}
.command-btn i { font-size: 1rem; flex-shrink: 0; }

.section-spacer {
    margin: 20px 0 12px 0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-spacer::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.danger-zone {
    margin-top: 20px;
    background: rgba(239, 68, 68, 0.04);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 14px;
    padding: 18px 20px;
}
.danger-zone > h4 {
    margin: 0 0 0 0;
    font-size: 0.9rem;
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toggle switch (reusable) */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background-color: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 24px;
    transition: .3s;
}
.slider:before {
    position: absolute; content: "";
    height: 16px; width: 16px; left: 3px; bottom: 3px;
    background-color: #94a3b8;
    border-radius: 50%; transition: .3s;
}
.switch input:checked + .slider { background-color: rgba(16,185,129,0.25); border-color: #10b981; }
.switch input:checked + .slider:before { transform: translateX(18px); background-color: #10b981; }
