html, body {
    background-color: #0f212e;
    color: #FFF;
}

#app {
    padding: 45px;
}

.text-small,
.clients-list {
    font-size: 0.8rem;
}

.blur {
    filter: blur(5px);
}

.cursor-pointer {
    cursor: pointer;
}

#topbar {
    background-color: #213743;
    box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.5);
    width: 100%;
    padding: 5px 0;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1;
    font-size: 0.9rem;
}

/* Bootstrap overwrites */
.table .thead-dark th {
    background-color: #213743;
    border-color: #1d303b;
    vertical-align: middle;
}

.table td, .table th {
    border-color: #1d303b;
    vertical-align: middle;
    padding: 0.5rem 0.25rem;
    font-size: 0.8rem;
}

/* 桌面版大螢幕空間利用優化 */
@media (min-width: 1200px) {
    .container-xl {
        max-width: 95% !important; /* 利用更多螢幕空間 */
    }
    
    .table td, .table th {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }
}

@media (min-width: 1400px) {
    .container-xl {
        max-width: 96% !important;
    }
    
    .table td, .table th {
        padding: 0.8rem 0.6rem;
        font-size: 0.95rem;
    }
}

@media (min-width: 1600px) {
    .container-xl {
        max-width: 97% !important;
    }
    
    .table td, .table th {
        padding: 0.9rem 0.7rem;
        font-size: 1rem;
    }
}

/* 桌面版網頁標題欄優化 */
@media (min-width: 769px) {
    #topbar {
        background: linear-gradient(135deg, #213743 0%, #2c4152 100%);
        border-bottom: 3px solid #28a745;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        backdrop-filter: blur(10px);
        position: relative;
        overflow: visible;
    }
    
    #topbar .container-xl {
        position: relative;
    }
    
    #topbar .d-md-flex {
        display: flex !important;
        flex-wrap: wrap;
        gap: 12px;
        align-items: center;
        justify-content: space-between;
        padding: 12px 0;
    }
    
    #topbar .px-2 {
        background: rgba(255,255,255,0.08);
        backdrop-filter: blur(5px);
        border: 1px solid rgba(255,255,255,0.12);
        border-radius: 8px;
        padding: 8px 12px !important;
        margin: 0 !important;
        color: #ffffff;
        font-weight: 500;
        font-size: 0.85rem;
        transition: all 0.3s ease;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        position: relative;
        overflow: hidden;
    }
    
    #topbar .px-2::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: linear-gradient(90deg, #28a745, #20c997);
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    #topbar .px-2:hover {
        background: rgba(255,255,255,0.12);
        border-color: rgba(255,255,255,0.2);
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }
    
    #topbar .px-2:hover::before {
        opacity: 1;
    }
    
    /* 特殊數據項目的樣式 */
    #topbar .px-2 b {
        color: #90EE90;
        font-weight: 600;
        text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    }
    
    /* 只對高亮行（黃色/紅色背景）使用黑色文字 */
    .table-danger,
    .table-danger td,
    .table-danger th {
        background-color: #f8d7da !important;
        color: #721c24 !important;
        border-color: #f5c6cb !important;
        font-weight: 600 !important;
    }
    
    .table-warning,
    .table-warning td,
    .table-warning th {
        background-color: #fff3cd !important;
        color: #856404 !important;
        border-color: #ffeaa7 !important;
        font-weight: 600 !important;
    }
    
    /* 保持原始深色主題 - 移除白色背景覆蓋 */
    .table tbody tr {
        background-color: transparent;
        color: inherit;
    }
    
    .table tbody tr:hover {
        background-color: rgba(255,255,255,0.05);
        color: inherit;
    }
    
    /* 網頁版header額外UI/UX改進 */
    
    /* 添加數據分組視覺效果 */
    #topbar .px-2:nth-child(1),
    #topbar .px-2:nth-child(2),
    #topbar .px-2:nth-child(3) {
        border-left: 3px solid #007bff; /* 藍色：基本財務數據 */
    }
    
    #topbar .px-2:nth-child(4),
    #topbar .px-2:nth-child(5),
    #topbar .px-2:nth-child(6) {
        border-left: 3px solid #28a745; /* 綠色：交易數據 */
    }
    
    #topbar .px-2:nth-child(7),
    #topbar .px-2:nth-child(8),
    #topbar .px-2:nth-child(9) {
        border-left: 3px solid #ffc107; /* 黃色：運營數據 */
    }
    
    /* 關鍵指標突出顯示 */
    #topbar .px-2:contains("Profit"),
    #topbar .px-2:contains("Bankroll") {
        background: rgba(40, 167, 69, 0.1);
        border-color: rgba(40, 167, 69, 0.3);
        box-shadow: 0 0 15px rgba(40, 167, 69, 0.2);
    }
    
    /* 狀態指示器 */
    #topbar::after {
        content: '';
        position: absolute;
        top: -3px;
        left: 0;
        right: 0;
        height: 3px;
        background: linear-gradient(90deg, 
            #007bff 0%, #007bff 33%, 
            #28a745 33%, #28a745 66%, 
            #ffc107 66%, #ffc107 100%);
        animation: statusPulse 3s ease-in-out infinite;
    }
    
    @keyframes statusPulse {
        0%, 100% { opacity: 0.6; }
        50% { opacity: 1; }
    }
    
    /* 響應式字體大小調整 */
    @media (min-width: 1200px) {
        #topbar .px-2 {
            font-size: 0.9rem;
            padding: 10px 14px !important;
        }
    }
    
    @media (min-width: 1400px) {
        #topbar .px-2 {
            font-size: 0.95rem;
            padding: 12px 16px !important;
        }
    }
    
    /* 控制按鈕改進 */
    #topbar .cursor-pointer,
    #topbar .btn {
        background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
        border: 1px solid rgba(255,255,255,0.2);
        border-radius: 6px;
        backdrop-filter: blur(10px);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        overflow: hidden;
    }
    
    #topbar .cursor-pointer::before,
    #topbar .btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
        transition: left 0.5s;
    }
    
    #topbar .cursor-pointer:hover::before,
    #topbar .btn:hover::before {
        left: 100%;
    }
    
    #topbar .cursor-pointer:hover,
    #topbar .btn:hover {
        background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.08) 100%);
        border-color: rgba(255,255,255,0.3);
        transform: translateY(-2px);
        box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    }
}

.dropdown-item {
    padding: .25rem 0.75rem;
}

.btn-group-sm > .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Search and Sort Controls */
.search-box input {
    background-color: #213743;
    border: 1px solid #1d303b;
    color: #fff;
}

.search-box input:focus {
    background-color: #2c4152;
    border-color: #28a745;
    color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.search-box input::placeholder {
    color: #adb5bd;
}

select.form-control {
    background-color: #213743;
    border: 1px solid #1d303b;
    color: #fff;
}

select.form-control:focus {
    background-color: #2c4152;
    border-color: #28a745;
    color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

select.form-control option {
    background-color: #213743;
    color: #fff;
}

/* Desktop Pagination Styles */
.desktop-pagination {
    background-color: #1a2936;
    border: 1px solid #1d303b;
    border-radius: 8px;
    padding: 15px 20px;
    margin-top: 15px;
}

.pagination-info {
    font-size: 0.9rem;
}

.pagination .page-item .page-link {
    background-color: #213743;
    border-color: #1d303b;
    color: #adb5bd;
    padding: 0.375rem 0.75rem;
    margin: 0 2px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.pagination .page-item .page-link:hover {
    background-color: #2c4152;
    border-color: #28a745;
    color: #fff;
}

.pagination .page-item.active .page-link {
    background-color: #28a745;
    border-color: #28a745;
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    background-color: #1a2936;
    border-color: #1d303b;
    color: #6c757d;
    cursor: not-allowed;
}

.pagination .page-item.disabled .page-link:hover {
    background-color: #1a2936;
    border-color: #1d303b;
    color: #6c757d;
}

@media (max-width: 768px) {
    .desktop-pagination {
        display: none !important;
    }
    
    .pagination-info {
        font-size: 0.8rem;
        text-align: center;
        margin-bottom: 10px;
    }
    
    .pagination .page-item .page-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* ========== MOBILE CARD STYLES ========== */
@media (max-width: 768px) {
    #app {
        padding: 230px 10px 10px 10px; /* 為更高的頂部導航欄留出空間 */
    }
    
    #topbar {
        font-size: 0.6rem;
        height: 220px;
        max-height: 220px;
        padding: 5px 0;
        z-index: 1030;
        overflow-x: hidden;
        overflow-y: auto;
        white-space: normal;
        -webkit-overflow-scrolling: touch;
    }
    
    #topbar .container-xl {
        padding: 0;
        overflow: visible;
        white-space: normal;
        width: 100%;
        height: auto;
        max-width: 100%;
    }
    
    #topbar .d-md-flex {
        display: flex !important;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 3px;
        justify-content: flex-start;
        align-items: stretch;
        width: 100%;
        height: auto;
        padding: 0 8px;
    }
    
    #topbar .px-2 {
        padding: 4px 6px !important;
        font-size: 0.55rem;
        margin: 0;
        text-align: center;
        background: rgba(255,255,255,0.05);
        border-radius: 4px;
        border: 1px solid rgba(255,255,255,0.1);
        white-space: nowrap;
        flex: 1;
        display: block;
        min-height: 28px;
        line-height: 1.2;
    }
    
    /* 確保所有頂部導航欄元素都可點擊 */
    #topbar .cursor-pointer,
    #topbar .btn,
    #topbar a {
        z-index: 1100;
        position: relative;
        pointer-events: auto;
        touch-action: manipulation;
        min-height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.6rem;
        white-space: nowrap;
        flex: 1;
        text-align: center;
        margin: 1px 0;
    }
    
    .table-responsive {
        display: none !important;
    }
    
    .mobile-cards {
        display: block !important;
        padding: 0;
        margin: 0;
    }
    
    .client-card {
        background-color: #213743;
        border: 1px solid #1d303b;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 15px;
        position: relative;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        overflow: hidden;
    }
    
    .client-card.bust {
        border-left: 4px solid #dc3545;
        background-color: #2a1f20;
    }
    
    .client-card.disconnected {
        border-left: 4px solid #6c757d;
        background-color: #212529;
    }
    
    .client-card.paused {
        border-left: 4px solid #ffc107;
        background-color: #2a2520;
    }
    
    .client-card.active {
        border-left: 4px solid #28a745;
        background-color: #1f2a20;
    }
    
    .connection-indicator {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        background-color: #28a745;
    }
    
    .connection-indicator.disconnected {
        background-color: #dc3545;
    }
    
    .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
        padding-bottom: 10px;
        border-bottom: 1px solid #1d303b;
    }
    
    .card-header .username {
        font-size: 1.1rem;
        font-weight: bold;
        margin: 0;
        color: #fff;
        max-width: 60%;
        word-break: break-all;
    }
    
    .status-badge {
        padding: 3px 8px;
        border-radius: 12px;
        font-size: 0.7rem;
        font-weight: bold;
        text-transform: uppercase;
    }
    
    .status-badge.ok {
        background-color: #28a745;
        color: white;
    }
    
    .status-badge.bust {
        background-color: #dc3545;
        color: white;
    }
    
    .vip-section {
        display: flex;
        justify-content: space-between;
        margin-bottom: 15px;
        padding: 10px;
        background-color: #1a2936;
        border-radius: 6px;
    }
    
    .vip-info {
        text-align: center;
    }
    
    .vip-flag {
        font-size: 0.9rem;
        font-weight: bold;
        color: #ffc107;
    }
    
    .vip-progress {
        font-size: 0.8rem;
        color: #adb5bd;
    }
    
    .stage-info {
        text-align: center;
    }
    
    .stage-info div:first-child {
        font-size: 0.9rem;
        font-weight: bold;
    }
    
    .stage-info .text-muted {
        font-size: 0.75rem;
        color: #6c757d;
    }
    
    .balance-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .balance-item {
        padding: 10px;
        background-color: #1a2936;
        border-radius: 6px;
        text-align: center;
    }
    
    .balance-item.sufficient {
        background-color: #1f2a20;
        border: 1px solid #28a745;
    }
    
    .balance-item .label {
        font-size: 0.75rem;
        color: #adb5bd;
        margin-bottom: 5px;
    }
    
    .balance-item .value {
        font-size: 0.85rem;
        font-weight: bold;
        word-break: break-all;
    }
    
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .stat-item {
        padding: 8px;
        background-color: #1a2936;
        border-radius: 6px;
        text-align: center;
    }
    
    .stat-label {
        font-size: 0.7rem;
        color: #adb5bd;
        margin-bottom: 3px;
    }
    
    .stat-value {
        font-size: 0.8rem;
        font-weight: bold;
    }
    
    .additional-info {
        background-color: #1a2936;
        border-radius: 6px;
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .info-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border-bottom: 1px solid #0f212e;
        font-size: 0.75rem;
    }
    
    .info-item:last-child {
        border-bottom: none;
    }
    
    .info-item span:first-child {
        color: #adb5bd;
        min-width: 60px;
        flex-shrink: 0;
    }
    
    .info-item span:last-child {
        color: #fff;
        text-align: right;
        word-break: break-all;
        font-size: 0.65rem; /* 專門為IP地址設計的較小字體 */
        max-width: 60%;
        overflow-wrap: break-word;
    }
    
    .info-item.warning span:last-child {
        color: #ffc107;
    }
    
    .card-actions {
        display: flex;
        gap: 5px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .card-actions .btn {
        flex: 1;
        min-width: 40px;
        padding: 5px 8px;
        font-size: 0.7rem;
        border-radius: 4px;
    }
    
    /* 行動端分頁樣式 */
    .mobile-pagination {
        margin: 20px 0;
        padding: 15px;
        background-color: #1a2936;
        border-radius: 8px;
        border: 1px solid #1d303b;
    }
    
    .pagination-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }
    
    .page-numbers {
        display: flex;
        gap: 5px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-btn {
        background-color: #213743;
        border: 1px solid #1d303b;
        color: #adb5bd;
        padding: 5px 10px;
        border-radius: 4px;
        font-size: 0.8rem;
        cursor: pointer;
        transition: all 0.3s ease;
        min-width: 35px;
    }
    
    .page-btn:hover {
        background-color: #2c4152;
        color: #fff;
    }
    
    .page-btn.active {
        background-color: #28a745;
        border-color: #28a745;
        color: #fff;
    }
    
    .page-ellipsis {
        color: #6c757d;
        padding: 5px 8px;
        font-size: 0.8rem;
        display: flex;
        align-items: center;
    }
    
    .mobile-pagination-info {
        background-color: #1a2936;
        border-radius: 6px;
        padding: 8px;
        margin-bottom: 10px;
        border: 1px solid #1d303b;
    }

/* Missing Clients Alert Styles */
.missing-clients-alert {
    background: linear-gradient(135deg, #2a1f20 0%, #3a1f1f 100%);
    border: 2px solid #dc3545;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.missing-clients-alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #dc3545, #ff6b7a, #dc3545);
    background-size: 200% 100%;
    animation: alertPulse 2s ease-in-out infinite;
}

@keyframes alertPulse {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(220, 53, 69, 0.3);
    position: relative;
}

.alert-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #dc3545, #ff6b7a);
    border-radius: 1px;
}

.alert-icon {
    font-size: 1.3rem;
    margin-right: 10px;
    color: #dc3545;
    animation: iconPulse 1.5s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.alert-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #dc3545;
    flex-grow: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.missing-clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 15px;
}

.missing-client-card {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.15) 0%, rgba(220, 53, 69, 0.05) 100%);
    border: 1px solid rgba(220, 53, 69, 0.4);
    border-radius: 12px;
    padding: 0;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.25);
    position: relative;
    backdrop-filter: blur(5px);
}

.missing-client-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #dc3545, #ff6b7a, #dc3545);
    background-size: 200% 100%;
    animation: cardPulse 3s ease-in-out infinite;
}

@keyframes cardPulse {
    0%, 100% { background-position: 0% 50%; opacity: 0.6; }
    50% { background-position: 100% 50%; opacity: 1; }
}

.missing-client-card:hover {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.25) 0%, rgba(220, 53, 69, 0.15) 100%);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
    border-color: rgba(220, 53, 69, 0.6);
}

.missing-client-card:hover::before {
    animation-duration: 1.5s;
}

.missing-client-header {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.25) 0%, rgba(220, 53, 69, 0.15) 100%);
    padding: 15px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(220, 53, 69, 0.3);
    position: relative;
    margin-top: 3px;
}

.missing-client-header::before {
    content: '⚠️';
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    animation: warningBlink 2s ease-in-out infinite;
}

@keyframes warningBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.missing-client-name {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    margin-left: 25px;
}

.client-username {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    word-break: break-all;
    line-height: 1.2;
}

.client-status {
    font-size: 0.75rem;
    color: #ff6b7a;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 8px;
    background: rgba(220, 53, 69, 0.3);
    border-radius: 10px;
    display: inline-block;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 rgba(220, 53, 69, 0.7); }
    50% { box-shadow: 0 0 10px rgba(220, 53, 69, 0.7); }
}

.missing-client-details {
    padding: 18px 20px 15px 20px;
    background: rgba(0, 0, 0, 0.1);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(220, 53, 69, 0.05);
    border-radius: 8px;
    border-left: 3px solid rgba(220, 53, 69, 0.3);
    transition: all 0.3s ease;
}

.detail-row:hover {
    background: rgba(220, 53, 69, 0.1);
    border-left-color: rgba(220, 53, 69, 0.5);
    transform: translateX(3px);
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    font-size: 0.85rem;
    color: #adb5bd;
    font-weight: 600;
    min-width: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-label::before {
    color: #dc3545;
    font-weight: bold;
    font-size: 1rem;
    margin-right: 2px;
}

.detail-row.time .detail-label::before {
    content: '🕒';
}

.detail-row.ip .detail-label::before {
    content: '🌐';
}

.detail-row.profit .detail-label::before {
    content: '💰';
}

.detail-row.balance .detail-label::before {
    content: '💳';
}

/* 斷線警告擴展動畫 */
@keyframes expandAlert {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.missing-clients-alert {
    animation: expandAlert 0.5s ease-out;
}

/* 客戶端卡片進入動畫 */
@keyframes cardSlideIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.missing-client-card {
    animation: cardSlideIn 0.6s ease-out;
    animation-fill-mode: both;
}

.missing-client-card:nth-child(1) { animation-delay: 0.1s; }
.missing-client-card:nth-child(2) { animation-delay: 0.2s; }
.missing-client-card:nth-child(3) { animation-delay: 0.3s; }
.missing-client-card:nth-child(4) { animation-delay: 0.4s; }

/* 數據更新閃爍效果 */
@keyframes dataUpdate {
    0% { background-color: rgba(40, 167, 69, 0.3); }
    100% { background-color: transparent; }
}

.detail-value.updated {
    animation: dataUpdate 1s ease-out;
}

/* 連接狀態指示器 */
.connection-status-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc3545;
    animation: statusBlink 2s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 50% { opacity: 1; }
    25%, 75% { opacity: 0.3; }
}

/* 提升按鈕點擊反饋 */
.btn-xs:active {
    transform: translateY(-1px) scale(0.98);
}

/* 刷新按鈕美化 */
.alert-header .btn-outline-danger {
    border: 2px solid #dc3545;
    background: rgba(220, 53, 69, 0.1);
    color: #ff6b7a;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    backdrop-filter: blur(5px);
}

.alert-header .btn-outline-danger:hover {
    background: rgba(220, 53, 69, 0.2);
    border-color: #ff6b7a;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.alert-header .btn-outline-danger:active {
    transform: translateY(0) scale(0.98);
}

/* 警告圖標旋轉動畫 */
.alert-icon {
    display: inline-block;
    animation: iconRotate 3s ease-in-out infinite;
}

@keyframes iconRotate {
    0%, 90%, 100% { transform: rotate(0deg); }
    5%, 15% { transform: rotate(-15deg); }
    10% { transform: rotate(15deg); }
}

/* 移除客戶端時的淡出效果 */
@keyframes fadeOutAndSlide {
    0% {
        opacity: 1;
        transform: translateX(0);
        max-height: 200px;
    }
    50% {
        opacity: 0;
        transform: translateX(-30px);
        max-height: 200px;
    }
    100% {
        opacity: 0;
        transform: translateX(-30px);
        max-height: 0;
        margin-bottom: 0;
        padding: 0;
    }
}

.missing-client-card.removing {
    animation: fadeOutAndSlide 0.8s ease-in-out forwards;
    pointer-events: none;
}

/* 數據標籤的懸停提示效果 */
.detail-label {
    cursor: help;
    position: relative;
}

.detail-label:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    animation: tooltipFadeIn 0.3s ease-out forwards;
}

@keyframes tooltipFadeIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 空狀態顯示 */
.missing-clients-alert.empty {
    background: linear-gradient(135deg, #1a2936 0%, #213743 100%);
    border-color: #28a745;
    padding: 30px;
    text-align: center;
}

.missing-clients-alert.empty .alert-icon {
    animation: none;
}

.missing-clients-alert.empty::before {
    background: linear-gradient(90deg, #28a745, #20c997, #28a745);
}

.detail-value {
    font-size: 0.85rem;
    color: #fff;
    font-weight: 600;
    text-align: right;
    flex: 1;
    margin-left: 15px;
    word-break: break-all;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.detail-row.profit .detail-value {
    color: #28a745;
    font-weight: 700;
}

.detail-row.profit.negative .detail-value {
    color: #dc3545;
}

.detail-row.balance .detail-value {
    color: #ffc107;
    font-weight: 700;
}

.detail-row.ip .detail-value {
    color: #17a2b8;
    font-size: 0.75rem;
}

.detail-row.time .detail-value {
    color: #6c757d;
    font-style: italic;
}

.missing-client-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(220, 53, 69, 0.2);
    margin-top: 10px;
    border-radius: 0 0 12px 12px;
}

.btn-xs {
    padding: 6px 12px;
    font-size: 0.7rem;
    line-height: 1.3;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.btn-xs::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-xs:hover::before {
    left: 100%;
}

.btn-xs.btn-warning {
    background: linear-gradient(135deg, #ffc107, #ffca28);
    color: #212529;
    border-color: #ffc107;
}

.btn-xs.btn-warning:hover {
    background: linear-gradient(135deg, #e0a800, #ffc107);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.btn-xs.btn-info {
    background: linear-gradient(135deg, #17a2b8, #20c997);
    color: #fff;
    border-color: #17a2b8;
}

.btn-xs.btn-info:hover {
    background: linear-gradient(135deg, #138496, #17a2b8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.btn-xs.btn-danger {
    background: linear-gradient(135deg, #dc3545, #e74c3c);
    color: #fff;
    border-color: #dc3545;
}

.btn-xs.btn-danger:hover {
    background: linear-gradient(135deg, #c82333, #dc3545);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

@media (max-width: 768px) {
    .missing-clients-alert {
        border-radius: 10px;
        padding: 15px;
        margin: 0 5px;
    }
    
    .missing-clients-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .missing-client-card {
        border-radius: 10px;
        margin: 0 5px;
    }
    
    .missing-client-header {
        padding: 12px 15px;
        margin-top: 3px;
    }
    
    .missing-client-header::before {
        left: 0;
        font-size: 1.1rem;
    }
    
    .missing-client-name {
        margin-left: 20px;
    }
    
    .missing-client-details {
        padding: 15px;
    }
    
    .detail-row {
        margin-bottom: 10px;
        padding: 6px 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .detail-label {
        font-size: 0.75rem;
        min-width: auto;
        margin-bottom: 2px;
    }
    
    .detail-value {
        font-size: 0.8rem;
        margin-left: 0;
        text-align: left;
        width: 100%;
    }
    
    .client-username {
        font-size: 0.9rem;
        line-height: 1.3;
    }
    
    .client-status {
        font-size: 0.65rem;
        padding: 1px 6px;
    }
    
    .alert-header {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .alert-title {
        font-size: 1rem;
    }
    
    .missing-client-actions {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .btn-xs {
        padding: 4px 8px;
        font-size: 0.65rem;
        flex: 1;
        min-width: 70px;
    }
    
    .detail-row.ip .detail-value {
        font-size: 0.7rem;
        word-break: break-all;
    }
}
    
    /* Max LS 顯示樣式 */
    .max-ls-display {
        background-color: #213743;
        border: 1px solid #1d303b;
        border-radius: 6px;
        padding: 10px;
        margin-bottom: 15px;
        text-align: center;
    }
    
    .max-ls-display .label {
        font-size: 0.8rem;
        color: #adb5bd;
        margin-bottom: 5px;
    }
    
    .max-ls-display .value {
        font-size: 1.2rem;
        font-weight: bold;
        color: #dc3545;
    }

    /* Mobile Profit Stats */
    .mobile-profit-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin: 10px 0 15px 0;
    }

    .profit-stat {
        background-color: #1a2936;
        border: 1px solid #1d303b;
        border-radius: 8px;
        padding: 12px;
        text-align: center;
    }

    .profit-stat .label {
        font-size: 0.75rem;
        color: #adb5bd;
        margin-bottom: 5px;
        font-weight: 500;
    }

    .profit-stat .value {
        font-size: 0.9rem;
        font-weight: bold;
        color: #fff;
    }

    .profit-stat .usd-value {
        font-size: 0.75rem;
        color: #adb5bd;
        margin-top: 2px;
    }
}

/* Desktop max LS display */
@media (min-width: 769px) {
    .mobile-cards {
        display: none !important;
    }
}

/* Mobile responsive improvements */
@media (max-width: 768px) {
    .mobile-btn-group {
        position: relative;
    }

    .mobile-btn-toggle {
        display: inline-block;
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
        background-color: #213743;
        border: 1px solid #1d303b;
        color: #fff;
        border-radius: 0.25rem;
        cursor: pointer;
    }

    .mobile-btn-dropdown {
        display: none;
        position: absolute;
        right: 0;
        top: 100%;
        background-color: #213743;
        border: 1px solid #1d303b;
        border-radius: 0.25rem;
        z-index: 1000;
        min-width: 180px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }

    .mobile-btn-dropdown.show {
        display: block;
    }

    .mobile-btn-dropdown .btn {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        border: none;
        border-radius: 0;
        text-align: left;
        border-bottom: 1px solid #1d303b;
    }

    .mobile-btn-dropdown .btn:last-child {
        border-bottom: none;
    }

    .desktop-btn-group {
        display: none;
    }
}

@media (min-width: 769px) {
    .mobile-btn-group {
        display: none;
    }

    .desktop-btn-group {
        display: block;
    }
}

/* Mobile Global Actions */
.mobile-global-actions {
    position: fixed;
    bottom: 180px; /* 向上移動 */
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mobile-global-actions .mobile-btn-group {
    position: relative;
    z-index: 1500;
}

.mobile-global-actions .mobile-btn-toggle {
    display: inline-block;
    padding: 0.5rem;
    font-size: 1rem;
    background-color: #213743;
    border: 2px solid #1d303b;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.mobile-global-actions .mobile-btn-toggle:hover,
.mobile-global-actions .mobile-btn-toggle:focus {
    background-color: #2c4152;
    transform: scale(1.05);
    outline: none;
}

.mobile-global-actions .mobile-btn-dropdown {
    position: absolute;
    right: 0;
    bottom: 120px; /* 向上移動更多 */
    background-color: #1a2936;
    border: 2px solid #0f212e;
    border-radius: 0.5rem;
    z-index: 3000;
    min-width: 200px;
    max-width: 240px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.9);
    overflow: visible;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(15px);
    display: block;
    flex-direction: column;
}

/* Ensure dropdown stays within viewport */
@media (max-height: 800px) {
    .mobile-global-actions .mobile-btn-dropdown {
        bottom: 140px; /* 確保有足夠空間 */
    }
}

@media (max-height: 700px) {
    .mobile-global-actions .mobile-btn-dropdown {
        bottom: auto;
        top: 50%;
        transform: translateY(-50%) scale(0.9);
    }
    
    .mobile-global-actions .mobile-btn-dropdown.show {
        transform: translateY(-50%) scale(1);
    }
}

@media (max-height: 600px) {
    .mobile-global-actions .mobile-btn-dropdown {
        bottom: auto;
        top: 40%;
        transform: translateY(-50%) scale(0.9);
    }
    
    .mobile-global-actions .mobile-btn-dropdown.show {
        transform: translateY(-50%) scale(1);
    }
}

@media (max-height: 500px) {
    .mobile-global-actions .mobile-btn-dropdown {
        bottom: auto;
        top: 30%;
        transform: translateY(-50%) scale(0.9);
    }
    
    .mobile-global-actions .mobile-btn-dropdown.show {
        transform: translateY(-50%) scale(1);
    }
}

.mobile-global-actions .mobile-btn-dropdown.show {
    display: block !important;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.mobile-global-actions .mobile-btn-dropdown .btn {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0.6rem 0.8rem !important;
    font-size: 0.8rem !important;
    border: none !important;
    border-radius: 0 !important;
    text-align: left !important;
    border-bottom: 1px solid #1d303b !important;
    transition: background-color 0.2s ease !important;
    color: #fff !important;
    background-color: #213743 !important;
    position: relative !important;
    float: none !important;
    clear: both !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    justify-content: flex-start !important;
    box-sizing: border-box !important;
}

.mobile-global-actions .mobile-btn-dropdown .btn:last-child {
    border-bottom: none !important;
}

.mobile-global-actions .mobile-btn-dropdown .btn:hover,
.mobile-global-actions .mobile-btn-dropdown .btn:focus {
    background-color: #2c4152 !important;
    outline: none !important;
    transform: translateX(2px) !important;
}

.mobile-global-actions .mobile-btn-dropdown .btn span {
    display: inline-block !important;
    width: 100% !important;
}

/* Scroll Navigation Buttons */
.scroll-buttons {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scroll-btn {
    width: 45px;
    height: 45px;
    background-color: #213743;
    border: 2px solid #1d303b;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    outline: none;
    opacity: 0.8;
}

.scroll-btn:hover,
.scroll-btn:focus {
    background-color: #2c4152;
    transform: scale(1.1);
    opacity: 1;
    outline: none;
}

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

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

/* Mobile dropdown backdrop */
.mobile-dropdown-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-dropdown-backdrop.show {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 769px) {
    .mobile-global-actions,
    .scroll-buttons,
    .mobile-dropdown-backdrop {
        display: none;
    }
}

/* 橫向模式手機版優化 */
@media (max-width: 768px) and (orientation: landscape) {
    #app {
        padding: 230px 10px 10px 10px; /* 更高的頂部導航欄 - 橫向模式 */
    }
    
    #topbar {
        height: 220px;
        max-height: 220px;
        padding: 5px 0;
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    /* 橫向模式下調整按鈕選單位置 */
    .mobile-global-actions .mobile-btn-dropdown {
        bottom: auto;
        top: 50%;
        right: 0;
        transform: translateY(-50%) scale(0.9);
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .mobile-global-actions .mobile-btn-dropdown.show {
        transform: translateY(-50%) scale(1);
    }
}

/* 直向模式手機版優化 */
@media (max-width: 768px) and (orientation: portrait) {
    #app {
        padding: 230px 10px 10px 10px; /* 更高的頂部導航欄 - 直向模式 */
    }
    
    #topbar {
        height: 220px;
        max-height: 220px;
        padding: 5px 0;
        overflow-x: hidden;
        overflow-y: auto;
    }
}

/* 桌面版按鈕和UI改進 */
@media (min-width: 769px) {
    /* 改進按鈕組樣式 */
    .btn-group-sm > .btn {
        background-color: #213743;
        border: 1px solid #1d303b;
        color: #fff;
        padding: 6px 12px;
        font-size: 0.8rem;
        border-radius: 4px;
        margin: 0 2px;
        transition: all 0.2s ease;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }
    
    .btn-group-sm > .btn:hover {
        background-color: #2c4152;
        border-color: #24373d;
        transform: translateY(-1px);
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    }
    
    /* 恢復原始按鈕顏色方案 - 清晰的視覺識別 */
    .btn-success {
        background-color: #28a745 !important;
        border-color: #28a745 !important;
        color: #fff !important;
    }
    
    .btn-success:hover,
    .btn-success:focus,
    .btn-success:active {
        background-color: #218838 !important;
        border-color: #1e7e34 !important;
        color: #fff !important;
    }
    
    .btn-danger {
        background-color: #dc3545 !important;
        border-color: #dc3545 !important;
        color: #fff !important;
    }
    
    .btn-danger:hover,
    .btn-danger:focus,
    .btn-danger:active {
        background-color: #c82333 !important;
        border-color: #bd2130 !important;
        color: #fff !important;
    }
    
    .btn-warning {
        background-color: #ffc107 !important;
        border-color: #ffc107 !important;
        color: #212529 !important;
    }
    
    .btn-warning:hover,
    .btn-warning:focus,
    .btn-warning:active {
        background-color: #e0a800 !important;
        border-color: #d39e00 !important;
        color: #212529 !important;
    }
    
    .btn-primary {
        background-color: #007bff !important;
        border-color: #007bff !important;
        color: #fff !important;
    }
    
    .btn-primary:hover,
    .btn-primary:focus,
    .btn-primary:active {
        background-color: #0069d9 !important;
        border-color: #0062cc !important;
        color: #fff !important;
    }
    
    .btn-info {
        background-color: #17a2b8 !important;
        border-color: #17a2b8 !important;
        color: #fff !important;
    }
    
    .btn-info:hover,
    .btn-info:focus,
    .btn-info:active {
        background-color: #138496 !important;
        border-color: #117a8b !important;
        color: #fff !important;
    }
    
    /* 搜索和篩選控制項樣式改進 */
    .search-box {
        position: relative;
        display: block;
    }
    
    .search-box input {
        background-color: #213743;
        border: 2px solid #1d303b;
        color: #fff;
        border-radius: 6px;
        padding: 8px 12px;
        transition: all 0.2s ease;
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .search-box input:focus {
        border-color: #007bff;
        background-color: #1a2936;
        box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25), inset 0 1px 3px rgba(0,0,0,0.1);
        outline: none;
    }
    
    .search-box input::placeholder {
        color: #6c757d;
        opacity: 1;
    }
    
    select.form-control {
        background-color: #213743;
        border: 2px solid #1d303b;
        color: #fff;
        border-radius: 6px;
        padding: 7px 10px;
        transition: all 0.2s ease;
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
        appearance: none;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 8px center;
        background-repeat: no-repeat;
        background-size: 16px 12px;
        padding-right: 32px;
    }
    
    select.form-control:focus {
        border-color: #007bff;
        background-color: #1a2936;
        box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25), inset 0 1px 3px rgba(0,0,0,0.1);
        outline: none;
    }
    
    select.form-control option {
        background-color: #213743;
        color: #fff;
        padding: 8px;
    }
    
    /* 表格頭部樣式改進 */
    .table .thead-dark th {
        background-color: #1a2936;
        border-color: #1d303b;
        color: #fff;
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.75rem;
        letter-spacing: 0.5px;
        padding: 12px 8px;
    }
    
    /* 表格行懸停效果 */
    .table-hover tbody tr:hover {
        background-color: #1a2936;
        transition: background-color 0.15s ease-in-out;
    }
    
    /* 改進頂部導航欄按鈕樣式 */
    #topbar .cursor-pointer,
    #topbar .btn {
        background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
        border: 1px solid rgba(255,255,255,0.2);
        border-radius: 6px;
        backdrop-filter: blur(10px);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        overflow: hidden;
    }
    
    #topbar .cursor-pointer::before,
    #topbar .btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
        transition: left 0.5s;
    }
    
    #topbar .cursor-pointer:hover::before,
    #topbar .btn:hover::before {
        left: 100%;
    }
    
    #topbar .cursor-pointer:hover,
    #topbar .btn:hover {
        background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.08) 100%);
        border-color: rgba(255,255,255,0.3);
        transform: translateY(-2px);
        box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    }
}
