/* C³ CELERITY - Modern Dark UI
 * by Click Connect
 */

:root {
    /* Colors - Deep dark theme */
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #18181b;
    --bg-elevated: #1f1f23;
    --bg-hover: #27272a;
    
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-gradient-end: #7c3aed;
    --accent-hover-gradient-end: #8b5cf6;

    --success: #22c55e;
    --success-hover: #16a34a;
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning: #eab308;
    --warning-hover: #ca8a04;
    --warning-bg: rgba(234, 179, 8, 0.15);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-bg: rgba(239, 68, 68, 0.15);

    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);

    --border: #27272a;
    --border-light: #3f3f46;

    /* Aliases for backward compat */
    --primary: var(--accent);
    --text: var(--text-primary);
    --muted: var(--text-muted);
    --card-bg: var(--bg-secondary);
    --input-bg: var(--bg-primary);
    --border-color: var(--border);
    
    /* Unified radii — settings page is the reference (etalon).
     * --radius     16px : all cards, modals, panels, large surfaces
     * --radius-sm  10px : buttons, inputs, selects, small cards, pills inside cards
     * --radius-xs   6px : tiny chips, badges, code chips, micro-tags
     */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    
    --transition: 0.15s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Layout */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 12px var(--accent-glow));
    animation: pulse 3s infinite;
}

.logo-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.8;
    font-weight: 400;
}

.sidebar-version {
    display: block;
    margin-top: 10px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    opacity: 0.45;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.sidebar-version:hover {
    opacity: 0.85;
}

.login-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 16px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    opacity: 0.4;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.login-footer:hover {
    opacity: 0.8;
}

.nav-menu {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
}

.nav-menu li {
    margin-bottom: 4px;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #c4c4cc;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    position: relative;
}

.nav-menu a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    transition: height 0.3s ease;
}

.nav-menu a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-menu a:hover::before {
    height: 60%;
}

.nav-menu a.active {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-gradient-end) 100%);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-menu a.active::before {
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    color: #d4d4dc;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.logout-btn {
    display: block;
    width: 100%;
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-weight: 500;
}

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

.github-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    text-align: center;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 8px;
}

.github-link:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
    color: var(--text-primary);
}

.github-link svg {
    flex-shrink: 0;
}

/* Content */
.content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    min-width: 0;
    background: var(--bg-primary);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 12px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.main-content {
    padding: 32px;
    min-width: 0;
    position: relative;
}

.main-content::before {
    content: '';
    position: absolute;
    inset: -120px -120px auto -120px;
    height: 380px;
    background:
        radial-gradient(circle at 18% 22%, rgba(99, 102, 241, 0.22), transparent 38%),
        radial-gradient(circle at 82% 14%, rgba(168, 85, 247, 0.18), transparent 40%),
        radial-gradient(circle at 50% 80%, rgba(56, 189, 248, 0.10), transparent 36%);
    filter: blur(70px);
    opacity: 0.55;
    pointer-events: none;
    z-index: 0;
}

.main-content > *:not(.toast):not(.sticky-header) {
    position: relative;
    z-index: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, #a855f7 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

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

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

.stat-icon {
    font-size: 24px;
}

.stat-trend {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 20px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, transparent 100%);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h2 i {
    font-size: 18px;
    opacity: 0.9;
}

.card-body {
    padding: 24px;
}

.card-body.no-padding {
    padding: 0;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.table th.sortable {
    user-select: none;
    transition: all 0.2s ease;
}

.table th.sortable:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
    transform: scale(1.005);
}

.table code {
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-gradient-end) 100%);
    border: none;
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #818cf8 0%, var(--accent-hover-gradient-end) 100%);
    box-shadow: 0 6px 20px var(--accent-glow);
    transform: translateY(-2px);
}

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

.btn-success { 
    background: var(--success); 
    border-color: var(--success); 
    color: white; 
}
.btn-success:hover { 
    background: var(--success-hover); 
    border-color: var(--success-hover);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.3);
    transform: translateY(-2px);
}

.btn-warning { 
    background: var(--warning); 
    border-color: var(--warning); 
    color: black; 
}
.btn-warning:hover { 
    background: var(--warning-hover); 
    border-color: var(--warning-hover);
    box-shadow: 0 6px 20px rgba(234, 179, 8, 0.3);
    transform: translateY(-2px);
}

.btn-danger { 
    background: var(--danger); 
    border-color: var(--danger); 
    color: white; 
}
.btn-danger:hover { 
    background: var(--danger-hover); 
    border-color: var(--danger-hover);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: scale(1.1);
}

.btn-icon:hover::after {
    opacity: 1;
}

.btn-icon:active {
    transform: scale(0.95);
}

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

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 24px;
    transition: all var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-hover) 100%);
    border-color: var(--success);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch:hover .toggle-slider {
    border-color: var(--border-light);
}

.toggle-switch:hover input:checked + .toggle-slider {
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

/* Page Header with Sticky Filters */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}

/* Sticky-header is a transparent floating row — its children (filters
   pill, tabs pill, action buttons) carry their own glass surfaces, so
   no gap with topbar can ever appear. */
.sticky-header {
    position: sticky;
    top: 70px;
    z-index: 40;
    background: transparent;
    padding: 8px 0;
    margin: 0 0 22px 0;
    border-bottom: none;
}

.page-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

/* ----- Filter pill — copies .settings-tabs exactly ----- */
.filters-bar {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    padding: 6px;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
.filters-bar::-webkit-scrollbar { display: none; }

/* ----- Children: transparent pill segments matching .settings-tab ----- */
.filters-bar > * {
    flex-shrink: 0;
}

.filters-bar .search-box {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.filters-bar .search-box input {
    width: 260px;
    padding: 9px 36px 9px 36px;
    background: transparent;
    border: none;
    border-radius: 999px;
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: none;
    transition: background .2s ease, box-shadow .2s ease;
}
.filters-bar .search-box input:hover {
    background: rgba(255, 255, 255, 0.05);
}
.filters-bar .search-box input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
}
.filters-bar .search-icon {
    left: 12px;
    color: var(--text-muted);
}
.filters-bar .search-hint {
    right: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.filters-bar .filter-select {
    padding: 9px 32px 9px 16px;
    background-color: transparent;
    border: none;
    border-radius: 999px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: color .2s ease, background-color .2s ease;
}
.filters-bar .filter-select:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}
.filters-bar .filter-select:focus {
    outline: none;
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.08);
}
.filters-bar .filter-select option {
    background: #1f1f23;
    color: var(--text-primary);
}

.filters-bar .filter-count {
    color: var(--text-muted);
    font-size: 12.5px;
    padding: 0 12px 0 8px;
    white-space: nowrap;
}

/* Toolbar buttons inside the pill (e.g. Network View: auto-layout /
   fit / refresh) — transparent segments matching selects. */
.filters-bar .btn {
    background: transparent;
    border: none;
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: none;
    color: var(--text-secondary);
    transition: color .2s ease, background-color .2s ease;
}
.filters-bar .btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: none;
}

/* Action buttons next to filters wear matching pill shape */
.page-header-right .btn {
    border-radius: 999px;
    padding: 9px 18px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 280px;
    padding: 10px 14px 10px 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-box input:hover {
    border-color: var(--border-light);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    background: var(--bg-tertiary);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-hint {
    position: absolute;
    right: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: inherit;
}

.filter-select {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Results count rendered as a glass pill matching .filters-bar */
.results-count {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

/* Users Table */
.users-table-card {
    overflow: visible;
}

.table-wrapper {
    overflow-x: auto;
}

.user-row {
    transition: all var(--transition);
}

.user-row.is-selected {
    background: var(--accent-glow);
}

.user-select-cell {
    width: 42px;
    min-width: 42px;
    text-align: center;
}

.user-select-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.bulk-delete-btn {
    margin-left: 8px;
    white-space: nowrap;
}

.bulk-delete-btn[hidden] {
    display: none !important;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-id {
    font-weight: 600;
    color: var(--text-primary);
}

.user-name {
    font-size: 12px;
    color: var(--text-muted);
}

.plan-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-standart {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.plan-premium {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.traffic-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.traffic-bar {
    width: 60px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.traffic-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.traffic-limit {
    color: var(--text-muted);
    font-size: 12px;
}

.traffic-unlimited {
    color: var(--success);
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
}

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Nodes Table */
.node-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.node-name-row {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.node-name-row strong {
    display: inline;
}

.node-ip {
    font-size: 12px;
    color: var(--text-muted);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
}

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

.status-online .status-dot { 
    background: var(--success); 
    box-shadow: 0 0 12px var(--success), 0 0 20px rgba(34, 197, 94, 0.3);
}
.status-online { color: var(--success); font-weight: 500; }

.status-offline .status-dot { 
    background: var(--text-muted); 
}
.status-offline { color: var(--text-muted); }

.status-error .status-dot { 
    background: var(--danger); 
    box-shadow: 0 0 12px var(--danger);
}
.status-error { color: var(--danger); font-weight: 500; }

.status-syncing .status-dot { 
    background: var(--warning); 
    animation: pulse 1s infinite; 
    box-shadow: 0 0 12px var(--warning);
}
.status-syncing { color: var(--warning); font-weight: 500; }

.node-actions {
    display: flex;
    gap: 8px;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    width: 100%;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.quick-action::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left 0.5s ease;
}

.quick-action:hover::before {
    left: 100%;
}

.quick-action:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateX(4px);
}

.quick-action:active {
    transform: translateX(2px) scale(0.98);
}

.qa-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* System Info */
.system-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sys-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.sys-item:last-child {
    border-bottom: none;
}

.sys-label {
    color: var(--text-muted);
    font-size: 13px;
}

.sys-value {
    font-weight: 500;
    font-size: 13px;
}

/* Logs */
.logs-container {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: var(--bg-primary);
}

.log-line {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: anywhere;
}

.log-line:hover {
    background: var(--bg-tertiary);
}

.log-error { color: var(--danger); }
.log-warn { color: var(--warning); }
.log-success { color: var(--success); }

.logs-empty, .logs-loading, .logs-error {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

/* Logs search */
.logs-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logs-search-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    padding: 7px 12px;
    width: 180px;
    outline: none;
    transition: all 0.2s ease;
}

.logs-search-input:hover {
    border-color: var(--border-light);
}

.logs-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-tertiary);
    width: 220px;
}

.logs-search-input::placeholder {
    color: var(--text-muted);
}

.logs-search-count {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px 8px;
    min-width: 20px;
    text-align: center;
}

.logs-search-count:empty {
    display: none;
}

.logs-search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
    margin-left: -4px;
}

.logs-search-clear:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.page-btn.active {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-gradient-end) 100%);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
    transform: scale(1.05);
}

.page-btn:active {
    transform: scale(0.95);
}

.page-dots {
    color: var(--text-muted);
    padding: 0 8px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transform: translateY(150px) scale(0.9);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    backdrop-filter: blur(12px);
    min-width: 280px;
}

.toast.show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.toast.error {
    border-color: var(--danger);
    background: linear-gradient(135deg, var(--danger-bg) 0%, rgba(239, 68, 68, 0.05) 100%);
    color: var(--danger);
}

.toast.success {
    border-color: var(--success);
    background: linear-gradient(135deg, var(--success-bg) 0%, rgba(34, 197, 94, 0.05) 100%);
    color: var(--success);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
    min-width: 0;
}

.form-group label:not(.checkbox-label) {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.form-group input:not([type="checkbox"]):not([type="radio"]):hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--border-light);
}

.form-group small {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr);
    gap: 16px;
}

.form-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.form-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.section-hint {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.docs-hint-link {
    display: inline-block;
    margin-right: 6px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.docs-hint-link:hover,
.docs-hint-link:focus {
    text-decoration: underline;
}

.optional-fields-wrap {
    margin-top: 12px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    line-height: 1.35;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 0;
    vertical-align: middle;
}

.form-group label.checkbox-label {
    display: flex;
    margin-bottom: 0;
}

.checkbox-label > input[type="checkbox"],
.checkbox-label > input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
}

.checkbox-label > input[type="checkbox"]:hover,
.checkbox-label > input[type="checkbox"]:focus,
.checkbox-label > input[type="radio"]:hover,
.checkbox-label > input[type="radio"]:focus {
    background: transparent;
    box-shadow: none;
    transform: none;
}

.checkbox-label > .checkbox-text,
.checkbox-label > span {
    line-height: 1.35;
}

/* Onboarding Pages */
.onboarding-page {
    min-height: 100vh;
    padding: 32px 16px 48px;
    background:
        radial-gradient(circle at top, rgba(99, 102, 241, 0.16) 0%, transparent 32%),
        linear-gradient(135deg, #09090b 0%, #0f1020 48%, #111113 100%);
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
}

.onboarding-page::before,
.onboarding-page::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.onboarding-page::before {
    inset: -35vmax;
    background: conic-gradient(
        from 0deg,
        rgba(99, 102, 241, 0.18),
        rgba(168, 85, 247, 0.14),
        rgba(14, 165, 233, 0.12),
        rgba(99, 102, 241, 0.18)
    );
    filter: blur(96px);
    opacity: 0.9;
    transform-origin: center;
    animation: onboardingRotate 42s linear infinite;
}

.onboarding-page::after {
    background:
        radial-gradient(circle at 18% 18%, rgba(99, 102, 241, 0.18), transparent 26%),
        radial-gradient(circle at 82% 16%, rgba(168, 85, 247, 0.16), transparent 28%),
        radial-gradient(circle at 50% 82%, rgba(56, 189, 248, 0.12), transparent 24%);
    animation: onboardingFloat 18s ease-in-out infinite alternate;
}

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

@keyframes onboardingFloat {
    to { transform: translate3d(0, 18px, 0) scale(1.04); }
}

.onboarding-shell {
    position: relative;
    z-index: 1;
    width: min(100%, 760px);
    margin: 0 auto;
}

.onboarding-card {
    position: relative;
    background: rgba(17, 17, 19, 0.86);
    border: 1px solid rgba(63, 63, 70, 0.78);
    border-radius: 24px;
    padding: clamp(24px, 4vw, 46px);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.onboarding-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 28%);
    pointer-events: none;
}

.onboarding-header {
    text-align: center;
    margin-bottom: 32px;
}

.onboarding-header .logo-icon {
    font-size: 48px;
    display: inline-block;
    filter: drop-shadow(0 0 18px var(--accent-glow));
}

.onboarding-header h1 {
    margin-top: 16px;
    font-size: clamp(28px, 4vw, 36px);
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.onboarding-brand {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    background: linear-gradient(135deg, var(--accent) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.onboarding-subtitle {
    max-width: 620px;
    margin: 12px auto 0;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.65;
}

.onboarding-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    margin: 0 auto 28px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.onboarding-lang-switch a {
    min-width: 48px;
    padding: 7px 14px;
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.onboarding-lang-switch a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.onboarding-lang-switch a.active {
    color: white;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-gradient-end) 100%);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.25);
}

.onboarding-stack > * + * {
    margin-top: 18px;
}

.onboarding-section {
    position: relative;
    border: 1px solid rgba(63, 63, 70, 0.9);
    border-radius: 18px;
    padding: 20px;
    background: rgba(24, 24, 27, 0.74);
}

.onboarding-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.onboarding-section-title i {
    font-size: 16px;
    color: var(--accent);
}

.onboarding-section-copy {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.65;
}

.onboarding-feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.onboarding-feature-card {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(63, 63, 70, 0.9);
    background: rgba(24, 24, 27, 0.72);
}

.onboarding-feature-card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-primary);
}

.onboarding-feature-card span {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}

.onboarding-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.onboarding-actions .btn {
    flex: 1 1 0;
    padding: 14px 20px;
    font-size: 15px;
    min-height: 48px;
}

.onboarding-progress-meta {
    text-align: center;
    margin-bottom: 22px;
}

.onboarding-progress-meta p {
    color: var(--text-secondary);
    font-size: 14px;
}

@media (max-width: 800px) {
    .onboarding-feature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .onboarding-page {
        padding: 18px 12px 28px;
    }

    .onboarding-card {
        border-radius: 20px;
        padding: 20px 18px;
    }

    .onboarding-header {
        margin-bottom: 24px;
    }

    .onboarding-actions {
        flex-direction: column;
    }
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 16px 48px;
    background:
        radial-gradient(circle at top, rgba(99, 102, 241, 0.16) 0%, transparent 32%),
        linear-gradient(135deg, #09090b 0%, #0f1020 48%, #111113 100%);
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
}

.login-page::before,
.login-page::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.login-page::before {
    inset: -35vmax;
    background: conic-gradient(
        from 0deg,
        rgba(99, 102, 241, 0.18),
        rgba(168, 85, 247, 0.14),
        rgba(14, 165, 233, 0.12),
        rgba(99, 102, 241, 0.18)
    );
    filter: blur(96px);
    opacity: 0.9;
    transform-origin: center;
    animation: onboardingRotate 42s linear infinite;
}

.login-page::after {
    background:
        radial-gradient(circle at 18% 18%, rgba(99, 102, 241, 0.18), transparent 26%),
        radial-gradient(circle at 82% 16%, rgba(168, 85, 247, 0.16), transparent 28%),
        radial-gradient(circle at 50% 82%, rgba(56, 189, 248, 0.12), transparent 24%);
    animation: onboardingFloat 18s ease-in-out infinite alternate;
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-box {
    position: relative;
    background: rgba(17, 17, 19, 0.86);
    border: 1px solid rgba(63, 63, 70, 0.78);
    border-radius: 24px;
    padding: clamp(28px, 4vw, 48px);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
}

.login-box::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 28%);
    pointer-events: none;
}

.login-box > * {
    position: relative;
    z-index: 1;
}

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

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header .logo-icon {
    font-size: 48px;
    filter: drop-shadow(0 0 20px var(--accent-glow));
    display: inline-block;
    animation: pulse 2s infinite;
}

.login-header h1 {
    margin-top: 16px;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-secondary);
    margin-top: 8px;
}

.login-form .form-group {
    margin-bottom: 24px;
}

.login-form .btn-block {
    padding: 14px 20px;
    font-size: 15px;
    min-height: 48px;
}

/* TOTP Enrollment */
.login-container.totp-enrollment {
    max-width: 480px;
}

.totp-qr-section {
    display: flex;
    justify-content: center;
    padding: 20px 0;
}

.totp-qr {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-sm);
    background: #fafafa;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.totp-secret {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 20px;
}

.totp-secret-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.totp-secret-value {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-all;
    line-height: 1.5;
}

.totp-secret-hint {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 480px) {
    .totp-qr {
        width: 160px;
        height: 160px;
    }

    .login-container.totp-enrollment .login-box {
        padding: 28px 20px;
    }
}

/* Login Language Switcher */
.login-lang-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    margin: 0 auto 24px;
    width: fit-content;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.login-lang-switcher .lang-btn {
    min-width: 48px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 999px;
    background: transparent;
    text-align: center;
    transition: all 0.2s ease;
}

.login-lang-switcher .lang-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.login-lang-switcher .lang-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-gradient-end) 100%);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.25);
}

/* Lockout Alert */
.lockout-alert {
    margin-bottom: 16px;
}

.lockout-meta {
    margin-top: 6px;
    font-size: 12px;
    opacity: 0.9;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.badge-success { 
    background: var(--success-bg); 
    color: var(--success); 
    border-color: var(--success);
}

.badge-warning { 
    background: var(--warning-bg); 
    color: var(--warning); 
    border-color: var(--warning);
}

.badge-danger { 
    background: var(--danger-bg); 
    color: var(--danger); 
    border-color: var(--danger);
}

.badge-secondary { 
    background: var(--bg-tertiary); 
    color: var(--text-secondary); 
    border-color: var(--border);
}

.badge-lg { 
    padding: 7px 16px; 
    font-size: 12px; 
}

.badge:hover {
    transform: scale(1.05);
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.detail-item {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.detail-item label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.detail-item .value {
    font-size: 14px;
    font-weight: 500;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    margin: 28px 0 16px;
    color: var(--text-secondary);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Nodes List */
.nodes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.node-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.node-name {
    font-weight: 600;
}

/* Actions List */
.actions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Input readonly */
.input-readonly {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* Grid */
.row {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.col { flex: 1; }
.col-4 { flex: 0 0 33.333%; }
.col-6 { flex: 0 0 calc(50% - 12px); }
.col-8 { flex: 0 0 calc(66.666% - 12px); }

/* Empty State */
.empty-state {
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty-cell {
    padding: 0 !important;
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.hint { font-size: 13px; color: var(--text-muted); }

/* Settings grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.settings-grid .form-group {
    margin-bottom: 0;
}
.settings-grid input[type="number"] {
    width: 100%;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-error { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success); color: var(--success); }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning); color: var(--warning); }
.alert-info { background: var(--info-bg); border: 1px solid var(--info); color: var(--text-secondary); }
.alert-info strong { color: var(--info); }
.alert-info code { color: var(--text-primary); }

/* Groups */
.groups-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.checkbox-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    background: var(--bg-tertiary);
}

.checkbox-tag:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.checkbox-tag input {
    display: none;
}

.checkbox-tag:has(input:checked) {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--accent-glow);
    transform: scale(1.02);
}

.checkbox-tag:has(input:checked) span {
    color: white;
    font-weight: 600;
}

.checkbox-tag:has(input:checked) .tag-dot {
    background: white !important;
    box-shadow: 0 0 8px rgba(255,255,255,0.5);
}

.tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.group-tag {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 6px;
    transition: all 0.2s ease;
    cursor: default;
}

.group-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.group-tag-sm {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border: 1px solid;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-right: 4px;
    transition: all 0.2s ease;
    cursor: default;
}

.group-tag-sm:hover {
    transform: scale(1.08);
}

.group-more {
    font-size: 11px;
    color: var(--text-muted);
}

.groups-list {
    margin-top: 8px;
}

/* Actions Grid (Node Management) */
.actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn .action-icon {
    font-size: 16px;
}

/* Mobile Header (hidden on desktop) */
.mobile-header {
    display: none;
}

.mobile-overlay {
    display: none;
}

/* Mobile Cards — hidden by default (shown only on mobile breakpoint) */
.mobile-nodes-list,
.mobile-users-list {
    display: none;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-btn span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Hide desktop tables */
    .table-wrapper {
        display: none !important;
    }
    
    /* Show mobile cards */
    .mobile-nodes-list,
    .mobile-users-list {
        display: flex !important;
    }
    
    /* Mobile Header */
    .mobile-header {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        z-index: 200;
    }

    /* Logo is absolutely centered relative to the header so the menu
       button on the left can't pull the title off-axis. */
    .mobile-logo {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        display: flex;
        align-items: center;
        gap: 8px;
        pointer-events: none;
    }

    /* Lightning icon and the green status dot are intentionally hidden
       on mobile to keep the header focused on the centered wordmark. */
    .mobile-logo .logo-icon,
    .mobile-status {
        display: none;
    }

    .mobile-logo .logo-text {
        font-size: 16px;
        font-weight: 700;
        letter-spacing: 0.5px;
        background: linear-gradient(135deg, var(--accent) 0%, #a855f7 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .mobile-menu-btn {
        display: flex;
    }
    
    /* Overlay */
    .mobile-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 150;
    }
    
    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Sidebar Mobile */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 200;
        transition: left 0.3s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Content */
    .content {
        margin-left: 0;
        padding-top: 60px;
        width: 100%;
    }
    
    .topbar {
        position: relative;
        padding: 16px;
    }

    .topbar h1 {
        font-size: 18px;
    }

    .topbar-right .status-text {
        display: none;
    }

    .main-content {
        padding: 16px;
    }

    /* On mobile we drop sticky behaviour so the pill bar scrolls away
       with the page instead of eating half the screen on long lists. */
    .sticky-header {
        position: relative;
        top: auto;
        padding: 4px 0;
        margin: 0 0 14px 0;
    }

    /* Toast centered on mobile */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        min-width: 0;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }
    
    /* Forms */
    .form-row,
    .form-row-3,
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .row {
        flex-direction: column;
        gap: 16px;
    }
    
    .col-4, .col-6, .col-8 {
        flex: 1;
    }
    
    /* Mobile page header: the filter pill keeps its shape and scrolls
       horizontally inside its row, so the whole header stays compact. */
    .page-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .page-header-left,
    .page-header-right {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: wrap;
    }

    .page-header-center {
        width: 100%;
        justify-content: flex-start;
    }

    /* Pill is allowed to overflow its row and scroll horizontally */
    .filters-bar {
        max-width: 100%;
        gap: 2px;
    }

    .filters-bar .search-box input {
        width: 180px;
        font-size: 13px;
    }

    .filters-bar .filter-select {
        font-size: 13px;
        padding: 8px 26px 8px 12px;
    }

    /* Hide the keyboard hint on mobile — there's no keyboard */
    .filters-bar .search-hint {
        display: none;
    }

    .page-header-right .btn {
        flex: 0 1 auto;
        white-space: nowrap;
    }

    /* Floating action button — primary "Create" lifted into the
       bottom-right corner so it stays one tap away while the user
       scrolls a long list. */
    .page-fab-mobile {
        position: fixed;
        right: 18px;
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        z-index: 100;
        width: 56px;
        height: 56px;
        padding: 0;
        gap: 0;
        border-radius: 50%;
        box-shadow:
            0 12px 28px rgba(99, 102, 241, 0.45),
            0 4px 12px rgba(0, 0, 0, 0.45);
    }
    .page-fab-mobile i {
        font-size: 24px;
    }
    .page-fab-mobile .fab-label {
        display: none;
    }
    .page-fab-mobile:active {
        transform: scale(0.94);
    }
    /* `display: contents` removes the wrapper's box without hiding its
       child — the FAB still renders (it's fixed-positioned anyway) but
       the now-redundant row stops contributing a flex gap. Older
       browsers without :has() simply leave a small empty row. */
    .page-header-right:has(.page-fab-mobile) {
        display: contents;
    }

    .logs-search-wrap {
        flex: 1;
        min-width: 0;
    }

    .logs-search-input {
        width: 100% !important;
    }

    .logs-search-input:focus {
        width: 100% !important;
    }
    
    /* Tables — hidden on mobile */
    .table-wrapper {
        display: none;
    }
    
    /* Mobile Cards — shown only on mobile */
    .mobile-nodes-list,
    .mobile-users-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }
    
    .mobile-node-card,
    .mobile-user-card {
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 16px;
        transition: all 0.2s ease;
    }
    
    .mobile-node-card:active,
    .mobile-user-card:active {
        transform: scale(0.98);
        background: var(--bg-hover);
    }
    
    .mobile-node-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
        gap: 12px;
    }

    .mobile-user-title-wrap {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        min-width: 0;
    }

    .mobile-user-card.is-selected {
        border-color: var(--accent);
        background: rgba(99, 102, 241, 0.12);
    }

    .mobile-user-select {
        margin-top: 2px;
        flex: 0 0 auto;
    }
    
    .mobile-node-title {
        flex: 1;
        min-width: 0;
    }
    
    .mobile-node-title strong {
        font-size: 15px;
        display: block;
        margin-bottom: 4px;
    }
    
    .mobile-node-title code {
        font-size: 12px;
        color: var(--text-muted);
    }
    
    .mobile-node-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 12px;
    }
    
    .mobile-stat-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .mobile-stat-label {
        font-size: 11px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .mobile-stat-value {
        font-size: 14px;
        font-weight: 500;
    }
    
    /* Equal-width icon buttons (restart / edit / delete). Each child
       takes the same flex share so the row stays symmetric. */
    .mobile-node-actions {
        display: flex;
        gap: 8px;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }
    .mobile-node-actions > .btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 10px 0;
        gap: 0;
    }
    .mobile-node-actions > .btn i {
        font-size: 18px;
    }
    
    
    /* Logs Container Mobile */
    .logs-container {
        max-height: 200px;
        font-size: 11px;
    }
    
    .log-line {
        padding: 6px 12px;
        word-break: break-word;
        white-space: pre-wrap;
        font-size: 10px;
    }
    
    /* Buttons — only full-width in form/action contexts */
    .form-actions .btn,
    .actions-list .btn,
    .login-form .btn {
        width: 100%;
        justify-content: center;
    }

    .btn-sm {
        padding: 10px 16px;
    }

    .action-buttons {
        justify-content: center;
    }
    
    /* Cards */
    .card {
        border-radius: var(--radius);
    }
    
    .card-header {
        padding: 16px;
        flex-wrap: wrap;
    }
    
    .card-body {
        padding: 16px;
    }
    
    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .dashboard-main,
    .dashboard-sidebar {
        width: 100%;
        margin-top: 0;
    }
    
    /* Nodes table scrollable */
    .nodes-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Quick Actions */
    .quick-action {
        padding: 16px;
        font-size: 15px;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
    }
    
    .page-btn {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
    }
    
    /* Forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Login Page */
    .login-container {
        padding: 16px;
    }
    
    .login-box {
        padding: 32px 24px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-label {
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 10px 8px;
        font-size: 12px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .action-buttons {
        gap: 6px;
    }
}

/* Language Switcher — pill capsule (mirrors settings tab bar) */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
}

.lang-btn {
    flex: 1;
    padding: 7px 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    text-decoration: none;
    background: transparent;
    border-radius: 999px;
    transition: color .2s ease, background .2s ease, transform .15s ease;
}

.lang-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.lang-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-gradient-end) 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.30),
                0 1px 0 rgba(255, 255, 255, 0.18) inset,
                0 -1px 0 rgba(0, 0, 0, 0.25) inset;
}

.lang-btn:active {
    transform: scale(0.97);
}

.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-group .datetime-input {
    color-scheme: dark;
    padding-right: 44px;
}

.form-group .datetime-input::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    border-radius: var(--radius-xs);
    padding: 4px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-light);
    filter: invert(94%) sepia(7%) saturate(154%) hue-rotate(192deg) brightness(91%) contrast(96%);
    transition: all var(--transition);
}

.form-group .datetime-input::-webkit-calendar-picker-indicator:hover {
    background-color: var(--bg-hover);
    border-color: var(--accent);
}

.form-group .datetime-input::-webkit-calendar-picker-indicator:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ── Tabler Icons ── */
.ti {
    font-size: 1em;
    line-height: 1;
    vertical-align: -0.125em;
}

/* Spinner animation for loader icons */
@keyframes ti-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.ti-loader-2 {
    display: inline-block;
    animation: ti-spin 1s linear infinite;
}

/* ─── Page enter animations ───────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

/* Main content area fades in on navigation */
.main-content {
    animation: fadeIn 0.2s ease-out;
}

/* Stats cards stagger */
.stat-card {
    animation: fadeUp 0.3s ease-out both;
}
.stat-card:nth-child(1) { animation-delay: 0.03s; }
.stat-card:nth-child(2) { animation-delay: 0.07s; }
.stat-card:nth-child(3) { animation-delay: 0.11s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }

/* Cards */
.card {
    animation: fadeUp 0.25s ease-out both;
}

/* Dashboard grid children stagger */
.dashboard-main > .card:nth-child(1) { animation-delay: 0.05s; }
.dashboard-main > .card:nth-child(2) { animation-delay: 0.1s; }
.dashboard-sidebar > .card:nth-child(1) { animation-delay: 0.08s; }
.dashboard-sidebar > .card:nth-child(2) { animation-delay: 0.13s; }

/* Table rows */
.table tbody tr {
    animation: fadeIn 0.2s ease-out both;
}
.table tbody tr:nth-child(1)  { animation-delay: 0.04s; }
.table tbody tr:nth-child(2)  { animation-delay: 0.07s; }
.table tbody tr:nth-child(3)  { animation-delay: 0.10s; }
.table tbody tr:nth-child(4)  { animation-delay: 0.13s; }
.table tbody tr:nth-child(5)  { animation-delay: 0.16s; }
.table tbody tr:nth-child(n+6) { animation-delay: 0.18s; }

/* Topbar */
.topbar {
    animation: fadeIn 0.15s ease-out;
}

/* Page header — fadeIn (opacity-only) so we don't leave a frozen
   transform on the wrapper. A non-identity transform here would create
   a stacking context that breaks `backdrop-filter` on descendants
   (the glass filter pills), regardless of how it's painted. */
.page-header {
    animation: fadeIn 0.2s ease-out;
}

/* Quick action items */
.quick-action {
    animation: fadeUp 0.25s ease-out both;
}
.quick-actions .quick-action:nth-child(1) { animation-delay: 0.05s; }
.quick-actions .quick-action:nth-child(2) { animation-delay: 0.08s; }
.quick-actions .quick-action:nth-child(3) { animation-delay: 0.11s; }
.quick-actions .quick-action:nth-child(4) { animation-delay: 0.14s; }
.quick-actions .quick-action:nth-child(5) { animation-delay: 0.17s; }

/* Respect prefer-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .main-content, .stat-card, .card, .table tbody tr,
    .nav-menu li, .topbar, .page-header, .quick-action {
        animation: none;
    }
}

/* ==================== CASCADE ROLE PICKER ==================== */

.cascade-role-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.role-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.18s;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.02));
    user-select: none;
}

.role-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
}

.role-card.active {
    border-color: var(--accent, #6366f1);
    background: rgba(99, 102, 241, 0.08);
}

.role-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.role-card-icon.role-standalone { background: rgba(71, 85, 105, 0.3); color: #94a3b8; }
.role-card-icon.role-portal     { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
.role-card-icon.role-bridge     { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.role-card-icon.role-relay      { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }

.role-card.active .role-card-icon.role-standalone { background: rgba(71, 85, 105, 0.5); }
.role-card.active .role-card-icon.role-portal     { background: rgba(99, 102, 241, 0.3); }
.role-card.active .role-card-icon.role-bridge     { background: rgba(245, 158, 11, 0.3); }
.role-card.active .role-card-icon.role-relay      { background: rgba(139, 92, 246, 0.3); }

.role-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.role-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    white-space: nowrap;
}

.role-card-name small {
    font-weight: 400;
    color: var(--text-muted, #64748b);
    font-size: 10px;
}

.role-card-desc {
    font-size: 10px;
    color: var(--text-muted, #64748b);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ==================== CASCADE LINKS TABLE ==================== */

.cascade-links-table td { vertical-align: middle; }

.cascade-node-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.badge-this {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    background: rgba(99, 102, 241, 0.18);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
    text-transform: uppercase;
}

.cascade-link-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}
/* Global Focus States for Accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:focus-visible,
.btn-icon:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Typography Refinements */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    letter-spacing: -0.02em;
}

p {
    line-height: 1.6;
}

.ti {
    vertical-align: middle;
    position: relative;
    top: -1px;
}

/* Table Polish */
.table th {
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--bg-hover);
    transform: none; /* Remove scale for better performance and less jank */
}

/* Badge Polish */
.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge:hover {
    transform: none; /* Remove scale for better UX */
    filter: brightness(1.1);
}

/* Form Polish */
.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    transform: none; /* Remove transform for better UX */
}

.form-group label:not(.checkbox-label) {
    color: var(--text-primary);
}

/* Card Polish */
.card {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: var(--bg-secondary);
}

.stat-card {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Button Polish */
.btn {
    letter-spacing: 0.01em;
}

.btn:active {
    transform: scale(0.98);
}

.btn-icon:active {
    transform: scale(0.92);
}

/* Nav Menu Polish */
.nav-menu a {
    border-radius: var(--radius-sm);
}

.nav-menu a:active {
    transform: scale(0.98);
}

/* Transition Polish */
.btn, .btn-icon, .nav-menu a, .card, .stat-card, .action-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Port chips for the Nodes table — used when an Xray node has multiple
 * client-facing inbounds (main + extras). */
.port-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.port-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.4;
    cursor: help;
}
.port-chip-extra {
    background: var(--accent-glow, rgba(99, 102, 241, 0.12));
    border-color: var(--accent, #6366f1);
    color: var(--accent, #6366f1);
}

/* ============================================================
 * Glass surfaces, settings page layout & components
 * ============================================================ */

:root {
    /* Frosted surface tokens */
    --glass-bg:        rgba(24, 24, 27, 0.62);
    --glass-bg-strong: rgba(24, 24, 27, 0.78);
    --glass-bg-soft:   rgba(255, 255, 255, 0.025);
    --glass-border:    rgba(255, 255, 255, 0.08);
    --glass-border-strong: rgba(255, 255, 255, 0.14);
    --glass-highlight: rgba(255, 255, 255, 0.06);
    --glass-shadow:    0 1px 0 rgba(255, 255, 255, 0.04) inset,
                       0 -1px 0 rgba(0, 0, 0, 0.35) inset,
                       0 8px 32px rgba(0, 0, 0, 0.32);
    --glass-shadow-lg: 0 1px 0 rgba(255, 255, 255, 0.06) inset,
                       0 -1px 0 rgba(0, 0, 0, 0.4) inset,
                       0 24px 60px rgba(0, 0, 0, 0.45);
    --glass-blur:      saturate(180%) blur(22px);
    --glass-blur-sm:   saturate(160%) blur(14px);
}

/* Generic .glass utility — frosted card with subtle inner highlight */
.glass {
    position: relative;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius);
    overflow: hidden;
}

.glass::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.06) 0%,
        rgba(255, 255, 255, 0.0) 24%,
        transparent 100%);
    border-radius: inherit;
}

/* Frosted card variant (opt-in via .card-glass) — leaves legacy .card intact */
.card-glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow);
}

/* Reusable glass modal — overlay + content card */
.glass-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(8, 8, 10, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.glass-modal-content {
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border-strong);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow-lg);
}

/* Topbar: subtle glass */
.topbar {
    background: rgba(17, 17, 19, 0.72);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

/* Mobile header glass */
.mobile-header {
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
}

/* Sidebar — gentle glassy tint */
.sidebar {
    background: linear-gradient(180deg,
        rgba(17, 17, 19, 0.96) 0%,
        rgba(15, 16, 27, 0.96) 100%);
    border-right: 1px solid var(--glass-border);
}

/* Toast — fully glass */
.toast {
    background: rgba(31, 31, 35, 0.78);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border-strong);
    box-shadow: var(--glass-shadow-lg);
}

/* ============================================================
 * SETTINGS PAGE — refined layout & components
 * ============================================================ */

/* Page wrapper provides subtle ambient gradient (only when used) */
/* Sticky tab bar (glass pills) — no fill, just sticky positioning */
.settings-tabbar {
    position: sticky;
    top: 73px; /* below topbar */
    z-index: 30;
    margin: 0 0 22px 0;
    padding: 0;
    background: transparent;
}

.settings-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }

.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 999px;
    transition: color .2s ease, background .2s ease, transform .15s ease;
    position: relative;
}

.settings-tab i {
    font-size: 16px;
    opacity: .85;
}

.settings-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.settings-tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-gradient-end) 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35),
                0 1px 0 rgba(255, 255, 255, 0.18) inset,
                0 -1px 0 rgba(0, 0, 0, 0.25) inset;
}

.settings-tab.active i { opacity: 1; }

.settings-tab:active {
    transform: scale(0.97);
}

/* Per-tab caption shown above the content */
.settings-tab-caption {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px 18px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
}

.settings-tab-caption .stc-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 19px;
    background: linear-gradient(135deg, rgba(99,102,241,0.22), rgba(168,85,247,0.16));
    color: #c7d2fe;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.settings-tab-caption .stc-text {
    min-width: 0;
}

.settings-tab-caption .stc-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin: 0;
}

.settings-tab-caption .stc-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 2px 0 0;
    line-height: 1.5;
}

/* Cards inside settings: frosted surface treatment */
.settings-page .card,
.settings-page .card-glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
    position: relative;
    overflow: hidden;
}

.settings-page .card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.0) 30%,
        transparent 100%);
    border-radius: inherit;
}

.settings-page .card > * {
    position: relative;
    z-index: 1;
}

.settings-page .card-header {
    background: transparent;
    border-bottom: 1px solid var(--glass-border);
    padding: 16px 20px;
    gap: 12px;
}

.settings-page .card-header h2 {
    font-size: 14.5px;
    letter-spacing: -0.005em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Section icon chip in card headers (auto applied to first <i>) */
.settings-page .card-header h2 > i:first-child {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(168,85,247,0.12));
    color: #c7d2fe;
    border: 1px solid rgba(99, 102, 241, 0.2);
    flex-shrink: 0;
}

.settings-page .card-body {
    padding: 18px 20px;
}

/* Hover lift, but gentle */
.settings-page .card:hover {
    border-color: var(--glass-border-strong);
    box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset,
                0 -1px 0 rgba(0,0,0,0.4) inset,
                0 14px 44px rgba(0, 0, 0, 0.42);
}

/* Settings-list: compact rows with cleaner separators */
.settings-list .setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--glass-border);
}

.settings-list .setting-item:last-child {
    border-bottom: none;
}

.settings-list .setting-item label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.settings-list .setting-item span,
.settings-list .setting-item code {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
}

.settings-list .setting-item code {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    padding: 3px 7px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
}

/* Form group hints inside settings — slightly tighter */
.settings-page .form-group small.hint,
.settings-page small.hint {
    color: var(--text-muted);
    line-height: 1.55;
    font-size: 12px;
}

/* Form inputs glass treatment */
.settings-page .form-group input:not([type="checkbox"]):not([type="radio"]),
.settings-page .form-group select,
.settings-page .form-group textarea {
    background: rgba(10, 10, 11, 0.55);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    transition: all 0.18s ease;
}

.settings-page .form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.settings-page .form-group select:focus,
.settings-page .form-group textarea:focus {
    background: rgba(10, 10, 11, 0.8);
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

/* Action bar at the bottom of forms — just alignment, no surface */
.settings-save-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* Stat-pill rows: compact key metric chips for the System tab */
.settings-stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.settings-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
    transition: border-color .2s ease, transform .15s ease;
}

.settings-stat:hover {
    border-color: var(--glass-border-strong);
    transform: translateY(-1px);
}

.settings-stat-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 18px;
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(168,85,247,0.14));
    color: #c7d2fe;
    border: 1px solid rgba(99, 102, 241, 0.22);
}

.settings-stat-icon.success {
    background: linear-gradient(135deg, rgba(34,197,94,0.22), rgba(34,197,94,0.10));
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.28);
}
.settings-stat-icon.warning {
    background: linear-gradient(135deg, rgba(234,179,8,0.22), rgba(234,179,8,0.10));
    color: #fde047;
    border-color: rgba(234, 179, 8, 0.28);
}
.settings-stat-icon.info {
    background: linear-gradient(135deg, rgba(56,189,248,0.22), rgba(56,189,248,0.10));
    color: #7dd3fc;
    border-color: rgba(56, 189, 248, 0.28);
}

.settings-stat-content {
    min-width: 0;
    flex: 1;
}

.settings-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 2px;
    font-weight: 600;
}

.settings-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-stat-value code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    padding: 2px 6px;
}

/* Danger zone card */
.settings-page .card.danger-zone {
    border-color: rgba(239, 68, 68, 0.32);
    background: linear-gradient(180deg, rgba(239,68,68,0.06), rgba(24,24,27,0.6));
}

.settings-page .card.danger-zone .card-header {
    border-bottom-color: rgba(239, 68, 68, 0.2);
}

.settings-page .card.danger-zone .card-header h2 {
    color: #fca5a5;
}

.settings-page .card.danger-zone .card-header h2 > i:first-child {
    background: linear-gradient(135deg, rgba(239,68,68,0.24), rgba(239,68,68,0.12));
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.32);
}

/* Modal glass overhaul (used by API key + MCP modals) */
.settings-page [id$="Modal"] > div,
.glass-modal {
    background: rgba(20, 20, 23, 0.86) !important;
    border: 1px solid var(--glass-border-strong) !important;
    border-radius: var(--radius) !important;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow-lg) !important;
}

/* Backdrop dimmer for modals */
[id$="Modal"][style*="flex"] {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Code blocks within settings: glass-tinted */
.settings-page pre,
.settings-page code:not(.setting-item code):not(.table code) {
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
}

/* Subtle divider helper */
.settings-divider {
    height: 1px;
    margin: 18px 0;
    background: linear-gradient(90deg, transparent, var(--glass-border-strong), transparent);
    border: none;
}

/* Section subhead used inside cards */
.settings-subsection-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.settings-subsection-title i {
    color: var(--accent);
    font-size: 15px;
}

.settings-subsection-title:first-child {
    margin-top: 0;
}

/* Mobile tweaks for settings */
@media (max-width: 768px) {
    .settings-tabbar {
        top: 60px;
        margin: 0 0 18px 0;
        padding: 0;
    }

    .settings-tabs {
        width: 100%;
        border-radius: var(--radius);
        flex-wrap: nowrap;
    }

    .settings-tab {
        padding: 8px 12px;
        font-size: 12.5px;
    }

    .settings-tab i { font-size: 15px; }

    .settings-tab-caption {
        padding: 12px 14px;
        gap: 10px;
    }

    .settings-tab-caption .stc-icon {
        width: 34px;
        height: 34px;
        font-size: 17px;
    }

    .settings-stat-row {
        grid-template-columns: 1fr;
    }

    .settings-page .card-body {
        padding: 14px 16px;
    }

    .settings-save-bar {
        flex-wrap: wrap;
    }
}

/* Accessibility: focus visible on tabs */
.settings-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .settings-tab, .settings-stat, .settings-page .card {
        transition: none;
    }
}

/* ============================================================
 * Global glass treatment — applies to every page in the panel
 * Lives at end of file so it overrides earlier flat-color rules.
 * ============================================================ */

/* Body — subtle ambient gradient under all content */
body {
    background:
        radial-gradient(ellipse at 0% 0%,   rgba(99, 102, 241, 0.08), transparent 45%),
        radial-gradient(ellipse at 100% 0%, rgba(168, 85, 247, 0.06), transparent 50%),
        var(--bg-primary);
    background-attachment: fixed;
}

/* Cards everywhere become frosted */
.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
    position: relative;
}

.card::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.0) 28%,
        transparent 100%);
    border-radius: inherit;
}

.card > * { position: relative; z-index: 1; }

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--glass-border);
}

.card:hover {
    border-color: var(--glass-border-strong);
    box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset,
                0 -1px 0 rgba(0,0,0,0.4) inset,
                0 14px 44px rgba(0, 0, 0, 0.42);
}

/* Stat cards (dashboard) — glass */
.stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
}

.stat-card:hover {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset,
                0 -1px 0 rgba(0,0,0,0.4) inset,
                0 18px 50px rgba(99, 102, 241, 0.18);
}

/* Quick actions — glass tint */
.quick-action {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
}

.quick-action:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.4);
}

/* Tables — translucent header */
.table th {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
}

.table td {
    border-bottom: 1px solid var(--glass-border);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

/* Search box / filter selects — glass */
.search-box input,
.filter-select,
.logs-search-input {
    background: rgba(10, 10, 11, 0.55);
    border-color: var(--glass-border);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
}

.search-box input:focus,
.filter-select:focus,
.logs-search-input:focus {
    background: rgba(10, 10, 11, 0.8);
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

/* Form inputs across the panel — glass */
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    background: rgba(10, 10, 11, 0.55);
    border-color: var(--glass-border);
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    background: rgba(10, 10, 11, 0.8);
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

/* Pagination buttons — glass */
.page-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
}

/* Badges — slightly brighter on glass background */
.badge-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border);
}

/* Generic action-btn (node management etc.) */
.action-btn {
    background: var(--glass-bg);
    border-color: var(--glass-border);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border-strong);
}

/* Mobile node/user cards */
.mobile-node-card,
.mobile-user-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur-sm);
    -webkit-backdrop-filter: var(--glass-blur-sm);
}

/* Section title underline becomes soft */
.section-title {
    border-bottom: 1px solid var(--glass-border);
}

/* Detail item — glass tile */
.detail-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

/* IDs / hostnames / IPs in tables: clean monospaced text, no chip background */
.table code {
    background: transparent;
    border: none;
    padding: 0;
}

/* Equal-height rows on settings page */
.settings-page .row {
    align-items: stretch;
}

.settings-page .row > [class^="col-"] {
    display: flex;
    flex-direction: column;
}

.settings-page .row > [class^="col-"] > .card {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.settings-page .row > [class^="col-"] > .card > .card-body {
    flex: 1 1 auto;
}

/* ─── Xray TLS Source picker (panel/manual/self-signed) ───────────────────── */

.xray-tls-config {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 16px;
    background: var(--bg-elevated, transparent);
}

.xray-tls-config > .block-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--text);
    font-size: 14px;
}

.xray-tls-config > .hint {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin: 0 0 14px;
    line-height: 1.5;
}

/* Override the global .radio-group (horizontal flex). Cards stacked vertically
   on narrow screens, three columns on wide layouts. */
.xray-tls-config .radio-group {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin: 0 0 14px;
    flex-wrap: nowrap;
}

.xray-tls-config .radio-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    padding-right: 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
    background: transparent;
    margin: 0;
}

.xray-tls-config .radio-row .badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 2px 8px;
    font-size: 9px;
    line-height: 1.4;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.xray-tls-config .radio-row:hover {
    background: var(--bg-hover, rgba(127, 127, 127, 0.05));
    border-color: var(--border);
}

.xray-tls-config .radio-row input[type="radio"] {
    margin: 3px 0 0;
    flex-shrink: 0;
    accent-color: var(--accent);
}

.xray-tls-config .radio-row:has(input[type="radio"]:checked) {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb, 79, 156, 249), 0.08);
    box-shadow: 0 0 0 1px var(--accent) inset;
}

.xray-tls-config .radio-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.4;
}

.xray-tls-config .radio-label strong {
    display: block;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    padding-right: 90px;
}

.xray-tls-config .radio-hint {
    display: block;
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.5;
}

/* Xray fingerprint: single/random mode selector + pool checkboxes */
.fp-mode-group .radio-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin: 0 0 6px;
    flex-wrap: nowrap;
}

.fp-mode-group .radio-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
    margin: 0;
}

.fp-mode-group .radio-row:hover {
    border-color: var(--text-muted);
}

.fp-mode-group .radio-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fp-mode-group .radio-hint {
    display: block;
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.5;
}

.fp-checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fp-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    cursor: pointer;
    font-size: 12.5px;
    line-height: 1;
    user-select: none;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.fp-checkbox:hover {
    border-color: var(--accent);
}

.fp-checkbox:has(input:checked) {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.14);
    color: var(--accent-hover);
}

.fp-checkbox input {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--accent);
}

.fp-checkbox input:disabled {
    cursor: default;
}

.xray-tls-config .info-card {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    margin: 0 0 10px;
    background: rgba(127, 127, 127, 0.05);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xs);
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.xray-tls-config .info-card > i {
    color: var(--accent);
    margin-top: 2px;
    flex-shrink: 0;
    font-size: 16px;
}

.xray-tls-config .info-card > div {
    flex: 1;
    min-width: 0;
}

.xray-tls-config .info-card > div > div {
    color: var(--text);
    margin-bottom: 4px;
}

.xray-tls-config .info-card > div > small {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
}

.xray-tls-config .info-card-warning {
    background: rgba(217, 154, 39, 0.07);
    border-color: rgba(217, 154, 39, 0.4);
}

.xray-tls-config .info-card-warning > i {
    color: #d99a27;
}

.xray-tls-config .info-card-warning > div > strong {
    display: block;
    color: #d99a27;
    margin-bottom: 4px;
}

.xray-tls-config .info-card code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: rgba(127, 127, 127, 0.12);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--text);
}

.xray-tls-config .tls-source-manual .form-group {
    margin: 0 0 12px;
}

.xray-tls-config .tls-source-manual .form-group:last-child {
    margin-bottom: 0;
}

.xray-tls-config .tls-source-manual label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
}

.xray-tls-config .tls-source-manual small {
    display: block;
    color: var(--text-muted);
    font-size: 11.5px;
    margin-top: 4px;
    line-height: 1.5;
}

.pem-textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    width: 100%;
}

.pem-status {
    display: block;
    min-height: 16px;
    margin-top: 4px;
    font-size: 11.5px;
    transition: color 100ms ease;
}

.pem-status.is-valid {
    color: #2ea043;
}

.pem-status.is-invalid {
    color: #d9534f;
}
