:root {
    --bg-base: #0f1115;
    --bg-surface: #1e2128;
    --bg-surface-hover: #2a2e37;
    --border: #333842;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.4;
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 13px; /* Slightly smaller overall */
}

canvas#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
    opacity: 0.6;
}

/* Typography */
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; }
.highlight { color: var(--accent); }
.text-mono { font-family: 'JetBrains Mono', monospace; }

/* Header */
.header {
    background: rgba(30, 33, 40, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon { width: 32px; height: 32px; border-radius: 8px; }
.logo-text { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.03em; }
.logo-accent { 
    background: linear-gradient(135deg, #a78bfa, #6366f1); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
}

.header-stats { display: flex; gap: 1rem; }
.stat-pill { background: var(--bg-surface); border: 1px solid var(--border); padding: 0.25rem 0.75rem; border-radius: 999px; display: flex; gap: 0.5rem; align-items: center; font-size: 0.875rem; }
.stat-pill.accent { border-color: var(--accent); background: rgba(99, 102, 241, 0.1); }
.stat-pill.accent .stat-value { color: #a78bfa; font-weight: 700; }
.stat-label { color: var(--text-secondary); }
.stat-value { font-weight: 600; font-family: 'JetBrains Mono', monospace; }

/* Main layout */
.main {
    max-width: 1600px; /* Wider to avoid horizontal scroll */
    margin: 0 auto;
    padding: 1rem; /* Compact padding */
}
.section { display: flex; flex-direction: column; gap: 2rem; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.section-header { text-align: center; max-width: 600px; margin: 0 auto; }
.cars-section .section-header { text-align: left; max-width: none; display: flex; justify-content: space-between; align-items: flex-end; }
.section-title { font-size: 2rem; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.75rem; justify-content: center; }
.cars-section .section-title { justify-content: flex-start; }
.section-subtitle { color: var(--text-secondary); font-size: 1.1rem; }

/* Upload Zone */
.upload-zone {
    background: rgba(30, 33, 40, 0.5);
    border: 2px dashed #4b5563;
    border-radius: var(--radius-lg);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}
.upload-zone::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at center, var(--accent-glow) 0%, transparent 70%); opacity: 0; transition: opacity 0.3s ease; z-index: 0; pointer-events: none; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: rgba(99, 102, 241, 0.05); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.upload-zone:hover::before, .upload-zone.dragover::before { opacity: 0.2; }
.upload-zone-inner { position: relative; z-index: 1; }
.upload-icon { margin-bottom: 1.5rem; display: inline-block; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.upload-title { font-size: 1.25rem; margin-bottom: 0.5rem; }
.upload-subtitle { color: var(--text-secondary); margin-bottom: 1rem; }
.upload-formats { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: #4b5563; background: #1f2937; display: inline-block; padding: 0.25rem 0.5rem; border-radius: 4px; }

/* Settings */
.settings-panel { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; max-width: 600px; margin: 0 auto; box-shadow: var(--shadow-md); }
.settings-title { font-size: 1rem; margin-bottom: 1rem; color: var(--text-secondary); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.setting-item { display: flex; flex-direction: column; gap: 0.5rem; }
.setting-label { font-size: 0.875rem; font-weight: 500; }
.range-container { display: flex; align-items: center; gap: 1rem; }
.range-input { flex: 1; accent-color: var(--accent); }
.range-value { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--accent); width: 40px; text-align: right; }
.select-input { background: var(--bg-base); border: 1px solid var(--border); color: var(--text-primary); padding: 0.5rem; border-radius: var(--radius-sm); outline: none; transition: border-color 0.2s; }
.select-input:focus { border-color: var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.875rem; cursor: pointer; transition: all 0.2s ease; border: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: white; box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: #374151; color: #9ca3af; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-secondary { background: var(--bg-surface-hover); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #374151; }
.btn-action { background: rgba(255, 255, 255, 0.1); color: white; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.75rem; border: 1px solid transparent; }
.btn-action:hover { background: var(--accent); }
.btn-action.analyzing { background: var(--info-bg); color: var(--info); border-color: var(--info); cursor: wait; }
.btn-action.success { background: var(--success-bg); color: var(--success); border-color: var(--success); }

/* Badges & Indicators */
.badge { background: var(--bg-surface-hover); border: 1px solid var(--border); padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.875rem; font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.status-dot.green { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.yellow { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-dot.red { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-dot.gray { background: #6b7280; }

.dmg-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; }
.dmg-1 { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.dmg-2 { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.dmg-3 { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.dmg-4 { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.dmg-5 { background: rgba(185, 28, 28, 0.4); color: #fca5a5; }

/* Progress container */
.progress-container { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.progress-header { display: flex; justify-content: space-between; font-weight: 600; }
.progress-count { font-family: 'JetBrains Mono', monospace; color: var(--accent); }
.progress-bar { height: 8px; background: var(--bg-base); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #a78bfa); width: 0%; transition: width 0.3s ease; border-radius: 4px; box-shadow: 0 0 10px rgba(167, 139, 250, 0.8); }

/* Summary */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.summary-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; display: flex; align-items: center; gap: 1.25rem; transition: transform 0.2s; }
.summary-card:hover { transform: translateY(-2px); border-color: #4b5563; }
.summary-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.summary-icon.green { background: var(--success-bg); color: var(--success); }
.summary-icon.blue { background: var(--info-bg); color: var(--info); }
.summary-icon.purple { background: rgba(167, 139, 250, 0.1); color: #a78bfa; }
.summary-icon.orange { background: var(--warning-bg); color: var(--warning); }
.summary-info { display: flex; flex-direction: column; }
.summary-value { font-size: 1.5rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; line-height: 1.2; }
.summary-label { color: var(--text-secondary); font-size: 0.875rem; }

/* Filters */
.filter-bar { display: flex; justify-content: space-between; gap: 1rem; background: var(--bg-surface); padding: 1rem; border-radius: var(--radius-md); border: 1px solid var(--border); flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box svg { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }
.search-input { width: 100%; background: var(--bg-base); border: 1px solid var(--border); color: white; padding: 0.5rem 1rem 0.5rem 2.5rem; border-radius: var(--radius-sm); font-size: 0.875rem; outline: none; transition: border-color 0.2s; }
.search-input:focus { border-color: var(--accent); }
.filter-chips { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 2px; }
.chip { background: var(--bg-base); border: 1px solid var(--border); color: var(--text-secondary); padding: 0.5rem 1rem; border-radius: 999px; font-size: 0.875rem; cursor: pointer; white-space: nowrap; transition: all 0.2s; font-weight: 500; }
.chip:hover { border-color: #6b7280; color: white; }
.chip.active { background: rgba(99, 102, 241, 0.1); border-color: var(--accent); color: #a78bfa; }

/* Table */
.table-container { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow-x: hidden; box-shadow: var(--shadow-md); width: 100%; }
.car-table { width: 100%; border-collapse: collapse; text-align: left; }
.car-table th { padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-weight: 600; font-size: 0.75rem; white-space: nowrap; background: rgba(15, 17, 21, 0.5); position: sticky; top: 0; z-index: 10; }
.car-table th.sortable { cursor: pointer; user-select: none; transition: color 0.2s; }
.car-table th.sortable:hover { color: white; }
.car-table th.sortable.active { color: var(--accent); }
.car-table td { padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--border); font-size: 0.75rem; vertical-align: middle; }
.car-table tr:last-child td { border-bottom: none; }
.car-table tr:hover { background: rgba(255, 255, 255, 0.02); }
.th-narrow { width: 40px; text-align: center; }

.td-model { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.td-money { font-family: 'JetBrains Mono', monospace; font-weight: 600; text-align: right; white-space: nowrap; }
.td-profit.positive { color: var(--success); text-shadow: 0 0 10px rgba(16, 185, 129, 0.4); }
.td-profit.negative { color: var(--danger); opacity: 0.7; }

/* Conf bar */
.conf-wrapper { display: flex; align-items: center; gap: 0.5rem; }
.conf-bar-bg { flex: 1; height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; min-width: 40px; overflow: hidden; }
.conf-fill { height: 100%; border-radius: 3px; }
.conf-val { font-size: 0.75rem; font-family: 'JetBrains Mono', monospace; color: var(--text-secondary); width: 3ch; text-align: right; }

.row-fade { opacity: 0.5; filter: grayscale(1); }
.row-profitable { background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.05), transparent); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; animation: modalFadeIn 0.3s forwards; }
.modal { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); width: 95%; max-width: 700px; max-height: 85vh; overflow-y: auto; position: relative; transform: scale(0.95); animation: modalScaleIn 0.3s forwards; box-shadow: var(--shadow-lg); }
@keyframes modalFadeIn { to { opacity: 1; } }
@keyframes modalScaleIn { to { transform: scale(1); } }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--text-secondary); font-size: 1.25rem; cursor: pointer; transition: color 0.2s; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { color: white; background: rgba(255, 255, 255, 0.1); }
.modal-content { padding: 1.25rem; }

/* Modal content layout */
.m-header { margin-bottom: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.m-title { font-size: 1.5rem; margin-bottom: 0.5rem; }
.m-badge-list { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 768px) { .m-grid { grid-template-columns: 1fr; } }

.m-panel { background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; }
.m-panel h3 { font-size: 1rem; margin-bottom: 0.75rem; color: #a78bfa; display: flex; align-items: center; gap: 0.4rem; }

.m-stats-list { display: flex; flex-direction: column; gap: 0.5rem; }
.m-stat { display: flex; justify-content: space-between; border-bottom: 1px dashed #333; padding-bottom: 0.4rem; }
.m-stat:last-child { border-bottom: none; }
.m-stat-label { color: var(--text-secondary); font-size: 0.8rem; }
.m-stat-val { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 0.8rem; }
.m-stat-val.highlight-green { color: var(--success); font-weight: 700; font-size: 1.1em; }
.m-stat-val.highlight-blue { color: #60a5fa; }

.m-source-link { display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 1rem; color: #60a5fa; text-decoration: none; font-size: 0.875rem; font-weight: 500; }
.m-source-link:hover { text-decoration: underline; }

/* Toast Notifications */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; display: flex; flex-direction: column; gap: 1rem; z-index: 2000; }
.toast { background: var(--bg-surface); border-left: 4px solid var(--accent); padding: 1rem 1.5rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); color: white; display: flex; align-items: center; gap: 0.75rem; animation: slideInX 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; max-width: 400px; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideInX { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-10px); } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #6b7280; }
