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

/* Performance: Use system fonts as fallback */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

/* Accessibility: Focus states */
*:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: clamp(0.875rem, 2vw, 1rem);
    opacity: 0.95;
    line-height: 1.5;
}

/* TABS */
.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 3px solid #667eea;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
    white-space: nowrap;
    min-width: 120px;
}

.tab-btn:hover {
    background: #e9ecef;
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

/* Tab content animation */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

/* MAIN CONTENT */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 40px;
}

.main-content.full-width {
    grid-template-columns: 1fr;
}

.form-container, .result-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.form-container h2, .result-container h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: clamp(1.25rem, 3vw, 1.5rem);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.9em;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

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

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 10px;
    margin-top: 10px;
}

.btn-sm {
    padding: 8px 20px;
    font-size: 0.9em;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white;
    width: 100%;
    margin-top: 15px;
}

.btn-success:hover {
    background: #218838;
}

.result-box {
    background: white;
    padding: 20px;
    border-radius: 10px;
    min-height: 200px;
    border: 2px dashed #ddd;
}

.result-box-inline {
    background: white;
    padding: 15px;
    border-radius: 8px;
    min-height: 80px;
    border: 2px dashed #ddd;
    margin: 10px 0;
}

.placeholder {
    text-align: center;
    color: #999;
    padding: 60px 20px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.number-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.number-item:hover {
    transform: scale(1.05);
}

.stats {
    margin-top: 20px;
    padding: 15px;
    background: #e9ecef;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

.stats span {
    color: #667eea;
    font-size: 1.2em;
}

/* SPECIAL SECTIONS */
.special-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
}

.special-container h2 {
    color: #667eea;
    margin-bottom: 25px;
    text-align: center;
}

.special-section {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.special-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.form-row .form-control {
    flex: 1;
    min-width: 150px;
}

.form-row .btn {
    margin: 0;
}

/* DÀN TÁCH */
.dan-group {
    background: #f8f9fa;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.dan-group h4 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.dan-group .result-grid {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.dan-group .number-item {
    padding: 10px;
    font-size: 1em;
}

/* XIÊN RESULT */
.xien-item {
    background: #f8f9fa;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    font-weight: 600;
    color: #333;
}

.xien-item:hover {
    background: #e9ecef;
}

/* SEO CONTENT SECTION */
.seo-content {
    padding: 40px;
    background: white;
    line-height: 1.8;
}

.seo-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.seo-content h3 {
    color: #667eea;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
}

.seo-content p {
    margin-bottom: 15px;
    color: #333;
}

.seo-content ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.seo-content li {
    margin-bottom: 10px;
    color: #333;
}

/* FEATURES */
.features {
    padding: 40px;
    background: #f8f9fa;
}

.features h2 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
    font-size: clamp(1.5rem, 3vw, 2rem);
}

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

.feature-item {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.feature-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.feature-item h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.feature-item p {
    color: #666;
    line-height: 1.6;
}

footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 30px 20px;
}

footer p {
    margin-bottom: 10px;
}

footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}

footer a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    
    .tab-btn {
        flex: 0 0 auto;
    }
    
    .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row .btn {
        width: 100%;
    }
    
    .seo-content {
        padding: 20px;
    }
    
    .features {
        padding: 20px;
    }
}

/* PRINT STYLES */
@media print {
    .tabs, .btn, footer {
        display: none;
    }
    
    .result-box {
        border: 1px solid #000;
    }
}

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

.btn-primary:active {
    animation: pulse 0.3s;
}

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* LOADING STATE */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* SKIP TO CONTENT (Accessibility) */
.skip-to-content {
    position: absolute;
    left: -9999px;
    z-index: 999;
}

.skip-to-content:focus {
    left: 50%;
    transform: translateX(-50%);
    top: 10px;
    background: #667eea;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
}
