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

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #f5f5f5;
            color: #333;
        }

        .login-container {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .login-form {
            background: white;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            width: 100%;
            max-width: 400px;
        }

        .login-form h2 {
            text-align: center;
            margin-bottom: 2rem;
            color: #333;
        }

        .form-group {
            margin-bottom: 1rem;
        }

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 500;
        }

        .form-group input {
            width: 100%;
            padding: 0.75rem;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 1rem;
        }

        .login-btn {
            width: 100%;
            padding: 0.75rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 1rem;
            cursor: pointer;
            transition: transform 0.2s;
        }

        .login-btn:hover {
            transform: translateY(-2px);
        }

        .separator {
            text-align: center;
            margin: 1.5rem 0;
            color: #aaa;
            font-weight: bold;
        }

        .google-login-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            padding: 0.75rem;
            background: #fff;
            color: #444;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 1rem;
            cursor: pointer;
            text-decoration: none;
            transition: background-color 0.2s, box-shadow 0.2s;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        .google-login-btn:hover {
            background: #f8f8f8;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }

        .google-login-btn img {
            width: 20px;
            height: 20px;
            margin-right: 10px;
        }

        .dashboard {
            display: block;
            min-height: 100vh;
        }

        .header {
            background: white;
            padding: 1rem 2rem;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid #e9ecef;
        }

        .header h1 {
            color: #333;
            font-size: 1.5rem;
        }

        .logout-btn {
            padding: 0.5rem 1rem;
            background: #dc3545;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
        }

        .filters {
            background: white;
            margin: 1rem;
            padding: 1rem;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
            align-items: center;
        }

        .filter-group {
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
        }

        .filter-group label {
            font-size: 0.875rem;
            font-weight: 500;
            color: #555;
        }

        .filter-group input, .filter-group select {
            padding: 0.5rem;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 0.875rem;
        }

        .apply-filters-btn {
            padding: 0.5rem 1rem;
            background: #667eea;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            height: fit-content;
            margin-top: auto;
            transition: background-color 0.2s;
        }

        .apply-filters-btn:hover {
            background: #5a6fd5;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 1rem;
            margin: 1rem;
        }

        .stat-card {
            background: white;
            padding: 1.5rem;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.06);
            border: 1px solid #e9ecef;
        }

        .stat-card.clickable {
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
        }

        .stat-card.clickable:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 20px rgba(0,0,0,0.08);
        }

        .stat-card h3 {
            margin-bottom: 1rem;
            color: #333;
            font-size: 1.125rem;
        }

        .stat-number {
            font-size: 1.75rem;
            font-weight: bold;
            color: #667eea;
            margin-bottom: 0.5rem;
        }

        .stat-label {
            color: #666;
            font-size: 0.875rem;
        }

        .charts-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 1rem;
            margin: 1rem;
        }

        .chart-container {
            background: white;
            margin: 1rem;
            padding: 1.5rem;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.06);
            border: 1px solid #e9ecef;
            max-height: 400px; /* Giới hạn chiều cao */
        }

        .charts-grid .chart-container {
            margin: 0; /* Reset margin khi nằm trong grid */
        }

        .chart-container h3, .chart-container h4 {
            margin-bottom: 1rem;
            text-align: center;
            font-weight: 600;
            color: #495057;
        }

        .chart-container canvas {
            max-height: 300px !important; /* Giới hạn chiều cao canvas */
            width: 100% !important;
            height: auto !important;
        }

        .tabs {
            display: flex;
            background: white;
            margin: 1rem 1rem 0 1rem;
            border-radius: 8px 8px 0 0;
            overflow: hidden;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            border-bottom: 1px solid #dee2e6;
        }

        .tab {
            flex: 1;
            padding: 1rem;
            background: #f8f9fa;
            border: none;
            cursor: pointer;
            font-size: 1rem;
            transition: background-color 0.2s, color 0.2s;
        }

        .tab.active {
            background: #667eea;
            color: white;
            border-bottom: 2px solid #5a6fd5;
        }

        .tab-content {
            margin: 0 1rem 1rem 1rem;
            background: white;
            padding: 1.5rem;
            border-radius: 0 0 8px 8px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.06);
        }

        .tab-panel {
            display: none;
        }

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

        .data-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1rem;
        }

        .data-table th,
        .data-table td {
            padding: 0.75rem;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }

        .data-table th {
            background: #f8f9fa;
            font-weight: 600;
        }

        .data-table tr:hover {
            background: #f8f9fa;
        }

        .data-table tbody tr.clickable:hover {
            cursor: pointer;
            background: #f1f3f5;
        }

        .pagination {
            display: flex;
            justify-content: center;
            gap: 0.5rem;
            margin-top: 1rem;
        }

        .pagination button {
            padding: 0.5rem 1rem;
            border: 1px solid #ddd;
            background: white;
            cursor: pointer;
            border-radius: 4px;
        }

        .pagination button.active {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }

        .error {
            background: #f8d7da;
            color: #721c24;
            padding: 0.75rem;
            border-radius: 4px;
            margin: 1rem;
        }

        .loading {
            text-align: center;
            padding: 2rem;
            color: #666;
        }

        .export-controls {
            display: flex;
            gap: 1rem;
            align-items: center;
            margin-bottom: 1rem;
            flex-wrap: wrap;
        }
        
        .filter-controls {
            display: flex;
            gap: 0.5rem;
            align-items: center;
            flex-wrap: wrap;
        }
        
        .export-btn, .filter-btn {
            padding: 0.5rem 1rem;
            background: #28a745;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.875rem;
        }
        
        .export-btn:hover, .filter-btn:hover {
            background: #218838;
        }
        
        .api-key-cell {
            font-family: monospace;
            font-size: 0.875rem;
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .usage-badge {
            display: inline-block;
            padding: 2px 6px;
            border-radius: 12px;
            font-size: 0.75rem;
            font-weight: bold;
        }
        
        .usage-high { background: #dc3545; color: white; }
        .usage-medium { background: #ffc107; color: #333; }
        .usage-low { background: #28a745; color: white; }
        
        .duplicate-badge {
            background: #ff6b6b;
            color: white;
            padding: 2px 6px;
            border-radius: 10px;
            font-size: 0.75rem;
            margin-left: 0.5rem;
        }
        
        .details-btn {
            background: #667eea;
            color: white;
            border: none;
            padding: 4px 8px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.75rem;
            transition: background-color 0.2s;
        }

        .details-btn:hover {
            background: #5a6fd5;
        }
        
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            z-index: 1000;
            backdrop-filter: blur(5px);
        }
        
        .modal-content {
            background: #f8f9fa;
            margin: 5% auto;
            padding: 0;
            border-radius: 12px;
            width: 90%;
            max-width: 1000px; /* Tăng max-width modal */
            max-height: 90vh;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .modal-body {
            overflow-y: auto;
            padding: 1.5rem;
        }

        .modal-content .chart-container {
            max-height: 300px; /* Biểu đồ trong modal nhỏ hơn */
            margin: 1rem 0;
        }

        .modal-content .chart-container canvas {
            max-height: 200px !important; /* Canvas trong modal nhỏ hơn */
        }
        
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1rem 1.5rem;
            border-bottom: 1px solid #dee2e6;
            background: white;
        }
        
        .close-btn {
            background: #dc3545;
            color: white;
            border: none;
            padding: 0.5rem 1rem;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .close-btn:hover {
            background: #c82333;
        }

        .details-section {
            background: white;
            padding: 1.5rem;
            border-radius: 8px;
            margin-bottom: 1rem;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        .details-section h4 {
            margin-top: 0;
            margin-bottom: 1rem;
            border-bottom: 1px solid #eee;
            padding-bottom: 0.5rem;
            color: #333;
        }

        .details-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 1.5rem;
            margin-top: 1rem;
        }

        .count-list {
            list-style: none;
            padding: 0;
            max-height: 250px;
            overflow-y: auto;
        }

        .count-list-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.6rem 0.2rem;
            border-bottom: 1px solid #f1f1f1;
            font-size: 0.9rem;
        }

        .count-list-item:last-child {
            border-bottom: none;
        }

        .count-badge {
            background: #e9ecef;
            color: #495057;
            padding: 0.25rem 0.6rem;
            border-radius: 12px;
            font-size: 0.8em;
            font-weight: 600;
            min-width: 30px;
            text-align: center;
        }

        pre {
            background: #212529;
            color: #f8f9fa;
            padding: 1rem;
            border-radius: 8px;
            white-space: pre-wrap;
            word-wrap: break-word;
            font-size: 0.875rem;
        }

        /* Responsive cho mobile */
        @media (max-width: 1200px) {
            .charts-grid {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 768px) {
            .chart-container {
                margin: 0.5rem;
                padding: 1rem;
                max-height: 300px;
            }
            
            .chart-container canvas {
                max-height: 200px !important;
            }
            
            .modal-content {
                width: 95%;
                margin: 2% auto;
                padding: 1rem;
            }
            
            .modal-content .chart-container canvas {
                max-height: 150px !important;
            }
        }