/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(30, 30, 55, 0.7);
    --bg-card-hover: rgba(40, 40, 70, 0.8);
    --bg-input: rgba(20, 20, 40, 0.8);
    --border-color: rgba(100, 100, 180, 0.2);
    --border-active: rgba(120, 120, 255, 0.5);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0c0;
    --text-muted: #6a6a8a;
    --accent-blue: #4f7cff;
    --accent-blue-hover: #6b93ff;
    --accent-green: #3ecf8e;
    --accent-green-hover: #56dca1;
    --accent-red: #ef4444;
    --accent-red-hover: #f87171;
    --accent-purple: #a855f7;
    --accent-orange: #f59e0b;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #4f7cff 0%, #a855f7 100%);
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px rgba(79, 124, 255, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(79, 124, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(62, 207, 142, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ==================== LAYOUT ==================== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

/* ==================== HEADER ==================== */
.app-header {
    text-align: center;
    margin-bottom: 32px;
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--gradient-2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.app-header .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-active);
    box-shadow: var(--shadow-soft), var(--shadow-glow);
}

.card-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-blue);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon {
    font-size: 1rem;
}

/* ==================== GRID LAYOUT ==================== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

/* ==================== UPLOAD ZONE ==================== */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-input);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent-blue);
    background: rgba(79, 124, 255, 0.05);
}

.upload-zone .upload-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.7;
}

.upload-zone .upload-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.upload-zone .upload-text strong {
    color: var(--accent-blue);
    cursor: pointer;
}

.upload-zone .upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(62, 207, 142, 0.08);
    border: 1px solid rgba(62, 207, 142, 0.2);
    border-radius: var(--radius-sm);
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--accent-green);
}

.file-info .file-icon { font-size: 1.2rem; }

/* ==================== FORM ELEMENTS ==================== */
.form-group {
    margin-bottom: 14px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-select,
.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: var(--transition);
    outline: none;
}

.form-select:focus,
.form-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.15);
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--gradient-2);
    color: white;
    box-shadow: 0 4px 15px rgba(79, 124, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 124, 255, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-green) 0%, #20c997 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(62, 207, 142, 0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(62, 207, 142, 0.4);
}

.btn-danger {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-red);
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-red);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.82rem;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ==================== CUSTOM BRANDS ==================== */
.brand-input-row {
    display: flex;
    gap: 8px;
}

.brand-input-row .form-input {
    flex: 1;
}

.brand-list {
    max-height: 160px;
    overflow-y: auto;
    margin-top: 10px;
    border-radius: var(--radius-sm);
}

.brand-list::-webkit-scrollbar {
    width: 4px;
}

.brand-list::-webkit-scrollbar-track {
    background: transparent;
}

.brand-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.brand-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    font-size: 0.84rem;
    transition: var(--transition);
}

.brand-item:hover {
    border-color: var(--border-active);
    background: var(--bg-card-hover);
}

.brand-item .brand-name {
    color: var(--accent-blue);
    font-weight: 600;
}

.brand-item .brand-arrow {
    color: var(--text-muted);
    margin: 0 6px;
}

.brand-item .brand-model {
    color: var(--text-primary);
}

.brand-item .delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition);
    line-height: 1;
}

.brand-item .delete-btn:hover {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
}

.brand-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ==================== TABLE ==================== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    max-height: 400px;
    overflow-y: auto;
}

.table-wrapper::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-input);
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.preview-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.preview-table th {
    background: rgba(79, 124, 255, 0.12);
    color: var(--accent-blue);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.preview-table td {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(100, 100, 180, 0.08);
    color: var(--text-secondary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-table tr:hover td {
    background: rgba(79, 124, 255, 0.03);
    color: var(--text-primary);
}

/* ==================== STATUS / NOTIFICATIONS ==================== */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    margin-top: 12px;
    transition: var(--transition);
}

.status-bar.info {
    background: rgba(79, 124, 255, 0.08);
    border: 1px solid rgba(79, 124, 255, 0.2);
    color: var(--accent-blue);
}

.status-bar.success {
    background: rgba(62, 207, 142, 0.08);
    border: 1px solid rgba(62, 207, 142, 0.2);
    color: var(--accent-green);
}

.status-bar.error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.status-bar.warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--accent-orange);
}

/* ==================== STATS ==================== */
.stats-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

.stat-badge .stat-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.stat-badge.blue .stat-value { color: var(--accent-blue); }
.stat-badge.green .stat-value { color: var(--accent-green); }
.stat-badge.purple .stat-value { color: var(--accent-purple); }

/* ==================== PROGRESS BAR ==================== */
.progress-container {
    margin-top: 12px;
}

.progress-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-2);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ==================== SPINNER ==================== */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== HIDDEN ==================== */
.hidden {
    display: none !important;
}

/* ==================== FADE IN ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 640px) {
    .app-container {
        padding: 16px 12px 32px;
    }

    .app-header h1 {
        font-size: 1.4rem;
    }

    .card {
        padding: 16px 18px;
    }

    .stats-row {
        flex-direction: column;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
    }
}
