* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shopify: #95bf47;
    --zoho: #e44332;
    --merged: #8b5cf6;
    --grade-a: #059669;
    --grade-b: #0891b2;
    --grade-c: #f59e0b;
    --grade-d: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --header-height: 120px;
    --container-width: 1400px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-top: var(--header-height);
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.header-compact {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: grid;
    grid-template-columns: 240px 1fr auto;
    gap: 20px;
    align-items: center;
    padding: 12px 0;
}

.brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2px;
}

.stats-inline {
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 500;
}

.stats-inline span {
    color: var(--gray-900);
    font-weight: 700;
}

.search-bar {
    position: relative;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    padding: 10px 40px 10px 40px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: white;
    transition: all 0.2s;
    outline: none;
}

#searchInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-200);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: var(--gray-300);
}

.filters-inline {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-700);
    user-select: none;
    font-weight: 500;
    white-space: nowrap;
}

.filter-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    font-weight: 500;
    color: var(--gray-700);
}

.filter-select:focus {
    border-color: var(--primary);
}

.privacy-toggle {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
}

.privacy-toggle:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.privacy-toggle.active {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.privacy-toggle.active svg {
    opacity: 0.3;
}

.main-content {
    padding: 20px 0 60px;
    min-height: calc(100vh - var(--header-height));
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    border: 1px solid var(--gray-200);
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.product-info {
    padding: 12px 12px 0 12px;
}

.product-sku {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.grade-badge-inline {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.grade-badge-inline.grade-a { background: rgba(5, 150, 105, 0.15); color: var(--grade-a); }
.grade-badge-inline.grade-b { background: rgba(8, 145, 178, 0.15); color: var(--grade-b); }
.grade-badge-inline.grade-c { background: rgba(245, 158, 11, 0.15); color: var(--grade-c); }
.grade-badge-inline.grade-d { background: rgba(220, 38, 38, 0.15); color: var(--grade-d); }

.product-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.3;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 39px;
}

.product-image-container {
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--gray-100);
    position: relative;
    overflow: hidden;
}

.product-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
}

.product-image-placeholder svg {
    width: 40px;
    height: 40px;
    color: var(--gray-400);
}

.product-prices {
    padding: 12px;
    background: var(--gray-50);
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--gray-200);
}

.price-row:last-child {
    border-bottom: none;
}

.price-row.main {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12) 0%, rgba(37, 99, 235, 0.05) 100%);
    margin: -4px -4px 6px -4px;
    padding: 8px 6px;
    border-radius: 4px;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.price-row.cost {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(239, 68, 68, 0.05) 100%);
    margin: 2px -4px;
    padding: 5px 6px;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.price-row.discount {
    background: rgba(16, 185, 129, 0.06);
    margin: 2px -4px;
    padding: 4px 6px;
    border-radius: 4px;
}

.price-row.margin {
    background: rgba(245, 158, 11, 0.08);
    margin: 6px -4px -4px -4px;
    padding: 6px 6px;
    border-radius: 4px;
    font-weight: 600;
    border-top: 1px solid rgba(245, 158, 11, 0.2);
}

.price-label {
    font-size: 10px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.price-row.main .price-label {
    font-size: 11px;
    color: var(--primary);
    font-weight: 700;
}

.price-row.cost .price-label {
    color: var(--danger);
    font-weight: 700;
}

.price-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
}

.price-value.main-price {
    font-size: 17px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.3px;
}

.price-row.cost .price-value {
    color: var(--danger);
    font-weight: 700;
}

body.privacy-mode .price-row.cost,
body.privacy-mode .price-row.margin,
body.privacy-mode .grade-badge-inline {
    display: none;
}

.product-meta-compact {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--gray-200);
}

.badge-mini {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-shopify { background: rgba(149, 191, 71, 0.1); color: var(--shopify); }
.badge-zoho { background: rgba(228, 67, 50, 0.1); color: var(--zoho); }
.badge-merged { background: rgba(139, 92, 246, 0.1); color: var(--merged); }

.product-actions-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 0 12px 12px 12px;
}

.btn-mini {
    padding: 6px 8px;
    border: none;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary-mini {
    background: var(--primary);
    color: white;
}

.btn-primary-mini:hover {
    background: var(--primary-dark);
}

.btn-secondary-mini {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary-mini:hover {
    background: var(--gray-200);
}

.products-grid.compact-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.compact-view .product-card {
    display: grid;
    grid-template-columns: 2fr 80px 1fr auto;
    gap: 12px;
    padding: 12px;
}

.compact-view .product-info {
    padding: 0;
}

.compact-view .product-image-container {
    width: 80px;
    height: 60px;
    aspect-ratio: unset;
    border-radius: 4px;
    order: 2;
}

.compact-view .product-prices {
    padding: 0;
    background: transparent;
    order: 3;
}

.compact-view .product-meta-compact {
    padding: 0;
}

.compact-view .product-actions-compact {
    padding: 0;
    order: 4;
    display: flex;
    gap: 6px;
    align-items: center;
}

.compact-view .product-title {
    font-size: 14px;
    min-height: auto;
    -webkit-line-clamp: 1;
}

.compact-view .price-row {
    padding: 2px 0;
}

.compact-view .price-row.main {
    margin: 0 0 4px 0;
    padding: 4px 6px;
}

.compact-view .price-row.cost {
    margin: 2px 0;
    padding: 3px 6px;
}

.compact-view .price-row.discount {
    margin: 2px 0;
    padding: 3px 6px;
}

.compact-view .price-row.margin {
    margin: 4px 0 0 0;
    padding: 3px 6px;
}

.loading, .error-state {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-600);
}

.no-results svg {
    margin: 0 auto 16px;
    color: var(--gray-300);
}

.no-results p {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--gray-700);
}

.no-results small {
    font-size: 13px;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-900);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-section {
    margin-bottom: 8px;
}

.suggestion-section:last-child {
    margin-bottom: 0;
}

.suggestion-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    padding: 0 4px;
}

.suggestion-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    margin-bottom: 2px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    font-size: 13px;
    color: var(--gray-900);
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-item:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateX(4px);
}

@media (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    
    .header-content {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .search-bar {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 200px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .filters-inline {
        flex-wrap: wrap;
    }
    
    .compact-view .product-card {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
    }
    
    .compact-view .product-image-container {
        width: 100%;
        height: 120px;
        order: 2;
    }
    
    .compact-view .product-prices {
        order: 3;
    }
    
    .compact-view .product-actions-compact {
        order: 4;
    }
}

@media (min-width: 1400px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}
/* ============================================
   EDIT FUNCTIONALITY STYLES
   ============================================ */

/* Modified Items Link */
.modified-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}

.modified-link:hover {
    background: #e5e7eb;
}

.modified-count {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
}

/* Edit Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #111827;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.modal-body {
    padding: 24px;
}

.product-info {
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #6b7280;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.margin-preview {
    padding: 16px;
    background: #f0f9ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    margin-top: 20px;
}

.margin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.margin-row span {
    color: #1e40af;
    font-size: 14px;
}

.margin-row strong {
    color: #1e3a8a;
    font-size: 16px;
}

.grade-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}

.grade-a { background: #d1fae5; color: #065f46; }
.grade-b { background: #dbeafe; color: #1e40af; }
.grade-c { background: #fef3c7; color: #92400e; }
.grade-d { background: #fee2e2; color: #991b1b; }

.validation-error {
    padding: 12px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 14px;
    margin-top: 12px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* Edit Button in Product Card */
.edit-btn-mini {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-btn-mini:hover {
    background: #2563eb;
}

.edit-btn-mini svg {
    flex-shrink: 0;
}

/* Sync Icon */
.sync-icon {
    display: inline-block;
    margin-left: 8px;
    font-size: 14px;
    cursor: help;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Clickable SKU */
.product-sku span:first-child {
    transition: all 0.2s;
}

.product-sku span:first-child:hover {
    color: #3b82f6;
    text-decoration: underline;
}


/* Save Button Loading State */
.btn-primary {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-spinner {
    display: none;
    align-items: center;
    gap: 8px;
}

.spinner {
    animation: spin 1s linear infinite;
}

.spinner circle:last-child {
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dashoffset: 44;
    }
    50% {
        stroke-dashoffset: 11;
    }
    100% {
        stroke-dashoffset: 44;
    }
}
