/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    line-height: 1.6;
    color: #3b496e;
    background-color: #f8f9fc;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Screen Management */
.screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Login/Auth Screens */
.login-container {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(59, 73, 110, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.icon {
    width: 48px;
    height: 48px;
    background: #3b496e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 24px;
    color: white;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #3b496e;
}

.login-header p {
    color: #6b7280;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: #3b496e;
}

input[type="text"], 
input[type="password"], 
textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #80b4e1;
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: border-color 0.15s ease-in-out;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #3b496e;
    box-shadow: 0 0 0 3px rgba(59, 73, 110, 0.1);
}

textarea {
    resize: vertical;
    font-family: inherit;
}

.input-sm {
    flex: 1;
    margin-right: 0.5rem;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    gap: 0.5rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: #3b496e;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2d3851;
}

.btn-success {
    background: #80b4e1;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #6ba3d6;
}

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

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

.btn-gradient {
    background: linear-gradient(to right, #80b4e1, #3b496e);
    color: white;
}

.btn-gradient:hover:not(:disabled) {
    background: linear-gradient(to right, #6ba3d6, #2d3851);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

.btn-large {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.link-btn {
    background: none;
    border: none;
    color: #80b4e1;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: underline;
}

.link-btn:hover {
    color: #3b496e;
}

/* Main App Layout */
#mainApp {
    align-items: flex-start;
    padding-top: 0;
}

.app-header {
    margin-bottom: 2rem;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #3b496e;
}

.app-header p {
    color: #6b7280;
    margin-bottom: 1rem;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

/* New Layout Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* Left Column Styles */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Right Column Styles */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Card Styles */
.card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(59, 73, 110, 0.1);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #3b496e;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin-bottom: 0;
}

/* Compact Card for Top Section */
.compact-card {
    background: white;
    padding: 1rem;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
    margin-bottom: 1rem;
}

.compact-card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #3b496e;
}

/* Top Section Layout */
.top-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .top-section {
        grid-template-columns: 1fr;
    }
}

/* Status Indicators */
.status-indicator {
    margin-bottom: 0.75rem;
}

.loading {
    color: #6b7280;
    font-style: italic;
}

.status-success {
    background: #f0fdf4;
    color: #166534;
    padding: 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #bbf7d0;
    font-size: 0.875rem;
}

.status-error {
    background: #fef2f2;
    color: #b91c1c;
    padding: 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #fecaca;
    font-size: 0.875rem;
}

.help-text {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Connection Status */
.connection-status {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.connection-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background: #f8f9fc;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

/* PPE Code Management */
.ppe-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ppe-add {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.ppe-codes-list {
    max-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ppe-code-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fc;
    padding: 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
    font-size: 0.75rem;
}

.ppe-remove-btn {
    color: #dc2626;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ppe-remove-btn:hover {
    color: #991b1b;
}

/* Upload Area - Made Smaller */
.upload-area {
    border: 2px dashed #80b4e1;
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    background: #f8fdff;
    transition: border-color 0.15s ease-in-out;
}

.upload-area:hover {
    border-color: #3b496e;
}

.upload-area.drag-over {
    border-color: #3b496e;
    background: #f0f8ff;
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.upload-title {
    font-size: 1rem;
    font-weight: 500;
    color: #3b496e;
    margin-bottom: 0.25rem;
}

.upload-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
}

/* File List */
.file-list {
    margin-top: 1rem;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fc;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
    margin-bottom: 0.5rem;
}

.file-info {
    display: flex;
    flex-direction: column;
}

.file-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #3b496e;
}

.file-size {
    font-size: 0.75rem;
    color: #6b7280;
}

.file-remove {
    color: #dc2626;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
}

.file-remove:hover {
    color: #991b1b;
    text-decoration: underline;
}

/* Analysis Summary */
.analysis-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.analysis-summary p {
    margin: 0;
    padding: 0.5rem;
    background: #f8f9fc;
    border-radius: 0.25rem;
    border-left: 3px solid #80b4e1;
}

#emailContent {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    background: white;
    border: 1px solid #80b4e1;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.email-actions {
    display: flex;
    gap: 0.5rem;
}

/* Guidance Buttons */
.guidance-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 73, 110, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    text-align: center;
    box-shadow: 0 10px 25px rgba(59, 73, 110, 0.2);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #80b4e1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Market Guidance */
.guidance-section {
    margin-bottom: 1.5rem;
}

.guidance-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #3b496e;
    margin-bottom: 0.5rem;
}

.guidance-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.guidance-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.875rem;
    color: #4b5563;
}

.guidance-list li:last-child {
    border-bottom: none;
}

.guidance-list li strong {
    color: #3b496e;
}