:root {
    /* Light Theme (Default) */
    --bg-app: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --radius-md: 8px;
    --radius-lg: 12px;
}

[data-theme="dark"] {
    --bg-app: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}

.app-title { font-size: 1.25rem; font-weight: 700; }
.text-primary { color: var(--primary); }

.nav-menu { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.nav-btn:hover { background-color: var(--bg-surface-hover); color: var(--text-main); }
.nav-btn.active { background-color: rgba(79, 70, 229, 0.1); color: var(--primary); }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 1rem; }
.version { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-top: 1rem; }

/* Main Content */
.main-content {
    flex: 1;
    padding: 2.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.header-content { margin-bottom: 2rem; }
.header-content h2 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.header-content p { color: var(--text-muted); max-width: 600px; }
.text-muted { color: var(--text-muted); }

/* Panels */
.panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

/* Utilities */
.hidden { display: none !important; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mb-4 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.py-4 { padding: 1rem 0; }

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}
.alert-error { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }

/* Upload Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 4rem 2rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    background-color: var(--bg-app);
}
.drop-zone.dragover { border-color: var(--primary); background-color: rgba(79, 70, 229, 0.05); }
.upload-icon { color: var(--primary); margin-bottom: 1rem; }
.drop-text { font-size: 1.2rem; font-weight: 500; margin-bottom: 0.5rem; }
.divider-text { display: block; color: var(--text-muted); margin: 1rem 0; font-size: 0.9rem; text-transform: uppercase; }
.file-hints { margin-top: 1.5rem; color: var(--text-muted); font-size: 0.85rem; }

/* File Info */
.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}
.file-details { display: flex; align-items: center; gap: 0.75rem; }
.file-icon { color: var(--primary); }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; }
.btn-icon:hover { color: var(--danger); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 500;
    border-radius: var(--radius-md); cursor: pointer; transition: all 0.2s; border: none; font-family: inherit;
}
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background-color: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background-color: var(--bg-surface); border: 1px solid var(--border); color: var(--text-main); }
.btn-secondary:hover { background-color: var(--bg-surface-hover); }
.btn-outline { background-color: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background-color: var(--primary); color: white; }
.btn-block { width: 100%; }
.btn-large { padding: 1rem 2rem; font-size: 1.1rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* Processing Animation */
.processing-panel { text-align: center; padding: 4rem 2rem; }
.processing-animation { position: relative; width: 80px; height: 80px; margin: 0 auto 2rem; display: flex; align-items: center; justify-content: center; }
.pulse-ring { position: absolute; width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--primary); animation: pulse 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite; }
.scan-icon { color: var(--primary); position: relative; z-index: 2; }
.progress-container { width: 100%; max-width: 400px; height: 8px; background-color: var(--bg-app); border-radius: 4px; margin: 2rem auto; overflow: hidden; }
.progress-fill { height: 100%; background-color: var(--primary); width: 0%; transition: width 0.3s ease; }
.processing-steps { list-style: none; text-align: left; max-width: 300px; margin: 0 auto; color: var(--text-muted); font-size: 0.9rem; }
.processing-steps li { margin-bottom: 0.5rem; opacity: 0.5; transition: opacity 0.3s; }
.processing-steps li.active { opacity: 1; color: var(--primary); font-weight: 500; }

/* Dashboard */
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; display: flex; align-items: center; gap: 1rem; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: white; flex-shrink: 0; }
.bg-blue { background-color: var(--info); }
.bg-green { background-color: var(--success); }
.bg-red { background-color: var(--danger); }
.bg-yellow { background-color: var(--warning); }
.stat-info { display: flex; flex-direction: column; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.5rem; font-weight: 700; }

/* Charts */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.chart-panel h3 { margin-bottom: 1.5rem; font-size: 1.1rem; }
.chart-container { position: relative; height: 250px; width: 100%; }
.quality-legend { display: flex; gap: 1.5rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.legend-item { display: flex; flex-direction: column; }
.legend-item span { font-size: 0.85rem; color: var(--text-muted); }
.legend-item strong { font-size: 1.2rem; }

/* Download Center */
.download-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.dl-card { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius-md); text-decoration: none; color: var(--text-main); transition: all 0.2s; background-color: var(--bg-app); }
.dl-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.primary-dl { background-color: rgba(79, 70, 229, 0.05); border-color: rgba(79, 70, 229, 0.2); }
.primary-dl svg { color: var(--primary); }
.dl-info { display: flex; flex-direction: column; }
.dl-info span { font-size: 0.8rem; color: var(--text-muted); }

/* History Table */
.table-responsive { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; text-align: left; }
.history-table th, .history-table td { padding: 1rem; border-bottom: 1px solid var(--border); }
.history-table th { color: var(--text-muted); font-weight: 500; font-size: 0.9rem; }
.history-table tr:last-child td { border-bottom: none; }
.job-hash { font-family: monospace; color: var(--text-muted); background: var(--bg-app); padding: 0.2rem 0.5rem; border-radius: 4px; }

@keyframes pulse { 0% { transform: scale(0.9); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }

@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); padding: 1rem; }
    .nav-menu { flex-direction: row; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.5rem; }
    .nav-btn { width: auto; white-space: nowrap; }
    .sidebar-footer { display: none; }
    .main-content { padding: 1.5rem 1rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
}