*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f0f2f5; color: #333; padding: 8px; margin: 0; -webkit-tap-highlight-color: transparent; }
.container { max-width: 1400px; margin: 0 auto; background: #ffffff; padding: 12px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }

.auth-screen { max-width: 100%; width: 400px; margin: 30px auto; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-top: 4px solid #3498db; }
.auth-screen h2 { text-align: center; margin-top: 0; color: #2c3e50; font-size: 22px; }

.app-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #3498db; padding-bottom: 12px; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.app-header h2 { margin: 0; color: #2c3e50; font-size: 20px; width: 100%; text-align: center; }
.user-info { font-weight: bold; color: #475569; display: flex; align-items: center; justify-content: space-between; width: 100%; background: #f8fafc; padding: 8px 12px; border-radius: 8px; font-size: 13px; }

.hidden { display: none !important; }

.main-layout { display: flex; flex-direction: column; gap: 15px; margin-top: 15px; }

input[type="number"], input[type="text"], input[type="password"], input[type="date"], select { padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; width: 100%; margin-bottom: 10px; outline: none; transition: border-color 0.2s; }
input:focus, select:focus { border-color: #3498db; }
input:disabled, select:disabled { background-color: #f1f5f9; color: #64748b; cursor: not-allowed; border-style: dashed; }
input[readonly] { background-color: #f8fafc; color: #334155; cursor: not-allowed; border-color: #cbd5e1; font-weight: 600; border-style: dotted; }

button { background-color: #3498db; color: white; padding: 12px 16px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; width: 100%; white-space: nowrap; display: inline-flex; justify-content: center; align-items: center; gap: 5px; }
button:hover { background-color: #2980b9; }
button:disabled { background-color: #cbd5e1 !important; color: #94a3b8 !important; cursor: not-allowed; }
.btn-logout { background-color: #e74c3c; padding: 8px 12px; font-size: 12px; }
.btn-action { background-color: #2ecc71; }
.btn-action:hover { background-color: #27ae60; }

.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 15px; }
.card-dash { background: #f8fafc; padding: 10px; border-radius: 8px; text-align: center; border: 1px solid #e2e8f0; }
.card-dash h4 { margin: 0; color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.card-dash .value { font-size: 15px; font-weight: bold; margin-top: 4px; word-break: break-all; }

.filter-bar { background: #e2e8f0; padding: 12px; border-radius: 10px; margin-bottom: 15px; display: flex; flex-direction: column; gap: 10px; }
.filter-bar .group { display: flex; align-items: center; gap: 8px; width: 100%; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { margin-bottom: 0; width: 100%; }
.filter-btn-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; }
.filter-btn-group button { padding: 10px 4px; font-size: 12px; }

.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; display: block; }
table { width: 100%; border-collapse: collapse; background: white; font-size: 13px; }

tr { transition: all 0.2s ease-in-out; }
@media (min-width: 992px) {
    tbody tr:not(.round-header-tr):hover { 
        background-color: #f1f5f9 !important; 
        transform: scale(1.002);
        box-shadow: 0 4px 10px rgba(0,0,0,0.04);
        cursor: pointer;
    }
}

img.emoji {
   height: 1.2em;
   width: 1.2em;
   margin: 0 .05em 0 .1em;
   vertical-align: -0.1em;
}

.pagination-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; background: #f8fafc; padding: 8px; border-radius: 8px; border: 1px solid #e2e8f0; gap: 10px; }
.pagination-bar span { font-size: 12.5px; font-weight: 600; color: #475569; }
.pagination-bar button { width: auto; padding: 8px 12px; font-size: 12px; }

/* LAYOUT THẺ (CARD) TRÊN MOBILE */
@media (max-width: 767px) {
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px; margin-bottom: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); position: relative; }
    tr:not(.round-header-tr):active { background-color: #f1f5f9; }
    tr.selected-row { border: 2px solid #3b82f6; background-color: #f0f6ff; }
    td { border: none; padding: 6px 0; text-align: left; padding-left: 45%; position: relative; font-size: 13.5px; min-height: 32px; display: flex; align-items: center; }
    td::before { position: absolute; left: 10px; width: 40%; padding-right: 10px; white-space: nowrap; font-weight: bold; color: #64748b; }
    
    #adminTableBody td:nth-of-type(1)::before { content: "📅 Giờ đá:"; }
    #adminTableBody td:nth-of-type(2)::before { content: "⚽ Trận đấu:"; }
    #adminTableBody td:nth-of-type(3)::before { content: "🎯 Tỷ số:"; }
    #adminTableBody td:nth-of-type(4)::before { content: "⚖️ Tỷ lệ chấp:"; }
    #adminTableBody td:nth-of-type(6)::before { content: "📊 Số phiếu:"; }

    #userTableBody td:nth-of-type(1)::before { content: "📅 Giờ đá:"; }
    #userTableBody td:nth-of-type(2)::before { content: "⚽ Trận đấu:"; }
    #userTableBody td:nth-of-type(3)::before { content: "🎯 Tỷ số:"; }
    #userTableBody td:nth-of-type(5)::before { content: "📊 Tình trạng:"; }
    
    #userPersonalHistory td:nth-of-type(1)::before { content: "📅 Thời gian:"; }
    #userPersonalHistory td:nth-of-type(2)::before { content: "⚽ Trận đấu:"; }
    #userPersonalHistory td:nth-of-type(3)::before { content: "🎯 Đồng hành:"; }
    #userPersonalHistory td:nth-of-type(5)::before { content: "🤝 Kết quả:"; }
    
    #leaderboardTableBody td:nth-of-type(1)::before { content: "🏅 Hạng:"; }
    #leaderboardTableBody td:nth-of-type(2)::before { content: "👤 Thành viên:"; }
    #leaderboardTableBody td:nth-of-type(3)::before { content: "⚽ Đã Vote:"; }
    #leaderboardTableBody td:nth-of-type(4)::before { content: " Số trận thua:"; }
    #leaderboardTableBody td:nth-of-type(5)::before { content: "✅ Đã  xác nhận:"; }
    #leaderboardTableBody td:nth-of-type(6)::before { content: " Chưa xác nhận:"; }

    #collectorYesterdayBody td:nth-of-type(1)::before { content: "👤 Thành viên:"; }
    #collectorYesterdayBody td:nth-of-type(2)::before { content: "📊 Số trận:"; }
    #collectorYesterdayBody td:nth-of-type(3)::before { content: " Cần xác nhận:"; }
    #collectorYesterdayBody td:nth-of-type(4)::before { content: "⚡ Hành động:"; }

    #collectorPastBody td:nth-of-type(1)::before { content: "👤 Thành viên:"; }
    #collectorPastBody td:nth-of-type(2)::before { content: "📊 Tồn đọng:"; }
    #collectorPastBody td:nth-of-type(3)::before { content: " Chưa xác nhận:"; }
    #collectorPastBody td:nth-of-type(4)::before { content: "⚡ Hành động:"; }

    td input, td select { max-width: 100%; }
    tr.round-header-tr { padding: 0; border: none; margin-bottom: 6px; margin-top: 15px; }
    td.round-header { display: block; width: 100%; padding: 8px 10px !important; border-radius: 6px; }
    td.round-header::before { content: "" !important; }
}

/* GIAO DIỆN MÁY TÍNH */
@media (min-width: 992px) { 
    body { padding: 20px; }
    .container { padding: 25px; }
    .app-header h2 { width: auto; font-size: 24px; text-align: left; }
    .user-info { width: auto; justify-content: flex-end; gap: 15px; background: transparent; padding: 0; }
    .main-layout { display: grid; grid-template-columns: 2fr 1.2fr; gap: 20px; }
    .dashboard-grid { grid-template-columns: repeat(4, 1fr); gap: 15px; }
    .card-dash { padding: 12px; }
    .card-dash .value { font-size: 18px; }
    .filter-bar { flex-direction: row; align-items: center; justify-content: space-between; padding: 15px; }
    .filter-bar .group { flex-direction: row; align-items: center; width: auto; }
    .filter-bar input, .filter-bar select { width: auto; min-width: 160px; }
    .filter-btn-group { width: auto; display: flex; gap: 8px; }
    .filter-btn-group button { width: auto; padding: 12px 16px; font-size: 14px; }
    table { width: 100%; min-width: 100%; }
    th, td { border: 1px solid #e2e8f0; padding: 12px; text-align: center; display: table-cell; }
    th { background-color: #f8fafc; color: #334155; font-weight: 600; white-space: nowrap; }
    td::before { display: none; }
    tr { display: table-row; border: none; border-radius: 0; box-shadow: none; margin-bottom: 0; }
    tr.round-header-tr { display: table-row; }
    td.round-header { text-align: left; padding: 10px 15px !important; font-size: 13px; display: table-cell; }
    button { width: auto; }
}

.round-header { background-color: #e2e8f0; color: #334155; font-weight: 700; text-transform: uppercase; border-top: 2px solid #cbd5e1; }
.badge { padding: 6px 8px; border-radius: 6px; font-size: 11px; font-weight: bold; white-space: nowrap; display: inline-block; }
.badge-waiting { background: #fee2e2; color: #ef4444; }
.badge-done { background: #dcfce7; color: #15803d; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.team-title { font-weight: 600; color: #1e293b; }
.input-table { text-align: center; padding: 6px; border: 1px solid #cbd5e1; border-radius: 6px; margin-bottom: 0; width: 100%; min-width: 70px; max-width: 140px; }
.side-panel { background: #f8fafc; border: 1px solid #e2e8f0; padding: 15px; border-radius: 10px; height: fit-content; max-width: 100%; overflow: hidden; box-sizing: border-box; }

.custom-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); display: flex; justify-content: center; align-items: center; z-index: 10000; padding: 15px; transition: opacity 0.2s; }
.modal-content { background: white; width: 100%; max-width: 550px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); display: flex; flex-direction: column; max-height: 85vh; animation: modalSlideUp 0.2s ease-out; }
.modal-header { padding: 15px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; background: #f8fafc; border-top-left-radius: 12px; border-top-right-radius: 12px; }
.modal-header h3 { margin: 0; font-size: 16px; color: #1e293b; font-weight: bold; }
.modal-close-btn { background: none; border: none; color: #94a3b8; font-size: 24px; cursor: pointer; padding: 0; width: auto; }
.modal-close-btn:hover { color: #475569; }
.modal-body { padding: 15px; overflow-y: auto; flex: 1; }
@keyframes modalSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Container bọc ngoài */
.matches-grid-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 15px;
}

/* Tiêu đề nhóm ngày (Ví dụ: Vòng Bảng - 14/06) */
/* Tiêu đề nhóm ngày - Đã làm nổi bật cực mạnh */
.date-group-header {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff; /* Chữ trắng cho nổi */
    background: linear-gradient(to right, #1e293b, #334155); /* Nền xám đen gradient ngầu như ảnh mẫu */
    padding: 12px 15px;
    margin-top: 25px;
    margin-bottom: 5px;
    border-radius: 8px;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between; /* Đẩy Vòng đấu sang trái, Ngày sang phải */
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #3b82f6; /* Vạch màu xanh lam bên cạnh tạo điểm nhấn */
}

/* Lưới chứa các trận đấu */
.matches-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Máy tính chia 2 cột */
    gap: 15px;
}

/* Giao diện từng Thẻ (Card) trận đấu */
.match-card {
    background: #ffffff; /* Màu nền thẻ */
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.2s ease;
}

.match-card:hover {
    border-color: #94a3b8;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

/* Cột trái: Tên Đội & Tỷ số */
.card-left { flex: 1; }
.team-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: bold;
    color: #1e293b;
}
.team-name { flex: 1; padding-right: 10px; }
.team-score { font-size: 16px; color: #e74c3c; }
.hdp-text { font-size: 12px; color: #64748b; font-weight: normal; margin-top: 5px; }

/* Cột phải: Giờ đá & Trạng thái */
.card-right {
    text-align: right;
    border-left: 1px solid #e2e8f0;
    padding-left: 15px;
    min-width: 110px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}
.match-time { font-size: 18px; font-weight: bold; color: #0f172a; }
.match-date-small { font-size: 12px; color: #64748b; }

/* Responsive: Màn hình điện thoại tự co về 1 cột */
@media (max-width: 768px) {
    .matches-grid { grid-template-columns: 1fr; }
}