* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 8px;
}

.subtitle {
    color: #888;
    font-size: 14px;
}

/* ============================================
   BẢNG XẾP HẠNG - TỰ ĐỘNG CHẠY CSS ANIMATION
   ============================================ */
.ranking-bar {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(90deg, #fff8e1 0%, #fffde7 100%);
    border: 1px solid #ffe082;
    border-radius: 30px;
    padding: 8px 16px;
    overflow: hidden;
    max-width: 100%;
}

.ranking-label {
    font-size: 13px;
    font-weight: 700;
    color: #5d4037;
    white-space: nowrap;
    flex-shrink: 0;
}

.ranking-marquee {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
    height: 32px;
    display: flex;
    align-items: center;

    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 20px,
        #000 calc(100% - 20px),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 20px,
        #000 calc(100% - 20px),
        transparent 100%
    );
}

.ranking-track {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    padding-left: 0;
    will-change: transform;
}

.ranking-marquee:hover .ranking-track {
    animation-play-state: paused;
}

.ranking-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #5d4037;
    background: #fff;
    border: 1px solid #ffe0b2;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ranking-item .rank { font-size: 15px; }
.ranking-item .name { color: #333; }
.ranking-item .amount { color: #e65100; font-weight: 700; }
.ranking-item .count { color: #888; font-size: 11px; font-weight: 500; }

.ranking-item.top1 {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border-color: #f9a825;
    color: #5d4037;
}

.ranking-item.top2 {
    background: linear-gradient(135deg, #e0e0e0, #fafafa);
    border-color: #bdbdbd;
}

.ranking-item.top3 {
    background: linear-gradient(135deg, #ffb74d, #ffcc80);
    border-color: #ef6c00;
}

@keyframes rankingScroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* ============================================
   STATS CARDS
   ============================================ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-label {
    font-size: 13px;
    opacity: 0.9;
}

.stat-value {
    font-size: 22px;
    font-weight: bold;
}

/* ============================================
   FILTER BAR
   ============================================ */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#searchInput {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

#searchInput:focus {
    border-color: #667eea;
}

#typeFilter {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

#refreshBtn {
    padding: 12px 24px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

#refreshBtn:hover {
    background: #5568d3;
}

/* ============================================
   TABLE
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

thead {
    background: #f8f9ff;
}

th {
    padding: 15px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    border-bottom: 2px solid #e8eaf6;
}

td {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

tbody tr:hover {
    background: #f8f9ff;
}

.amount {
    font-weight: 700;
}

.amount-in {
    color: #27ae60;
}

.amount-out {
    color: #e74c3c;
}

.empty {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ============================================
   TOAST THÔNG BÁO
   ============================================ */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #27ae60;
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
        border-radius: 12px;
    }

    h1 {
        font-size: 18px;
        line-height: 1.3;
    }

    .subtitle {
        font-size: 12px;
    }

    .ranking-bar {
        padding: 6px 10px;
        gap: 8px;
        border-radius: 20px;
    }

    .ranking-label {
        font-size: 11px;
    }

    .ranking-marquee {
        height: 26px;
    }

    .ranking-item {
        font-size: 11px;
        padding: 4px 10px;
        gap: 4px;
    }

    .ranking-item .rank { font-size: 13px; }
    .ranking-item .count { font-size: 10px; }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 18px;
    }

    .filter-bar {
        flex-direction: column;
    }

    #searchInput,
    #typeFilter,
    #refreshBtn {
        width: 100%;
    }

    th, td {
        padding: 10px 8px;
        font-size: 12px;
    }

    .toast {
        left: 10px;
        right: 10px;
        top: 10px;
        font-size: 13px;
    }
}