/* ==========================================================
   FILE: style.css - BẢN HỢP NHẤT V2 (PC & MOBILE)
   ========================================================== */

/* 1. MÀU SẮC CHỦ ĐẠO & CÀI ĐẶT GỐC */
:root { 
    --primary: #4f46e5; /* Indigo hiện đại */
    --primary-light: #eef2ff;
    --secondary: #f43f5e;
    --bg: #f1f5f9;
    --sidebar: #0f172a;
    --white: #ffffff;
    --text: #334155;
    --warning: #f59e0b;
    --success: #10b981;
    --slate-600: #475569;
    --slate-400: #94a3b8;
    --border: #e2e8f0;
}

/* Helper Classes */
.m-0 { margin: 0; }
.text-center { text-align: center; }

/* Utility for long text */
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

* { box-sizing: border-box; }

/* Ép cứng font Inter cho toàn bộ chữ, số trên trang */
body, button, input, textarea, select { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-size: 16px; /* Chống auto-zoom trên mobile */
}

body { 
    background: var(--bg);
    overscroll-behavior-y: contain; /* Ngăn chặn kéo refresh trang không mong muốn */
    margin: 0; 
    display: flex; 
    height: 100vh; 
    overflow: hidden; 
    color: var(--text);
    -webkit-font-smoothing: antialiased; 
}

/* ==========================================
   3. CẤU TRÚC SIDEBAR VÀ MENU
   ========================================== */
.sidebar { 
    width: 260px; background: var(--sidebar); color: white; display: flex; flex-direction: column; 
    transition: transform 0.3s ease-in-out, margin 0.3s ease-in-out !important; 
    z-index: 1001; flex-shrink: 0; 
}
.sidebar-header { padding: 20px 10px; border-bottom: 1px solid #334155; display: flex; align-items: center; justify-content: center; min-height: 64px; font-weight: 800; font-size: 18px; color: #38bdf8;}
.sidebar-header-flex { justify-content: space-between; padding-right: 15px; }
.close-sidebar-btn { font-size: 32px; font-weight: normal; cursor: pointer; color: var(--slate-400); display: none; line-height: 0.8; }

.nav-menu { flex: 1; padding: 15px 0; display: flex; flex-direction: column; overflow-y: auto; }
.nav-item { padding: 12px 20px; display: flex; align-items: center; gap: 12px; color: #cbd5e1; text-decoration: none; cursor: pointer; transition: 0.2s; font-size: 14px; border-left: 4px solid transparent; font-weight: 600;}
.nav-item:hover, .nav-item.active { background: #334155; color: white; border-left-color: #38bdf8; }
.nav-item-support { border-top: 1px solid #334155; }

/* 4. TOP BAR & AUTH */
.auth-flex { display: flex; align-items: center; gap: 15px; }
.btn-vip { 
    background: linear-gradient(45deg, #ffd700, #ff8c00); color: #000; padding: 8px 16px; 
    font-size: 13px; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; 
    box-shadow: 0 4px 10px rgba(255, 215, 0, 0.3); white-space: nowrap; flex: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-vip:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 140, 0, 0.4);
    filter: brightness(1.05);
}
.btn-vip:active { transform: translateY(-1px); }

/* --- HIỆU ỨNG BANNER DÙNG THỬ TRƯỢT XUỐNG --- */
#trial_banner {
    position: fixed;
    top: -100px; /* Bắt đầu ngoài màn hình */
    left: 0;
    width: 100%;
    z-index: 10006;
    padding: 8px 25px; /* Làm thanh mảnh hơn */
    background: linear-gradient(135deg, #fb7185, #f43f5e); /* Màu đỏ nhẹ/Rose hiện đại */
    color: white;
    display: none; /* Sẽ được JS bật sang flex */
    align-items: center;
    justify-content: center;
    font-size: 13px; /* Chữ nhỏ gọn hơn */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: top 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Hiệu ứng bouncy nhẹ */
}
#trial_banner.active {
    top: 0;
}

/* Thanh tiến trình đếm ngược 30s */
.trial-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.5);
    width: 100%;
    transform-origin: left;
    transform: scaleX(0);
}
#trial_banner.active .trial-progress-bar {
    animation: trialCountdown 30s linear forwards;
}

.close-trial-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 16px; /* Nhỏ lại cho cân đối với thanh mảnh */
    cursor: pointer;
    margin-left: 15px;
    padding: 5px;
    transition: 0.2s;
}
.close-trial-btn:hover { color: white; transform: scale(1.1); }

@keyframes trialCountdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.user-badge { display: none; align-items: center; background: transparent; padding: 6px 10px; }
.logout-link { margin-left: 12px; padding-left: 12px; border-left: 2px solid #e2e8f0; color: #ef4444; text-decoration: none; font-weight: bold; font-size: 13px; }

/* --- ẨN CÁC ICON QR / KIỂM TRA MÃ KHI CHƯA ĐĂNG NHẬP --- */
body:not(.is-logged-in) #qrcode-screen,
body:not(.is-logged-in) [onclick*="showQRModal"],
body:not(.is-logged-in) [onclick*="openQuickCheckModal"],
body:not(.is-logged-in) .btn-qr,
body:not(.is-logged-in) #notif_container,
body:not(.is-logged-in) #sound_toggle_btn {
    display: none !important;
}

/* 5. NHẬP LIỆU */
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

.btn-clear { background: #fff1f2 !important; color: #ef4444 !important; border: 1px solid #fecaca !important; box-shadow: none !important; }

/* ==========================================
   4. KHU VỰC NỘI DUNG CHÍNH (PC & CHUNG)
   ========================================== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; position: relative; width: 100%; }
.top-bar { background: var(--white); height: 60px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; padding: 0 25px; flex-shrink: 0; width: 100%; }
.btn-menu-toggle { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--sidebar); padding: 0; display: flex; align-items: center; justify-content: center; height: 40px; width: 40px; border-radius: 8px; transition: 0.2s; }
.btn-menu-toggle:hover { background: #e2e8f0; }
.content-wrapper { padding: 20px; max-width: 1200px; margin: 0 auto; width: 100%; }

.money-card { 
    background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%); 
    border-left: 5px solid var(--secondary); 
    text-align: center;
    padding: 25px 15px;
    /* Giữ nguyên chiều cao tự nhiên theo nội dung */
    transition: 0.3s;
}

/* Grid cho bảng giá */
.settings-group { 
    background: #f8fafc; 
    border-radius: 12px; 
    padding: 15px; 
    margin-bottom: 20px; 
    border: 1px solid #e2e8f0; 
}
.section-title { 
    font-size: 13px; 
    font-weight: 800; 
    color: var(--primary); 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-bottom: 15px; 
    margin-top: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.bet-item-box { background: #f8fafc; padding: 15px; border-radius: 10px; border: 1px solid #e2e8f0; transition: 0.2s; }
.bet-item-box:hover { border-color: var(--primary); background: #fff; }
.bet-label { font-weight: 700; margin-bottom: 6px; color: var(--slate-600); font-size: 10px; text-transform: uppercase; display: block; }

/* --- TAG INPUT STYLES --- */
.tag-container {
    transition: 0.2s;
    background: #f8fafc;
}
.tag-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: #fff;
}
.tag-item {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #c7d2fe;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.05);
    max-width: 100%;
    word-break: break-word;
    white-space: normal;
}
.tag-item span { flex: 1; }
.tag-item .remove-tag {
    cursor: pointer;
    font-size: 12px;
    opacity: 0.6;
    transition: 0.2s;
    flex-shrink: 0;
}
.tag-item .remove-tag:hover {
    opacity: 1;
    color: #ef4444;
}

/* --- FORMAT SEPARATOR STYLES --- */
.sep-block-input {
    font-family: 'JetBrains Mono', 'Roboto Mono', monospace !important;
    font-size: 18px !important;
    font-weight: 900 !important;
    color: var(--primary) !important;
    letter-spacing: 8px !important;
    text-align: center !important;
    background: var(--primary-light) !important;
    border: 1px dashed #c7d2fe !important;
}
.sep-block-input:focus {
    background: #ffffff !important;
    border: 1px solid var(--primary) !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15) !important;
}

/* ==========================================
   5. Ô NHẬP LIỆU, BÔI ĐỎ LỖI & NÚT BẤM
   ========================================== */
/* Đưa lớp bôi đỏ lên trên textarea để có thể hover, nhưng cho phép click xuyên qua */
.input-container { position: relative; width: 100%; height: 200px; min-height: 120px; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; cursor: text; resize: vertical; padding-bottom: 15px; }
.backdrop { position: absolute; z-index: 3; top: 0; left: 0; width: 100%; height: calc(100% - 15px); overflow: hidden; background-color: transparent; pointer-events: none; }
.highlights { padding: 12px; font-size: 18px; line-height: 1.6; font-family: 'JetBrains Mono', 'Roboto Mono', monospace !important; letter-spacing: normal; margin: 0; white-space: pre-wrap; word-wrap: break-word; color: #0f172a; pointer-events: none; }

.highlights mark { 
    background-color: rgba(239, 68, 68, 0.2); 
    color: inherit; 
    border-bottom: 2px solid #ef4444; 
    border-radius: 2px; 
    pointer-events: none;
}

@keyframes preview-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.highlights mark.duplicate {
    background-color: rgba(245, 158, 11, 0.15);
    border-bottom: 2px dotted #f59e0b;
}

.station-name-highlight {
    background-color: transparent;
    font-weight: 800;
}
.station-region-mn { color: #dc2626; } /* Đỏ cho miền Nam */
.station-region-mt { color: #16a34a; } /* Xanh lá cho miền Trung */
.station-region-mb { color: #2563eb; } /* Xanh dương cho miền Bắc */
.station-region-unknown { color: #8b5cf6; } /* Tím cho đài không rõ ràng */

textarea#raw_input { position: absolute; z-index: 1; top: 0; left: 0; width: 100%; height: calc(100% - 15px); background: transparent; color: transparent; caret-color: #0f172a; border: none; padding: 12px; font-size: 18px; line-height: 1.6; font-family: 'JetBrains Mono', 'Roboto Mono', monospace !important; letter-spacing: normal; margin: 0; resize: none; outline: none; white-space: pre-wrap; word-wrap: break-word; }
textarea#raw_input::selection { color: transparent; background-color: rgba(59, 130, 246, 0.3); }

.form-inp { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #cbd5e1; border-radius: 8px; outline: none; font-size: 15px; }
.password-wrapper { position: relative; width: 100%; display: block; margin-bottom: 15px; }
.password-wrapper .form-inp { margin-bottom: 0 !important; padding-right: 45px !important; }
.toggle-password { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #94a3b8; font-size: 16px; transition: 0.2s; z-index: 5; }
.toggle-password:hover { color: var(--primary); }

/* --- HỆ THỐNG NÚT BẤM ĐỒNG BỘ V3 --- */
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; }

/* Đã khôi phục nút Voice Input */

.btn-action { 
    height: 38px; /* Chiều cao chuẩn cho mọi nút */
    padding: 0 20px; 
    border: none; 
    border-radius: 10px; 
    font-weight: 700; 
    cursor: pointer; 
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
    font-size: 14px; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    white-space: nowrap; /* Chống rớt dòng làm phồng nút */
    gap: 8px;
    user-select: none;
    flex: none;
}
    .btn-lg { height: 48px; min-height: 48px; font-size: 16px; border-radius: 14px; } /* Nút lớn cho hành động quan trọng */
.btn-sm { height: 48px; font-size: 12px; border-radius: 8px; padding: 0 12px; } /* Nút nhỏ cho thao tác phụ */

.btn-primary { background: var(--primary); color: white; border: none; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:hover { opacity: 0.9; }
.status-badge {
    display: flex; align-items: center; gap: 8px; padding: 6px 12px;
    border-radius: 20px; font-size: 11px; font-weight: 800; margin-right: auto; margin-left: 15px;
    background: #f1f5f9; transition: 0.3s;
}
.status-badge.online { color: #10b981; }
.status-badge.offline { color: #ef4444; background: #fee2e2; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.status-badge.online .status-dot {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@media (max-width: 768px) {
    .status-badge { margin-left: 5px; padding: 4px 8px; }
    .status-text { display: none; } /* Trên mobile chỉ hiện chấm tròn cho gọn */
}

.btn-soft-warning { background: #fff7ed !important; color: #c2410c !important; border: 1px solid #fed7aa !important; }
.btn-soft-success { background: #f0fdf4 !important; color: #15803d !important; border: 1px solid #bbf7d0 !important; }
.btn-soft-secondary { background: #fff1f2 !important; color: #e11d48 !important; border: 1px solid #fecaca !important; }
.btn-soft-primary { background: var(--primary-light) !important; color: var(--primary) !important; border: 1px solid #c7d2fe !important; }
/* Hiệu ứng tương tác chung cho Soft Buttons */
.btn-soft-warning:hover, .btn-soft-success:hover, .btn-soft-secondary:hover { 
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    filter: brightness(0.98);
}
.btn-soft-warning:active, .btn-soft-success:active, .btn-soft-secondary:active { transform: translateY(0); }

/* Định dạng độ rộng chuẩn cho Modal Đăng nhập trên PC */
.login-modal-box {
    width: 100%;
    max-width: 480px; /* Độ rộng lý tưởng cho form đăng nhập */
}

/* Style chung cho tiêu đề Modal Đăng nhập trên cả PC và Mobile */
#login_modal .v3-toolbar {
    padding: 30px 20px !important;
    justify-content: center !important;
    text-align: center !important;
}

#login_modal .v3-toolbar .dashboard-title {
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
}

#login_modal #modal_title {
    font-size: 22px !important; /* Đồng nhất cỡ chữ tiêu đề lớn */
    margin-bottom: 5px;
}

#login_modal .v3-toolbar .dashboard-title i {
    font-size: 32px !important;
    margin: 0 !important;
}

/* ==========================================
   6. VÙNG HIỂN THỊ KẾT QUẢ PC
   ========================================== */
.result-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; width: 100%; align-items: stretch; }
.right-panel { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.detail-box { min-height: 400px; max-height: none !important; background: #ffffff; padding: 0 !important; overflow: hidden !important; margin: 0 !important; width: 100%; border: 1px solid #e2e8f0; border-radius: 12px; display: flex; flex-direction: column; font-family: 'Inter', sans-serif; }
.qr-box { 
    text-align: center; 
    margin: 0 !important; 
    max-height: none !important;
    width: 100%; 
    display: flex; 
    flex-direction: column; 
    align-items: stretch; 
    justify-content: flex-start; 
    flex: 1; /* Kéo dài để bù đắp chiều cao còn lại cho cân bằng với cột trái */
}

/* ==========================================
   DROPDOWN MENU LỊCH SỬ THAO TÁC
   ========================================== */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #ffffff;
    min-width: 150px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-top: 5px;
}

.dropdown-menu.show {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s ease;
}

.dropdown-item {
    background: none;
    border: none;
    padding: 10px 15px;
    text-align: left;
    width: 100%;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.dropdown-item.text-danger:hover {
    background-color: #fee2e2;
    color: #ef4444;
}

/* --- CẤU TRÚC PHÔI BIÊN NHẬN --- */
.receipt-header { padding: 15px; font-weight: 800; border-bottom: 1px solid #e2e8f0; background: #f8fafc; color: var(--sidebar); font-size: 15px; flex: 0 0 auto; }
.receipt-body { padding: 10px 15px; flex: 1; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.station-group { background: #fdfdfd; border: 1px solid #f1f5f9; border-radius: 8px; padding: 10px; }
.station-name { font-weight: 800; color: var(--primary); font-size: 14px; margin-bottom: 8px; border-bottom: 1px solid #e0f2fe; padding-bottom: 4px; text-transform: uppercase; }
.bet-line { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 6px 0; border-bottom: 1px dashed #e2e8f0; font-size: 14px; 
}
.bet-line:last-child { border-bottom: none; }
.bet-info { display: flex; gap: 8px; align-items: baseline; color: #334155; }
.bet-nums { font-weight: 800; color: #000; font-size: 15px; }
.bet-type { color: #64748b; font-weight: 600; font-size: 15px; text-transform: capitalize; }
.bet-pts { font-weight: 700; color: var(--secondary); font-size: 15px; }
.bet-price { font-weight: 800; color: #1e293b; text-align: right; }

/* Trạng thái chưa có dữ liệu */
.empty-state { 
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; 
    color: #94a3b8; gap: 10px; padding: 40px; text-align: center;
}
.empty-state i { font-size: 48px; opacity: 0.2; }

/* ==========================================
   7. HỆ THỐNG POPUP (MODAL) CHUNG
   ========================================== */
.modal-overlay { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(15, 23, 42, 0.35); z-index: 10000; justify-content: center; align-items: center; padding: 20px; 
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}
.modal-box { background: white; padding: 25px; border-radius: 12px; width: 100%; max-width: 450px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.modal-box-xl { 
    max-width: 950px; width: 100%; background: #ffffff; border-radius: 16px; padding: 25px; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.3); max-height: 90vh; display: flex; flex-direction: column; 
    position: relative; margin: auto; overflow: hidden; border: 1px solid var(--border);
}
.modal-box-vip { max-width: 850px; width: 100%; background: #ffffff; border-radius: 12px; padding: 25px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); max-height: 90vh; display: flex; flex-direction: column; position: relative; margin: auto; overflow: hidden; }

/* Tối ưu riêng màn hình Tablet (từ 769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .result-grid {
        grid-template-columns: 1fr !important;
    }
    .right-panel {
        flex-direction: row !important;
    }
    .money-card { flex: 1 !important; }
    #qr_container { flex: 1 !important; }
}

/* --- HELP CENTER STYLES --- */
.help-container { display: flex; gap: 20px; flex: 1; min-height: 0; border-top: 1px solid var(--border); padding-top: 15px; }
.help-sidebar { width: 200px; border-right: 1px solid var(--border); padding-right: 15px; display: flex; flex-direction: column; gap: 8px; }
.help-nav-item { padding: 12px 15px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 700; color: var(--slate-600); transition: 0.2s; border: 1px solid transparent; }
.help-nav-item:hover { background: var(--primary-light); color: var(--primary); }
.help-nav-item.active { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2); }
.help-nav-vip { color: var(--warning); border-top: 1px solid var(--border); margin-top: 10px; padding-top: 15px; font-weight: 800; }
.help-nav-vip:hover { background: #fffbeb; }
.help-content { flex: 1; overflow-y: auto; padding-left: 5px; }
.help-section { display: none; }
.help-section.active { display: block; animation: fadeIn 0.3s ease; }
.help-card { background: var(--bg); border-radius: 12px; padding: 15px; margin-bottom: 15px; border: 1px solid var(--border); }
.help-title { font-size: 18px; font-weight: 800; color: var(--sidebar); margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.syntax-example { background: #1e293b; color: #38bdf8; padding: 12px; border-radius: 8px; font-family: 'JetBrains Mono', monospace; font-size: 14px; margin: 10px 0; line-height: 1.5; border-left: 4px solid var(--primary); }
.syntax-desc { font-size: 13px; color: var(--slate-600); margin-bottom: 8px; }
.badge-guide { padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; background: #e2e8f0; }

@media (max-width: 768px) {
    .help-container { 
        flex-direction: column !important; 
        flex: 1 !important; 
        min-height: 0 !important; 
        height: auto !important; 
    }
    
    /* Tối ưu Thanh Tab Hướng dẫn trên Mobile */
    .help-sidebar { 
        width: 100% !important; 
        border-right: none !important; 
        border-bottom: 1px solid var(--border) !important; 
        padding: 10px !important; 
        flex-direction: row !important; 
        overflow-x: auto !important; 
        white-space: nowrap !important; 
        display: flex !important;
        -webkit-overflow-scrolling: touch; /* Giúp cuộn mượt trên iOS/Android */
        align-items: center !important;
        gap: 8px !important;
        background: #f1f5f9 !important;
        scrollbar-width: none;
    }
    .help-sidebar::-webkit-scrollbar { display: none; }

    .help-nav-item { 
        padding: 10px 18px !important; 
        padding: 0 18px !important; 
        height: 42px !important; /* Chiều cao cố định giúp các nút luôn bằng chằn chặn */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 0 0 auto !important; /* Ngăn không cho các mục bị co lại */
        background: white; /* Bỏ !important để class .active có thể đè màu */
        color: var(--slate-600);
        border: 1px solid var(--border) !important;
        border-radius: 10px !important;
        white-space: nowrap !important; /* Ép chữ trên 1 dòng để kích hoạt cuộn ngang */
        font-size: 13px !important;
        font-weight: 700 !important; /* Độ đậm đồng nhất để không bị nhảy kích thước khi chuyển tab */
    }
    .help-nav-item.active {
        background: var(--primary) !important;
        color: white !important;
        border-color: var(--primary) !important;
    }
    .help-nav-vip { margin-top: 0 !important; padding-top: 10px !important; border-top: none !important; }
    .help-nav-vip { margin: 0 !important; border-top: none !important; color: var(--warning) !important; }
    
    #huongdan_modal .v3-toolbar h3 { display: none !important; }
    #huongdan_modal .v3-toolbar { justify-content: center !important; min-height: 45px !important; padding: 10px !important; }
    .help-content { 
        padding: 15px !important; 
        flex: 1 !important; 
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .help-container { flex-direction: column; height: auto; }
    .help-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 10px; flex-direction: row; overflow-x: auto; white-space: nowrap; }
    .help-nav-item { padding: 8px 15px; }
}

/* Bảng biểu PC */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { border: 1px solid #e2e8f0; padding: 6px 10px; text-align: center; font-size: 14px; }
th { background: #f8fafc; color: #64748b; font-size: 12px; text-transform: uppercase; }

/* Chuẩn hóa nội dung bảng biểu (Lịch sử & Sổ nợ): 1 size, chữ đen, không in đậm */
.history-row td, .sono-row td {
    color: #000000 !important;
    font-weight: 400 !important;
    font-size: 14px !important;
}

/* Đan xen dòng xám nhẹ - trắng (Zebra striping) */
.v3-table tbody tr:nth-child(even) td {
    background: #f8fafc !important;
}
.v3-table tbody tr:hover td {
    background: #f1f5f9 !important;
}

/* Căn chỉnh nội dung bảng lịch sử PC */
.td-noidung { text-align: left; }
.noidung-flex-wrapper { justify-content: flex-start; }
.noidung-text-box { text-align: left; }
.col-thanhtoan-flex { align-items: center; }
.btn-thanhtoan-mobile { margin: 0 auto; }

/* Nâng cấp V3.1: Kéo dài Form tìm kiếm trong Modal Lịch sử để lấp đầy hàng ngang */
#lichsu_modal .v3-toolbar > div:nth-child(2) {
    flex: 1;
    min-width: 200px;
}
#lichsu_modal .v3-toolbar > div:nth-child(2) input {
    width: 100% !important;
}

/* ==========================================
   8. THÔNG BÁO & LOADING
   ========================================== */
#toast {
    visibility: hidden;
    position: fixed;
    top: 80px; /* Ngay dưới Top Bar */
    right: 20px;
    transform: translateX(120%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #1e293b;
    padding: 15px 20px;
    border-radius: 12px;
    z-index: 11000;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 300px;
    max-width: 400px;
    overflow: hidden;
    cursor: grab;
    user-select: none;
}
#toast:active { cursor: grabbing; }
#toast.show { visibility: visible; opacity: 1; transform: translateX(0); }

/* Thanh tiến trình thời gian */
#toast::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
    transform-origin: left;
}
#toast.show::after {
    animation: toast-progress 4s linear forwards;
}
@keyframes toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

#toast.success { border-right: 4px solid #10b981; }
#toast.error { border-right: 4px solid #ef4444; }
#toast.warning { border-right: 4px solid #f59e0b; }
#toast.info { border-right: 4px solid var(--primary); }

#toast .toast-icon { font-size: 22px; width: 30px; display: flex; justify-content: center; }
#toast.success .toast-icon { color: #10b981; }
#toast.error .toast-icon { color: #ef4444; }
#toast.warning .toast-icon { color: #f59e0b; }
#toast.info .toast-icon { color: var(--primary); }
#toast .toast-message { flex: 1; }
#toast .toast-title { font-weight: 800; font-size: 13px; text-transform: uppercase; margin-bottom: 2px; display: block; }
#toast .toast-desc { font-size: 14px; color: #475569; font-weight: 500; }

/* Notification Bell Styles */
.notification-bell {
    padding: 8px; border-radius: 50%; transition: 0.3s; position: relative; cursor: pointer;
}
.notification-bell:hover { background: #f1f5f9; }
.notification-bell i { font-size: 20px; color: #64748b; transition: 0.3s; }
.notification-bell:hover i { color: var(--primary); transform: rotate(15deg); }
#notif_badge {
    position: absolute; top: -2px; right: -2px; background: var(--secondary); color: white;
    font-size: 10px; font-weight: 800; min-width: 16px; height: 16px;
    border-radius: 50%; border: 2px solid white; display: flex; align-items: center; justify-content: center;
}

/* Notif Item Styles */
.notif-item {
    padding: 15px; border-radius: 12px; background: #f8fafc; border: 1px solid #e2e8f0;
    margin-bottom: 12px; transition: 0.2s; position: relative; cursor: pointer;
}
.notif-item:hover { border-color: var(--primary); background: #fff; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.notif-item.unread { background: #eff6ff; border-color: #bae6fd; }
.notif-item.unread::after {
    content: "MỚI"; position: absolute; top: 15px; right: 15px; background: var(--secondary);
    color: white; font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 4px;
}

/* ==========================================================================
   💻 9. GIAO DIỆN PC & DỌN DẸP (MIN-WIDTH: 769PX)
   ========================================================================== */
@media screen and (min-width: 769px) {
    .sidebar { transform: translateX(0); }
    .sidebar.collapsed { transform: translateX(-100%); margin-left: -260px; }
    .user-block-mobile, #nav_account_mobile, #nav_login_mobile { display: none !important; }
    .nav-item-support { margin-top: auto !important; }
}

/* ==========================================================================
   📱 10. GIAO DIỆN MOBILE & TỐI ƯU CÔNG NĂNG (MAX-WIDTH: 768PX)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* SideBar Di Động */
    .sidebar { position: fixed !important; top: 0 !important; left: 0 !important; height: 100vh !important; transform: translateX(-100%); box-shadow: 4px 0 15px rgba(0,0,0,0.5); }
    .sidebar.active { transform: translateX(0); }
    .sidebar { position: fixed !important; top: 0 !important; left: 0 !important; height: 100vh !important; transform: translateX(-100%); box-shadow: none; }
    .sidebar.active { transform: translateX(0); box-shadow: 10px 0 30px rgba(0,0,0,0.2); }
    .user-block-mobile { display: block !important; padding: 20px 15px !important; background: #0f172a !important; margin-top: auto !important; border-top: 1px solid #334155 !important; }
    .close-sidebar-btn { display: block !important; }

    /* Header & Auth Section */
    .top-bar { padding: 10px 15px !important; }
    #auth-section { margin-left: auto !important; gap: 8px !important; }
    #auth-section .btn-action { width: auto !important; padding: 8px 12px !important; font-size: 12px !important; min-width: max-content !important; margin: 0 !important; }
    #userInfo { display: none !important; }
    .notification-bell { margin: 0 5px !important; padding: 5px !important; }
    #sound_toggle_btn { display: none !important; }

    /* Ẩn widget chat ZenlyBox trên mobile để giải phóng diện tích màn hình */
    #a102-chat-widget { display: none !important; }

    /* Tối ưu thẻ tóm tắt trên mobile */
    .v3-summary-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        padding: 12px !important;
        gap: 10px !important;
    }
    .v3-mini-card { padding: 12px !important; gap: 10px !important; }
    .v3-mini-card .icon-box { width: 35px !important; height: 35px !important; font-size: 16px !important; }
    .v3-mini-card .value { font-size: 16px !important; }
    .v3-mini-card .value { font-size: clamp(13px, 4vw, 16px) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .money-card .value { font-size: clamp(32px, 10vw, 44px) !important; font-weight: 900 !important; letter-spacing: -1px !important; }

    /* Bố cục trang chủ */
    .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .controls button { width: 100% !important; margin: 0 !important; }
    /* Thêm margin-top để tách biệt ô nhập liệu và cụm kết quả */
    .result-grid { display: flex !important; flex-direction: column !important; gap: 15px !important; width: 100% !important; margin-top: 20px !important; }
    .right-panel { display: contents !important; }
    .money-card { order: 1 !important; margin-bottom: 15px !important; width: 100% !important; padding: 20px !important; }
    #result_detail { order: 2 !important; margin-bottom: 15px !important; width: 100% !important; min-height: 300px !important; }
    #qr_container { order: 3 !important; padding: 20px !important; margin-bottom: 0 !important; }

    /* Kéo giãn Modal Mobile (Áp dụng chung) */
    .modal-overlay { padding: 10px !important; }
    .modal-box, .modal-box-vip, .modal-box-xl { 
        width: 100% !important; max-width: 100% !important; 
        padding: 15px !important; margin: 0 !important;
    }

    /* ================= CƠ CHẾ CARD VIEW CHO BẢNG BIỂU ================= */
    table:not(.no-responsive), 
    table:not(.no-responsive) tbody, 
    table:not(.no-responsive) tr { display: block !important; width: 100% !important; }
    table:not(.no-responsive) thead { display: none !important; } /* Giấu tiêu đề cột truyền thống */
    
    table:not(.no-responsive) tr {
        margin-bottom: 15px !important; padding: 15px !important;
        background: #ffffff !important; border: 1px solid #e2e8f0 !important;
        border-radius: 12px !important; box-shadow: 0 4px 6px rgba(0,0,0,0.05) !important;
    }
    
    table:not(.no-responsive) td {
        display: flex !important; justify-content: space-between !important; align-items: flex-start !important;
        padding: 5px 0 !important; border: none !important; border-bottom: 1px dashed #f1f5f9 !important;
        text-align: right !important; font-size: 14px !important; gap: 10px !important;
    }
    table:not(.no-responsive) td::before { content: attr(data-label); flex: 0 0 100px !important; text-align: left !important; font-weight: 700; color: var(--slate-400); font-size: 10px; text-transform: uppercase; }
    table:not(.no-responsive) td:last-child { border-bottom: none !important; }

    /* Ghi đè căn chỉnh trên Mobile cho Lịch Sử Ghi */
    .td-noidung { text-align: right !important; max-width: none !important; }
    .noidung-flex-wrapper { justify-content: flex-end !important; }
    .noidung-text-box { text-align: right !important; }
    .col-thanhtoan-flex { align-items: flex-end !important; }
    .btn-thanhtoan-mobile { margin: 0 0 0 auto !important; }

    /* ================= CƠ CHẾ GHIM NÚT DƯỚI ĐÁY TỰ ĐỘNG ================= */
    .modal-box-vip > .btn-action:last-child,
    .modal-box-xl > .btn-action:last-child {
        position: sticky !important; bottom: -5px !important; z-index: 100 !important;
        box-shadow: 0 -15px 20px rgba(255, 255, 255, 0.95) !important;
        margin-top: auto !important; height: 50px !important; font-weight: 800 !important;
        border-radius: 8px !important; text-transform: uppercase !important;
    }

    /* Tinh chỉnh UI Nhập liệu trên di động */
    .v3-toolbar { padding: 10px 50px 10px 15px !important; gap: 10px !important; }

    /* Nâng cấp V3.1: Căn chỉnh lại thanh công cụ nhập liệu chính trên mobile */
    .content-wrapper > .v3-kqxs-container > .v3-toolbar {
        padding-right: 15px !important;
    }
    
    /* CHỐNG XÔ LỆCH TIÊU ĐỀ TRONG MODAL & CARD CHI TIẾT */
    .v3-toolbar h3, 
    .dashboard-title, 
    .dashboard-title > div { 
        white-space: nowrap !important; 
        overflow: hidden !important; 
        text-overflow: ellipsis !important; 
        flex: 1 !important; 
        min-width: 0 !important; 
        font-size: clamp(13px, 4.2vw, 16px) !important;
    }
    .v3-toolbar > div:first-child { flex: 1 !important; min-width: 0 !important; gap: 8px !important; }
    .dashboard-title { font-size: clamp(12px, 3.8vw, 14px) !important; flex: 1 !important; min-width: 0 !important; }
    .dashboard-title > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .dashboard-title .truncate { font-size: inherit !important; }
    .v3-toolbar > div:last-child { flex-shrink: 0 !important; }
    
    /* Ép 2 ô nhập liệu trên thanh công cụ co giãn thông minh trên Mobile */
    #ghi_chu_input, #phoi_date_input { width: 100% !important; max-width: 110px !important; height: 30px !important; flex: 1 !important; min-width: 0 !important; padding: 0 6px !important; }
    .input-container { height: 180px !important; }
    .highlights, textarea#raw_input { font-size: 16px !important; }
}

/* ==========================================================
   TỐI ƯU RIÊNG CHO TELEGRAM MINI APP (TMA MODE)
   ========================================================== */
.tma-mode .sidebar {
    display: none !important;
}

.tma-mode .sidebar.active {
    display: flex !important; /* Cho phép hiện ra khi được bấm nút menu */
}

.tma-mode .top-bar,
.tma-mode #trial_banner {
    display: none !important; /* Ẩn sạch các thanh menu điều hướng */
}

.tma-mode .main-content {
    height: 100vh !important;
    width: 100vw !important;
}

.tma-mode .content-wrapper {
    padding: 10px !important; /* Thu nhỏ lề tối đa trên Telegram */
    margin: 0 !important;
    max-width: 100% !important;
}

/* Ẩn tiêu đề NHẬP LIỆU trên TMA cho gọn gàng */
.tma-mode .content-wrapper > .v3-kqxs-container > .v3-toolbar .dashboard-title {
    display: none !important;
}

/* Thu gọn thanh công cụ nhập liệu trên TMA */
.tma-mode .content-wrapper > .v3-kqxs-container > .v3-toolbar {
    min-height: 40px !important;
    padding: 8px 10px !important;
    justify-content: flex-end !important; /* Đẩy các nút bấm (Refresh, Voice...) sát sang mép phải */
}

.tma-mode .google-login-section {
    display: none !important;
}

/* Nút Nổi (Floating Action Button) để mở Menu khi cần */
#tma_fab {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: var(--primary);
    color: white;
    z-index: 9999;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.tma-mode #tma_fab { display: flex; }
@media screen and (max-width: 768px) {
    /* Tối ưu Toolbar của Lịch Sử Ghi Số */
    #lichsu_modal .v3-toolbar {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        padding: 15px 50px 15px 15px !important; /* Tạo vùng đệm an toàn cho nút X */
        gap: 12px !important;
    }

    /* HÀNG 1: Chọn ngày tháng */
    #lichsu_modal .v3-toolbar > div:first-child {
        width: 100% !important;
        flex: 0 0 100% !important; /* Ép chiếm 100% chiều rộng để tạo thành một hàng riêng biệt */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #lichsu_modal .v3-toolbar > div:first-child h3 {
        display: none !important;
    }

    #lichsu_modal .v3-toolbar .v3-date-picker {
        width: 100% !important;
        max-width: 300px !important; /* Ngăn ô ngày quá dài */
        justify-content: center !important;
    }
    #lichsu_modal .v3-toolbar .v3-date-picker input[type="date"] {
        flex: 1 !important;
        min-width: 120px !important;
    }

    /* HÀNG 2: Form Tìm Kiếm */
    #lichsu_modal .v3-toolbar > div:nth-child(2) {
        flex: 1 !important; /* Cho phép ô tìm kiếm co giãn lấp đầy không gian hàng 2 */
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
    }

    /* HÀNG 2: Nhóm Nút Xóa, Refresh, Excel */
    #lichsu_modal .v3-toolbar > div:last-child {
        flex: none !important; /* Không dãn, bám sát form tìm kiếm */
        width: auto !important;
        display: flex !important; /* Đổi sang Flex để các nút xếp linh hoạt */
        justify-content: flex-end !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    /* Thêm khoảng đệm cho các thẻ card trong Lịch sử và Sổ nợ trên mobile */
    #lichsu_modal .v3-table > tbody,
    #sono_modal .v3-table > tbody {
        padding: 15px 15px 0 15px;
    }
    
    /* Thu gọn nút bấm Toolbar trên Mobile cho thanh mảnh */
    .v3-toolbar .btn-action {
        height: 36px !important;
        padding: 0 8px !important;
        font-size: 11px !important;
        border-radius: 8px !important;
        min-width: 0 !important;
        width: auto !important; /* Vô hiệu hóa inline width cố định (VD: 38px) trên PC */
        white-space: nowrap !important; /* Chống rớt dòng chữ trong nút */
        gap: 4px !important; /* Thu hẹp khoảng cách với icon */
        flex: 1 1 auto; /* Cho phép nút dãn ra lấp đầy khoảng trống */
        justify-content: center !important;
    }

    /* Tối ưu Toolbar của Trung Tâm Kết Quả (KQXS Modal) */
    #kqxs_modal .v3-toolbar {
        flex-direction: column !important; /* Xếp chồng dọc */
        align-items: center !important;
        padding: 15px 50px 15px 15px !important; /* Tạo vùng đệm an toàn cho nút X */
        gap: 12px !important;
    }

    #kqxs_modal .v3-toolbar > div:first-child {
        width: 100% !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 8px !important;
    }

    #kqxs_modal .v3-toolbar > div:first-child h3 {
        display: none !important; /* Ẩn tiêu đề trên mobile */
    }

    #kqxs_modal .v3-toolbar .v3-date-picker {
        width: 100% !important;
        justify-content: center !important;
    }

    #kqxs_modal .v3-toolbar > div:last-child {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important; /* Đổi thành 4 cột vì menu này có 4 nút */
        gap: 6px !important;
    }
    #kqxs_modal .v3-toolbar > div:last-child .btn-action {
        padding: 8px 2px !important;
        font-size: 11px !important;
        min-width: 0 !important;
        width: 100% !important; /* Ép nút dãn đều trong Grid */
        height: 38px !important;
    }

    /* Tối ưu bộ lọc của Trung Tâm Báo Cáo (Thống kê) trên Mobile */
    .tk-toolbar-redesign {
        flex-direction: row !important; /* Giữ nguyên hàng ngang */
        padding: 12px 50px 12px 12px !important; /* Tạo vùng đệm an toàn cho nút X */
        align-items: stretch !important; /* Kéo dài các item con */
    }
    #thongke_modal .tk-toolbar-redesign > div:first-child {
        display: none !important; /* Ẩn tiêu đề trên mobile để tiết kiệm diện tích */
    }
    .tk-toolbar-redesign .tk-filter-group {
        width: 100%;
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 8px !important;
    }
    /* Hàng 1: Loại và Ngày */
    #tk_filter_type { grid-column: 1 / 2; }
    #tk_date_wrapper, #tk_filter_month { grid-column: 2 / 4; }
    /* Hàng 2: Các nút action */
    .tk-toolbar-redesign .btn-soft-primary { grid-column: 1 / 2; grid-row: 2; }
    .tk-toolbar-redesign .btn-soft-success { grid-column: 2 / 3; grid-row: 2; }
    .tk-toolbar-redesign .btn-soft-warning { grid-column: 3 / 4; grid-row: 2; }
    
    /* Căn chỉnh các phần tử trong grid để có chiều cao và vị trí đồng bộ */
    .tk-toolbar-redesign .tk-filter-group > * {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        height: 42px !important;
        padding: 0 8px !important;
    }

    #tk_region_summary {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

}

@media screen and (max-width: 768px) {
    /* Kéo giãn Modal Mobile (Áp dụng chung) */
    .modal-overlay { 
        padding: 20px 10px 50vh 10px !important; /* Dành 50vh vùng đệm tàng hình dưới đáy cho bàn phím ảo */
        align-items: flex-start !important; /* Đẩy form lên trên cùng để tránh phím ảo che */
        overflow-y: auto !important; /* Bật chế độ cuộn */
    }
    .modal-box, .modal-box-vip, .modal-box-xl {
        width: 100% !important; max-width: 100% !important;
        padding: 15px !important; /* Reduced padding */
        margin: 0 !important;
        border-radius: 16px !important; /* Make it consistent with other modals */
        max-height: none !important; /* Bỏ max-height để form tự do giãn nở */
        height: auto !important;
    }

    .v3-kqxs-container {
        width: 100% !important; max-width: 100% !important;
        padding: 0 !important; /* KQXS có padding riêng ở toolbar */
        margin: 0 !important;
        border-radius: 16px !important;
        height: auto !important;
        max-height: none !important; 
    }
    .modal-overlay > .v3-kqxs-container { margin: 0 auto !important; }

    #kqxs_modal .v3-kqxs-container {
        height: 96vh !important; /* Ép full màn hình riêng cho bảng kết quả */
        max-height: 96vh !important;
    }

    .login-modal-box { max-width: 100% !important; }

    /* Tinh chỉnh nhỏ cho Modal Đăng nhập trên Mobile */
    #login_modal .v3-toolbar {
        padding: 20px 50px 20px 15px !important; /* Tạo vùng đệm an toàn cho nút X */
    }
    #login_modal .v3-toolbar .dashboard-subtitle {
        font-size: 11px !important;
    }

    #login_modal > div > div:last-child { /* The div containing the forms */
        padding: 20px !important; /* Reduce padding */
    }

    #login_modal .form-inp {
        height: 45px !important; /* Reduce input height */
        font-size: 14px !important; /* Adjust font size */
        border-radius: 10px !important; /* Slightly smaller border-radius */
    }

    #login_modal .btn-action {
        height: 48px !important; /* Reduce button height */
        font-size: 15px !important; /* Adjust button font size */
        border-radius: 12px !important; /* Slightly smaller border-radius */
    }

    /* Google Sign-in button adjustments */
    .g_id_signin {
        max-width: 280px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    /* Adjust spacing for "OR EMAIL" separator */
    .google-login-section > div:last-child { /* This targets the div containing the separator */
        margin-bottom: 20px !important;
        gap: 10px !important;
    }
    .google-login-section > div:last-child span {
        font-size: 10px !important;
    }

    /* Adjust spacing for remember me / forgot password */
    #login_form > div:nth-child(4) { /* This targets the div containing remember/forgot */
        margin-bottom: 20px !important;
    }

    /* Adjust spacing for OTP container */
    #otp_container {
        padding: 15px !important;
        border-radius: 12px !important;
        margin-bottom: 15px !important;
    }
    #otp_container .bet-label {
        font-size: 12px !important;
        margin-bottom: 8px !important;
    }
    #otp_container .form-inp {
        height: 50px !important; /* Keep OTP input slightly larger for readability */
        font-size: 20px !important;
        letter-spacing: 4px !important;
    }

    /* Adjust spacing for register form */
    #register_form p {
        font-size: 11px !important;
        margin-bottom: 15px !important;
    }
    #register_form > div:last-child { /* "Đã có tài khoản?" section */
        padding-top: 15px !important;
    }

    /* Tối ưu Toolbar của Danh bạ & Sổ nợ trên Mobile */
    #sono_modal .v3-toolbar {
        flex-direction: column !important;
        align-items: center !important;
        padding: 15px 50px 15px 15px !important; /* Tạo vùng đệm an toàn cho nút X */
        gap: 15px !important;
    }
    #sono_modal .v3-toolbar h3 { display: none !important; }
    #sono_modal .v3-toolbar > div:last-child {
        width: 100% !important;
        flex-direction: column !important;
        gap: 12px !important;
        align-items: stretch !important;
    }
    #sono_modal .search-refresh-group, 
    #sono_modal .add-cust-group {
        width: 100% !important;
        display: flex !important;
        gap: 8px !important;
    }
    #sono_modal .search-refresh-group > div { flex: 1 !important; width: auto !important; max-width: none !important; }
    #sono_modal .add-cust-group input { flex: 1 !important; width: auto !important; margin: 0 !important; }
    #sono_modal .v3-divider { display: none !important; }
    #sono_modal .search-refresh-group button { flex: none !important; } /* Ngăn nút Refresh phình to */

    /* Tối ưu Toolbar của Hạn Chế Số trên Mobile */
    #risk_manager_modal .v3-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding: 15px 50px 15px 15px !important; /* Thêm vùng đệm an toàn cho nút X */
    }
    #risk_manager_modal .v3-toolbar .dashboard-title {
        display: none !important;
    }
    #risk_manager_modal .v3-toolbar .v3-date-picker {
        width: 100% !important;
        justify-content: center !important;
    }
    #risk_manager_modal .v3-toolbar > div:last-child { /* Vùng chứa nút */
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    /* Tối ưu Toolbar của Telegram trên Mobile */
    #tele_modal .v3-toolbar {
        padding: 15px 50px 15px 15px !important; /* Thêm vùng đệm an toàn cho nút X */
        min-height: 45px !important;
    }
    #tele_modal .v3-toolbar .dashboard-title { display: none !important; }

    /* Tối ưu Modal Cài Đặt trên Mobile */
    #settings_modal .v3-toolbar h3 { display: none !important; }
    #settings_modal .v3-toolbar { justify-content: center !important; padding: 12px 50px 12px 15px !important; }
    #settings_modal .v3-toolbar > div:last-child { width: 100% !important; display: flex !important; gap: 8px !important; }
    #settings_modal .v3-toolbar button { flex: 1 !important; width: auto !important; max-width: none !important; height: 42px !important; font-size: 12px !important; }

    #settings_modal .v3-tab-bar {
        display: flex !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding: 5px !important;
        gap: 8px !important;
        background: #f1f5f9 !important;
        scrollbar-width: none;
    }
    #settings_modal .v3-tab-bar::-webkit-scrollbar { display: none; }
    #settings_modal .v3-tab-item { flex: 0 0 auto !important; padding: 10px 15px !important; font-size: 12px !important; }

    .settings-group { padding: 15px 12px !important; margin-bottom: 15px !important; }
    .settings-group .section-title { font-size: 11px !important; }

    /* Ép các grid nhập liệu trong settings về 1 cột trên mobile để tránh tràn màn hình (đặc biệt Thẻ Tag) */
    #settings_modal .settings-group > div[style*="display: grid"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Các ô bảng giá (Tab MN/MB) nên để 1 cột để dễ nhập Thu/Đền */
    #tab_mn .settings-group > div[style*="display: grid"],
    #tab_mb .settings-group > div[style*="display: grid"],
    .settings-grid {
        grid-template-columns: 1fr !important;
    }
    
    .bet-item-box { padding: 12px 10px !important; }
    .bet-item-box .bet-label { font-size: 9px !important; }
}

/* ==========================================================
   V3 REDESIGN: KẾT QUẢ XỔ SỐ SCIENTIFIC STYLE
   ========================================================== */
.v3-kqxs-container {
    position: relative;
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    width: 100%;
    margin: auto;
    height: auto;
    max-height: 95vh;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

/* Ép cứng chiều cao cho riêng modal KQXS để có thanh cuộn mượt mà */
#kqxs_modal .v3-kqxs-container {
    height: 70vh;
}

.v3-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 4.5rem 1rem 1.5rem; /* Tăng padding-right (4.5rem) để bảo vệ khu vực nút X */
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1.5rem; /* Khoảng cách giữa tiêu đề và nhóm nút rộng rãi hơn */
}

/* Đồng bộ phong cách Tiêu đề tất cả các Menu */
.v3-toolbar h3,
.dashboard-title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--sidebar);
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
}

/* Đồng bộ hiển thị icon cho tất cả tiêu đề */
.v3-toolbar h3 i,
.dashboard-title i {
    display: inline-block !important;
    color: var(--primary) !important;
    font-size: 22px !important;
}

#risk_manager_modal .v3-toolbar .dashboard-subtitle,
#tele_modal .v3-toolbar .dashboard-subtitle { display: none; }

.dashboard-subtitle { margin: 4px 0 0 0; font-size: 13px; color: #64748b; font-weight: 500; text-transform: none; letter-spacing: normal; }

.v3-date-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #ffffff;
    padding: 4px 8px;
    border-radius: 10px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.v3-date-picker input[type="date"] {
    border: none;
    background: transparent;
    font-weight: 600 !important;
    color: #1e293b !important;
    outline: none;
    font-size: 13px !important;
    cursor: pointer;
}

.v3-nav-btn {
    background: #ffffff;
    border: 1px solid var(--border);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--slate-600);
    transition: all 0.2s;
}
.v3-nav-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

.v3-tab-bar {
    display: flex;
    gap: 0.5rem;
    background: var(--bg);
    padding: 0.25rem;
    border-radius: 12px;
    overflow-x: auto; /* Cho phép cuộn ngang trên mobile */
    scrollbar-width: none; /* Ẩn scrollbar Firefox */
    -ms-overflow-style: none; /* Ẩn scrollbar IE */
}
.v3-tab-bar::-webkit-scrollbar { display: none; } /* Ẩn scrollbar Chrome/Safari */

.v3-tab-item {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s all;
    font-size: 0.875rem;
    color: var(--slate-600);
    white-space: nowrap; /* Không cho rớt dòng */
}

.v3-tab-item.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.v3-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.v3-table th {
    background: var(--bg);
    color: var(--slate-600);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
}

.v3-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

/* Cho phép cuộn nội dung kết quả bên trong Modal */
#tab_kq_mb, #tab_kq_mt, #tab_kq_mn {
    flex: 1;
    overflow-y: auto;
}

.v3-table tbody tr:nth-child(even) td {
    background: var(--bg);
}

.v3-table tr:hover td {
    background: var(--primary-light);
}

.v3-input-kq {
    background: transparent;
    border: 1px solid transparent;
    text-align: center;
    font-weight: 700;
    font-family: 'JetBrains Mono', 'Roboto Mono', monospace;
    font-size: 1.1rem;
    width: 100%;
    transition: 0.2s;
}

.v3-input-kq:focus {
    border-color: var(--primary);
    background: #fff;
    border-radius: 6px;
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.v3-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    z-index: 100;
    line-height: 1;
}

/* Summary Cards Styling */
.v3-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding: 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.v3-mini-card {
    background: white;
    padding: 15px;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.v3-mini-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.v3-mini-card .icon-box {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.v3-mini-card .content-box {
    display: flex;
    flex-direction: column;
}

.v3-mini-card .label {
    font-size: 11px;
    font-weight: 800;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.v3-mini-card .value {
    font-size: 20px;
    font-weight: 900;
    color: var(--sidebar);
    line-height: 1;
}

.bg-blue-soft { background: #eff6ff; color: #3b82f6; }
.bg-green-soft { background: #f0fdf4; color: #10b981; }
.bg-rose-soft { background: #fff1f2; color: #f43f5e; }
.bg-amber-soft { background: #fffbeb; color: #f59e0b; }

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: #ef4444 !important; }

/* Hiệu ứng nháy khi load lại dữ liệu */
.flash-effect {
    animation: flash-fade 0.4s ease-out;
}

@keyframes flash-fade {
    0% { opacity: 0.4; transform: scale(0.998); }
    100% { opacity: 1; transform: scale(1); }
}

.fa-spin-once {
    animation: fa-spin 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hiệu ứng pulse cho nút load */
@keyframes btn-pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.btn-loading {
    animation: btn-pulse 1s infinite;
    pointer-events: none;
    opacity: 0.8;
}

.v3-status-badge {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    font-size: 14px;
    font-weight: 400 !important;
    text-transform: none !important;
    display: inline !important;
    color: #000;
}

.badge-win { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.badge-lose { background: #f8fafc; color: #94a3b8; border: 1px solid #e2e8f0; }
.badge-paid { background: #eef2ff; color: #4f46e5; border: 1px solid #c7d2fe; }
.badge-unpaid { background: #fff1f2; color: #e11d48; border: 1px solid #fecaca; }

/* Tối ưu lưới thống kê trong Modal Thống Kê (Bỏ box trắng) */
#tk_summary_grid {
    background: transparent;
    padding: 0;
    border: none;
    margin-bottom: 25px; /* Giữ khoảng cách với phần bên dưới */
}

/* Nâng cấp: Toolbar đa năng cho Modal Thống Kê (Desktop) */
.tk-toolbar-redesign {
    justify-content: space-between !important;
    padding: 12px 55px 12px 20px !important; /* Tăng padding phải để không chèn lên nút Đóng (X) */
    align-items: center;
}
.tk-toolbar-redesign .tk-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto; /* Đẩy nhóm nút sang phải */
}

.v3-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ==========================================================================
   V3.1 REDESIGN: BẢNG CHI TIẾT LỊCH SỬ (THANH MẢNH HƠN)
   ========================================================================== */
.vr-details-grid {
    /* This class is now only used for the header */
}

.vr-details-header {
    padding: 12px 15px;
    background: var(--primary);
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: -20px; /* Bù lại padding của container cha */
    z-index: 10;
    border: 1px solid #334155;
    display: grid;
    grid-template-columns: 1fr 90px 80px 110px 110px; /* Bỏ cột Đài */
    gap: 10px;
    align-items: center;
}

.vr-details-header > div:nth-child(1) { text-align: left; }
.vr-details-header > div:nth-child(2),
.vr-details-header > div:nth-child(3) { text-align: center; }
.vr-details-header > div:nth-child(4),
.vr-details-header > div:nth-child(5) { text-align: right; }

.vr-station-frame {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    overflow: hidden;
}

.vr-station-header-cell {
    background: #f8fafc;
    color: var(--primary);
    font-weight: 800;
    padding: 10px 15px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

/* Cấu trúc dòng chi tiết mới */
.vr-details-row {
    display: grid;
    grid-template-columns: 1fr 90px 80px 110px 110px;
    gap: 10px;
    padding: 12px 15px;
    align-items: center;
    font-size: 14px;
    border-bottom: 1px dashed var(--border);
    transition: background-color 0.2s;
}
.vr-details-row:last-child {
    border-bottom: none;
}
.vr-details-row:hover {
    background-color: #f8fafc;
}

/* Căn chỉnh các ô trong dòng */
.vr-details-row > div:nth-child(1) { /* Số đánh */
    text-align: left;
}
.vr-details-row > div:nth-child(2) { /* Kiểu */
    text-align: center;
}
.vr-details-row > div:nth-child(3) { /* Điểm */
    text-align: right; font-weight: 700; color: var(--sidebar);
}
.vr-details-row > div:nth-child(4) { /* Vốn */
    text-align: right; font-weight: 600; color: var(--warning);
}
.vr-details-row > div:nth-child(5) { /* Trúng */
    text-align: right; font-weight: 800;
}

/* ==========================================================================
   11. CSS ẨN CHO IN ẤN (TIẾT KIỆM MỰC / GIẤY)
   ========================================================================== */
@media screen { #print-section { display: none !important; } }
@media print {
    @page { margin: 0; }
    html, body { height: auto !important; overflow: visible !important; }
    body > *:not(#print-section) { display: none !important; }
    #print-section { 
        display: block !important; 
        padding: 5mm;
        margin: 0 auto;
        color: #000; 
        font-family: 'Inter', sans-serif !important;
        font-size: 13px;
        line-height: 1.4;
    }
    .print-header { text-align: center; margin-bottom: 10px; }
    .print-title { font-size: 20px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
    .print-divider { border-top: 1px solid #ccc; margin: 8px 0; }
    .print-station { font-size: 14px; font-weight: 900; text-transform: uppercase; padding: 6px 0 4px 0; margin: 12px 0 6px 0; display: block; break-after: avoid; page-break-after: avoid; }
    .print-item { display: flex; justify-content: space-between; padding: 4px 0; align-items: baseline; break-inside: avoid; page-break-inside: avoid; }
    .print-total-row { display: flex; justify-content: space-between; font-size: 14px; font-weight: 900; border-top: 1px dashed #000; padding-top: 8px; margin-top: 15px; margin-bottom: 15px; }
    .print-qr canvas, .print-qr img { width: 65px !important; height: 65px !important; }
    .print-footer { text-align: center; margin-top: 15px; padding-top: 8px; font-size: 12px; font-style: italic; }
}

/* ==========================================================
   12. ELECTRON APP SPECIFIC STYLES
   ========================================================== */
/* Ẩn nút đăng nhập Google khi chạy trong ứng dụng Electron */
.is-electron-app .google-login-section { display: none !important; }

/* Scrollbar mỏng tùy chỉnh cho các ô nội dung giới hạn chiều cao */
.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
