* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    flex: 1;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.sync-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress {
    margin-top: 2rem;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 30%;
    background: var(--primary-color);
    border-radius: 4px;
    animation: progress-slide 1.5s ease-in-out infinite;
}

@keyframes progress-slide {
    0% {
        left: -30%;
    }
    100% {
        left: 100%;
    }
}

.progress-text {
    margin-top: 1rem;
    color: var(--text-secondary);
}

.result {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.result h3 {
    color: var(--success-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-icon {
    width: 24px;
    height: 24px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
}

.csv-download {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fffbeb;
    border: 1px solid #fed7aa;
    border-radius: 8px;
}

.csv-download h4 {
    color: #b45309;
    margin-bottom: 0.5rem;
}

.csv-download p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: #f59e0b;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #d97706;
}

.error {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.error h3 {
    color: var(--error-color);
    margin-bottom: 0.5rem;
}

.error-message {
    color: var(--text-color);
    font-family: monospace;
    background: white;
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
    overflow-x: auto;
}

.info-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.info-section h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.info-section ul {
    list-style-position: inside;
    color: var(--text-secondary);
}

.info-section li {
    margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.5rem;
    }

    .result-stats {
        grid-template-columns: 1fr;
    }
}

/* Login page styles */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.login-card .form-group {
    margin-bottom: 1.25rem;
}

.login-card .btn-primary {
    margin-top: 1rem;
}

.login-card .error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: var(--error-color);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    text-align: center;
}

/* Header with user info and logout */
.header-top {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.header-top .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    margin: 0 auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.user-name {
    font-weight: 600;
    color: var(--text-color);
}

.btn-logout {
    padding: 0.5rem 1.25rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #fef2f2;
    color: var(--error-color);
    border-color: #fecaca;
}

@media (max-width: 640px) {
    .login-card {
        padding: 2rem;
    }

    .header-top .container {
        padding: 0 1rem;
    }

    .user-label {
        display: none;
    }
}
