* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4472C4;
    --primary-dark: #2E4A7F;
    --secondary-color: #6C757D;
    --success-color: #28A745;
    --danger-color: #DC3545;
    --warning-color: #FFC107;
    --info-color: #17A2B8;
    --light-bg: #F8F9FA;
    --dark-text: #212529;
    --border-color: #DEE2E6;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
}

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;
    color: var(--dark-text);
}

/* Navbar */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    padding: 1rem 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.card h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.page-header {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.page-header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Auth */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    background: white;
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--secondary-color);
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--secondary-color);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--dark-text);
}

.form-group input {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #5A6268;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Upload */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--light-bg);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #F0F4FF;
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--primary-color);
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    gap: 1rem;
    flex-wrap: wrap;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.file-name {
    font-weight: 500;
}

.file-supplier {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.file-supplier-input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    width: 200px;
    min-width: 150px;
    flex: 1;
    max-width: 100%;
}

.file-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.file-remove:hover {
    background: #C82333;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1rem 0;
}

/* Legend */
.legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Message */
.message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.message.success {
    background: #D4EDDA;
    color: #155724;
    border: 1px solid #C3E6CB;
}

.message.error {
    background: #F8D7DA;
    color: #721C24;
    border: 1px solid #F5C6CB;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.progress-container {
    width: min(520px, calc(100vw - 2rem));
    margin-top: 1rem;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4472C4 0%, #6ea8ff 100%);
    transition: width 0.25s ease;
}

.progress-meta {
    margin-top: 0.5rem;
    font-size: 0.95rem;
    opacity: 0.95;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results */
.results-info {
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.results-info p {
    margin: 0.5rem 0;
}

.process-details {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.process-detail-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--light-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
    align-items: flex-start;
}

.process-detail-text {
    flex: 1;
    min-width: 200px;
}

.process-detail-text p {
    margin: 0.2rem 0;
    word-break: break-word;
}

.process-detail-message {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.status-badge {
    align-self: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-processed {
    background: #D4EDDA;
    color: #155724;
}

.status-empty {
    background: #FFF3CD;
    color: #856404;
}

.status-error {
    background: #F8D7DA;
    color: #721C24;
}

.status-uploaded,
.status-pending {
    background: #D1ECF1;
    color: #0C5460;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    .nav-container {
        padding: 0 1rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn {
        width: 100%;
        margin: 0;
    }
    
    .file-item {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .file-info {
        width: 100%;
    }
    
    .file-supplier-input {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .file-remove {
        width: 100%;
        padding: 0.75rem;
    }
    
    .nav-user {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .legend {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .user-item {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .user-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .user-actions .btn {
        width: 100%;
    }
    
    .api-key-input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-toggle-visibility {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .settings-action-buttons {
        flex-direction: column;
    }
    
    .settings-action-buttons .btn {
        width: 100%;
        min-width: auto;
    }
    
    .form-group textarea {
        min-height: 300px;
    }
}

/* Settings Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--light-bg);
    color: var(--dark-text);
}

.modal-body {
    padding: 1.5rem;
}

.settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.settings-tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--secondary-color);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}

.settings-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.form-hint code {
    background: var(--light-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.form-group textarea {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    width: 100%;
    resize: vertical;
    transition: border-color 0.3s;
    line-height: 1.6;
    min-height: 400px;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(68, 114, 196, 0.1);
}

/* API Key Input Wrapper */
.api-key-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.api-key-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s;
}

.api-key-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(68, 114, 196, 0.1);
}

.btn-toggle-visibility {
    padding: 0.75rem;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-toggle-visibility svg {
    width: 18px;
    height: 18px;
}

.btn-toggle-visibility:hover {
    transform: scale(1.05);
}

/* Settings Action Buttons */
.settings-action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.settings-action-buttons .btn {
    min-width: 150px;
}

/* Prompt Info */
.prompt-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 8px;
    border-left: 4px solid var(--info-color);
}

.prompt-info .form-hint {
    margin: 0;
    color: var(--dark-text);
}

.users-list {
    margin-top: 1.5rem;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    gap: 1rem;
    flex-wrap: wrap;
}

.user-info {
    flex: 1;
}

.user-info strong {
    color: var(--primary-color);
}

.user-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.btn-icon {
    padding: 0.5rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    min-width: 40px;
}

.btn-icon:hover {
    background: #5A6268;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #C82333;
}

.admin-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}


