:root {
    --primary: #1a1a1a;
    --secondary: #FFD700;
    --accent: #FF6B6B;
    --success: #4ECDC4;
    --warning: #FFE66D;
    --danger: #FF6B6B;
    --info: #4A90E2;
    --bg: #F5F5F5;
    --bg-secondary: #E8E8E8;
    --text: #1a1a1a;
    --text-light: #666;
    --border: #1a1a1a;
    --shadow: 6px 6px 0px #1a1a1a;
    --shadow-hover: 8px 8px 0px #1a1a1a;
    --shadow-small: 3px 3px 0px #1a1a1a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.loading-icon {
    font-size: 4rem;
    color: var(--secondary);
    animation: bounce 1s infinite;
}

.loading-bar {
    width: 200px;
    height: 8px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    margin: 20px auto;
    position: relative;
}

.loading-progress {
    height: 100%;
    background: var(--secondary);
    animation: loading 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 100%; }
    100% { width: 0%; }
}

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 20px;
    border-bottom: 4px solid var(--secondary);
    position: sticky;
    top: 0;
    z-index: 100;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: bold;
}

.logo i {
    color: var(--secondary);
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.nav-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: 3px solid var(--border);
    background: white;
    color: var(--text);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-small);
    text-transform: uppercase;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px var(--border);
}

.btn-primary {
    background: var(--secondary);
}

.btn-success {
    background: var(--success);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-icon {
    padding: 10px;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
    animation: fadeIn 0.5s ease;
}

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

/* Cards */
.card {
    background: white;
    border: 3px solid var(--border);
    box-shadow: var(--shadow-small);
    margin-bottom: 20px;
    transition: all 0.3s ease;
    animation: slideUp 0.5s ease;
}

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

.card:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-bottom: 3px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

/* Grid */
.grid {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border: 3px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow-small);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--secondary);
}

.stat-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--secondary);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-light);
    text-transform: uppercase;
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 3px solid var(--border);
    background: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    box-shadow: var(--shadow-small);
    transform: translate(-2px, -2px);
}

select.form-control {
    cursor: pointer;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border: 3px solid var(--border);
    background: white;
    box-shadow: var(--shadow-small);
}

.category-header:hover {
    background: var(--bg-secondary);
    opacity: 0.9;
}

.category-header td {
    user-select: none;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--primary);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9rem;
    border-bottom: 3px solid var(--secondary);
}

.table td {
    padding: 12px 15px;
    border-bottom: 2px solid var(--bg-secondary);
}

.table tbody tr {
    transition: all 0.3s ease;
}

.table tbody tr:hover {
    background: var(--bg-secondary);
    transform: translateX(5px);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    border: 2px solid var(--border);
    background: white;
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-warning {
    background: var(--warning);
}

.badge-danger {
    background: var(--danger);
    color: white;
}

.badge-info {
    background: var(--info);
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border: 4px solid var(--border);
    box-shadow: var(--shadow);
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: zoomIn 0.3s ease;
    position: relative;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    background: var(--primary);
    color: white;
    border-bottom: 4px solid var(--secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.modal-close:hover {
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    background: var(--bg-secondary);
    border-top: 3px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Tabs */
.tabs {
    border: 3px solid var(--border);
    background: white;
    margin-bottom: 20px;
}

.tab-list {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 3px solid var(--border);
    overflow-x: auto;
}

.tab-button {
    padding: 15px 20px;
    background: none;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.tab-button:hover {
    background: white;
}

.tab-button.active {
    background: var(--secondary);
    color: var(--primary);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.tab-content {
    padding: 20px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.5s ease;
}

.tab-pane.active {
    display: block;
}

/* Image Tooltip */
.image-tooltip {
    position: relative;
    display: inline-block;
}

.image-preview {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 3px solid var(--border);
    box-shadow: var(--shadow);
    padding: 5px;
    z-index: 1000;
    display: none;
    animation: fadeIn 0.3s ease;
}

.image-tooltip:hover .image-preview {
    display: block;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    display: block;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-icon {
    font-size: 4rem;
    color: var(--bg-secondary);
    margin-bottom: 20px;
}

.empty-title {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text);
}

.empty-description {
    margin-bottom: 20px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
}

.action-buttons .btn {
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    margin: 20px 0;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .nav-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        max-width: 95%;
        margin: 10px;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .table th, .table td {
        padding: 8px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Print Styles */
@media print {
    .header, .nav-buttons, .btn, .modal {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    .table {
        border: 1px solid #000;
    }
    
    .table th, .table td {
        border: 1px solid #000;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border: 2px solid var(--border);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 0;
    background: var(--secondary);
    border: 3px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: var(--shadow-hover);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    background: white;
    border: 3px solid var(--border);
    box-shadow: var(--shadow-small);
    padding: 15px 20px;
    margin-bottom: 10px;
    min-width: 250px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 5px solid var(--success);
}

.toast.error {
    border-left: 5px solid var(--danger);
}

.toast.info {
    border-left: 5px solid var(--info);
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-message {
    flex: 1;
}

.toast-close {
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-light);
}
/* ============================================
   BỔ SUNG CSS CHO TÍNH NĂNG MỚI
   - Lịch sử thanh toán nhân công
   - Bảng thống kê ngân sách
   - Giữ nguyên style Soft Brutalism
   ============================================ */

/* === NÚT LỊCH SỬ THANH TOÁN (màu xanh lá) === */
.btn-success-alt {
    background: var(--success);
    color: white;
}

.btn-success-alt:hover {
    background: #3dbdb5;
}

/* === PAYMENT INFO CARD (Header modal lịch sử thanh toán) === */
.payment-info-card {
    background: var(--primary);
    color: white;
    padding: 20px;
    border: 3px solid var(--border);
    margin-bottom: 20px;
    position: relative;
}

.payment-info-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--secondary);
}

.payment-info-card h4 {
    margin: 0 0 15px 0;
    font-size: 1.2rem;
}

.payment-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.payment-summary-item {
    text-align: center;
}

.payment-summary-item .label {
    font-size: 0.8rem;
    opacity: 0.9;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.payment-summary-item .value {
    font-size: 1.1rem;
    font-weight: bold;
}

/* === FORM THÊM THANH TOÁN === */
.add-payment-section {
    background: var(--bg-secondary);
    padding: 20px;
    border: 3px dashed var(--border);
    margin-bottom: 20px;
}

.add-payment-section h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.add-payment-section h4 i {
    color: var(--success);
}

.quick-fill-btn {
    background: none;
    border: none;
    color: var(--info);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 5px 0;
    text-decoration: underline;
    margin-top: 5px;
    display: block;
}

.quick-fill-btn:hover {
    color: var(--primary);
}

/* === ĐÃ THANH TOÁN ĐẦY ĐỦ === */
.payment-completed-box {
    background: var(--success);
    color: white;
    padding: 15px 20px;
    border: 3px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    font-weight: bold;
}

.payment-completed-box i {
    font-size: 1.5rem;
}

/* === BẢNG LỊCH SỬ THANH TOÁN === */
.payment-history-section h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.payment-history-table {
    width: 100%;
    border-collapse: collapse;
    border: 3px solid var(--border);
    font-size: 0.9rem;
}

.payment-history-table th {
    background: var(--primary);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8rem;
    border-bottom: 3px solid var(--secondary);
}

.payment-history-table td {
    padding: 10px 12px;
    border-bottom: 2px solid var(--bg-secondary);
}

.payment-history-table tbody tr:hover {
    background: var(--bg-secondary);
}

.payment-amount {
    color: var(--success);
    font-weight: bold;
}

/* === NÚT XEM THỐNG KÊ NGÂN SÁCH === */
.budget-summary-btn {
    width: 100%;
    padding: 15px 20px;
    background: var(--info);
    color: white;
    border: 3px solid var(--border);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-small);
    text-transform: uppercase;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.budget-summary-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow);
}

.budget-summary-btn .warning-badge {
    background: var(--danger);
    padding: 3px 10px;
    font-size: 0.75rem;
}

/* === GRID THỐNG KÊ NGÂN SÁCH === */
.budget-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.budget-stat-card {
    background: white;
    border: 3px solid var(--border);
    padding: 15px;
    box-shadow: var(--shadow-small);
    transition: all 0.3s ease;
}

.budget-stat-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow);
}

.budget-stat-card.danger {
    background: #FEF2F2;
    border-color: var(--danger);
}

.budget-stat-card.warning {
    background: #FFFBEB;
    border-color: var(--warning);
}

.budget-stat-card .icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--secondary);
}

.budget-stat-card.danger .icon {
    color: var(--danger);
}

.budget-stat-card.warning .icon {
    color: var(--warning);
}

.budget-stat-card .label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.budget-stat-card .value {
    font-size: 1rem;
    font-weight: bold;
}

.budget-stat-card .value.success {
    color: var(--success);
}

.budget-stat-card .value.danger {
    color: var(--danger);
}

.budget-stat-card .value.warning {
    color: #F59E0B;
}

/* === THANH TIẾN ĐỘ NGÂN SÁCH === */
.budget-progress-section {
    margin-bottom: 25px;
}

.budget-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.budget-progress-bar {
    height: 15px;
    background: var(--bg-secondary);
    border: 3px solid var(--border);
    position: relative;
}

.budget-progress-fill {
    height: 100%;
    background: var(--success);
    transition: width 0.5s ease;
}

.budget-progress-fill.warning {
    background: var(--warning);
}

.budget-progress-fill.danger {
    background: var(--danger);
}

/* === BẢNG CHI TIẾT NGÂN SÁCH === */
.budget-breakdown-section h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.budget-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    border: 3px solid var(--border);
}

.budget-breakdown-table th {
    background: var(--primary);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8rem;
    border-bottom: 3px solid var(--secondary);
}

.budget-breakdown-table td {
    padding: 12px;
    border-bottom: 2px solid var(--bg-secondary);
}

.budget-breakdown-table td i {
    margin-right: 8px;
    color: var(--secondary);
}

.budget-breakdown-table tfoot td {
    background: var(--secondary);
    font-weight: bold;
    border-bottom: none;
}

.text-success {
    color: var(--success) !important;
}

.text-warning {
    color: #F59E0B !important;
}

.text-danger {
    color: var(--danger) !important;
}

/* === STAT CARD MỚI (Ngân sách & Còn lại) === */
.stat-card.budget-card {
    position: relative;
}

.stat-card.budget-card::before {
    background: var(--info);
}

.stat-card.remaining-card.over-budget {
    background: #FEF2F2;
}

.stat-card.remaining-card.over-budget::before {
    background: var(--danger);
}

.stat-card.remaining-card .stat-icon.danger {
    color: var(--danger);
}

/* === CỘT CÒN NỢ TRONG BẢNG NHÂN CÔNG === */
.debt-amount {
    font-weight: bold;
}

.debt-amount.has-debt {
    color: #F59E0B;
}

.debt-amount.no-debt {
    color: var(--success);
}

/* === EMPTY STATE NHỎ === */
.empty-state-small {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-light);
    background: var(--bg-secondary);
    border: 2px dashed var(--border);
}

.empty-state-small i {
    font-size: 2rem;
    color: var(--bg-secondary);
    margin-bottom: 10px;
}

.empty-state-small p {
    margin: 0;
    font-size: 0.9rem;
}

/* === RESPONSIVE CHO TÍNH NĂNG MỚI === */
@media (max-width: 768px) {
    .payment-summary-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .budget-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .budget-stat-card .value {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .budget-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .payment-history-table {
        font-size: 0.8rem;
    }
    
    .payment-history-table th,
    .payment-history-table td {
        padding: 8px;
    }
}
/* Fix stat cards hiển thị đủ số */
@media (min-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 1399px) and (min-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .stat-value {
        font-size: 1.2rem;
    }
}

@media (max-width: 1199px) and (min-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .stat-value {
        font-size: 1.4rem;
    }
}

@media (max-width: 991px) and (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
/* ============================================
   CSS CHO TAB THỐNG KÊ CHI TIẾT
   ============================================ */

.statistics-container {
    padding: 10px 0;
}

/* Section */
.stat-section {
    background: white;
    border: 3px solid var(--border);
    margin-bottom: 25px;
    box-shadow: var(--shadow-small);
}

.stat-section-title {
    background: var(--primary);
    color: white;
    padding: 15px 20px;
    margin: 0;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 4px solid var(--secondary);
}

.stat-section-title i {
    color: var(--secondary);
}

/* Overview Grid */
.stat-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 20px;
}

.stat-overview-card {
    background: var(--bg-secondary);
    border: 3px solid var(--border);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
}

.stat-overview-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-small);
}

.stat-overview-card.budget {
    border-left: 5px solid var(--info);
}

.stat-overview-card.spent {
    border-left: 5px solid var(--secondary);
}

.stat-overview-card.paid {
    border-left: 5px solid var(--success);
}

.stat-overview-card.debt {
    border-left: 5px solid var(--warning);
}

.stat-overview-card.remain {
    border-left: 5px solid var(--success);
}

.stat-overview-card.over {
    border-left: 5px solid var(--danger);
    background: #FEF2F2;
}

.stat-overview-icon {
    font-size: 2rem;
    color: var(--secondary);
    width: 50px;
    text-align: center;
}

.stat-overview-card.paid .stat-overview-icon { color: var(--success); }
.stat-overview-card.debt .stat-overview-icon { color: var(--warning); }
.stat-overview-card.over .stat-overview-icon { color: var(--danger); }

.stat-overview-content {
    flex: 1;
}

.stat-overview-label {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-overview-value {
    font-size: 1.3rem;
    font-weight: bold;
}

.stat-overview-value.success { color: var(--success); }
.stat-overview-value.warning { color: #F59E0B; }
.stat-overview-value.danger { color: var(--danger); }

.stat-overview-sub {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 3px;
}

/* Progress Bar */
.budget-progress-wrapper {
    padding: 0 20px 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9rem;
}

.progress-bar-container {
    height: 20px;
    background: var(--bg-secondary);
    border: 3px solid var(--border);
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.progress-bar-fill.success { background: var(--success); }
.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* Mini Progress */
.mini-progress {
    width: 60px;
    height: 8px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

.mini-progress-fill {
    height: 100%;
    background: var(--success);
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
}

.status-card {
    background: var(--bg-secondary);
    border: 3px solid var(--border);
    padding: 20px;
}

.status-card h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-card h4 i {
    color: var(--secondary);
}

.status-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border: 2px solid var(--border);
}

.status-count {
    font-weight: bold;
    font-size: 1.1rem;
}

/* Project Info Grid */
.project-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    padding: 20px;
}

.project-info-item {
    background: var(--bg-secondary);
    padding: 15px;
    border: 2px solid var(--border);
}

.project-info-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.project-info-item value {
    display: block;
    font-weight: bold;
    font-size: 1rem;
}

/* Detail Table */
.stat-detail-table tfoot tr {
    background: var(--secondary);
}

.text-center {
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .stat-overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-overview-value {
        font-size: 1rem;
    }
    
    .status-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stat-overview-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-overview-card {
        padding: 15px;
    }
}
/* ============================================
   TỐI ƯU MOBILE + FAB BUTTON - PHIÊN BẢN SỬA
   ============================================ */

/* === FAB - FLOATING ACTION BUTTON === */
#fab-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 1000;
}

.fab-main {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--secondary);
    border: 3px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    z-index: 1002;
}

.fab-main:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-hover);
}

.fab-main.open {
    transform: rotate(45deg);
    background: var(--danger);
    color: white;
}

.fab-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
}

.fab-menu.open {
    opacity: 1;
    visibility: visible;
}

.fab-item {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    cursor: pointer;
    transform: translateX(20px);
    opacity: 0;
    transition: all 0.3s ease;
}

.fab-menu.open .fab-item {
    transform: translateX(0);
    opacity: 1;
}

.fab-menu.open .fab-item:nth-child(1) { transition-delay: 0.05s; }
.fab-menu.open .fab-item:nth-child(2) { transition-delay: 0.1s; }
.fab-menu.open .fab-item:nth-child(3) { transition-delay: 0.15s; }
.fab-menu.open .fab-item:nth-child(4) { transition-delay: 0.2s; }

.fab-label {
    background: var(--primary);
    color: white;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: bold;
    white-space: nowrap;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-small);
}

.fab-icon-small {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--primary);
    box-shadow: var(--shadow-small);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.fab-item:hover .fab-icon-small {
    background: var(--secondary);
    transform: scale(1.1);
}

.fab-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

.fab-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* === FIX TABS RESPONSIVE === */
.tabs {
    border: 3px solid var(--border);
    background: white;
    margin-bottom: 20px;
    overflow: hidden;
}

.tab-list {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 3px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: nowrap;
}

.tab-list::-webkit-scrollbar {
    display: none;
    height: 0;
    width: 0;
}

.tab-button {
    padding: 15px 20px;
    background: none;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    text-transform: uppercase;
    font-size: 0.9rem;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-button:hover {
    background: white;
}

.tab-button.active {
    background: var(--secondary);
    color: var(--primary);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

/* === MOBILE RESPONSIVE === */

/* Extra Large Desktop */
@media (min-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    #fab-container {
        display: none;
    }
}

/* Large Desktop */
@media (min-width: 1200px) and (max-width: 1399px) {
    .stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    #fab-container {
        display: none;
    }
}

/* Desktop */
@media (min-width: 992px) and (max-width: 1199px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    #fab-container {
        display: block;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 991px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 15px 12px;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .tab-button {
        padding: 12px 15px;
        font-size: 0.8rem;
    }
}

/* Mobile Large (480-767px) */
@media (min-width: 480px) and (max-width: 767px) {
    /* Header */
    .header {
        padding: 12px 15px;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .logo span {
        display: none;
    }
    
    .nav-buttons .btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    /* Container */
    .container {
        padding: 0 10px;
        margin: 10px auto;
    }
    
    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px 10px;
    }
    
    .stat-icon {
        font-size: 1.5rem;
        margin-bottom: 6px;
    }
    
    .stat-value {
        font-size: 0.95rem;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    /* Tabs */
    .tab-button {
        padding: 10px 12px;
        font-size: 0.7rem;
        gap: 5px;
    }
    
    .tab-button i {
        font-size: 0.9rem;
    }
    
    .tab-content {
        padding: 12px;
    }
    
    /* Table */
    .table {
        font-size: 0.8rem;
    }
    
    .table th, .table td {
        padding: 8px 6px;
    }
    
    /* Modal */
    .modal-content {
        max-width: 95%;
        margin: 10px;
    }
    
    /* Form */
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-control {
        font-size: 16px;
    }
    
    /* FAB */
    #fab-container {
        bottom: 20px;
        right: 15px;
    }
    
    .fab-main {
        width: 55px;
        height: 55px;
    }
}

/* Mobile Small (< 480px) */
@media (max-width: 479px) {
    /* Header */
    .header {
        padding: 10px 12px;
    }
    
    .header-content {
        gap: 10px;
    }
    
    .logo {
        font-size: 0.9rem;
    }
    
    .logo span {
        display: none;
    }
    
    .logo i {
        font-size: 1.3rem;
    }
    
    .nav-buttons {
        gap: 6px;
    }
    
    .nav-buttons .btn {
        padding: 6px 10px;
        font-size: 0.7rem;
    }
    
    /* Container */
    .container {
        padding: 0 8px;
        margin: 8px auto;
    }
    
    /* Stats - 2 cột nhỏ gọn */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .stat-card {
        padding: 10px 8px;
    }
    
    .stat-card::before {
        height: 3px;
    }
    
    .stat-icon {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }
    
    .stat-value {
        font-size: 0.85rem;
        line-height: 1.2;
        word-break: break-word;
    }
    
    .stat-label {
        font-size: 0.6rem;
        line-height: 1.2;
    }
    
    /* Tabs - scroll horizontal */
    .tabs {
        margin-bottom: 12px;
    }
    
    .tab-list {
        padding: 0;
    }
    
    .tab-button {
        padding: 10px 10px;
        font-size: 0.65rem;
        gap: 4px;
        flex-direction: column;
        min-width: 60px;
    }
    
    .tab-button i {
        font-size: 1rem;
    }
    
    .tab-content {
        padding: 10px;
    }
    
    /* Table */
    .table-container {
        margin: 0 -8px;
        border-left: none;
        border-right: none;
    }
    
    .table {
        font-size: 0.7rem;
    }
    
    .table th {
        padding: 8px 5px;
        font-size: 0.65rem;
    }
    
    .table td {
        padding: 8px 5px;
    }
    
    /* Ẩn bớt cột trên mobile nhỏ */
    .table th:nth-child(n+5):not(:last-child),
    .table td:nth-child(n+5):not(:last-child) {
        display: none;
    }
    
    /* Action buttons */
    .action-buttons {
        gap: 4px;
    }
    
    .btn-icon {
        width: 30px;
        height: 30px;
        padding: 4px;
        font-size: 0.75rem;
    }
    
    /* Cards */
    .card {
        margin-bottom: 10px;
    }
    
    .card-header {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .card-title {
        font-size: 0.95rem;
    }
    
    .card-body {
        padding: 12px;
    }
    
    /* Buttons */
    .btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    /* Modal - full screen từ dưới lên */
    .modal.show {
        align-items: flex-end;
    }
    
    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 90vh;
        margin: 0;
        border: none;
        border-top: 4px solid var(--secondary);
        border-radius: 15px 15px 0 0;
    }
    
    .modal-header {
        padding: 12px 15px;
        border-radius: 15px 15px 0 0;
    }
    
    .modal-title {
        font-size: 1rem;
    }
    
    .modal-body {
        padding: 15px;
        max-height: calc(90vh - 120px);
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 80px;
    }
    
    /* Form */
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
    
    .form-label {
        font-size: 0.75rem;
        margin-bottom: 5px;
    }
    
    .form-control {
        padding: 10px 12px;
        font-size: 16px; /* Prevent zoom iOS */
    }
    
    /* FAB */
    #fab-container {
        bottom: 15px;
        right: 12px;
    }
    
    .fab-main {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .fab-menu {
        bottom: 60px;
        gap: 10px;
    }
    
    .fab-icon-small {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }
    
    .fab-label {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    /* Empty state */
    .empty-state {
        padding: 30px 15px;
    }
    
    .empty-icon {
        font-size: 2.5rem;
    }
    
    .empty-title {
        font-size: 1.1rem;
    }
    
    .empty-description {
        font-size: 0.85rem;
    }
    
    /* Toast */
    .toast-container {
        top: auto;
        bottom: 80px;
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
        padding: 12px 15px;
        font-size: 0.85rem;
    }
    
    /* Statistics Tab */
    .stat-overview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px;
    }
    
    .stat-overview-card {
        padding: 10px;
        flex-direction: column;
        text-align: center;
        gap: 6px;
    }
    
    .stat-overview-icon {
        font-size: 1.3rem;
    }
    
    .stat-overview-value {
        font-size: 0.9rem;
    }
    
    .stat-overview-label {
        font-size: 0.65rem;
    }
    
    .stat-overview-sub {
        font-size: 0.6rem;
    }
    
    .stat-section-title {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
    
    .budget-progress-wrapper {
        padding: 0 12px 12px;
    }
    
    .progress-header {
        font-size: 0.75rem;
    }
    
    .progress-bar-container {
        height: 15px;
    }
    
    .status-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }
    
    .project-info-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px;
    }
    
    /* Category header */
    .category-header td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    /* Chart */
    .chart-container {
        height: 200px;
    }
    
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Extra Small (< 360px) */
@media (max-width: 359px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .stat-card {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 10px 12px;
    }
    
    .stat-icon {
        margin-bottom: 0;
        font-size: 1.5rem;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .tab-button {
        min-width: 50px;
        padding: 8px 8px;
        font-size: 0.6rem;
    }
    
    .fab-label {
        display: none;
    }
    
    .stat-overview-grid {
        grid-template-columns: 1fr;
    }
}

/* iOS Safe Area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #fab-container {
        bottom: calc(15px + env(safe-area-inset-bottom));
    }
    
    .modal-footer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    
    .toast-container {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
}

/* Touch friendly */
@media (hover: none) and (pointer: coarse) {
    .btn, .tab-button, .fab-main, .fab-item {
        min-height: 44px;
    }
    
    .table tbody tr:hover {
        transform: none;
    }
    
    .stat-card:hover,
    .card:hover {
        transform: none;
        box-shadow: var(--shadow-small);
    }
}

/* Prevent iOS zoom */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select,
    textarea,
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="email"],
    input[type="tel"] {
        font-size: 16px !important;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-body {
        max-height: calc(100vh - 100px);
    }
}

/* Print */
@media print {
    #fab-container {
        display: none !important;
    }
    
    .tab-list {
        display: none !important;
    }
}
