/* ==========================================================================
   rs-xray Cyber-Terminal Pro Theme (High-Performance, Tactile, Zero-Lag)
   Engineered for Professional Developer Experience & Extreme Snappiness
   ========================================================================== */


:root {
    /* Palette: Obsidian Black & Neon Phosphor */
    --bg-base: #020402;
    --bg-surface: #050906;
    --bg-card: #070d08;
    --bg-card-hover: #0b140c;
    --bg-modal: #060b07;
    --bg-input: #010301;
    --bg-header: #030704;
    
    --border-color: #152c18;
    --border-subtle: #0f2012;
    --border-hover: #224727;
    --border-focus: #00ff66;
    --border-active: #00ff66;

    /* Terminal Metrics & Highlights */
    --text-primary: #f2fff2;
    --text-secondary: #96be99;
    --text-muted: #4e7051;
    
    --primary: #00ff66;
    --primary-bg: rgba(0, 255, 102, 0.08);
    --primary-glow: rgba(0, 255, 102, 0.22);
    
    --accent: #00e5ff;
    --accent-bg: rgba(0, 229, 255, 0.08);
    --accent-yellow: #ffb000;
    --accent-purple: #bf7af0;
    
    --success: #00ff66;
    --warning: #ffb000;
    --danger: #ff3366;
    --danger-bg: rgba(255, 51, 102, 0.1);

    --sidebar-width: 250px;
    --sidebar-collapsed-width: 68px;
    --topbar-height: 56px;
    
    --radius-xs: 2px;
    --radius-sm: 4px;
    --radius-md: 6px;
    
    --ease-tactile: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Termux Cyber Themes Palette
   ========================================================================== */

/* Termux Theme 1: Matrix Green (Default) */
[data-theme="termux"], :root {
    --bg-base: #020402;
    --bg-surface: #050906;
    --bg-card: #070d08;
    --bg-card-hover: #0b140c;
    --bg-modal: #060b07;
    --bg-input: #010301;
    --bg-header: #030704;
    --border-color: #152c18;
    --border-subtle: #0f2012;
    --border-hover: #224727;
    --border-focus: #00ff66;
    --border-active: #00ff66;
    --text-primary: #f2fff2;
    --text-secondary: #96be99;
    --text-muted: #4e7051;
    --primary: #00ff66;
    --primary-bg: rgba(0, 255, 102, 0.08);
    --primary-glow: rgba(0, 255, 102, 0.22);
    --accent: #00e5ff;
    --accent-bg: rgba(0, 229, 255, 0.08);
}

/* Termux Theme 2: Cyberpunk Neon (Cyan / Magenta) */
[data-theme="cyber"] {
    --bg-base: #060913;
    --bg-surface: #0a0f20;
    --bg-card: #0f162c;
    --bg-card-hover: #151e3c;
    --bg-modal: #0c1224;
    --bg-input: #050812;
    --bg-header: #080d1c;
    --border-color: #192849;
    --border-subtle: #131e36;
    --border-hover: #263c6e;
    --border-focus: #00d9ff;
    --border-active: #00d9ff;
    --text-primary: #eaf4fc;
    --text-secondary: #89a3c7;
    --text-muted: #4e6382;
    --primary: #00d9ff;
    --primary-bg: rgba(0, 217, 255, 0.09);
    --primary-glow: rgba(0, 217, 255, 0.25);
    --accent: #ff007f;
    --accent-bg: rgba(255, 0, 127, 0.09);
}

/* Termux Theme 3: Dracula Pro (Midnight Purple) */
[data-theme="dracula"] {
    --bg-base: #14151c;
    --bg-surface: #191a24;
    --bg-card: #1f202c;
    --bg-card-hover: #282a3a;
    --bg-modal: #1d1e2a;
    --bg-input: #111218;
    --bg-header: #161720;
    --border-color: #313347;
    --border-subtle: #252636;
    --border-hover: #484b67;
    --border-focus: #bd93f9;
    --border-active: #bd93f9;
    --text-primary: #f8f8f2;
    --text-secondary: #b6b9d6;
    --text-muted: #6272a4;
    --primary: #bd93f9;
    --primary-bg: rgba(189, 147, 249, 0.1);
    --primary-glow: rgba(189, 147, 249, 0.25);
    --accent: #ff79c6;
    --accent-bg: rgba(255, 121, 198, 0.1);
}

/* Termux Theme 4: Monokai Pro (Amber & Green) */
[data-theme="monokai"] {
    --bg-base: #151517;
    --bg-surface: #1b1b1e;
    --bg-card: #222226;
    --bg-card-hover: #2c2c31;
    --bg-modal: #1f1f23;
    --bg-input: #111113;
    --bg-header: #18181a;
    --border-color: #36363c;
    --border-subtle: #28282d;
    --border-hover: #505058;
    --border-focus: #ffd866;
    --border-active: #ffd866;
    --text-primary: #fcfcfa;
    --text-secondary: #c2c1c5;
    --text-muted: #727075;
    --primary: #ffd866;
    --primary-bg: rgba(255, 216, 102, 0.1);
    --primary-glow: rgba(255, 216, 102, 0.25);
    --accent: #a9dc76;
    --accent-bg: rgba(169, 220, 118, 0.1);
}

/* Termux Theme 5: Nord Frost (Arctic Ice Blue) */
[data-theme="nord"] {
    --bg-base: #15181f;
    --bg-surface: #1a1e27;
    --bg-card: #202531;
    --bg-card-hover: #2a3141;
    --bg-modal: #1e222d;
    --bg-input: #11141a;
    --bg-header: #171b23;
    --border-color: #2f3749;
    --border-subtle: #242a38;
    --border-hover: #434e68;
    --border-focus: #88c0d0;
    --border-active: #88c0d0;
    --text-primary: #eceff4;
    --text-secondary: #b2bed2;
    --text-muted: #5e6c86;
    --primary: #88c0d0;
    --primary-bg: rgba(136, 192, 208, 0.1);
    --primary-glow: rgba(136, 192, 208, 0.25);
    --accent: #81a1c1;
    --accent-bg: rgba(129, 161, 193, 0.1);
}

/* Termux Theme 6: Solarized Dark (Teal & Amber) */
[data-theme="solarized"] {
    --bg-base: #001a20;
    --bg-surface: #00232c;
    --bg-card: #042d38;
    --bg-card-hover: #083845;
    --bg-modal: #022731;
    --bg-input: #00141a;
    --bg-header: #001f27;
    --border-color: #0b4554;
    --border-subtle: #073541;
    --border-hover: #125e73;
    --border-focus: #2aa198;
    --border-active: #2aa198;
    --text-primary: #eee8d5;
    --text-secondary: #93a1a1;
    --text-muted: #586e75;
    --primary: #2aa198;
    --primary-bg: rgba(42, 161, 152, 0.1);
    --primary-glow: rgba(42, 161, 152, 0.25);
    --accent: #b58900;
    --accent-bg: rgba(181, 137, 0, 0.1);
}

/* Termux Theme 7: One Dark Pro (Deep Slate) */
[data-theme="onedark"] {
    --bg-base: #11141a;
    --bg-surface: #161922;
    --bg-card: #1c212c;
    --bg-card-hover: #252b3a;
    --bg-modal: #1a1e28;
    --bg-input: #0e1015;
    --bg-header: #13161d;
    --border-color: #2b3243;
    --border-subtle: #202532;
    --border-hover: #3d475e;
    --border-focus: #61afef;
    --border-active: #61afef;
    --text-primary: #f0f2f7;
    --text-secondary: #a0a8b7;
    --text-muted: #5c6370;
    --primary: #61afef;
    --primary-bg: rgba(97, 175, 239, 0.1);
    --primary-glow: rgba(97, 175, 239, 0.25);
    --accent: #98c379;
    --accent-bg: rgba(152, 195, 121, 0.1);
}

/* Dropdown Components */
.dropdown-relative {
    position: relative;
    display: inline-block;
}

.theme-dropdown-menu, .lang-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 175px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
    padding: 6px;
    z-index: 1050;
    display: none;
}

.theme-dropdown-menu.active, .lang-dropdown-menu.active {
    display: block;
}

.theme-option-btn, .lang-option-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.theme-option-btn:hover, .lang-option-btn:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.theme-option-btn.active, .lang-option-btn.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

.theme-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

/* Light / High Contrast Fallback */
.light-theme {
    --bg-base: #0c150e;
    --bg-surface: #101c12;
    --bg-card: #142417;
    --bg-card-hover: #192e1d;
    --bg-modal: #101c12;
    --bg-input: #090e0a;
    --border-color: #244629;
    --text-primary: #ffffff;
    --text-secondary: #a9d4ad;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

html {
    font-size: 14px; /* Reduced from default 16px to 14px (87.5%) for compact pro layout */
}

body {
    zoom: var(--ui-scale, 0.92); /* Default scaled down by ~8% to fit more dense info */
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, Monaco, Consolas, monospace !important;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    letter-spacing: -0.015em;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-input);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-surface);
    border-radius: var(--radius-xs);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.font-mono {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace !important;
}

/* ==========================================================================
   App Layout & Sidebar (With Smooth Collapse Support)
   ========================================================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-base);
    position: relative;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: width 0.22s var(--ease-tactile), transform 0.22s var(--ease-tactile);
}

.sidebar-brand {
    height: var(--topbar-height);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
    overflow: hidden;
}

.brand-logo {
    width: 34px;
    height: 34px;
    background: var(--bg-input);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.15);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.brand-logo:hover {
    border-color: var(--text-primary);
    transform: scale(1.05);
}

.brand-text {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin-left: 0.75rem;
    flex: 1;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid rgba(0, 255, 102, 0.3);
}

.btn-sidebar-collapse {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: var(--radius-xs);
    transition: color 0.15s ease;
}

.btn-sidebar-collapse:hover {
    color: var(--primary);
}

/* Sidebar Nav */
.sidebar-nav {
    padding: 0.85rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    white-space: nowrap;
}

.nav-item svg {
    width: 17px;
    height: 17px;
    stroke: var(--text-muted);
    flex-shrink: 0;
    transition: stroke 0.12s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
    border-color: #1a3c1e;
}

.nav-item:hover svg {
    stroke: var(--primary);
}

.nav-item.active {
    color: var(--text-primary);
    background: var(--bg-surface);
    border-color: var(--primary);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(0, 255, 102, 0.12);
}

.nav-item.active svg {
    stroke: var(--primary);
}

.counter-badge {
    margin-left: auto;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    background: var(--bg-input);
    color: var(--primary);
    border: 1px solid var(--border-color);
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-header);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.core-status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

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

.core-status-pill.online {
    border-color: #1a4220;
    color: var(--text-primary);
}

.core-status-pill.online .status-dot {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.core-status-pill.offline .status-dot {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.hot-reload-btn {
    width: 100%;
}

/* Sidebar Collapsed State */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .btn-sidebar-collapse,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .counter-badge,
.sidebar-collapsed .core-status-pill .status-text,
.sidebar-collapsed .hot-reload-btn span {
    display: none !important;
}

.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem 0;
    gap: 0;
}

.sidebar-collapsed .nav-item svg {
    width: 20px;
    height: 20px;
}

.sidebar-collapsed .core-status-pill {
    justify-content: center;
    padding: 0.5rem 0;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ==========================================================================
   Main Content & Topbar (Pixel-Perfect Alignment for Telemetry Speeds)
   ========================================================================== */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-base);
    transition: margin-left 0.22s var(--ease-tactile);
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.btn-sidebar-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-sidebar-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-surface);
}

.page-title-box {
    display: flex;
    flex-direction: column;
}

.page-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    line-height: 1.2;
}

.page-title::before {
    content: "➜";
    color: var(--primary);
    font-size: 0.85rem;
}

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

/* Topbar Right - Telemetry & Actions */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}

/* Server Speed Telemetry Ticker */
.server-speed-ticker {
    display: inline-flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid #16331a;
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    gap: 10px;
    height: 34px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}

.speed-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.speed-icon {
    font-weight: 800;
    font-size: 0.82rem;
    line-height: 1;
}

.speed-up .speed-icon,
.speed-up .speed-label {
    color: var(--accent);
}

.speed-down .speed-icon,
.speed-down .speed-label {
    color: var(--primary);
}

.speed-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.speed-val {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 66px;
    text-align: right;
    font-family: inherit;
}

.speed-divider {
    width: 1px;
    height: 16px;
    background: var(--bg-surface);
}

/* Content Area */
.content-body, .content-area {
    padding: 1.5rem;
    flex: 1;
}

.content-section {
    display: none;
    animation: fadeIn 0.15s ease;
}

.content-section.active {
    display: block;
}

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

/* ==========================================================================
   Cards & Data Containers
   ========================================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: border-color 0.15s ease;
}

.card:hover {
    border-color: var(--border-hover);
}

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

.card-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.card-title::before {
    content: "#";
    color: var(--primary);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-input);
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.stat-card:hover {
    border-color: #204b24;
    background: var(--bg-card-hover);
}

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

.stat-title {
    font-size: 0.74rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.stat-tag {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.stat-tag.tag-success {
    border-color: #17421f;
    color: var(--primary);
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.progress-bar-bg {
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: var(--radius-xs);
    overflow: hidden;
    margin: 4px 0 2px 0;
    border: 1px solid var(--border-color);
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    box-shadow: 0 0 6px var(--primary);
    transition: width 0.3s ease;
}

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

/* ==========================================================================
   Buttons (Tactile, Clean, Terminal Keycaps)
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0 0.95rem;
    height: 36px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}

.btn:active {
    transform: translateY(1px) scale(0.985);
}

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

.btn-primary:hover {
    background: var(--primary);
    color: #000000;
    box-shadow: 0 0 10px var(--primary-glow);
}

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

.btn-secondary:hover {
    background: var(--bg-surface);
    border-color: #244b29;
    color: var(--text-primary);
}

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

.btn-ghost:hover {
    background: var(--bg-surface);
    color: var(--primary);
    border-color: #1a3c1e;
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary-bg);
}

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid #4a1520;
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: var(--text-primary);
    border-color: var(--danger);
}

.btn-sm {
    padding: 0 0.65rem;
    height: 32px;
    font-size: 0.76rem;
}

.btn-xs {
    padding: 0 0.52rem;
    height: 26px;
    font-size: 0.72rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
}

.btn-icon-sm {
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
}

/* Copy button */
.btn-copy {
    padding: 0.45rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-left: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: background 0.12s ease, color 0.12s ease;
}

.btn-copy:hover {
    background: var(--primary);
    color: #000000;
}

.btn-copy.copy-success,
.btn.copy-success {
    background: #059669 !important;
    border-color: #059669 !important;
    color: var(--text-primary) !important;
}

/* ==========================================================================
   Form System & Inbound Modal Unified Grid (Solving Misaligned Layout)
   ========================================================================== */

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

.form-label {
    display: block;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    letter-spacing: 0.02em;
}

.required-star {
    color: var(--danger);
}

.help-tip {
    color: var(--text-muted);
    cursor: help;
    font-size: 0.75rem;
    font-style: normal;
}

.form-control {
    width: 100%;
    padding: 0.52rem 0.75rem;
    font-size: 0.84rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    height: 36px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

input[type="date"].form-control {
    color-scheme: dark;
}

select.form-control {
    cursor: pointer;
    background-color: var(--bg-input);
}

select.form-control option {
    background-color: var(--bg-input);
    color: #e0f2e1;
    padding: 6px;
}

textarea.form-control {
    height: auto;
    min-height: 54px;
    resize: vertical;
}

.form-control:focus {
    border-color: var(--border-focus);
    background: var(--bg-input);
    box-shadow: 0 0 8px var(--primary-glow);
}

.form-control:disabled, .form-control[readonly] {
    background: var(--bg-input);
    color: #6e8a71;
    cursor: default;
}

/* INBOUND MODAL PIXEL-PERFECT ALIGNMENT GRID */
.form-field-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: start;
    gap: 1.25rem;
    margin-bottom: 0.65rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(21, 44, 24, 0.45);
}

.field-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #a4cfa7;
    text-align: right;
    user-select: none;
    line-height: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.field-control {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    min-height: 36px;
}

.flex-row-gap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

.flex-1 {
    flex: 1;
}

.form-grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.input-with-copy {
    display: flex;
    width: 100%;
}

.input-with-copy .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-with-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-with-icon-btn .form-control {
    padding-right: 38px;
}

.btn-icon-inside {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.75rem;
    transition: color 0.12s ease, border-color 0.12s ease;
}

.btn-icon-inside:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Info Callout */
.info-callout {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid #1a3c20;
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: #b4d8b7;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.info-icon {
    font-weight: 800;
    color: var(--accent);
}

/* Segmented Control */
.segmented-control {
    display: inline-flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
    width: auto;
    min-width: 80px;
    max-width: 320px;
}

.seg-btn {
    flex: 1;
    min-width: 60px;
    padding: 0.4rem 0.9rem;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: all 0.12s ease;
}

.seg-btn:hover {
    color: var(--text-primary);
}

.seg-btn.active {
    background: var(--bg-surface);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.15);
}

/* Input with inline action button */
.input-with-action {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-with-action .form-control {
    padding-right: 2.75rem;
}

.input-action-btn {
    position: absolute;
    right: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.05rem;
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: all 0.2s ease;
}

.input-action-btn:hover {
    color: var(--primary);
    transform: rotate(180deg);
}

/* Dynamic Account Rows for HTTP and SOCKS */
.accounts-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0 12px 0;
}

.account-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.account-index-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 36px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    flex-shrink: 0;
}

.account-item-row .form-control {
    flex: 1;
}

.account-del-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.account-del-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

/* Tags Container for Sniffing */
.tags-input-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-height: 38px;
    width: 100%;
}

.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 2px 7px;
    font-size: 0.72rem;
    background: var(--bg-input);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: var(--radius-xs);
}

.tag-close {
    cursor: pointer;
    color: var(--danger);
    font-weight: bold;
}

.tag-add-select {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    outline: none;
    cursor: pointer;
}

/* Switch / Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
    flex-shrink: 0;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-surface);
    border: 1px solid #1a3820;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    border-radius: var(--radius-xs);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #4a6c4c;
    transition: transform 0.15s var(--ease-tactile), background-color 0.15s ease;
    border-radius: 1px;
}

input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(18px);
    background-color: var(--bg-input);
}

/* ==========================================================================
   Modals (Springy Entrance, Clean Terminal Titles)
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

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

/* Modal Stacking Hierarchy to avoid overlapping/hiding child modals */
#modal-inbound { z-index: 1020; }
#modal-clients-mgr { z-index: 1030; }
#modal-client-edit { z-index: 1060; }
#modal-qrcode { z-index: 1100; }

.modal-dialog {
    background: var(--bg-modal);
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    box-shadow: 0 0 30px rgba(0, 255, 102, 0.15);
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.18s var(--ease-tactile);
}

/* Stable modal heights preventing window jumping when switching tabs */
#modal-inbound .modal-dialog {
    height: 84vh;
    max-height: 840px;
    min-height: 560px;
}

#modal-clients-mgr .modal-dialog {
    height: 80vh;
    max-height: 800px;
    min-height: 520px;
}

#modal-client-edit .modal-dialog {
    height: 76vh;
    max-height: 740px;
    min-height: 480px;
}

#modal-qrcode .modal-dialog {
    height: auto;
    max-height: 90vh;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

.modal-sm { max-width: 460px; }
.modal-md { max-width: 680px; }
.modal-lg { max-width: 920px; }

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

.modal-title {
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.modal-title::before {
    content: "[TERMUX]";
    color: var(--primary);
    font-size: 0.72rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.12s ease;
}

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

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    flex-shrink: 0;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Modal Tab Bar - Strict minimum height and zero-shrink to prevent clipping */
.modal-tabs-nav {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    min-height: 44px;
    height: 44px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    overflow-x: auto;
    overflow-y: hidden;
}

.modal-tab-btn, .modal-client-tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 1.15rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.12s ease;
    flex-shrink: 0;
}

.modal-tab-btn:hover, .modal-client-tab-btn:hover {
    color: var(--text-primary);
}

.modal-tab-btn.active, .modal-client-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(0, 255, 102, 0.04);
}

.modal-tab-pane, .modal-client-tab-pane {
    display: none;
}

.modal-tab-pane.active, .modal-client-tab-pane.active {
    display: block;
    animation: paneFade 0.14s ease-out;
}

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

/* ==========================================================================
   Data Tables
   ========================================================================== */

.table-card {
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.data-table th {
    background: var(--bg-input);
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #0c1a0e;
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tr {
    transition: background-color 0.1s ease;
}

.data-table tr:hover td {
    background: var(--bg-surface);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem 1rem !important;
    font-size: 0.85rem;
}

/* Badges (Modern Neon Gradient & Glow) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 0.69rem;
    font-weight: 600;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-family: inherit;
    white-space: nowrap;
    letter-spacing: 0.02em;
    transition: all 0.2s ease;
}

.badge-vless {
    border-color: rgba(0, 255, 102, 0.35);
    color: var(--primary);
    background: rgba(0, 255, 102, 0.09);
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.1);
}

.badge-vmess {
    border-color: rgba(97, 175, 239, 0.4);
    color: #61afef;
    background: rgba(97, 175, 239, 0.09);
    box-shadow: 0 0 10px rgba(97, 175, 239, 0.1);
}

.badge-trojan {
    border-color: rgba(191, 122, 240, 0.4);
    color: #bf7af0;
    background: rgba(191, 122, 240, 0.09);
    box-shadow: 0 0 10px rgba(191, 122, 240, 0.1);
}

.badge-hysteria, .badge-hysteria2 {
    border-color: rgba(255, 153, 0, 0.4);
    color: #ff9900;
    background: rgba(255, 153, 0, 0.09);
    box-shadow: 0 0 10px rgba(255, 153, 0, 0.1);
}

.badge-shadowsocks {
    border-color: rgba(0, 229, 255, 0.4);
    color: #00e5ff;
    background: rgba(0, 229, 255, 0.09);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.1);
}

.badge-socks {
    border-color: rgba(46, 204, 113, 0.4);
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.09);
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.1);
}

.badge-http {
    border-color: rgba(255, 107, 129, 0.4);
    color: #ff6b81;
    background: rgba(255, 107, 129, 0.09);
    box-shadow: 0 0 10px rgba(255, 107, 129, 0.1);
}

.badge-wireguard {
    border-color: rgba(235, 77, 75, 0.4);
    color: #eb4d4b;
    background: rgba(235, 77, 75, 0.09);
    box-shadow: 0 0 10px rgba(235, 77, 75, 0.1);
}

.badge-dokodemo-door {
    border-color: rgba(164, 176, 190, 0.35);
    color: #ced6e0;
    background: rgba(164, 176, 190, 0.08);
}

.badge-status-on {
    border-color: rgba(0, 255, 102, 0.4);
    color: var(--primary);
    background: rgba(0, 255, 102, 0.12);
}

.badge-status-off {
    border-color: rgba(255, 51, 102, 0.3);
    color: var(--danger);
    background: rgba(255, 51, 102, 0.08);
}

/* Enhanced Table Action Buttons & Layouts */
.table-actions-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

.table-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.74rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.table-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.table-action-btn.btn-action-primary {
    background: linear-gradient(135deg, rgba(0, 255, 102, 0.15), rgba(0, 229, 255, 0.15));
    border-color: var(--primary);
    color: var(--text-primary);
}

.table-action-btn.btn-action-primary:hover {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #000000;
    box-shadow: 0 0 12px rgba(0, 255, 102, 0.4);
}

.table-action-btn.btn-action-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

.table-action-btn.btn-action-danger {
    color: var(--danger);
    border-color: rgba(255, 51, 102, 0.25);
    background: rgba(255, 51, 102, 0.05);
}

.table-action-btn.btn-action-danger:hover {
    background: var(--danger);
    color: var(--text-primary);
    border-color: var(--danger);
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.4);
}

/* Quota Progress Bar for Clients */
.client-quota-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.client-quota-text {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-secondary);
}

.client-quota-bar-bg {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.client-quota-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s ease;
}

.client-quota-bar-fill.warning {
    background: linear-gradient(90deg, var(--accent-yellow), #ff7700);
}

.client-quota-bar-fill.danger {
    background: linear-gradient(90deg, #ff4757, var(--danger));
}

/* Inbound & Client Node visual elements */
.node-remark-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.node-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--text-primary);
}

.node-tag-pill {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.client-email-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.client-avatar-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 255, 102, 0.15), rgba(0, 229, 255, 0.2));
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.client-credential-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.73rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.client-credential-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 255, 102, 0.05);
}

.client-node-link-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    font-size: 0.73rem;
    color: var(--text-secondary);
}

.node-traffic-display {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
}

.node-traffic-up {
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.node-traffic-down {
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.client-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.74rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.client-pill-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 255, 102, 0.08);
    transform: translateY(-1px);
}

/* Log Console */
.console-card {
    background: var(--bg-input) !important;
    border: 1px solid #1a4220 !important;
}

.console-header {
    background: var(--bg-input) !important;
    border-bottom: 1px solid #1a4220 !important;
}

.console-log {
    background: var(--bg-input);
    color: var(--primary);
    font-family: inherit;
    font-size: 0.78rem;
    line-height: 1.45;
    padding: 1rem;
    height: 380px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    border: none;
}

/* ==========================================================================
   Advanced Inbound JSON Code Editor (Screenshot 1 exact styling)
   ========================================================================== */

.adv-json-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    margin-bottom: 0.5rem;
}

.adv-json-header {
    margin-bottom: 0.75rem;
}

.adv-json-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.adv-json-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.adv-subtabs-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid #142a17;
    margin-bottom: 0.65rem;
    padding-bottom: 0.25rem;
}

.adv-subtab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.12s ease, border-color 0.12s ease;
}

.adv-subtab-btn:hover {
    color: var(--text-primary);
}

.adv-subtab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.adv-subtab-hint {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-bottom: 0.65rem;
}

.code-editor-wrapper {
    border: 1px solid #1a3c1e;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6);
}

.code-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.65rem;
    background: var(--bg-input);
    border-bottom: 1px solid #142a17;
}

.editor-lang-tag {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(0, 255, 102, 0.08);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    border: 1px solid rgba(0, 255, 102, 0.2);
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.btn-xs.btn-success {
    background: #059669;
    color: var(--text-primary);
    border: 1px solid #10b981;
}

.btn-xs.btn-success:hover {
    background: #10b981;
    color: var(--text-primary);
}

.adv-json-status-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.74rem;
    font-family: monospace;
    border-bottom: 1px solid #142a17;
    background: rgba(0, 255, 102, 0.05);
    color: #4ade80;
    transition: all 0.2s ease;
    word-break: break-all;
}

.adv-json-status-bar.valid {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border-bottom-color: rgba(16, 185, 129, 0.35);
}

.adv-json-status-bar.error {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-bottom-color: rgba(239, 68, 68, 0.35);
}

.code-editor-body {
    display: flex;
    height: 320px;
    position: relative;
    background: var(--bg-input);
}

.code-line-numbers {
    width: 42px;
    background: var(--bg-input);
    border-right: 1px solid #122815;
    padding: 0.65rem 0.35rem;
    font-family: monospace;
    font-size: 0.76rem;
    line-height: 1.45;
    color: #3e6343;
    text-align: right;
    user-select: none;
    overflow: hidden;
    white-space: pre;
}

.code-editor-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0.65rem 0.75rem;
    font-family: monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #e0f2e1;
    resize: none;
    overflow-y: auto;
    white-space: pre;
    tab-size: 2;
}

/* ==========================================================================
   ECH and TLS Details (Screenshot 2 exact styling)
   ========================================================================== */

.field-subnote {
    font-size: 0.71rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    line-height: 1.35;
}

.ech-callout-card {
    background: var(--bg-input);
    border: 1px solid #19401f;
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin: 0.65rem 0;
}

.ech-card-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ech-card-desc {
    font-size: 0.73rem;
    color: #a4cfa7;
    margin-top: 0.35rem;
    line-height: 1.4;
}

.seg-cert-mode {
    flex: 1;
    padding: 0.35rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: all 0.12s ease;
}

.seg-cert-mode.active {
    background: var(--bg-surface);
    border-color: var(--primary);
    color: var(--primary);
}

/* ==========================================================================
   Client Direct QR Code Scanner & Preview (Requirement 3)
   ========================================================================== */

.client-qr-panel {
    display: flex;
    flex-direction: column;
}

.qr-switch-bar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.seg-qr-type, .seg-modal-qr {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.12s ease;
}

.seg-qr-type.active, .seg-modal-qr.active {
    background: var(--bg-surface);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.15);
}

.qrcode-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0.65rem 0;
}

.qrcode-wrapper canvas,
.qrcode-wrapper img,
.qrcode-wrapper svg,
#qr-code-box svg,
#client-qr-code svg {
    background: #ffffff;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 0 24px rgba(0, 255, 102, 0.22), 0 4px 18px rgba(0, 0, 0, 0.8);
    max-width: 220px;
    max-height: 220px;
    width: 200px;
    height: 200px;
    display: block;
    margin: 0 auto;
}

/* Reality Fallback Limitation Card (Screenshot 3 exact match) */
.reality-fallback-card {
    margin-top: 1.25rem;
    background: var(--bg-surface);
    border: 1px solid rgba(0, 255, 102, 0.2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: var(--transition-tactile);
}

.reality-fallback-card[open] {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

.reality-fallback-summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
    background: var(--bg-input);
    border-bottom: 1px solid rgba(0, 255, 102, 0.15);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s ease;
}

.reality-fallback-summary:hover {
    color: var(--primary);
    background: var(--bg-surface);
}

.fallback-summary-title {
    font-family: var(--font-mono);
    letter-spacing: 0.3px;
}

.reality-fallback-body {
    padding: 1rem 1.25rem 1.25rem 1.25rem;
}

.fallback-section-divider {
    position: relative;
    text-align: center;
    margin: 1.15rem 0 0.95rem 0;
}

.fallback-section-divider:first-child {
    margin-top: 0.25rem;
}

.fallback-section-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    z-index: 1;
}

.fallback-section-divider span {
    position: relative;
    z-index: 2;
    background: var(--bg-surface);
    padding: 0 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #e2f7e7;
    letter-spacing: 0.4px;
}

.fallback-field-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    margin-bottom: 0.65rem;
}

.fallback-label {
    width: 140px;
    text-align: right;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

.fallback-input-wrap {
    width: 140px;
}

.fallback-input {
    width: 100%;
    text-align: left;
    height: 32px;
    padding: 0 0.6rem;
    font-size: 0.8rem;
    background: var(--bg-input) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    color: var(--text-main);
}

.fallback-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.2);
}

.qrcode-scan-hint {
    color: var(--text-muted);
    font-size: 0.74rem;
    margin-top: 0.6rem;
    text-align: center;
}

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

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 440px;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 12px var(--primary-glow);
    pointer-events: auto;
    animation: toastSlideIn 0.22s var(--ease-tactile);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-error {
    border-color: var(--danger);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 12px rgba(255, 51, 102, 0.2);
}

.toast.toast-info {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 12px rgba(0, 229, 255, 0.2);
}

.toast.toast-leave {
    opacity: 0;
    transform: translateX(20px);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Performance Metrics & Kernel Switcher Card in 系统状态 */
.core-version-mgr-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.55);
}

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

.perf-metric-item {
    background: var(--bg-input);
    border: 1px solid rgba(0, 255, 102, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    position: relative;
    overflow: hidden;
}

.perf-metric-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
}

.perf-metric-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.perf-metric-value {
    font-size: 1.22rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.perf-metric-sub {
    font-size: 0.72rem;
    color: #92b899;
}

.version-switch-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

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

.installed-versions-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
    max-height: 220px;
    overflow-y: auto;
}

/* Sidebar Backdrop Component */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

/* Responsive Breakpoints & Mobile Optimization */
@media (max-width: 900px) {
    .sidebar-backdrop {
        display: block;
    }
    .app-layout.sidebar-mobile-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100dvh;
        width: 270px;
        max-width: 82vw;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.85);
    }
    .app-layout.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }
}

@media (max-width: 768px) {
    body {
        zoom: 1 !important;
        overflow-x: hidden;
        width: 100%;
    }
    html {
        font-size: 13.5px;
    }
    .topbar {
        height: auto;
        min-height: 52px;
        padding: 0.5rem 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .topbar-left {
        gap: 0.5rem;
    }
    .page-title {
        font-size: 0.95rem;
    }
    .page-subtitle {
        display: none !important;
    }
    .topbar-right {
        gap: 0.4rem;
        flex-wrap: wrap;
        justify-content: flex-end;
        margin-left: auto;
    }
    .server-speed-ticker {
        padding: 3px 6px;
        gap: 6px;
        height: 30px;
    }
    .speed-val {
        min-width: 50px;
        font-size: 0.72rem;
    }
    .refresh-interval-control {
        padding: 2px 4px;
        height: 30px;
    }
    .refresh-label {
        display: none;
    }
    .btn-refresh-rate {
        padding: 2px 6px;
        font-size: 0.72rem;
    }
    #btn-theme-picker, #btn-lang-toggle, #btn-logout {
        height: 30px !important;
        padding: 0 6px !important;
        font-size: 0.75rem !important;
    }
    #btn-add-inbound-top {
        height: 30px;
        padding: 0 8px;
        font-size: 0.75rem;
    }
    .content-body, .content-area {
        padding: 0.75rem;
    }
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    .stat-card {
        padding: 0.85rem;
    }
    .card-header {
        padding: 0.75rem 0.85rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .card-body {
        padding: 0.85rem;
    }
    .section-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .toolbar-search {
        width: 100%;
    }
    .toolbar-actions {
        display: flex;
        width: 100%;
    }
    .toolbar-actions .btn {
        flex: 1;
    }
    /* Tables Responsive Scroll on Touch */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.5rem;
    }
    .data-table th, .data-table td {
        padding: 0.55rem 0.65rem;
        font-size: 0.78rem;
        white-space: nowrap;
    }
    /* Mobile-optimized Modals */
    #modal-inbound .modal-dialog,
    #modal-clients-mgr .modal-dialog,
    #modal-client-edit .modal-dialog,
    #modal-inbound-picker .modal-dialog,
    #modal-qrcode .modal-dialog,
    .modal-dialog {
        width: 95vw !important;
        max-width: 95vw !important;
        height: 92dvh !important;
        max-height: 92dvh !important;
        min-height: 0 !important;
        margin: 10px auto !important;
        border-radius: 10px;
    }
    .modal-header {
        padding: 0.75rem 0.85rem;
    }
    .modal-body {
        padding: 0.75rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-footer {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .modal-footer .btn {
        flex: 1;
        min-height: 38px;
    }
    .modal-tabs-nav, .modal-picker-toolbar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0.25rem 0.5rem;
        gap: 4px;
    }
    .modal-tabs-nav::-webkit-scrollbar {
        display: none;
    }
    .modal-tab-btn, .modal-client-tab-btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 6px 10px;
        font-size: 0.76rem;
    }
    .adv-subtabs-nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .adv-subtab-btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 5px 9px;
    }
    .form-field-row {
        grid-template-columns: 1fr;
        gap: 0.3rem;
        padding: 0.6rem 0;
    }
    .field-label {
        text-align: left;
        font-size: 0.82rem;
    }
    .form-grid-2col {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .form-row {
        flex-direction: column;
    }
    .form-row .col-6 {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
    }
    .two-col-layout {
        grid-template-columns: 1fr;
    }
    .perf-metric-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .tools-grid {
        grid-template-columns: 1fr;
    }
    .login-card {
        width: 92vw;
        max-width: 380px;
        padding: 1.5rem 1.25rem;
    }
    .core-info-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .core-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }
    .core-actions .btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    #current-theme-label {
        display: none;
    }
    #top-username-text {
        display: none;
    }
    .user-badge-pill {
        padding: 0 6px;
    }
    .server-speed-ticker {
        display: none;
    }
    .topbar {
        padding: 0.4rem 0.5rem;
    }
    .card-title {
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   Xray Update Panel (Exact Match to Screenshot 2)
   ========================================================================== */
.xray-update-accordion {
    margin-top: 1.25rem;
    background: var(--bg-input);
    border: 1px solid #142817;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.xray-update-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background: var(--bg-input);
    border-bottom: 1px solid #142817;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.xray-update-header:hover {
    background: var(--bg-input);
}

.xray-update-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.xray-update-chevron {
    color: var(--primary);
    font-size: 0.85rem;
    transition: transform 0.2s ease;
}

.xray-update-caution {
    margin: 1rem 1.25rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #fcd34d;
    font-size: 0.82rem;
    line-height: 1.4;
}

.xray-version-list-card {
    margin: 0 1.25rem 1.25rem 1.25rem;
    border: 1px solid #142817;
    border-radius: 8px;
    background: var(--bg-input);
    overflow: hidden;
}

.xray-version-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.2rem;
    border-bottom: 1px solid #0d1a10;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.xray-version-row:hover {
    background: rgba(0, 255, 102, 0.04);
}

.xray-version-row.active {
    background: rgba(0, 255, 102, 0.07);
    border-left: 3px solid var(--primary);
}

.xray-version-tag {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.xray-version-tag.tag-purple {
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.28);
}

.xray-version-tag.tag-green {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.28);
}

.xray-version-radio {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.xray-version-row.active .xray-version-radio {
    border-color: #3b82f6;
    background: transparent;
}

.xray-version-row.active .xray-version-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.7);
}

/* ==========================================================================
   Inbound Picker Component
   ========================================================================== */
.inbound-picker-trigger-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.65rem;
    cursor: pointer;
    min-height: 42px;
    transition: border-color 0.15s ease;
}

.inbound-picker-trigger-box:hover {
    border-color: var(--primary);
}

.inbound-picker-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    flex: 1;
}

.inbound-picker-placeholder {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.inbound-picker-tag {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 255, 102, 0.1);
    border: 1px solid rgba(0, 255, 102, 0.3);
    color: var(--primary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.76rem;
    font-family: var(--font-mono);
}

.modal-picker-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.picker-status-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.inbound-picker-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.inbound-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.12s ease;
}

.inbound-picker-item:hover {
    border-color: rgba(0, 255, 102, 0.4);
    background: rgba(0, 255, 102, 0.03);
}

.inbound-picker-item.selected {
    border-color: var(--primary);
    background: rgba(0, 255, 102, 0.07);
}

.inbound-picker-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ==========================================================================
   Terminal Authentication Overlay & Login Card
   ========================================================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-input);
    background: radial-gradient(circle at center, #07150a 0%, #010401 100%);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.login-overlay.active {
    display: flex !important;
}

/* Guarantee that when login-overlay is active or unauthenticated, main app layout is 100% hidden */
body.unauthenticated .app-layout,
body.login-active .app-layout,
body:has(#login-overlay.active) .app-layout {
    display: none !important;
}

body.unauthenticated,
body.login-active,
body:has(#login-overlay.active) {
    overflow: hidden !important;
    height: 100% !important;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 0 60px rgba(0, 255, 102, 0.12), 0 20px 40px rgba(0, 0, 0, 0.8);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 440px;
    padding: 2.5rem 2.2rem;
    animation: modalIn 0.22s var(--ease-tactile);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    background: var(--primary-bg);
    border: 1px solid var(--primary);
    color: var(--primary);
    margin-bottom: 0.85rem;
    box-shadow: 0 0 20px var(--primary-glow);
}

.login-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.login-alert {
    background: rgba(255, 51, 102, 0.12);
    border: 1px solid var(--danger);
    color: #ff6688;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.15s ease;
}

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

.input-prefix-box .input-icon {
    position: absolute;
    left: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    pointer-events: none;
}

.input-prefix-box input {
    padding-left: 38px !important;
}

.login-footer {
    margin-top: 1.75rem;
    text-align: center;
    font-size: 0.74rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border-color);
    padding-top: 1.1rem;
}

.user-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.user-badge-pill .status-dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--primary);
}

/* ==========================================================================
   Refresh Interval Selector & Seamless In-Place Animations
   ========================================================================== */
.refresh-interval-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
    height: 36px;
}

.refresh-dot-pulse {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--primary);
    animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.refresh-label {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-weight: 500;
}

.refresh-btn-group {
    display: inline-flex;
    gap: 3px;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px;
    border-radius: 3px;
    border: 1px solid var(--border-subtle);
}

.btn-refresh-rate {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.12s ease;
}

.btn-refresh-rate:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-refresh-rate.active {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.25);
}

.cell-updated {
    animation: cellFlash 0.6s ease-out;
}

@keyframes cellFlash {
    0% { background-color: rgba(0, 255, 102, 0.18); color: var(--primary); }
    100% { background-color: transparent; }
}

/* --- Server IP Redacted & Eye Visibility Toggle (Item 1) --- */
.dual-ip-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 4px 0 2px;
}

.stat-ip-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 6px;
    border-radius: var(--radius-xs);
    border: 1px solid rgba(0, 255, 102, 0.12);
}

.badge-ip-type {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--primary);
    flex-shrink: 0;
}

.stat-card-ip .stat-ip-val {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    user-select: all;
    transition: filter 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    word-break: break-all;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-ip-val.ip-blurred {
    filter: blur(5px);
    user-select: none;
    cursor: pointer;
    opacity: 0.65;
}

.stat-ip-val.ip-blurred:hover {
    filter: blur(3.5px);
    opacity: 0.85;
}

.btn-icon-eye, .btn-copy-sm {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--radius-xs);
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-icon-eye:hover, .btn-copy-sm:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-bg);
}

.btn-icon-eye.active {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.3);
}

.btn-icon-eye svg {
    display: block;
}

/* ==========================================================================
   Reality TLS Scanner Card
   ========================================================================== */
.reality-scan-card {
    background: var(--bg-surface);
    border: 1px solid #1f4228;
    border-radius: 8px;
    padding: 18px 20px;
    margin: 6px 0 12px 0;
    width: 100%;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    transition: all 0.25s ease;
}

.reality-scan-card.unavailable {
    background: var(--bg-surface);
    border-color: #522327;
}

.reality-scan-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.reality-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.reality-status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #22c55e;
    color: #0b1a0e;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
    flex-shrink: 0;
}

.reality-scan-card.unavailable .reality-status-icon {
    background: #ef4444;
    color: var(--text-primary);
}

.reality-status-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.reality-scan-card.unavailable .reality-status-text {
    color: #fca5a5;
}

.reality-scan-loading {
    font-size: 0.85rem;
    color: #a7f3d0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.reality-scan-body {
    display: flex;
    flex-direction: column;
    gap: 7px;
    transition: opacity 0.2s ease;
}

.reality-scan-row {
    display: flex;
    align-items: baseline;
    font-size: 0.93rem;
    line-height: 1.5;
}

.reality-scan-label {
    color: #8fa695;
    min-width: 110px;
    font-weight: 500;
    flex-shrink: 0;
}

.reality-scan-card.unavailable .reality-scan-label {
    color: #ab9093;
}

.reality-scan-val {
    color: var(--text-primary);
    font-weight: 600;
    word-break: break-all;
}

.reality-scan-error {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.12);
    border-left: 3px solid #ef4444;
    border-radius: 4px;
    color: #fca5a5;
    font-size: 0.88rem;
    line-height: 1.45;
}

/* ==========================================================================
   Multi-Tag Input Component for Short IDs (Exact Match with Reference)
   ========================================================================== */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-surface);
    border: 1px solid #2e3748;
    border-radius: 6px;
    min-height: 44px;
    cursor: text;
    transition: all 0.2s ease;
}

.tag-input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 255, 102, 0.15);
}

.tag-list {
    display: contents;
}

.short-id-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: var(--bg-surface);
    border: 1px solid #3c4659;
    border-radius: 4px;
    color: #f3f4f6;
    font-family: var(--font-mono, monospace);
    font-size: 0.88rem;
    line-height: 1.35;
    user-select: none;
    transition: background 0.15s, border-color 0.15s;
}

.short-id-tag:hover {
    background: #323b4b;
    border-color: #4f5a70;
}

.tag-remove-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0 0 0 2px;
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.tag-remove-btn:hover {
    color: #ef4444;
}

.tag-inner-input {
    flex: 1;
    min-width: 90px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono, monospace);
    font-size: 0.88rem;
    padding: 3px 4px;
}

.tag-inner-input::placeholder {
    color: #64748b;
    font-family: inherit;
    font-size: 0.82rem;
}

#btn-refresh-sid {
    height: 40px;
    width: 40px;
    min-height: 40px;
    flex-shrink: 0;
    align-self: flex-start;
}

/* --- Hysteria & UDP Mask UI (Screenshot 1 Match) --- */
.udpmask-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0 1rem 0;
    color: #94a3b8;
    font-size: 0.88rem;
    font-weight: 600;
}

.udpmask-divider::before,
.udpmask-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.udpmask-divider:not(:empty)::before {
    margin-right: 0.85em;
}

.udpmask-divider:not(:empty)::after {
    margin-left: 0.85em;
}

.btn-icon-danger {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: #ef4444;
    padding: 2px 6px;
    margin-left: 6px;
    border-radius: 4px;
    transition: transform 0.15s ease, background 0.15s ease;
}

.btn-icon-danger:hover {
    transform: scale(1.15);
    background: rgba(239, 68, 68, 0.15);
}

.flex-col-start {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

.field-tip {
    font-size: 0.76rem;
    color: #64748b;
    margin-top: 4px;
    line-height: 1.3;
}

